# HG changeset patch # User Christos Kotselidis # Date 1362506006 -3600 # Node ID 992f62c457b074b9ce79672eefb7432982fc9ab7 # Parent 96a337d307bdb539e3307b4cbde13a75b9550761 -More bug fixes diff -r 96a337d307bd -r 992f62c457b0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VerOopStubCall.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nodes/VerOopStubCall.java Tue Mar 05 18:53:26 2013 +0100 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.hotspot.nodes; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; +import com.oracle.graal.compiler.gen.*; +import com.oracle.graal.compiler.target.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.type.*; + +/** + * Node implementing a call to HotSpot's {@code graal_monitorenter} stub. + */ +public class VerOopStubCall extends FixedWithNextNode implements LIRGenLowerable { + + @Input private final ValueNode object; + public static final Descriptor VEROOPCALL = new Descriptor("veroopcall", true, void.class, Object.class); + + public VerOopStubCall(ValueNode object) { + super(StampFactory.forVoid()); + this.object = object; + } + + @Override + public void generate(LIRGenerator gen) { + RuntimeCallTarget stub = gen.getRuntime().lookupRuntimeCall(VerOopStubCall.VEROOPCALL); + gen.emitCall(stub, stub.getCallingConvention(), true, gen.operand(object)); + } + + @NodeIntrinsic + public static native void call(Object hub); +} diff -r 96a337d307bd -r 992f62c457b0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Mon Mar 04 16:46:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/NewObjectSnippets.java Tue Mar 05 18:53:26 2013 +0100 @@ -29,8 +29,8 @@ import static com.oracle.graal.snippets.Snippet.Varargs.*; import static com.oracle.graal.snippets.SnippetTemplate.*; import static com.oracle.graal.snippets.SnippetTemplate.Arguments.*; +import static com.oracle.graal.snippets.nodes.BranchProbabilityNode.*; import static com.oracle.graal.snippets.nodes.ExplodeLoopNode.*; -import static com.oracle.graal.snippets.nodes.BranchProbabilityNode.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; @@ -59,6 +59,11 @@ // @formatter:off + private static void trace(boolean enabled, String format, WordBase value) { + if (enabled) { + Log.printf(format, value.rawValue()); + } + } @Snippet public static Word allocate(@Parameter("size") int size) { Word thread = thread(); @@ -69,7 +74,10 @@ if (newTop.belowOrEqual(end)) { probability(FAST_PATH_PROBABILITY); thread.writeWord(threadTlabTopOffset(), newTop); + trace(true, " Allocate object at: 0x%016lx\n", newTop); + return top; + } return Word.zero(); } diff -r 96a337d307bd -r 992f62c457b0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Mon Mar 04 16:46:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/snippets/WriteBarrierSnippets.java Tue Mar 05 18:53:26 2013 +0100 @@ -40,20 +40,12 @@ public class WriteBarrierSnippets implements SnippetsInterface { - private static final boolean TRACE = true; + private static final boolean TRACE = false; private static final SnippetCounter.Group counters = WriteBarrierSnippets.TRACE ? new SnippetCounter.Group("GC") : null; private static final SnippetCounter g1PreCounter = new SnippetCounter(counters, "G1-PRE", "G1-PRE"); private static final SnippetCounter g1PostCounter = new SnippetCounter(counters, "G1-POST", "G1-POST"); - private static void traceObject(boolean enabled, String action, Object object) { - if (enabled) { - Log.print(action); - Log.print(' '); - Log.printlnObject(object); - } - } - @Snippet public static void g1PreWriteBarrier(@Parameter("object") Object object, @Parameter("location") Object location, @ConstantParameter("doLoad") boolean doLoad) { Word thread = thread(); @@ -139,7 +131,7 @@ trace(WriteBarrierSnippets.TRACE, " G1 POST Word.size 0x%016lx\n", Word.signed(HotSpotSnippetUtils.wordSize())); // Card Table - Word cardBase = (Word) oop.unsignedShiftRight(cardTableShift()); + Word cardBase = (Word) field.unsignedShiftRight(cardTableShift()); long startAddress = cardTableStart(); int displacement = 0; if (((int) startAddress) == startAddress) { @@ -150,14 +142,12 @@ Word cardAddress = cardBase.add(displacement); // if (writtenValue.notEqual(Word.zero())) { - Word xorResult = ((Word) oop.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); + Word xorResult = ((Word) field.xor(writtenValue)).unsignedShiftRight(HotSpotSnippetUtils.logOfHRGrainBytes()); trace(WriteBarrierSnippets.TRACE, " G1 POST xor result: 0x%016lx\n", xorResult); if (xorResult.notEqual(Word.zero())) { if (writtenValue.notEqual(Word.zero())) { byte cardByte = cardAddress.readByte(0); - trace(WriteBarrierSnippets.TRACE, " G1 POST cardAddress: 0x%016lx\n", cardAddress); - trace(WriteBarrierSnippets.TRACE, " G1 POST cardValue: %d\n", Word.signed(cardByte)); if (cardByte != (byte) 0) { cardAddress.writeByte(0, (byte) 0); // smash zero into card @@ -166,6 +156,9 @@ Word logAddress = bufferAddress.add(nextIndex); logAddress.writeWord(0, cardAddress); indexAddress.writeWord(0, nextIndex); + trace(WriteBarrierSnippets.TRACE, " G1 POST cardAddress: 0x%016lx\n", cardAddress); + trace(WriteBarrierSnippets.TRACE, " G1 POST cardValue: %d\n", Word.signed(cardByte)); + trace(WriteBarrierSnippets.TRACE, " G1 POST nextIndex: 0x%016lx\n", nextIndex); trace(WriteBarrierSnippets.TRACE, " G1 POST logAddress: 0x%016lx\n", logAddress); } else { diff -r 96a337d307bd -r 992f62c457b0 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Mon Mar 04 16:46:37 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/NewInstanceStub.java Tue Mar 05 18:53:26 2013 +0100 @@ -29,6 +29,7 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.hotspot.nodes.*; import com.oracle.graal.hotspot.snippets.*; @@ -95,7 +96,8 @@ * operation was unsuccessful */ static Word refillAllocate(Word intArrayHub, int sizeInBytes, boolean log) { - + if (HotSpotGraalRuntime.getInstance().getRuntime().config.useG1GC) + return Word.zero(); Word intArrayMarkWord = Word.unsigned(tlabIntArrayMarkWord()); int alignmentReserveInBytes = tlabAlignmentReserveInHeapWords() * wordSize(); @@ -172,6 +174,12 @@ } } + private static void trace(boolean enabled, String format, WordBase value) { + if (enabled) { + Log.printf(format, value.rawValue()); + } + } + /** * Attempts to allocate a chunk of memory from Eden space. * @@ -180,6 +188,7 @@ * @return the allocated chunk or {@link Word#zero()} if allocation fails */ static Word edenAllocate(Word sizeInBytes, boolean log) { + trace(true, "REFILLTLAB: retaining TLAB 0x%16lu", Word.zero()); Word heapTopAddress = Word.unsigned(heapTopAddress()); Word heapEndAddress = Word.unsigned(heapEndAddress()); diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp Tue Mar 05 18:53:26 2013 +0100 @@ -6437,6 +6437,7 @@ assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); // First, check the explicit lists. + _free_list.verify(); { // Given that a concurrent operation might be adding regions to diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp Tue Mar 05 18:53:26 2013 +0100 @@ -70,6 +70,7 @@ if (result == NULL) { result = attempt_allocation_slow(word_size, gc_count_before_ret); } + assert_heap_not_locked(); if (result != NULL) { dirty_young_block(result, word_size); @@ -89,6 +90,8 @@ result = _survivor_gc_alloc_region.attempt_allocation_locked(word_size, false /* bot_updates */); } + + if (result != NULL) { dirty_young_block(result, word_size); } diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/gc_implementation/g1/g1_globals.hpp --- a/src/share/vm/gc_implementation/g1/g1_globals.hpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/g1_globals.hpp Tue Mar 05 18:53:26 2013 +0100 @@ -197,7 +197,7 @@ develop(bool, G1RecordHRRSOops, false, \ "When true, record recent calls to rem set operations.") \ \ - develop(bool, G1RecordHRRSEvents, false, \ + develop(bool, G1RecordHRRSEvents, true, \ "When true, record recent calls to rem set operations.") \ \ develop(intx, G1MaxVerifyFailures, -1, \ @@ -221,7 +221,7 @@ "It determines the minimum reserve we should have in the heap " \ "to minimize the probability of promotion failure.") \ \ - diagnostic(bool, G1PrintHeapRegions, false, \ + diagnostic(bool, G1PrintHeapRegions, true, \ "If set G1 will print information on which regions are being " \ "allocated and which are reclaimed.") \ \ diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/gc_implementation/g1/heapRegionSet.cpp --- a/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.cpp Tue Mar 05 18:53:26 2013 +0100 @@ -112,6 +112,10 @@ ( regions_humongous() && region_num() >= length()), hrs_ext_msg(this, "invariant")); + printf("region name %s\n", this->name()); + printf("regions empty? %d\n", regions_empty()); + printf("total used bytes %lu\n", total_used_bytes()); + guarantee(!regions_empty() || total_used_bytes() == 0, hrs_ext_msg(this, "invariant")); @@ -126,7 +130,7 @@ hrs_ext_msg(this, "verification should not be in progress")); // Do the basic verification first before we do the checks over the regions. - HeapRegionSetBase::verify(); + //HeapRegionSetBase::verify(); _calc_length = 0; _calc_region_num = 0; @@ -437,6 +441,12 @@ "prev1: "PTR_FORMAT" length: %u", name(), count, curr, prev0, prev1, length())); + //printf("[%s] the calculated length: %u " + // "just print " + // "curr: "PTR_FORMAT" prev0: "PTR_FORMAT" " + // "prev1: "PTR_FORMAT" length: %u used: %lu\n", + // name(), count, (unsigned long)curr, (unsigned long)prev0, (unsigned long)prev1, length(), curr->used()); + curr->print(); prev1 = prev0; prev0 = curr; curr = curr->next(); diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp --- a/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/gc_implementation/g1/heapRegionSet.inline.hpp Tue Mar 05 18:53:26 2013 +0100 @@ -62,7 +62,12 @@ hrs_err_msg("[%s] region's used bytes: "SIZE_FORMAT" " "should be <= used bytes: "SIZE_FORMAT, name(), used_bytes, _total_used_bytes)); + + //printf("[%s] region's used bytes: "SIZE_FORMAT" " + // "should be <= used bytes: "SIZE_FORMAT"\n", + // name(), used_bytes, _total_used_bytes); _total_used_bytes -= used_bytes; + //printf("TOTAL USED BYTES 4 %lu\n", _total_used_bytes); } inline void HeapRegionSetBase::remove_internal(HeapRegion* hr) { diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/graal/graalRuntime.cpp --- a/src/share/vm/graal/graalRuntime.cpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/graal/graalRuntime.cpp Tue Mar 05 18:53:26 2013 +0100 @@ -493,11 +493,6 @@ JRT_LEAF(void, GraalRuntime::graal_wb_post_call(JavaThread* thread, oopDesc* obj, void* card_addr)) if(TRACE_WB) tty->print_cr("HELLO POST WRITE BARRIER Card address 0x%016lx", card_addr); thread->dirty_card_queue().enqueue(card_addr); -//if(!((CardTableModRefBS*)(Universe::heap()->barrier_set()))->is_valid_card_address(obj,(signed char*)card_addr)) { -// tty->print_cr("Invalid worker start card"); -//} - - JRT_END JRT_LEAF(void, GraalRuntime::graal_ver_oop(JavaThread* thread, oopDesc* obj)) @@ -505,9 +500,6 @@ if(obj==NULL) tty->print_cr("ERROR NULL in verifyoop G1 in method obj " INTPTR_FORMAT, obj); if (obj!=NULL &&!obj->is_oop()) { tty->print_cr("ERROR in verifyoop G1 in method obj " INTPTR_FORMAT, obj); - -}else { - tty->print_cr("PASS in verifyoop G1 in method obj " INTPTR_FORMAT, obj); } JRT_END diff -r 96a337d307bd -r 992f62c457b0 src/share/vm/utilities/debug.hpp --- a/src/share/vm/utilities/debug.hpp Mon Mar 04 16:46:37 2013 +0100 +++ b/src/share/vm/utilities/debug.hpp Tue Mar 05 18:53:26 2013 +0100 @@ -160,15 +160,6 @@ } while (0) #endif // #ifndef USE_REPEATED_ASSERTS -#define assert1(p, msg) -do { \ - for (int __i = 0; __i < AssertRepeat; __i++) { \ - if (!(p)) { \ - report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", msg); \ - BREAKPOINT; \ - } \ - } \ -} while (0) // This version of assert is for use with checking return status from // library calls that return actual error values eg. EINVAL,