143 // relock objects if synchronization on them was eliminated. |
143 // relock objects if synchronization on them was eliminated. |
144 if (DoEscapeAnalysis) { |
144 if (DoEscapeAnalysis) { |
145 if (EliminateAllocations) { |
145 if (EliminateAllocations) { |
146 assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames"); |
146 assert (chunk->at(0)->scope() != NULL,"expect only compiled java frames"); |
147 GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects(); |
147 GrowableArray<ScopeValue*>* objects = chunk->at(0)->scope()->objects(); |
|
148 |
|
149 // The flag return_oop() indicates call sites which return oop |
|
150 // in compiled code. Such sites include java method calls, |
|
151 // runtime calls (for example, used to allocate new objects/arrays |
|
152 // on slow code path) and any other calls generated in compiled code. |
|
153 // It is not guaranteed that we can get such information here only |
|
154 // by analyzing bytecode in deoptimized frames. This is why this flag |
|
155 // is set during method compilation (see Compile::Process_OopMap_Node()). |
|
156 bool save_oop_result = chunk->at(0)->scope()->return_oop(); |
|
157 Handle return_value; |
|
158 if (save_oop_result) { |
|
159 // Reallocation may trigger GC. If deoptimization happened on return from |
|
160 // call which returns oop we need to save it since it is not in oopmap. |
|
161 oop result = deoptee.saved_oop_result(&map); |
|
162 assert(result == NULL || result->is_oop(), "must be oop"); |
|
163 return_value = Handle(thread, result); |
|
164 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer"); |
|
165 if (TraceDeoptimization) { |
|
166 tty->print_cr("SAVED OOP RESULT " INTPTR_FORMAT " in thread " INTPTR_FORMAT, result, thread); |
|
167 } |
|
168 } |
148 bool reallocated = false; |
169 bool reallocated = false; |
149 if (objects != NULL) { |
170 if (objects != NULL) { |
150 JRT_BLOCK |
171 JRT_BLOCK |
151 reallocated = realloc_objects(thread, &deoptee, objects, THREAD); |
172 reallocated = realloc_objects(thread, &deoptee, objects, THREAD); |
152 JRT_END |
173 JRT_END |
156 #ifndef PRODUCT |
177 #ifndef PRODUCT |
157 if (TraceDeoptimization) { |
178 if (TraceDeoptimization) { |
158 ttyLocker ttyl; |
179 ttyLocker ttyl; |
159 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread); |
180 tty->print_cr("REALLOC OBJECTS in thread " INTPTR_FORMAT, thread); |
160 print_objects(objects); |
181 print_objects(objects); |
161 } |
182 } |
162 #endif |
183 #endif |
|
184 } |
|
185 if (save_oop_result) { |
|
186 // Restore result. |
|
187 deoptee.set_saved_oop_result(&map, return_value()); |
163 } |
188 } |
164 } |
189 } |
165 if (EliminateLocks) { |
190 if (EliminateLocks) { |
166 #ifndef PRODUCT |
191 #ifndef PRODUCT |
167 bool first = true; |
192 bool first = true; |