# HG changeset patch # User Thomas Wuerthinger # Date 1381129851 -7200 # Node ID 9fe53a7b42b8577799312db8b6d391df3fec3b70 # Parent 47a5e23bb418344dc7b99fb61e8f66277a15d42c# Parent cf4dd10ced32f18370af0627063ce733f946e3e2 Merge. diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java --- a/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.asm.ptx/src/com/oracle/graal/asm/ptx/PTXAssembler.java Mon Oct 07 09:10:51 2013 +0200 @@ -22,6 +22,7 @@ */ package com.oracle.graal.asm.ptx; +import static com.oracle.graal.asm.ptx.PTXStateSpace.*; import static com.oracle.graal.api.code.ValueUtil.*; import com.oracle.graal.asm.Label; @@ -532,7 +533,13 @@ } public void emit(PTXAssembler asm) { - asm.emitString("cvt." + super.emit()); + if (dest.getKind() == Kind.Float || + dest.getKind() == Kind.Double) { + // round-to-zero - might not be right + asm.emitString("cvt.rz." + super.emit()); + } else { + asm.emitString("cvt." + super.emit()); + } } } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/FloatPTXTest.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/FloatPTXTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/FloatPTXTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -31,41 +31,44 @@ /* PTX ISA 3.1 - 8.7.3 Floating-Point Instructions */ public class FloatPTXTest extends PTXTestBase { - @Ignore @Test public void testAdd() { - CompilationResult r = compile("testAdd2F"); - if (r.getTargetCode() == null) { - printReport("Compilation of testAdd2F FAILED"); + Float ret = (Float) invoke(compile("testAdd2I"), 42, 43); + if (ret != null) { + printReport("testAdd2I: " + ret); + } else { + printReport("testAdd2I: no VALUE"); } - /* - r = compile("testAdd2D"); - if (r.getTargetCode() == null) { - printReport("Compilation of testAdd2D FAILED"); + ret = (Float) invoke(compile("testAdd2F"), 42.1F, 43.5F); + if (ret != null) { + printReport("testAdd2F: " + ret); + } else { + printReport("testAdd2F: no VALUE"); } - r = compile("testAddFConst"); - if (r.getTargetCode() == null) { - printReport("Compilation of testAddFConst FAILED"); - } - r = compile("testAddConstF"); - if (r.getTargetCode() == null) { - printReport("Compilation of testConstF FAILED"); + ret = (Float) invoke(compile("testAddFConst"), 42.1F); + if (ret != null) { + printReport("testAddFConst: " + ret); + } else { + printReport("testAddFConst: no VALUE"); } - r = compile("testAddDConst"); - if (r.getTargetCode() == null) { - printReport("Compilation of testAddDConst FAILED"); + + Double dret = (Double) invoke(compile("testAdd2D"), 42.1, 43.5); + if (dret != null) { + printReport("testAdd2D: " + dret); + } else { + printReport("testAdd2D: no VALUE"); } - r = compile("testAddConstD"); - if (r.getTargetCode() == null) { - printReport("Compilation of testConstD FAILED"); - } - */ + + } + + public static float testAdd2I(int a, int b) { + return (float) (a + b); } public static float testAdd2F(float a, float b) { - return a + b; + return (a + b); } public static double testAdd2D(double a, double b) { diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXBackend.java Mon Oct 07 09:10:51 2013 +0200 @@ -85,7 +85,8 @@ } @Override - public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) { + public TargetMethodAssembler newAssembler(LIRGenerator lirGen, + CompilationResult compilationResult) { // Omit the frame of the method: // - has no spill slots or other slots allocated during register allocation // - has no callee-saved registers @@ -99,7 +100,9 @@ return tasm; } - private static void emitKernelEntry(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { + private static void emitKernelEntry(TargetMethodAssembler tasm, + LIRGenerator lirGen, + ResolvedJavaMethod codeCacheOwner) { // Emit PTX kernel entry text based on PTXParameterOp // instructions in the start block. Remove the instructions // once kernel entry text and directives are emitted to @@ -109,8 +112,8 @@ Buffer codeBuffer = tasm.asm.codeBuffer; // Emit initial boiler-plate directives. - codeBuffer.emitString(".version 2.1"); - codeBuffer.emitString(".target sm_20"); + codeBuffer.emitString(".version 3.0"); + codeBuffer.emitString(".target sm_30"); codeBuffer.emitString0(".entry " + name + " ("); codeBuffer.emitString(""); @@ -140,9 +143,13 @@ } // Emit .reg space declarations - private static void emitRegisterDecl(TargetMethodAssembler tasm, LIRGenerator lirGen, + private static void emitRegisterDecl(TargetMethodAssembler tasm, + LIRGenerator lirGen, ResolvedJavaMethod codeCacheOwner) { - assert codeCacheOwner != null : lirGen.getGraph() + " is not associated with a method"; + + assert codeCacheOwner != null : + lirGen.getGraph() + " is not associated with a method"; + Buffer codeBuffer = tasm.asm.codeBuffer; final SortedSet signed32 = new TreeSet<>(); diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXLIRGenerator.java Mon Oct 07 09:10:51 2013 +0200 @@ -900,24 +900,46 @@ throw GraalInternalError.unimplemented("PTXLIRGenerator.visitInfopointNode()"); } - public Variable emitLoadParam(Kind kind, Value address, DeoptimizingNode deopting) { + public Variable emitLoadParam(Kind kind, Value address, + DeoptimizingNode deopting) { + PTXAddressValue loadAddress = asAddress(address); Variable result = newVariable(kind); - append(new LoadParamOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); + append(new LoadParamOp(kind, result, loadAddress, + deopting != null ? state(deopting) : null)); + return result; } - public Variable emitLoadReturnAddress(Kind kind, Value address, DeoptimizingNode deopting) { + public Variable emitLoadReturnAddress(Kind kind, Value address, + DeoptimizingNode deopting) { + PTXAddressValue loadAddress = asAddress(address); - Variable result = newVariable(kind); - append(new LoadReturnAddrOp(kind, result, loadAddress, deopting != null ? state(deopting) : null)); + Variable result; + switch (kind) { + case Float: + result = newVariable(Kind.Int); + break; + case Double: + result = newVariable(Kind.Long); + break; + default: + result = newVariable(kind); + + } + append(new LoadReturnAddrOp(kind, result, loadAddress, + deopting != null ? state(deopting) : null)); + return result; } - public void emitStoreReturnValue(Kind kind, Value address, Value inputVal, DeoptimizingNode deopting) { + public void emitStoreReturnValue(Kind kind, Value address, Value inputVal, + DeoptimizingNode deopting) { + PTXAddressValue storeAddress = asAddress(address); Variable input = load(inputVal); - append(new StoreReturnValOp(kind, storeAddress, input, deopting != null ? state(deopting) : null)); + append(new StoreReturnValOp(kind, storeAddress, input, + deopting != null ? state(deopting) : null)); } @Override diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java --- a/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.compiler.ptx/src/com/oracle/graal/compiler/ptx/PTXTargetMethodAssembler.java Mon Oct 07 09:10:51 2013 +0200 @@ -33,10 +33,13 @@ public class PTXTargetMethodAssembler extends TargetMethodAssembler { - private static CompilerToGPU toGPU = HotSpotGraalRuntime.graalRuntime().getCompilerToGPU(); + private static CompilerToGPU toGPU = + HotSpotGraalRuntime.graalRuntime().getCompilerToGPU(); + private static boolean validDevice = toGPU.deviceInit(); - private static final int totalProcessors = (validDevice ? toGPU.availableProcessors() : 0); + private static final int totalProcessors = + (validDevice ? toGPU.availableProcessors() : 0); public static int getAvailableProcessors() { return totalProcessors; @@ -44,8 +47,12 @@ // detach ?? - public PTXTargetMethodAssembler(TargetDescription target, CodeCacheProvider runtime, FrameMap frameMap, - AbstractAssembler asm, FrameContext frameContext, CompilationResult compilationResult) { + public PTXTargetMethodAssembler(TargetDescription target, + CodeCacheProvider runtime, + FrameMap frameMap, + AbstractAssembler asm, + FrameContext frameContext, + CompilationResult compilationResult) { super(target, runtime, frameMap, asm, frameContext, compilationResult); } @@ -53,11 +60,14 @@ public CompilationResult finishTargetMethod(StructuredGraph graph) { ResolvedJavaMethod method = graph.method(); assert method != null : graph + " is not associated wth a method"; - ExternalCompilationResult graalCompile = (ExternalCompilationResult) super.finishTargetMethod(graph); + + ExternalCompilationResult graalCompile = + (ExternalCompilationResult) super.finishTargetMethod(graph); try { if ((validDevice) && (graalCompile.getTargetCode() != null)) { - long kernel = toGPU.generateKernel(graalCompile.getTargetCode(), method.getName()); + long kernel = toGPU.generateKernel(graalCompile.getTargetCode(), + method.getName()); graalCompile.setEntryPoint(kernel); } } catch (Throwable th) { diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java --- a/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.ptx/src/com/oracle/graal/hotspot/ptx/PTXHotSpotRegisterConfig.java Mon Oct 07 09:10:51 2013 +0200 @@ -104,7 +104,14 @@ int currentStackOffset = 0; Kind returnKind = returnType == null ? Kind.Void : returnType.getKind(); - AllocatableValue returnLocation = returnKind == Kind.Void ? Value.ILLEGAL : new Variable(returnKind, currentGeneral++); + + AllocatableValue returnLocation; + if (returnKind == Kind.Void) { + returnLocation = Value.ILLEGAL; + } else { + returnLocation = new Variable(returnKind, currentGeneral++); + } + AllocatableValue[] locations = new AllocatableValue[parameterTypes.length]; for (int i = 0; i < parameterTypes.length; i++) { diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java --- a/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.lir.ptx/src/com/oracle/graal/lir/ptx/PTXMemOp.java Mon Oct 07 09:10:51 2013 +0200 @@ -43,7 +43,8 @@ @Use({COMPOSITE}) protected PTXAddressValue address; @State protected LIRFrameState state; - public LoadOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) { + public LoadOp(Kind kind, Variable result, PTXAddressValue address, + LIRFrameState state) { this.kind = kind; this.result = result; this.address = address; @@ -62,7 +63,8 @@ case Float: case Double: case Object: - new Ld(Global, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm); + new Ld(Global, result, addr.getBase(), + Constant.forLong(addr.getDisplacement())).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -97,7 +99,8 @@ case Float: case Double: case Object: - new St(Global, input, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm); + new St(Global, input, addr.getBase(), + Constant.forLong(addr.getDisplacement())).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind()); @@ -114,7 +117,8 @@ @Use({COMPOSITE}) protected PTXAddressValue address; @State protected LIRFrameState state; - public LoadParamOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) { + public LoadParamOp(Kind kind, Variable result, PTXAddressValue address, + LIRFrameState state) { this.kind = kind; this.result = result; this.address = address; @@ -133,7 +137,8 @@ case Float: case Double: case Object: - new Ld(Parameter, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm); + new Ld(Parameter, result, addr.getBase(), + Constant.forLong(addr.getDisplacement())).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -151,7 +156,8 @@ @Use({COMPOSITE}) protected PTXAddressValue address; @State protected LIRFrameState state; - public LoadReturnAddrOp(Kind kind, Variable result, PTXAddressValue address, LIRFrameState state) { + public LoadReturnAddrOp(Kind kind, Variable result, + PTXAddressValue address, LIRFrameState state) { this.kind = kind; this.result = result; this.address = address; @@ -166,7 +172,8 @@ case Long: case Float: case Double: - new Ld(Parameter, result, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm); + new Ld(Parameter, result, addr.getBase(), + Constant.forLong(addr.getDisplacement())).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere(); @@ -183,7 +190,8 @@ @Use({REG}) protected Variable input; @State protected LIRFrameState state; - public StoreReturnValOp(Kind kind, PTXAddressValue address, Variable input, LIRFrameState state) { + public StoreReturnValOp(Kind kind, PTXAddressValue address, + Variable input, LIRFrameState state) { this.kind = kind; this.address = address; this.input = input; @@ -202,7 +210,8 @@ case Float: case Double: case Object: - new St(Global, input, addr.getBase(), Constant.forLong(addr.getDisplacement())).emit(masm); + new St(Global, input, addr.getBase(), + Constant.forLong(addr.getDisplacement())).emit(masm); break; default: throw GraalInternalError.shouldNotReachHere("missing: " + address.getKind()); diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AbstractTestNode.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AbstractTestNode.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/AbstractTestNode.java Mon Oct 07 09:10:51 2013 +0200 @@ -27,5 +27,9 @@ public abstract class AbstractTestNode extends Node { + protected AbstractTestNode() { + super(null); + } + public abstract int execute(VirtualFrame frame); } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/RootTestNode.java --- a/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/RootTestNode.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.graal.truffle.test/src/com/oracle/graal/truffle/test/nodes/RootTestNode.java Mon Oct 07 09:10:51 2013 +0200 @@ -31,6 +31,7 @@ @Child AbstractTestNode node; public RootTestNode(String name, AbstractTestNode node) { + super(null); this.name = name; this.node = node; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java --- a/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.dsl.test/src/com/oracle/truffle/api/dsl/test/TypeSystemTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -58,6 +58,10 @@ @TypeSystemReference(SimpleTypes.class) public abstract static class ValueNode extends Node { + public ValueNode() { + super(null); + } + public int executeInt(VirtualFrame frame) throws UnexpectedResultException { return SimpleTypesGen.SIMPLETYPES.expectInteger(execute(frame)); } @@ -105,6 +109,7 @@ @Child private E node; public TestRootNode(E node) { + super(null); this.node = adoptChild(node); } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ArgumentsTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -75,6 +75,7 @@ @Children private TestArgumentNode[] children; TestRootNode(TestArgumentNode[] children) { + super(null); this.children = adoptChildren(children); } @@ -93,6 +94,7 @@ private final int index; TestArgumentNode(int index) { + super(null); this.index = index; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/CallTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -60,6 +60,7 @@ private final CallTarget secondTarget; DualCallNode(CallTarget firstTarget, CallTarget secondTarget) { + super(null); this.firstTarget = firstTarget; this.secondTarget = secondTarget; } @@ -75,6 +76,7 @@ private final int value; public ConstantRootNode(int value) { + super(null); this.value = value; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildNodeTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -78,6 +78,7 @@ @Child private TestChildNode right; public TestRootNode(TestChildNode left, TestChildNode right) { + super(null); this.left = adoptChild(left); this.right = adoptChild(right); } @@ -90,6 +91,10 @@ class TestChildNode extends Node { + public TestChildNode() { + super(null); + } + public int execute() { return 21; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ChildrenNodesTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -71,6 +71,7 @@ @Children private final TestChildNode[] children; public TestRootNode(TestChildNode[] children) { + super(null); this.children = adoptChildren(children); } @@ -86,6 +87,10 @@ class TestChildNode extends Node { + public TestChildNode() { + super(null); + } + public int execute() { return 21; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FinalFieldTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -65,6 +65,7 @@ @Children TestChildNode[] children; public TestRootNode(TestChildNode[] children) { + super(null); this.children = adoptChildren(children); } @@ -83,6 +84,7 @@ private final int value; public TestChildNode(int value) { + super(null); this.value = value; } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameSlotTypeSpecializationTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -63,6 +63,7 @@ @Child TestChildNode right; public TestRootNode(TestChildNode left, TestChildNode right) { + super(null); this.left = adoptChild(left); this.right = adoptChild(right); } @@ -76,6 +77,10 @@ abstract class TestChildNode extends Node { + protected TestChildNode() { + super(null); + } + abstract Object execute(VirtualFrame frame); } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/FrameTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -77,6 +77,7 @@ @Child TestChildNode right; public TestRootNode(TestChildNode left, TestChildNode right) { + super(null); this.left = adoptChild(left); this.right = adoptChild(right); } @@ -89,6 +90,10 @@ abstract class TestChildNode extends Node { + public TestChildNode() { + super(null); + } + abstract int execute(VirtualFrame frame); } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReplaceTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -84,6 +84,7 @@ @Children private final ValueNode[] children; public TestRootNode(ValueNode[] children) { + super(null); this.children = adoptChildren(children); } @@ -99,6 +100,10 @@ abstract class ValueNode extends Node { + public ValueNode() { + super(null); + } + abstract int execute(); } diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ReturnTypeSpecializationTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -62,6 +62,7 @@ @Child TestChildNode right; public TestRootNode(TestChildNode left, TestChildNode right) { + super(null); this.left = adoptChild(left); this.right = adoptChild(right); } @@ -75,6 +76,10 @@ abstract class TestChildNode extends Node { + public TestChildNode() { + super(null); + } + abstract Object execute(VirtualFrame frame); int executeInt(VirtualFrame frame) throws UnexpectedResultException { diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java --- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/RootNodeTest.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -59,6 +59,10 @@ class TestRootNode extends RootNode { + public TestRootNode() { + super(null); + } + @Override public Object execute(VirtualFrame frame) { return 42; diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java --- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java Mon Oct 07 09:10:51 2013 +0200 @@ -657,7 +657,7 @@ final SourceSection sourceSection = node.getSourceSection(); if (sourceSection != null) { final String txt = sourceSection.getSource().getCode(); - p.println("Full source len=(" + txt.length() + ") txt=___" + txt + "___"); + p.println("Full source len=(" + txt.length() + ") ___" + txt + "___"); p.println("AST source attribution:"); } } @@ -793,7 +793,7 @@ final StringBuilder sb = new StringBuilder(); sb.append("source: len=" + srcText.length()); sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); - sb.append(" txt=___" + srcText + "___"); + sb.append(" ___" + srcText + "___"); return sb.toString(); } return ""; diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNode.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/SLNode.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -28,6 +28,11 @@ @TypeSystemReference(SLTypes.class) public class SLNode extends Node { + public SLNode() { + // No source attribution + super(null); + } + @Override public String toString() { return NodeUtil.printTreeToString(this); diff -r 47a5e23bb418 -r 9fe53a7b42b8 graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionDefinitionNode.java --- a/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionDefinitionNode.java Mon Oct 07 03:12:05 2013 +0200 +++ b/graal/com.oracle.truffle.sl/src/com/oracle/truffle/sl/nodes/FunctionDefinitionNode.java Mon Oct 07 09:10:51 2013 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2013, 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 @@ -35,6 +35,7 @@ private final String name; public FunctionDefinitionNode(StatementNode body, FrameDescriptor frameDescriptor, String name, TypedNode returnValue) { + super(null); this.body = adoptChild(body); this.frameDescriptor = frameDescriptor; this.name = name; diff -r 47a5e23bb418 -r 9fe53a7b42b8 src/gpu/ptx/vm/gpu_ptx.cpp --- a/src/gpu/ptx/vm/gpu_ptx.cpp Mon Oct 07 03:12:05 2013 +0200 +++ b/src/gpu/ptx/vm/gpu_ptx.cpp Mon Oct 07 09:10:51 2013 +0200 @@ -415,6 +415,17 @@ ret.set_jfloat(return_val); } break; + case T_DOUBLE: + { + double return_val; + status = gpu::Ptx::_cuda_cu_memcpy_dtoh(&return_val, ptxka._return_value_ptr, T_DOUBLE_BYTE_SIZE); + if (status != GRAAL_CUDA_SUCCESS) { + tty->print_cr("[CUDA] *** Error (%d) Failed to copy value to device argument", status); + return false; + } + ret.set_jdouble(return_val); + } + break; case T_LONG: { long return_val; diff -r 47a5e23bb418 -r 9fe53a7b42b8 src/gpu/ptx/vm/ptxKernelArguments.cpp --- a/src/gpu/ptx/vm/ptxKernelArguments.cpp Mon Oct 07 03:12:05 2013 +0200 +++ b/src/gpu/ptx/vm/ptxKernelArguments.cpp Mon Oct 07 09:10:51 2013 +0200 @@ -104,6 +104,39 @@ return; } +void PTXKernelArguments::do_double() { + if (is_after_invocation()) { + return; + } + // If the parameter is a return value, + jvalue doubleval; + if (is_return_type()) { + // Allocate device memory for T_INT return value pointer on device. Size in bytes + int status = gpu::Ptx::_cuda_cu_memalloc(&_return_value_ptr, T_DOUBLE_BYTE_SIZE); + if (status != GRAAL_CUDA_SUCCESS) { + tty->print_cr("[CUDA] *** Error (%d) Failed to allocate memory for return value pointer on device", status); + _success = false; + return; + } + // Push _return_value_ptr to _kernelBuffer + *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = _return_value_ptr; + // _bufferOffset += sizeof(_return_value_ptr); + _bufferOffset += sizeof(doubleval.d); + } else { + // Get the next java argument and its value which should be a T_INT + oop arg = next_arg(T_FLOAT); + // Copy the java argument value to kernelArgBuffer + if (java_lang_boxing_object::get_value(arg, &doubleval) != T_DOUBLE) { + tty->print_cr("[CUDA] *** Error: Unexpected argument type; expecting T_INT"); + _success = false; + return; + } + *((gpu::Ptx::CUdeviceptr*) &_kernelArgBuffer[_bufferOffset]) = doubleval.d; + _bufferOffset += sizeof(doubleval.d); + } + return; +} + void PTXKernelArguments::do_long() { if (is_after_invocation()) { return; diff -r 47a5e23bb418 -r 9fe53a7b42b8 src/gpu/ptx/vm/ptxKernelArguments.hpp --- a/src/gpu/ptx/vm/ptxKernelArguments.hpp Mon Oct 07 03:12:05 2013 +0200 +++ b/src/gpu/ptx/vm/ptxKernelArguments.hpp Mon Oct 07 09:10:51 2013 +0200 @@ -28,12 +28,13 @@ #include "runtime/gpu.hpp" #include "runtime/signature.hpp" -#define T_BYTE_SIZE 1 -#define T_BOOLEAN_SIZE 4 -#define T_INT_BYTE_SIZE 4 -#define T_FLOAT_BYTE_SIZE 4 -#define T_LONG_BYTE_SIZE 8 -#define T_ARRAY_BYTE_SIZE 8 +#define T_BYTE_SIZE 1 +#define T_BOOLEAN_SIZE 4 +#define T_INT_BYTE_SIZE 4 +#define T_FLOAT_BYTE_SIZE 4 +#define T_DOUBLE_BYTE_SIZE 8 +#define T_LONG_BYTE_SIZE 8 +#define T_ARRAY_BYTE_SIZE 8 class PTXKernelArguments : public SignatureIterator { public: @@ -103,6 +104,7 @@ void do_bool(); void do_int(); void do_float(); + void do_double(); void do_long(); void do_array(int begin, int end); void do_void(); @@ -115,11 +117,6 @@ /* TODO : To be implemented */ guarantee(false, "do_short:NYI"); } - inline void do_double() { - /* TODO : To be implemented */ - guarantee(false, "do_double:NYI"); - } - inline void do_object() { /* TODO : To be implemented */ guarantee(false, "do_object:NYI"); diff -r 47a5e23bb418 -r 9fe53a7b42b8 src/share/vm/graal/graalCompilerToGPU.cpp --- a/src/share/vm/graal/graalCompilerToGPU.cpp Mon Oct 07 03:12:05 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToGPU.cpp Mon Oct 07 09:10:51 2013 +0200 @@ -96,7 +96,20 @@ } else { oop o = java_lang_boxing_object::create(ptxka.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL); if (TraceGPUInteraction) { - tty->print_cr("GPU execution returned %d", result.get_jint()); + switch (ptxka.get_ret_type()) { + case T_INT: + tty->print_cr("GPU execution returned %d", result.get_jint()); + break; + case T_FLOAT: + tty->print_cr("GPU execution returned %f", result.get_jfloat()); + break; + case T_DOUBLE: + tty->print_cr("GPU execution returned %f", result.get_jdouble()); + break; + default: + tty->print_cr("GPU returned unhandled"); + break; + } } return JNIHandles::make_local(o); } @@ -135,7 +148,20 @@ } else { oop o = java_lang_boxing_object::create(ptxka.get_ret_type(), (jvalue *) result.get_value_addr(), CHECK_NULL); if (TraceGPUInteraction) { - tty->print_cr("GPU execution returned %d", result.get_jint()); + switch (ptxka.get_ret_type()) { + case T_INT: + tty->print_cr("GPU execution returned %d", result.get_jint()); + break; + case T_FLOAT: + tty->print_cr("GPU execution returned %f", result.get_jfloat()); + break; + case T_DOUBLE: + tty->print_cr("GPU execution returned %g", result.get_jdouble()); + break; + default: + tty->print_cr("GPU returned unhandled"); + break; + } } return JNIHandles::make_local(o); }