annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java @ 22157:dc83cc1f94f2

Using fully qualified imports
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 16 Sep 2015 11:33:22 +0200
parents c6966c8ea83c
children a63bda98cfdb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
11279
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9258
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9258
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9258
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * accompanied this code).
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 * questions.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 */
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.impl;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
27 import com.oracle.truffle.api.Assumption;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
28 import com.oracle.truffle.api.CallTarget;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
29 import com.oracle.truffle.api.CompilerOptions;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
30 import com.oracle.truffle.api.RootCallTarget;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
31 import com.oracle.truffle.api.Truffle;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
32 import com.oracle.truffle.api.TruffleRuntime;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
33 import com.oracle.truffle.api.frame.FrameDescriptor;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
34 import com.oracle.truffle.api.frame.FrameInstance;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
35 import com.oracle.truffle.api.frame.FrameInstanceVisitor;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
36 import com.oracle.truffle.api.frame.MaterializedFrame;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
37 import com.oracle.truffle.api.frame.VirtualFrame;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
38 import com.oracle.truffle.api.nodes.DirectCallNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
39 import com.oracle.truffle.api.nodes.IndirectCallNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
40 import com.oracle.truffle.api.nodes.LoopNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
41 import com.oracle.truffle.api.nodes.Node;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
42 import com.oracle.truffle.api.nodes.RepeatingNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
43 import com.oracle.truffle.api.nodes.RootNode;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
44 import java.util.Collection;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
45 import java.util.Collections;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
46 import java.util.LinkedList;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
47 import java.util.Map;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22097
diff changeset
48 import java.util.WeakHashMap;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
51 * Default implementation of the Truffle runtime if the virtual machine does not provide a better
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
52 * performing alternative.
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
53 * <p>
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
54 * This is an implementation-specific class. Do not use or instantiate it. Instead, use
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
55 * {@link Truffle#getRuntime()} to retrieve the current {@link TruffleRuntime}.
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 */
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 public final class DefaultTruffleRuntime implements TruffleRuntime {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58
18870
c65f549c4015 DefaultTruffleRuntime fields can be final
Andreas Woess <andreas.woess@jku.at>
parents: 18485
diff changeset
59 private final ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>();
c65f549c4015 DefaultTruffleRuntime fields can be final
Andreas Woess <andreas.woess@jku.at>
parents: 18485
diff changeset
60 private final ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>();
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
61 private final Map<RootCallTarget, Void> callTargets = Collections.synchronizedMap(new WeakHashMap<RootCallTarget, Void>());
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
62
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
63 public DefaultTruffleRuntime() {
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
64 }
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
65
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 @Override
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 public String getName() {
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 return "Default Truffle Runtime";
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 @Override
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13705
diff changeset
72 public RootCallTarget createCallTarget(RootNode rootNode) {
17149
0a35e2789735 Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents: 17036
diff changeset
73 DefaultCallTarget target = new DefaultCallTarget(rootNode);
19703
48eeda5dfdbf Move linking of RootNode to CallTarget to ensure final semantics.
Benoit Daloze <benoit.daloze@jku.at>
parents: 19311
diff changeset
74 rootNode.setCallTarget(target);
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
75 callTargets.put(target, null);
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
76 return target;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 }
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
78
15093
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
79 public DirectCallNode createDirectCallNode(CallTarget target) {
17149
0a35e2789735 Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents: 17036
diff changeset
80 return new DefaultDirectCallNode(target);
15093
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
81 }
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
82
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
83 public IndirectCallNode createIndirectCallNode() {
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
84 return new DefaultIndirectCallNode();
13983
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13760
diff changeset
85 }
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13760
diff changeset
86
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
87 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
88 public VirtualFrame createVirtualFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
89 return new DefaultVirtualFrame(frameDescriptor, arguments);
11934
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
90 }
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
91
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
92 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
93 public MaterializedFrame createMaterializedFrame(Object[] arguments) {
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
94 return createMaterializedFrame(arguments, new FrameDescriptor());
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
95 }
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
96
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
97 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
98 public MaterializedFrame createMaterializedFrame(Object[] arguments, FrameDescriptor frameDescriptor) {
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
99 return new DefaultMaterializedFrame(new DefaultVirtualFrame(frameDescriptor, arguments));
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
100 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
101
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
102 @Override
18386
656331a61829 Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents: 18220
diff changeset
103 public CompilerOptions createCompilerOptions() {
656331a61829 Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents: 18220
diff changeset
104 return new DefaultCompilerOptions();
656331a61829 Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents: 18220
diff changeset
105 }
656331a61829 Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents: 18220
diff changeset
106
656331a61829 Truffle: add support for setting a couple of compiler options for individual execution contexts.
Chris Seaton <chris.seaton@oracle.com>
parents: 18220
diff changeset
107 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
108 public Assumption createAssumption() {
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
109 return createAssumption(null);
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
110 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
111
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
112 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
113 public Assumption createAssumption(String name) {
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
114 return new DefaultAssumption(name);
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
115 }
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
116
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
117 private LinkedList<FrameInstance> getThreadLocalStackTrace() {
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
118 LinkedList<FrameInstance> result = stackTraces.get();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
119 if (result == null) {
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
120 result = new LinkedList<>();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
121 stackTraces.set(result);
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
122 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
123 return result;
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
124 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
125
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
126 public FrameInstance setCurrentFrame(FrameInstance newValue) {
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
127 FrameInstance oldValue = currentFrames.get();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
128 currentFrames.set(newValue);
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
129 return oldValue;
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
130 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
131
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
132 public void pushFrame(FrameInstance frame) {
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
133 getThreadLocalStackTrace().addFirst(frame);
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
134 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
135
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
136 public void popFrame() {
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
137 getThreadLocalStackTrace().removeFirst();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
138 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
139
16529
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
140 @Override
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
141 public <T> T iterateFrames(FrameInstanceVisitor<T> visitor) {
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
142 T result = null;
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
143 for (FrameInstance frameInstance : getThreadLocalStackTrace()) {
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
144 result = visitor.visitFrame(frameInstance);
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
145 if (result != null) {
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
146 return result;
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
147 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
148 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
149 return result;
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
150 }
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
151
16529
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
152 @Override
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
153 public FrameInstance getCallerFrame() {
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
154 return getThreadLocalStackTrace().peekFirst();
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
155 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
156
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
157 @Override
17036
7b45e33b7986 Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
158 public Collection<RootCallTarget> getCallTargets() {
7b45e33b7986 Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents: 16992
diff changeset
159 return Collections.unmodifiableSet(callTargets.keySet());
16992
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
160 }
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
161
5a1d764f6afc Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents: 16916
diff changeset
162 @Override
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
163 public FrameInstance getCurrentFrame() {
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
164 return currentFrames.get();
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
165 }
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
166
18220
890d284b2771 Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents: 17149
diff changeset
167 public <T> T getCapability(Class<T> capability) {
890d284b2771 Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents: 17149
diff changeset
168 return null;
890d284b2771 Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents: 17149
diff changeset
169 }
890d284b2771 Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents: 17149
diff changeset
170
16535
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
171 public void notifyTransferToInterpreter() {
ada0a7729b6f Truffle: introduce debug option to print the stack trace when transferring to the interpreter
Andreas Woess <andreas.woess@jku.at>
parents: 16529
diff changeset
172 }
16916
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
173
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
174 public LoopNode createLoopNode(RepeatingNode repeating) {
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
175 if (!(repeating instanceof Node)) {
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
176 throw new IllegalArgumentException("Repeating node must be of type Node.");
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
177 }
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
178 return new DefaultLoopNode(repeating);
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
179 }
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 }