Mercurial > hg > truffle
diff src/share/vm/c1/c1_Runtime1.cpp @ 1783:d5d065957597
6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti
author | iveresov |
---|---|
date | Fri, 03 Sep 2010 17:51:07 -0700 |
parents | 3e8fbc61cee8 |
children | ce6848d0666d |
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Runtime1.cpp Thu Sep 02 11:40:02 2010 -0700 +++ b/src/share/vm/c1/c1_Runtime1.cpp Fri Sep 03 17:51:07 2010 -0700 @@ -140,9 +140,7 @@ case slow_subtype_check_id: case fpu2long_stub_id: case unwind_exception_id: -#ifndef TIERED - case counter_overflow_id: // Not generated outside the tiered world -#endif + case counter_overflow_id: #if defined(SPARC) || defined(PPC) case handle_exception_nofpu_id: // Unused on sparc #endif @@ -322,31 +320,60 @@ } JRT_END -#ifdef TIERED -JRT_ENTRY(void, Runtime1::counter_overflow(JavaThread* thread, int bci)) - RegisterMap map(thread, false); - frame fr = thread->last_frame().sender(&map); +// This is a helper to allow us to safepoint but allow the outer entry +// to be safepoint free if we need to do an osr +static nmethod* counter_overflow_helper(JavaThread* THREAD, int branch_bci, methodOopDesc* m) { + nmethod* osr_nm = NULL; + methodHandle method(THREAD, m); + + RegisterMap map(THREAD, false); + frame fr = THREAD->last_frame().sender(&map); nmethod* nm = (nmethod*) fr.cb(); - assert(nm!= NULL && nm->is_nmethod(), "what?"); - methodHandle method(thread, nm->method()); - if (bci == 0) { - // invocation counter overflow - if (!Tier1CountOnly) { - CompilationPolicy::policy()->method_invocation_event(method, CHECK); - } else { - method()->invocation_counter()->reset(); + assert(nm!= NULL && nm->is_nmethod(), "Sanity check"); + methodHandle enclosing_method(THREAD, nm->method()); + + CompLevel level = (CompLevel)nm->comp_level(); + int bci = InvocationEntryBci; + if (branch_bci != InvocationEntryBci) { + // Compute desination bci + address pc = method()->code_base() + branch_bci; + Bytecodes::Code branch = Bytecodes::code_at(pc, method()); + int offset = 0; + switch (branch) { + case Bytecodes::_if_icmplt: case Bytecodes::_iflt: + case Bytecodes::_if_icmpgt: case Bytecodes::_ifgt: + case Bytecodes::_if_icmple: case Bytecodes::_ifle: + case Bytecodes::_if_icmpge: case Bytecodes::_ifge: + case Bytecodes::_if_icmpeq: case Bytecodes::_if_acmpeq: case Bytecodes::_ifeq: + case Bytecodes::_if_icmpne: case Bytecodes::_if_acmpne: case Bytecodes::_ifne: + case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: case Bytecodes::_goto: + offset = (int16_t)Bytes::get_Java_u2(pc + 1); + break; + case Bytecodes::_goto_w: + offset = Bytes::get_Java_u4(pc + 1); + break; + default: ; } - } else { - if (!Tier1CountOnly) { - // Twe have a bci but not the destination bci and besides a backedge - // event is more for OSR which we don't want here. - CompilationPolicy::policy()->method_invocation_event(method, CHECK); - } else { - method()->backedge_counter()->reset(); + bci = branch_bci + offset; + } + + osr_nm = CompilationPolicy::policy()->event(enclosing_method, method, branch_bci, bci, level, THREAD); + return osr_nm; +} + +JRT_BLOCK_ENTRY(address, Runtime1::counter_overflow(JavaThread* thread, int bci, methodOopDesc* method)) + nmethod* osr_nm; + JRT_BLOCK + osr_nm = counter_overflow_helper(thread, bci, method); + if (osr_nm != NULL) { + RegisterMap map(thread, false); + frame fr = thread->last_frame().sender(&map); + VM_DeoptimizeFrame deopt(thread, fr.id()); + VMThread::execute(&deopt); } - } + JRT_BLOCK_END + return NULL; JRT_END -#endif // TIERED extern void vm_exit(int code); @@ -898,7 +925,7 @@ NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff); assert(n_copy->data() == 0 || - n_copy->data() == (int)Universe::non_oop_word(), + n_copy->data() == (intptr_t)Universe::non_oop_word(), "illegal init value"); assert(load_klass() != NULL, "klass not set"); n_copy->set_data((intx) (load_klass()));