1.1 --- a/src/share/vm/memory/resourceArea.hpp Tue Jul 09 22:48:52 2013 +0200 1.2 +++ b/src/share/vm/memory/resourceArea.hpp Wed Jul 10 15:49:15 2013 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -83,6 +83,10 @@ 1.11 Chunk *_chunk; // saved arena chunk 1.12 char *_hwm, *_max; 1.13 size_t _size_in_bytes; 1.14 +#ifdef ASSERT 1.15 + Thread* _thread; 1.16 + ResourceMark* _previous_resource_mark; 1.17 +#endif //ASSERT 1.18 1.19 void initialize(Thread *thread) { 1.20 _area = thread->resource_area(); 1.21 @@ -92,6 +96,11 @@ 1.22 _size_in_bytes = _area->size_in_bytes(); 1.23 debug_only(_area->_nesting++;) 1.24 assert( _area->_nesting > 0, "must stack allocate RMs" ); 1.25 +#ifdef ASSERT 1.26 + _thread = thread; 1.27 + _previous_resource_mark = thread->current_resource_mark(); 1.28 + thread->set_current_resource_mark(this); 1.29 +#endif // ASSERT 1.30 } 1.31 public: 1.32 1.33 @@ -111,6 +120,17 @@ 1.34 _size_in_bytes = r->_size_in_bytes; 1.35 debug_only(_area->_nesting++;) 1.36 assert( _area->_nesting > 0, "must stack allocate RMs" ); 1.37 +#ifdef ASSERT 1.38 + Thread* thread = ThreadLocalStorage::thread(); 1.39 + if (thread != NULL) { 1.40 + _thread = thread; 1.41 + _previous_resource_mark = thread->current_resource_mark(); 1.42 + thread->set_current_resource_mark(this); 1.43 + } else { 1.44 + _thread = NULL; 1.45 + _previous_resource_mark = NULL; 1.46 + } 1.47 +#endif // ASSERT 1.48 } 1.49 1.50 void reset_to_mark() { 1.51 @@ -137,6 +157,11 @@ 1.52 assert( _area->_nesting > 0, "must stack allocate RMs" ); 1.53 debug_only(_area->_nesting--;) 1.54 reset_to_mark(); 1.55 +#ifdef ASSERT 1.56 + if (_thread != NULL) { 1.57 + _thread->set_current_resource_mark(_previous_resource_mark); 1.58 + } 1.59 +#endif // ASSERT 1.60 } 1.61 1.62