src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/NewArrayStub.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
*** old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/NewArrayStub.java Mon Mar 20 17:39:07 2017
--- new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/NewArrayStub.java Mon Mar 20 17:39:07 2017
*** 29,39 ****
--- 29,39 ----
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.layoutHelperElementTypeShift;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.layoutHelperHeaderSizeMask;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.layoutHelperHeaderSizeShift;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.layoutHelperLog2ElementSizeMask;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.layoutHelperLog2ElementSizeShift;
! import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.loadKlassLayoutHelperIntrinsic;
! import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.readLayoutHelper;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord;
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.wordSize;
import static org.graalvm.compiler.hotspot.replacements.NewObjectSnippets.MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH;
import static org.graalvm.compiler.hotspot.replacements.NewObjectSnippets.formatArray;
import static org.graalvm.compiler.hotspot.stubs.NewInstanceStub.refillAllocate;
*** 55,64 ****
--- 55,65 ----
import org.graalvm.compiler.hotspot.nodes.StubForeignCallNode;
import org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp;
import org.graalvm.compiler.hotspot.replacements.NewObjectSnippets;
import org.graalvm.compiler.hotspot.word.KlassPointer;
import org.graalvm.compiler.nodes.ConstantNode;
+ import org.graalvm.compiler.options.OptionValues;
import org.graalvm.compiler.word.Word;
import jdk.vm.ci.code.Register;
import jdk.vm.ci.hotspot.HotSpotResolvedObjectType;
*** 68,96 ****
--- 69,99 ----
* If this stub fails to refill the TLAB or allocate the object, it calls out to the HotSpot C++
* runtime to complete the allocation.
*/
public class NewArrayStub extends SnippetStub {
! public NewArrayStub(OptionValues options, HotSpotProviders providers, HotSpotForeignCallLinkage linkage) {
! super("newArray", options, providers, linkage);
}
@Override
protected Object[] makeConstArgs() {
HotSpotResolvedObjectType intArrayType = (HotSpotResolvedObjectType) providers.getMetaAccess().lookupJavaType(int[].class);
int count = method.getSignature().getParameterCount(false);
Object[] args = new Object[count];
assert checkConstArg(3, "intArrayHub");
assert checkConstArg(4, "threadRegister");
+ assert checkConstArg(5, "options");
args[3] = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), intArrayType.klass(), null);
args[4] = providers.getRegisters().getThreadRegister();
+ args[5] = options;
return args;
}
@Fold
! static boolean logging(OptionValues options) {
! return StubOptions.TraceNewArrayStub.getValue(options);
}
/**
* Re-attempts allocation after an initial TLAB allocation failed or was skipped (e.g., due to
* -XX:-UseTLAB).
*** 99,135 ****
--- 102,139 ----
* @param length the length of the array
* @param fillContents Should the array be filled with zeroes?
* @param intArrayHub the hub for {@code int[].class}
*/
@Snippet
! private static Object newArray(KlassPointer hub, int length, boolean fillContents, @ConstantParameter KlassPointer intArrayHub, @ConstantParameter Register threadRegister) {
int layoutHelper = loadKlassLayoutHelperIntrinsic(hub);
! private static Object newArray(KlassPointer hub, int length, boolean fillContents, @ConstantParameter KlassPointer intArrayHub, @ConstantParameter Register threadRegister,
+ @ConstantParameter OptionValues options) {
+ int layoutHelper = readLayoutHelper(hub);
int log2ElementSize = (layoutHelper >> layoutHelperLog2ElementSizeShift(INJECTED_VMCONFIG)) & layoutHelperLog2ElementSizeMask(INJECTED_VMCONFIG);
int headerSize = (layoutHelper >> layoutHelperHeaderSizeShift(INJECTED_VMCONFIG)) & layoutHelperHeaderSizeMask(INJECTED_VMCONFIG);
int elementKind = (layoutHelper >> layoutHelperElementTypeShift(INJECTED_VMCONFIG)) & layoutHelperElementTypeMask(INJECTED_VMCONFIG);
int sizeInBytes = computeArrayAllocationSize(length, wordSize(), headerSize, log2ElementSize);
! if (logging(options)) {
printf("newArray: element kind %d\n", elementKind);
printf("newArray: array length %d\n", length);
printf("newArray: array size %d\n", sizeInBytes);
printf("newArray: hub=%p\n", hub.asWord().rawValue());
}
// check that array length is small enough for fast path.
Word thread = registerAsWord(threadRegister);
boolean inlineContiguousAllocationSupported = GraalHotSpotVMConfigNode.inlineContiguousAllocationSupported();
if (inlineContiguousAllocationSupported && length >= 0 && length <= MAX_ARRAY_FAST_PATH_ALLOCATION_LENGTH) {
! Word memory = refillAllocate(thread, intArrayHub, sizeInBytes, logging(options));
if (memory.notEqual(0)) {
! if (logging(options)) {
printf("newArray: allocated new array at %p\n", memory.rawValue());
}
return verifyObject(
! formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord(INJECTED_VMCONFIG)), fillContents, false, false));
! formatArray(hub, sizeInBytes, length, headerSize, memory, Word.unsigned(arrayPrototypeMarkWord(INJECTED_VMCONFIG)), fillContents, false, null));
}
}
! if (logging(options)) {
printf("newArray: calling new_array_c\n");
}
newArrayC(NEW_ARRAY_C, thread, hub, length);
handlePendingException(thread, true);
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/stubs/NewArrayStub.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File