--- old/src/share/vm/asm/codeBuffer.hpp 2014-08-22 16:43:38.774491794 -0400 +++ new/src/share/vm/asm/codeBuffer.hpp 2014-08-22 16:43:38.702489235 -0400 @@ -27,6 +27,7 @@ #include "code/oopRecorder.hpp" #include "code/relocInfo.hpp" +#include "utilities/debug.hpp" class CodeStrings; class PhaseCFG; @@ -245,15 +246,33 @@ private: #ifndef PRODUCT CodeString* _strings; + // Becomes true after copy-out, forbids further use. + bool _defunct; // Zero bit pattern is "valid", see memset call in decode_env::decode_env #endif CodeString* find(intptr_t offset) const; CodeString* find_last(intptr_t offset) const; + void set_null_and_invalidate() { +#ifdef ASSERT + _strings = NULL; + _defunct = true; +#endif + } + public: CodeStrings() { #ifndef PRODUCT _strings = NULL; + _defunct = false; +#endif + } + + bool isNull() { +#ifdef ASSERT + return _strings == NULL; +#else + return true; #endif } @@ -261,8 +280,17 @@ void add_comment(intptr_t offset, const char * comment) PRODUCT_RETURN; void print_block_comment(outputStream* stream, intptr_t offset) const PRODUCT_RETURN; + // MOVE strings from other to this; invalidate other. void assign(CodeStrings& other) PRODUCT_RETURN; + // COPY strings from other to this; leave other valid. + void copy(CodeStrings& other) PRODUCT_RETURN; void free() PRODUCT_RETURN; + // Guarantee that _strings are used at most once; assign invalidates a buffer. + inline void check_valid() const { +#ifdef ASSERT + assert(!_defunct, "Use of invalid CodeStrings"); +#endif + } }; // A CodeBuffer describes a memory space into which assembly @@ -533,6 +561,12 @@ OopRecorder* oop_recorder() const { return _oop_recorder; } CodeStrings& strings() { return _strings; } + void free_strings() { + if (!_strings.isNull()) { + _strings.free(); // sets _strings Null as a side-effect. + } + } + // Code generation void relocate(address at, RelocationHolder const& rspec, int format = 0) { _insts.relocate(at, rspec, format);