< prev index next > src/hotspot/share/opto/runtime.cpp
Print this page
#include "interpreter/linkResolver.hpp"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
+ #include "oops/flatArrayKlass.hpp"
+ #include "oops/flatArrayOop.inline.hpp"
#include "oops/objArrayKlass.hpp"
#include "oops/klass.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/typeArrayOop.inline.hpp"
#include "opto/ad.hpp"
//=============================allocation======================================
// We failed the fast-path allocation. Now we need to do a scavenge or GC
// and try allocation again.
// object allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* current))
JRT_BLOCK;
#ifndef PRODUCT
SharedRuntime::_new_instance_ctr++; // new instance requires GC
#endif
assert(check_compiled_frame(current), "incorrect caller");
//=============================allocation======================================
// We failed the fast-path allocation. Now we need to do a scavenge or GC
// and try allocation again.
// object allocation
! JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, bool is_larval, JavaThread* current))
JRT_BLOCK;
#ifndef PRODUCT
SharedRuntime::_new_instance_ctr++; // new instance requires GC
#endif
assert(check_compiled_frame(current), "incorrect caller");
}
if (!HAS_PENDING_EXCEPTION) {
// Scavenge and allocate an instance.
Handle holder(current, klass->klass_holder()); // keep the klass alive
! oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
current->set_vm_result(result);
// Pass oops back through thread local storage. Our apparent type to Java
// is that we return an oop, but we can block on exit from this routine and
// a GC can trash the oop in C's return register. The generated stub will
}
if (!HAS_PENDING_EXCEPTION) {
// Scavenge and allocate an instance.
Handle holder(current, klass->klass_holder()); // keep the klass alive
! instanceOop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
+ if (is_larval) {
+ // Check if this is a larval buffer allocation
+ result->set_mark(result->mark().enter_larval_state());
+ }
current->set_vm_result(result);
// Pass oops back through thread local storage. Our apparent type to Java
// is that we return an oop, but we can block on exit from this routine and
// a GC can trash the oop in C's return register. The generated stub will
assert(check_compiled_frame(current), "incorrect caller");
// Scavenge and allocate an instance.
oop result;
! if (array_type->is_typeArray_klass()) {
// The oopFactory likes to work with the element type.
// (We could bypass the oopFactory, since it doesn't add much value.)
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray(elem_type, len, THREAD);
} else {
- // Although the oopFactory likes to work with the elem_type,
- // the compiler prefers the array_type, since it must already have
- // that latter value in hand for the fast path.
Handle holder(current, array_type->klass_holder()); // keep the array klass alive
! Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
- result = oopFactory::new_objArray(elem_type, len, THREAD);
}
// Pass oops back through thread local storage. Our apparent type to Java
// is that we return an oop, but we can block on exit from this routine and
// a GC can trash the oop in C's return register. The generated stub will
assert(check_compiled_frame(current), "incorrect caller");
// Scavenge and allocate an instance.
oop result;
! if (array_type->is_flatArray_klass()) {
+ Klass* elem_type = FlatArrayKlass::cast(array_type)->element_klass();
+ result = oopFactory::new_valueArray(elem_type, len, THREAD);
+ } else if (array_type->is_typeArray_klass()) {
// The oopFactory likes to work with the element type.
// (We could bypass the oopFactory, since it doesn't add much value.)
BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
result = oopFactory::new_typeArray(elem_type, len, THREAD);
} else {
Handle holder(current, array_type->klass_holder()); // keep the array klass alive
! result = ObjArrayKlass::cast(array_type)->allocate(len, THREAD);
}
// Pass oops back through thread local storage. Our apparent type to Java
// is that we return an oop, but we can block on exit from this routine and
// a GC can trash the oop in C's return register. The generated stub will
JRT_BLOCK_END;
JRT_END
const TypeFunc *OptoRuntime::new_instance_Type() {
// create input type (domain)
! const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
! const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
// create result type (range)
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
JRT_BLOCK_END;
JRT_END
const TypeFunc *OptoRuntime::new_instance_Type() {
// create input type (domain)
! const Type **fields = TypeTuple::fields(2);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
! fields[TypeFunc::Parms+1] = TypeInt::BOOL; // is_larval
+ const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
// create result type (range)
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain,range);
}
const TypeFunc *OptoRuntime::complete_monitor_locking_Type() {
return complete_monitor_enter_Type();
}
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::complete_monitor_locking_Type() {
return complete_monitor_enter_Type();
}
assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
frame caller_frame = stub_frame.sender(®_map);
return caller_frame.is_deoptimized_frame();
}
-
const TypeFunc *OptoRuntime::register_finalizer_Type() {
// create input type (domain)
const Type **fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
// // The JavaThread* is passed to each routine as the last argument
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain,range);
}
#if INCLUDE_JFR
const TypeFunc *OptoRuntime::class_id_load_barrier_Type() {
// create input type (domain)
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain, range);
}
#if INCLUDE_JFR
const TypeFunc *OptoRuntime::class_id_load_barrier_Type() {
// create input type (domain)
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain,range);
}
const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
// create input type (domain)
const Type **fields = TypeTuple::fields(2);
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain, range);
}
const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
// create input type (domain)
const Type **fields = TypeTuple::fields(2);
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain,range);
}
JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
assert(oopDesc::is_oop(obj), "must be a valid oop");
// create result type (range)
fields = TypeTuple::fields(0);
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
! return TypeFunc::make(domain, range);
}
JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer_C(oopDesc* obj, JavaThread* current))
assert(oopDesc::is_oop(obj), "must be a valid oop");
tempst.print(" at " INTPTR_FORMAT, p2i(exception_pc));
tempst.print("]");
st->print_raw_cr(tempst.freeze());
}
+
+ const TypeFunc *OptoRuntime::store_inline_type_fields_Type() {
+ // create input type (domain)
+ uint total = SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
+ const Type **fields = TypeTuple::fields(total);
+ // We don't know the number of returned values and their
+ // types. Assume all registers available to the return convention
+ // are used.
+ fields[TypeFunc::Parms] = TypePtr::BOTTOM;
+ uint i = 1;
+ for (; i < SharedRuntime::java_return_convention_max_int; i++) {
+ fields[TypeFunc::Parms+i] = TypeInt::INT;
+ }
+ for (; i < total; i+=2) {
+ fields[TypeFunc::Parms+i] = Type::DOUBLE;
+ fields[TypeFunc::Parms+i+1] = Type::HALF;
+ }
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
+
+ // create result type (range)
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
+
+ const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
+
+ return TypeFunc::make(domain, range);
+ }
+
+ const TypeFunc *OptoRuntime::pack_inline_type_Type() {
+ // create input type (domain)
+ uint total = 1 + SharedRuntime::java_return_convention_max_int + SharedRuntime::java_return_convention_max_float*2;
+ const Type **fields = TypeTuple::fields(total);
+ // We don't know the number of returned values and their
+ // types. Assume all registers available to the return convention
+ // are used.
+ fields[TypeFunc::Parms] = TypeRawPtr::BOTTOM;
+ fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM;
+ uint i = 2;
+ for (; i < SharedRuntime::java_return_convention_max_int+1; i++) {
+ fields[TypeFunc::Parms+i] = TypeInt::INT;
+ }
+ for (; i < total; i+=2) {
+ fields[TypeFunc::Parms+i] = Type::DOUBLE;
+ fields[TypeFunc::Parms+i+1] = Type::HALF;
+ }
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + total, fields);
+
+ // create result type (range)
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL;
+
+ const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1,fields);
+
+ return TypeFunc::make(domain, range);
+ }
+
+ JRT_BLOCK_ENTRY(void, OptoRuntime::load_unknown_inline_C(flatArrayOopDesc* array, int index, JavaThread* current))
+ JRT_BLOCK;
+ flatArrayHandle vah(current, array);
+ oop buffer = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, THREAD);
+ deoptimize_caller_frame(current, HAS_PENDING_EXCEPTION);
+ current->set_vm_result(buffer);
+ JRT_BLOCK_END;
+ JRT_END
+
+ const TypeFunc* OptoRuntime::load_unknown_inline_Type() {
+ // create input type (domain)
+ const Type** fields = TypeTuple::fields(2);
+ fields[TypeFunc::Parms] = TypeOopPtr::NOTNULL;
+ fields[TypeFunc::Parms+1] = TypeInt::POS;
+
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+2, fields);
+
+ // create result type (range)
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL;
+
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
+
+ return TypeFunc::make(domain, range);
+ }
+
+ JRT_LEAF(void, OptoRuntime::store_unknown_inline_C(instanceOopDesc* buffer, flatArrayOopDesc* array, int index))
+ {
+ assert(buffer != nullptr, "can't store null into flat array");
+ array->value_copy_to_index(buffer, index, LayoutKind::PAYLOAD); // Temporary hack for the transition
+ }
+ JRT_END
+
+ const TypeFunc* OptoRuntime::store_unknown_inline_Type() {
+ // create input type (domain)
+ const Type** fields = TypeTuple::fields(3);
+ fields[TypeFunc::Parms] = TypeInstPtr::NOTNULL;
+ fields[TypeFunc::Parms+1] = TypeOopPtr::NOTNULL;
+ fields[TypeFunc::Parms+2] = TypeInt::POS;
+
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+3, fields);
+
+ // create result type (range)
+ fields = TypeTuple::fields(0);
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
+
+ return TypeFunc::make(domain, range);
+ }
< prev index next >