Fri, 27 Nov 2009 07:56:58 -0800
6896043: first round of zero fixes
Reviewed-by: kvn
Contributed-by: Gary Benson <gbenson@redhat.com>
1.1 --- a/src/cpu/zero/vm/cppInterpreter_zero.cpp Tue Nov 24 11:49:42 2009 -0800 1.2 +++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp Fri Nov 27 07:56:58 2009 -0800 1.3 @@ -204,6 +204,20 @@ 1.4 goto unwind_and_return; 1.5 } 1.6 1.7 + // Update the invocation counter 1.8 + if ((UseCompiler || CountCompiledCalls) && !method->is_synchronized()) { 1.9 + thread->set_do_not_unlock(); 1.10 + InvocationCounter *counter = method->invocation_counter(); 1.11 + counter->increment(); 1.12 + if (counter->reached_InvocationLimit()) { 1.13 + CALL_VM_NOCHECK( 1.14 + InterpreterRuntime::frequency_counter_overflow(thread, NULL)); 1.15 + if (HAS_PENDING_EXCEPTION) 1.16 + goto unwind_and_return; 1.17 + } 1.18 + thread->clr_do_not_unlock(); 1.19 + } 1.20 + 1.21 // Lock if necessary 1.22 BasicObjectLock *monitor; 1.23 monitor = NULL;
2.1 --- a/src/cpu/zero/vm/frame_zero.cpp Tue Nov 24 11:49:42 2009 -0800 2.2 +++ b/src/cpu/zero/vm/frame_zero.cpp Fri Nov 27 07:56:58 2009 -0800 2.3 @@ -36,11 +36,8 @@ 2.4 return zeroframe()->is_interpreter_frame(); 2.5 } 2.6 2.7 -bool frame::is_fake_stub_frame() const { 2.8 - return zeroframe()->is_fake_stub_frame(); 2.9 -} 2.10 - 2.11 frame frame::sender_for_entry_frame(RegisterMap *map) const { 2.12 + assert(zeroframe()->is_entry_frame(), "wrong type of frame"); 2.13 assert(map != NULL, "map must be set"); 2.14 assert(!entry_frame_is_first(), "next Java fp must be non zero"); 2.15 assert(entry_frame_call_wrapper()->anchor()->last_Java_sp() == sender_sp(), 2.16 @@ -50,15 +47,10 @@ 2.17 return frame(sender_sp(), sp() + 1); 2.18 } 2.19 2.20 -frame frame::sender_for_interpreter_frame(RegisterMap *map) const { 2.21 - return frame(sender_sp(), sp() + 1); 2.22 -} 2.23 - 2.24 -frame frame::sender_for_compiled_frame(RegisterMap *map) const { 2.25 - return frame(sender_sp(), sp() + 1); 2.26 -} 2.27 - 2.28 -frame frame::sender_for_fake_stub_frame(RegisterMap *map) const { 2.29 +frame frame::sender_for_nonentry_frame(RegisterMap *map) const { 2.30 + assert(zeroframe()->is_interpreter_frame() || 2.31 + zeroframe()->is_shark_frame() || 2.32 + zeroframe()->is_fake_stub_frame(), "wrong type of frame"); 2.33 return frame(sender_sp(), sp() + 1); 2.34 } 2.35 2.36 @@ -69,17 +61,8 @@ 2.37 2.38 if (is_entry_frame()) 2.39 return sender_for_entry_frame(map); 2.40 - 2.41 - if (is_interpreted_frame()) 2.42 - return sender_for_interpreter_frame(map); 2.43 - 2.44 - if (is_compiled_frame()) 2.45 - return sender_for_compiled_frame(map); 2.46 - 2.47 - if (is_fake_stub_frame()) 2.48 - return sender_for_fake_stub_frame(map); 2.49 - 2.50 - ShouldNotReachHere(); 2.51 + else 2.52 + return sender_for_nonentry_frame(map); 2.53 } 2.54 2.55 #ifdef CC_INTERP
3.1 --- a/src/cpu/zero/vm/frame_zero.hpp Tue Nov 24 11:49:42 2009 -0800 3.2 +++ b/src/cpu/zero/vm/frame_zero.hpp Fri Nov 27 07:56:58 2009 -0800 3.3 @@ -65,10 +65,7 @@ 3.4 } 3.5 3.6 public: 3.7 - bool is_fake_stub_frame() const; 3.8 - 3.9 - public: 3.10 - frame sender_for_fake_stub_frame(RegisterMap* map) const; 3.11 + frame sender_for_nonentry_frame(RegisterMap* map) const; 3.12 3.13 public: 3.14 void zero_print_on_error(int index,
4.1 --- a/src/cpu/zero/vm/globals_zero.hpp Tue Nov 24 11:49:42 2009 -0800 4.2 +++ b/src/cpu/zero/vm/globals_zero.hpp Fri Nov 27 07:56:58 2009 -0800 4.3 @@ -36,7 +36,6 @@ 4.4 4.5 define_pd_global(intx, CodeEntryAlignment, 32); 4.6 define_pd_global(intx, InlineFrequencyCount, 100); 4.7 -define_pd_global(intx, InlineSmallCode, 1000); 4.8 define_pd_global(intx, PreInflateSpin, 10); 4.9 4.10 define_pd_global(intx, StackYellowPages, 2);
5.1 --- a/src/cpu/zero/vm/sharedRuntime_zero.cpp Tue Nov 24 11:49:42 2009 -0800 5.2 +++ b/src/cpu/zero/vm/sharedRuntime_zero.cpp Fri Nov 27 07:56:58 2009 -0800 5.3 @@ -1,6 +1,6 @@ 5.4 /* 5.5 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. 5.6 - * Copyright 2007, 2008 Red Hat, Inc. 5.7 + * Copyright 2007, 2008, 2009 Red Hat, Inc. 5.8 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.9 * 5.10 * This code is free software; you can redistribute it and/or modify it 5.11 @@ -61,7 +61,14 @@ 5.12 BasicType *in_sig_bt, 5.13 VMRegPair *in_regs, 5.14 BasicType ret_type) { 5.15 +#ifdef SHARK 5.16 + return SharkCompiler::compiler()->generate_native_wrapper(masm, 5.17 + method, 5.18 + in_sig_bt, 5.19 + ret_type); 5.20 +#else 5.21 ShouldNotCallThis(); 5.22 +#endif // SHARK 5.23 } 5.24 5.25 int Deoptimization::last_frame_adjust(int callee_parameters,
6.1 --- a/src/cpu/zero/vm/sharkFrame_zero.hpp Tue Nov 24 11:49:42 2009 -0800 6.2 +++ b/src/cpu/zero/vm/sharkFrame_zero.hpp Fri Nov 27 07:56:58 2009 -0800 6.3 @@ -1,6 +1,6 @@ 6.4 /* 6.5 * Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. 6.6 - * Copyright 2008 Red Hat, Inc. 6.7 + * Copyright 2008, 2009 Red Hat, Inc. 6.8 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.9 * 6.10 * This code is free software; you can redistribute it and/or modify it 6.11 @@ -41,7 +41,7 @@ 6.12 // | ... | 6.13 6.14 class SharkFrame : public ZeroFrame { 6.15 - friend class SharkFunction; 6.16 + friend class SharkStack; 6.17 6.18 private: 6.19 SharkFrame() : ZeroFrame() {
7.1 --- a/src/share/vm/interpreter/bytecodeInterpreter.cpp Tue Nov 24 11:49:42 2009 -0800 7.2 +++ b/src/share/vm/interpreter/bytecodeInterpreter.cpp Fri Nov 27 07:56:58 2009 -0800 7.3 @@ -281,7 +281,7 @@ 7.4 7.5 #define DO_BACKEDGE_CHECKS(skip, branch_pc) \ 7.6 if ((skip) <= 0) { \ 7.7 - if (UseCompiler && UseLoopCounter) { \ 7.8 + if (UseLoopCounter) { \ 7.9 bool do_OSR = UseOnStackReplacement; \ 7.10 BACKEDGE_COUNT->increment(); \ 7.11 if (do_OSR) do_OSR = BACKEDGE_COUNT->reached_InvocationLimit(); \ 7.12 @@ -289,16 +289,12 @@ 7.13 nmethod* osr_nmethod; \ 7.14 OSR_REQUEST(osr_nmethod, branch_pc); \ 7.15 if (osr_nmethod != NULL && osr_nmethod->osr_entry_bci() != InvalidOSREntryBci) { \ 7.16 - intptr_t* buf; \ 7.17 - CALL_VM(buf=SharedRuntime::OSR_migration_begin(THREAD), handle_exception); \ 7.18 + intptr_t* buf = SharedRuntime::OSR_migration_begin(THREAD); \ 7.19 istate->set_msg(do_osr); \ 7.20 istate->set_osr_buf((address)buf); \ 7.21 istate->set_osr_entry(osr_nmethod->osr_entry()); \ 7.22 return; \ 7.23 } \ 7.24 - } else { \ 7.25 - INCR_INVOCATION_COUNT; \ 7.26 - SAFEPOINT; \ 7.27 } \ 7.28 } /* UseCompiler ... */ \ 7.29 INCR_INVOCATION_COUNT; \ 7.30 @@ -1281,12 +1277,7 @@ 7.31 jfloat f; 7.32 jdouble r; 7.33 f = STACK_FLOAT(-1); 7.34 -#ifdef IA64 7.35 - // IA64 gcc bug 7.36 - r = ( f == 0.0f ) ? (jdouble) f : (jdouble) f + ia64_double_zero; 7.37 -#else 7.38 r = (jdouble) f; 7.39 -#endif 7.40 MORE_STACK(-1); // POP 7.41 SET_STACK_DOUBLE(r, 1); 7.42 UPDATE_PC_AND_TOS_AND_CONTINUE(1, 2);
8.1 --- a/src/share/vm/prims/jni.cpp Tue Nov 24 11:49:42 2009 -0800 8.2 +++ b/src/share/vm/prims/jni.cpp Fri Nov 27 07:56:58 2009 -0800 8.3 @@ -3231,6 +3231,21 @@ 8.4 jint result = JNI_ERR; 8.5 DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); 8.6 8.7 + // We're about to use Atomic::xchg for synchronization. Some Zero 8.8 + // platforms use the GCC builtin __sync_lock_test_and_set for this, 8.9 + // but __sync_lock_test_and_set is not guaranteed to do what we want 8.10 + // on all architectures. So we check it works before relying on it. 8.11 +#if defined(ZERO) && defined(ASSERT) 8.12 + { 8.13 + jint a = 0xcafebabe; 8.14 + jint b = Atomic::xchg(0xdeadbeef, &a); 8.15 + void *c = &a; 8.16 + void *d = Atomic::xchg_ptr(&b, &c); 8.17 + assert(a == 0xdeadbeef && b == (jint) 0xcafebabe, "Atomic::xchg() works"); 8.18 + assert(c == &b && d == &a, "Atomic::xchg_ptr() works"); 8.19 + } 8.20 +#endif // ZERO && ASSERT 8.21 + 8.22 // At the moment it's only possible to have one Java VM, 8.23 // since some of the runtime state is in global variables. 8.24
9.1 --- a/src/share/vm/prims/jvmtiManageCapabilities.cpp Tue Nov 24 11:49:42 2009 -0800 9.2 +++ b/src/share/vm/prims/jvmtiManageCapabilities.cpp Fri Nov 27 07:56:58 2009 -0800 9.3 @@ -115,8 +115,10 @@ 9.4 jvmtiCapabilities jc; 9.5 9.6 memset(&jc, 0, sizeof(jc)); 9.7 +#ifndef CC_INTERP 9.8 jc.can_pop_frame = 1; 9.9 jc.can_force_early_return = 1; 9.10 +#endif // !CC_INTERP 9.11 jc.can_get_source_debug_extension = 1; 9.12 jc.can_access_local_variables = 1; 9.13 jc.can_maintain_original_method_order = 1;
10.1 --- a/src/share/vm/runtime/os.hpp Tue Nov 24 11:49:42 2009 -0800 10.2 +++ b/src/share/vm/runtime/os.hpp Fri Nov 27 07:56:58 2009 -0800 10.3 @@ -294,19 +294,16 @@ 10.4 } 10.5 10.6 static bool is_memory_serialize_page(JavaThread *thread, address addr) { 10.7 - address thr_addr; 10.8 if (UseMembar) return false; 10.9 - // Calculate thread specific address 10.10 + // Previously this function calculated the exact address of this 10.11 + // thread's serialize page, and checked if the faulting address 10.12 + // was equal. However, some platforms mask off faulting addresses 10.13 + // to the page size, so now we just check that the address is 10.14 + // within the page. This makes the thread argument unnecessary, 10.15 + // but we retain the NULL check to preserve existing behaviour. 10.16 if (thread == NULL) return false; 10.17 - // TODO-FIXME: some platforms mask off faulting addresses to the base pagesize. 10.18 - // Instead of using a test for equality we should probably use something 10.19 - // of the form: 10.20 - // return ((_mem_serialize_page ^ addr) & -pagesize) == 0 10.21 - // 10.22 - thr_addr = (address)(((uintptr_t)thread >> 10.23 - get_serialize_page_shift_count()) & 10.24 - get_serialize_page_mask()) + (uintptr_t)_mem_serialize_page; 10.25 - return (thr_addr == addr); 10.26 + address page = (address) _mem_serialize_page; 10.27 + return addr >= page && addr < (page + os::vm_page_size()); 10.28 } 10.29 10.30 static void block_on_serialize_page_trap();