# HG changeset patch # User Doug Simon # Date 1354553645 -3600 # Node ID ce248dc0a65674f33d5f55ea51f09ace72bdadac # Parent 1baf7f1e3f235d5c9f6f182a72f22e2d7bd83183 removed all Graal modifications to ci and c1 diff -r 1baf7f1e3f23 -r ce248dc0a656 src/cpu/x86/vm/c1_MacroAssembler_x86.cpp --- a/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -35,7 +35,7 @@ #include "runtime/os.hpp" #include "runtime/stubRoutines.hpp" -int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Register scratch, Label& slow_case, bool use_basic_object_lock) { +int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr, Register scratch, Label& slow_case) { const int aligned_mask = BytesPerWord -1; const int hdr_offset = oopDesc::mark_offset_in_bytes(); assert(hdr == rax, "hdr must be rax, for the cmpxchg instruction"); @@ -45,10 +45,8 @@ verify_oop(obj); - if (use_basic_object_lock) { - // save object being locked into the BasicObjectLock - movptr(Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()), obj); - } + // save object being locked into the BasicObjectLock + movptr(Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes()), obj); if (UseBiasedLocking) { assert(scratch != noreg, "should have scratch register at this point"); @@ -100,7 +98,7 @@ } -void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case, bool use_basic_object_lock) { +void C1_MacroAssembler::unlock_object(Register hdr, Register obj, Register disp_hdr, Label& slow_case) { const int aligned_mask = BytesPerWord -1; const int hdr_offset = oopDesc::mark_offset_in_bytes(); assert(disp_hdr == rax, "disp_hdr must be rax, for the cmpxchg instruction"); @@ -108,10 +106,8 @@ Label done; if (UseBiasedLocking) { - if (use_basic_object_lock) { - // load object - movptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes())); - } + // load object + movptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes())); biased_locking_exit(obj, hdr, done); } @@ -122,10 +118,8 @@ // if we had recursive locking, we are done jcc(Assembler::zero, done); if (!UseBiasedLocking) { - if (use_basic_object_lock) { - // load object - movptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes())); - } + // load object + movptr(obj, Address(disp_hdr, BasicObjectLock::obj_offset_in_bytes())); } verify_oop(obj); // test if object header is pointing to the displaced header, and if so, restore @@ -290,13 +284,10 @@ } } -#ifndef GRAAL - // TODO(thomaswue): Check how we can access the flag without a ciEnv object. if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == rax, "must be"); call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); } -#endif verify_oop(obj); } @@ -326,14 +317,10 @@ const Register len_zero = len; initialize_body(obj, arr_size, header_size * BytesPerWord, len_zero); - -#ifndef GRAAL - // TODO(thomaswue): Check how we can access the flag without a ciEnv object. if (CURRENT_ENV->dtrace_alloc_probes()) { assert(obj == rax, "must be"); call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id))); } -#endif verify_oop(obj); } diff -r 1baf7f1e3f23 -r ce248dc0a656 src/cpu/x86/vm/c1_MacroAssembler_x86.hpp --- a/src/cpu/x86/vm/c1_MacroAssembler_x86.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/cpu/x86/vm/c1_MacroAssembler_x86.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -51,13 +51,13 @@ // disp_hdr: must point to the displaced header location, contents preserved // scratch : scratch register, contents destroyed // returns code offset at which to add null check debug information - int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case, bool use_basic_object_lock = true); + int lock_object (Register swap, Register obj, Register disp_hdr, Register scratch, Label& slow_case); // unlocking // hdr : contents destroyed // obj : must point to the object to lock, contents preserved // disp_hdr: must be eax & must point to the displaced header location, contents destroyed - void unlock_object(Register swap, Register obj, Register lock, Label& slow_case, bool use_basic_object_lock = true); + void unlock_object(Register swap, Register obj, Register lock, Label& slow_case); void initialize_object( Register obj, // result: pointer to object after successful allocation diff -r 1baf7f1e3f23 -r ce248dc0a656 src/cpu/x86/vm/c1_Runtime1_x86.cpp --- a/src/cpu/x86/vm/c1_Runtime1_x86.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/cpu/x86/vm/c1_Runtime1_x86.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -38,7 +38,6 @@ #include "runtime/vframeArray.hpp" #include "vmreg_x86.inline.hpp" -static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true); // Implementation of StubAssembler @@ -113,14 +112,6 @@ if (metadata_result->is_valid()) { movptr(Address(thread, JavaThread::vm_result_2_offset()), NULL_WORD); } -#ifdef GRAAL - // (thomaswue) Deoptimize in case of an exception. - restore_live_registers(this, false); - movptr(Address(thread, Thread::pending_exception_offset()), NULL_WORD); - leave(); - movl(rscratch1, Deoptimization::make_trap_request(Deoptimization::Reason_constraint, Deoptimization::Action_reinterpret)); - jump(RuntimeAddress(SharedRuntime::deopt_blob()->uncommon_trap())); -#else if (frame_size() == no_frame_size) { leave(); jump(RuntimeAddress(StubRoutines::forward_exception_entry())); @@ -129,7 +120,6 @@ } else { jump(RuntimeAddress(Runtime1::entry_for(Runtime1::forward_exception_id))); } -#endif bind(L); } // get oop results if there are any and reset the values in the thread @@ -561,7 +551,7 @@ } -static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers/* = true*/) { +static void restore_live_registers(StubAssembler* sasm, bool restore_fpu_registers = true) { __ block_comment("restore_live_registers"); restore_fpu(sasm, restore_fpu_registers); @@ -615,25 +605,6 @@ // has_argument: true if the exception needs an argument (passed on stack because registers must be preserved) OopMapSet* Runtime1::generate_exception_throw(StubAssembler* sasm, address target, bool has_argument) { - OopMapSet* oop_maps = new OopMapSet(); -#ifdef GRAAL - OopMap* oop_map = save_live_registers(sasm, 1); - - // now all registers are saved and can be used freely - // verify that no old value is used accidentally - __ invalidate_registers(true, true, true, true, true, true); - - // registers used by this stub - const Register temp_reg = rbx; - - // load argument for exception that is passed as an argument into the stub - if (has_argument) { - __ movptr(c_rarg1, r10); - } - int call_offset = __ call_RT(noreg, noreg, target, has_argument ? 1 : 0); - - oop_maps->add_gc_map(call_offset, oop_map); -#else // preserve all registers int num_rt_args = has_argument ? 2 : 1; OopMap* oop_map = save_live_registers(sasm, num_rt_args); @@ -656,8 +627,8 @@ } int call_offset = __ call_RT(noreg, noreg, target, num_rt_args - 1); + OopMapSet* oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); -#endif __ stop("should not reach here"); @@ -1002,6 +973,7 @@ return oop_maps; } + OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { // for better readability @@ -1048,10 +1020,6 @@ __ push(rdi); __ push(rbx); -#ifdef GRAAL - __ push(rcx); - __ push(rsi); -#endif if (id == fast_new_instance_init_check_id) { // make sure the klass is initialized @@ -1090,10 +1058,6 @@ __ initialize_object(obj, klass, obj_size, 0, t1, t2); __ verify_oop(obj); -#ifdef GRAAL - __ pop(rsi); - __ pop(rcx); -#endif __ pop(rbx); __ pop(rdi); __ ret(0); @@ -1107,19 +1071,11 @@ __ initialize_object(obj, klass, obj_size, 0, t1, t2); __ verify_oop(obj); -#ifdef GRAAL - __ pop(rsi); - __ pop(rcx); -#endif __ pop(rbx); __ pop(rdi); __ ret(0); __ bind(slow_path); -#ifdef GRAAL - __ pop(rsi); - __ pop(rcx); -#endif __ pop(rbx); __ pop(rdi); } @@ -1310,13 +1266,8 @@ // will be place in C abi locations #ifdef _LP64 -#ifdef GRAAL - __ verify_oop(j_rarg0); - __ mov(rax, j_rarg0); -#else __ verify_oop(c_rarg0); __ mov(rax, c_rarg0); -#endif #else // The object is passed on the stack and we haven't pushed a // frame yet so it's one work away from top of stack. @@ -1446,17 +1397,9 @@ __ movptr(rax, Address(rsp, (sup_k_off) * VMRegImpl::stack_slot_size)); // superclass Label miss; -#ifdef GRAAL - Label success; - __ check_klass_subtype_fast_path(rsi, rax, rcx, &success, &miss, NULL); -#endif - __ check_klass_subtype_slow_path(rsi, rax, rcx, rdi, NULL, &miss); // fallthrough on success: -#ifdef GRAAL - __ bind(success); -#endif __ movptr(Address(rsp, (result_off) * VMRegImpl::stack_slot_size), 1); // result __ pop(rax); __ pop(rcx); @@ -1862,242 +1805,6 @@ } break; #endif // !SERIALGC -#ifdef GRAAL - case graal_unwind_exception_call_id: { - // remove the frame from the stack - __ movptr(rsp, rbp); - __ pop(rbp); - // exception_oop is passed using ordinary java calling conventions - __ movptr(rax, j_rarg0); - - Label nonNullExceptionOop; - __ testptr(rax, rax); - __ jcc(Assembler::notZero, nonNullExceptionOop); - { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(rax, noreg, (address)graal_create_null_exception, 0); - oop_maps->add_gc_map(call_offset, oop_map); - __ leave(); - } - __ bind(nonNullExceptionOop); - - __ set_info("unwind_exception", dont_gc_arguments); - // note: no stubframe since we are about to leave the current - // activation and we are calling a leaf VM function only. - generate_unwind_exception(sasm); - __ should_not_reach_here(); - break; - } - - case graal_OSR_migration_end_id: { - __ enter(); - save_live_registers(sasm, 0); - __ movptr(c_rarg0, j_rarg0); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_end))); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case graal_set_deopt_info_id: { - __ movptr(Address(r15_thread, JavaThread::graal_deopt_info_offset()), rscratch1); - __ ret(0); - break; - } - - case graal_create_null_pointer_exception_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(rax, noreg, (address)graal_create_null_exception, 0); - oop_maps->add_gc_map(call_offset, oop_map); - __ leave(); - __ ret(0); - break; - } - - case graal_create_out_of_bounds_exception_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(rax, noreg, (address)graal_create_out_of_bounds_exception, j_rarg0); - oop_maps->add_gc_map(call_offset, oop_map); - __ leave(); - __ ret(0); - break; - } - - case graal_vm_error_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(noreg, noreg, (address)graal_vm_error, j_rarg0, j_rarg1, j_rarg2); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case graal_log_printf_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(noreg, noreg, (address)graal_log_printf, j_rarg0, j_rarg1, j_rarg2); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case graal_log_primitive_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(noreg, noreg, (address)graal_log_primitive, j_rarg0, j_rarg1, j_rarg2); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case graal_log_object_id: { - __ enter(); - oop_maps = new OopMapSet(); - OopMap* oop_map = save_live_registers(sasm, 0); - int call_offset = __ call_RT(noreg, noreg, (address)graal_log_object, j_rarg0, j_rarg1); - oop_maps->add_gc_map(call_offset, oop_map); - restore_live_registers(sasm); - __ leave(); - __ ret(0); - break; - } - - case graal_verify_oop_id: { - // We use enter & leave so that a better stack trace is produced in the hs_err file - __ enter(); - __ verify_oop(r13, "Graal verify oop"); - __ leave(); - __ ret(0); - break; - } - - case graal_arithmetic_frem_id: { - __ subptr(rsp, 8); - __ movflt(Address(rsp, 0), xmm1); - __ fld_s(Address(rsp, 0)); - __ movflt(Address(rsp, 0), xmm0); - __ fld_s(Address(rsp, 0)); - Label L; - __ bind(L); - __ fprem(); - __ fwait(); - __ fnstsw_ax(); - __ testl(rax, 0x400); - __ jcc(Assembler::notZero, L); - __ fxch(1); - __ fpop(); - __ fstp_s(Address(rsp, 0)); - __ movflt(xmm0, Address(rsp, 0)); - __ addptr(rsp, 8); - __ ret(0); - break; - } - case graal_arithmetic_drem_id: { - __ subptr(rsp, 8); - __ movdbl(Address(rsp, 0), xmm1); - __ fld_d(Address(rsp, 0)); - __ movdbl(Address(rsp, 0), xmm0); - __ fld_d(Address(rsp, 0)); - Label L; - __ bind(L); - __ fprem(); - __ fwait(); - __ fnstsw_ax(); - __ testl(rax, 0x400); - __ jcc(Assembler::notZero, L); - __ fxch(1); - __ fpop(); - __ fstp_d(Address(rsp, 0)); - __ movdbl(xmm0, Address(rsp, 0)); - __ addptr(rsp, 8); - __ ret(0); - break; - } - case graal_monitorenter_id: { - Label slow_case; - - Register obj = j_rarg0; - Register lock = j_rarg1; - - Register scratch1 = rax; - Register scratch2 = rbx; - assert_different_registers(obj, lock, scratch1, scratch2); - - // copied from LIR_Assembler::emit_lock - if (UseFastLocking) { - assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); - __ lock_object(scratch1, obj, lock, scratch2, slow_case, false); - __ ret(0); - } - - __ bind(slow_case); - { - StubFrame f(sasm, "graal_monitorenter", dont_gc_arguments); - OopMap* map = save_live_registers(sasm, 2, save_fpu_registers); - - // Called with store_parameter and not C abi - int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, graal_monitorenter), obj, lock); - - oop_maps = new OopMapSet(); - oop_maps->add_gc_map(call_offset, map); - restore_live_registers(sasm, save_fpu_registers); - } - __ ret(0); - break; - } - case graal_monitorexit_id: { - Label slow_case; - - Register obj = j_rarg0; - Register lock = j_rarg1; - - // needed in rax later on... - Register lock2 = rax; - __ mov(lock2, lock); - Register scratch1 = rbx; - assert_different_registers(obj, lock, scratch1, lock2); - - // copied from LIR_Assembler::emit_lock - if (UseFastLocking) { - assert(BasicLock::displaced_header_offset_in_bytes() == 0, "lock_reg must point to the displaced header"); - __ unlock_object(scratch1, obj, lock2, slow_case, false); - __ ret(0); - } - - __ bind(slow_case); - { - StubFrame f(sasm, "graal_monitorexit", dont_gc_arguments); - OopMap* map = save_live_registers(sasm, 2, save_fpu_registers); - - // note: really a leaf routine but must setup last java sp - // => use call_RT for now (speed can be improved by - // doing last java sp setup manually) - int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, graal_monitorexit), obj, lock); - - oop_maps = new OopMapSet(); - oop_maps->add_gc_map(call_offset, map); - restore_live_registers(sasm, save_fpu_registers); - } - __ ret(0); - break; - } -#endif default: { StubFrame f(sasm, "unimplemented entry", dont_gc_arguments); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/cpu/x86/vm/c1_globals_x86.hpp --- a/src/cpu/x86/vm/c1_globals_x86.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/cpu/x86/vm/c1_globals_x86.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -37,41 +37,26 @@ define_pd_global(bool, ResizeTLAB, true ); define_pd_global(bool, InlineIntrinsics, true ); define_pd_global(bool, PreferInterpreterNativeStubs, false); +define_pd_global(bool, ProfileTraps, false); +define_pd_global(bool, UseOnStackReplacement, true ); define_pd_global(bool, TieredCompilation, false); +define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, BackEdgeThreshold, 100000); define_pd_global(intx, OnStackReplacePercentage, 933 ); define_pd_global(intx, FreqInlineSize, 325 ); define_pd_global(intx, NewSizeThreadIncrease, 4*K ); -define_pd_global(uintx,MetaspaceSize, 12*M ); -define_pd_global(uintx,MaxPermSize, 64*M ); -define_pd_global(bool, NeverActAsServerClassMachine, true ); -define_pd_global(uint64_t,MaxRAM, 1ULL*G); -define_pd_global(bool, CICompileOSR, true ); - -#ifdef GRAAL -define_pd_global(bool, ProfileTraps, true ); -define_pd_global(bool, UseOnStackReplacement, true); -define_pd_global(intx, CompileThreshold, 10000 ); -define_pd_global(intx, InitialCodeCacheSize, 16*M ); -define_pd_global(intx, ReservedCodeCacheSize, 64*M ); -define_pd_global(bool, ProfileInterpreter, true ); -define_pd_global(intx, CodeCacheExpansionSize, 64*K ); -define_pd_global(uintx,CodeCacheMinBlockLength, 4); -define_pd_global(intx, TypeProfileWidth, 8); -#else -define_pd_global(bool, ProfileTraps, false); -define_pd_global(bool, UseOnStackReplacement, true ); -define_pd_global(intx, CompileThreshold, 1500 ); define_pd_global(intx, InitialCodeCacheSize, 160*K); define_pd_global(intx, ReservedCodeCacheSize, 32*M ); define_pd_global(bool, ProfileInterpreter, false); define_pd_global(intx, CodeCacheExpansionSize, 32*K ); define_pd_global(uintx,CodeCacheMinBlockLength, 1); -define_pd_global(intx, TypeProfileWidth, 0); -#endif // GRAAL +define_pd_global(uintx,MetaspaceSize, 12*M ); +define_pd_global(bool, NeverActAsServerClassMachine, true ); +define_pd_global(uint64_t,MaxRAM, 1ULL*G); +define_pd_global(bool, CICompileOSR, true ); #endif // !TIERED - +define_pd_global(bool, UseTypeProfile, false); define_pd_global(bool, RoundFPResults, true ); define_pd_global(bool, LIRFillDelaySlots, false); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/c1/c1_Runtime1.cpp --- a/src/share/vm/c1/c1_Runtime1.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/c1/c1_Runtime1.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -205,14 +205,6 @@ #if defined(SPARC) || defined(PPC) case handle_exception_nofpu_id: // Unused on sparc #endif -#ifdef GRAAL - case graal_verify_oop_id: - case graal_unwind_exception_call_id: - case graal_OSR_migration_end_id: - case graal_arithmetic_frem_id: - case graal_arithmetic_drem_id: - case graal_set_deopt_info_id: -#endif break; // All other stubs should have oopmaps @@ -539,9 +531,8 @@ if (TraceExceptions) { ttyLocker ttyl; ResourceMark rm; - int offset = pc - nm->code_begin(); - tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x", - exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread); + tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " for thread 0x%x", + exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, thread); } // for AbortVMOnException flag NOT_PRODUCT(Exceptions::debug_check_abort(exception)); @@ -559,7 +550,7 @@ thread->set_exception_pc(pc); // the exception cache is used only by non-implicit exceptions - if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { + if (continuation != NULL) { nm->add_handler_for_exception_and_pc(exception, pc, continuation); } } @@ -652,158 +643,6 @@ SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError()); JRT_END -#ifdef GRAAL - -JRT_ENTRY(void, Runtime1::graal_create_null_exception(JavaThread* thread)) - thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL)()); -JRT_END - -JRT_ENTRY(void, Runtime1::graal_create_out_of_bounds_exception(JavaThread* thread, jint index)) - char message[jintAsStringSize]; - sprintf(message, "%d", index); - thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)()); -JRT_END - -JRT_ENTRY_NO_ASYNC(void, Runtime1::graal_monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) - NOT_PRODUCT(_monitorenter_slowcase_cnt++;) -#ifdef ASSERT - if (TraceGraal >= 3) { - char type[1024]; - obj->klass()->name()->as_C_string(type, 1024); - markOop mark = obj->mark(); - tty->print_cr("entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, obj, type, mark, lock); - tty->flush(); - } - if (PrintBiasedLockingStatistics) { - Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); - } -#endif - Handle h_obj(thread, obj); - assert(h_obj()->is_oop(), "must be NULL or an object"); - if (UseBiasedLocking) { - // Retry fast entry if bias is revoked to avoid unnecessary inflation - ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); - } else { - if (UseFastLocking) { - // When using fast locking, the compiled code has already tried the fast case - ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); - } else { - ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); - } - } -#ifdef ASSERT - if (TraceGraal >= 3) { - tty->print_cr("exiting locking"); - tty->print_cr(""); - tty->print_cr("done"); - } -#endif -JRT_END - - -JRT_LEAF(void, Runtime1::graal_monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) - NOT_PRODUCT(_monitorexit_slowcase_cnt++;) - assert(thread == JavaThread::current(), "threads must correspond"); - assert(thread->last_Java_sp(), "last_Java_sp must be set"); - // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown - EXCEPTION_MARK; - -#ifdef DEBUG - if (!obj->is_oop()) { - ResetNoHandleMark rhm; - nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); - if (method != NULL) { - tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj); - } - thread->print_stack_on(tty); - assert(false, "invalid lock object pointer dected"); - } -#endif - - if (UseFastLocking) { - // When using fast locking, the compiled code has already tried the fast case - ObjectSynchronizer::slow_exit(obj, lock, THREAD); - } else { - ObjectSynchronizer::fast_exit(obj, lock, THREAD); - } -#ifdef ASSERT - if (TraceGraal >= 3) { - char type[1024]; - obj->klass()->name()->as_C_string(type, 1024); - tty->print_cr("exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, obj, type, obj->mark(), lock); - tty->flush(); - } -#endif -JRT_END - -JRT_ENTRY(void, Runtime1::graal_log_object(JavaThread* thread, oop obj, jint flags)) - bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); - bool address = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); - bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); - if (!string) { - if (!address && obj->is_oop_or_null(true)) { - char buf[O_BUFLEN]; - tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), obj); - } else { - tty->print("%p", obj); - } - } else { - ResourceMark rm; - assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); - char *buf = java_lang_String::as_utf8_string(obj); - tty->print(buf); - } - if (newline) { - tty->cr(); - } -JRT_END - -JRT_ENTRY(void, Runtime1::graal_vm_error(JavaThread* thread, oop where, oop format, jlong value)) - ResourceMark rm; - assert(where == NULL || java_lang_String::is_instance(where), "must be"); - const char *error_msg = where == NULL ? "" : java_lang_String::as_utf8_string(where); - char *detail_msg = NULL; - if (format != NULL) { - const char* buf = java_lang_String::as_utf8_string(format); - size_t detail_msg_length = strlen(buf) * 2; - detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); - jio_snprintf(detail_msg, detail_msg_length, buf, value); - } - report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); -JRT_END - -JRT_ENTRY(void, Runtime1::graal_log_printf(JavaThread* thread, oop format, jlong val)) - ResourceMark rm; - assert(format != NULL && java_lang_String::is_instance(format), "must be"); - char *buf = java_lang_String::as_utf8_string(format); - tty->print(buf, val); -JRT_END - -JRT_ENTRY(void, Runtime1::graal_log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) - union { - jlong l; - jdouble d; - jfloat f; - } uu; - uu.l = value; - switch (typeChar) { - case 'z': tty->print(value == 0 ? "false" : "true"); break; - case 'b': tty->print("%d", (jbyte) value); break; - case 'c': tty->print("%c", (jchar) value); break; - case 's': tty->print("%d", (jshort) value); break; - case 'i': tty->print("%d", (jint) value); break; - case 'f': tty->print("%f", uu.f); break; - case 'j': tty->print(INT64_FORMAT, value); break; - case 'd': tty->print("%lf", uu.d); break; - default: assert(false, "unknown typeChar"); break; - } - if (newline) { - tty->cr(); - } -JRT_END - -#endif /* GRAAL */ - JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock)) NOT_PRODUCT(_monitorenter_slowcase_cnt++;) @@ -1048,9 +887,7 @@ mirror = Handle(THREAD, m); } break; - default: - tty->print_cr("Unhandled bytecode: %d stub_id=%d caller=%s bci=%d pc=%d", code, stub_id, caller_method->name()->as_C_string(), bci, caller_frame.pc()); - Unimplemented(); + default: Unimplemented(); } // convert to handle load_klass = KlassHandle(THREAD, k); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/c1/c1_Runtime1.hpp --- a/src/share/vm/c1/c1_Runtime1.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/c1/c1_Runtime1.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -36,57 +36,7 @@ // The Runtime1 holds all assembly stubs and VM // runtime routines needed by code code generated // by the Compiler1. -#ifdef GRAAL -#define RUNTIME1_STUBS(stub, last_entry) \ - stub(dtrace_object_alloc) \ - stub(unwind_exception) \ - stub(forward_exception) \ - stub(throw_range_check_failed) /* throws ArrayIndexOutOfBoundsException */ \ - stub(throw_index_exception) /* throws IndexOutOfBoundsException */ \ - stub(throw_div0_exception) \ - stub(throw_null_pointer_exception) \ - stub(register_finalizer) \ - stub(new_instance) \ - stub(fast_new_instance) \ - stub(fast_new_instance_init_check) \ - stub(new_type_array) \ - stub(new_object_array) \ - stub(new_multi_array) \ - stub(handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(handle_exception) \ - stub(handle_exception_from_callee) \ - stub(throw_array_store_exception) \ - stub(throw_class_cast_exception) \ - stub(throw_incompatible_class_change_error) \ - stub(slow_subtype_check) \ - stub(monitorenter) \ - stub(monitorenter_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(monitorexit) \ - stub(monitorexit_nofpu) /* optimized version that does not preserve fpu registers */ \ - stub(deoptimize) \ - stub(access_field_patching) \ - stub(load_klass_patching) \ - stub(load_mirror_patching) \ - stub(g1_pre_barrier_slow) \ - stub(g1_post_barrier_slow) \ - stub(fpu2long_stub) \ - stub(counter_overflow) \ - stub(graal_unwind_exception_call) \ - stub(graal_OSR_migration_end) \ - stub(graal_arithmetic_frem) \ - stub(graal_arithmetic_drem) \ - stub(graal_monitorenter) \ - stub(graal_monitorexit) \ - stub(graal_verify_oop) \ - stub(graal_vm_error) \ - stub(graal_set_deopt_info) \ - stub(graal_create_null_pointer_exception) \ - stub(graal_create_out_of_bounds_exception) \ - stub(graal_log_object) \ - stub(graal_log_printf) \ - stub(graal_log_primitive) \ - last_entry(number_of_ids) -#else + #define RUNTIME1_STUBS(stub, last_entry) \ stub(dtrace_object_alloc) \ stub(unwind_exception) \ @@ -122,7 +72,6 @@ stub(fpu2long_stub) \ stub(counter_overflow) \ last_entry(number_of_ids) -#endif #define DECLARE_STUB_ID(x) x ## _id , #define DECLARE_LAST_STUB_ID(x) x @@ -201,25 +150,9 @@ static void throw_class_cast_exception(JavaThread* thread, oopDesc* object); static void throw_incompatible_class_change_error(JavaThread* thread); static void throw_array_store_exception(JavaThread* thread, oopDesc* object); + static void monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock); static void monitorexit (JavaThread* thread, BasicObjectLock* lock); -#ifdef GRAAL - static void graal_create_null_exception(JavaThread* thread); - static void graal_create_out_of_bounds_exception(JavaThread* thread, jint index); - static void graal_monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock); - static void graal_monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock); - static void graal_vm_error(JavaThread* thread, oop where, oop format, jlong value); - static void graal_log_printf(JavaThread* thread, oop format, jlong value); - static void graal_log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline); - - // Note: Must be kept in sync with constants in com.oracle.graal.snippets.Log - enum { - LOG_OBJECT_NEWLINE = 0x01, - LOG_OBJECT_STRING = 0x02, - LOG_OBJECT_ADDRESS = 0x04 - }; - static void graal_log_object(JavaThread* thread, oop msg, jint flags); -#endif // GRAAL static void deoptimize(JavaThread* thread); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/ci/ciEnv.cpp --- a/src/share/vm/ci/ciEnv.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/ci/ciEnv.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -86,7 +86,7 @@ // ciEnv::ciEnv ciEnv::ciEnv(CompileTask* task, int system_dictionary_modification_counter) { VM_ENTRY_MARK; - CompilerThread* compiler_thread = CompilerThread::current(); + // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. thread->set_env(this); assert(ciEnv::current() == this, "sanity"); @@ -104,7 +104,7 @@ _system_dictionary_modification_counter = system_dictionary_modification_counter; _num_inlined_bytecodes = 0; - assert(task == NULL || compiler_thread->task() == task, "sanity"); + assert(task == NULL || thread->task() == task, "sanity"); _task = task; _log = NULL; @@ -141,11 +141,7 @@ ASSERT_IN_VM; // Set up ciEnv::current immediately, for the sake of ciObjectFactory, etc. -#ifdef GRAAL - JavaThread* current_thread = JavaThread::current(); -#else CompilerThread* current_thread = CompilerThread::current(); -#endif assert(current_thread->env() == NULL, "must be"); current_thread->set_env(this); assert(ciEnv::current() == this, "sanity"); @@ -158,10 +154,8 @@ _break_at_compile = false; _compiler_data = NULL; #ifndef PRODUCT -#ifndef GRAAL assert(firstEnv, "must be first"); firstEnv = false; -#endif #endif /* !PRODUCT */ _system_dictionary_modification_counter = 0; @@ -194,16 +188,11 @@ } ciEnv::~ciEnv() { -#ifdef GRAAL - _factory->remove_symbols(); - JavaThread::current()->set_env(NULL); -#else CompilerThread* current_thread = CompilerThread::current(); _factory->remove_symbols(); // Need safepoint to clear the env on the thread. RedefineClasses might // be reading it. GUARDED_VM_ENTRY(current_thread->set_env(NULL);) -#endif } // ------------------------------------------------------------------ @@ -780,8 +769,8 @@ Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc); if (m != NULL && (bc == Bytecodes::_invokestatic - ? InstanceKlass::cast(m->method_holder())->is_not_initialized() - : !InstanceKlass::cast(m->method_holder())->is_loaded())) { + ? m->method_holder()->is_not_initialized() + : !m->method_holder()->is_loaded())) { m = NULL; } #ifdef ASSERT @@ -927,7 +916,7 @@ // ------------------------------------------------------------------ // ciEnv::register_method -nmethod* ciEnv::register_method(ciMethod* target, +void ciEnv::register_method(ciMethod* target, int entry_bci, CodeOffsets* offsets, int orig_pc_offset, @@ -995,7 +984,7 @@ // If the code buffer is created on each compile attempt // as in C2, then it must be freed. code_buffer->free_blob(); - return NULL; + return; } assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry"); @@ -1073,7 +1062,7 @@ method_name, entry_bci); } - InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); + method->method_holder()->add_osr_nmethod(nm); } } @@ -1083,7 +1072,6 @@ nm->post_compiled_method_load_event(); } - return nm; } diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/ci/ciEnv.hpp --- a/src/share/vm/ci/ciEnv.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/ci/ciEnv.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -45,9 +45,6 @@ friend class CompileBroker; friend class Dependencies; // for get_object, during logging -#ifdef GRAAL - friend class CodeInstaller; -#endif static fileStream* _replay_data_stream; @@ -105,8 +102,6 @@ ciInstance* _the_null_string; // The Java string "null" ciInstance* _the_min_jint_string; // The Java string "-2147483648" -public: - // Look up a klass by name from a particular class loader (the accessor's). // If require_local, result must be defined in that class loader, or NULL. // If !require_local, a result from remote class loader may be reported, @@ -137,8 +132,6 @@ int method_index, Bytecodes::Code bc, ciInstanceKlass* loading_klass); -private: - // Implementation methods for loading and constant pool access. ciKlass* get_klass_by_name_impl(ciKlass* accessing_klass, constantPoolHandle cpool, @@ -166,7 +159,6 @@ Symbol* sig, Bytecodes::Code bc); - public: // Get a ciObject from the object factory. Ensures uniqueness // of ciObjects. ciObject* get_object(oop o) { @@ -176,7 +168,6 @@ return _factory->get(o); } } - private: ciSymbol* get_symbol(Symbol* o) { if (o == NULL) { @@ -362,7 +353,7 @@ uint compile_id(); // task()->compile_id() // Register the result of a compilation. - nmethod* register_method(ciMethod* target, + void register_method(ciMethod* target, int entry_bci, CodeOffsets* offsets, int orig_pc_offset, @@ -430,10 +421,10 @@ Arena* arena() { return _arena; } // What is the current compilation environment? - static ciEnv* current() { return JavaThread::current()->env(); } + static ciEnv* current() { return CompilerThread::current()->env(); } // Overload with current thread argument - static ciEnv* current(JavaThread *thread) { return thread->env(); } + static ciEnv* current(CompilerThread *thread) { return thread->env(); } // Per-compiler data. (Used by C2 to publish the Compile* pointer.) void* compiler_data() { return _compiler_data; } diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/ci/ciKlass.cpp --- a/src/share/vm/ci/ciKlass.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/ci/ciKlass.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -71,9 +71,8 @@ if (this == that) { return true; } -#ifndef GRAAL + VM_ENTRY_MARK; -#endif Klass* this_klass = get_Klass(); Klass* that_klass = that->get_Klass(); bool result = this_klass->is_subtype_of(that_klass); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/ci/ciObjectFactory.cpp --- a/src/share/vm/ci/ciObjectFactory.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/ci/ciObjectFactory.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -84,13 +84,11 @@ _arena = arena; _ci_metadata = new (arena) GrowableArray(arena, expected_size, 0, NULL); -#ifndef GRAAL // If the shared ci objects exist append them to this factory's objects if (_shared_ci_metadata != NULL) { _ci_metadata->appendAll(_shared_ci_metadata); } -#endif _unloaded_methods = new (arena) GrowableArray(arena, 4, 0, NULL); _unloaded_klasses = new (arena) GrowableArray(arena, 8, 0, NULL); @@ -207,7 +205,6 @@ ciSymbol* ciObjectFactory::get_symbol(Symbol* key) { -#ifndef GRAAL vmSymbols::SID sid = vmSymbols::find_sid(key); if (sid != vmSymbols::NO_SID) { // do not pollute the main cache with it @@ -215,8 +212,6 @@ } assert(vmSymbols::find_sid(key) == vmSymbols::NO_SID, ""); -#endif - ciSymbol* s = new (arena()) ciSymbol(key, vmSymbols::NO_SID); _symbols->push(s); return s; diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/ci/ciUtilities.hpp --- a/src/share/vm/ci/ciUtilities.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/ci/ciUtilities.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -36,7 +36,7 @@ // Bring the compilation thread into the VM state. #define VM_ENTRY_MARK \ - JavaThread* thread=JavaThread::current(); \ + CompilerThread* thread=CompilerThread::current(); \ ThreadInVMfromNative __tiv(thread); \ ResetNoHandleMark rnhm; \ HandleMarkCleaner __hm(thread); \ @@ -47,7 +47,7 @@ // Bring the compilation thread into the VM state. No handle mark. #define VM_QUICK_ENTRY_MARK \ - JavaThread* thread=JavaThread::current(); \ + CompilerThread* thread=CompilerThread::current(); \ ThreadInVMfromNative __tiv(thread); \ /* \ * [TODO] The NoHandleMark line does nothing but declare a function prototype \ @@ -60,7 +60,7 @@ #define EXCEPTION_CONTEXT \ - JavaThread* thread=JavaThread::current(); \ + CompilerThread* thread=CompilerThread::current(); \ Thread* THREAD = thread; diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/graal/graalCompiler.cpp --- a/src/share/vm/graal/graalCompiler.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/graal/graalCompiler.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -70,14 +70,14 @@ ResourceMark rm; HandleMark hm; { - VM_ENTRY_MARK; + GRAAL_VM_ENTRY_MARK; check_pending_exception("Could not register natives"); } graal_compute_offsets(); { - VM_ENTRY_MARK; + GRAAL_VM_ENTRY_MARK; HandleMark hm; VMToCompiler::setDefaultOptions(); for (int i = 0; i < Arguments::num_graal_args(); ++i) { @@ -151,7 +151,7 @@ } void GraalCompiler::compile_method(methodHandle method, int entry_bci, jboolean blocking) { - EXCEPTION_CONTEXT + GRAAL_EXCEPTION_CONTEXT if (!_initialized) { method->clear_queued_for_compilation(); method->invocation_counter()->reset(); diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -48,7 +48,7 @@ #define C2V_VMENTRY(result_type, name, signature) \ JNIEXPORT result_type JNICALL c2v_ ## name signature { \ TRACE_graal_3("CompilerToVM::" #name); \ - VM_ENTRY_MARK; \ + GRAAL_VM_ENTRY_MARK; \ // Entry to native method implementation that calls a JNI function // and hence cannot transition current thread to '_thread_in_vm'. diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/graal/graalEnv.cpp --- a/src/share/vm/graal/graalEnv.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/graal/graalEnv.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -70,7 +70,7 @@ constantPoolHandle& cpool, Symbol* sym, bool require_local) { - EXCEPTION_CONTEXT; + GRAAL_EXCEPTION_CONTEXT; // Now we need to check the SystemDictionary if (sym->byte_at(0) == 'L' && @@ -162,7 +162,7 @@ int index, bool& is_accessible, KlassHandle& accessor) { - EXCEPTION_CONTEXT; + GRAAL_EXCEPTION_CONTEXT; KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index)); Symbol* klass_name = NULL; if (klass.is_null()) { @@ -233,7 +233,7 @@ // in the accessor klass. void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc, int index) { - EXCEPTION_CONTEXT; + GRAAL_EXCEPTION_CONTEXT; assert(klass->is_linked(), "must be linked before using its constant-pool"); @@ -285,7 +285,7 @@ Symbol* name, Symbol* sig, Bytecodes::Code bc) { - EXCEPTION_CONTEXT; + GRAAL_EXCEPTION_CONTEXT; LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL)); methodHandle dest_method; switch (bc) { @@ -421,7 +421,7 @@ bool has_debug_info, bool has_unsafe_access, Handle installed_code) { - EXCEPTION_CONTEXT; + GRAAL_EXCEPTION_CONTEXT; NMethodSweeper::possibly_sweep(); nm = NULL; int comp_level = CompLevel_simple; diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/graal/graalEnv.hpp --- a/src/share/vm/graal/graalEnv.hpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/graal/graalEnv.hpp Mon Dec 03 17:54:05 2012 +0100 @@ -34,6 +34,19 @@ class CompileTask; +// Bring the Graal compiler thread into the VM state. +#define GRAAL_VM_ENTRY_MARK \ + JavaThread* thread = JavaThread::current(); \ + ThreadInVMfromNative __tiv(thread); \ + ResetNoHandleMark rnhm; \ + HandleMarkCleaner __hm(thread); \ + Thread* THREAD = thread; \ + debug_only(VMNativeEntryWrapper __vew;) + +#define GRAAL_EXCEPTION_CONTEXT \ + JavaThread* thread=JavaThread::current(); \ + Thread* THREAD = thread; + // // This class is the top level broker for requests from the compiler // to the VM. diff -r 1baf7f1e3f23 -r ce248dc0a656 src/share/vm/prims/jni.cpp --- a/src/share/vm/prims/jni.cpp Mon Dec 03 15:32:17 2012 +0100 +++ b/src/share/vm/prims/jni.cpp Mon Dec 03 17:54:05 2012 +0100 @@ -5152,8 +5152,8 @@ *(JNIEnv**)penv = thread->jni_environment(); #ifdef GRAAL - GraalCompiler* compiler = GraalCompiler::instance(); - compiler->initialize(); + GraalCompiler* graal_compiler = GraalCompiler::instance(); + graal_compiler->initialize(); #endif // Tracks the time application was running before GC