hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp
changeset 46271 979ebd346ecf
parent 42861 1d4dfdf4390b
child 46289 1904e7ec236e
equal deleted inserted replaced
46270:2e7898927798 46271:979ebd346ecf
     1 /*
     1 /*
     2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    57 VMReg getVMRegFromLocation(Handle location, int total_frame_size, TRAPS) {
    57 VMReg getVMRegFromLocation(Handle location, int total_frame_size, TRAPS) {
    58   if (location.is_null()) {
    58   if (location.is_null()) {
    59     THROW_NULL(vmSymbols::java_lang_NullPointerException());
    59     THROW_NULL(vmSymbols::java_lang_NullPointerException());
    60   }
    60   }
    61 
    61 
    62   Handle reg = code_Location::reg(location);
    62   Handle reg(THREAD, code_Location::reg(location));
    63   jint offset = code_Location::offset(location);
    63   jint offset = code_Location::offset(location);
    64 
    64 
    65   if (reg.not_null()) {
    65   if (reg.not_null()) {
    66     // register
    66     // register
    67     jint number = code_Register::number(reg);
    67     jint number = code_Register::number(reg);
    93   }
    93   }
    94 }
    94 }
    95 
    95 
    96 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo
    96 // creates a HotSpot oop map out of the byte arrays provided by DebugInfo
    97 OopMap* CodeInstaller::create_oop_map(Handle debug_info, TRAPS) {
    97 OopMap* CodeInstaller::create_oop_map(Handle debug_info, TRAPS) {
    98   Handle reference_map = DebugInfo::referenceMap(debug_info);
    98   Handle reference_map(THREAD, DebugInfo::referenceMap(debug_info));
    99   if (reference_map.is_null()) {
    99   if (reference_map.is_null()) {
   100     THROW_NULL(vmSymbols::java_lang_NullPointerException());
   100     THROW_NULL(vmSymbols::java_lang_NullPointerException());
   101   }
   101   }
   102   if (!reference_map->is_a(HotSpotReferenceMap::klass())) {
   102   if (!reference_map->is_a(HotSpotReferenceMap::klass())) {
   103     JVMCI_ERROR_NULL("unknown reference map: %s", reference_map->klass()->signature_name());
   103     JVMCI_ERROR_NULL("unknown reference map: %s", reference_map->klass()->signature_name());
   104   }
   104   }
   105   if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) {
   105   if (HotSpotReferenceMap::maxRegisterSize(reference_map) > 16) {
   106     _has_wide_vector = true;
   106     _has_wide_vector = true;
   107   }
   107   }
   108   OopMap* map = new OopMap(_total_frame_size, _parameter_count);
   108   OopMap* map = new OopMap(_total_frame_size, _parameter_count);
   109   objArrayHandle objects = HotSpotReferenceMap::objects(reference_map);
   109   objArrayHandle objects(THREAD, HotSpotReferenceMap::objects(reference_map));
   110   objArrayHandle derivedBase = HotSpotReferenceMap::derivedBase(reference_map);
   110   objArrayHandle derivedBase(THREAD, HotSpotReferenceMap::derivedBase(reference_map));
   111   typeArrayHandle sizeInBytes = HotSpotReferenceMap::sizeInBytes(reference_map);
   111   typeArrayHandle sizeInBytes(THREAD, HotSpotReferenceMap::sizeInBytes(reference_map));
   112   if (objects.is_null() || derivedBase.is_null() || sizeInBytes.is_null()) {
   112   if (objects.is_null() || derivedBase.is_null() || sizeInBytes.is_null()) {
   113     THROW_NULL(vmSymbols::java_lang_NullPointerException());
   113     THROW_NULL(vmSymbols::java_lang_NullPointerException());
   114   }
   114   }
   115   if (objects->length() != derivedBase->length() || objects->length() != sizeInBytes->length()) {
   115   if (objects->length() != derivedBase->length() || objects->length() != sizeInBytes->length()) {
   116     JVMCI_ERROR_NULL("arrays in reference map have different sizes: %d %d %d", objects->length(), derivedBase->length(), sizeInBytes->length());
   116     JVMCI_ERROR_NULL("arrays in reference map have different sizes: %d %d %d", objects->length(), derivedBase->length(), sizeInBytes->length());
   117   }
   117   }
   118   for (int i = 0; i < objects->length(); i++) {
   118   for (int i = 0; i < objects->length(); i++) {
   119     Handle location = objects->obj_at(i);
   119     Handle location(THREAD, objects->obj_at(i));
   120     Handle baseLocation = derivedBase->obj_at(i);
   120     Handle baseLocation(THREAD, derivedBase->obj_at(i));
   121     int bytes = sizeInBytes->int_at(i);
   121     int bytes = sizeInBytes->int_at(i);
   122 
   122 
   123     VMReg vmReg = getVMRegFromLocation(location, _total_frame_size, CHECK_NULL);
   123     VMReg vmReg = getVMRegFromLocation(location, _total_frame_size, CHECK_NULL);
   124     if (baseLocation.not_null()) {
   124     if (baseLocation.not_null()) {
   125       // derived oop
   125       // derived oop
   147     } else {
   147     } else {
   148       JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d", bytes);
   148       JVMCI_ERROR_NULL("invalid oop size in ReferenceMap: %d", bytes);
   149     }
   149     }
   150   }
   150   }
   151 
   151 
   152   Handle callee_save_info = (oop) DebugInfo::calleeSaveInfo(debug_info);
   152   Handle callee_save_info(THREAD, (oop) DebugInfo::calleeSaveInfo(debug_info));
   153   if (callee_save_info.not_null()) {
   153   if (callee_save_info.not_null()) {
   154     objArrayHandle registers = RegisterSaveLayout::registers(callee_save_info);
   154     objArrayHandle registers(THREAD, RegisterSaveLayout::registers(callee_save_info));
   155     typeArrayHandle slots = RegisterSaveLayout::slots(callee_save_info);
   155     typeArrayHandle slots(THREAD, RegisterSaveLayout::slots(callee_save_info));
   156     for (jint i = 0; i < slots->length(); i++) {
   156     for (jint i = 0; i < slots->length(); i++) {
   157       Handle jvmci_reg = registers->obj_at(i);
   157       Handle jvmci_reg (THREAD, registers->obj_at(i));
   158       jint jvmci_reg_number = code_Register::number(jvmci_reg);
   158       jint jvmci_reg_number = code_Register::number(jvmci_reg);
   159       VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL);
   159       VMReg hotspot_reg = CodeInstaller::get_hotspot_reg(jvmci_reg_number, CHECK_NULL);
   160       // HotSpot stack slots are 4 bytes
   160       // HotSpot stack slots are 4 bytes
   161       jint jvmci_slot = slots->int_at(i);
   161       jint jvmci_slot = slots->int_at(i);
   162       jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word;
   162       jint hotspot_slot = jvmci_slot * VMRegImpl::slots_per_word;
   277   TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
   277   TRACE_jvmci_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string());
   278   return Klass::encode_klass(klass);
   278   return Klass::encode_klass(klass);
   279 }
   279 }
   280 #endif
   280 #endif
   281 
   281 
   282 Location::Type CodeInstaller::get_oop_type(Handle value) {
   282 Location::Type CodeInstaller::get_oop_type(Thread* thread, Handle value) {
   283   Handle valueKind = Value::valueKind(value);
   283   Handle valueKind(thread, Value::valueKind(value));
   284   Handle platformKind = ValueKind::platformKind(valueKind);
   284   Handle platformKind(thread, ValueKind::platformKind(valueKind));
   285 
   285 
   286   if (platformKind == word_kind()) {
   286   if (platformKind == word_kind()) {
   287     return Location::oop;
   287     return Location::oop;
   288   } else {
   288   } else {
   289     return Location::narrowoop;
   289     return Location::narrowoop;
   298     if (type != T_ILLEGAL) {
   298     if (type != T_ILLEGAL) {
   299       JVMCI_ERROR_NULL("unexpected illegal value, expected %s", basictype_to_str(type));
   299       JVMCI_ERROR_NULL("unexpected illegal value, expected %s", basictype_to_str(type));
   300     }
   300     }
   301     return _illegal_value;
   301     return _illegal_value;
   302   } else if (value->is_a(RegisterValue::klass())) {
   302   } else if (value->is_a(RegisterValue::klass())) {
   303     Handle reg = RegisterValue::reg(value);
   303     Handle reg(THREAD, RegisterValue::reg(value));
   304     jint number = code_Register::number(reg);
   304     jint number = code_Register::number(reg);
   305     VMReg hotspotRegister = get_hotspot_reg(number, CHECK_NULL);
   305     VMReg hotspotRegister = get_hotspot_reg(number, CHECK_NULL);
   306     if (is_general_purpose_reg(hotspotRegister)) {
   306     if (is_general_purpose_reg(hotspotRegister)) {
   307       Location::Type locationType;
   307       Location::Type locationType;
   308       if (type == T_OBJECT) {
   308       if (type == T_OBJECT) {
   309         locationType = get_oop_type(value);
   309         locationType = get_oop_type(THREAD, value);
   310       } else if (type == T_LONG) {
   310       } else if (type == T_LONG) {
   311         locationType = Location::lng;
   311         locationType = Location::lng;
   312       } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) {
   312       } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) {
   313         locationType = Location::int_in_long;
   313         locationType = Location::int_in_long;
   314       } else {
   314       } else {
   341       offset += _total_frame_size;
   341       offset += _total_frame_size;
   342     }
   342     }
   343 
   343 
   344     Location::Type locationType;
   344     Location::Type locationType;
   345     if (type == T_OBJECT) {
   345     if (type == T_OBJECT) {
   346       locationType = get_oop_type(value);
   346       locationType = get_oop_type(THREAD, value);
   347     } else if (type == T_LONG) {
   347     } else if (type == T_LONG) {
   348       locationType = Location::lng;
   348       locationType = Location::lng;
   349     } else if (type == T_DOUBLE) {
   349     } else if (type == T_DOUBLE) {
   350       locationType = Location::dbl;
   350       locationType = Location::dbl;
   351     } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) {
   351     } else if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BYTE || type == T_BOOLEAN) {
   362     if (value->is_a(PrimitiveConstant::klass())) {
   362     if (value->is_a(PrimitiveConstant::klass())) {
   363       if (value->is_a(RawConstant::klass())) {
   363       if (value->is_a(RawConstant::klass())) {
   364         jlong prim = PrimitiveConstant::primitive(value);
   364         jlong prim = PrimitiveConstant::primitive(value);
   365         return new ConstantLongValue(prim);
   365         return new ConstantLongValue(prim);
   366       } else {
   366       } else {
   367         BasicType constantType = JVMCIRuntime::kindToBasicType(PrimitiveConstant::kind(value), CHECK_NULL);
   367         Handle primitive_constant_kind(THREAD, PrimitiveConstant::kind(value));
       
   368         BasicType constantType = JVMCIRuntime::kindToBasicType(primitive_constant_kind, CHECK_NULL);
   368         if (type != constantType) {
   369         if (type != constantType) {
   369           JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType));
   370           JVMCI_ERROR_NULL("primitive constant type doesn't match, expected %s but got %s", basictype_to_str(type), basictype_to_str(constantType));
   370         }
   371         }
   371         if (type == T_INT || type == T_FLOAT) {
   372         if (type == T_INT || type == T_FLOAT) {
   372           jint prim = (jint)PrimitiveConstant::primitive(value);
   373           jint prim = (jint)PrimitiveConstant::primitive(value);
   419 
   420 
   420   JVMCI_ERROR_NULL("unexpected value in scope: %s", value->klass()->signature_name())
   421   JVMCI_ERROR_NULL("unexpected value in scope: %s", value->klass()->signature_name())
   421 }
   422 }
   422 
   423 
   423 void CodeInstaller::record_object_value(ObjectValue* sv, Handle value, GrowableArray<ScopeValue*>* objects, TRAPS) {
   424 void CodeInstaller::record_object_value(ObjectValue* sv, Handle value, GrowableArray<ScopeValue*>* objects, TRAPS) {
   424   Handle type = VirtualObject::type(value);
   425   // Might want a HandleMark here.
       
   426   Handle type(THREAD, VirtualObject::type(value));
   425   int id = VirtualObject::id(value);
   427   int id = VirtualObject::id(value);
   426   oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type);
   428   oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type);
   427   Klass* klass = java_lang_Class::as_Klass(javaMirror);
   429   Klass* klass = java_lang_Class::as_Klass(javaMirror);
   428   bool isLongArray = klass == Universe::longArrayKlassObj();
   430   bool isLongArray = klass == Universe::longArrayKlassObj();
   429 
   431 
   430   objArrayHandle values = VirtualObject::values(value);
   432   objArrayHandle values(THREAD, VirtualObject::values(value));
   431   objArrayHandle slotKinds = VirtualObject::slotKinds(value);
   433   objArrayHandle slotKinds(THREAD, VirtualObject::slotKinds(value));
   432   for (jint i = 0; i < values->length(); i++) {
   434   for (jint i = 0; i < values->length(); i++) {
       
   435     HandleMark hm(THREAD);
   433     ScopeValue* cur_second = NULL;
   436     ScopeValue* cur_second = NULL;
   434     Handle object = values->obj_at(i);
   437     Handle object(THREAD, values->obj_at(i));
   435     BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK);
   438     Handle slot_kind (THREAD, slotKinds->obj_at(i));
       
   439     BasicType type = JVMCIRuntime::kindToBasicType(slot_kind, CHECK);
   436     ScopeValue* value = get_scope_value(object, type, objects, cur_second, CHECK);
   440     ScopeValue* value = get_scope_value(object, type, objects, cur_second, CHECK);
   437 
   441 
   438     if (isLongArray && cur_second == NULL) {
   442     if (isLongArray && cur_second == NULL) {
   439       // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations.
   443       // we're trying to put ints into a long array... this isn't really valid, but it's used for some optimizations.
   440       // add an int 0 constant
   444       // add an int 0 constant
   456   if (!value->is_a(StackLockValue::klass())) {
   460   if (!value->is_a(StackLockValue::klass())) {
   457     JVMCI_ERROR_NULL("Monitors must be of type StackLockValue, got %s", value->klass()->signature_name());
   461     JVMCI_ERROR_NULL("Monitors must be of type StackLockValue, got %s", value->klass()->signature_name());
   458   }
   462   }
   459 
   463 
   460   ScopeValue* second = NULL;
   464   ScopeValue* second = NULL;
   461   ScopeValue* owner_value = get_scope_value(StackLockValue::owner(value), T_OBJECT, objects, second, CHECK_NULL);
   465   Handle stack_lock_owner(THREAD, StackLockValue::owner(value));
       
   466   ScopeValue* owner_value = get_scope_value(stack_lock_owner, T_OBJECT, objects, second, CHECK_NULL);
   462   assert(second == NULL, "monitor cannot occupy two stack slots");
   467   assert(second == NULL, "monitor cannot occupy two stack slots");
   463 
   468 
   464   ScopeValue* lock_data_value = get_scope_value(StackLockValue::slot(value), T_LONG, objects, second, CHECK_NULL);
   469   Handle stack_lock_slot(THREAD, StackLockValue::slot(value));
       
   470   ScopeValue* lock_data_value = get_scope_value(stack_lock_slot, T_LONG, objects, second, CHECK_NULL);
   465   assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots");
   471   assert(second == lock_data_value, "monitor is LONG value that occupies two stack slots");
   466   assert(lock_data_value->is_location(), "invalid monitor location");
   472   assert(lock_data_value->is_location(), "invalid monitor location");
   467   Location lock_data_loc = ((LocationValue*)lock_data_value)->location();
   473   Location lock_data_loc = ((LocationValue*)lock_data_value)->location();
   468 
   474 
   469   bool eliminated = false;
   475   bool eliminated = false;
   474   return new MonitorValue(owner_value, lock_data_loc, eliminated);
   480   return new MonitorValue(owner_value, lock_data_loc, eliminated);
   475 }
   481 }
   476 
   482 
   477 void CodeInstaller::initialize_dependencies(oop compiled_code, OopRecorder* recorder, TRAPS) {
   483 void CodeInstaller::initialize_dependencies(oop compiled_code, OopRecorder* recorder, TRAPS) {
   478   JavaThread* thread = JavaThread::current();
   484   JavaThread* thread = JavaThread::current();
       
   485   assert(THREAD == thread, "");
   479   CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL;
   486   CompilerThread* compilerThread = thread->is_Compiler_thread() ? thread->as_CompilerThread() : NULL;
   480   _oop_recorder = recorder;
   487   _oop_recorder = recorder;
   481   _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL);
   488   _dependencies = new Dependencies(&_arena, _oop_recorder, compilerThread != NULL ? compilerThread->log() : NULL);
   482   objArrayHandle assumptions = HotSpotCompiledCode::assumptions(compiled_code);
   489   objArrayHandle assumptions(THREAD, HotSpotCompiledCode::assumptions(compiled_code));
   483   if (!assumptions.is_null()) {
   490   if (!assumptions.is_null()) {
   484     int length = assumptions->length();
   491     int length = assumptions->length();
   485     for (int i = 0; i < length; ++i) {
   492     for (int i = 0; i < length; ++i) {
   486       Handle assumption = assumptions->obj_at(i);
   493       Handle assumption(THREAD, assumptions->obj_at(i));
   487       if (!assumption.is_null()) {
   494       if (!assumption.is_null()) {
   488         if (assumption->klass() == Assumptions_NoFinalizableSubclass::klass()) {
   495         if (assumption->klass() == Assumptions_NoFinalizableSubclass::klass()) {
   489           assumption_NoFinalizableSubclass(assumption);
   496           assumption_NoFinalizableSubclass(THREAD, assumption);
   490         } else if (assumption->klass() == Assumptions_ConcreteSubtype::klass()) {
   497         } else if (assumption->klass() == Assumptions_ConcreteSubtype::klass()) {
   491           assumption_ConcreteSubtype(assumption);
   498           assumption_ConcreteSubtype(THREAD, assumption);
   492         } else if (assumption->klass() == Assumptions_LeafType::klass()) {
   499         } else if (assumption->klass() == Assumptions_LeafType::klass()) {
   493           assumption_LeafType(assumption);
   500           assumption_LeafType(THREAD, assumption);
   494         } else if (assumption->klass() == Assumptions_ConcreteMethod::klass()) {
   501         } else if (assumption->klass() == Assumptions_ConcreteMethod::klass()) {
   495           assumption_ConcreteMethod(assumption);
   502           assumption_ConcreteMethod(THREAD, assumption);
   496         } else if (assumption->klass() == Assumptions_CallSiteTargetValue::klass()) {
   503         } else if (assumption->klass() == Assumptions_CallSiteTargetValue::klass()) {
   497           assumption_CallSiteTargetValue(assumption);
   504           assumption_CallSiteTargetValue(THREAD, assumption);
   498         } else {
   505         } else {
   499           JVMCI_ERROR("unexpected Assumption subclass %s", assumption->klass()->signature_name());
   506           JVMCI_ERROR("unexpected Assumption subclass %s", assumption->klass()->signature_name());
   500         }
   507         }
   501       }
   508       }
   502     }
   509     }
   503   }
   510   }
   504   if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
   511   if (JvmtiExport::can_hotswap_or_post_breakpoint()) {
   505     objArrayHandle methods = HotSpotCompiledCode::methods(compiled_code);
   512     objArrayHandle methods(THREAD, HotSpotCompiledCode::methods(compiled_code));
   506     if (!methods.is_null()) {
   513     if (!methods.is_null()) {
   507       int length = methods->length();
   514       int length = methods->length();
   508       for (int i = 0; i < length; ++i) {
   515       for (int i = 0; i < length; ++i) {
   509         Handle method_handle = methods->obj_at(i);
   516         Handle method_handle(THREAD, methods->obj_at(i));
   510         methodHandle method = getMethodFromHotSpotMethod(method_handle());
   517         methodHandle method = getMethodFromHotSpotMethod(method_handle());
   511         _dependencies->assert_evol_method(method());
   518         _dependencies->assert_evol_method(method());
   512       }
   519       }
   513     }
   520     }
   514   }
   521   }
   637   return result;
   644   return result;
   638 }
   645 }
   639 
   646 
   640 void CodeInstaller::initialize_fields(oop target, oop compiled_code, TRAPS) {
   647 void CodeInstaller::initialize_fields(oop target, oop compiled_code, TRAPS) {
   641   if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) {
   648   if (compiled_code->is_a(HotSpotCompiledNmethod::klass())) {
   642     Handle hotspotJavaMethod = HotSpotCompiledNmethod::method(compiled_code);
   649     Handle hotspotJavaMethod(THREAD, HotSpotCompiledNmethod::method(compiled_code));
   643     methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod());
   650     methodHandle method = getMethodFromHotSpotMethod(hotspotJavaMethod());
   644     _parameter_count = method->size_of_parameters();
   651     _parameter_count = method->size_of_parameters();
   645     TRACE_jvmci_2("installing code for %s", method->name_and_sig_as_C_string());
   652     TRACE_jvmci_2("installing code for %s", method->name_and_sig_as_C_string());
   646   } else {
   653   } else {
   647     // Must be a HotSpotCompiledRuntimeStub.
   654     // Must be a HotSpotCompiledRuntimeStub.
   726 }
   733 }
   727 
   734 
   728 // perform data and call relocation on the CodeBuffer
   735 // perform data and call relocation on the CodeBuffer
   729 JVMCIEnv::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, TRAPS) {
   736 JVMCIEnv::CodeInstallResult CodeInstaller::initialize_buffer(CodeBuffer& buffer, TRAPS) {
   730   HandleMark hm;
   737   HandleMark hm;
   731   objArrayHandle sites = this->sites();
   738   objArrayHandle sites(THREAD, this->sites());
   732   int locs_buffer_size = sites->length() * (relocInfo::length_limit + sizeof(relocInfo));
   739   int locs_buffer_size = sites->length() * (relocInfo::length_limit + sizeof(relocInfo));
   733 
   740 
   734   // Allocate enough space in the stub section for the static call
   741   // Allocate enough space in the stub section for the static call
   735   // stubs.  Stubs have extra relocs but they are managed by the stub
   742   // stubs.  Stubs have extra relocs but they are managed by the stub
   736   // section itself so they don't need to be accounted for in the
   743   // section itself so they don't need to be accounted for in the
   764   guarantee(_instructions->allocates2(end_pc), "initialize should have reserved enough space for all the code");
   771   guarantee(_instructions->allocates2(end_pc), "initialize should have reserved enough space for all the code");
   765   memcpy(_instructions->start(), code()->base(T_BYTE), _code_size);
   772   memcpy(_instructions->start(), code()->base(T_BYTE), _code_size);
   766   _instructions->set_end(end_pc);
   773   _instructions->set_end(end_pc);
   767 
   774 
   768   for (int i = 0; i < data_section_patches()->length(); i++) {
   775   for (int i = 0; i < data_section_patches()->length(); i++) {
   769     Handle patch = data_section_patches()->obj_at(i);
   776     HandleMark hm(THREAD);
       
   777     Handle patch(THREAD, data_section_patches()->obj_at(i));
   770     if (patch.is_null()) {
   778     if (patch.is_null()) {
   771       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   779       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   772     }
   780     }
   773     Handle reference = site_DataPatch::reference(patch);
   781     Handle reference(THREAD, site_DataPatch::reference(patch));
   774     if (reference.is_null()) {
   782     if (reference.is_null()) {
   775       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   783       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   776     }
   784     }
   777     if (!reference->is_a(site_ConstantReference::klass())) {
   785     if (!reference->is_a(site_ConstantReference::klass())) {
   778       JVMCI_ERROR_OK("invalid patch in data section: %s", reference->klass()->signature_name());
   786       JVMCI_ERROR_OK("invalid patch in data section: %s", reference->klass()->signature_name());
   779     }
   787     }
   780     Handle constant = site_ConstantReference::constant(reference);
   788     Handle constant(THREAD, site_ConstantReference::constant(reference));
   781     if (constant.is_null()) {
   789     if (constant.is_null()) {
   782       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   790       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   783     }
   791     }
   784     address dest = _constants->start() + site_Site::pcOffset(patch);
   792     address dest = _constants->start() + site_Site::pcOffset(patch);
   785     if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
   793     if (constant->is_a(HotSpotMetaspaceConstantImpl::klass())) {
   791 #endif
   799 #endif
   792       } else {
   800       } else {
   793         *((void**) dest) = record_metadata_reference(_constants, dest, constant, CHECK_OK);
   801         *((void**) dest) = record_metadata_reference(_constants, dest, constant, CHECK_OK);
   794       }
   802       }
   795     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
   803     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
   796       Handle obj = HotSpotObjectConstantImpl::object(constant);
   804       Handle obj(THREAD, HotSpotObjectConstantImpl::object(constant));
   797       jobject value = JNIHandles::make_local(obj());
   805       jobject value = JNIHandles::make_local(obj());
   798       int oop_index = _oop_recorder->find_index(value);
   806       int oop_index = _oop_recorder->find_index(value);
   799 
   807 
   800       if (HotSpotObjectConstantImpl::compressed(constant)) {
   808       if (HotSpotObjectConstantImpl::compressed(constant)) {
   801 #ifdef _LP64
   809 #ifdef _LP64
   810       JVMCI_ERROR_OK("invalid constant in data section: %s", constant->klass()->signature_name());
   818       JVMCI_ERROR_OK("invalid constant in data section: %s", constant->klass()->signature_name());
   811     }
   819     }
   812   }
   820   }
   813   jint last_pc_offset = -1;
   821   jint last_pc_offset = -1;
   814   for (int i = 0; i < sites->length(); i++) {
   822   for (int i = 0; i < sites->length(); i++) {
   815     Handle site = sites->obj_at(i);
   823     HandleMark hm(THREAD);
       
   824     Handle site(THREAD, sites->obj_at(i));
   816     if (site.is_null()) {
   825     if (site.is_null()) {
   817       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   826       THROW_(vmSymbols::java_lang_NullPointerException(), JVMCIEnv::ok);
   818     }
   827     }
   819 
   828 
   820     jint pc_offset = site_Site::pcOffset(site);
   829     jint pc_offset = site_Site::pcOffset(site);
   867   }
   876   }
   868 #endif
   877 #endif
   869   return JVMCIEnv::ok;
   878   return JVMCIEnv::ok;
   870 }
   879 }
   871 
   880 
   872 void CodeInstaller::assumption_NoFinalizableSubclass(Handle assumption) {
   881 void CodeInstaller::assumption_NoFinalizableSubclass(Thread* thread, Handle assumption) {
   873   Handle receiverType_handle = Assumptions_NoFinalizableSubclass::receiverType(assumption());
   882   Handle receiverType_handle (thread, Assumptions_NoFinalizableSubclass::receiverType(assumption()));
   874   Klass* receiverType = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(receiverType_handle));
   883   Klass* receiverType = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(receiverType_handle));
   875   _dependencies->assert_has_no_finalizable_subclasses(receiverType);
   884   _dependencies->assert_has_no_finalizable_subclasses(receiverType);
   876 }
   885 }
   877 
   886 
   878 void CodeInstaller::assumption_ConcreteSubtype(Handle assumption) {
   887 void CodeInstaller::assumption_ConcreteSubtype(Thread* thread, Handle assumption) {
   879   Handle context_handle = Assumptions_ConcreteSubtype::context(assumption());
   888   Handle context_handle (thread, Assumptions_ConcreteSubtype::context(assumption()));
   880   Handle subtype_handle = Assumptions_ConcreteSubtype::subtype(assumption());
   889   Handle subtype_handle (thread, Assumptions_ConcreteSubtype::subtype(assumption()));
   881   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   890   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   882   Klass* subtype = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(subtype_handle));
   891   Klass* subtype = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(subtype_handle));
   883 
   892 
   884   assert(context->is_abstract(), "");
   893   assert(context->is_abstract(), "");
   885   _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype);
   894   _dependencies->assert_abstract_with_unique_concrete_subtype(context, subtype);
   886 }
   895 }
   887 
   896 
   888 void CodeInstaller::assumption_LeafType(Handle assumption) {
   897 void CodeInstaller::assumption_LeafType(Thread* thread, Handle assumption) {
   889   Handle context_handle = Assumptions_LeafType::context(assumption());
   898   Handle context_handle (thread, Assumptions_LeafType::context(assumption()));
   890   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   899   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   891 
   900 
   892   _dependencies->assert_leaf_type(context);
   901   _dependencies->assert_leaf_type(context);
   893 }
   902 }
   894 
   903 
   895 void CodeInstaller::assumption_ConcreteMethod(Handle assumption) {
   904 void CodeInstaller::assumption_ConcreteMethod(Thread* thread, Handle assumption) {
   896   Handle impl_handle = Assumptions_ConcreteMethod::impl(assumption());
   905   Handle impl_handle (thread, Assumptions_ConcreteMethod::impl(assumption()));
   897   Handle context_handle = Assumptions_ConcreteMethod::context(assumption());
   906   Handle context_handle (thread, Assumptions_ConcreteMethod::context(assumption()));
   898 
   907 
   899   methodHandle impl = getMethodFromHotSpotMethod(impl_handle());
   908   methodHandle impl = getMethodFromHotSpotMethod(impl_handle());
   900   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   909   Klass* context = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(context_handle));
   901 
   910 
   902   _dependencies->assert_unique_concrete_method(context, impl());
   911   _dependencies->assert_unique_concrete_method(context, impl());
   903 }
   912 }
   904 
   913 
   905 void CodeInstaller::assumption_CallSiteTargetValue(Handle assumption) {
   914 void CodeInstaller::assumption_CallSiteTargetValue(Thread* thread, Handle assumption) {
   906   Handle callSite = Assumptions_CallSiteTargetValue::callSite(assumption());
   915   Handle callSite(thread, Assumptions_CallSiteTargetValue::callSite(assumption()));
   907   Handle methodHandle = Assumptions_CallSiteTargetValue::methodHandle(assumption());
   916   Handle methodHandle(thread, Assumptions_CallSiteTargetValue::methodHandle(assumption()));
   908 
   917 
   909   _dependencies->assert_call_site_target_value(callSite(), methodHandle());
   918   _dependencies->assert_call_site_target_value(callSite(), methodHandle());
   910 }
   919 }
   911 
   920 
   912 void CodeInstaller::site_ExceptionHandler(jint pc_offset, Handle exc) {
   921 void CodeInstaller::site_ExceptionHandler(jint pc_offset, Handle exc) {
   934     }
   943     }
   935   return true;
   944   return true;
   936 }
   945 }
   937 
   946 
   938 GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(Handle debug_info, TRAPS) {
   947 GrowableArray<ScopeValue*>* CodeInstaller::record_virtual_objects(Handle debug_info, TRAPS) {
   939   objArrayHandle virtualObjects = DebugInfo::virtualObjectMapping(debug_info);
   948   objArrayHandle virtualObjects(THREAD, DebugInfo::virtualObjectMapping(debug_info));
   940   if (virtualObjects.is_null()) {
   949   if (virtualObjects.is_null()) {
   941     return NULL;
   950     return NULL;
   942   }
   951   }
   943   GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL);
   952   GrowableArray<ScopeValue*>* objects = new GrowableArray<ScopeValue*>(virtualObjects->length(), virtualObjects->length(), NULL);
   944   // Create the unique ObjectValues
   953   // Create the unique ObjectValues
   945   for (int i = 0; i < virtualObjects->length(); i++) {
   954   for (int i = 0; i < virtualObjects->length(); i++) {
   946     Handle value = virtualObjects->obj_at(i);
   955     HandleMark hm(THREAD);
       
   956     Handle value(THREAD, virtualObjects->obj_at(i));
   947     int id = VirtualObject::id(value);
   957     int id = VirtualObject::id(value);
   948     Handle type = VirtualObject::type(value);
   958     Handle type(THREAD, VirtualObject::type(value));
   949     oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type);
   959     oop javaMirror = HotSpotResolvedObjectTypeImpl::javaClass(type);
   950     ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror)));
   960     ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(JNIHandles::make_local(Thread::current(), javaMirror)));
   951     if (id < 0 || id >= objects->length()) {
   961     if (id < 0 || id >= objects->length()) {
   952       JVMCI_ERROR_NULL("virtual object id %d out of bounds", id);
   962       JVMCI_ERROR_NULL("virtual object id %d out of bounds", id);
   953     }
   963     }
   957     objects->at_put(id, sv);
   967     objects->at_put(id, sv);
   958   }
   968   }
   959   // All the values which could be referenced by the VirtualObjects
   969   // All the values which could be referenced by the VirtualObjects
   960   // exist, so now describe all the VirtualObjects themselves.
   970   // exist, so now describe all the VirtualObjects themselves.
   961   for (int i = 0; i < virtualObjects->length(); i++) {
   971   for (int i = 0; i < virtualObjects->length(); i++) {
   962     Handle value = virtualObjects->obj_at(i);
   972     HandleMark hm(THREAD);
       
   973     Handle value(THREAD, virtualObjects->obj_at(i));
   963     int id = VirtualObject::id(value);
   974     int id = VirtualObject::id(value);
   964     record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL);
   975     record_object_value(objects->at(id)->as_ObjectValue(), value, objects, CHECK_NULL);
   965   }
   976   }
   966   _debug_recorder->dump_object_pool(objects);
   977   _debug_recorder->dump_object_pool(objects);
   967   return objects;
   978   return objects;
   968 }
   979 }
   969 
   980 
   970 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS) {
   981 void CodeInstaller::record_scope(jint pc_offset, Handle debug_info, ScopeMode scope_mode, bool return_oop, TRAPS) {
   971   Handle position = DebugInfo::bytecodePosition(debug_info);
   982   Handle position(THREAD, DebugInfo::bytecodePosition(debug_info));
   972   if (position.is_null()) {
   983   if (position.is_null()) {
   973     // Stubs do not record scope info, just oop maps
   984     // Stubs do not record scope info, just oop maps
   974     return;
   985     return;
   975   }
   986   }
   976 
   987 
   989     if (!position->is_a(BytecodeFrame::klass())) {
  1000     if (!position->is_a(BytecodeFrame::klass())) {
   990       JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset);
  1001       JVMCI_ERROR("Full frame expected for debug info at %i", pc_offset);
   991     }
  1002     }
   992     frame = position;
  1003     frame = position;
   993   }
  1004   }
   994   Handle caller_frame = BytecodePosition::caller(position);
  1005   Handle caller_frame (THREAD, BytecodePosition::caller(position));
   995   if (caller_frame.not_null()) {
  1006   if (caller_frame.not_null()) {
   996     record_scope(pc_offset, caller_frame, scope_mode, objects, return_oop, CHECK);
  1007     record_scope(pc_offset, caller_frame, scope_mode, objects, return_oop, CHECK);
   997   }
  1008   }
   998 
  1009 
   999   Handle hotspot_method = BytecodePosition::method(position);
  1010   Handle hotspot_method (THREAD, BytecodePosition::method(position));
  1000   Method* method = getMethodFromHotSpotMethod(hotspot_method());
  1011   Method* method = getMethodFromHotSpotMethod(hotspot_method());
  1001   jint bci = BytecodePosition::bci(position);
  1012   jint bci = BytecodePosition::bci(position);
  1002   if (bci == BytecodeFrame::BEFORE_BCI()) {
  1013   if (bci == BytecodeFrame::BEFORE_BCI()) {
  1003     bci = SynchronizationEntryBCI;
  1014     bci = SynchronizationEntryBCI;
  1004   }
  1015   }
  1025 
  1036 
  1026   if (frame.not_null()) {
  1037   if (frame.not_null()) {
  1027     jint local_count = BytecodeFrame::numLocals(frame);
  1038     jint local_count = BytecodeFrame::numLocals(frame);
  1028     jint expression_count = BytecodeFrame::numStack(frame);
  1039     jint expression_count = BytecodeFrame::numStack(frame);
  1029     jint monitor_count = BytecodeFrame::numLocks(frame);
  1040     jint monitor_count = BytecodeFrame::numLocks(frame);
  1030     objArrayHandle values = BytecodeFrame::values(frame);
  1041     objArrayHandle values(THREAD, BytecodeFrame::values(frame));
  1031     objArrayHandle slotKinds = BytecodeFrame::slotKinds(frame);
  1042     objArrayHandle slotKinds(THREAD, BytecodeFrame::slotKinds(frame));
  1032 
  1043 
  1033     if (values.is_null() || slotKinds.is_null()) {
  1044     if (values.is_null() || slotKinds.is_null()) {
  1034       THROW(vmSymbols::java_lang_NullPointerException());
  1045       THROW(vmSymbols::java_lang_NullPointerException());
  1035     }
  1046     }
  1036     if (local_count + expression_count + monitor_count != values->length()) {
  1047     if (local_count + expression_count + monitor_count != values->length()) {
  1046 
  1057 
  1047     TRACE_jvmci_2("Scope at bci %d with %d values", bci, values->length());
  1058     TRACE_jvmci_2("Scope at bci %d with %d values", bci, values->length());
  1048     TRACE_jvmci_2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
  1059     TRACE_jvmci_2("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
  1049 
  1060 
  1050     for (jint i = 0; i < values->length(); i++) {
  1061     for (jint i = 0; i < values->length(); i++) {
       
  1062       HandleMark hm(THREAD);
  1051       ScopeValue* second = NULL;
  1063       ScopeValue* second = NULL;
  1052       Handle value = values->obj_at(i);
  1064       Handle value(THREAD, values->obj_at(i));
  1053       if (i < local_count) {
  1065       if (i < local_count) {
  1054         BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK);
  1066         BasicType type = JVMCIRuntime::kindToBasicType(Handle(THREAD, slotKinds->obj_at(i)), CHECK);
  1055         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
  1067         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
  1056         if (second != NULL) {
  1068         if (second != NULL) {
  1057           locals->append(second);
  1069           locals->append(second);
  1058         }
  1070         }
  1059         locals->append(first);
  1071         locals->append(first);
  1060       } else if (i < local_count + expression_count) {
  1072       } else if (i < local_count + expression_count) {
  1061         BasicType type = JVMCIRuntime::kindToBasicType(slotKinds->obj_at(i), CHECK);
  1073         BasicType type = JVMCIRuntime::kindToBasicType(Handle(THREAD, slotKinds->obj_at(i)), CHECK);
  1062         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
  1074         ScopeValue* first = get_scope_value(value, type, objects, second, CHECK);
  1063         if (second != NULL) {
  1075         if (second != NULL) {
  1064           expressions->append(second);
  1076           expressions->append(second);
  1065         }
  1077         }
  1066         expressions->append(first);
  1078         expressions->append(first);
  1086   _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, return_oop,
  1098   _debug_recorder->describe_scope(pc_offset, method, NULL, bci, reexecute, throw_exception, false, return_oop,
  1087                                   locals_token, expressions_token, monitors_token);
  1099                                   locals_token, expressions_token, monitors_token);
  1088 }
  1100 }
  1089 
  1101 
  1090 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1102 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1091   Handle debug_info = site_Infopoint::debugInfo(site);
  1103   Handle debug_info (THREAD, site_Infopoint::debugInfo(site));
  1092   if (debug_info.is_null()) {
  1104   if (debug_info.is_null()) {
  1093     JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset);
  1105     JVMCI_ERROR("debug info expected at safepoint at %i", pc_offset);
  1094   }
  1106   }
  1095 
  1107 
  1096   // address instruction = _instructions->start() + pc_offset;
  1108   // address instruction = _instructions->start() + pc_offset;
  1100   record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
  1112   record_scope(pc_offset, debug_info, CodeInstaller::FullFrame, CHECK);
  1101   _debug_recorder->end_safepoint(pc_offset);
  1113   _debug_recorder->end_safepoint(pc_offset);
  1102 }
  1114 }
  1103 
  1115 
  1104 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1116 void CodeInstaller::site_Infopoint(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1105   Handle debug_info = site_Infopoint::debugInfo(site);
  1117   Handle debug_info (THREAD, site_Infopoint::debugInfo(site));
  1106   if (debug_info.is_null()) {
  1118   if (debug_info.is_null()) {
  1107     JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset);
  1119     JVMCI_ERROR("debug info expected at infopoint at %i", pc_offset);
  1108   }
  1120   }
  1109 
  1121 
  1110   // We'd like to check that pc_offset is greater than the
  1122   // We'd like to check that pc_offset is greater than the
  1115   record_scope(pc_offset, debug_info, CodeInstaller::BytecodePosition, CHECK);
  1127   record_scope(pc_offset, debug_info, CodeInstaller::BytecodePosition, CHECK);
  1116   _debug_recorder->end_non_safepoint(pc_offset);
  1128   _debug_recorder->end_non_safepoint(pc_offset);
  1117 }
  1129 }
  1118 
  1130 
  1119 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1131 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1120   Handle target = site_Call::target(site);
  1132   Handle target(THREAD, site_Call::target(site));
  1121   InstanceKlass* target_klass = InstanceKlass::cast(target->klass());
  1133   InstanceKlass* target_klass = InstanceKlass::cast(target->klass());
  1122 
  1134 
  1123   Handle hotspot_method; // JavaMethod
  1135   Handle hotspot_method; // JavaMethod
  1124   Handle foreign_call;
  1136   Handle foreign_call;
  1125 
  1137 
  1127     foreign_call = target;
  1139     foreign_call = target;
  1128   } else {
  1140   } else {
  1129     hotspot_method = target;
  1141     hotspot_method = target;
  1130   }
  1142   }
  1131 
  1143 
  1132   Handle debug_info = site_Call::debugInfo(site);
  1144   Handle debug_info (THREAD, site_Call::debugInfo(site));
  1133 
  1145 
  1134   assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type");
  1146   assert(hotspot_method.not_null() ^ foreign_call.not_null(), "Call site needs exactly one type");
  1135 
  1147 
  1136   NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);
  1148   NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);
  1137   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
  1149   jint next_pc_offset = CodeInstaller::pd_next_offset(inst, pc_offset, hotspot_method, CHECK);
  1175     _debug_recorder->end_safepoint(next_pc_offset);
  1187     _debug_recorder->end_safepoint(next_pc_offset);
  1176   }
  1188   }
  1177 }
  1189 }
  1178 
  1190 
  1179 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1191 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1180   Handle reference = site_DataPatch::reference(site);
  1192   Handle reference(THREAD, site_DataPatch::reference(site));
  1181   if (reference.is_null()) {
  1193   if (reference.is_null()) {
  1182     THROW(vmSymbols::java_lang_NullPointerException());
  1194     THROW(vmSymbols::java_lang_NullPointerException());
  1183   } else if (reference->is_a(site_ConstantReference::klass())) {
  1195   } else if (reference->is_a(site_ConstantReference::klass())) {
  1184     Handle constant = site_ConstantReference::constant(reference);
  1196     Handle constant(THREAD, site_ConstantReference::constant(reference));
  1185     if (constant.is_null()) {
  1197     if (constant.is_null()) {
  1186       THROW(vmSymbols::java_lang_NullPointerException());
  1198       THROW(vmSymbols::java_lang_NullPointerException());
  1187     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
  1199     } else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
  1188       if (!_immutable_pic_compilation) {
  1200       if (!_immutable_pic_compilation) {
  1189         // Do not patch during PIC compilation.
  1201         // Do not patch during PIC compilation.
  1211     JVMCI_ERROR("unknown data patch type: %s", reference->klass()->signature_name());
  1223     JVMCI_ERROR("unknown data patch type: %s", reference->klass()->signature_name());
  1212   }
  1224   }
  1213 }
  1225 }
  1214 
  1226 
  1215 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1227 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, Handle site, TRAPS) {
  1216   Handle id_obj = site_Mark::id(site);
  1228   Handle id_obj (THREAD, site_Mark::id(site));
  1217 
  1229 
  1218   if (id_obj.not_null()) {
  1230   if (id_obj.not_null()) {
  1219     if (!java_lang_boxing_object::is_instance(id_obj(), T_INT)) {
  1231     if (!java_lang_boxing_object::is_instance(id_obj(), T_INT)) {
  1220       JVMCI_ERROR("expected Integer id, got %s", id_obj->klass()->signature_name());
  1232       JVMCI_ERROR("expected Integer id, got %s", id_obj->klass()->signature_name());
  1221     }
  1233     }