1103 vf = vf->sender();
1104 frame_number++;
1105 }
1106 }
1107
1108 while (true) {
1109 // look for the given method
1110 while (true) {
1111 StackValueCollection* locals = NULL;
1112 if (vf->is_compiled_frame()) {
1113 // compiled method frame
1114 compiledVFrame* cvf = compiledVFrame::cast(vf);
1115 if (methods == NULL || matches(methods, cvf->method())) {
1116 if (initialSkip > 0) {
1117 initialSkip --;
1118 } else {
1119 ScopeDesc* scope = cvf->scope();
1120 // native wrapper do not have a scope
1121 if (scope != NULL && scope->objects() != NULL) {
1122 bool realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), scope->objects(), THREAD);
1123 Deoptimization::reassign_fields(fst.current(), fst.register_map(), scope->objects(), realloc_failures, false);
1124
1125 GrowableArray<ScopeValue*>* local_values = scope->locals();
1126 typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread);
1127 for (int i = 0; i < local_values->length(); i++) {
1128 ScopeValue* value = local_values->at(i);
1129 if (value->is_object()) {
1130 array->bool_at_put(i, true);
1131 }
1132 }
1133 HotSpotStackFrameReference::set_localIsVirtual(result, array());
1134 } else {
1135 HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
1136 }
1137
1138 locals = cvf->locals();
1139 HotSpotStackFrameReference::set_bci(result, cvf->bci());
1140 oop method = CompilerToVM::get_jvmci_method(cvf->method(), CHECK_NULL);
1141 HotSpotStackFrameReference::set_method(result, method);
1142 }
1143 }
1269 break;
1270 }
1271 vf = vf->sender();
1272 }
1273
1274 int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame);
1275 if (last_frame_number >= virtualFrames->length()) {
1276 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number")
1277 }
1278
1279 // Reallocate the non-escaping objects and restore their fields.
1280 assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope");
1281 GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects();
1282
1283 if (objects == NULL) {
1284 // no objects to materialize
1285 return;
1286 }
1287
1288 bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, THREAD);
1289 Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false);
1290
1291 for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) {
1292 compiledVFrame* cvf = virtualFrames->at(frame_index);
1293
1294 GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals();
1295 StackValueCollection* locals = cvf->locals();
1296
1297 if (locals != NULL) {
1298 for (int i2 = 0; i2 < locals->size(); i2++) {
1299 StackValue* var = locals->at(i2);
1300 if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) {
1301 jvalue val;
1302 val.l = (jobject) locals->at(i2)->get_obj()();
1303 cvf->update_local(T_OBJECT, i2, val);
1304 }
1305 }
1306 }
1307 }
1308
1309 // all locals are materialized by now
|
1103 vf = vf->sender();
1104 frame_number++;
1105 }
1106 }
1107
1108 while (true) {
1109 // look for the given method
1110 while (true) {
1111 StackValueCollection* locals = NULL;
1112 if (vf->is_compiled_frame()) {
1113 // compiled method frame
1114 compiledVFrame* cvf = compiledVFrame::cast(vf);
1115 if (methods == NULL || matches(methods, cvf->method())) {
1116 if (initialSkip > 0) {
1117 initialSkip --;
1118 } else {
1119 ScopeDesc* scope = cvf->scope();
1120 // native wrapper do not have a scope
1121 if (scope != NULL && scope->objects() != NULL) {
1122 bool realloc_failures = Deoptimization::realloc_objects(thread, fst.current(), scope->objects(), THREAD);
1123 Deoptimization::reassign_fields(fst.current(), fst.register_map(), scope->objects(), realloc_failures, false, THREAD);
1124
1125 GrowableArray<ScopeValue*>* local_values = scope->locals();
1126 typeArrayHandle array = oopFactory::new_boolArray(local_values->length(), thread);
1127 for (int i = 0; i < local_values->length(); i++) {
1128 ScopeValue* value = local_values->at(i);
1129 if (value->is_object()) {
1130 array->bool_at_put(i, true);
1131 }
1132 }
1133 HotSpotStackFrameReference::set_localIsVirtual(result, array());
1134 } else {
1135 HotSpotStackFrameReference::set_localIsVirtual(result, NULL);
1136 }
1137
1138 locals = cvf->locals();
1139 HotSpotStackFrameReference::set_bci(result, cvf->bci());
1140 oop method = CompilerToVM::get_jvmci_method(cvf->method(), CHECK_NULL);
1141 HotSpotStackFrameReference::set_method(result, method);
1142 }
1143 }
1269 break;
1270 }
1271 vf = vf->sender();
1272 }
1273
1274 int last_frame_number = HotSpotStackFrameReference::frameNumber(hs_frame);
1275 if (last_frame_number >= virtualFrames->length()) {
1276 THROW_MSG(vmSymbols::java_lang_IllegalStateException(), "invalid frame number")
1277 }
1278
1279 // Reallocate the non-escaping objects and restore their fields.
1280 assert (virtualFrames->at(last_frame_number)->scope() != NULL,"invalid scope");
1281 GrowableArray<ScopeValue*>* objects = virtualFrames->at(last_frame_number)->scope()->objects();
1282
1283 if (objects == NULL) {
1284 // no objects to materialize
1285 return;
1286 }
1287
1288 bool realloc_failures = Deoptimization::realloc_objects(thread, fstAfterDeopt.current(), objects, THREAD);
1289 Deoptimization::reassign_fields(fstAfterDeopt.current(), fstAfterDeopt.register_map(), objects, realloc_failures, false, THREAD);
1290
1291 for (int frame_index = 0; frame_index < virtualFrames->length(); frame_index++) {
1292 compiledVFrame* cvf = virtualFrames->at(frame_index);
1293
1294 GrowableArray<ScopeValue*>* scopeLocals = cvf->scope()->locals();
1295 StackValueCollection* locals = cvf->locals();
1296
1297 if (locals != NULL) {
1298 for (int i2 = 0; i2 < locals->size(); i2++) {
1299 StackValue* var = locals->at(i2);
1300 if (var->type() == T_OBJECT && scopeLocals->at(i2)->is_object()) {
1301 jvalue val;
1302 val.l = (jobject) locals->at(i2)->get_obj()();
1303 cvf->update_local(T_OBJECT, i2, val);
1304 }
1305 }
1306 }
1307 }
1308
1309 // all locals are materialized by now
|