comparison src/share/vm/code/stubs.hpp @ 8767:a5de0cc2f91c

8008555: Debugging code in compiled method sometimes leaks memory Summary: support for strings that have same life-time as code that uses them. Reviewed-by: kvn, twisti
author roland
date Mon, 18 Mar 2013 13:19:06 +0100
parents b9a9ed0f8eeb
children b9a918201d47 de6a9e811145 bdd155477289
comparison
equal deleted inserted replaced
8765:592f9722c72e 8767:a5de0cc2f91c
71 71
72 class Stub VALUE_OBJ_CLASS_SPEC { 72 class Stub VALUE_OBJ_CLASS_SPEC {
73 public: 73 public:
74 // Initialization/finalization 74 // Initialization/finalization
75 void initialize(int size, 75 void initialize(int size,
76 CodeComments& comments) { ShouldNotCallThis(); } // called to initialize/specify the stub's size 76 CodeStrings& strings) { ShouldNotCallThis(); } // called to initialize/specify the stub's size
77 void finalize() { ShouldNotCallThis(); } // called before the stub is deallocated 77 void finalize() { ShouldNotCallThis(); } // called before the stub is deallocated
78 78
79 // General info/converters 79 // General info/converters
80 int size() const { ShouldNotCallThis(); return 0; } // must return the size provided by initialize 80 int size() const { ShouldNotCallThis(); return 0; } // must return the size provided by initialize
81 static int code_size_to_size(int code_size) { ShouldNotCallThis(); return 0; } // computes the size given the code size 81 static int code_size_to_size(int code_size) { ShouldNotCallThis(); return 0; } // computes the size given the code size
105 105
106 class StubInterface: public CHeapObj<mtCode> { 106 class StubInterface: public CHeapObj<mtCode> {
107 public: 107 public:
108 // Initialization/finalization 108 // Initialization/finalization
109 virtual void initialize(Stub* self, int size, 109 virtual void initialize(Stub* self, int size,
110 CodeComments& comments) = 0; // called after creation (called twice if allocated via (request, commit)) 110 CodeStrings& strings) = 0; // called after creation (called twice if allocated via (request, commit))
111 virtual void finalize(Stub* self) = 0; // called before deallocation 111 virtual void finalize(Stub* self) = 0; // called before deallocation
112 112
113 // General info/converters 113 // General info/converters
114 virtual int size(Stub* self) const = 0; // the total size of the stub in bytes (must be a multiple of CodeEntryAlignment) 114 virtual int size(Stub* self) const = 0; // the total size of the stub in bytes (must be a multiple of CodeEntryAlignment)
115 virtual int code_size_to_size(int code_size) const = 0; // computes the total stub size in bytes given the code size in bytes 115 virtual int code_size_to_size(int code_size) const = 0; // computes the total stub size in bytes given the code size in bytes
134 static stub* cast(Stub* self) { return (stub*)self; } \ 134 static stub* cast(Stub* self) { return (stub*)self; } \
135 \ 135 \
136 public: \ 136 public: \
137 /* Initialization/finalization */ \ 137 /* Initialization/finalization */ \
138 virtual void initialize(Stub* self, int size, \ 138 virtual void initialize(Stub* self, int size, \
139 CodeComments& comments) { cast(self)->initialize(size, comments); } \ 139 CodeStrings& strings) { cast(self)->initialize(size, strings); } \
140 virtual void finalize(Stub* self) { cast(self)->finalize(); } \ 140 virtual void finalize(Stub* self) { cast(self)->finalize(); } \
141 \ 141 \
142 /* General info */ \ 142 /* General info */ \
143 virtual int size(Stub* self) const { return cast(self)->size(); } \ 143 virtual int size(Stub* self) const { return cast(self)->size(); } \
144 virtual int code_size_to_size(int code_size) const { return stub::code_size_to_size(code_size); } \ 144 virtual int code_size_to_size(int code_size) const { return stub::code_size_to_size(code_size); } \
174 Stub* stub_at(int i) const { check_index(i); return (Stub*)(_stub_buffer + i); } 174 Stub* stub_at(int i) const { check_index(i); return (Stub*)(_stub_buffer + i); }
175 Stub* current_stub() const { return stub_at(_queue_end); } 175 Stub* current_stub() const { return stub_at(_queue_end); }
176 176
177 // Stub functionality accessed via interface 177 // Stub functionality accessed via interface
178 void stub_initialize(Stub* s, int size, 178 void stub_initialize(Stub* s, int size,
179 CodeComments& comments) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size, comments); } 179 CodeStrings& strings) { assert(size % CodeEntryAlignment == 0, "size not aligned"); _stub_interface->initialize(s, size, strings); }
180 void stub_finalize(Stub* s) { _stub_interface->finalize(s); } 180 void stub_finalize(Stub* s) { _stub_interface->finalize(s); }
181 int stub_size(Stub* s) const { return _stub_interface->size(s); } 181 int stub_size(Stub* s) const { return _stub_interface->size(s); }
182 bool stub_contains(Stub* s, address pc) const { return _stub_interface->code_begin(s) <= pc && pc < _stub_interface->code_end(s); } 182 bool stub_contains(Stub* s, address pc) const { return _stub_interface->code_begin(s) <= pc && pc < _stub_interface->code_end(s); }
183 int stub_code_size_to_size(int code_size) const { return _stub_interface->code_size_to_size(code_size); } 183 int stub_code_size_to_size(int code_size) const { return _stub_interface->code_size_to_size(code_size); }
184 void stub_verify(Stub* s) { _stub_interface->verify(s); } 184 void stub_verify(Stub* s) { _stub_interface->verify(s); }
204 204
205 // Stub allocation (atomic transactions) 205 // Stub allocation (atomic transactions)
206 Stub* request_committed(int code_size); // request a stub that provides exactly code_size space for code 206 Stub* request_committed(int code_size); // request a stub that provides exactly code_size space for code
207 Stub* request(int requested_code_size); // request a stub with a (maximum) code space - locks the queue 207 Stub* request(int requested_code_size); // request a stub with a (maximum) code space - locks the queue
208 void commit (int committed_code_size, 208 void commit (int committed_code_size,
209 CodeComments& comments); // commit the previously requested stub - unlocks the queue 209 CodeStrings& strings); // commit the previously requested stub - unlocks the queue
210 210
211 // Stub deallocation 211 // Stub deallocation
212 void remove_first(); // remove the first stub in the queue 212 void remove_first(); // remove the first stub in the queue
213 void remove_first(int n); // remove the first n stubs in the queue 213 void remove_first(int n); // remove the first n stubs in the queue
214 void remove_all(); // remove all stubs in the queue 214 void remove_all(); // remove all stubs in the queue