Mercurial > hg > graal-jvmci-8
comparison src/share/vm/prims/jvmtiRedefineClasses.cpp @ 7949:5daaddd917a1
8006040: NPG: on_stack processing wastes space in ConstantPool
Summary: Added on_stack bit to flags. Also MetadataMarkOnStack is used for more than JVMTI so had to be moved.
Reviewed-by: dholmes, stefank
author | coleenp |
---|---|
date | Wed, 23 Jan 2013 10:34:29 -0500 |
parents | b14da2e6f2dc |
children | 8b46b0196eb0 edd76a5856f7 |
comparison
equal
deleted
inserted
replaced
7632:2ef7061f13b4 | 7949:5daaddd917a1 |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "classfile/metadataOnStackMark.hpp" | |
26 #include "classfile/systemDictionary.hpp" | 27 #include "classfile/systemDictionary.hpp" |
27 #include "classfile/verifier.hpp" | 28 #include "classfile/verifier.hpp" |
28 #include "code/codeCache.hpp" | 29 #include "code/codeCache.hpp" |
29 #include "compiler/compileBroker.hpp" | 30 #include "compiler/compileBroker.hpp" |
30 #include "interpreter/oopMapCache.hpp" | 31 #include "interpreter/oopMapCache.hpp" |
112 } | 113 } |
113 | 114 |
114 RC_TIMER_STOP(_timer_vm_op_prologue); | 115 RC_TIMER_STOP(_timer_vm_op_prologue); |
115 return true; | 116 return true; |
116 } | 117 } |
117 | |
118 // Keep track of marked on-stack metadata so it can be cleared. | |
119 GrowableArray<Metadata*>* _marked_objects = NULL; | |
120 NOT_PRODUCT(bool MetadataOnStackMark::_is_active = false;) | |
121 | |
122 // Walk metadata on the stack and mark it so that redefinition doesn't delete | |
123 // it. Class unloading also walks the previous versions and might try to | |
124 // delete it, so this class is used by class unloading also. | |
125 MetadataOnStackMark::MetadataOnStackMark() { | |
126 assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); | |
127 NOT_PRODUCT(_is_active = true;) | |
128 if (_marked_objects == NULL) { | |
129 _marked_objects = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Metadata*>(1000, true); | |
130 } | |
131 Threads::metadata_do(Metadata::mark_on_stack); | |
132 CodeCache::alive_nmethods_do(nmethod::mark_on_stack); | |
133 CompileBroker::mark_on_stack(); | |
134 } | |
135 | |
136 MetadataOnStackMark::~MetadataOnStackMark() { | |
137 assert(SafepointSynchronize::is_at_safepoint(), "sanity check"); | |
138 // Unmark everything that was marked. Can't do the same walk because | |
139 // redefine classes messes up the code cache so the set of methods | |
140 // might not be the same. | |
141 for (int i = 0; i< _marked_objects->length(); i++) { | |
142 _marked_objects->at(i)->set_on_stack(false); | |
143 } | |
144 _marked_objects->clear(); // reuse growable array for next time. | |
145 NOT_PRODUCT(_is_active = false;) | |
146 } | |
147 | |
148 // Record which objects are marked so we can unmark the same objects. | |
149 void MetadataOnStackMark::record(Metadata* m) { | |
150 assert(_is_active, "metadata on stack marking is active"); | |
151 _marked_objects->push(m); | |
152 } | |
153 | |
154 | 118 |
155 void VM_RedefineClasses::doit() { | 119 void VM_RedefineClasses::doit() { |
156 Thread *thread = Thread::current(); | 120 Thread *thread = Thread::current(); |
157 | 121 |
158 if (UseSharedSpaces) { | 122 if (UseSharedSpaces) { |