# HG changeset patch
# User Jaroslav Tulach
- * @NodeChild("operand") - * abstract TestNode extends Node { - * abstract void execute(Object operandValue); - * // ... example here ... - * } - *- * - *
- * @Specialization - * void doCached(int operand, @Cached("operand") int cachedOperand) { - * CompilerAsserts.compilationConstant(cachedOperand); - * ... - * } - * - * Example executions: - * execute(1) => doCached(1, 1) // new instantiation, localOperand is bound to 1 - * execute(0) => doCached(0, 1) - * execute(2) => doCached(2, 1) - * - *- * - *
int
values and for each
- * individual int
value a new specialization would get instantiated. The
- * {@link Specialization#limit()} property defines a limit for the number of specializations that
- * can get instantiated. If the specialization instantiation limit is reached then no further
- * specializations are instantiated. Like for other specializations if there are no more
- * specializations defined an {@link UnsupportedSpecializationException} is thrown. The default
- * specialization instantiation limit is 3
.
- *
- * - * @Specialization(guards = "operand == cachedOperand") - * void doCached(int operand, @Cached("operand") int cachedOperand) { - * CompilerAsserts.compilationConstant(cachedOperand); - * ... - * } - * - * Example executions: - * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0 - * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1 - * execute(1) => doCached(1, 1) - * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2 - * execute(3) => throws UnsupportedSpecializationException // instantiation limit overflows - * - *- * - *
doNormal
. This specialization has the same type restrictions but does not have local
- * state nor the operand identity guard. It is also declared after doCached
therefore
- * it is only instantiated if the limit of the doCached
specialization has been
- * reached. In other words doNormal
is more generic than doCached
. The
- * doNormal
specialization uses contains="doCached"
to specify
- * that all instantiations of doCached
get removed if doNormal
is
- * instantiated. Alternatively if the contains
relation is omitted then all
- * doCached
instances remain but no new instances are created.
- *
- *
- * @Specialization(guards = "operand == cachedOperand")
- * void doCached(int operand, @Cached("operand") int cachedOperand) {
- * CompilerAsserts.compilationConstant(cachedOperand);
- * ...
- * }
- *
- * @Specialization(contains = "doCached")
- * void doNormal(int operand) {...}
- *
- * Example executions with contains = "doCached":
- * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
- * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
- * execute(1) => doCached(1, 1)
- * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
- * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow; doCached gets removed.
- * execute(1) => doNormal(1)
- *
- * Example executions without contains = "doCached":
- * execute(0) => doCached(0, 0) // new instantiation, cachedOperand is bound to 0
- * execute(1) => doCached(1, 1) // new instantiation, cachedOperand is bound to 1
- * execute(1) => doCached(1, 1)
- * execute(2) => doCached(2, 2) // new instantiation, cachedOperand is bound to 2
- * execute(3) => doNormal(3) // new instantiation of doNormal due to limit overflow
- * execute(1) => doCached(1, 1)
- *
- *
- *
- * private
.
- *
- * - * @Specialization - * void s(int operand, @Cached("transformLocal(operand)") int cachedOperand) { - * } - * - * int transformLocal(int operand) { - * return operand & 0x42; - * } - * - *
new
keyword can be used to initialize a cached parameter using a constructor of
- * the parameter type.
- *
- * - * @Specialization - * void s(Object operand, @Cached("new()") OtherNode someNode) { - * someNode.execute(operand); - * } - * - * static class OtherNode extends Node { - * - * public String execute(Object value) { - * throw new UnsupportedOperationException(); - * } - * } - * - *- * - *
- * @Specialization - * void s(int operand, @Cached("create()") BranchProfile profile) { - * } - *- * - *
- * A method annotated with {@link Fallback} is treated as a {@link Specialization} that implicitly - * links all the guards of all other declared {@link Specialization} annotated methods of the - * operation in a negated form. As a consequence it cannot declare any other guards. The expected - * signature of the method must match to the signature of a {@link Specialization} with the - * additional limitation that only generically executable argument types are allowed. A generically - * executable argument is a an argument hat can be executed from the child {@link Node} using an - * execute method without {@link UnsupportedOperationException}. In many cases the generically - * executable type is {@link Object}. An operation is limited to just one {@link Fallback} - * specialization which is always ordered at the end of the specialization chain. - *
- * - *- * A simple example showing the use of the {@link Fallback} annotation in a DSL operation: - *
- * - *- * @Specialization int doInt(int a) {..} - * @Specialization int doDouble(double a) {..} - * @Fallback int orElse(Object a) {..} - *- * - *
- * The previous example could be redeclared just using {@link Specialization} annotated methods as - * follows: - *
- * - *- * @Specialization int doInt(int a) {..} - * @Specialization int doDouble(double a) {..} - * @Specialization(guard={"!isInt(a)", "!isDouble(a)"}) - * int orElse(Object a) {..} - *- * - *
- * Performance note: For operations with a lot of {@link Specialization} annotated methods - * the use of {@link Fallback} might generate a guard that is very big. Try to avoid the use of - * {@link Fallback} for specializations that are significantly important for peak performance. - *
- * - * @see Specialization - * @see NodeChild - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD}) -public @interface Fallback { - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GenerateNodeFactory.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* - * 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.dsl; - -import java.lang.annotation.*; - -/** - * Annotate nodes or base classes of nodes to generate factory handlers implementing the - * {@link NodeFactory} interface. The generated factory handlers class name starts with the source - * original class and ends with 'Factory'. - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE}) -public @interface GenerateNodeFactory { - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/GeneratedBy.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -/** - * Marks a type as being generated based on another class or method of a class. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface GeneratedBy { - - Class> value(); - - String methodName() default ""; - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImplicitCast.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImplicitCast.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD}) -public @interface ImplicitCast { - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Implies.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Implies.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -/** - * Experimental API. - * - * @deprecated annotation has no effect anymore. - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD}) -@Deprecated -public @interface Implies { - - String[] value(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImportStatic.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ImportStatic.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -/** - * Imports allpublic
and static
methods and fields of the provided
- * classes for the use in DSL expressions of the annotated class or its subclasses.
- *
- * @see Specialization#guards()
- * @see Specialization#assumptions()
- * @see Specialization#limit()
- * @see Cached
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE})
-public @interface ImportStatic {
-
- Class>[] value();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeAssumptions.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeAssumptions.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.lang.annotation.*;
-
-import com.oracle.truffle.api.*;
-
-/**
- * @deprecated use {@link NodeField} with type {@link Assumption} instead.
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.TYPE})
-@Deprecated
-public @interface NodeAssumptions {
-
- String[] value();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeChild.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeChild.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.lang.annotation.*;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * A {@link NodeChild} element defines an executable child for the enclosing {@link Node}. A
- * {@link Node} contains multiple {@link NodeChildren} specified in linear execution order.
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.TYPE})
-public @interface NodeChild {
-
- String value() default "";
-
- Class> type() default Node.class;
-
- /**
- * The {@link #executeWith()} property allows a node to pass the result of one child's
- * executable as an input to another child's executable. These referenced children must be
- * defined before the current node in the execution order. The current node {@link #type()}
- * attribute must be set to a {@link Node} which supports the evaluated execution with the
- * number of {@link #executeWith()} arguments that are defined. For example if this child is
- * executed with one argument, the {@link #type()} attribute must define a node which publicly
- * declares a method with the signature Object execute*(VirtualFrame, Object)
.
- */
- String[] executeWith() default {};
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeChildren.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeChildren.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.lang.annotation.*;
-
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.TYPE})
-public @interface NodeChildren {
-
- NodeChild[] value() default {};
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFactory.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFactory.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.util.*;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Enables the dynamic creation of generated nodes. It provides an convenient way to instantiate
- * generated node classes without using reflection.
- */
-public interface NodeFactory"get" + firstLetterUpperCase({@link #name()})()
.
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.TYPE})
-public @interface NodeField {
-
- String name();
-
- Class> type();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFields.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/NodeFields.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.lang.annotation.*;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * A {@link NodeFields} element defines a field for the generated {@link Node}. A {@link Node}
- * contains multiple {@link NodeFields} specified in linear declaration order. The field can be
- * accessed by declaring an abstract getter named
- * "get" + firstLetterUpperCase({@link #value()})()
.
- */
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.TYPE})
-public @interface NodeFields {
-
- NodeField[] value() default {};
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ShortCircuit.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/ShortCircuit.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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.dsl;
-
-import java.lang.annotation.*;
-
-@Retention(RetentionPolicy.CLASS)
-@Target({ElementType.METHOD})
-public @interface ShortCircuit {
-
- String value();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java
--- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/Specialization.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/*
- * Copyright (c) 2012, 2015, 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.dsl;
-
-import java.lang.annotation.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * - * Defines a method of a node subclass to represent one specialization of an operation. Multiple - * specializations can be defined in a node representing an operation. A specialization defines - * which kind of input is expected using the method signature and the annotation attributes. The - * specialized semantics of the operation are defined using the body of the annotated Java method. A - * specialization method must be declared in a class that is derived from {@link Node} that - * references a {@link TypeSystem}. At least one specialization must be defined per operation. If no - * specialization is valid for the given set of input values then an - * {@link UnsupportedSpecializationException} is thrown instead of invoking any specialization - * method. - *
- *- * A specialization must have at least as many parameters as there are {@link NodeChild} annotations - * declared for the enclosing operation node. These parameters are declared in the same order as the - * {@link NodeChild} annotations (linear execution order). We call such parameters dynamic input - * parameters. Every specialization that is declared within an operation must have an equal number - * of dynamic input parameters. - *
- *- * The supported kind of input values for a specialization are declared using guards. A - * specialization may provide declarative specifications for four kinds of guards: - *
true
. Expression guards are modeled using Java expressions that return a
- * boolean
value. If the guard expression returns false
, the
- * specialization is no longer applicable and the operation is re-specialized. Guard expressions are
- * declared using the {@link #guards()} attribute.true
. Assumptions can be assigned to specializations using the
- * {@link #assumptions()} attribute.
- * The enclosing {@link Node} of a specialization method must have at least one public
- * and non-final
execute method. An execute method is a method that starts with
- * 'execute'. If all execute methods declare the first parameter type as {@link Frame},
- * {@link VirtualFrame} or {@link MaterializedFrame} then the same frame type can be used as
- * optional first parameter of the specialization. This parameter does not count to the number of
- * dynamic parameters.
- *
- * A specialization method may declare multiple parameters annotated with {@link Cached}. Cached - * parameters are initialized and stored once per specialization instantiation. For consistency - * between specialization declarations cached parameters must be declared last in a specialization - * method. - *
- *- * If the operation is re-specialized or if it is executed for the first time then all declared - * specializations of the operation are tried in declaration order until the guards of the first - * specialization accepts the current input values. The new specialization is then added to the - * chain of current specialization instances which might consist of one (monomorph) or multiple - * instances (polymorph). If an assumption of an instantiated specialization is violated then - * re-specialization is triggered again. - *
- *- * With guards in combination with cached parameters it is possible that multiple instances of the - * same specialization are created. The {@link #limit()} attribute can be used to limit the number - * of instantiations per specialization. - *
- * - * @see NodeChild - * @see ShortCircuit - * @see Fallback - * @see Cached - * @see TypeSystem - * @see TypeSystemReference - * @see UnsupportedSpecializationException - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.METHOD}) -public @interface Specialization { - - /** - * @deprecated do not use anymore. Will get removed in the next release. - */ - @Deprecated int DEFAULT_ORDER = -1; - - /** - * @deprecated use declaration order instead. Will get removed in the next release. - */ - @Deprecated - int order() default DEFAULT_ORDER; - - /** - * References a specialization of a super class by its method name where this specialization is - * inserted before. The declaration order of a specialization is not usable for nodes where - * specializations are partly declared in the super class and partly declared in a derived - * class. By default all specializations declared in the derived class are appended to those in - * the super class. This attribute can be used to override the default behavior. - */ - String insertBefore() default ""; - - /** - *- * Declares an event guards that trigger re-specialization in case an exception is thrown in the - * specialization body. This attribute can be used to declare a list of such exceptions. Guards - * of this kind are useful to avoid calculating a value twice when it is used in the guard and - * its specialization. - *
- * - *- * If an event guard exception is triggered then all instantiations of this specialization are - * removed. If one of theses exceptions is thrown once then no further instantiations of this - * specialization are going to be created for this node. A specialization that rewrites on an - * exception must ensure that no non-repeatable side-effect is caused until the rewrite is - * triggered. - *
- * - * Example usage: - * - *- * @Specialization(rewriteOn = ArithmeticException.class) - * int doAddNoOverflow(int a, int b) { - * return ExactMath.addExact(a, b); - * } - * @Specialization - * long doAddWithOverflow(int a, int b) { - * return a + b; - * } - * ... - * Example executions: - * execute(Integer.MAX_VALUE - 1, 1) => doAddNoOverflow(Integer.MAX_VALUE - 1, 1) - * execute(Integer.MAX_VALUE, 1) => doAddNoOverflow(Integer.MAX_VALUE, 1) - * => throws ArithmeticException - * => doAddWithOverflow(Integer.MAX_VALUE, 1) - * execute(Integer.MAX_VALUE - 1, 1) => doAddWithOverflow(Integer.MAX_VALUE - 1, 1) - *- * - * - * - * @see ExactMath#addExact(int, int) - */ - Class extends Throwable>[] rewriteOn() default {}; - - /** - *
- * Declares other specializations of the same node to be contained by this specialization. Other - * specializations are references using their unique method name. If this specialization is - * instantiated then all contained specialization instances are removed and never instantiated - * again for this node instance. Therefore this specialization should handle strictly more - * inputs than which were handled by the contained specialization, otherwise the removal of the - * contained specialization will lead to unspecialized types of input values. The contains - * declaration is transitive for multiple involved specializations. - *
- * Example usage: - * - *- * @Specialization(guards = "b == 2") - * void doDivPowerTwo(int a, int b) { - * return a >> 1; - * } - * @Specialization(contains ="doDivPowerTwo", guards = "b > 0") - * void doDivPositive(int a, int b) { - * return a / b; - * } - * ... - * Example executions with contains="doDivPowerTwo": - * execute(4, 2) => doDivPowerTwo(4, 2) - * execute(9, 3) => doDivPositive(9, 3) // doDivPowerTwo instances get removed - * execute(4, 2) => doDivPositive(4, 2) - * Same executions without contains="doDivPowerTwo" - * execute(4, 2) => doDivPowerTwo(4, 2) - * execute(9, 3) => doDivPositive(9, 3) - * execute(4, 2) => doDivPowerTwo(4, 2) - *- * - * - * - * @see #guards() - */ - String[] contains() default {}; - - /** - *
- * Declares boolean
expressions that define whether or not input values are
- * applicable to this specialization instance. Guard expressions must always return the same
- * result for each combination of the enclosing node instance and the bound input values.
- *
- * If a guard expression does not bind any dynamic input parameters then the DSL assumes that - * the result will not change for this node after specialization instantiation. The DSL asserts - * this assumption if assertions are enabled (-ea). - *
- *
- * Guard expressions are defined using a subset of Java. This subset includes field/parameter
- * accesses, function calls, type exact infix comparisons (==, !=, <, <=, >, >=), logical
- * negation (!), logical disjunction (||) and integer literals. The return type of guard
- * expressions must be boolean
. Bound elements without receivers are resolved using
- * the following order:
- *
- * Example usage: - * - *
- * static boolean acceptOperand(int operand) { - * assert operand <= 42; - * return operand & 1 == 1; - * } - * @Specialization(guards = {"operand <= 42", "acceptOperand(operand)"}) - * void doSpecialization(int operand) {...} - *- * - * - * - * @see Cached - * @see ImportStatic - */ - String[] guards() default {}; - - /** - *
- * Declares assumption guards that optimistically assume that the state of an {@link Assumption} - * remains valid. Assumption expressions are cached once per specialization instantiation. If - * one of the returned assumptions gets invalidated then the specialization instance is removed. - * If the assumption expression returns an array of assumptions then all assumptions of the - * array are checked. This is limited to one-dimensional arrays. - *
- *- * Assumption expressions are defined using a subset of Java. This subset includes - * field/parameter accesses, function calls, type exact infix comparisons (==, !=, <, <=, >, - * >=), logical negation (!), logical disjunction (||) and integer literals. The return type of - * the expression must be {@link Assumption} or an array of {@link Assumption} instances. - * Assumption expressions are not allowed to bind to dynamic parameter values of the - * specialization. Bound elements without receivers are resolved using the following order: - *
- * Example usage: - * - *
- * static abstract class DynamicObject() { - * abstract Shape getShape(); - * ... - * } - * static abstract class Shape() { - * abstract Assumption getUnmodifiedAssuption(); - * ... - * } - * @Specialization(guards = "operand.getShape() == cachedShape", assumptions = "cachedShape.getUnmodifiedAssumption()") - * void doAssumeUnmodifiedShape(DynamicObject operand, @Cached("operand.getShape()") Shape cachedShape) {...} - *- * - * - * - * @see Cached - * @see ImportStatic - */ - String[] assumptions() default {}; - - /** - *
- * Declares the expression that limits the number of specialization instantiations. The default
- * limit for specialization instantiations is defined as "3"
. If the limit is
- * exceeded no more instantiations of the enclosing specialization method are created. Please
- * note that the existing specialization instantiations are not removed from the
- * specialization chain. You can use {@link #contains()} to remove unnecessary specializations
- * instances.
- *
- * The limit expression is defined using a subset of Java. This subset includes field/parameter
- * accesses, function calls, type exact infix comparisons (==, !=, <, <=, >, >=), logical
- * negation (!), logical disjunction (||) and integer literals. The return type of the limit
- * expression must be int
. Limit expressions are not allowed to bind to dynamic
- * parameter values of the specialization. Bound elements without receivers are resolved using
- * the following order:
- *
- * Example usage: - * - *
- * static int getCacheLimit() { - * return Integer.parseInt(System.getProperty("language.cacheLimit")); - * } - * @Specialization(guards = "operand == cachedOperand", limit = "getCacheLimit()") - * void doCached(Object operand, @Cached("operand") Object cachedOperand) {...} - *- * - * - * - * @see #guards() - * @see #contains() - * @see Cached - * @see ImportStatic - */ - String limit() default ""; - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeCast.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeCast.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -/** - * Overrides the standard way of casting a certain type in a {@link TypeSystem}. This is useful for - * types where the guest language specific type cast can be implemented more efficiently than an - * instanceof check. The annotated method must be contained in a {@link TypeSystem} annotated class. - * Type checks must conform to the following signature:
public static Type as{TypeName}(Object
- * value)
. The casted type must be a type declared in the {@link TypeSystem}.
- *
- * - * If no {@link TypeCast} is declared then the type system implicitly uses a type cast that can be - * declared as follows: - * - *
- * {@literal @}TypeCast(Type.class) - * public static Type asType(Object value) { - * return (Type) value; - * } - *- * - * @see TypeCheck - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD}) -public @interface TypeCast { - - Class> value(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeCheck.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeCheck.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -/** - * Overrides the standard way of checking for a certain type in a {@link TypeSystem}. This is useful - * for types where the guest language specific type check can be implemented more efficiently than a - * direct cast. The annotated method must be contained in a {@link TypeSystem} annotated class. Type - * checks must conform to the following signature:
public static boolean is{TypeName}(Object
- * value)
. The checked type must be a type declared in the {@link TypeSystem}.
- *
- * - * If no {@link TypeCheck} is declared then the type system implicitly uses a type check that can be - * declared as follows: - * - *
- * {@literal @}TypeCheck(Type.class) - * public static boolean isType(Object value) { - * return value instanceof Type; - * } - *- * - * @see TypeCast - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.METHOD}) -public @interface TypeCheck { - - Class> value(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystem.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystem.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -import com.oracle.truffle.api.nodes.*; - -/** - *
- * Each {@link Node} has one {@link TypeSystem} at its root to define the types that can be used - * throughout the system. Multiple {@link TypeSystem}s are allowed, but they cannot be mixed inside - * a single {@link Node} hierarchy. A {@link TypeSystem} defines a list of types as its child - * elements, in which every type precedes its super types.The latter condition ensures that the most - * concrete type is found first when searching the list sequentially for the type of a given generic - * value. - *
- * - *
- * Each {@link #value()} is represented as a java type. A type can specify two annotations:
- * {@link TypeCheck} and {@link TypeCast}. The {@link TypeCheck} checks whether a given generic
- * value matches to the current type. The {@link TypeCast} casts a generic type value to the current
- * type. If the {@link TypeCheck} and {@link TypeCast} annotations are not declared in the
- * {@link TypeSystem} the a default implementation is provided. The default implementation of
- * {@link TypeCheck} returns true
only on an exact type match and {@link TypeCast} is
- * only a cast to this type. Specified methods with {@link TypeCheck} and {@link TypeCast} may be
- * used to extend the definition of a type in the language. In our example, the
- * isInteger
and asInteger
methods are defined in a way so that they
- * accept also {@link Integer} values, implicitly converting them to {@link Double} . This example
- * points out how we express implicit type conversions.
- *
- * Example: The {@link TypeSystem} contains the types {@link Boolean}, {@link Integer}, and - * {@link Double}. The type {@link Object} is always used implicitly as the generic type represent - * all values. - * - *
- * - * {@literal @}TypeSystem(types = {boolean.class, int.class, double.class}) - * public abstract class ExampleTypeSystem { - * - * {@literal @}TypeCheck - * public boolean isInteger(Object value) { - * return value instanceof Integer || value instanceof Double; - * } - * - * {@literal @}TypeCast - * public double asInteger(Object value) { - * return ((Number)value).doubleValue(); - * } - * } - *- * - * - * @see TypeCast - * @see TypeCheck - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE}) -public @interface TypeSystem { - - /** - * The list of types as child elements of the {@link TypeSystem}. Each precedes its super type. - */ - Class>[] value(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystemReference.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/TypeSystemReference.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.lang.annotation.*; - -import com.oracle.truffle.api.nodes.*; - -/** - * References a {@link TypeSystem} on a node. Must be applied on a {@link Node} class. At least one - * {@link TypeSystem} must be referenced in a {@link Node}'s type hierarchy. - * - * @see TypeSystem - * @see Node - */ -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE}) -public @interface TypeSystemReference { - - /** The {@link TypeSystem} java type. */ - Class> value(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/UnsupportedSpecializationException.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/UnsupportedSpecializationException.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl; - -import java.util.*; - -import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; -import com.oracle.truffle.api.nodes.*; - -/** - * Thrown by the generated code of Truffle-DSL if no compatible Specialization could be found for - * the provided values. - */ -public final class UnsupportedSpecializationException extends RuntimeException { - - private static final long serialVersionUID = -2122892028296836269L; - - private final Node node; - private final Node[] suppliedNodes; - private final Object[] suppliedValues; - - @TruffleBoundary - public UnsupportedSpecializationException(Node node, Node[] suppliedNodes, Object... suppliedValues) { - Objects.requireNonNull(suppliedNodes, "The suppliedNodes parameter must not be null."); - if (suppliedNodes.length != suppliedValues.length) { - throw new IllegalArgumentException("The length of suppliedNodes must match the length of suppliedValues."); - } - this.node = node; - this.suppliedNodes = suppliedNodes; - this.suppliedValues = suppliedValues; - } - - @Override - public String getMessage() { - return String.format("Unexpected values provided for %s: %s", node, Arrays.toString(suppliedValues)); - } - - /** - * Returns the {@link Node} that caused the this {@link UnsupportedSpecializationException}. - */ - public Node getNode() { - return node; - } - - /** - * Returns the children of the {@link Node} returned by {@link #getNode()} which produced the - * values returned by {@link #getSuppliedValues()}. The array returned by - * {@link #getSuppliedNodes()} has the same length as the array returned by - * {@link #getSuppliedValues()}. Never returns null. - */ - public Node[] getSuppliedNodes() { - return suppliedNodes; - } - - /** - * Returns the dynamic values that were supplied to the node.The array returned by - * {@link #getSuppliedNodes()} has the same length as the array returned by - * {@link #getSuppliedValues()}. Never returns null. - */ - public Object[] getSuppliedValues() { - return suppliedValues; - } - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLMetadata.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLMetadata.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl.internal; - -/** - * This is NOT public API. Do not use directly. This code may change without notice. - */ -public final class DSLMetadata { - - public static final Class>[] EMPTY_CLASS_ARRAY = new Class>[]{}; - public static final DSLMetadata NONE = new DSLMetadata(null, EMPTY_CLASS_ARRAY, EMPTY_CLASS_ARRAY, EMPTY_CLASS_ARRAY, 0, 0); - - private final Class> specializationClass; - private final Class>[] includes; - private final Class>[] excludedBy; - private final Class>[] specializedTypes; - - private final int costs; - private final int order; - - public DSLMetadata(Class> specializationClass, Class>[] includes, Class>[] excludes, Class>[] specializedTypes, int costs, int order) { - this.specializationClass = specializationClass; - this.includes = includes; - this.excludedBy = excludes; - this.specializedTypes = specializedTypes; - this.costs = costs; - this.order = order; - } - - public Class> getSpecializationClass() { - return specializationClass; - } - - public Class>[] getSpecializedTypes() { - return specializedTypes; - } - - Class>[] getIncludes() { - return includes; - } - - Class>[] getExcludedBy() { - return excludedBy; - } - - int getCosts() { - return costs; - } - - int getOrder() { - return order; - } -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLNode.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLNode.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl.internal; - -import com.oracle.truffle.api.nodes.*; - -/** - * This is NOT public API. Do not use directly. This code may change without notice. - */ -public interface DSLNode { - - DSLMetadata getMetadata0(); - - void adoptChildren0(Node other, Node next); - - void updateTypes0(Class>[] types); - - Node getNext0(); - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLOptions.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLOptions.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,142 +0,0 @@ -/* - * 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.dsl.internal; - -import java.lang.annotation.*; - -/** - * Internal DSL options to tune the generated code. These are expert options and not intended to be - * changed used for guest language implementations. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface DSLOptions { - - /** Flag has no effect anymore. Is going to be removed soon. */ - @Deprecated - boolean useNewLayout() default true; - - /** - * Lazy class loading ensures that all generated specialization classes are loaded lazily. - * Disabling this feature will eagerly load all classes but will also reduce the generated code - * size. - */ - boolean useLazyClassLoading() default true; - - /** - * Sets the optimization strategy for implicit casts. - */ - ImplicitCastOptimization implicitCastOptimization() default ImplicitCastOptimization.DUPLICATE_TAIL; - - /** Not yet implemented. */ - boolean useDisjunctiveMethodGuardOptimization() default true; - - public enum ImplicitCastOptimization { - - /** Perform no informed optimization for implicit casts. */ - NONE, - - /** Duplicate specializations for each used implicit cast combination. */ - DUPLICATE_TAIL, - - /** - * Use the same specialization for multiple combinations of implicit casts and specialize - * them independently. Not yet fully implemented. - */ - MERGE_CASTS; - - public boolean isNone() { - return this == NONE; - } - - public boolean isDuplicateTail() { - return this == DUPLICATE_TAIL; - } - - public boolean isMergeCasts() { - return this == MERGE_CASTS; - } - } - - public enum TypeBoxingOptimization { - /** Perform the optimization for all types. */ - ALWAYS, - /** Perform the optimization just for primitive types. */ - PRIMITIVE, - /** Perform the optimization for no types. */ - NONE; - } - - /** - * Defines the range of the generation of type specialized execute methods for return types and - * for specialized parameter types. A type specialized execute method is generated as soon as - * one declared type is either returned or used a specialized parameter. - */ - TypeBoxingOptimization monomorphicTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE; - - /** - * Defines the range of types for which type specialized execute methods should be used for - * polymorphic operations. - */ - TypeBoxingOptimization polymorphicTypeBoxingElimination() default TypeBoxingOptimization.PRIMITIVE; - - /** - * Defines the range of types for which type specialized execute methods for implicit cast - * optimizations are used. This option only has an effect if - * {@link ImplicitCastOptimization#DUPLICATE_TAIL} or - * {@link ImplicitCastOptimization#MERGE_CASTS} is set in {@link #implicitCastOptimization()}. - */ - TypeBoxingOptimization implicitTypeBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE; - - /** - * Defines range of specialization return types in which the void boxing optimization is used. - * Void boxing generates an extra execute method with {@link Void} return type in order to avoid - * boxing and type checking of the return type in case the return type is not needed. For this - * to work the operation class needs to provide an overridable execute method returning - * {@link Void}. - */ - TypeBoxingOptimization voidBoxingOptimization() default TypeBoxingOptimization.PRIMITIVE; - - public enum FallbackOptimization { - /** Always generate an optimized fallback specialization. */ - ALWAYS, - - /** - * Only generate an optimized fallback specialization if a method annotated with @Fallback - * is used in the operation. - */ - DECLARED, - - /** - * Never generate an optimized fallback specialization. Please be aware that triggering a @Fallback - * case without optimization will also invalidate your compiled code. - */ - NEVER; - } - - /** Defines the optimization strategy that is used to optimize @Fallback annotated methods. */ - FallbackOptimization optimizeFallback() default FallbackOptimization.DECLARED; - -} diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLShare.java --- a/graal/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/internal/DSLShare.java Tue Jun 16 16:30:34 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2012, 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. 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.dsl.internal; - -import java.util.*; -import java.util.concurrent.*; - -import com.oracle.truffle.api.nodes.*; - -/** Contains utility classes shared across generated DSLNode implementations. */ -public class DSLShare { - - public static boolean isExcluded(Node currentNode, DSLMetadata otherMetadata) { - assert otherMetadata.getExcludedBy().length > 0 : "At least one exclude must be defined for isIncluded."; - Node cur = findRoot(currentNode); - while (cur != null) { - Class> curClass = cur.getClass(); - if (curClass == otherMetadata.getSpecializationClass()) { - return true; - } else if (containsClass(otherMetadata.getExcludedBy(), cur)) { - return true; - } - cur = getNext(cur); - } - return false; - } - - private static boolean includes(Node oldNode, DSLNode newNode) { - return containsClass(newNode.getMetadata0().getIncludes(), oldNode); - } - - public static
ForeignAccess
- * , use one of the factory methods available in this class.
- */
-public final class ForeignAccess {
- private final Factory factory;
-
- private ForeignAccess(Factory faf) {
- this.factory = faf;
- }
-
- /**
- * Creates new instance of {@link ForeignAccess} that delegates to provided factory.
- *
- * @param baseClass the super class of all {@link TruffleObject}s handled by this factory (if
- * null
than the second interface also needs to implement
- * {@link Factory})
- * @param factory the factory that handles access requests to {@link Message}s known as of
- * version 1.0
- * @return new instance wrapping factory
- */
- public static ForeignAccess create(final Class extends TruffleObject> baseClass, final Factory10 factory) {
- if (baseClass == null) {
- Factory f = (Factory) factory;
- assert f != null;
- }
- class DelegatingFactory implements Factory {
- @Override
- public boolean canHandle(TruffleObject obj) {
- if (baseClass == null) {
- return ((Factory) factory).canHandle(obj);
- }
- return baseClass.isInstance(obj);
- }
-
- @Override
- public CallTarget accessMessage(Message msg) {
- if (msg instanceof KnownMessage) {
- switch (msg.hashCode()) {
- case Execute.HASH1:
- return factory.accessInvoke(((Execute) msg).getArity());
- case Execute.HASH2:
- return factory.accessExecute(((Execute) msg).getArity());
- case GetSize.HASH:
- return factory.accessGetSize();
- case HasSize.HASH:
- return factory.accessHasSize();
- case IsBoxed.HASH:
- return factory.accessIsBoxed();
- case IsExecutable.HASH:
- return factory.accessIsExecutable();
- case IsNull.HASH:
- return factory.accessIsNull();
- case Read.HASH:
- return factory.accessRead();
- case Unbox.HASH:
- return factory.accessUnbox();
- case Write.HASH:
- return factory.accessWrite();
- }
- }
- return factory.accessMessage(msg);
- }
- }
- return new ForeignAccess(new DelegatingFactory());
- }
-
- /**
- * Creates new instance of {@link ForeignAccess} that delegates to provided factory.
- *
- * @param factory the factory that handles various access requests {@link Message}s.
- * @return new instance wrapping factory
- */
- public static ForeignAccess create(Factory factory) {
- return new ForeignAccess(factory);
- }
-
- /**
- * Executes {@link Message#createNode() foreign node}.
- *
- * @param foreignNode the createNode created by {@link Message#createNode()}
- * @param frame the call frame
- * @param receiver foreign object to receive the message passed to {@link Message#createNode()}
- * method
- * @param arguments parameters for the receiver
- * @return return value, if any
- * @throws ClassCastException if the createNode has not been created by
- * {@link Message#createNode()} method.
- */
- public static Object execute(Node foreignNode, VirtualFrame frame, TruffleObject receiver, Object... arguments) {
- ForeignObjectAccessHeadNode fn = (ForeignObjectAccessHeadNode) foreignNode;
- return fn.executeForeign(frame, receiver, arguments);
- }
-
- /**
- * Read only access to foreign call arguments inside of a frame.
- *
- * @param frame the frame that was called via
- * {@link #execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object...) }
- * @return read-only list of parameters passed to the frame
- */
- public static Listnull
if this message is not
- * supported
- */
- CallTarget accessIsNull();
-
- /**
- * Handles {@link Message#IS_EXECUTABLE} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessIsExecutable();
-
- /**
- * Handles {@link Message#IS_BOXED} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessIsBoxed();
-
- /**
- * Handles {@link Message#HAS_SIZE} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessHasSize();
-
- /**
- * Handles {@link Message#GET_SIZE} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessGetSize();
-
- /**
- * Handles {@link Message#UNBOX} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessUnbox();
-
- /**
- * Handles {@link Message#READ} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessRead();
-
- /**
- * Handles {@link Message#WRITE} message.
- *
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessWrite();
-
- /**
- * Handles {@link Message#createExecute(int)} messages.
- *
- * @param argumentsLength number of parameters the messages has been created for
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessExecute(int argumentsLength);
-
- /**
- * Handles {@link Message#createInvoke(int)} messages.
- *
- * @param argumentsLength number of parameters the messages has been created for
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessInvoke(int argumentsLength);
-
- /**
- * Handles request for access to a message not known in version 1.0.
- *
- * @param unknown the message
- * @return call target to handle the message or null
if this message is not
- * supported
- */
- CallTarget accessMessage(Message unknown);
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ForeignAccessArguments.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ForeignAccessArguments.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.interop;
-
-final class ForeignAccessArguments {
- static final Object[] EMPTY_ARGUMENTS_ARRAY = new Object[0];
- static final int RECEIVER_INDEX = 0;
- static final int RUNTIME_ARGUMENT_COUNT = 1;
-
- static Object[] create(Object receiver, Object... arguments) {
- if (arguments.length == 0) {
- return new Object[]{receiver};
- }
- Object[] objectArguments = new Object[RUNTIME_ARGUMENT_COUNT + arguments.length];
- objectArguments[RECEIVER_INDEX] = receiver;
- arraycopy(arguments, 0, objectArguments, RUNTIME_ARGUMENT_COUNT, arguments.length);
- return objectArguments;
- }
-
- private static void arraycopy(Object[] src, int srcPos, Object[] dest, int destPos, int length) {
- for (int i = 0; i < length; i++) {
- dest[destPos + i] = src[srcPos + i];
- }
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ForeignObjectAccessHeadNode.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ForeignObjectAccessHeadNode.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * 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.interop;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.Node;
-
-final class ForeignObjectAccessHeadNode extends Node {
-
- @Child private ObjectAccessNode first;
- private final Message accessTree;
-
- protected ForeignObjectAccessHeadNode(Message tree) {
- this.accessTree = tree;
- this.first = new UnresolvedObjectAccessNode();
- adoptChildren();
- }
-
- protected Message getAccessTree() {
- return accessTree;
- }
-
- protected ObjectAccessNode getFirst() {
- return first;
- }
-
- public Object executeForeign(VirtualFrame frame, TruffleObject receiver, Object... arguments) {
- return first.executeWith(frame, receiver, arguments);
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/GetSize.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/GetSize.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * 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.interop;
-
-final class GetSize extends UnaryMessage {
- public static final int HASH = 423432;
-
- static Message INSTANCE = new GetSize();
-
- @Override
- public String toString() {
- return "msgGetSize";
- }
-
- @Override
- public int hashCode() {
- return HASH;
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/HasSize.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/HasSize.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.interop;
-
-final class HasSize extends UnaryMessage {
- public static final int HASH = 423433;
- static Message INSTANCE = new HasSize();
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgHasSize";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsBoxed.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsBoxed.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.interop;
-
-final class IsBoxed extends UnaryMessage {
- public static final int HASH = 423434;
- static Message INSTANCE = new IsBoxed();
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgIsBoxed";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsExecutable.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsExecutable.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.interop;
-
-final class IsExecutable extends UnaryMessage {
- public static final int HASH = 423435;
- static Message INSTANCE = new IsExecutable();
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgIsExecutable";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsNull.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/IsNull.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.interop;
-
-final class IsNull extends UnaryMessage {
- public static final int HASH = 423436;
- static Message INSTANCE = new IsNull();
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgIsNull";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/KnownMessage.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/KnownMessage.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/*
- * 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.interop;
-
-/**
- * Marker class.
- */
-abstract class KnownMessage extends Message {
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Message.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Message.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-/*
- * 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.interop;
-
-import com.oracle.truffle.api.nodes.Node;
-import com.oracle.truffle.api.interop.ForeignAccess.Factory;
-
-/**
- * Inter-operability is based on sending messages. Standard messages are defined as as constants
- * like {@link #IS_NULL} or factory methods in this class, but one can always define their own,
- * specialized messages.
- */
-public abstract class Message {
- /**
- * Message to read a field.
- */
- public static final Message READ = Read.INSTANCE;
-
- /**
- * Converts {@link TruffleObject truffle value} to Java primitive type. Primitive types are
- * subclasses of {@link Number}, {@link Boolean}, {@link Character} and {@link String}. Related
- * to {@link #IS_BOXED} message.
- */
- public static final Message UNBOX = Unbox.INSTANCE;
-
- /**
- * Message to write a field.
- */
- public static Message WRITE = Write.INSTANCE;
-
- /**
- * Creates an execute message. All messages created by this method are
- * {@link Object#equals(java.lang.Object) equal} to each other regardless of the value of
- * argumentsLength
.
- *
- * @param argumentsLength number of parameters to pass to the target
- * @return execute message
- */
- public static Message createExecute(int argumentsLength) {
- return Execute.create(false, argumentsLength);
- }
-
- /**
- * Message to check for executability.
- *
- * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for
- * this message should yield value of {@link Boolean}.
- */
- public static final Message IS_EXECUTABLE = IsExecutable.INSTANCE;
-
- /**
- * Creates an execute message. All messages created by this method are
- * {@link Object#equals(java.lang.Object) equal} to each other regardless of the value of
- * argumentsLength
. The expected behavior of this message is to perform
- * {@link #READ} first and on the result invoke {@link #createExecute(int)}.
- *
- * @param argumentsLength number of parameters to pass to the target
- * @return read & execute message
- */
- public static Message createInvoke(int argumentsLength) {
- return Execute.create(true, argumentsLength);
- }
-
- /**
- * Check for null
message. The Truffle languages are suggested to have their own
- * object representing null
like values in their languages. For purposes of
- * inter-operability it is essential to canonicalize such values from time to time - sending
- * this message is a way to recognize such null
representing values.
- *
- * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for - * this message should yield value of {@link Boolean}. - */ - public static final Message IS_NULL = IsNull.INSTANCE; - - /** - * Message to check for having a size. - *
- * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for - * this message should yield value of {@link Boolean}. - */ - public static final Message HAS_SIZE = HasSize.INSTANCE; - - /** - * Getter of the size. If {@link #HAS_SIZE supported}, this message allows to obtain a size (of - * an array). - *
- * Calling {@link Factory#access(com.oracle.truffle.api.interop.Message) the target} created for - * this message should yield value of {@link Integer}. - */ - public static final Message GET_SIZE = GetSize.INSTANCE; - - /** - * Check for value being boxed. Can you value be converted to one of the basic Java types? Many - * languages have a special representation for types like number, string, etc. To ensure - * inter-operability, these types should support unboxing - if they do, they should handle this - * message. - *
- * Calling {@link Factory#accessMessage(com.oracle.truffle.api.interop.Message) the target}
- * created for this message should yield value of {@link Boolean}.
- */
- public static final Message IS_BOXED = IsBoxed.INSTANCE;
-
- /**
- * Compares types of two messages. Messages are encouraged to implement this method. All
- * standard ones ({@link #IS_NULL}, {@link #READ}, etc.) do so. Messages obtained via the same
- * {@link #createExecute(int) method} are equal, messages obtained by different methods or
- * fields are not.
- *
- * @param message the object to compare to
- * @return true, if the structure of the message is that same as of
- * Languages can exchange primitive Java type wrapper objects (e.g., {@link java.lang.Integer},
- * {@link java.lang.Double}, {@link java.lang.String}, etc) as well as any type
- * implementing {@link com.oracle.truffle.api.interop.TruffleObject}. Foreign objects are
- * precisely those implementing {@link com.oracle.truffle.api.interop.TruffleObject}.
- *
- * To use a {@link com.oracle.truffle.api.interop.TruffleObject} from a different language,
- * you need to ask the language to build appropriate AST for a given
- * {@link com.oracle.truffle.api.interop.Message} with
- * {@link com.oracle.truffle.api.interop.Message#createNode}. The message can then
- * be executed with {@link com.oracle.truffle.api.interop.ForeignAccess#execute}.
- */
-package com.oracle.truffle.api.interop;
-
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/BaseLocation.java
--- a/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/BaseLocation.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2013, 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.object;
-
-public interface BaseLocation {
- /**
- * Get object value as object at this location in store.
- *
- * @param shape the current shape of the object, which must contain this location
- */
- Object get(DynamicObject store, Shape shape);
-
- /**
- * Get object value as object at this location in store. For internal use only and subject to
- * change, use {@link #get(DynamicObject, Shape)} instead.
- *
- * @param condition the result of a shape check or {@code false}
- * @see #get(DynamicObject, Shape)
- */
- Object get(DynamicObject store, boolean condition);
-
- /**
- * Set object value at this location in store.
- *
- * @throws IncompatibleLocationException for storage type invalidations
- * @throws FinalLocationException for effectively final fields
- */
- void set(DynamicObject store, Object value) throws IncompatibleLocationException, FinalLocationException;
-
- /**
- * Set object value at this location in store.
- *
- * @param shape the current shape of the storage object
- * @throws IncompatibleLocationException for storage type invalidations
- * @throws FinalLocationException for effectively final fields
- */
- void set(DynamicObject store, Object value, Shape shape) throws IncompatibleLocationException, FinalLocationException;
-
- /**
- * Set object value at this location in store and update shape.
- *
- * @param oldShape the shape before the transition
- * @param newShape new shape after the transition
- * @throws IncompatibleLocationException if value is of non-assignable type
- */
- void set(DynamicObject store, Object value, Shape oldShape, Shape newShape) throws IncompatibleLocationException;
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/BooleanLocation.java
--- a/graal/com.oracle.truffle.api.object/src/com/oracle/truffle/api/object/BooleanLocation.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2013, 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.object;
-
-public interface BooleanLocation extends TypedLocation {
- /**
- * @see #get(DynamicObject, Shape)
- */
- boolean getBoolean(DynamicObject store, Shape shape);
-
- /**
- * @see #get(DynamicObject, boolean)
- */
- boolean getBoolean(DynamicObject store, boolean condition);
-
- /**
- * @see #set(DynamicObject, Object)
- */
- void setBoolean(DynamicObject store, boolean value) throws FinalLocationException;
-
- /**
- * @see #set(DynamicObject, Object, Shape)
- */
- void setBoolean(DynamicObject store, boolean value, Shape shape) throws FinalLocationException;
-
- /**
- * @see #set(DynamicObject, Object, Shape, Shape)
- */
- void setBoolean(DynamicObject store, boolean value, Shape oldShape, Shape newShape);
-
- Class
- * When invoking a call target with {@link CallTarget#call(Object[])}, arguments can be passed. A
- * Truffle node can access the arguments passed into the Truffle method by using
- * {@link VirtualFrame#getArguments}.
- *
- * The arguments class should only contain fields that are declared as final. This allows the
- * Truffle runtime to improve optimizations around guest language method calls. Also, the arguments
- * object array must never be stored into a field. It should be created immediately before invoking
- * {@link CallTarget#call(Object[])} and no longer be accessed afterwards.
- *
- * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.FrameTest}
- * .
- *
- * A guest language implementation can create multiple call targets using the
- * {@link TruffleRuntime#createCallTarget(RootNode)} method. Those call targets can be passed around
- * as normal Java objects and used for calling guest language methods.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.ArgumentsTest}.
- *
- * Child nodes are stored in the class of the parent node in fields that are marked with the
- * {@link Child} annotation. The {@link Node#getParent()} method allows access to this field. Every
- * node also provides the ability to iterate over its children using {@link Node#getChildren()}.
- *
- * A child node field must be declared private and non-final. It may only be assigned in the
- * constructor of the parent node. For changing the structure of the tree at run time, the method
- * {@link Node#replace(Node)} must be used (see {@link ReplaceTest}).
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.ChildrenNodesTest}.
- *
- * An array of children nodes can be used as a field in a parent node. The field has to be annotated
- * with {@link com.oracle.truffle.api.nodes.Node.Children} and must be declared private and final.
- * Before assigning the field in the parent node constructor, {@link Node#adoptChildren} must be
- * called in order to update the parent pointers in the child nodes. After filling the array with
- * its first values, it must never be changed. It is only possible to call {@link Node#replace} on a
- * child node.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.FinalFieldTest}.
- *
- * The usage of final fields in node classes is highly encouraged. It is beneficial for performance
- * to declare every field that is not pointing to a child node as final. This gives the Truffle
- * runtime an increased opportunity to optimize this node.
- *
- * If a node has a value which may change at run time, but will rarely do so, it is recommended to
- * speculate on the field being final. This involves starting executing with a node where this field
- * is final and only if this turns out to be no longer the case, the node is replaced with an
- * alternative implementation of the operation (see {@link ReplaceTest}).
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.ReplaceTest}.
- *
- * Dynamically typed languages can speculate on the type of a frame slot and only fall back at run
- * time to a more generic type if necessary. The new type of a frame slot can be set using the
- * {@link FrameSlot#setKind(FrameSlotKind)} method.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.ReturnTypeSpecializationTest}.
- *
- * The frame is the preferred data structure for passing values between nodes. It can in particular
- * be used for storing the values of local variables of the guest language. The
- * {@link FrameDescriptor} represents the current structure of the frame. The method
- * {@link FrameDescriptor#addFrameSlot(Object, FrameSlotKind)} can be used to create predefined
- * frame slots. The setter and getter methods in the {@link Frame} class can be used to access the
- * current value of a particular frame slot. Values can be removed from a frame via the
- * {@link FrameDescriptor#removeFrameSlot(Object)} method.
- *
- * There are five primitive types for slots available: {@link java.lang.Boolean},
- * {@link java.lang.Integer}, {@link java.lang.Long}, {@link java.lang.Float}, and
- * {@link java.lang.Double} . It is encouraged to use those types whenever possible. Dynamically
- * typed languages can speculate on the type of a value fitting into a primitive (see
- * {@link FrameSlotTypeSpecializationTest}). When a frame slot is of one of those particular
- * primitive types, its value may only be accessed with the respectively typed getter method (
- * {@link Frame#getBoolean}, {@link Frame#getInt}, {@link Frame#getLong}, {@link Frame#getFloat}, or
- * {@link Frame#getDouble}) or setter method ({@link Frame#setBoolean}, {@link Frame#setInt},
- * {@link Frame#setLong}, {@link Frame#setFloat}, or {@link Frame#setDouble}) in the {@link Frame}
- * class.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.FrameSlotTypeSpecializationTest}.
- *
- * The structure of the Truffle tree can be changed at run time by replacing nodes using the
- * {@link Node#replace(Node)} method. This method will automatically change the child pointer in the
- * parent of the node and replace it with a pointer to the new node.
- *
- * Replacing nodes is a costly operation, so it should not happen too often. The convention is that
- * the implementation of the Truffle nodes should ensure that there are maximal a small (and
- * constant) number of node replacements per Truffle node.
- *
- * The next part of the Truffle API introduction is at {@link com.oracle.truffle.api.test.CallTest}.
- *
- * In order to avoid boxing and/or type casts on the return value of a node, the return value the
- * method for executing a node can have a specific type and need not be of type
- * {@link java.lang.Object}. For dynamically typed languages, this return type is something that
- * should be speculated on. When the speculation fails and the child node cannot return the
- * appropriate type of value, it can use an {@link UnexpectedResultException} to still pass the
- * result to the caller. In such a case, the caller must rewrite itself to a more general version in
- * order to avoid future failures of this kind.
- *
- * A Truffle root node is the entry point into a Truffle tree that represents a guest language
- * method. It contains a {@link RootNode#execute(VirtualFrame)} method that can return a
- * {@link java.lang.Object} value as the result of the guest language method invocation. This method
- * must however never be called directly. Instead, the Truffle runtime must be used to create a
- * {@link CallTarget} object from a root node using the
- * {@link TruffleRuntime#createCallTarget(RootNode)} method. This call target object can then be
- * executed using the {@link CallTarget#call(Object...)} method or one of its overloads.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.ChildNodeTest}.
- *
- * The Truffle runtime can be accessed at any point in time globally using the static method
- * {@link Truffle#getRuntime()}. This method is guaranteed to return a non-null Truffle runtime
- * object with an identifying name. A Java Virtual Machine implementation can chose to replace the
- * default implementation of the {@link TruffleRuntime} interface with its own implementation for
- * providing improved performance.
- *
- * The next part of the Truffle API introduction is at
- * {@link com.oracle.truffle.api.test.RootNodeTest}.
- * This package contains basic tests of the Truffle API and serves at the same
- * time as an introduction to the Truffle API for language implementors. Every test gives an example on how to use the construct explained in the class description.
- * Truffle is a language implementation framework. A guest language method is represented as a tree of executable nodes.
- * The framework provides mechanisms for those trees to call each other. Additionally it contains dedicated data structures for storing data local to a tree invocation.
- *
- * This introduction to Truffle contains items in the following recommended order:
- *
- *
- * The exported object can either be
- * The way a symbol becomes exported is language dependent. In general it is preferred
- * to make the export explicit - e.g. call some function or method to register an object under
- * specific name. Some languages may however decide to support implicit export of symbols (for
- * example from global scope, if they have one). However explicit exports should always be
- * preferred. Implicitly exported object of some name should only be used when there is no
- * explicit export under such
- * The object is expected to be
- * Can be set with {@code -Dtruffle.ForceInterpreter=true}.
- */
- public static final boolean ForceInterpreter = Boolean.getBoolean("truffle.ForceInterpreter");
-
- /**
- * Enables/disables the rewriting of traces in the Truffle runtime to stdout.
- *
- * Can be set with {@code -Dtruffle.TraceRewrites=true}.
- */
- public static final boolean TraceRewrites;
-
- /**
- * Enables the generation of detailed rewrite reasons. Enabling this may introduce some overhead
- * for rewriting nodes.
- *
- * Can be set with {@code -Dtruffle.DetailedRewriteReasons=true}.
- */
- public static final boolean DetailedRewriteReasons;
-
- /**
- * Filters rewrites that do not contain the given string in the qualified name of the source or
- * target class hierarchy.
- *
- * Can be set with {@code -Dtruffle.TraceRewritesFilterClass=name}.
- */
- public static String TraceRewritesFilterClass;
-
- /**
- * Filters rewrites which does not contain the {@link NodeCost} in its source {@link NodeInfo}.
- * If no {@link NodeInfo} is defined the element is filtered if the filter value is set.
- *
- * Can be set with
- * {@code -Dtruffle.TraceRewritesFilterFromCost=NONE|MONOMORPHIC|POLYMORPHIC|MEGAMORPHIC}.
- */
- public static NodeCost TraceRewritesFilterFromCost;
-
- /**
- * Filters rewrites which does not contain the {@link NodeCost} in its target {@link NodeInfo}.
- * If no {@link NodeInfo} is defined the element is filtered if the filter value is set.
- *
- * Can be set with
- * {@code -Dtruffle.TraceRewritesFilterToKind=UNINITIALIZED|SPECIALIZED|POLYMORPHIC|GENERIC}.
- */
- public static NodeCost TraceRewritesFilterToCost;
-
- /**
- * Enables the dumping of Node creations and AST rewrites in JSON format.
- *
- * Can be set with {@code -Dtruffle.TraceASTJSON=true}.
- */
- public static final boolean TraceASTJSON;
-
- private static NodeCost parseNodeInfoKind(String kind) {
- if (kind == null) {
- return null;
- }
-
- return NodeCost.valueOf(kind);
- }
-
- static {
- final boolean[] values = new boolean[3];
- AccessController.doPrivileged(new PrivilegedAction
- * This is an implementation-specific class. Do not use or instantiate it. Instead, use
- * {@link Truffle#getRuntime()} to retrieve the current {@link TruffleRuntime}.
- */
-public final class DefaultTruffleRuntime implements TruffleRuntime {
-
- private final ThreadLocal
- * WARNING: this interface is under development and will change substantially.
- */
-public interface ASTPrinter {
-
- /**
- * Prints a textual AST display, one line per node, with nesting.
- *
- * @param p
- * @param node the root node of the display.
- * @param maxDepth the maximum number of levels to print below the root
- * @param markNode a node to mark with a textual arrow prefix, if present.
- */
- void printTree(PrintWriter p, Node node, int maxDepth, Node markNode);
-
- /**
- * Creates a textual AST display, one line per node, with nesting.
- *
- * @param node the root node of the display.
- * @param maxDepth the maximum number of levels to print below the root
- * @param markNode a node to mark with a textual arrow prefix, if present.
- */
- String printTreeToString(Node node, int maxDepth, Node markNode);
-
- /**
- * Creates a textual AST display, one line per node, with nesting.
- *
- * @param node the root node of the display.
- * @param maxDepth the maximum number of levels to print below the root
- */
- String printTreeToString(Node node, int maxDepth);
-
- /**
- * Creates a textual display describing a single (non-wrapper) node, including instrumentation
- * status: if Probed, and any tags.
- */
- String printNodeWithInstrumentation(Node node);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTProber.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ASTProber.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.instrument;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Enables instrumentation by attaching {@linkplain Probe Probes} to some nodes in a (newly created,
- * not yet executed) AST.
- *
- * @see Probe
- * @see Probe#addProbeListener(ProbeListener)
- */
-public interface ASTProber {
-
- /**
- * Walk the AST starting at a node and enable instrumentation at selected nodes by attaching
- * {@linkplain Probe Probes} to them. Ignore {@linkplain Node#isInstrumentable()
- * non-instrumentable} nodes.
- */
- void probeAST(Node node);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentResultListener.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentResultListener.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Listener for receiving the result a client-provided {@linkplain AdvancedInstrumentRoot AST
- * fragment}, when executed by a
- * {@linkplain Instrument#create(AdvancedInstrumentResultListener, AdvancedInstrumentRootFactory, Class, String)
- * Advanced Instrument}.
- *
- * @see Instrument
- * @see AdvancedInstrumentRoot
- * @see AdvancedInstrumentRootFactory
- */
-public interface AdvancedInstrumentResultListener {
-
- /**
- * Notifies listener that a client-provided {@linkplain AdvancedInstrumentRoot AST fragment} has
- * been executed by an
- * {@linkplain Instrument#create(AdvancedInstrumentResultListener, AdvancedInstrumentRootFactory, Class, String)
- * Advanced Instrument} with the specified result, possibly {@code null}.
- *
- * Note: Truffle will attempt to optimize implementations through partial
- * evaluation; annotate with {@link TruffleBoundary} if this should not be permitted.
- *
- * @param node the guest-language AST node to which the host Instrument's {@link Probe} is
- * attached
- * @param vFrame execution frame at the guest-language AST node
- * @param result the result of this AST fragment's execution
- */
- void notifyResult(Node node, VirtualFrame vFrame, Object result);
-
- /**
- * Notifies listener that execution of client-provided {@linkplain AdvancedInstrumentRoot AST
- * fragment} filed during execution by a @linkplain
- * Instrument#create(AdvancedInstrumentRootFactory, String) Advanced Instrument}.
- *
- * Note: Truffle will attempt to optimize implementations through partial
- * evaluation; annotate with {@link TruffleBoundary} if this should not be permitted.
- *
- * @param node the guest-language AST node to which the host Instrument's {@link Probe} is
- * attached
- * @param vFrame execution frame at the guest-language AST node
- * @param ex the exception
- */
- void notifyFailure(Node node, VirtualFrame vFrame, RuntimeException ex);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentRoot.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentRoot.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Root of a client-provided AST fragment that can be executed efficiently, subject to full Truffle
- * optimization, by an
- * {@linkplain Instrument#create(AdvancedInstrumentResultListener, AdvancedInstrumentRootFactory, Class, String)
- * Advanced Instrument}.
- *
- * @see Instrument
- * @see AdvancedInstrumentRootFactory
- * @see AdvancedInstrumentResultListener
- */
-public abstract class AdvancedInstrumentRoot extends Node implements InstrumentationNode {
-
- /**
- * Executes this AST fragment on behalf of a client {@link Instrument}, just before the
- * guest-language AST node to which the {@link Probe} holding the Instrument is executed.
- *
- * @param node the guest-language AST node to which the host Instrument's Probe is attached
- * @param vFrame execution frame at the guest-language AST node
- * @return the result of this AST fragment's execution
- */
- public abstract Object executeRoot(Node node, VirtualFrame vFrame);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentRootFactory.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/AdvancedInstrumentRootFactory.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Creator of {@linkplain AdvancedInstrumentRoot AST fragments} suitable for efficient execution,
- * subject to full Truffle optimization, by an
- * {@linkplain Instrument#create(AdvancedInstrumentResultListener, AdvancedInstrumentRootFactory, Class, String)
- * Advanced Instrument}.
- *
- * @see Instrument
- * @see AdvancedInstrumentRoot
- */
-public interface AdvancedInstrumentRootFactory {
-
- /**
- * Provider of {@linkplain AdvancedInstrumentRoot AST fragment} instances to be executed by the
- * Instrumentation Framework at a {@linkplain Probe Probed} site in a guest-language AST.
- *
- * Notes:
- *
- * Client-oriented documentation for the use of Instruments is available online at https://wiki.openjdk.java.net/display/Graal/Listening+for+Execution+Events
- *
- * The implementation of Instruments is complicated by the requirement that Truffle be able to clone
- * ASTs at any time. In particular, any instrumentation-supporting Nodes that have been attached to
- * an AST must be cloned along with the AST: AST clones are not permitted to share Nodes.
- *
- * AST cloning is intended to be as transparent as possible to clients. This is encouraged
- * by providing the {@link SimpleInstrumentListener} for clients that need know nothing more than
- * the properties associated with a Probe: it's {@link SourceSection} and any associated instances
- * of {@link SyntaxTag}.
- *
- * AST cloning is not transparent to clients that use the
- * {@link StandardInstrumentListener}, since those event methods identify the concrete Node instance
- * (and thus the AST instance) where the event takes place.
- *
- *
- *
- * Any {@link RuntimeException} thrown by execution of the fragment is caught by the framework
- * and reported to the listener; there is no other notification.
- *
- * @param resultListener optional client callback for results/failure notification
- * @param rootFactory provider of AST fragments on behalf of the client
- * @param requiredResultType optional requirement, any non-assignable result is reported to the
- * the listener, if any, as a failure
- * @param instrumentInfo optional description of the instrument's role, intended for debugging.
- * @return a new instrument, ready for attachment at a probe
- */
- public static Instrument create(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, Class> requiredResultType, String instrumentInfo) {
- return new AdvancedInstrument(resultListener, rootFactory, requiredResultType, instrumentInfo);
- }
-
- // TODO (mlvdv) experimental
- /**
- * For implementation testing.
- */
- public static Instrument create(TruffleOptListener listener) {
- return new TruffleOptInstrument(listener, null);
- }
-
- /**
- * Has this instrument been disposed? stays true once set.
- */
- private boolean isDisposed = false;
-
- protected Probe probe = null;
-
- /**
- * Optional documentation, mainly for debugging.
- */
- private final String instrumentInfo;
-
- private Instrument(String instrumentInfo) {
- this.instrumentInfo = instrumentInfo;
- }
-
- /**
- * Gets the {@link Probe} to which this Instrument is currently attached: {@code null} if not
- * yet attached to a Probe or if this Instrument has been {@linkplain #dispose() disposed}.
- */
- public Probe getProbe() {
- return probe;
- }
-
- /**
- * Removes this Instrument from the Probe to which it attached and renders this Instrument
- * inert.
- *
- * @throws IllegalStateException if this instrument has already been disposed
- */
- public void dispose() throws IllegalStateException {
- if (isDisposed) {
- throw new IllegalStateException("Attempt to dispose an already disposed Instrumennt");
- }
- if (probe != null) {
- // It's attached
- probe.disposeInstrument(this);
- probe = null;
- }
- this.isDisposed = true;
- }
-
- /**
- * For internal implementation only.
- */
- void setAttachedTo(Probe probe) {
- this.probe = probe;
- }
-
- /**
- * Has this instrument been disposed and rendered unusable?
- */
- boolean isDisposed() {
- return isDisposed;
- }
-
- abstract AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode);
-
- /**
- * Removes this instrument from an instrument chain.
- */
- abstract AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode);
-
- /**
- * An instrument that propagates events to an instance of {@link SimpleInstrumentListener}.
- */
- private static final class SimpleInstrument extends Instrument {
-
- /**
- * Tool-supplied listener for events.
- */
- private final SimpleInstrumentListener simpleListener;
-
- private SimpleInstrument(SimpleInstrumentListener simpleListener, String instrumentInfo) {
- super(instrumentInfo);
- this.simpleListener = simpleListener;
- }
-
- @Override
- AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
- return new SimpleInstrumentNode(nextNode);
- }
-
- @Override
- AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
- boolean found = false;
- if (instrumentNode != null) {
- if (instrumentNode.getInstrument() == this) {
- // Found the match at the head of the chain
- return instrumentNode.nextInstrumentNode;
- }
- // Match not at the head of the chain; remove it.
- found = instrumentNode.removeFromChain(SimpleInstrument.this);
- }
- if (!found) {
- throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
- }
- return instrumentNode;
- }
-
- /**
- * Node that implements a {@link SimpleInstrument} in a particular AST.
- */
- @NodeInfo(cost = NodeCost.NONE)
- private final class SimpleInstrumentNode extends AbstractInstrumentNode {
-
- private SimpleInstrumentNode(AbstractInstrumentNode nextNode) {
- super(nextNode);
- }
-
- public void enter(Node node, VirtualFrame vFrame) {
- SimpleInstrument.this.simpleListener.enter(SimpleInstrument.this.probe);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.enter(node, vFrame);
- }
- }
-
- public void returnVoid(Node node, VirtualFrame vFrame) {
- SimpleInstrument.this.simpleListener.returnVoid(SimpleInstrument.this.probe);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnVoid(node, vFrame);
- }
- }
-
- public void returnValue(Node node, VirtualFrame vFrame, Object result) {
- SimpleInstrument.this.simpleListener.returnValue(SimpleInstrument.this.probe, result);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnValue(node, vFrame, result);
- }
- }
-
- public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
- SimpleInstrument.this.simpleListener.returnExceptional(SimpleInstrument.this.probe, exception);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnExceptional(node, vFrame, exception);
- }
- }
-
- public String instrumentationInfo() {
- final String info = getInstrumentInfo();
- return info != null ? info : simpleListener.getClass().getSimpleName();
- }
- }
- }
-
- /**
- * An instrument that propagates events to an instance of {@link StandardInstrumentListener}.
- */
- private static final class StandardInstrument extends Instrument {
-
- /**
- * Tool-supplied listener for AST events.
- */
- private final StandardInstrumentListener standardListener;
-
- private StandardInstrument(StandardInstrumentListener standardListener, String instrumentInfo) {
- super(instrumentInfo);
- this.standardListener = standardListener;
- }
-
- @Override
- AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
- return new StandardInstrumentNode(nextNode);
- }
-
- @Override
- AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
- boolean found = false;
- if (instrumentNode != null) {
- if (instrumentNode.getInstrument() == this) {
- // Found the match at the head of the chain
- return instrumentNode.nextInstrumentNode;
- }
- // Match not at the head of the chain; remove it.
- found = instrumentNode.removeFromChain(StandardInstrument.this);
- }
- if (!found) {
- throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
- }
- return instrumentNode;
- }
-
- /**
- * Node that implements a {@link StandardInstrument} in a particular AST.
- */
- @NodeInfo(cost = NodeCost.NONE)
- private final class StandardInstrumentNode extends AbstractInstrumentNode {
-
- private StandardInstrumentNode(AbstractInstrumentNode nextNode) {
- super(nextNode);
- }
-
- public void enter(Node node, VirtualFrame vFrame) {
- standardListener.enter(StandardInstrument.this.probe, node, vFrame);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.enter(node, vFrame);
- }
- }
-
- public void returnVoid(Node node, VirtualFrame vFrame) {
- standardListener.returnVoid(StandardInstrument.this.probe, node, vFrame);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnVoid(node, vFrame);
- }
- }
-
- public void returnValue(Node node, VirtualFrame vFrame, Object result) {
- standardListener.returnValue(StandardInstrument.this.probe, node, vFrame, result);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnValue(node, vFrame, result);
- }
- }
-
- public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
- standardListener.returnExceptional(StandardInstrument.this.probe, node, vFrame, exception);
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnExceptional(node, vFrame, exception);
- }
- }
-
- public String instrumentationInfo() {
- final String info = getInstrumentInfo();
- return info != null ? info : standardListener.getClass().getSimpleName();
- }
- }
- }
-
- /**
- * An instrument that allows clients to provide an AST fragment to be executed directly from
- * within a Probe's instrumentation chain, and thus directly in the executing Truffle
- * AST with potential for full optimization.
- */
- private static final class AdvancedInstrument extends Instrument {
-
- private final AdvancedInstrumentResultListener resultListener;
- private final AdvancedInstrumentRootFactory rootFactory;
- private final Class> requiredResultType;
-
- private AdvancedInstrument(AdvancedInstrumentResultListener resultListener, AdvancedInstrumentRootFactory rootFactory, Class> requiredResultType, String instrumentInfo) {
- super(instrumentInfo);
- this.resultListener = resultListener;
- this.rootFactory = rootFactory;
- this.requiredResultType = requiredResultType;
- }
-
- @Override
- AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
- return new AdvancedInstrumentNode(nextNode);
- }
-
- @Override
- AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
- boolean found = false;
- if (instrumentNode != null) {
- if (instrumentNode.getInstrument() == this) {
- // Found the match at the head of the chain
- return instrumentNode.nextInstrumentNode;
- }
- // Match not at the head of the chain; remove it.
- found = instrumentNode.removeFromChain(AdvancedInstrument.this);
- }
- if (!found) {
- throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
- }
- return instrumentNode;
- }
-
- /**
- * Node that implements a {@link AdvancedInstrument} in a particular AST.
- */
- @NodeInfo(cost = NodeCost.NONE)
- private final class AdvancedInstrumentNode extends AbstractInstrumentNode {
-
- @Child private AdvancedInstrumentRoot instrumentRoot;
-
- private AdvancedInstrumentNode(AbstractInstrumentNode nextNode) {
- super(nextNode);
- }
-
- public void enter(Node node, VirtualFrame vFrame) {
- if (instrumentRoot == null) {
- try {
- final AdvancedInstrumentRoot newInstrumentRoot = AdvancedInstrument.this.rootFactory.createInstrumentRoot(AdvancedInstrument.this.probe, node);
- if (newInstrumentRoot != null) {
- instrumentRoot = newInstrumentRoot;
- adoptChildren();
- AdvancedInstrument.this.probe.invalidateProbeUnchanged();
- }
- } catch (RuntimeException ex) {
- if (resultListener != null) {
- resultListener.notifyFailure(node, vFrame, ex);
- }
- }
- }
- if (instrumentRoot != null) {
- try {
- final Object result = instrumentRoot.executeRoot(node, vFrame);
- if (resultListener != null) {
- checkResultType(result);
- resultListener.notifyResult(node, vFrame, result);
- }
- } catch (RuntimeException ex) {
- if (resultListener != null) {
- resultListener.notifyFailure(node, vFrame, ex);
- }
- }
- }
- if (nextInstrumentNode != null) {
- nextInstrumentNode.enter(node, vFrame);
- }
- }
-
- private void checkResultType(Object result) {
- if (requiredResultType == null) {
- return;
- }
- if (result == null) {
- throw new RuntimeException("Instrument result null: " + requiredResultType.getSimpleName() + " is required");
- }
- if (!(requiredResultType.isAssignableFrom(result.getClass()))) {
- throw new RuntimeException("Instrument result " + result.toString() + " not assignable to " + requiredResultType.getSimpleName());
- }
- }
-
- public void returnVoid(Node node, VirtualFrame vFrame) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnVoid(node, vFrame);
- }
- }
-
- public void returnValue(Node node, VirtualFrame vFrame, Object result) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnValue(node, vFrame, result);
- }
- }
-
- public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnExceptional(node, vFrame, exception);
- }
- }
-
- public String instrumentationInfo() {
- final String info = getInstrumentInfo();
- return info != null ? info : rootFactory.getClass().getSimpleName();
- }
- }
- }
-
- public interface TruffleOptListener {
- void notifyIsCompiled(boolean isCompiled);
- }
-
- private static final class TruffleOptInstrument extends Instrument {
-
- private final TruffleOptListener toolOptListener;
-
- private TruffleOptInstrument(TruffleOptListener listener, String instrumentInfo) {
- super(instrumentInfo);
- this.toolOptListener = listener;
- }
-
- @Override
- AbstractInstrumentNode addToChain(AbstractInstrumentNode nextNode) {
- return new TruffleOptInstrumentNode(nextNode);
- }
-
- @Override
- AbstractInstrumentNode removeFromChain(AbstractInstrumentNode instrumentNode) {
- boolean found = false;
- if (instrumentNode != null) {
- if (instrumentNode.getInstrument() == this) {
- // Found the match at the head of the chain
- return instrumentNode.nextInstrumentNode;
- }
- // Match not at the head of the chain; remove it.
- found = instrumentNode.removeFromChain(TruffleOptInstrument.this);
- }
- if (!found) {
- throw new IllegalStateException("Couldn't find instrument node to remove: " + this);
- }
- return instrumentNode;
- }
-
- @NodeInfo(cost = NodeCost.NONE)
- private final class TruffleOptInstrumentNode extends AbstractInstrumentNode {
-
- private boolean isCompiled;
-
- private TruffleOptInstrumentNode(AbstractInstrumentNode nextNode) {
- super(nextNode);
- this.isCompiled = CompilerDirectives.inCompiledCode();
- }
-
- public void enter(Node node, VirtualFrame vFrame) {
- if (this.isCompiled != CompilerDirectives.inCompiledCode()) {
- this.isCompiled = CompilerDirectives.inCompiledCode();
- TruffleOptInstrument.this.toolOptListener.notifyIsCompiled(this.isCompiled);
- }
- if (nextInstrumentNode != null) {
- nextInstrumentNode.enter(node, vFrame);
- }
- }
-
- public void returnVoid(Node node, VirtualFrame vFrame) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnVoid(node, vFrame);
- }
- }
-
- public void returnValue(Node node, VirtualFrame vFrame, Object result) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnValue(node, vFrame, result);
- }
- }
-
- public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
- if (nextInstrumentNode != null) {
- nextInstrumentNode.returnExceptional(node, vFrame, exception);
- }
- }
-
- public String instrumentationInfo() {
- final String info = getInstrumentInfo();
- return info != null ? info : toolOptListener.getClass().getSimpleName();
- }
- }
- }
-
- @NodeInfo(cost = NodeCost.NONE)
- abstract class AbstractInstrumentNode extends Node implements TruffleEvents, InstrumentationNode {
-
- @Child protected AbstractInstrumentNode nextInstrumentNode;
-
- protected AbstractInstrumentNode(AbstractInstrumentNode nextNode) {
- this.nextInstrumentNode = nextNode;
- }
-
- @Override
- public boolean isInstrumentable() {
- return false;
- }
-
- /**
- * Gets the instrument that created this node.
- */
- private Instrument getInstrument() {
- return Instrument.this;
- }
-
- /**
- * Removes the node from this chain that was added by a particular instrument, assuming that
- * the head of the chain is not the one to be replaced. This is awkward, but is required
- * because {@link Node#replace(Node)} won't take a {@code null} argument. This doesn't work
- * for the tail of the list, which would be replacing itself with null. So the replacement
- * must be directed the parent of the node being removed.
- */
- private boolean removeFromChain(Instrument instrument) {
- assert getInstrument() != instrument;
- if (nextInstrumentNode == null) {
- return false;
- }
- if (nextInstrumentNode.getInstrument() == instrument) {
- // Next is the one to remove
- if (nextInstrumentNode.nextInstrumentNode == null) {
- // Next is at the tail; just forget
- nextInstrumentNode = null;
- } else {
- // Replace next with its successor
- nextInstrumentNode.replace(nextInstrumentNode.nextInstrumentNode);
- }
- return true;
- }
- return nextInstrumentNode.removeFromChain(instrument);
- }
-
- protected String getInstrumentInfo() {
- return Instrument.this.instrumentInfo;
- }
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-public class InstrumentationException extends Exception {
-
- public InstrumentationException(RuntimeException ex) {
- super(ex);
- }
-
- private static final long serialVersionUID = 447857066220935502L;
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationNode.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationNode.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * A marker interface for Truffle {@linkplain Node nodes} that internally implement the
- * Instrumentation Framework. Such nodes should not be part of any Guest Language execution
- * semantics, and should in general not be visible to ordinary Instrumentation clients.
- */
-public interface InstrumentationNode {
-
- /**
- * A short description of the particular role played by the node, intended to support debugging.
- */
- String instrumentationInfo();
-
- /**
- * Events that propagate through the {@linkplain InstrumentationNode implementation nodes} of
- * the Instrumentation Framework, not visible in this form to Instrumentation clients.
- */
- interface TruffleEvents {
-
- /**
- * An AST node's execute method is about to be called.
- */
- void enter(Node node, VirtualFrame vFrame);
-
- /**
- * An AST Node's {@code void}-valued execute method has just returned.
- */
- void returnVoid(Node node, VirtualFrame vFrame);
-
- /**
- * An AST Node's execute method has just returned a value (boxed if primitive).
- */
- void returnValue(Node node, VirtualFrame vFrame, Object result);
-
- /**
- * An AST Node's execute method has just thrown an exception.
- */
- void returnExceptional(Node node, VirtualFrame vFrame, Exception exception);
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationTool.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/InstrumentationTool.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,185 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-/**
- * {@linkplain Instrument Instrumentation}-based tools that gather data during Guest Language
- * program execution.
- *
- * Tools share a common life cycle:
- *
- * Tool-specific methods that access data collected by the tool should:
- *
- * Client-oriented documentation for the use of Probes is available online at https://wiki.openjdk.java.net/display/Graal/Finding+Probes
- *
- *
- *
- * Language and tool implementations should ensure that clients of tools never see this exception.
- */
-public class ProbeException extends RuntimeException {
- static final long serialVersionUID = 1L;
- private final ProbeFailure failure;
-
- public ProbeException(Reason reason, Node parent, Node child, Object wrapper) {
- this.failure = new ProbeFailure(reason, parent, child, wrapper);
- }
-
- public ProbeFailure getFailure() {
- return failure;
- }
-
- @Override
- public String toString() {
- return failure.getMessage();
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeFailure.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Description of a failed attempt to instrument an AST node.
- */
-public final class ProbeFailure {
-
- public enum Reason {
-
- /**
- * Node to be probed has no parent.
- */
- NO_PARENT("Node to be probed has no parent"),
-
- /**
- * The node to be probed is a wrapper.
- */
- WRAPPER_NODE("The node to be probed is a wrapper"),
-
- /**
- * The node to be probed returned {@link Node#isInstrumentable()}{@code == false}.
- */
- NOT_INSTRUMENTABLE("The node to be project is \"not instrumentable\""),
-
- /**
- * No wrapper could be created that is also a {@link Node}.
- */
- NO_WRAPPER("No wrapper could be created"),
-
- /**
- * Wrapper not assignable to the parent's child field.
- */
- WRAPPER_TYPE("Wrapper not assignable to parent's child field");
-
- final String message;
-
- private Reason(String message) {
- this.message = message;
- }
-
- public String getMessage() {
- return message;
- }
- }
-
- private final Reason reason;
- private final Node parent;
- private final Node child;
- private final Object wrapper;
-
- /**
- * Description of an internal failure of {@link Node#probe()}.
- *
- * @param reason what caused the failure
- * @param parent the parent, if known, of the child being probed
- * @param child this child being probed
- * @param wrapper the {@link WrapperNode} created to implement the probe
- */
- public ProbeFailure(Reason reason, Node parent, Node child, Object wrapper) {
- this.reason = reason;
- this.parent = parent;
- this.child = child;
- this.wrapper = wrapper;
- }
-
- /**
- * @return a short explanation of the failure
- */
- public Reason getReason() {
- return reason;
- }
-
- /**
- * @return the parent, if any, of the node being probed
- */
- public Node getParent() {
- return parent;
- }
-
- /**
- * @return the node being probed
- */
- public Node getChild() {
- return child;
- }
-
- /**
- * @return the {@link WrapperNode} created for the probe attempt
- */
- public Object getWrapper() {
- return wrapper;
- }
-
- public String getMessage() {
- final StringBuilder sb = new StringBuilder(reason.message + ": ");
- if (parent != null) {
- sb.append("parent=" + parent.getClass().getSimpleName() + " ");
- if (child != null) {
- sb.append("child=" + child.getClass().getSimpleName() + " ");
- final NodeFieldAccessor field = NodeUtil.findChildField(parent, child);
- if (field != null) {
- sb.append("field=" + field.getName() + " ");
- }
- }
- }
- if (wrapper != null) {
- sb.append("wrapper=" + wrapper.getClass().getSimpleName());
- }
- return sb.toString();
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeListener.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeListener.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-
-/**
- * An observer of events related to {@link Probe}s: creating and tagging.
- */
-public interface ProbeListener {
-
- /**
- * Notifies that all registered {@link ASTProber}s are about to be applied to a newly
- * constructed AST.
- *
- * @param source source code from which the AST was constructed
- */
- void startASTProbing(Source source);
-
- /**
- * Notifies that a {@link Probe} has been newly attached to an AST via {@link Node#probe()}.
- *
- * There can be no more than one {@link Probe} at a node; this notification will only be
- * delivered the first time {@linkplain Node#probe() probe()} is called at a particular AST
- * node. There will also be no notification when the AST to which the Probe is attached is
- * cloned.
- */
- void newProbeInserted(Probe probe);
-
- /**
- * Notifies that a {@link SyntaxTag} has been newly added to the set of tags associated with a
- * {@link Probe} via {@link Probe#tagAs(SyntaxTag, Object)}.
- *
- * The {@linkplain SyntaxTag tags} at a {@link Probe} are a set; this notification will
- * only be delivered the first time a particular {@linkplain SyntaxTag tag} is added at a
- * {@link Probe}.
- *
- * An optional value supplied with {@linkplain Probe#tagAs(SyntaxTag, Object) tagAs(SyntaxTag,
- * Object)} is reported to all listeners, but not stored. As a consequence, the optional value
- * will have no effect at all if the tag had already been added.
- *
- * @param probe where a tag has been added
- * @param tag the tag that has been newly added (subsequent additions of the tag are
- * unreported).
- * @param tagValue an optional value associated with the tag for the purposes of reporting.
- */
- void probeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue);
-
- /**
- * Notifies that the application of all registered {@link ASTProber}s to a newly constructed AST
- * has completed.
- *
- * @param source source code from which the AST was constructed
- */
- void endASTProbing(Source source);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ProbeNode.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,236 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.instrument;
-
-import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
-import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.instrument.Instrument.AbstractInstrumentNode;
-import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-
-/**
- * Implementation class & interface for enabling the attachment of {@linkplain Probe Probes} to
- * Truffle ASTs.
- *
- * A {@link ProbeNode} is the head of a chain of nodes acting on behalf of {@linkplain Instrument
- * instruments}. It is attached to an AST as a child of a guest-language-specific
- * {@link WrapperNode} node.
- *
- * When Truffle clones an AST, the chain, including all attached {@linkplain Instrument instruments}
- * will be cloned along with the {@link WrapperNode} to which it is attached. An instance of
- * {@link Probe} represents abstractly the instrumentation at a particular location in a Guest
- * Language AST, tracks the clones of the chain, and keeps the instrumentation attached to the
- * clones consistent.
- */
-@NodeInfo(cost = NodeCost.NONE)
-public final class ProbeNode extends Node implements TruffleEvents, InstrumentationNode {
-
- /**
- * A node that can be inserted into a Truffle AST, and which enables {@linkplain Instrument
- * instrumentation} at a particular Guest Language (GL) node. Implementations must extend
- * {@link Node} and should override {@link Node#isInstrumentable()} to return {@code false}.
- *
- * The implementation must be GL-specific. A wrapper decorates a GL AST node (the
- * wrapper's child) by acting as a transparent proxy with respect to the GL's
- * execution semantics.
- *
- * Instrumentation at the wrapped node is implemented by an instance of {@link ProbeNode}
- * attached as a second child of the {@link WrapperNode}.
- *
- * A wrapper is obliged to notify its attached {@link ProbeNode} when execution events occur at
- * the wrapped AST node during program execution.
- *
- * When a GL AST is cloned, the {@link WrapperNode}, its {@link ProbeNode} and any
- * {@linkplain Instrument instrumentation} are also cloned; they are in effect part of the GL
- * AST. An instance of {@link Probe} represents abstractly the instrumentation at a particular
- * location in a GL AST; it tracks all the copies of the Wrapper and attached instrumentation,
- * and acts as a single point of access for tools.
- *
- * This interface is not intended to be visible as part of the API for tools (instrumentation
- * clients).
- *
- * Implementation guidelines:
- *
- *
- * @see Instrument
- */
- public interface WrapperNode extends InstrumentationNode {
-
- /**
- * Gets the node being "wrapped", i.e. the AST node for which
- * {@linkplain InstrumentationNode.TruffleEvents execution events} will be reported through
- * the Instrumentation Framework.
- */
- Node getChild();
-
- /**
- * Gets the {@link Probe} responsible for installing this wrapper.
- */
- Probe getProbe();
-
- /**
- * Implementation support for completing a newly created wrapper node.
- */
- void insertProbe(ProbeNode probeNode);
- }
-
- /**
- * Create a new {@link Probe} associated with, and attached to, a Guest Language specific
- * instance of {@link WrapperNode}.
- */
- public static Probe insertProbe(WrapperNode wrapper) {
- final SourceSection sourceSection = wrapper.getChild().getSourceSection();
- final ProbeNode probeNode = new ProbeNode(); // private constructor
- probeNode.probe = new Probe(probeNode, sourceSection); // package private access
- wrapper.insertProbe(probeNode);
- return probeNode.probe;
- }
-
- // Never changed once set.
- @CompilationFinal Probe probe = null;
- /**
- * First {@link AbstractInstrumentNode} node in chain; {@code null} of no instruments in chain.
- */
- @Child protected AbstractInstrumentNode firstInstrumentNode;
-
- @Override
- public boolean isInstrumentable() {
- return false;
- }
-
- @Override
- public Node copy() {
- Node node = super.copy();
- probe.registerProbeNodeClone((ProbeNode) node);
- return node;
- }
-
- /**
- * @return the {@link Probe} permanently associated with this {@link ProbeNode}.
- */
- public Probe getProbe() {
- return probe;
- }
-
- public void enter(Node node, VirtualFrame vFrame) {
- this.probe.checkProbeUnchanged();
- final SyntaxTagTrap beforeTagTrap = probe.getBeforeTrap();
- if (beforeTagTrap != null) {
- beforeTagTrap.tagTrappedAt(((WrapperNode) this.getParent()).getChild(), vFrame.materialize());
- }
- if (firstInstrumentNode != null) {
- firstInstrumentNode.enter(node, vFrame);
- }
- }
-
- public void returnVoid(Node node, VirtualFrame vFrame) {
- this.probe.checkProbeUnchanged();
- if (firstInstrumentNode != null) {
- firstInstrumentNode.returnVoid(node, vFrame);
- }
- final SyntaxTagTrap afterTagTrap = probe.getAfterTrap();
- if (afterTagTrap != null) {
- afterTagTrap.tagTrappedAt(((WrapperNode) this.getParent()).getChild(), vFrame.materialize());
- }
- }
-
- public void returnValue(Node node, VirtualFrame vFrame, Object result) {
- this.probe.checkProbeUnchanged();
- if (firstInstrumentNode != null) {
- firstInstrumentNode.returnValue(node, vFrame, result);
- }
- final SyntaxTagTrap afterTagTrap = probe.getAfterTrap();
- if (afterTagTrap != null) {
- afterTagTrap.tagTrappedAt(((WrapperNode) this.getParent()).getChild(), vFrame.materialize());
- }
- }
-
- public void returnExceptional(Node node, VirtualFrame vFrame, Exception exception) {
- this.probe.checkProbeUnchanged();
- if (firstInstrumentNode != null) {
- firstInstrumentNode.returnExceptional(node, vFrame, exception);
- }
- final SyntaxTagTrap afterTagTrap = probe.getAfterTrap();
- if (afterTagTrap != null) {
- afterTagTrap.tagTrappedAt(((WrapperNode) this.getParent()).getChild(), vFrame.materialize());
- }
- }
-
- public String instrumentationInfo() {
- return "Standard probe";
- }
-
- /**
- * Gets the guest-language AST node to which this Probe is attached.
- */
- Node getProbedNode() {
- return ((WrapperNode) this.getParent()).getChild();
- }
-
- /**
- * Adds an {@link AbstractInstrumentNode} to this chain.
- */
- @TruffleBoundary
- void addInstrument(Instrument instrument) {
- assert instrument.getProbe() == probe;
- // The existing chain of nodes may be empty
- // Attach the modified chain.
- firstInstrumentNode = insert(instrument.addToChain(firstInstrumentNode));
- }
-
- /**
- * Removes an instrument from this chain of instruments.
- *
- * @throws RuntimeException if no matching instrument is found,
- */
- @TruffleBoundary
- void removeInstrument(Instrument instrument) {
- assert instrument.getProbe() == probe;
- final AbstractInstrumentNode modifiedChain = instrument.removeFromChain(firstInstrumentNode);
- if (modifiedChain == null) {
- firstInstrumentNode = null;
- } else {
- firstInstrumentNode = insert(modifiedChain);
- }
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/QuitException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/QuitException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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.instrument;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Controls breaking out of all executions and ending Truffle execution.
- */
-public final class QuitException extends ControlFlowException {
-
- private static final long serialVersionUID = -4301115629772778413L;
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SimpleInstrumentListener.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SimpleInstrumentListener.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.source.*;
-
-/**
- * A receiver of Truffle execution events that can act on behalf of an external client.
- *
- * The {@link Probe} instance provides access to the {@link SourceSection} associated with the
- * event, as well as any {@link SyntaxTag}s that have been applied at that program's location.
- *
- * This is the simplest kind of listener, suitable for clients that need no other information about
- * the program's execution state at the time of the event. Clients that require access to the AST
- * execution state should use {@link StandardInstrumentListener}.
- *
- * Clients are free, of course, to record additional information in the listener implementation that
- * carries additional information about the context and reason for the particular {@link Instrument}
- * that is to be created from the listener.
- */
-public interface SimpleInstrumentListener {
-
- /**
- * Receive notification that a program location is about to be executed.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void enter(Probe probe);
-
- /**
- * Receive notification that a program location's {@code void}-valued execution has just
- * completed.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnVoid(Probe probe);
-
- /**
- * Receive notification that a program location's execution has just completed and returned a
- * value (boxed if primitive).
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnValue(Probe probe, Object result);
-
- /**
- * Receive notification that a program location's execution has just thrown an exception.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnExceptional(Probe probe, Exception exception);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/StandardInstrumentListener.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/StandardInstrumentListener.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-
-/**
- * A receiver of Truffle execution events that can act on behalf of an external client.
- *
- * The {@link Probe} argument provides access to the {@link SourceSection} associated with the
- * event, as well as any {@link SyntaxTag}s that have been applied at that AST node.
- *
- * This listener is designed for clients that also require access to the AST execution state at the
- * time of the event. Clients that do not require access to the AST execution state should use the
- * {@link SimpleInstrumentListener}.
- *
- * Clients are free, of course, to record additional information in the listener implementation that
- * carries additional information about the context and reason for the particular {@link Instrument}
- * that is to be created from the listener.
- */
-public interface StandardInstrumentListener {
-
- /**
- * Receive notification that an AST node's execute method is about to be called.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void enter(Probe probe, Node node, VirtualFrame vFrame);
-
- /**
- * Receive notification that an AST Node's {@code void}-valued execute method has just returned.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnVoid(Probe probe, Node node, VirtualFrame vFrame);
-
- /**
- * Receive notification that an AST Node's execute method has just returned a value (boxed if
- * primitive).
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnValue(Probe probe, Node node, VirtualFrame vFrame, Object result);
-
- /**
- * Receive notification that an AST Node's execute method has just thrown an exception.
- *
- * Synchronous: Truffle execution waits until the call returns.
- */
- void returnExceptional(Probe probe, Node node, VirtualFrame vFrame, Exception exception);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/StandardSyntaxTag.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/StandardSyntaxTag.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument;
-
-/**
- * A somewhat language-agnostic set of user-sensible syntactic categories, suitable for conventional
- * imperative languages, and is being developed incrementally.
- *
- * The need for alternative sets of tags is likely to arise, perhaps for other families of languages
- * (for example for mostly expression-oriented languages) or even for specific languages.
- *
- * @see Probe
- */
-public enum StandardSyntaxTag implements SyntaxTag {
-
- /**
- * Marker for a variable assignment.
- */
- ASSIGNMENT("assignment", "a variable assignment"),
-
- /**
- * Marker for a call site.
- */
- CALL("call", "a method/procedure call site"),
-
- /**
- * Marker for a location where a guest language exception is about to be thrown.
- */
- THROW("throw", "creator of an exception"),
-
- /**
- * Marker for a location where ordinary "stepping" should halt.
- */
- STATEMENT("statement", "basic unit of the language, suitable for \"stepping\" in a debugger"),
-
- /**
- * Marker for the start of the body of a method.
- */
- START_METHOD("start-method", "start of the body of a method"),
-
- /**
- * Marker for the start of the body of a loop.
- */
- START_LOOP("start-loop", "start of the body of a loop"),
-
- /**
- * Marker that is attached to some arbitrary locations that appear often-enough in an AST so
- * that a location with this tag is regularly executed. Could be the start of method and loop
- * bodies. May be used to implement some kind of safepoint functionality.
- */
- PERIODIC("periodic", "arbitrary locations that appear often-enough in an AST so that a location with this tag is regularly executed");
-
- private final String name;
- private final String description;
-
- private StandardSyntaxTag(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SyntaxTag.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SyntaxTag.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument;
-
-/**
- * Program element "tags", presumed to be singletons (best implemented as enums) that define
- * user-visible behavior for debugging and other simple tools. These categories should correspond to
- * program structures, for example "statement" and "assignment", that are meaningful
- * ("human-sensible") to guest language programmers.
- *
- * An untagged Truffle node should be understood as an artifact of the guest language implementation
- * and should not be visible to guest language programmers. Nodes may also have more than one tag,
- * for example a variable assignment that is also a statement. Finally, the assignment of tags to
- * nodes could depending on the use-case of whatever tool is using them.
- *
- * @see Probe
- * @see StandardSyntaxTag
- */
-public interface SyntaxTag {
-
- /**
- * Human-friendly name of guest language program elements belonging to the category, e.g.
- * "statement".
- */
- String name();
-
- /**
- * Criteria and example uses for the tag.
- */
- String getDescription();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SyntaxTagTrap.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/SyntaxTagTrap.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument;
-
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * A trap that can be set to interrupt execution at probed nodes carrying a specific tag.
- *
- * @see Probe
- */
-public abstract class SyntaxTagTrap {
-
- private final SyntaxTag tag;
-
- protected SyntaxTagTrap(SyntaxTag tag) {
- this.tag = tag;
- }
-
- public final SyntaxTag getTag() {
- return tag;
- }
-
- /**
- * Notifies that execution is halted at a node with the specified tag.
- */
- public abstract void tagTrappedAt(Node node, MaterializedFrame frame);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ToolSupportProvider.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/ToolSupportProvider.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2015, 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.instrument;
-
-/**
- * Access to language-specific information and execution services for external tools.
- */
-public interface ToolSupportProvider {
-
- /**
- * Gets visualization services for language-specific information.
- */
- Visualizer getVisualizer();
-
- /**
- * Enables AST probing on all subsequently created ASTs (sources parsed).
- *
- * @param astProber optional AST prober to enable; the default for the language used if
- * {@code null}
- */
- void enableASTProbing(ASTProber astProber);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Visualizer.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Visualizer.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Visualization services for the benefit of instrumentation-based tools, possibly specialized for
- * each guest language and possibly specialized for relevant information from the underlying Truffle
- * implementation.
- *
- * Disclaimer: experimental interface under development.
- */
-public interface Visualizer {
-
- // TODO (mlvdv) "Visualizer" is misleading: rename.
- /**
- * Gets a printer for Truffle ASTs, possibly specialized to be helpful for a specific guest
- * language implementation.
- */
- ASTPrinter getASTPrinter();
-
- /**
- * A short description of a source location in terms of source + line number.
- */
- String displaySourceLocation(Node node);
-
- /**
- * Describes the name of the method containing a node.
- */
- String displayMethodName(Node node);
-
- /**
- * The name of the method.
- */
- String displayCallTargetName(CallTarget callTarget);
-
- /**
- * Converts a value in the guest language to a display string. If
- *
- * @param trim if {@code > 0}, them limit size of String to either the value of trim or the
- * number of characters in the first line, whichever is lower.
- */
- String displayValue(Object value, int trim);
-
- /**
- * Converts a slot identifier in the guest language to a display string.
- */
- String displayIdentifier(FrameSlot slot);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/impl/DefaultASTPrinter.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-/*
- * Copyright (c) 2014, 2015, 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.instrument.impl;
-
-import java.io.*;
-import java.util.*;
-
-import com.oracle.truffle.api.instrument.*;
-import com.oracle.truffle.api.instrument.ProbeNode.WrapperNode;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind;
-import com.oracle.truffle.api.source.*;
-
-/**
- * A language-agnostic for printing out various pieces of a Truffle AST.
- */
-public class DefaultASTPrinter implements ASTPrinter {
-
- public DefaultASTPrinter() {
- }
-
- public void printTree(PrintWriter p, Node node, int maxDepth, Node markNode) {
- printTree(p, node, maxDepth, markNode, 1);
- p.println();
- p.flush();
- }
-
- public String printTreeToString(Node node, int maxDepth, Node markNode) {
- StringWriter out = new StringWriter();
- printTree(new PrintWriter(out), node, maxDepth, markNode);
- return out.toString();
- }
-
- public String printTreeToString(Node node, int maxDepth) {
- return printTreeToString(node, maxDepth, null);
- }
-
- public String printNodeWithInstrumentation(Node node) {
- if (node == null) {
- return "null";
- }
- final StringBuilder sb = new StringBuilder();
- sb.append(nodeName(node));
- sb.append("(");
- if (node instanceof InstrumentationNode) {
- sb.append(instrumentInfo((InstrumentationNode) node));
- }
- sb.append(sourceInfo(node));
- sb.append(NodeUtil.printSyntaxTags(node));
- sb.append(")");
- final Node parent = node.getParent();
- if (parent instanceof WrapperNode) {
- final WrapperNode wrapper = (WrapperNode) parent;
- sb.append(" Probed");
- sb.append(NodeUtil.printSyntaxTags(wrapper));
- }
- return sb.toString();
- }
-
- protected void printTree(PrintWriter p, Node node, int maxDepth, Node markNode, int level) {
- if (node == null) {
- p.print("null");
- return;
- }
-
- p.print(nodeName(node));
-
- p.print("(");
-
- if (node instanceof InstrumentationNode) {
- p.print(instrumentInfo((InstrumentationNode) node));
- }
-
- p.print(sourceInfo(node));
-
- p.print(NodeUtil.printSyntaxTags(node));
-
- ArrayList
- * Note: instrumentation requires a appropriate {@link WrapperNode}, which must be
- * provided by {@link #createWrapperNode()}.
- *
- * @see Instrument
- */
- public boolean isInstrumentable() {
- return false;
- }
-
- /**
- * For any node that {@link #isInstrumentable()}, this method must return a {@link Node} that:
- *
- * If this is not done, then the AST will not be subject to debugging or any other
- * instrumentation-supported tooling.
- *
- * Implementations should ensure that instrumentation is never applied more than once to an AST,
- * as this is not guaranteed to be error-free.
- *
- * @see Probe#registerASTProber(com.oracle.truffle.api.instrument.ASTProber)
- */
- public void applyInstrumentation() {
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/SlowPathException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/SlowPathException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * 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. 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.nodes;
-
-import com.oracle.truffle.api.*;
-
-/**
- * An exception thrown to enter a slow path. The Truffle optimizer has special knowledge of this
- * exception class and will never compile a catch block that catches this exception type.
- */
-public class SlowPathException extends Exception {
-
- private static final long serialVersionUID = 3676602078425211386L;
-
- /**
- * Creates an exception thrown to enter a slow path.
- */
- public SlowPathException() {
- CompilerDirectives.transferToInterpreter();
- }
-
- /**
- * Creates an exception thrown to enter a slow path.
- */
- public SlowPathException(String message, Throwable cause) {
- super(message, cause);
- CompilerDirectives.transferToInterpreter();
- }
-
- /**
- * Creates an exception thrown to enter a slow path.
- */
- public SlowPathException(String message) {
- super(message);
- CompilerDirectives.transferToInterpreter();
- }
-
- /**
- * Creates an exception thrown to enter a slow path.
- */
- public SlowPathException(Throwable cause) {
- super(cause);
- CompilerDirectives.transferToInterpreter();
- }
-
- /**
- * For performance reasons, this exception does not record any stack trace information.
- */
- @SuppressWarnings("sync-override")
- @Override
- public Throwable fillInStackTrace() {
- return null;
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnexpectedResultException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/UnexpectedResultException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/*
- * 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. 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.nodes;
-
-import com.oracle.truffle.api.*;
-
-/**
- * An exception that should be thrown if the return value cannot be represented as a value of the
- * return type. The Truffle optimizer has special knowledge of this exception class and will never
- * compile a catch block that catches this exception type.
- */
-public final class UnexpectedResultException extends SlowPathException {
-
- private static final long serialVersionUID = 3676602078425211386L;
- private final Object result;
-
- /**
- * Creates the exception with the alternative result that cannot be represented as a value of
- * the return type.
- *
- * @param result the alternative result
- */
- public UnexpectedResultException(Object result) {
- CompilerDirectives.transferToInterpreter();
- this.result = result;
- }
-
- /**
- * @return the unexpected result
- */
- public Object getResult() {
- return result;
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,375 +0,0 @@
-/*
- * 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. 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.nodes.serial;
-
-import java.lang.reflect.*;
-import java.util.*;
-
-import sun.misc.*;
-
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind;
-import com.oracle.truffle.api.source.*;
-
-/**
- * Experimental API. May change without notice.
- */
-public final class PostOrderDeserializer {
-
- private static final Unsafe unsafe = loadUnsafe();
-
- private final SerializerConstantPool cp;
-
- private final HierarchicalStack stack = new HierarchicalStack();
-
- /**
- * Constructs a new serializer using a custom {@link SerializerConstantPool} implementation. For
- * the {@link SerializerConstantPool} implementation at least the following methods must be
- * implemented:
- *
- * See {@link Source#fromBytes}.
- */
-public interface BytesDecoder {
-
- String decode(byte[] bytes, int byteIndex, int length);
-
- void decodeLines(byte[] bytes, int byteIndex, int length, LineMarker lineMarker);
-
- public interface LineMarker {
-
- void markLine(int index);
-
- }
-
- public static class UTF8BytesDecoder implements BytesDecoder {
-
- @Override
- public String decode(byte[] bytes, int byteIndex, int length) {
- return new String(Arrays.copyOfRange(bytes, byteIndex, byteIndex + length), StandardCharsets.UTF_8);
- }
-
- @Override
- public void decodeLines(byte[] bytes, int byteIndex, int length, LineMarker lineMarker) {
- for (int n = byteIndex; n < byteIndex + length; n++) {
- if (bytes[n] == '\n') {
- lineMarker.markLine(n + 1);
- }
- }
- }
-
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/LineLocation.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/LineLocation.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.source;
-
-import java.util.*;
-
-/**
- * A specification for a location in guest language source, expressed as a line number in a specific
- * instance of {@link Source}, suitable for hash table keys with equality defined in terms of
- * content.
- */
-public interface LineLocation {
-
- Source getSource();
-
- /**
- * Gets the 1-based number of a line in the source.
- */
- int getLineNumber();
-
- String getShortDescription();
-
- /**
- * Default comparator by (1) textual path name, (2) line number.
- */
- Comparator
- *
- *
- *
- *
- *
- *
- * File cache:
- *
- *
- * @see SourceTag
- * @see SourceListener
- */
-public abstract class Source {
-
- // TODO (mlvdv) consider canonicalizing and reusing SourceSection instances
- // TOOD (mlvdv) connect SourceSections into a spatial tree for fast geometric lookup
-
- public enum Tags implements SourceTag {
-
- /**
- * From bytes.
- */
- FROM_BYTES("bytes", "read from bytes"),
-
- /**
- * Read from a file.
- */
- FROM_FILE("file", "read from a file"),
-
- /**
- * From literal text.
- */
- FROM_LITERAL("literal", "from literal text"),
-
- /**
- * From a {@linkplain java.io.Reader Reader}.
- */
- FROM_READER("reader", "read from a Java Reader"),
-
- /**
- * Read from a URL.
- */
- FROM_URL("URL", "read from a URL");
-
- private final String name;
- private final String description;
-
- private Tags(String name, String description) {
- this.name = name;
- this.description = description;
- }
-
- public String getName() {
- return name;
- }
-
- public String getDescription() {
- return description;
- }
-
- }
-
- /**
- * All Sources that have been created.
- */
- private static final List
- * This method performs no checks on the validity of the arguments.
- *
- * The resulting representation defines hash/equality around equivalent location, presuming that
- * {@link Source} representations are canonical.
- *
- * @param identifier terse description of the region
- * @param startLine 1-based line number of the first character in the section
- * @param startColumn 1-based column number of the first character in the section
- * @param charIndex the 0-based index of the first character of the section
- * @param length the number of characters in the section
- * @return newly created object representing the specified region
- */
- public final SourceSection createSection(String identifier, int startLine, int startColumn, int charIndex, int length) {
- return new DefaultSourceSection(this, identifier, startLine, startColumn, charIndex, length);
- }
-
- /**
- * Creates a representation of a contiguous region of text in the source. Computes the
- * {@code charIndex} value by building a {@linkplain TextMap map} of lines in the source.
- *
- * Checks the position arguments for consistency with the source.
- *
- * The resulting representation defines hash/equality around equivalent location, presuming that
- * {@link Source} representations are canonical.
- *
- * @param identifier terse description of the region
- * @param startLine 1-based line number of the first character in the section
- * @param startColumn 1-based column number of the first character in the section
- * @param length the number of characters in the section
- * @return newly created object representing the specified region
- * @throws IllegalArgumentException if arguments are outside the text of the source
- * @throws IllegalStateException if the source is one of the "null" instances
- */
- public final SourceSection createSection(String identifier, int startLine, int startColumn, int length) {
- final int lineStartOffset = getTextMap().lineStartOffset(startLine);
- if (startColumn > getTextMap().lineLength(startLine)) {
- throw new IllegalArgumentException("column out of range");
- }
- final int startOffset = lineStartOffset + startColumn - 1;
- return new DefaultSourceSection(this, identifier, startLine, startColumn, startOffset, length);
- }
-
- /**
- * Creates a representation of a contiguous region of text in the source. Computes the
- * {@code (startLine, startColumn)} values by building a {@linkplain TextMap map} of lines in
- * the source.
- *
- * Checks the position arguments for consistency with the source.
- *
- * The resulting representation defines hash/equality around equivalent location, presuming that
- * {@link Source} representations are canonical.
- *
- *
- * @param identifier terse description of the region
- * @param charIndex 0-based position of the first character in the section
- * @param length the number of characters in the section
- * @return newly created object representing the specified region
- * @throws IllegalArgumentException if either of the arguments are outside the text of the
- * source
- * @throws IllegalStateException if the source is one of the "null" instances
- */
- public final SourceSection createSection(String identifier, int charIndex, int length) throws IllegalArgumentException {
- checkRange(charIndex, length);
- final int startLine = getLineNumber(charIndex);
- final int startColumn = charIndex - getLineStartOffset(startLine) + 1;
- return new DefaultSourceSection(this, identifier, startLine, startColumn, charIndex, length);
- }
-
- protected void checkRange(int charIndex, int length) {
- if (!(charIndex >= 0 && length >= 0 && charIndex + length <= getCode().length())) {
- throw new IllegalArgumentException("text positions out of range");
- }
- }
-
- /**
- * Creates a representation of a line of text in the source identified only by line number, from
- * which the character information will be computed.
- *
- * @param identifier terse description of the line
- * @param lineNumber 1-based line number of the first character in the section
- * @return newly created object representing the specified line
- * @throws IllegalArgumentException if the line does not exist the source
- * @throws IllegalStateException if the source is one of the "null" instances
- */
- public final SourceSection createSection(String identifier, int lineNumber) {
- final int charIndex = getTextMap().lineStartOffset(lineNumber);
- final int length = getTextMap().lineLength(lineNumber);
- return createSection(identifier, charIndex, length);
- }
-
- /**
- * Creates a representation of a line number in this source, suitable for use as a hash table
- * key with equality defined to mean equivalent location.
- *
- * @param lineNumber a 1-based line number in this source
- * @return a representation of a line in this source
- */
- public final LineLocation createLineLocation(int lineNumber) {
- return new LineLocationImpl(this, lineNumber);
- }
-
- /**
- * An object suitable for using as a key into a hashtable that defines equivalence between
- * different source types.
- */
- protected Object getHashKey() {
- return getName();
- }
-
- protected final TextMap getTextMap() {
- if (textMap == null) {
- textMap = createTextMap();
- }
- return textMap;
- }
-
- protected final void clearTextMap() {
- textMap = null;
- }
-
- protected TextMap createTextMap() {
- final String code = getCode();
- if (code == null) {
- throw new RuntimeException("can't read file " + getName());
- }
- return TextMap.fromString(code);
- }
-
- private static final class LiteralSource extends Source {
-
- private final String description;
- private final String code;
-
- public LiteralSource(String description, String code) {
- this.description = description;
- this.code = code;
- }
-
- @Override
- public String getName() {
- return description;
- }
-
- @Override
- public String getShortName() {
- return description;
- }
-
- @Override
- public String getCode() {
- return code;
- }
-
- @Override
- public String getPath() {
- return description;
- }
-
- @Override
- public URL getURL() {
- return null;
- }
-
- @Override
- public Reader getReader() {
- return new StringReader(code);
- }
-
- @Override
- protected void reset() {
- }
-
- @Override
- public int hashCode() {
- return description.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (obj instanceof LiteralSource) {
- LiteralSource other = (LiteralSource) obj;
- return description.equals(other.description);
- }
- return false;
- }
- }
-
- private static final class AppendableLiteralSource extends Source {
- private String description;
- final List
- * The starting location of the section is specified using two different coordinate:
- *
- *
- * @param source object representing the complete source program that contains this section
- * @param identifier an identifier used when printing the section
- * @param startLine the 1-based number of the start line of the section
- * @param startColumn the 1-based number of the start column of the section
- * @param charIndex the 0-based index of the first character of the section
- * @param charLength the length of the section in number of characters
- */
- public DefaultSourceSection(Source source, String identifier, int startLine, int startColumn, int charIndex, int charLength) {
- this.source = source;
- this.identifier = identifier;
- this.startLine = startLine;
- this.startColumn = startColumn;
- this.charIndex = charIndex;
- this.charLength = charLength;
- }
-
- @Override
- public Source getSource() {
- return source;
- }
-
- @Override
- public int getStartLine() {
- return startLine;
- }
-
- @Override
- public LineLocation getLineLocation() {
- return source.createLineLocation(startLine);
- }
-
- @Override
- public int getStartColumn() {
- return startColumn;
- }
-
- public int getEndLine() {
- return source.getLineNumber(charIndex + charLength - 1);
- }
-
- public int getEndColumn() {
- return source.getColumnNumber(charIndex + charLength - 1);
- }
-
- @Override
- public int getCharIndex() {
- return charIndex;
- }
-
- @Override
- public int getCharLength() {
- return charLength;
- }
-
- @Override
- public int getCharEndIndex() {
- return charIndex + charLength;
- }
-
- @Override
- public String getIdentifier() {
- return identifier;
- }
-
- @Override
- public String getCode() {
- return getSource().getCode(charIndex, charLength);
- }
-
- @Override
- public String getShortDescription() {
- return String.format("%s:%d", source.getShortName(), startLine);
- }
-
- @Override
- public String toString() {
- return getCode();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + charIndex;
- result = prime * result + charLength;
- result = prime * result + ((identifier == null) ? 0 : identifier.hashCode());
- result = prime * result + ((source == null) ? 0 : source.hashCode());
- result = prime * result + startColumn;
- result = prime * result + startLine;
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof DefaultSourceSection)) {
- return false;
- }
- DefaultSourceSection other = (DefaultSourceSection) obj;
- if (charIndex != other.charIndex) {
- return false;
- }
- if (charLength != other.charLength) {
- return false;
- }
- if (identifier == null) {
- if (other.identifier != null) {
- return false;
- }
- } else if (!identifier.equals(other.identifier)) {
- return false;
- }
- if (source == null) {
- if (other.source != null) {
- return false;
- }
- } else if (!source.equals(other.source)) {
- return false;
- }
- if (startColumn != other.startColumn) {
- return false;
- }
- if (startLine != other.startLine) {
- return false;
- }
- return true;
- }
- }
-
- private static final class LineLocationImpl implements LineLocation {
- private final Source source;
- private final int line;
-
- public LineLocationImpl(Source source, int line) {
- assert source != null;
- this.source = source;
- this.line = line;
- }
-
- @Override
- public Source getSource() {
- return source;
- }
-
- @Override
- public int getLineNumber() {
- return line;
- }
-
- @Override
- public String getShortDescription() {
- return source.getShortName() + ":" + line;
- }
-
- @Override
- public String toString() {
- return "Line[" + getShortDescription() + "]";
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + line;
- result = prime * result + source.getHashKey().hashCode();
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (!(obj instanceof LineLocationImpl)) {
- return false;
- }
- LineLocationImpl other = (LineLocationImpl) obj;
- if (line != other.line) {
- return false;
- }
- return source.getHashKey().equals(other.source.getHashKey());
- }
-
- }
-
- /**
- * A utility for converting between coordinate systems in a string of text interspersed with
- * newline characters. The coordinate systems are:
- *
- * This utility is based on positions occupied by characters, not text stream positions as in a
- * text editor. The distinction shows up in editors where you can put the cursor just past the
- * last character in a buffer; this is necessary, among other reasons, so that you can put the
- * edit cursor in a new (empty) buffer. For the purposes of this utility, however, there are no
- * character positions in an empty text string and there are no lines in an empty text string.
- *
- * A newline character designates the end of a line and occupies a column position.
- *
- * If the text ends with a character other than a newline, then the characters following the
- * final newline character count as a line, even though not newline-terminated.
- *
- * Limitations:
- *
- * Tabs are not expanded; they occupy 1 column.
- *
- * @throws IllegalArgumentException if the offset is outside the string.
- */
- public int offsetToCol(int offset) throws IllegalArgumentException {
- return 1 + offset - nlOffsets[offsetToLine(offset) - 1];
- }
-
- /**
- * The number of characters in the mapped text.
- */
- public int length() {
- return textLength;
- }
-
- /**
- * The number of lines in the text; if characters appear after the final newline, then they
- * also count as a line, even though not newline-terminated.
- */
- public int lineCount() {
- if (textLength == 0) {
- return 0;
- }
- return finalNL ? nlOffsets.length - 2 : nlOffsets.length - 1;
- }
-
- /**
- * Converts 1-based line number to the 0-based offset of the line's first character; this
- * would be the offset of a newline if the line is empty.
- *
- * @throws IllegalArgumentException if there is no such line in the text.
- */
- public int lineStartOffset(int line) throws IllegalArgumentException {
- if (textLength == 0 || lineOutOfRange(line)) {
- throw new IllegalArgumentException("line out of bounds");
- }
- return nlOffsets[line - 1];
- }
-
- /**
- * Gets the number of characters in a line, identified by 1-based line number;
- * does not include the final newline, if any.
- *
- * @throws IllegalArgumentException if there is no such line in the text.
- */
- public int lineLength(int line) throws IllegalArgumentException {
- if (textLength == 0 || lineOutOfRange(line)) {
- throw new IllegalArgumentException("line out of bounds");
- }
- if (line == nlOffsets.length - 1 && !finalNL) {
- return textLength - nlOffsets[line - 1];
- }
- return (nlOffsets[line] - nlOffsets[line - 1]) - 1;
-
- }
-
- /**
- * Is the line number out of range.
- */
- private boolean lineOutOfRange(int line) {
- return line <= 0 || line >= nlOffsets.length || (line == nlOffsets.length - 1 && finalNL);
- }
-
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceListener.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceListener.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2015, 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.source;
-
-/**
- * An observer of events related to {@link Source}s: creating and tagging.
- */
-public interface SourceListener {
-
- /**
- * Notifies that a new {@link Source} has just been created.
- */
- void sourceCreated(Source source);
-
- /**
- * Notifies that a {@link SourceTag} has been newly added to the set of tags associated with a
- * {@link Source} via {@link Source#tagAs(SourceTag)}.
- *
- * The {@linkplain SourceTag tags} at a {@link Source} are a set; this notification
- * will only be delivered the first time a particular {@linkplain SourceTag tag} is added at a
- * {@link Source}.
- *
- * @param source where a tag has been added
- * @param tag the tag that has been newly added (subsequent additions of the tag are
- * unreported).
- */
- void sourceTaggedAs(Source source, SourceTag tag);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceSection.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,126 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.source;
-
-/**
- * Description of contiguous section of text within a {@link Source} of program code; supports
- * multiple modes of access to the text and its location. A special {@linkplain NullSourceSection
- * null subtype} should be used for code that is not available from source, e.g language builtins.
- *
- * @see Source#createSection(String, int, int, int, int)
- * @see Source#createSection(String, int, int, int)
- * @see Source#createSection(String, int, int)
- * @see Source#createSection(String, int)
- * @see NullSourceSection
- */
-public interface SourceSection {
-
- // TODO support alternate text representations/encodings
-
- /**
- * Representation of the source program that contains this section.
- *
- * @return the source object
- */
- Source getSource();
-
- /**
- * Returns 1-based line number of the first character in this section (inclusive).
- *
- * @return the starting line number
- */
- int getStartLine();
-
- /**
- * Gets a representation of the first line of the section, suitable for a hash key.
- */
- LineLocation getLineLocation();
-
- /**
- * Returns the 1-based column number of the first character in this section (inclusive).
- *
- * @return the starting column number
- */
- int getStartColumn();
-
- /**
- * Returns 1-based line number of the last character in this section (inclusive).
- *
- * @return the starting line number
- */
- int getEndLine();
-
- /**
- * Returns the 1-based column number of the last character in this section (inclusive).
- *
- * @return the starting column number
- */
- int getEndColumn();
-
- /**
- * Returns the 0-based index of the first character in this section.
- *
- * @return the starting character index
- */
- int getCharIndex();
-
- /**
- * Returns the length of this section in characters.
- *
- * @return the number of characters in the section
- */
- int getCharLength();
-
- /**
- * Returns the index of the text position immediately following the last character in the
- * section.
- *
- * @return the end position of the section
- */
- int getCharEndIndex();
-
- /**
- * Returns terse text describing this source section, typically used for printing the section.
- *
- * @return the identifier of the section
- */
- String getIdentifier();
-
- /**
- * Returns text described by this section.
- *
- * @return the code as a String object
- */
- String getCode();
-
- /**
- * Returns a short description of the source section, using just the file name, rather than its
- * full path.
- *
- * @return a short description of the source section
- */
- String getShortDescription();
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceTag.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/SourceTag.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright (c) 2015, 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.source;
-
-/**
- * Categorical information (best implemented as enums} about particular sources of Guest Language
- * code that can be useful to configure behavior of both the language runtime and external tools.
- * These might include {@linkplain Source.Tags standard tags} noting, for example, whether the
- * source was read from a file and whether it should be considered library code.
- *
- * The need for additional tags is likely to arise, in some cases because of issue specific to a
- * Guest Language, but also for help configuring the behavior of particular tools.
- *
- * @see Source
- * @see Source.Tags
- */
-public interface SourceTag {
-
- /**
- * Human-friendly name of a category of code sources, e.g. "file", or "library".
- *
- */
- String name();
-
- /**
- * Criteria and example uses for the tag.
- */
- String getDescription();
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/unsafe/UnsafeAccess.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,266 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.unsafe;
-
-public interface UnsafeAccess {
-
- /**
- * Casts the given value to the value of the given type without any checks. The class must
- * evaluate to a constant. The condition parameter gives a hint to the compiler under which
- * circumstances this cast can be moved to an earlier location in the program.
- *
- * @param value the value that is known to have the specified type
- * @param type the specified new type of the value
- * @param condition the condition that makes this cast safe also at an earlier location of the
- * program
- * @param nonNull whether value is known to never be null
- * @return the value to be casted to the new type
- */
-
- * Compiled code that uses the value will be invalidated each time the value changes, so you should
- * take care to only change values infrequently, or to monitor the number of times the value has
- * changed and at some point to replace the value with something more generic so that it does not
- * have to be changed and code does not have to keep being recompiled.
- */
-public class AssumedValuethis
one.
- */
- @Override
- public abstract boolean equals(Object message);
-
- /**
- * When re-implementing {@link #equals(java.lang.Object)}, it is generally recommended to also
- * implement hashCode()
.
- *
- * @return hash code
- */
- @Override
- public abstract int hashCode();
-
- /**
- * Creates an AST node for this message. The node can be inserted into AST of your language and
- * will handle communication with the foreign language.
- *
- * @return node to be inserted into your AST and passed back to
- * {@link ForeignAccess#execute(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.VirtualFrame, com.oracle.truffle.api.interop.TruffleObject, java.lang.Object[])}
- * method.
- */
- public final Node createNode() {
- return new ForeignObjectAccessHeadNode(this);
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ObjectAccessNode.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/ObjectAccessNode.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,128 +0,0 @@
-/*
- * 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.interop;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.nodes.*;
-
-abstract class ObjectAccessNode extends Node {
-
- public abstract Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments);
-
-}
-
-class UnresolvedObjectAccessNode extends ObjectAccessNode {
-
- private static final int CACHE_SIZE = 8;
- private int cacheLength = 1;
-
- @Override
- public Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
- CompilerDirectives.transferToInterpreterAndInvalidate();
- ForeignObjectAccessHeadNode nthParent = (ForeignObjectAccessHeadNode) NodeUtil.getNthParent(this, cacheLength);
- ObjectAccessNode first = nthParent.getFirst();
- if (cacheLength < CACHE_SIZE) {
- cacheLength++;
- CachedObjectAccessNode createCachedAccess = createCachedAccess(receiver, nthParent.getAccessTree(), first);
- return first.replace(createCachedAccess).executeWith(frame, receiver, arguments);
- } else {
- return first.replace(createGenericAccess(nthParent.getAccessTree())).executeWith(frame, receiver, arguments);
- }
- }
-
- private static CachedObjectAccessNode createCachedAccess(TruffleObject receiver, Message accessTree, ObjectAccessNode next) {
- ForeignAccess fa = receiver.getForeignAccess();
- final CallTarget ct = fa.access(accessTree);
- if (ct == null) {
- throw new IllegalArgumentException("Message " + accessTree + " not recognized by " + fa);
- }
- return new CachedObjectAccessNode(Truffle.getRuntime().createDirectCallNode(ct), next, fa);
- }
-
- private static GenericObjectAccessNode createGenericAccess(Message access) {
- return new GenericObjectAccessNode(access);
- }
-}
-
-class GenericObjectAccessNode extends ObjectAccessNode {
-
- private final Message access;
- @Child private IndirectCallNode indirectCallNode;
-
- public GenericObjectAccessNode(Message access) {
- this.access = access;
- indirectCallNode = Truffle.getRuntime().createIndirectCallNode();
- }
-
- public GenericObjectAccessNode(GenericObjectAccessNode prev) {
- this(prev.access);
- }
-
- @Override
- public Object executeWith(VirtualFrame frame, TruffleObject truffleObject, Object[] arguments) {
- final ForeignAccess fa = truffleObject.getForeignAccess();
- final CallTarget ct = fa.access(access);
- if (ct == null) {
- throw new IllegalStateException("Message " + access + " not recognized by " + fa);
- }
- return indirectCallNode.call(frame, ct, ForeignAccessArguments.create(truffleObject, arguments));
- }
-}
-
-class CachedObjectAccessNode extends ObjectAccessNode {
- @Child private DirectCallNode callTarget;
- @Child private ObjectAccessNode next;
-
- private final ForeignAccess languageCheck;
-
- protected CachedObjectAccessNode(DirectCallNode callTarget, ObjectAccessNode next, ForeignAccess languageCheck) {
- this.callTarget = callTarget;
- this.next = next;
- this.languageCheck = languageCheck;
- this.callTarget.forceInlining();
- }
-
- protected CachedObjectAccessNode(CachedObjectAccessNode prev) {
- this(prev.callTarget, prev.next, prev.languageCheck);
- }
-
- @Override
- public Object executeWith(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
- return doAccess(frame, receiver, arguments);
- }
-
- private Object doAccess(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
- if (languageCheck.canHandle(receiver)) {
- return callTarget.call(frame, ForeignAccessArguments.create(receiver, arguments));
- } else {
- return doNext(frame, receiver, arguments);
- }
- }
-
- private Object doNext(VirtualFrame frame, TruffleObject receiver, Object[] arguments) {
- return next.executeWith(frame, receiver, arguments);
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Read.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Read.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * 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.interop;
-
-final class Read extends KnownMessage {
- public static final int HASH = 423438;
- static Message INSTANCE = new Read();
-
- private Read() {
- }
-
- @Override
- public boolean equals(Object message) {
- return message instanceof Read;
- }
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgRead";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/TruffleObject.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/TruffleObject.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * 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.interop;
-
-/**
- * Interface for any entity of a Truffle guest language implementations that can be shared across
- * other language implementations.
- */
-public interface TruffleObject {
- /**
- * Provides the {@code ForeignAccessFactory} instance for this {@code TruffleObject} instance.
- *
- * @return the {@code ForeignAccessFactory} instance for this {@code TruffleObject} instance.
- */
- ForeignAccess getForeignAccess();
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/UnaryMessage.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/UnaryMessage.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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.interop;
-
-abstract class UnaryMessage extends KnownMessage {
- protected UnaryMessage() {
- }
-
- @Override
- public boolean equals(Object message) {
- if (message == null) {
- return false;
- }
- return this.getClass() == message.getClass();
- }
-
- @Override
- public abstract int hashCode();
-
- @Override
- public abstract String toString();
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Unbox.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Unbox.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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.interop;
-
-final class Unbox extends UnaryMessage {
- public static final int HASH = 423437;
- static Message INSTANCE = new Unbox();
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgUnbox";
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Write.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/Write.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * 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.interop;
-
-final class Write extends KnownMessage {
- public static final int HASH = 423431;
-
- static Message INSTANCE = new Write();
-
- @Override
- public boolean equals(Object message) {
- return message instanceof Write;
- }
-
- @Override
- public int hashCode() {
- return HASH;
- }
-
- @Override
- public String toString() {
- return "msgWrite";
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/impl/ReadOnlyArrayList.java
--- a/graal/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/impl/ReadOnlyArrayList.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,270 +0,0 @@
-/*
- * 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.interop.impl;
-
-import java.lang.reflect.Array;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-public final class ReadOnlyArrayListPassing Arguments
- *
- * Calling Another Tree
- *
- * Creating a Child Node
- *
- * Creating an Array of Children Nodes
- *
- * Using Final Fields in Node Classes
- *
- * Specializing Frame Slot Types
- *
- * Storing Values in Frame Slots
- *
- * Replacing Nodes at Run Time
- *
- * Specializing Return Types
- *
- * Creating a Root Node
- *
- * Accessing the Truffle Runtime
- *
- * AST Instrumentation
- *
- * Instrumentation allows the insertion into Truffle ASTs language-specific instances of
- * {@link WrapperNode} that propagate execution events through a {@link Probe} to any instances of
- * {@link Instrument} that might be attached to the particular probe by tools.
- *
- *
- * To do these tests, several required classes have been implemented in their most basic form, only
- * implementing the methods necessary for the tests to pass, with stubs elsewhere.
- */
-public class InstrumentationTest {
-
- private static final SyntaxTag ADD_TAG = new SyntaxTag() {
-
- @Override
- public String name() {
- return "Addition";
- }
-
- @Override
- public String getDescription() {
- return "Test Language Addition Node";
- }
- };
-
- private static final SyntaxTag VALUE_TAG = new SyntaxTag() {
-
- @Override
- public String name() {
- return "Value";
- }
-
- @Override
- public String getDescription() {
- return "Test Language Value Node";
- }
- };
-
- @Test
- public void testInstrumentationStructure() {
- // Create a simple addition AST
- final TruffleRuntime runtime = Truffle.getRuntime();
- final TestValueNode leftValueNode = new TestValueNode(6);
- final TestValueNode rightValueNode = new TestValueNode(7);
- final TestAdditionNode addNode = new TestAdditionNode(leftValueNode, rightValueNode);
-
- try {
- addNode.probe();
- } catch (ProbeException e) {
- assertEquals(e.getFailure().getReason(), Reason.NO_PARENT);
- }
- final TestRootNode rootNode = new TestRootNode(addNode);
-
- // Creating a call target sets the parent pointers in this tree and is necessary prior to
- // checking any parent/child relationships
- final CallTarget callTarget1 = runtime.createCallTarget(rootNode);
-
- // Check the tree structure
- assertEquals(addNode, leftValueNode.getParent());
- assertEquals(addNode, rightValueNode.getParent());
- Iterator
- *
- *
- *
- */
-package com.oracle.truffle.api.test;
-
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/BytesSourceSectionTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-/*
- * 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.truffle.api.test.source;
-
-import static org.junit.Assert.*;
-
-import java.nio.charset.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.source.*;
-
-public class BytesSourceSectionTest {
-
- @Test
- public void testSectionsFromLineNumberASCII() {
- final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.US_ASCII);
- final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder());
- assertEquals("foo", source.createSection("identifier", 1).getCode());
- assertEquals("bar", source.createSection("identifier", 2).getCode());
- assertEquals("baz", source.createSection("identifier", 3).getCode());
- }
-
- @Test
- public void testSectionsFromOffsetsASCII() {
- final byte[] bytes = "foo\nbar\nbaz\n".getBytes(StandardCharsets.US_ASCII);
- final Source source = Source.fromBytes(bytes, "description", new BytesDecoder.UTF8BytesDecoder());
- assertEquals("foo", source.createSection("identifier", 0, 3).getCode());
- assertEquals("bar", source.createSection("identifier", 4, 3).getCode());
- assertEquals("baz", source.createSection("identifier", 8, 3).getCode());
- }
-
- @Test
- public void testOffset() {
- final byte[] bytes = "xxxfoo\nbar\nbaz\nxxx".getBytes(StandardCharsets.US_ASCII);
- final Source source = Source.fromBytes(bytes, 3, bytes.length - 6, "description", new BytesDecoder.UTF8BytesDecoder());
- assertEquals("foo", source.createSection("identifier", 0, 3).getCode());
- assertEquals("bar", source.createSection("identifier", 4, 3).getCode());
- assertEquals("baz", source.createSection("identifier", 8, 3).getCode());
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceSectionTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.truffle.api.test.source;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.source.*;
-
-public class SourceSectionTest {
-
- private final Source emptySource = Source.fromText("", null);
-
- private final Source emptyLineSource = Source.fromText("\n", null);
-
- private final Source shortSource = Source.fromText("01", null);
-
- private final Source longSource = Source.fromText("01234\n67\n9\n", null);
-
- public void emptySourceTest0() {
- SourceSection section = emptySource.createSection("test", 0, 0);
- assertNotNull(section);
- assertEquals(section.getCode(), "");
- }
-
- @Test
- public void emptyLineTest0() {
- SourceSection section = emptyLineSource.createSection("test", 0, 0);
- assertNotNull(section);
- assertEquals(section.getCode(), "");
- assertEquals(section.getCharIndex(), 0);
- assertEquals(section.getCharLength(), 0);
- assertEquals(section.getStartLine(), 1);
- assertEquals(section.getStartColumn(), 1);
- }
-
- @Ignore
- @Test
- public void emptyLineTest0a() {
- SourceSection section = emptyLineSource.createSection("test", 0, 0);
- assertEquals(section.getEndLine(), 1);
- assertEquals(section.getEndColumn(), 1);
- }
-
- @Test
- public void emptyLineTest1() {
- SourceSection section = emptyLineSource.createSection("test", 0, 1);
- assertNotNull(section);
- assertEquals(section.getCode(), "\n");
- assertEquals(section.getCharIndex(), 0);
- assertEquals(section.getCharLength(), 1);
- assertEquals(section.getStartLine(), 1);
- assertEquals(section.getStartColumn(), 1);
- assertEquals(section.getEndLine(), 1);
- assertEquals(section.getEndColumn(), 1);
- }
-
- @Ignore
- @Test
- public void emptyLineTest2() {
- SourceSection section = emptyLineSource.createSection("test", 1, 0);
- assertNotNull(section);
- assertEquals(section.getCode(), "");
- assertEquals(section.getCharIndex(), 1);
- assertEquals(section.getCharLength(), 0);
- assertEquals(section.getStartLine(), 1);
- assertEquals(section.getStartColumn(), 1);
- assertEquals(section.getEndLine(), 1);
- assertEquals(section.getEndColumn(), 1);
- }
-
- @Test
- public void emptySectionTest2() {
- SourceSection section = shortSource.createSection("test", 0, 0);
- assertNotNull(section);
- assertEquals(section.getCode(), "");
- }
-
- @Test
- public void emptySectionTest3() {
- SourceSection section = longSource.createSection("test", 0, 0);
- assertNotNull(section);
- assertEquals(section.getCode(), "");
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceTagTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceTagTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,162 +0,0 @@
-/*
- * Copyright (c) 2015, 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.truffle.api.test.source;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.source.*;
-
-public class SourceTagTest {
-
- @Test
- public void sourceTagTest() {
-
- // Private tag
- final SourceTag testTag = new SourceTag() {
-
- public String name() {
- return null;
- }
-
- public String getDescription() {
- return null;
- }
- };
-
- // No sources exist with the private tag
- assertEquals(Source.findSourcesTaggedAs(testTag).size(), 0);
-
- // Create a new source
- final Source source = Source.fromText("test1 source", "test1 source");
-
- // Initially has only the default tag
- assertEquals(source.getSourceTags().size(), 1);
-
- assertTrue(source.getSourceTags().contains(Source.Tags.FROM_LITERAL));
- assertTrue(source.isTaggedAs(Source.Tags.FROM_LITERAL));
- assertTrue(Source.findSourcesTaggedAs(Source.Tags.FROM_LITERAL).contains(source));
-
- assertFalse(source.isTaggedAs(testTag));
- assertEquals(Source.findSourcesTaggedAs(testTag).size(), 0);
-
- // Add a private tag
- source.tagAs(testTag);
-
- // Now there are exactly two tags
- assertEquals(source.getSourceTags().size(), 2);
-
- assertTrue(source.getSourceTags().contains(Source.Tags.FROM_LITERAL));
- assertTrue(source.isTaggedAs(Source.Tags.FROM_LITERAL));
- assertTrue(Source.findSourcesTaggedAs(Source.Tags.FROM_LITERAL).contains(source));
-
- assertTrue(source.getSourceTags().contains(testTag));
- assertTrue(source.isTaggedAs(testTag));
- assertEquals(Source.findSourcesTaggedAs(testTag).size(), 1);
- assertTrue(Source.findSourcesTaggedAs(testTag).contains(source));
-
- // Add the private tag again
- source.tagAs(testTag);
-
- // Nothing has changed
- assertEquals(source.getSourceTags().size(), 2);
-
- assertTrue(source.getSourceTags().contains(Source.Tags.FROM_LITERAL));
- assertTrue(source.isTaggedAs(Source.Tags.FROM_LITERAL));
- assertTrue(Source.findSourcesTaggedAs(Source.Tags.FROM_LITERAL).contains(source));
-
- assertTrue(source.getSourceTags().contains(testTag));
- assertTrue(source.isTaggedAs(testTag));
- assertEquals(Source.findSourcesTaggedAs(testTag).size(), 1);
- assertTrue(Source.findSourcesTaggedAs(testTag).contains(source));
- }
-
- @Test
- public void sourceListenerTest() {
-
- // Private tag
- final SourceTag testTag = new SourceTag() {
-
- public String name() {
- return null;
- }
-
- public String getDescription() {
- return null;
- }
- };
-
- final int[] newSourceEvents = {0};
- final Source[] newSource = {null};
-
- final int[] newTagEvents = {0};
- final Source[] taggedSource = {null};
- final SourceTag[] newTag = {null};
-
- Source.addSourceListener(new SourceListener() {
-
- public void sourceCreated(Source source) {
- newSourceEvents[0] = newSourceEvents[0] + 1;
- newSource[0] = source;
- }
-
- public void sourceTaggedAs(Source source, SourceTag tag) {
- newTagEvents[0] = newTagEvents[0] + 1;
- taggedSource[0] = source;
- newTag[0] = tag;
- }
- });
-
- // New source has a default tag applied.
- // Get one event for the new source, another one when it gets tagged
- final Source source = Source.fromText("testSource", "testSource");
- assertEquals(newSourceEvents[0], 1);
- assertEquals(newSource[0], source);
- assertEquals(newTagEvents[0], 1);
- assertEquals(taggedSource[0], source);
- assertEquals(newTag[0], Source.Tags.FROM_LITERAL);
-
- // reset
- newSource[0] = null;
- taggedSource[0] = null;
- newTag[0] = null;
-
- // Add a tag; only get one event (the new tag)
- source.tagAs(testTag);
- assertEquals(newSourceEvents[0], 1);
- assertEquals(newSource[0], null);
- assertEquals(newTagEvents[0], 2);
- assertEquals(taggedSource[0], source);
- assertEquals(newTag[0], testTag);
-
- // Add the same tag; no events, and nothing changes.
- source.tagAs(testTag);
- assertEquals(newSourceEvents[0], 1);
- assertEquals(newSource[0], null);
- assertEquals(newTagEvents[0], 2);
- assertEquals(taggedSource[0], source);
- assertEquals(newTag[0], testTag);
-
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceTextTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/source/SourceTextTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,202 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.truffle.api.test.source;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.source.*;
-
-public class SourceTextTest {
-
- private final Source emptySource = Source.fromText("", null);
-
- private final Source emptyLineSource = Source.fromText("\n", null);
-
- private final Source shortSource = Source.fromText("01", null);
-
- private final Source longSource = Source.fromText("01234\n67\n9\n", null);
-
- @Test
- public void emptyTextTest0() {
- assertEquals(emptySource.getLineCount(), 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest1() {
- emptySource.getLineNumber(0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest2() {
- emptySource.getColumnNumber(0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest3() {
- emptySource.getLineNumber(-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest4() {
- emptySource.getLineStartOffset(0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest5() {
- emptySource.getLineStartOffset(1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyTextTest6() {
- emptySource.getLineLength(1);
- }
-
- @Test
- public void emptyLineTest0() {
- assertEquals(emptyLineSource.getLineCount(), 1);
- assertEquals(emptyLineSource.getLineNumber(0), 1);
- assertEquals(emptyLineSource.getLineStartOffset(1), 0);
- assertEquals(emptyLineSource.getColumnNumber(0), 1);
- assertEquals(emptyLineSource.getLineLength(1), 0);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyLineTest1() {
- emptyLineSource.getLineNumber(1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyLineTest2() {
- emptyLineSource.getLineStartOffset(2);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyLineTest3() {
- emptyLineSource.getColumnNumber(1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void emptyLineTest4() {
- emptyLineSource.getLineLength(2);
- }
-
- @Test
- public void shortTextTest0() {
-
- assertEquals(shortSource.getLineCount(), 1);
-
- assertEquals(shortSource.getLineNumber(0), 1);
- assertEquals(shortSource.getLineStartOffset(1), 0);
- assertEquals(shortSource.getColumnNumber(0), 1);
-
- assertEquals(shortSource.getLineNumber(1), 1);
- assertEquals(shortSource.getColumnNumber(1), 2);
-
- assertEquals(shortSource.getLineLength(1), 2);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest1() {
- shortSource.getLineNumber(-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest2() {
- shortSource.getColumnNumber(-1);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest3() {
- shortSource.getLineNumber(2);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest4() {
- shortSource.getColumnNumber(2);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest5() {
- shortSource.getLineLength(2);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void shortTextTest6() {
- shortSource.getLineLength(2);
- }
-
- @Test
- public void longTextTest0() {
-
- assertEquals(longSource.getLineCount(), 3);
-
- assertEquals(longSource.getLineNumber(0), 1);
- assertEquals(longSource.getLineStartOffset(1), 0);
- assertEquals(longSource.getColumnNumber(0), 1);
-
- assertEquals(longSource.getLineNumber(4), 1);
- assertEquals(longSource.getColumnNumber(4), 5);
-
- assertEquals(longSource.getLineNumber(5), 1); // newline
- assertEquals(longSource.getColumnNumber(5), 6); // newline
- assertEquals(longSource.getLineLength(1), 5);
-
- assertEquals(longSource.getLineNumber(6), 2);
- assertEquals(longSource.getLineStartOffset(2), 6);
- assertEquals(longSource.getColumnNumber(6), 1);
-
- assertEquals(longSource.getLineNumber(7), 2);
- assertEquals(longSource.getColumnNumber(7), 2);
-
- assertEquals(longSource.getLineNumber(8), 2); // newline
- assertEquals(longSource.getLineNumber(8), 2); // newline
- assertEquals(longSource.getLineLength(2), 2);
-
- assertEquals(longSource.getLineNumber(9), 3);
- assertEquals(longSource.getLineStartOffset(3), 9);
- assertEquals(longSource.getColumnNumber(9), 1);
-
- assertEquals(longSource.getLineNumber(10), 3); // newline
- assertEquals(longSource.getColumnNumber(10), 2); // newline
- assertEquals(longSource.getLineLength(3), 1);
-
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void longTextTest1() {
- longSource.getLineNumber(11);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void longTextTest2() {
- longSource.getColumnNumber(11);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void longTextTest3() {
- longSource.getLineStartOffset(4);
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AlwaysValidAssumptionTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 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
- * 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.truffle.api.test.utilities;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.utilities.*;
-
-public class AlwaysValidAssumptionTest {
-
- @Test
- public void testCheck() throws InvalidAssumptionException {
- final AlwaysValidAssumption assumption = AlwaysValidAssumption.INSTANCE;
- assumption.check();
- }
-
- @Test
- public void testIsValid() {
- final AlwaysValidAssumption assumption = AlwaysValidAssumption.INSTANCE;
- assertTrue(assumption.isValid());
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testCannotInvalidate() {
- final AlwaysValidAssumption assumption = AlwaysValidAssumption.INSTANCE;
- assumption.invalidate();
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/utilities/AssumedValueTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 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
- * 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.truffle.api.test.utilities;
-
-import static org.junit.Assert.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.utilities.*;
-
-public class AssumedValueTest {
-
- @Test
- public void testGet() {
- final AssumedValue42
.
- *
- * @return name of globally exported symbol
- */
- protected abstract String fourtyTwo();
-
- /**
- * Name of a function that returns null
. Truffle languages are encouraged to have
- * their own type representing null
, but when such value is returned from
- * {@link TruffleVM#eval}, it needs to be converted to real Java null
by sending a
- * foreign access isNull message. There is a test to verify it is really true.
- *
- * @return name of globally exported symbol
- */
- protected abstract String returnsNull();
-
- /**
- * Name of function to add two integer values together. The symbol will be invoked with two
- * parameters of type {@link Integer} and expects result of type {@link Number} which's
- * {@link Number#intValue()} is equivalent of param1 + param2
.
- *
- * @return name of globally exported symbol
- */
- protected abstract String plusInt();
-
- /**
- * Return a code snippet that is invalid in your language. Its
- * {@link TruffleVM#eval(java.lang.String, java.lang.String) evaluation} should fail and yield
- * an exception.
- *
- * @return code snippet invalid in the tested language
- */
- protected abstract String invalidCode();
-
- private TruffleVM vm() throws Exception {
- if (tckVM == null) {
- tckVM = prepareVM();
- }
- return tckVM;
- }
-
- //
- // The tests
- //
-
- @Test
- public void testFortyTwo() throws Exception {
- TruffleVM.Symbol fourtyTwo = findGlobalSymbol(fourtyTwo());
-
- Object res = fourtyTwo.invoke(null);
-
- assert res instanceof Number : "should yield a number, but was: " + res;
-
- Number n = (Number) res;
-
- assert 42 == n.intValue() : "The value is 42 = " + n.intValue();
- }
-
- @Test
- public void testNull() throws Exception {
- if (getClass() == TruffleTCK.class) {
- return;
- }
- TruffleVM.Symbol retNull = findGlobalSymbol(returnsNull());
-
- Object res = retNull.invoke(null);
-
- assertNull("Should yield real Java null", res);
- }
-
- @Test
- public void testPlusWithInts() throws Exception {
- Random r = new Random();
- int a = r.nextInt(100);
- int b = r.nextInt(100);
-
- TruffleVM.Symbol plus = findGlobalSymbol(plusInt());
-
- Object res = plus.invoke(null, a, b);
-
- assert res instanceof Number : "+ on two ints should yield a number, but was: " + res;
-
- Number n = (Number) res;
-
- assert a + b == n.intValue() : "The value is correct: (" + a + " + " + b + ") = " + n.intValue();
- }
-
- @Test(expected = IOException.class)
- public void testInvalidTestMethod() throws Exception {
- String mime = mimeType();
- String code = invalidCode();
- Object ret = vm().eval(mime, code);
- fail("Should yield IOException, but returned " + ret);
- }
-
- private TruffleVM.Symbol findGlobalSymbol(String name) throws Exception {
- TruffleVM.Symbol s = vm().findGlobalSymbol(name);
- assert s != null : "Symbol " + name + " is not found!";
- return s;
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleVMSingleThreadedTest.java
--- a/graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/vm/TruffleVMSingleThreadedTest.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2012, 2015, 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.truffle.api.test.vm;
-
-import java.io.*;
-import java.net.*;
-
-import org.junit.*;
-
-import com.oracle.truffle.api.vm.*;
-
-public class TruffleVMSingleThreadedTest {
- TruffleVM tvm;
-
- @Before
- public void initInDifferentThread() throws InterruptedException {
- final TruffleVM.Builder b = TruffleVM.newVM();
- Thread t = new Thread("Initializer") {
- @Override
- public void run() {
- tvm = b.build();
- }
- };
- t.start();
- t.join();
- }
-
- @Test(expected = IllegalStateException.class)
- public void evalURI() throws IOException, URISyntaxException {
- tvm.eval(new URI("http://unknown.js"));
- }
-
- @Test(expected = IllegalStateException.class)
- public void evalString() throws IOException {
- tvm.eval("text/javascript", "1 + 1");
- }
-
- @Test(expected = IllegalStateException.class)
- public void evalReader() throws IOException {
- try (StringReader sr = new StringReader("1 + 1")) {
- tvm.eval("text/javascript", sr);
- }
- }
-
- @Test(expected = IllegalStateException.class)
- public void findGlobalSymbol() {
- tvm.findGlobalSymbol("doesNotExists");
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/.checkstyle_checks.xml
--- a/graal/com.oracle.truffle.api/.checkstyle_checks.xml Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,218 +0,0 @@
-
-
-
-
-
-true
.
- *
- * Note that optimizations that a compiler will apply to code that is conditional on
- * isCompilationConstant
may be limited. For this reason
- * isCompilationConstant
is not recommended for use to select between alternate
- * implementations of functionality depending on whether a value is constant. Instead, it is
- * intended for use as a diagnostic mechanism.
- *
- * @param value
- * @return {@code true} when given value is seen as compilation constant, {@code false} if not
- * compilation constant.
- */
- public static boolean isCompilationConstant(Object value) {
- return CompilerDirectives.inInterpreter();
- }
-
- /**
- * Directive for the compiler that the given runnable should only be executed in the interpreter
- * and ignored in the compiled code.
- *
- * @param runnable the closure that should only be executed in the interpreter
- */
- public static void interpreterOnly(Runnable runnable) {
- runnable.run();
- }
-
- /**
- * Directive for the compiler that the given callable should only be executed in the
- * interpreter.
- *
- * @param callable the closure that should only be executed in the interpreter
- * @return the result of executing the closure in the interpreter and null in the compiled code
- * @throws Exception If the closure throws an exception when executed in the interpreter.
- */
- public static
- * if (injectBranchProbability(0.9, a > b)) {
- * // ...
- * }
- *
- *
- * Example usage for a combined condition (it specifies that the likelihood for a to be greater
- * than b is 90% and under the assumption that this is true, the likelihood for a being 0 is
- * 10%):
- *
- *
- * if (injectBranchProbability(0.9, a > b) && injectBranchProbability(0.1, a == 0)) {
- * // ...
- * }
- *
- *
- * There are predefined constants for commonly used probabilities (see
- * {@link #LIKELY_PROBABILITY} , {@link #UNLIKELY_PROBABILITY}, {@link #SLOWPATH_PROBABILITY},
- * {@link #FASTPATH_PROBABILITY} ).
- *
- * @param probability the probability value between 0.0 and 1.0 that should be injected
- */
- public static boolean injectBranchProbability(double probability, boolean condition) {
- assert probability >= 0.0 && probability <= 1.0;
- return condition;
- }
-
- /**
- * Bails out of a compilation (e.g., for guest language features that should never be compiled).
- *
- * @param reason the reason for the bailout
- */
- public static void bailout(String reason) {
- }
-
- /**
- * Marks fields that should be considered final for a Truffle compilation although they are not
- * final while executing in the interpreter.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.FIELD})
- public @interface CompilationFinal {
- }
-
- /**
- * Marks a method that it is considered as a boundary for Truffle partial evaluation.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
- public @interface TruffleBoundary {
- }
-
- /**
- * Marks classes as value types. Reference comparisons (==) between instances of those classes
- * have undefined semantics and can either return true or false.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target({ElementType.TYPE})
- public @interface ValueType {
- }
-
- /**
- * Ensures that the given object is not virtual, i.e., not removed by Escape Analysis at the
- * point of this call.
- *
- * @param obj the object to exclude from Escape Analysis
- */
- public static void materialize(Object obj) {
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerOptions.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/CompilerOptions.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * 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;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Allows options to be set to control the compilation of a specific {@link RootNode}, without
- * creating a dependency on the specific compiler used. Options can be tested for support before
- * setting.
- */
-public interface CompilerOptions {
-
- boolean supportsOption(String name);
-
- void setOption(String name, Object value);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExactMath.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExactMath.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-/*
- * 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. 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;
-
-/**
- * This class contains methods that will be part of java.lang.Math starting with JDK 8. Until JDK 8
- * is release, we duplicate them here because they are generally useful for dynamic language
- * implementations.
- */
-public class ExactMath {
-
- public static int addExact(int x, int y) {
- int r = x + y;
- // HD 2-12 Overflow iff both arguments have the opposite sign of the result
- if (((x ^ r) & (y ^ r)) < 0) {
- throw new ArithmeticException("integer overflow");
- }
- return r;
- }
-
- public static long addExact(long x, long y) {
- long r = x + y;
- // HD 2-12 Overflow iff both arguments have the opposite sign of the result
- if (((x ^ r) & (y ^ r)) < 0) {
- throw new ArithmeticException("long overflow");
- }
- return r;
- }
-
- public static int subtractExact(int x, int y) {
- int r = x - y;
- // HD 2-12 Overflow iff the arguments have different signs and
- // the sign of the result is different than the sign of x
- if (((x ^ y) & (x ^ r)) < 0) {
- throw new ArithmeticException("integer overflow");
- }
- return r;
- }
-
- public static long subtractExact(long x, long y) {
- long r = x - y;
- // HD 2-12 Overflow iff the arguments have different signs and
- // the sign of the result is different than the sign of x
- if (((x ^ y) & (x ^ r)) < 0) {
- throw new ArithmeticException("long overflow");
- }
- return r;
- }
-
- public static int multiplyExact(int x, int y) {
- long r = (long) x * (long) y;
- if ((int) r != r) {
- throw new ArithmeticException("long overflow");
- }
- return (int) r;
- }
-
- public static long multiplyExact(long x, long y) {
- long r = x * y;
- long ax = Math.abs(x);
- long ay = Math.abs(y);
- if (((ax | ay) >>> 31 != 0)) {
- // Some bits greater than 2^31 that might cause overflow
- // Check the result using the divide operator
- // and check for the special case of Long.MIN_VALUE * -1
- if (((y != 0) && (r / y != x)) || (x == Long.MIN_VALUE && y == -1)) {
- throw new ArithmeticException("long overflow");
- }
- }
- return r;
- }
-
- public static int multiplyHigh(int x, int y) {
- long r = (long) x * (long) y;
- return (int) (r >> 32);
- }
-
- public static int multiplyHighUnsigned(int x, int y) {
- long xl = x & 0xFFFFFFFFL;
- long yl = y & 0xFFFFFFFFL;
- long r = xl * yl;
- return (int) (r >> 32);
- }
-
- public static long multiplyHigh(long x, long y) {
- // Checkstyle: stop
- long x0, y0, z0;
- long x1, y1, z1, z2, t;
- // Checkstyle: resume
-
- x0 = x & 0xFFFFFFFFL;
- x1 = x >> 32;
-
- y0 = y & 0xFFFFFFFFL;
- y1 = y >> 32;
-
- z0 = x0 * y0;
- t = x1 * y0 + (z0 >>> 32);
- z1 = t & 0xFFFFFFFFL;
- z2 = t >> 32;
- z1 += x0 * y1;
-
- return x1 * y1 + z2 + (z1 >> 32);
- }
-
- public static long multiplyHighUnsigned(long x, long y) {
- // Checkstyle: stop
- long x0, y0, z0;
- long x1, y1, z1, z2, t;
- // Checkstyle: resume
-
- x0 = x & 0xFFFFFFFFL;
- x1 = x >>> 32;
-
- y0 = y & 0xFFFFFFFFL;
- y1 = y >>> 32;
-
- z0 = x0 * y0;
- t = x1 * y0 + (z0 >>> 32);
- z1 = t & 0xFFFFFFFFL;
- z2 = t >>> 32;
- z1 += x0 * y1;
-
- return x1 * y1 + z2 + (z1 >>> 32);
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ExecutionContext.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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;
-
-import com.oracle.truffle.api.impl.*;
-
-/**
- * Access to information and basic services in the runtime context for a Truffle-implemented guest
- * language.
- */
-public abstract class ExecutionContext {
-
- protected ExecutionContext() {
- }
-
- /**
- * Get compiler options specific to this ExecutionContext
.
- */
- public CompilerOptions getCompilerOptions() {
- return DefaultCompilerOptions.INSTANCE;
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/LoopCountReceiver.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/LoopCountReceiver.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * 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. 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;
-
-/**
- * Accepts the execution count of a loop that is a child of this node. The optimization heuristics
- * can use the loop count to guide compilation and inlining.
- */
-public interface LoopCountReceiver {
-
- void reportLoopCount(int count);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/OptimizationFailedException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/OptimizationFailedException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
- * 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;
-
-public class OptimizationFailedException extends RuntimeException {
-
- private final RootCallTarget callTarget;
-
- public OptimizationFailedException(Throwable cause, RootCallTarget callTarget) {
- super(cause);
- this.callTarget = callTarget;
- }
-
- public RootCallTarget getCallTarget() {
- return callTarget;
- }
-
- private static final long serialVersionUID = -8797188744430210785L;
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ReplaceObserver.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/ReplaceObserver.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * An observer that is notified whenever a child node is replaced.
- */
-public interface ReplaceObserver {
-
- /**
- * Returns true
if the event is consumed and no parent nodes should be notified by
- * for replaces. Returns false
if the parent {@link Node} or {@link CallTarget}
- * should get notified.
- */
- boolean nodeReplaced(Node oldNode, Node newNode, CharSequence reason);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/RootCallTarget.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * 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. 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;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Represents the target of a call to a {@link RootNode}, i.e., to another tree of nodes. Instances
- * of this class can be created using {@link TruffleRuntime#createCallTarget(RootNode)}.
- */
-public interface RootCallTarget extends CallTarget {
-
- RootNode getRootNode();
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/Truffle.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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;
-
-import java.lang.reflect.*;
-import java.security.*;
-
-import com.oracle.truffle.api.impl.*;
-
-/**
- * Class for obtaining the Truffle runtime singleton object of this virtual machine.
- */
-public class Truffle {
-
- private static final TruffleRuntime RUNTIME = initRuntime();
-
- /**
- * Gets the singleton {@link TruffleRuntime} object.
- */
- public static TruffleRuntime getRuntime() {
- return RUNTIME;
- }
-
- private static TruffleRuntime initRuntime() {
- if (TruffleOptions.ForceInterpreter) {
- /*
- * Force Truffle to run in interpreter mode even if we have a specialized implementation
- * of TruffleRuntime available.
- */
- return new DefaultTruffleRuntime();
- }
-
- return AccessController.doPrivileged(new PrivilegedActionTruffleObject
(e.g. a native object from the
- * other language) to support interoperability between languages, {@link String} or one of Java
- * primitive wrappers ( {@link Integer}, {@link Double}, {@link Short}, {@link Boolean}, etc.).
- * globalName
. To ensure so the infrastructure first
- * asks all known languages for onlyExplicit
symbols and only when none is found,
- * it does one more round with onlyExplicit
set to false
.
- *
- * @param globalName the name of the global symbol to find
- * @param onlyExplicit should the language seek for implicitly exported object or only consider
- * the explicitly exported ones?
- * @return an exported object or null
, if the symbol does not represent anything
- * meaningful in this language
- */
- protected abstract Object findExportedSymbol(String globalName, boolean onlyExplicit);
-
- /**
- * Returns global object for the language.
- * TruffleObject
(e.g. a native object from the other
- * language) but technically it can be one of Java primitive wrappers ({@link Integer},
- * {@link Double}, {@link Short}, etc.).
- *
- * @return the global object or null
if the language does not support such concept
- */
- protected abstract Object getLanguageGlobal();
-
- /**
- * Checks whether the object is provided by this language.
- *
- * @param object the object to check
- * @return true
if this language can deal with such object in native way
- */
- protected abstract boolean isObjectOfLanguage(Object object);
-
- protected abstract ToolSupportProvider getToolSupport();
-
- protected abstract DebugSupportProvider getDebugSupport();
-
- /**
- * Represents execution environment of the {@link TruffleLanguage}. Each active
- * {@link TruffleLanguage} receives instance of the environment before any code is executed upon
- * it. The environment has knowledge of all active languages and can exchange symbols between
- * them.
- */
- public static final class Env {
- private final TruffleVM vm;
- private final TruffleLanguage lang;
- private final Reader in;
- private final Writer err;
- private final Writer out;
-
- Env(TruffleVM vm, Constructor> langConstructor, Writer out, Writer err, Reader in) {
- this.vm = vm;
- this.in = in;
- this.err = err;
- this.out = out;
- try {
- this.lang = (TruffleLanguage) langConstructor.newInstance(this);
- } catch (Exception ex) {
- throw new IllegalStateException("Cannot construct language " + langConstructor.getDeclaringClass().getName(), ex);
- }
- }
-
- /**
- * Asks the environment to go through other registered languages and find whether they
- * export global symbol of specified name. The expected return type is either
- * TruffleObject
, or one of wrappers of Java primitive types ({@link Integer},
- * {@link Double}).
- *
- * @param globalName the name of the symbol to search for
- * @return object representing the symbol or null
- */
- public Object importSymbol(String globalName) {
- return API.importSymbol(vm, lang, globalName);
- }
-
- /**
- * Input associated with this {@link TruffleVM}.
- *
- * @return reader, never null
- */
- public Reader stdIn() {
- return in;
- }
-
- /**
- * Standard output writer for this {@link TruffleVM}.
- *
- * @return writer, never null
- */
- public Writer stdOut() {
- return out;
- }
-
- /**
- * Standard error writer for this {@link TruffleVM}.
- *
- * @return writer, never null
- */
- public Writer stdErr() {
- return err;
- }
- }
-
- private static final AccessAPI API = new AccessAPI();
-
- private static final class AccessAPI extends Accessor {
- @Override
- protected TruffleLanguage attachEnv(TruffleVM vm, Constructor> langClazz, Writer stdOut, Writer stdErr, Reader stdIn) {
- Env env = new Env(vm, langClazz, stdOut, stdErr, stdIn);
- return env.lang;
- }
-
- @Override
- public Object importSymbol(TruffleVM vm, TruffleLanguage queryingLang, String globalName) {
- return super.importSymbol(vm, queryingLang, globalName);
- }
-
- @Override
- protected Object eval(TruffleLanguage l, Source s) throws IOException {
- return l.eval(s);
- }
-
- @Override
- protected Object findExportedSymbol(TruffleLanguage l, String globalName, boolean onlyExplicit) {
- return l.findExportedSymbol(globalName, onlyExplicit);
- }
-
- @Override
- protected Object languageGlobal(TruffleLanguage l) {
- return l.getLanguageGlobal();
- }
-
- @Override
- protected ToolSupportProvider getToolSupport(TruffleLanguage l) {
- return l.getToolSupport();
- }
-
- @Override
- protected DebugSupportProvider getDebugSupport(TruffleLanguage l) {
- return l.getDebugSupport();
- }
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/TruffleOptions.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2012, 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. 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;
-
-import java.security.*;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Class containing general Truffle options.
- */
-public class TruffleOptions {
-
- /**
- * Force truffle to run in interpreter mode.
- *
- *
- *
- * @param probe the Probe to which the Instrument requesting the AST fragment is attached
- * @param node the guest-language AST location that is the context in which the requesting
- * Instrument must execute the AST fragment.
- * @return a newly created AST fragment suitable for execution, via instrumentation, in the
- * execution context of the specified guest-language AST site.
- */
- AdvancedInstrumentRoot createInstrumentRoot(Probe probe, Node node);
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Instrument.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,636 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.instrument;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.frame.*;
-import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-
-// TODO (mlvdv) these statics should not be global. Move them to some kind of context.
-// TODO (mlvdv) migrate factory (together with Probe)? break out nested classes?
-
-/**
- * A binding between:
- *
- *
- * Implementation Notes: the Life Cycle of an {@link Instrument} at a {@link Probe}
- *
- *
- *
- * @see Probe
- * @see TruffleEvents
- */
-public abstract class Instrument {
-
- /**
- * Creates a Simple Instrument: this Instrument routes execution events to a
- * client-provided listener.
- *
- * @param listener a listener for execution events
- * @param instrumentInfo optional description of the instrument's role, intended for debugging.
- * @return a new instrument, ready for attachment at a probe
- */
- public static Instrument create(SimpleInstrumentListener listener, String instrumentInfo) {
- return new SimpleInstrument(listener, instrumentInfo);
- }
-
- /**
- * Creates a Standard Instrument: this Instrument routes execution events, together
- * with access to Truffle execution state, to a client-provided listener.
- *
- * @param standardListener a listener for execution events and execution state
- * @param instrumentInfo optional description of the instrument's role, intended for debugging.
- * @return a new instrument, ready for attachment at a probe
- */
- public static Instrument create(StandardInstrumentListener standardListener, String instrumentInfo) {
- return new StandardInstrument(standardListener, instrumentInfo);
- }
-
- /**
- * Creates an Advanced Instrument: this Instrument executes efficiently, subject to
- * full Truffle optimization, a client-provided AST fragment every time the Probed node is
- * entered.
- *
- *
- *
- *
- *
- *
- * Note:
- * Tool installation is currently global to the Truffle Execution environment. When
- * language-agnostic management of individual execution environments is added to the platform,
- * installation will be (optionally) specific to a single execution environment.
- */
-public abstract class InstrumentationTool {
- // TODO (mlvdv) still thinking about the most appropriate name for this class of tools
-
- private enum ToolState {
-
- /** Not yet installed, inert. */
- UNINSTALLED,
-
- /** Installed, collecting data. */
- ENABLED,
-
- /** Installed, not collecting data. */
- DISABLED,
-
- /** Was installed, but now removed, inactive, and no longer usable. */
- DISPOSED;
- }
-
- private ToolState toolState = ToolState.UNINSTALLED;
-
- protected InstrumentationTool() {
- }
-
- /**
- * Connect the tool to some part of the Truffle runtime, and enable data collection to start.
- * Instrumentation will only be added to subsequently created ASTs.
- *
- * @throws IllegalStateException if the tool has previously been installed.
- */
- public final void install() {
- checkUninstalled();
- if (internalInstall()) {
- toolState = ToolState.ENABLED;
- }
- }
-
- /**
- * @return whether the tool is currently collecting data.
- */
- public final boolean isEnabled() {
- return toolState == ToolState.ENABLED;
- }
-
- /**
- * Switches tool state between enabled (collecting data) and disabled (not
- * collecting data, but keeping data already collected).
- *
- * @throws IllegalStateException if not yet installed or disposed.
- */
- public final void setEnabled(boolean isEnabled) {
- checkInstalled();
- internalSetEnabled(isEnabled);
- toolState = isEnabled ? ToolState.ENABLED : ToolState.DISABLED;
- }
-
- /**
- * Clears any data already collected, but otherwise does not change the state of the tool.
- *
- * @throws IllegalStateException if not yet installed or disposed.
- */
- public final void reset() {
- checkInstalled();
- internalReset();
- }
-
- /**
- * Makes the tool permanently disabled, removes instrumentation, but keeps data already
- * collected.
- *
- * @throws IllegalStateException if not yet installed or disposed.
- */
- public final void dispose() {
- checkInstalled();
- internalDispose();
- toolState = ToolState.DISPOSED;
- }
-
- /**
- * @return whether the installation succeeded.
- */
- protected abstract boolean internalInstall();
-
- /**
- * No subclass action required.
- *
- * @param isEnabled
- */
- protected void internalSetEnabled(boolean isEnabled) {
- }
-
- protected abstract void internalReset();
-
- protected abstract void internalDispose();
-
- /**
- * Ensure that the tool is currently installed.
- *
- * @throws IllegalStateException
- */
- private void checkInstalled() throws IllegalStateException {
- if (toolState == ToolState.UNINSTALLED) {
- throw new IllegalStateException("Tool " + getClass().getSimpleName() + " not yet installed");
- }
- if (toolState == ToolState.DISPOSED) {
- throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has been disposed");
- }
- }
-
- /**
- * Ensure that the tool has not yet been installed.
- *
- * @throws IllegalStateException
- */
- private void checkUninstalled() {
- if (toolState != ToolState.UNINSTALLED) {
- throw new IllegalStateException("Tool " + getClass().getSimpleName() + " has already been installed");
- }
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/KillException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/KillException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * 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.instrument;
-
-import com.oracle.truffle.api.nodes.*;
-
-/**
- * Controls breaking out of an execution context, such as a shell or eval.
- */
-public final class KillException extends ControlFlowException {
-
- private static final long serialVersionUID = 3163641880088766957L;
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/instrument/Probe.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,486 +0,0 @@
-/*
- * Copyright (c) 2013, 2015, 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.instrument;
-
-import java.io.*;
-import java.lang.ref.*;
-import java.util.*;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
-import com.oracle.truffle.api.instrument.InstrumentationNode.TruffleEvents;
-import com.oracle.truffle.api.nodes.*;
-import com.oracle.truffle.api.source.*;
-import com.oracle.truffle.api.utilities.*;
-
-//TODO (mlvdv) these statics should not be global. Move them to some kind of context.
-
-/**
- * A binding between:
- *
- *
- * Implementation notes:
- *
- *
- *
- * @see Instrument
- * @see ASTProber
- * @see ProbeListener
- * @see SyntaxTag
- */
-public final class Probe {
-
- private static final boolean TRACE = false;
- private static final String TRACE_PREFIX = "PROBE: ";
- private static final PrintStream OUT = System.out;
-
- private static void trace(String format, Object... args) {
- if (TRACE) {
- OUT.println(TRACE_PREFIX + String.format(format, args));
- }
- }
-
- private static final List
- *
- *
- *
- *
- *
- *
- * @param newBeforeTagTrap The new "before" {@link SyntaxTagTrap} to set.
- */
- public static void setBeforeTagTrap(SyntaxTagTrap newBeforeTagTrap) {
- beforeTagTrap = newBeforeTagTrap;
- for (WeakReference
- *
- *
- * @param newAfterTagTrap The new "after" {@link SyntaxTagTrap} to set.
- */
- public static void setAfterTagTrap(SyntaxTagTrap newAfterTagTrap) {
- afterTagTrap = newAfterTagTrap;
- for (WeakReference
- *
- * true
if the underlying runtime system supports inlining for the
- * {@link CallTarget} in this {@link DirectCallNode}.
- *
- * @return true if inlining is supported.
- */
- public abstract boolean isInlinable();
-
- /**
- * Returns true
if the {@link CallTarget} is forced to be inlined. A
- * {@link DirectCallNode} can either be inlined manually by invoking {@link #forceInlining()} or
- * by the runtime system which may at any point decide to inline.
- *
- * @return true if this method was inlined else false.
- */
- public abstract boolean isInliningForced();
-
- /**
- * Enforces the runtime system to inline the {@link CallTarget} at this call site. If the
- * runtime system does not support inlining or it is already inlined this method has no effect.
- * The runtime system may decide to not inline calls which were forced to inline.
- */
- public abstract void forceInlining();
-
- /**
- * Returns true if the runtime system has decided to inline this call-site. If the
- * {@link DirectCallNode} was forced to inline then this does not necessarily mean that the
- * {@link DirectCallNode} is really going to be inlined. This depends on whether or not the
- * runtime system supports inlining. The runtime system may also decide to not inline calls
- * which were forced to inline.
- *
- * @deprecated we do not expose this information any longer. returns always false.
- */
- @SuppressWarnings("static-method")
- @Deprecated
- public final boolean isInlined() {
- return false;
- }
-
- /**
- * Returns true
if the runtime system supports cloning and the {@link RootNode}
- * returns true
in {@link RootNode#isCloningAllowed()}.
- *
- * @return true
if the target is allowed to be cloned.
- */
- public abstract boolean isCallTargetCloningAllowed();
-
- /**
- * Clones the {@link CallTarget} instance returned by {@link #getCallTarget()} in an
- * uninitialized state for this {@link DirectCallNode}. This can be sensible to gather call site
- * sensitive profiling information for this {@link DirectCallNode}. If
- * {@link #isCallTargetCloningAllowed()} returns false
this method has no effect
- * and returns false
.
- */
- public abstract boolean cloneCallTarget();
-
- /**
- * Returns true
if the target of the {@link DirectCallNode} was cloned by the
- * runtime system or by the guest language implementation.
- *
- * @return if the target was split
- */
- public final boolean isCallTargetCloned() {
- return getClonedCallTarget() != null;
- }
-
- /**
- * Returns the split {@link CallTarget} if this call site's {@link CallTarget} is cloned.
- *
- * @return the split {@link CallTarget}
- */
- public abstract CallTarget getClonedCallTarget();
-
- /**
- * Returns the used call target when {@link #call(VirtualFrame, Object[])} is invoked. If the
- * {@link CallTarget} was split this method returns the {@link CallTarget} returned by
- * {@link #getClonedCallTarget()}.
- *
- * @return the used {@link CallTarget} when node is called
- */
- public CallTarget getCurrentCallTarget() {
- CallTarget split = getClonedCallTarget();
- if (split != null) {
- return split;
- } else {
- return getCallTarget();
- }
- }
-
- /**
- * Returns the {@link RootNode} associated with {@link CallTarget} returned by
- * {@link #getCurrentCallTarget()}. If the stored {@link CallTarget} does not contain a
- * {@link RootNode} this method returns null
.
- *
- * @see #getCurrentCallTarget()
- * @return the root node of the used call target
- */
- public final RootNode getCurrentRootNode() {
- CallTarget target = getCurrentCallTarget();
- if (target instanceof RootCallTarget) {
- return ((RootCallTarget) target).getRootNode();
- }
- return null;
- }
-
- @Override
- public String toString() {
- return String.format("%s(target=%s)", getClass().getSimpleName(), getCurrentCallTarget());
- }
-
- public static DirectCallNode create(CallTarget target) {
- return Truffle.getRuntime().createDirectCallNode(target);
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExplodeLoop.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/ExplodeLoop.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * 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. 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.nodes;
-
-import java.lang.annotation.*;
-
-/**
- * Specifies for a method that the loops with constant number of invocations should be fully
- * unrolled.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.METHOD)
-public @interface ExplodeLoop {
- boolean merge() default false;
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/GraphPrintVisitor.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,420 +0,0 @@
-/*
- * 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. 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.nodes;
-
-import java.io.*;
-import java.lang.annotation.*;
-import java.net.*;
-import java.util.*;
-
-import javax.xml.parsers.*;
-import javax.xml.transform.*;
-import javax.xml.transform.dom.*;
-import javax.xml.transform.stream.*;
-
-import org.w3c.dom.*;
-
-import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind;
-
-/**
- * Utility class for creating output for the ideal graph visualizer.
- */
-public class GraphPrintVisitor {
-
- public static final String GraphVisualizerAddress = "127.0.0.1";
- public static final int GraphVisualizerPort = 4444;
-
- private Document dom;
- private Map
- *
- *
- * @return an appropriately typed {@link WrapperNode} if {@link #isInstrumentable()}.
- */
- public WrapperNode createWrapperNode() {
- return null;
- }
-
- /**
- * Enables {@linkplain Instrument instrumentation} of a node, where the node is presumed to be
- * part of a well-formed Truffle AST that is not being executed. If this node has not already
- * been probed, modifies the AST by inserting a {@linkplain WrapperNode wrapper node} between
- * the node and its parent; the wrapper node must be provided by implementations of
- * {@link #createWrapperNode()}. No more than one {@link Probe} may be associated with a node,
- * so a {@linkplain WrapperNode wrapper} may not wrap another {@linkplain WrapperNode wrapper}.
- *
- * @return a (possibly newly created) {@link Probe} associated with this node.
- * @throws ProbeException (unchecked) when a probe cannot be created, leaving the AST unchanged
- */
- public final Probe probe() {
-
- if (this instanceof WrapperNode) {
- throw new ProbeException(ProbeFailure.Reason.WRAPPER_NODE, null, this, null);
- }
-
- if (parent == null) {
- throw new ProbeException(ProbeFailure.Reason.NO_PARENT, null, this, null);
- }
-
- if (parent instanceof WrapperNode) {
- return ((WrapperNode) parent).getProbe();
- }
-
- if (!isInstrumentable()) {
- throw new ProbeException(ProbeFailure.Reason.NOT_INSTRUMENTABLE, parent, this, null);
- }
-
- // Create a new wrapper/probe with this node as its child.
- final WrapperNode wrapper = createWrapperNode();
-
- if (wrapper == null || !(wrapper instanceof Node)) {
- throw new ProbeException(ProbeFailure.Reason.NO_WRAPPER, parent, this, wrapper);
- }
-
- final Node wrapperNode = (Node) wrapper;
-
- if (!this.isSafelyReplaceableBy(wrapperNode)) {
- throw new ProbeException(ProbeFailure.Reason.WRAPPER_TYPE, parent, this, wrapper);
- }
-
- // Connect it to a Probe
- final Probe probe = ProbeNode.insertProbe(wrapper);
-
- // Replace this node in the AST with the wrapper
- this.replace(wrapperNode);
-
- return probe;
- }
-
- /**
- * Converts this node to a textual representation useful for debugging.
- */
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(getClass().getSimpleName());
- Map
- *
- */
- public static String printSyntaxTags(final Object node) {
- if (node instanceof WrapperNode) {
- final Probe probe = ((WrapperNode) node).getProbe();
- final Collectiontrue
if this {@link RootNode} is allowed to be cloned. The runtime
- * system might decide to create deep copies of the {@link RootNode} in order to gather context
- * sensitive profiling feedback. The default implementation returns false
. Guest
- * language specific implementations may want to return true
here to indicate that
- * gathering call site specific profiling information might make sense for this {@link RootNode}
- * .
- *
- * @return true
if cloning is allowed else false
.
- */
- public boolean isCloningAllowed() {
- return false;
- }
-
- /**
- * Reports the execution count of a loop that is a child of this node. The optimization
- * heuristics can use the loop count to guide compilation and inlining.
- */
- public final void reportLoopCount(int count) {
- if (getCallTarget() instanceof LoopCountReceiver) {
- ((LoopCountReceiver) getCallTarget()).reportLoopCount(count);
- }
- }
-
- /**
- * Executes this function using the specified frame and returns the result value.
- *
- * @param frame the frame of the currently executing guest language method
- * @return the value of the execution
- */
- public abstract Object execute(VirtualFrame frame);
-
- public final RootCallTarget getCallTarget() {
- return callTarget;
- }
-
- public final FrameDescriptor getFrameDescriptor() {
- return frameDescriptor;
- }
-
- public final void setCallTarget(RootCallTarget callTarget) {
- this.callTarget = callTarget;
- }
-
- /**
- * Returns the {@link ExecutionContext} associated with this RootNode
. This allows
- * the correct ExecutionContext
to be determined for a RootNode
(and
- * so also for a {@link RootCallTarget} and a {@link FrameInstance} obtained from the call
- * stack) without prior knowledge of the language it has come from.
- *
- * Used for instance to determine the language of a RootNode
:
- *
- *
- *
- *
- * Returns
- * rootNode.getExecutionContext().getLanguageShortName();
- *
null
by default.
- */
- public ExecutionContext getExecutionContext() {
- return null;
- }
-
- /**
- * Get compiler options specific to this RootNode
.
- */
- public CompilerOptions getCompilerOptions() {
- final ExecutionContext context = getExecutionContext();
-
- if (context == null) {
- return DefaultCompilerOptions.INSTANCE;
- } else {
- return context.getCompilerOptions();
- }
- }
-
- /**
- * Apply all registered instances of {@link ASTProber} to the AST, if any, held by this root
- * node. This can only be done once the AST is complete, notably once all parent pointers are
- * correctly assigned. But it also must be done before any AST cloning or execution.
- *
- *
- */
- public PostOrderDeserializer(SerializerConstantPool cp) {
- this.cp = cp;
- }
-
- /**
- * Deserializes the byte stream and returns the deserialized Truffle AST node.
- *
- * @param bytes the trimmed byte array containing the serialized data
- * @param expectedType the expected root node type. Throws an exception if the root node is not
- * assignable from this type.
- * @return the deserialized Truffle AST represented by the root Node.
- *
- * @throws UnsupportedConstantPoolTypeException thrown if a type is encountered that is not
- * supported by the constant pool implementation.
- */
- @SuppressWarnings("unchecked")
- public
- *
- */
- public PostOrderSerializer(SerializerConstantPool cp) {
- this.cp = cp;
- }
-
- /**
- * Serializes the node AST and returns the serialized data as byte array.
- *
- * @param node the root node that represents the Truffle AST that should be serialized.
- * @return a trimmed byte array that contains the serialized data.
- *
- * @throws UnsupportedConstantPoolTypeException thrown if a type is encountered that is not
- * supported by the constant pool implementation.
- */
- public byte[] serialize(Node node) throws UnsupportedConstantPoolTypeException {
- VariableLengthIntBuffer buffer = new VariableLengthIntBuffer(ByteBuffer.allocate(512));
- serialize(buffer, node);
- return buffer.getBytes();
- }
-
- private void serialize(VariableLengthIntBuffer buffer, Node node) throws UnsupportedConstantPoolTypeException {
- if (node == null) {
- buffer.put(VariableLengthIntBuffer.NULL);
- return;
- }
- Class extends Node> nodeClass = node.getClass();
-
- NodeFieldAccessor[] nodeFields = NodeClass.get(nodeClass).getFields();
- serializeChildFields(buffer, node, nodeFields);
- serializeChildrenFields(buffer, node, nodeFields);
- buffer.put(cp.putClass(node.getClass()));
- serializeDataFields(buffer, node, nodeFields);
- }
-
- private void serializeDataFields(VariableLengthIntBuffer buffer, Node node, NodeFieldAccessor[] nodeFields) throws UnsupportedConstantPoolTypeException {
- for (int i = 0; i < nodeFields.length; i++) {
- NodeFieldAccessor field = nodeFields[i];
- if (field.getKind() == NodeFieldKind.DATA) {
- Class> fieldClass = field.getType();
- long offset = field.getOffset();
- int cpi;
-
- if (field.getType().isAssignableFrom(SourceSection.class)) {
- continue;
- }
-
- if (fieldClass == int.class) {
- cpi = cp.putInt(unsafe.getInt(node, offset));
- } else if (fieldClass == long.class) {
- cpi = cp.putLong(unsafe.getLong(node, offset));
- } else if (fieldClass == float.class) {
- cpi = cp.putFloat(unsafe.getFloat(node, offset));
- } else if (fieldClass == double.class) {
- cpi = cp.putDouble(unsafe.getDouble(node, offset));
- } else if (fieldClass == byte.class) {
- cpi = cp.putInt(unsafe.getByte(node, offset));
- } else if (fieldClass == short.class) {
- cpi = cp.putInt(unsafe.getShort(node, offset));
- } else if (fieldClass == char.class) {
- cpi = cp.putInt(unsafe.getChar(node, offset));
- } else if (fieldClass == boolean.class) {
- cpi = cp.putInt(unsafe.getBoolean(node, offset) ? 1 : 0);
- } else {
- cpi = serializeDataFieldsObject(node, fieldClass, offset);
- }
-
- buffer.put(cpi);
- }
- }
- }
-
- private int serializeDataFieldsObject(Node node, Class> fieldClass, long offset) {
- Object value = unsafe.getObject(node, offset);
- if (value == null) {
- return VariableLengthIntBuffer.NULL;
- } else if (fieldClass == Integer.class) {
- return cp.putInt((Integer) value);
- } else if (fieldClass == Long.class) {
- return cp.putLong((Long) value);
- } else if (fieldClass == Float.class) {
- return cp.putFloat((Float) value);
- } else if (fieldClass == Double.class) {
- return cp.putDouble((Double) value);
- } else if (fieldClass == Byte.class) {
- return cp.putInt((Byte) value);
- } else if (fieldClass == Short.class) {
- return cp.putInt((Short) value);
- } else if (fieldClass == Character.class) {
- return cp.putInt((Character) value);
- } else if (fieldClass == Boolean.class) {
- return cp.putInt((Boolean) value ? 1 : 0);
- } else {
- return cp.putObject(fieldClass, value);
- }
- }
-
- private void serializeChildrenFields(VariableLengthIntBuffer buffer, Node nodeInstance, NodeFieldAccessor[] nodeFields) throws UnsupportedConstantPoolTypeException {
- for (int i = 0; i < nodeFields.length; i++) {
- NodeFieldAccessor field = nodeFields[i];
- if (field.getKind() == NodeFieldKind.CHILDREN) {
- Object childArrayObject = unsafe.getObject(nodeInstance, field.getOffset());
- if (childArrayObject != null && !(childArrayObject instanceof Node[])) {
- throw new AssertionError("Node children must be instanceof Node[]");
- }
-
- buffer.put(cp.putClass(field.getType()));
-
- Node[] childArray = (Node[]) childArrayObject;
- if (childArray == null) {
- buffer.put(VariableLengthIntBuffer.NULL);
- } else {
- buffer.put(cp.putInt(childArray.length));
-
- for (int j = 0; j < childArray.length; j++) {
- serialize(buffer, childArray[j]);
- }
- }
- }
- }
- }
-
- private void serializeChildFields(VariableLengthIntBuffer buffer, Node nodeInstance, NodeFieldAccessor[] nodeFields) throws UnsupportedConstantPoolTypeException {
- for (int i = 0; i < nodeFields.length; i++) {
- NodeFieldAccessor field = nodeFields[i];
- if (field.getKind() == NodeFieldKind.CHILD) {
- Object childObject = unsafe.getObject(nodeInstance, field.getOffset());
- if (childObject != null && !(childObject instanceof Node)) {
- throw new AssertionError("Node children must be instanceof Node");
- }
- serialize(buffer, (Node) childObject);
- }
- }
- }
-
- private static Unsafe loadUnsafe() {
- try {
- return Unsafe.getUnsafe();
- } catch (SecurityException e) {
- }
- try {
- Field theUnsafeInstance = Unsafe.class.getDeclaredField("theUnsafe");
- theUnsafeInstance.setAccessible(true);
- return (Unsafe) theUnsafeInstance.get(Unsafe.class);
- } catch (Exception e) {
- throw new RuntimeException("exception while trying to get Unsafe.theUnsafe via reflection:", e);
- }
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/SerializerConstantPool.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/SerializerConstantPool.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,152 +0,0 @@
-/*
- * 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. 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.nodes.serial;
-
-/**
- * Experimental API. May change without notice. This interface is used as bridge between the
- * {@link PostOrderDeserializer}, {@link PostOrderSerializer} and underlying constant pool
- * implementation. A constant pool stores a value and returns an identifying index, with which the
- * object can later be returned from the pool again. All methods of this class are optional and may
- * throw a {@link UnsupportedOperationException}.
- */
-public interface SerializerConstantPool {
-
- /**
- * Returns the constant pool index of a value that is not a java native type, a java
- * native-wrapper class or a {@link Class} instance. The implementor should support all
- * additional types that are necessary to serialize a truffle AST for a specific truffle
- * implementation. If a type is not supported by this constant pool implementation a
- * {@link UnsupportedConstantPoolTypeException} should be thrown.
- *
- * @param clazz the {@link Class} of the value
- * @param value the value to be stored. Must be at least a subclass of the given clazz.
- * @return the constant pool index
- * @throws UnsupportedConstantPoolTypeException if a type is not supported for persistence in
- * the constant pool.
- */
- int putObject(Class> clazz, Object value) throws UnsupportedConstantPoolTypeException;
-
- /**
- * Stores a value in the constant pool that is not a java native type, a java native-wrapper
- * class or a {@link Class} instance. The implementor should support all additional types that
- * are necessary to serialize a truffle AST for a specific truffle implementation. If a type is
- * not supported by this constant pool implementation a
- * {@link UnsupportedConstantPoolTypeException} should be thrown.
- *
- * @param clazz the {@link Class} of the value in the constant pool.
- * @param cpi the previously returned index
- * @return the value stored inside the constant pool
- * @throws UnsupportedConstantPoolTypeException if a type is not supported for persistence in
- * the constant pool.
- * @throws IllegalArgumentException if the provided cpi is not a valid constant pool index.
- */
- Object getObject(Class> clazz, int cpi) throws UnsupportedConstantPoolTypeException;
-
- /**
- * Stores a Class instance in the constant pool and returns the constant pool index.
- *
- * @param value the class to store
- * @return the new or existing constant pool index of the Class
- */
- int putClass(Class> value);
-
- /**
- * Returns the {@link Class} instance to the given constant pool index.
- *
- * @param cpi the constant pool index
- * @return stored value
- * @throws IllegalArgumentException if the constant pool indes is invalid.
- */
- Class> getClass(int cpi);
-
- /**
- * Stores an int value in the constant pool and returns the constant pool index.
- *
- * @param value the value to store
- * @return the new or existing constant pool index of the value
- */
- int putInt(int value);
-
- /**
- * Returns the stored int value to the given constant pool index from the constant pool.
- *
- * @param cpi the constant pool index
- * @return stored value
- * @throws IllegalArgumentException if the constant pool index is invalid.
- */
- int getInt(int cpi);
-
- /**
- * Stores a long value in the constant pool and returns the constant pool index.
- *
- * @param value the value to store
- * @return the new or existing constant pool index of the value
- */
- int putLong(long value);
-
- /**
- * Returns the stored long value to the given constant pool index from the constant pool.
- *
- * @param cpi the constant pool index
- * @return the stored value
- * @throws IllegalArgumentException if the constant pool index is invalid.
- */
- long getLong(int cpi);
-
- /**
- * Stores a double value in the constant pool and returns the constant pool index.
- *
- * @param value the value to store
- * @return the new or existing constant pool index of the value
- */
- int putDouble(double value);
-
- /**
- * Returns the stored double value to the given constant pool index from the constant pool.
- *
- * @param cpi the constant pool index
- * @return the stored value
- * @throws IllegalArgumentException if the constant pool index is invalid.
- */
- double getDouble(int cpi);
-
- /**
- * Stores a float value in the constant pool and returns the constant pool index.
- *
- * @param value the value to store
- * @return the new or existing constant pool index of the value
- */
- int putFloat(float value);
-
- /**
- * Returns the stored float value to the given constant pool index from the constant pool.
- *
- * @param cpi the constant pool index
- * @return the stored value
- * @throws IllegalArgumentException if the constant pool index is invalid.
- */
- float getFloat(int cpi);
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/UnsupportedConstantPoolTypeException.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/UnsupportedConstantPoolTypeException.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * 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. 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.nodes.serial;
-
-/**
- * Experimental API. May change without notice.
- */
-public class UnsupportedConstantPoolTypeException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
-
- public UnsupportedConstantPoolTypeException() {
- super();
- }
-
- public UnsupportedConstantPoolTypeException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public UnsupportedConstantPoolTypeException(String message) {
- super(message);
- }
-
- public UnsupportedConstantPoolTypeException(Throwable cause) {
- super(cause);
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/VariableLengthIntBuffer.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/VariableLengthIntBuffer.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/*
- * 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. 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.nodes.serial;
-
-import java.nio.*;
-
-/**
- * Experimental API. May change without notice. Simple variable length unsigned int buffer backed by
- * a byte buffer.
- */
-public class VariableLengthIntBuffer {
-
- public static final int NULL = -1;
-
- private ByteBuffer buffer;
-
- public VariableLengthIntBuffer(ByteBuffer buffer) {
- this.buffer = buffer;
- }
-
- public VariableLengthIntBuffer(byte[] array) {
- buffer = ByteBuffer.wrap(array);
- }
-
- /**
- * Returns the backing byte buffer.
- */
- public ByteBuffer getBuffer() {
- return buffer;
- }
-
- public byte[] getBytes() {
- int pos = buffer.position();
- byte[] bytes = new byte[buffer.position()];
- buffer.rewind();
- buffer.get(bytes);
- buffer.position(pos);
- return bytes;
- }
-
- public int get() {
- byte peekByte = buffer.get(buffer.position());
- if ((peekByte & 0x80) == 0) {
- // single byte encoding with prefix 0 (range 127)
- return buffer.get(); // no bit to be masked
- } else {
- if (peekByte == (byte) 0xFF) {
- buffer.get(); // skip one byte
- return NULL;
- }
- int result = buffer.getInt() & 0x7FFF_FFFF; // first bit masked out
- assert (result & 0x4000_0000) == 0;
- return result;
- }
- }
-
- public void put(int i) {
- ensureCapacity();
- if (i == NULL) {
- buffer.put((byte) 0xFF);
- } else if ((i & 0xFFFF_FF80) == 0) { // 7 bits data
- buffer.put((byte) i);
- } else if ((i & 0xC000_0000) == 0) { // 32 bits data
- buffer.putInt(i | 0x8000_0000); // append leading 1
- } else {
- throw new IllegalArgumentException("Integer out of encodeable " + i);
- }
- }
-
- private void ensureCapacity() {
- if (buffer.position() + 4 > buffer.capacity()) {
- ByteBuffer newBuffer = ByteBuffer.allocate(buffer.capacity() * 2);
-
- int pos = buffer.position();
- buffer.rewind();
- newBuffer.put(buffer);
- newBuffer.position(pos);
-
- buffer = newBuffer;
- }
- }
-
- public boolean hasRemaining() {
- return buffer.hasRemaining();
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/script/TruffleScriptEngineFactory.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/script/TruffleScriptEngineFactory.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * 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 final void engineCreated(ScriptEngine engine) {
- }
-
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/BytesDecoder.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/source/BytesDecoder.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * 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.source;
-
-import java.nio.charset.*;
-import java.util.*;
-
-/**
- * For a language where strings do not map into Java strings, provides utilities to find line
- * endings and to decode raw bytes into an approximate representation for tools to display.
- *
- *
- *
- * See {@link Source#fromText(CharSequence, String)}
- * See {@link Source#fromNamedText(CharSequence, String)}
- * See {@link Source#find(String)}
- * See {@link Source#fromFileName(String)}
- * See {@link Source#fromFileName(String, boolean)}
- * See {@link Source#find(String)}
- * See {@link Source#fromURL(URL, String)}
- * See {@link Source#find(String)}
- * See {@link Source#fromReader(Reader, String)}
- * See @link {@link Source#subSource(Source, int, int)}
- * See @link {@link Source#subSource(Source, int)}
- * See {@link Source#fromAppendableText(String)}
- * See {@link Source#fromNamedAppendableText(String)}
- *
- *
- *
- * The newline that terminates each line counts as a single character for the purpose
- * of a character index. The (row,column) coordinates of a newline character should never
- * appear in a text section.
- *
- *
- *
- *
- */
- private static final class TextMap {
-
- // 0-based offsets of newline characters in the text, with sentinel
- private final int[] nlOffsets;
-
- // The number of characters in the text, including newlines (which count as 1).
- private final int textLength;
-
- // Is the final text character a newline?
- final boolean finalNL;
-
- public TextMap(int[] nlOffsets, int textLength, boolean finalNL) {
- this.nlOffsets = nlOffsets;
- this.textLength = textLength;
- this.finalNL = finalNL;
- }
-
- /**
- * Constructs map permitting translation between 0-based character offsets and 1-based
- * lines/columns.
- */
- public static TextMap fromString(String text) {
- final int textLength = text.length();
- final ArrayList
- * private final ConditionProfile zero = ConditionProfile.createBinaryProfile();
- *
- * int value = ...;
- * if (zero.profile(value == 0)) {
- * return 0;
- * } else {
- * return value;
- * }
- *
- *
- *
- * All instances of {@code ConditionProfile} (and subclasses) must be held in {@code final} fields
- * for compiler optimizations to take effect.
- *
- * @see #createCountingProfile()
- * @see #createBinaryProfile()
- */
-public abstract class ConditionProfile extends NodeCloneable {
- ConditionProfile() {
- }
-
- public abstract boolean profile(boolean value);
-
- /**
- * Returns a {@link ConditionProfile} that speculates on conditions to be never
- * true
or to be never false
. Additionally to a binary profile this
- * method returns a condition profile that also counts the number of times the condition was
- * true and false. This information is reported to the underlying optimization system using
- * {@link CompilerDirectives#injectBranchProbability(double, boolean)}. Condition profiles are
- * intended to be used as part of if conditions.
- *
- * @see ConditionProfile
- * @see #createBinaryProfile()
- */
- public static ConditionProfile createCountingProfile() {
- return new CountingConditionProfile();
- }
-
- /**
- * Returns a {@link ConditionProfile} that speculates on conditions to be never true or to be
- * never false. Condition profiles are intended to be used as part of if conditions.
- *
- * @see ConditionProfile
- * @see ConditionProfile#createCountingProfile()
- */
- public static ConditionProfile createBinaryProfile() {
- return new BinaryConditionProfile();
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CountingConditionProfile.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CountingConditionProfile.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * 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.utilities;
-
-import com.oracle.truffle.api.*;
-import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
-
-/**
- * Utility class to speculate on conditions to be never true or to be never false. Additionally to
- * {@link BinaryConditionProfile} this implementation of {@link ConditionProfile} also counts the
- * number of times the condition was true and false. This information is reported to the underlying
- * optimization system using {@link CompilerDirectives#injectBranchProbability(double, boolean)}.
- * Condition profiles are intended to be used as part of if conditions.
- *
- * @see ConditionProfile#createCountingProfile()
- */
-public final class CountingConditionProfile extends ConditionProfile {
-
- @CompilationFinal private int trueCount;
- @CompilationFinal private int falseCount;
-
- CountingConditionProfile() {
- /* package protected constructor */
- }
-
- @Override
- public boolean profile(boolean value) {
- if (value) {
- if (trueCount == 0) {
- CompilerDirectives.transferToInterpreterAndInvalidate();
- }
- if (CompilerDirectives.inInterpreter()) {
- trueCount++;
- }
- } else {
- if (falseCount == 0) {
- CompilerDirectives.transferToInterpreterAndInvalidate();
- }
- if (CompilerDirectives.inInterpreter()) {
- falseCount++;
- }
- }
- return CompilerDirectives.injectBranchProbability((double) trueCount / (double) (trueCount + falseCount), value);
- }
-
- public int getTrueCount() {
- return trueCount;
- }
-
- public int getFalseCount() {
- return falseCount;
- }
-
- @Override
- public String toString() {
- return String.format("%s(trueCount=%s, falseCount=%s)@%x", getClass().getSimpleName(), trueCount, falseCount, hashCode());
- }
-}
diff -r 861108f5408e -r 964677af4a3c graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CyclicAssumption.java
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/utilities/CyclicAssumption.java Tue Jun 16 16:30:34 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 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
- * 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.utilities;
-
-import java.util.concurrent.atomic.*;
-
-import com.oracle.truffle.api.*;
-
-/**
- * Holds an {@link Assumption}, and knows how to recreate it with the same properties on
- * invalidation. Used so that mutability is isolated in this class, and all other classes that need
- * an assumption that may be recreated can have a final reference to an object of this class. Note
- * that you should be careful that repeated invalidations do not cause a deoptimization loop in that
- * same way that you would with any other assumption.
- */
-public class CyclicAssumption {
-
- private final String name;
- private final AtomicReference