annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java @ 16916:534a87f866dc

Truffle: new experimental LoopNode API.
author Christian Humer <christian.humer@gmail.com>
date Sat, 23 Aug 2014 19:31:40 +0200
parents ada0a7729b6f
children 5a1d764f6afc
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
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
27 import java.util.*;
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
28
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
29 import com.oracle.truffle.api.*;
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
30 import com.oracle.truffle.api.frame.*;
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
31 import com.oracle.truffle.api.nodes.*;
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
32
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
33 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
34 * 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
35 * 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
36 * <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
37 * 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
38 * {@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
39 */
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
40 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
41
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
42 private ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
43 private ThreadLocal<FrameInstance> currentFrames = new ThreadLocal<>();
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
44
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
45 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
46 if (Truffle.getRuntime() != null) {
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
47 throw new IllegalArgumentException("Cannot instantiate DefaultTruffleRuntime. Use Truffle.getRuntime() instead.");
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
48 }
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
49 }
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
50
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
51 @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
52 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
53 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
54 }
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
55
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 @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
57 public RootCallTarget createCallTarget(RootNode rootNode) {
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
58 return new DefaultCallTarget(rootNode, this);
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
59 }
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
60
15093
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
61 public DirectCallNode createDirectCallNode(CallTarget target) {
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 return new DefaultDirectCallNode(target, this);
15093
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
63 }
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
64
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
65 public IndirectCallNode createIndirectCallNode() {
5634b199c4da Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents: 15064
diff changeset
66 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
67 }
f46cab39a9a2 Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents: 13760
diff changeset
68
7712
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
69 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
70 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
71 return new DefaultVirtualFrame(frameDescriptor, arguments);
11934
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
72 }
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
73
dca16d6f9d65 TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents: 11279
diff changeset
74 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
75 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
76 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
77 }
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
78
0a346c23cbd5 Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
79 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13983
diff changeset
80 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
81 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
82 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
83
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
84 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
85 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
86 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
87 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
88
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
89 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7712
diff changeset
90 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
91 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
92 }
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
93
15564
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
94 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
95 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
96 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
97 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
98 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
99 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
100 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
101 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
102
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
103 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
104 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
105 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
106 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
107 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
108
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
109 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
110 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
111 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
112
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
113 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
114 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
115 }
a3b0ecef8a15 Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 15093
diff changeset
116
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
117 @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
118 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
119 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
120 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
121 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
122 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
123 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
124 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
125 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
126 return result;
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
127 }
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
128
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
129 @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
130 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
131 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
132 }
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
133
f6ac86d3334e Change API for stack walking to a visitor: TruffleRuntime#iterateFrames replaces TruffleRuntime#getStackTrace
Christian Wimmer <christian.wimmer@oracle.com>
parents: 15564
diff changeset
134 @Override
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
135 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
136 return currentFrames.get();
15064
f675818d9ad0 new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents: 14991
diff changeset
137 }
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
138
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
139 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
140 }
16916
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
141
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
142 public LoopNode createLoopNode(RepeatingNode repeating) {
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
143 if (!(repeating instanceof Node)) {
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
144 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
145 }
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
146 return new DefaultLoopNode(repeating);
534a87f866dc Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents: 16535
diff changeset
147 }
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
148 }