1152 assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
1153 RegisterMap map(thread(), true);
1154 frame caller_fr = stub_fr.sender(&map);
1155
1156 // Should only be poll_return or poll
1157 assert( nm->is_at_poll_or_poll_return(real_return_addr), "should not be at call" );
1158
1159 // This is a poll immediately before a return. The exception handling code
1160 // has already had the effect of causing the return to occur, so the execution
1161 // will continue immediately after the call. In addition, the oopmap at the
1162 // return point does not mark the return value as an oop (if it is), so
1163 // it needs a handle here to be updated.
1164 if( nm->is_at_poll_return(real_return_addr) ) {
1165 ResourceMark rm;
1166 // See if return type is an oop.
1167 Method* method = nm->method();
1168 bool return_oop = method->may_return_oop();
1169
1170 GrowableArray<Handle> return_values;
1171 ValueKlass* vk = NULL;
1172 if (method->is_returning_vt() && ValueTypeReturnedAsFields) {
1173 // Check if value type is returned as fields
1174 vk = ValueKlass::returned_value_klass(map);
1175 if (vk != NULL) {
1176 // We're at a safepoint at the return of a method that returns
1177 // multiple values. We must make sure we preserve the oop values
1178 // across the safepoint.
1179 assert(vk == method->returned_value_type(thread()), "bad value klass");
1180 vk->save_oop_fields(map, return_values);
1181 return_oop = false;
1182 }
1183 }
1184
1185 if (return_oop) {
1186 // The oop result has been saved on the stack together with all
1187 // the other registers. In order to preserve it over GCs we need
1188 // to keep it in a handle.
1189 oop result = caller_fr.saved_oop_result(&map);
1190 assert(oopDesc::is_oop_or_null(result), "must be oop");
1191 return_values.push(Handle(thread(), result));
1192 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
1193 }
1194
1195 // Block the thread
1196 SafepointMechanism::block_if_requested(thread());
1197
1198 // restore oop result, if any
1199 if (return_oop) {
1200 assert(return_values.length() == 1, "only one return value");
1201 caller_fr.set_saved_oop_result(&map, return_values.pop()());
|
1152 assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
1153 RegisterMap map(thread(), true);
1154 frame caller_fr = stub_fr.sender(&map);
1155
1156 // Should only be poll_return or poll
1157 assert( nm->is_at_poll_or_poll_return(real_return_addr), "should not be at call" );
1158
1159 // This is a poll immediately before a return. The exception handling code
1160 // has already had the effect of causing the return to occur, so the execution
1161 // will continue immediately after the call. In addition, the oopmap at the
1162 // return point does not mark the return value as an oop (if it is), so
1163 // it needs a handle here to be updated.
1164 if( nm->is_at_poll_return(real_return_addr) ) {
1165 ResourceMark rm;
1166 // See if return type is an oop.
1167 Method* method = nm->method();
1168 bool return_oop = method->may_return_oop();
1169
1170 GrowableArray<Handle> return_values;
1171 ValueKlass* vk = NULL;
1172
1173 if (return_oop && ValueTypeReturnedAsFields) {
1174 SignatureStream ss(method->signature());
1175 while (!ss.at_return_type()) {
1176 ss.next();
1177 }
1178 if (ss.type() == T_VALUETYPE) {
1179 // Check if value type is returned as fields
1180 vk = ValueKlass::returned_value_klass(map);
1181 if (vk != NULL) {
1182 // We're at a safepoint at the return of a method that returns
1183 // multiple values. We must make sure we preserve the oop values
1184 // across the safepoint.
1185 assert(vk == method->returned_value_type(thread()), "bad value klass");
1186 vk->save_oop_fields(map, return_values);
1187 return_oop = false;
1188 }
1189 }
1190 }
1191
1192 if (return_oop) {
1193 // The oop result has been saved on the stack together with all
1194 // the other registers. In order to preserve it over GCs we need
1195 // to keep it in a handle.
1196 oop result = caller_fr.saved_oop_result(&map);
1197 assert(oopDesc::is_oop_or_null(result), "must be oop");
1198 return_values.push(Handle(thread(), result));
1199 assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
1200 }
1201
1202 // Block the thread
1203 SafepointMechanism::block_if_requested(thread());
1204
1205 // restore oop result, if any
1206 if (return_oop) {
1207 assert(return_values.length() == 1, "only one return value");
1208 caller_fr.set_saved_oop_result(&map, return_values.pop()());
|