--- old/src/cpu/x86/vm/assembler_x86.cpp 2012-11-12 10:52:08.180661169 -0800 +++ new/src/cpu/x86/vm/assembler_x86.cpp 2012-11-12 10:52:08.020663181 -0800 @@ -212,14 +212,6 @@ return enc; } -static int encode(XMMRegister r) { - int enc = r->encoding(); - if (enc >= 8) { - enc -= 8; - } - return enc; -} - void Assembler::emit_arith_b(int op1, int op2, Register dst, int imm8) { assert(dst->has_byte_register(), "must have byte register"); assert(isByte(op1) && isByte(op2), "wrong opcode"); --- old/src/share/vm/compiler/compileLog.cpp 2012-11-12 10:52:08.168661320 -0800 +++ new/src/share/vm/compiler/compileLog.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -60,28 +60,6 @@ } -// Advance kind up to a null or space, return this tail. -// Make sure kind is null-terminated, not space-terminated. -// Use the buffer if necessary. -static const char* split_attrs(const char* &kind, char* buffer) { - const char* attrs = strchr(kind, ' '); - // Tease apart the first word from the rest: - if (attrs == NULL) { - return ""; // no attrs, no split - } else if (kind == buffer) { - ((char*) attrs)[-1] = 0; - return attrs; - } else { - // park it in the buffer, so we can put a null on the end - assert(!(kind >= buffer && kind < buffer+100), "not obviously in buffer"); - int klen = attrs - kind; - strncpy(buffer, kind, klen); - buffer[klen] = 0; - kind = buffer; // return by reference - return attrs; - } -} - // see_tag, pop_tag: Override the default do-nothing methods on xmlStream. // These methods provide a hook for managing the the extra context markup. void CompileLog::see_tag(const char* tag, bool push) { --- old/src/share/vm/gc_implementation/g1/ptrQueue.cpp 2012-11-12 10:52:08.184661119 -0800 +++ new/src/share/vm/gc_implementation/g1/ptrQueue.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -64,15 +64,6 @@ } -static int byte_index_to_index(int ind) { - assert((ind % oopSize) == 0, "Invariant."); - return ind / oopSize; -} - -static int index_to_byte_index(int byte_ind) { - return byte_ind * oopSize; -} - void PtrQueue::enqueue_known_active(void* ptr) { assert(0 <= _index && _index <= _sz, "Invariant."); assert(_index == 0 || _buf != NULL, "invariant"); --- old/src/share/vm/c1/c1_LIRGenerator.cpp 2012-11-12 10:52:08.216660716 -0800 +++ new/src/share/vm/c1/c1_LIRGenerator.cpp 2012-11-12 10:52:08.020663181 -0800 @@ -706,25 +706,6 @@ } } -static Value maxvalue(IfOp* ifop) { - switch (ifop->cond()) { - case If::eql: return NULL; - case If::neq: return NULL; - case If::lss: // x < y ? x : y - case If::leq: // x <= y ? x : y - if (ifop->x() == ifop->tval() && - ifop->y() == ifop->fval()) return ifop->y(); - return NULL; - - case If::gtr: // x > y ? y : x - case If::geq: // x >= y ? y : x - if (ifop->x() == ifop->tval() && - ifop->y() == ifop->fval()) return ifop->y(); - return NULL; - - } -} - static ciType* phi_declared_type(Phi* phi) { ciType* t = phi->operand_at(0)->declared_type(); if (t == NULL) { --- old/src/cpu/x86/vm/methodHandles_x86.cpp 2012-11-12 10:52:08.264660113 -0800 +++ new/src/cpu/x86/vm/methodHandles_x86.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -40,11 +40,6 @@ #define BIND(label) bind(label); BLOCK_COMMENT(#label ":") -// Workaround for C++ overloading nastiness on '0' for RegisterOrConstant. -static RegisterOrConstant constant(int value) { - return RegisterOrConstant(value); -} - void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) { if (VerifyMethodHandles) verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class), --- old/src/os/linux/vm/os_linux.cpp 2012-11-12 10:52:08.252660265 -0800 +++ new/src/os/linux/vm/os_linux.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -192,7 +192,6 @@ // utility functions static int SR_initialize(); -static int SR_finalize(); julong os::available_memory() { return Linux::available_memory(); @@ -3555,10 +3554,6 @@ return 0; } -static int SR_finalize() { - return 0; -} - // returns true on success and false on error - really an error is fatal // but this seems the normal response to library errors @@ -4402,16 +4397,6 @@ //////////////////////////////////////////////////////////////////////////////// // debug support -static address same_page(address x, address y) { - int page_bits = -os::vm_page_size(); - if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) - return x; - else if (x > y) - return (address)(intptr_t(y) | ~page_bits) + 1; - else - return (address)(intptr_t(y) & page_bits); -} - bool os::find(address addr, outputStream* st) { Dl_info dlinfo; memset(&dlinfo, 0, sizeof(dlinfo)); @@ -4435,8 +4420,8 @@ if (Verbose) { // decode some bytes around the PC - address begin = same_page(addr-40, addr); - address end = same_page(addr+40, addr); + address begin = clamp_address_in_page(addr-40, addr); + address end = clamp_address_in_page(addr+40, addr); address lowest = (address) dlinfo.dli_sname; if (!lowest) lowest = (address) dlinfo.dli_fbase; if (begin < lowest) begin = lowest; --- old/src/share/vm/compiler/compilerOracle.cpp 2012-11-12 10:52:08.248660316 -0800 +++ new/src/share/vm/compiler/compilerOracle.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -237,13 +237,6 @@ "help" }; -static const char * command_name(OracleCommand command) { - if (command < OracleFirstCommand || command >= OracleCommandCount) { - return "unknown command"; - } - return command_names[command]; -} - class MethodMatcher; static MethodMatcher* lists[OracleCommandCount] = { 0, }; --- old/src/os/bsd/vm/os_bsd.cpp 2012-11-12 10:52:08.264660113 -0800 +++ new/src/os/bsd/vm/os_bsd.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -170,7 +170,6 @@ // utility functions static int SR_initialize(); -static int SR_finalize(); julong os::available_memory() { return Bsd::available_memory(); @@ -2768,10 +2767,6 @@ return 0; } -static int SR_finalize() { - return 0; -} - // returns true on success and false on error - really an error is fatal // but this seems the normal response to library errors @@ -3578,16 +3573,6 @@ //////////////////////////////////////////////////////////////////////////////// // debug support -static address same_page(address x, address y) { - int page_bits = -os::vm_page_size(); - if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) - return x; - else if (x > y) - return (address)(intptr_t(y) | ~page_bits) + 1; - else - return (address)(intptr_t(y) & page_bits); -} - bool os::find(address addr, outputStream* st) { Dl_info dlinfo; memset(&dlinfo, 0, sizeof(dlinfo)); @@ -3611,8 +3596,8 @@ if (Verbose) { // decode some bytes around the PC - address begin = same_page(addr-40, addr); - address end = same_page(addr+40, addr); + address begin = clamp_address_in_page(addr-40, addr); + address end = clamp_address_in_page(addr+40, addr); address lowest = (address) dlinfo.dli_sname; if (!lowest) lowest = (address) dlinfo.dli_fbase; if (begin < lowest) begin = lowest; --- old/src/cpu/x86/vm/x86_64.ad 2012-11-12 10:52:08.288659813 -0800 +++ new/src/cpu/x86/vm/x86_64.ad 2012-11-12 10:52:08.016663231 -0800 @@ -1669,17 +1669,6 @@ return PTR_RBP_REG_mask(); } -static Address build_address(int b, int i, int s, int d) { - Register index = as_Register(i); - Address::ScaleFactor scale = (Address::ScaleFactor)s; - if (index == rsp) { - index = noreg; - scale = Address::no_scale; - } - Address addr(as_Register(b), index, scale, d); - return addr; -} - %} //----------ENCODING BLOCK----------------------------------------------------- --- old/make/linux/makefiles/gcc.make 2012-11-12 10:52:08.328659310 -0800 +++ new/make/linux/makefiles/gcc.make 2012-11-12 10:52:08.016663231 -0800 @@ -136,7 +136,9 @@ ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare endif -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS) +ADDITIONAL_WARNINGS = -Wunused-function + +CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS) $(ADDITIONAL_WARNINGS) # Special cases CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) --- old/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp 2012-11-12 10:52:08.292659762 -0800 +++ new/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp 2012-11-12 10:52:08.020663181 -0800 @@ -1353,7 +1353,7 @@ #ifndef PRODUCT // for debugging, bit of a hack... -static char* +char* region_num_to_mbs(int length) { static char buffer[64]; double bytes = (double) (length * HeapRegion::GrainBytes); --- old/src/os/solaris/vm/os_solaris.cpp 2012-11-12 10:52:08.336659208 -0800 +++ new/src/os/solaris/vm/os_solaris.cpp 2012-11-12 10:52:08.016663231 -0800 @@ -5797,16 +5797,6 @@ //--------------------------------------------------------------------------------- -static address same_page(address x, address y) { - intptr_t page_bits = -os::vm_page_size(); - if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) - return x; - else if (x > y) - return (address)(intptr_t(y) | ~page_bits) + 1; - else - return (address)(intptr_t(y) & page_bits); -} - bool os::find(address addr, outputStream* st) { Dl_info dlinfo; memset(&dlinfo, 0, sizeof(dlinfo)); @@ -5832,8 +5822,8 @@ if (Verbose) { // decode some bytes around the PC - address begin = same_page(addr-40, addr); - address end = same_page(addr+40, addr); + address begin = clamp_address_in_page(addr-40, addr); + address end = clamp_address_in_page(addr+40, addr); address lowest = (address) dlinfo.dli_sname; if (!lowest) lowest = (address) dlinfo.dli_fbase; if (begin < lowest) begin = lowest; --- old/src/share/vm/prims/jni.cpp 2012-11-12 10:52:09.672642413 -0800 +++ new/src/share/vm/prims/jni.cpp 2012-11-12 10:52:09.460645079 -0800 @@ -1290,32 +1290,6 @@ JNI_NONVIRTUAL }; -static methodHandle jni_resolve_interface_call(Handle recv, methodHandle method, TRAPS) { - assert(!method.is_null() , "method should not be null"); - - KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) - if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); - KlassHandle spec_klass (THREAD, method->method_holder()); - Symbol* name = method->name(); - Symbol* signature = method->signature(); - CallInfo info; - LinkResolver::resolve_interface_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); - return info.selected_method(); -} - -static methodHandle jni_resolve_virtual_call(Handle recv, methodHandle method, TRAPS) { - assert(!method.is_null() , "method should not be null"); - - KlassHandle recv_klass; // Default to NULL (use of ?: can confuse gcc) - if (recv.not_null()) recv_klass = KlassHandle(THREAD, recv->klass()); - KlassHandle spec_klass (THREAD, method->method_holder()); - Symbol* name = method->name(); - Symbol* signature = method->signature(); - CallInfo info; - LinkResolver::resolve_virtual_call(info, recv, recv_klass, spec_klass, name, signature, KlassHandle(), false, true, CHECK_(methodHandle())); - return info.selected_method(); -} - static void jni_invoke_static(JNIEnv *env, JavaValue* result, jobject receiver, JNICallType call_type, jmethodID method_id, JNI_ArgumentPusher *args, TRAPS) { @@ -5051,6 +5025,7 @@ void execute_internal_vm_tests() { if (ExecuteInternalVMTests) { tty->print_cr("Running internal VM tests"); + run_unit_test(GlobalDefinitions::test_globals()); run_unit_test(arrayOopDesc::test_max_array_length()); run_unit_test(CollectedHeap::test_is_in()); run_unit_test(QuickSort::test_quick_sort()); --- old/src/share/vm/oops/constantPool.cpp 2012-11-12 10:52:09.688642212 -0800 +++ new/src/share/vm/oops/constantPool.cpp 2012-11-12 10:52:09.464645028 -0800 @@ -1389,7 +1389,8 @@ // JVMTI GetConstantPool support // For temporary use until code is stable. -#define DBG(code) +#if DEBUG_CPOOL +#define DBG(code) code static const char* WARN_MSG = "Must not be such entry!"; @@ -1516,6 +1517,12 @@ return; } /* end print_cpool_bytes */ +#else + +#define DBG(code) + +#endif + // Returns size of constant pool entry. jint ConstantPool::cpool_entry_size(jint idx) { --- old/src/share/vm/opto/block.cpp 2012-11-12 10:52:09.684642263 -0800 +++ new/src/share/vm/opto/block.cpp 2012-11-12 10:52:09.476644877 -0800 @@ -1028,7 +1028,7 @@ } #ifndef PRODUCT -static void edge_dump(GrowableArray *edges) { +void edge_dump(GrowableArray *edges) { tty->print_cr("---- Edges ----"); for (int i = 0; i < edges->length(); i++) { CFGEdge *e = edges->at(i); @@ -1038,7 +1038,7 @@ } } -static void trace_dump(Trace *traces[], int count) { +void trace_dump(Trace *traces[], int count) { tty->print_cr("---- Traces ----"); for (int i = 0; i < count; i++) { Trace *tr = traces[i]; --- old/src/share/vm/opto/connode.cpp 2012-11-12 10:52:09.708641960 -0800 +++ new/src/share/vm/opto/connode.cpp 2012-11-12 10:52:09.472644927 -0800 @@ -465,29 +465,6 @@ return (phase->type(in(1)) == phase->type(this)) ? in(1) : this; } -// Determine whether "n" is a node which can cause an alias of one of its inputs. Node types -// which can create aliases are: CheckCastPP, Phi, and any store (if there is also a load from -// the location.) -// Note: this checks for aliases created in this compilation, not ones which may -// be potentially created at call sites. -static bool can_cause_alias(Node *n, PhaseTransform *phase) { - bool possible_alias = false; - - if (n->is_Store()) { - possible_alias = !n->as_Store()->value_never_loaded(phase); - } else { - int opc = n->Opcode(); - possible_alias = n->is_Phi() || - opc == Op_CheckCastPP || - opc == Op_StorePConditional || - opc == Op_CompareAndSwapP || - opc == Op_CompareAndSwapN || - opc == Op_GetAndSetP || - opc == Op_GetAndSetN; - } - return possible_alias; -} - //------------------------------Value------------------------------------------ // Take 'join' of input and cast-up type, unless working with an Interface const Type *CheckCastPPNode::Value( PhaseTransform *phase ) const { --- old/src/share/vm/prims/jniCheck.hpp 2012-11-12 10:52:09.716641860 -0800 +++ new/src/share/vm/prims/jniCheck.hpp 2012-11-12 10:52:09.468644977 -0800 @@ -35,7 +35,7 @@ // within IN_VM macro), one to be called when in NATIVE state. // When in VM state: - static void ReportJNIFatalError(JavaThread* thr, const char *msg) { + static inline void ReportJNIFatalError(JavaThread* thr, const char *msg) { tty->print_cr("FATAL ERROR in native method: %s", msg); thr->print_stack(); os::abort(true); --- old/src/share/vm/opto/compile.cpp 2012-11-12 10:52:09.740641557 -0800 +++ new/src/share/vm/opto/compile.cpp 2012-11-12 10:52:09.480644827 -0800 @@ -2078,12 +2078,14 @@ int get_inner_loop_count() const { return _inner_loop_count; } }; +#ifdef ASSERT static bool oop_offset_is_sane(const TypeInstPtr* tp) { ciInstanceKlass *k = tp->klass()->as_instance_klass(); // Make sure the offset goes inside the instance layout. return k->contains_field_offset(tp->offset()); // Note that OffsetBot and OffsetTop are very negative. } +#endif // Eliminate trivially redundant StoreCMs and accumulate their // precedence edges. --- old/src/share/vm/memory/heap.cpp 2012-11-12 10:52:09.736641608 -0800 +++ new/src/share/vm/memory/heap.cpp 2012-11-12 10:52:09.476644877 -0800 @@ -79,13 +79,6 @@ } -static size_t align_to_allocation_size(size_t size) { - const size_t alignment = (size_t)os::vm_allocation_granularity(); - assert(is_power_of_2(alignment), "no kidding ???"); - return (size + alignment - 1) & ~(alignment - 1); -} - - void CodeHeap::on_code_mapping(char* base, size_t size) { #ifdef LINUX extern void linux_wrap_code(char* base, size_t size); --- old/src/share/vm/interpreter/interpreterRuntime.cpp 2012-11-12 10:52:09.748641457 -0800 +++ new/src/share/vm/interpreter/interpreterRuntime.cpp 2012-11-12 10:52:09.504644525 -0800 @@ -556,10 +556,6 @@ // be shared by method invocation and synchronized blocks. //%note synchronization_3 -static void trace_locking(Handle& h_locking_obj, bool is_locking) { - ObjectSynchronizer::trace_locking(h_locking_obj, false, true, is_locking); -} - //%note monitor_1 IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem)) --- old/src/share/vm/opto/subnode.cpp 2012-11-12 10:52:09.708641960 -0800 +++ new/src/share/vm/opto/subnode.cpp 2012-11-12 10:52:09.480644827 -0800 @@ -1078,16 +1078,6 @@ return (_test._test == b->_test._test); } -//------------------------------clone_cmp-------------------------------------- -// Clone a compare/bool tree -static Node *clone_cmp( Node *cmp, Node *cmp1, Node *cmp2, PhaseGVN *gvn, BoolTest::mask test ) { - Node *ncmp = cmp->clone(); - ncmp->set_req(1,cmp1); - ncmp->set_req(2,cmp2); - ncmp = gvn->transform( ncmp ); - return new (gvn->C) BoolNode( ncmp, test ); -} - //-------------------------------make_predicate-------------------------------- Node* BoolNode::make_predicate(Node* test_value, PhaseGVN* phase) { if (test_value->is_Con()) return test_value; @@ -1216,51 +1206,6 @@ return new (phase->C) BoolNode( ncmp, _test.commute() ); } - // The transformation below is not valid for either signed or unsigned - // comparisons due to wraparound concerns at MAX_VALUE and MIN_VALUE. - // This transformation can be resurrected when we are able to - // make inferences about the range of values being subtracted from - // (or added to) relative to the wraparound point. - // - // // Remove +/-1's if possible. - // // "X <= Y-1" becomes "X < Y" - // // "X+1 <= Y" becomes "X < Y" - // // "X < Y+1" becomes "X <= Y" - // // "X-1 < Y" becomes "X <= Y" - // // Do not this to compares off of the counted-loop-end. These guys are - // // checking the trip counter and they want to use the post-incremented - // // counter. If they use the PRE-incremented counter, then the counter has - // // to be incremented in a private block on a loop backedge. - // if( du && du->cnt(this) && du->out(this)[0]->Opcode() == Op_CountedLoopEnd ) - // return NULL; - // #ifndef PRODUCT - // // Do not do this in a wash GVN pass during verification. - // // Gets triggered by too many simple optimizations to be bothered with - // // re-trying it again and again. - // if( !phase->allow_progress() ) return NULL; - // #endif - // // Not valid for unsigned compare because of corner cases in involving zero. - // // For example, replacing "X-1 Opcode() == Op_CmpU ) return NULL; - // int cmp2_op = cmp2->Opcode(); - // if( _test._test == BoolTest::le ) { - // if( cmp1_op == Op_AddI && - // phase->type( cmp1->in(2) ) == TypeInt::ONE ) - // return clone_cmp( cmp, cmp1->in(1), cmp2, phase, BoolTest::lt ); - // else if( cmp2_op == Op_AddI && - // phase->type( cmp2->in(2) ) == TypeInt::MINUS_1 ) - // return clone_cmp( cmp, cmp1, cmp2->in(1), phase, BoolTest::lt ); - // } else if( _test._test == BoolTest::lt ) { - // if( cmp1_op == Op_AddI && - // phase->type( cmp1->in(2) ) == TypeInt::MINUS_1 ) - // return clone_cmp( cmp, cmp1->in(1), cmp2, phase, BoolTest::le ); - // else if( cmp2_op == Op_AddI && - // phase->type( cmp2->in(2) ) == TypeInt::ONE ) - // return clone_cmp( cmp, cmp1, cmp2->in(1), phase, BoolTest::le ); - // } - return NULL; } --- old/src/share/vm/runtime/safepoint.cpp 2012-11-12 10:52:09.736641608 -0800 +++ new/src/share/vm/runtime/safepoint.cpp 2012-11-12 10:52:09.480644827 -0800 @@ -745,6 +745,9 @@ // Exception handlers #ifndef PRODUCT + +#ifdef SPARC + #ifdef _LP64 #define PTR_PAD "" #else @@ -765,7 +768,6 @@ newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" ")); } -#ifdef SPARC static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) { #ifdef _LP64 tty->print_cr("--------+------address-----+------before-----------+-------after----------+"); --- old/src/share/vm/memory/universe.cpp 2012-11-12 10:52:09.744641507 -0800 +++ new/src/share/vm/memory/universe.cpp 2012-11-12 10:52:09.476644877 -0800 @@ -1321,6 +1321,8 @@ static uintptr_t _verify_klass_data[2] = {0, (uintptr_t)-1}; +#ifndef PRODUCT + static void calculate_verify_data(uintptr_t verify_data[2], HeapWord* low_boundary, HeapWord* high_boundary) { @@ -1355,9 +1357,7 @@ verify_data[1] = bits; } - // Oop verification (see MacroAssembler::verify_oop) -#ifndef PRODUCT uintptr_t Universe::verify_oop_mask() { MemRegion m = heap()->reserved_region(); --- old/src/share/vm/runtime/arguments.cpp 2012-11-12 10:52:09.752641407 -0800 +++ new/src/share/vm/runtime/arguments.cpp 2012-11-12 10:52:09.540644073 -0800 @@ -1718,6 +1718,7 @@ return false; } +#ifdef SERIALGC static void force_serial_gc() { FLAG_SET_DEFAULT(UseSerialGC, true); FLAG_SET_DEFAULT(UseParNewGC, false); @@ -1728,11 +1729,15 @@ FLAG_SET_DEFAULT(UseG1GC, false); } +#ifdef ASSERT static bool verify_serial_gc_flags() { return (UseSerialGC && !(UseParNewGC || (UseConcMarkSweepGC || CMSIncrementalMode) || UseG1GC || UseParallelGC || UseParallelOldGC)); } +#endif // ASSERT + +#endif // SERIALGC // check if do gclog rotation // +UseGCLogFileRotation is a must, --- old/src/share/vm/utilities/globalDefinitions.cpp 2012-11-12 10:52:11.648617572 -0800 +++ new/src/share/vm/utilities/globalDefinitions.cpp 2012-11-12 10:52:11.564618628 -0800 @@ -355,3 +355,49 @@ return size_t(result); } + +// Clamp an address to be within a specific page +// 1. If the address is on the page it is returned as is +// 2. If the address is above the page_address the start of the *next* page will be returned +// 3. If the address is below the page_address the start of the page will be returned +static address clamp_address_in_page(address addr, address page_address, intptr_t page_size) { + if (align_size_down(intptr_t(addr), page_size) == align_size_down(intptr_t(page_address), page_size)) { + // address is in the specified page, just return it as is + return addr; + } else if (addr > page_address) { + // address is on above specified page, return start of next page + return (address)align_size_down(intptr_t(page_address), page_size) + page_size; + } else { + // address is below specified page, return start of page + return (address)align_size_down(intptr_t(page_address), page_size); + } +} + +address clamp_address_in_page(address addr, address page_address) { + intptr_t page_size = os::vm_page_size(); + return clamp_address_in_page(addr, page_address, page_size); +} + +#ifndef PRODUCT + +void GlobalDefinitions::test_globals() { + intptr_t page_size = 4096; + address a_page = (address)(10*page_size); + + // Check that address within page is returned as is + assert(clamp_address_in_page(a_page, a_page, 4096) == a_page, "incorrect"); + assert(clamp_address_in_page(a_page + 128, a_page, 4096) == a_page + 128, "incorrect"); + assert(clamp_address_in_page(a_page + page_size - 1, a_page, 4096) == a_page + page_size - 1, "incorrect"); + + // Check that address above page returns start of next page + assert(clamp_address_in_page(a_page + page_size, a_page, 4096) == a_page + page_size, "incorrect"); + assert(clamp_address_in_page(a_page + page_size + 1, a_page, 4096) == a_page + page_size, "incorrect"); + assert(clamp_address_in_page(a_page + page_size*5 + 1, a_page, 4096) == a_page + page_size, "incorrect"); + + // Check that address below page returns start of page + assert(clamp_address_in_page(a_page - 1, a_page, 4096) == a_page, "incorrect"); + assert(clamp_address_in_page(a_page - 2*page_size - 1, a_page, 4096) == a_page, "incorrect"); + assert(clamp_address_in_page(a_page - 5*page_size - 1, a_page, 4096) == a_page, "incorrect"); +} + +#endif // PRODUCT --- old/src/share/vm/utilities/globalDefinitions.hpp 2012-11-12 10:52:11.648617572 -0800 +++ new/src/share/vm/utilities/globalDefinitions.hpp 2012-11-12 10:52:11.560618678 -0800 @@ -413,6 +413,13 @@ return align_size_up(offset, HeapWordsPerLong); } +// Clamp an address to be within a specific page +// 1. If addr is on the page it is returned as is +// 2. If addr is above the page_address the start of the *next* page will be returned +// 3. Otherwise, if addr is below the page_address the start of the page will be returned +address clamp_address_in_page(address addr, address page_address); + + // The expected size in bytes of a cache line, used to pad data structures. #define DEFAULT_CACHE_LINE_SIZE 64 @@ -1274,4 +1281,15 @@ #define ARRAY_SIZE(array) (sizeof(array)/sizeof((array)[0])) + +#ifndef PRODUCT + +// For unit testing only +class GlobalDefinitions { +public: + static void test_globals(); +}; + +#endif // PRODUCT + #endif // SHARE_VM_UTILITIES_GLOBALDEFINITIONS_HPP --- old/src/share/vm/utilities/debug.cpp 2012-11-12 10:52:11.648617572 -0800 +++ new/src/share/vm/utilities/debug.cpp 2012-11-12 10:52:11.560618678 -0800 @@ -642,18 +642,6 @@ return CodeCache::find_nmethod((address)addr); } -static address same_page(address x, address y) { - intptr_t page_bits = -os::vm_page_size(); - if ((intptr_t(x) & page_bits) == (intptr_t(y) & page_bits)) { - return x; - } else if (x > y) { - return (address)(intptr_t(y) | ~page_bits) + 1; - } else { - return (address)(intptr_t(y) & page_bits); - } -} - - // Another interface that isn't ambiguous in dbx. // Can we someday rename the other find to hsfind? extern "C" void hsfind(intptr_t x) { --- old/src/share/vm/runtime/synchronizer.cpp 2012-11-12 10:52:11.664617370 -0800 +++ new/src/share/vm/runtime/synchronizer.cpp 2012-11-12 10:52:11.564618628 -0800 @@ -450,8 +450,6 @@ // and explicit fences (barriers) to control for architectural reordering performed // by the CPU(s) or platform. -static int MBFence (int x) { OrderAccess::fence(); return x; } - struct SharedGlobals { // These are highly shared mostly-read variables. // To avoid false-sharing they need to be the sole occupants of a $ line.