1980 // To do this, we need to make sure:
1981 // - klass is initialized
1982 // - klass can be fastpath allocated (e.g. does not have finalizer)
1983 // - TLAB accepts the allocation
1984 ConstantPool* constants = istate->method()->constants();
1985 if (UseTLAB && !constants->tag_at(index).is_unresolved_klass()) {
1986 Klass* entry = constants->resolved_klass_at(index);
1987 InstanceKlass* ik = InstanceKlass::cast(entry);
1988 if (ik->is_initialized() && ik->can_be_fastpath_allocated()) {
1989 size_t obj_size = ik->size_helper();
1990 HeapWord* result = THREAD->tlab().allocate(obj_size);
1991 if (result != nullptr) {
1992 // Initialize object field block.
1993 if (!ZeroTLAB) {
1994 // The TLAB was not pre-zeroed, we need to clear the memory here.
1995 size_t hdr_size = oopDesc::header_size();
1996 Copy::fill_to_words(result + hdr_size, obj_size - hdr_size, 0);
1997 }
1998
1999 // Initialize header, mirrors MemAllocator.
2000 oopDesc::set_mark(result, markWord::prototype());
2001 oopDesc::set_klass_gap(result, 0);
2002 oopDesc::release_set_klass(result, ik);
2003
2004 oop obj = cast_to_oop(result);
2005
2006 // Must prevent reordering of stores for object initialization
2007 // with stores that publish the new object.
2008 OrderAccess::storestore();
2009 SET_STACK_OBJECT(obj, 0);
2010 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
2011 }
2012 }
2013 }
2014 // Slow case allocation
2015 CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index),
2016 handle_exception);
2017 // Must prevent reordering of stores for object initialization
2018 // with stores that publish the new object.
2019 OrderAccess::storestore();
2020 SET_STACK_OBJECT(THREAD->vm_result(), 0);
2021 THREAD->set_vm_result(nullptr);
2022 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
2023 }
|
1980 // To do this, we need to make sure:
1981 // - klass is initialized
1982 // - klass can be fastpath allocated (e.g. does not have finalizer)
1983 // - TLAB accepts the allocation
1984 ConstantPool* constants = istate->method()->constants();
1985 if (UseTLAB && !constants->tag_at(index).is_unresolved_klass()) {
1986 Klass* entry = constants->resolved_klass_at(index);
1987 InstanceKlass* ik = InstanceKlass::cast(entry);
1988 if (ik->is_initialized() && ik->can_be_fastpath_allocated()) {
1989 size_t obj_size = ik->size_helper();
1990 HeapWord* result = THREAD->tlab().allocate(obj_size);
1991 if (result != nullptr) {
1992 // Initialize object field block.
1993 if (!ZeroTLAB) {
1994 // The TLAB was not pre-zeroed, we need to clear the memory here.
1995 size_t hdr_size = oopDesc::header_size();
1996 Copy::fill_to_words(result + hdr_size, obj_size - hdr_size, 0);
1997 }
1998
1999 // Initialize header, mirrors MemAllocator.
2000 if (UseCompactObjectHeaders) {
2001 oopDesc::release_set_mark(result, ik->prototype_header());
2002 } else {
2003 oopDesc::set_mark(result, markWord::prototype());
2004 oopDesc::set_klass_gap(result, 0);
2005 oopDesc::release_set_klass(result, ik);
2006 }
2007 oop obj = cast_to_oop(result);
2008
2009 // Must prevent reordering of stores for object initialization
2010 // with stores that publish the new object.
2011 OrderAccess::storestore();
2012 SET_STACK_OBJECT(obj, 0);
2013 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
2014 }
2015 }
2016 }
2017 // Slow case allocation
2018 CALL_VM(InterpreterRuntime::_new(THREAD, METHOD->constants(), index),
2019 handle_exception);
2020 // Must prevent reordering of stores for object initialization
2021 // with stores that publish the new object.
2022 OrderAccess::storestore();
2023 SET_STACK_OBJECT(THREAD->vm_result(), 0);
2024 THREAD->set_vm_result(nullptr);
2025 UPDATE_PC_AND_TOS_AND_CONTINUE(3, 1);
2026 }
|