# HG changeset patch # User Doug Simon # Date 1401918229 -7200 # Node ID 6b1bd708e25434b75280b2c7336ea6f6ca6f74fc # Parent 774349ad0b03ebf2f9d8c939a7a6ae8c42244c43# Parent 9f25b70d6113f6265d5b84133f8fe1d73399d33f Merge. diff -r 774349ad0b03 -r 6b1bd708e254 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Wed Jun 04 23:07:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotVMConfig.java Wed Jun 04 23:43:49 2014 +0200 @@ -1180,6 +1180,9 @@ @HotSpotVMField(name = "CardTableModRefBS::byte_map_base", type = "jbyte*", get = HotSpotVMField.Type.OFFSET) @Stable private int cardTableModRefBSByteMapBaseOffset; @HotSpotVMConstant(name = "CardTableModRefBS::card_shift") @Stable public int cardTableModRefBSCardShift; + @HotSpotVMValue(expression = "(jbyte)CardTableModRefBS::dirty_card_val()") @Stable public byte dirtyCardValue; + @HotSpotVMValue(expression = "(jbyte)G1SATBCardTableModRefBS::g1_young_card_val()") @Stable public byte g1YoungCardValue; + public long cardtableStartAddress() { final long barrierSetAddress = unsafe.getAddress(universeCollectedHeap + collectedHeapBarrierSetOffset); final int kind = unsafe.getInt(barrierSetAddress + barrierSetKindOffset); diff -r 774349ad0b03 -r 6b1bd708e254 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Wed Jun 04 23:07:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/HotSpotReplacementsUtil.java Wed Jun 04 23:43:49 2014 +0200 @@ -207,7 +207,7 @@ /** * Reads the pending deoptimization value for the given thread. - * + * * @return {@code true} if there was a pending deoptimization */ public static int readPendingDeoptimization(Word thread) { @@ -416,6 +416,16 @@ } @Fold + public static byte dirtyCardValue() { + return config().dirtyCardValue; + } + + @Fold + public static byte g1YoungCardValue() { + return config().g1YoungCardValue; + } + + @Fold public static int cardTableShift() { return config().cardtableShift(); } diff -r 774349ad0b03 -r 6b1bd708e254 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Wed Jun 04 23:07:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/WriteBarrierSnippets.java Wed Jun 04 23:43:49 2014 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.hotspot.replacements; +import static com.oracle.graal.api.code.MemoryBarriers.*; import static com.oracle.graal.compiler.common.GraalOptions.*; import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import static com.oracle.graal.nodes.extended.BranchProbabilityNode.*; @@ -213,22 +214,26 @@ g1EffectiveAfterNullPostWriteBarrierCounter.inc(); // If the card is already dirty, (hence already enqueued) skip the insertion. - if (probability(NOT_FREQUENT_PROBABILITY, cardByte != (byte) 0)) { - log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), Word.unsigned(cardByte).rawValue()); - cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION); - g1ExecutedPostWriteBarrierCounter.inc(); + if (probability(NOT_FREQUENT_PROBABILITY, cardByte != g1YoungCardValue())) { + MembarNode.memoryBarrier(STORE_LOAD); + byte cardByteReload = cardAddress.readByte(0); + if (probability(NOT_FREQUENT_PROBABILITY, cardByteReload != dirtyCardValue())) { + log(trace, "[%d] G1-Post Thread: %p Card: %p \n", gcCycle, thread.rawValue(), Word.unsigned(cardByte).rawValue()); + cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION); + g1ExecutedPostWriteBarrierCounter.inc(); - // If the thread local card queue is full, issue a native call which will - // initialize a new one and add the card entry. - if (probability(FREQUENT_PROBABILITY, indexValue.notEqual(0))) { - Word nextIndex = indexValue.subtract(wordSize()); - Word logAddress = bufferAddress.add(nextIndex); - // Log the object to be scanned as well as update - // the card queue's next index. - logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION); - indexAddress.writeWord(0, nextIndex, GC_INDEX_LOCATION); - } else { - g1PostBarrierStub(G1WBPOSTCALL, cardAddress); + // If the thread local card queue is full, issue a native call which will + // initialize a new one and add the card entry. + if (probability(FREQUENT_PROBABILITY, indexValue.notEqual(0))) { + Word nextIndex = indexValue.subtract(wordSize()); + Word logAddress = bufferAddress.add(nextIndex); + // Log the object to be scanned as well as update + // the card queue's next index. + logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION); + indexAddress.writeWord(0, nextIndex, GC_INDEX_LOCATION); + } else { + g1PostBarrierStub(G1WBPOSTCALL, cardAddress); + } } } } @@ -293,19 +298,23 @@ Word cardAddress = Word.unsigned((start + cardStart) + count); byte cardByte = cardAddress.readByte(0); // If the card is already dirty, (hence already enqueued) skip the insertion. - if (cardByte != (byte) 0) { - cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION); - // If the thread local card queue is full, issue a native call which will - // initialize a new one and add the card entry. - if (indexValue != 0) { - indexValue = indexValue - wordSize(); - Word logAddress = bufferAddress.add(Word.unsigned(indexValue)); - // Log the object to be scanned as well as update - // the card queue's next index. - logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION); - indexAddress.writeWord(0, Word.unsigned(indexValue), GC_INDEX_LOCATION); - } else { - g1PostBarrierStub(G1WBPOSTCALL, cardAddress); + if (probability(NOT_FREQUENT_PROBABILITY, cardByte != g1YoungCardValue())) { + MembarNode.memoryBarrier(STORE_LOAD); + byte cardByteReload = cardAddress.readByte(0); + if (probability(NOT_FREQUENT_PROBABILITY, cardByteReload != dirtyCardValue())) { + cardAddress.writeByte(0, (byte) 0, GC_CARD_LOCATION); + // If the thread local card queue is full, issue a native call which will + // initialize a new one and add the card entry. + if (indexValue != 0) { + indexValue = indexValue - wordSize(); + Word logAddress = bufferAddress.add(Word.unsigned(indexValue)); + // Log the object to be scanned as well as update + // the card queue's next index. + logAddress.writeWord(0, cardAddress, GC_LOG_LOCATION); + indexAddress.writeWord(0, Word.unsigned(indexValue), GC_INDEX_LOCATION); + } else { + g1PostBarrierStub(G1WBPOSTCALL, cardAddress); + } } } } diff -r 774349ad0b03 -r 6b1bd708e254 graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java --- a/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Wed Jun 04 23:07:29 2014 +0200 +++ b/graal/com.oracle.graal.hotspotvmconfig/src/com/oracle/graal/hotspotvmconfig/HotSpotVMConfigProcessor.java Wed Jun 04 23:43:49 2014 +0200 @@ -127,6 +127,8 @@ "}", "", "#define set_boolean(name, value) vmconfig_oop->bool_field_put(fs.offset(), value)", + "#define set_byte(name, value) vmconfig_oop->byte_field_put(fs.offset(), (jbyte)value)", + "#define set_short(name, value) vmconfig_oop->short_field_put(fs.offset(), (jshort)value)", "#define set_int(name, value) vmconfig_oop->int_field_put(fs.offset(), (int)value)", "#define set_long(name, value) vmconfig_oop->long_field_put(fs.offset(), value)", "#define set_address(name, value) do { set_long(name, (jlong) value); } while (0)", diff -r 774349ad0b03 -r 6b1bd708e254 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/script/TruffleScriptEngineFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/script/TruffleScriptEngineFactory.java Wed Jun 04 23:43:49 2014 +0200 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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.truffle.api.script; + +import javax.script.*; + +/** + * Tool access to the creation of Truffle execution engines. + */ +public abstract class TruffleScriptEngineFactory implements ScriptEngineFactory { + + // TODO (mlvdv) first step, based on a suggestion from NetBeans + /** + * To be called by each concrete factory just after each engine instance is created, presenting + * an opportunity for an IDE to interrupt in a language-independent way. + * + * @param engine a just-created engine + */ + protected void engineCreated(ScriptEngine engine) { + } + +}