Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultTruffleRuntime.java @ 20131:4b12d5355811
Truffle: do not use iterators for visitors.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 02 Apr 2015 01:27:27 +0200 |
parents | 48eeda5dfdbf |
children |
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.*; |
19311
b54b548047ac
Truffle: also offer UnsafeAccessFactory in DefaultTruffleRuntime
Andreas Woess <andreas.woess@jku.at>
parents:
18961
diff
changeset
|
32 import com.oracle.truffle.api.unsafe.*; |
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
|
33 |
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
|
34 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
35 * 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
|
36 * 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
|
37 * <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
|
38 * 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
|
39 * {@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
|
40 */ |
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 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
|
42 |
18870
c65f549c4015
DefaultTruffleRuntime fields can be final
Andreas Woess <andreas.woess@jku.at>
parents:
18485
diff
changeset
|
43 private final ThreadLocal<LinkedList<FrameInstance>> stackTraces = new ThreadLocal<>(); |
c65f549c4015
DefaultTruffleRuntime fields can be final
Andreas Woess <andreas.woess@jku.at>
parents:
18485
diff
changeset
|
44 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
|
45 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
|
46 |
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
|
47 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
|
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 |
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
|
50 @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
|
51 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
|
52 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
|
53 } |
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 @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
|
56 public RootCallTarget createCallTarget(RootNode rootNode) { |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
17036
diff
changeset
|
57 DefaultCallTarget target = new DefaultCallTarget(rootNode); |
19710
48eeda5dfdbf
Move linking of RootNode to CallTarget to ensure final semantics.
Benoit Daloze <benoit.daloze@jku.at>
parents:
19311
diff
changeset
|
58 rootNode.setCallTarget(target); |
16992
5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents:
16916
diff
changeset
|
59 callTargets.put(target, null); |
5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents:
16916
diff
changeset
|
60 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
|
61 } |
7712
0a346c23cbd5
Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
62 |
15093
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
63 public DirectCallNode createDirectCallNode(CallTarget target) { |
17149
0a35e2789735
Truffle: remove unnecessary DefaultTruffleRuntime fields
Andreas Woess <andreas.woess@jku.at>
parents:
17036
diff
changeset
|
64 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
|
65 } |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
66 |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
67 public IndirectCallNode createIndirectCallNode() { |
5634b199c4da
Truffle: API-change: renamed CallNode to DirectCallNode and added IndirectCallNode.
Christian Humer <christian.humer@gmail.com>
parents:
15064
diff
changeset
|
68 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
|
69 } |
f46cab39a9a2
Truffle: Updated inlining API. Pushed inlining implementation to the Truffle runtime.
Christian Humer <christian.humer@gmail.com>
parents:
13760
diff
changeset
|
70 |
7712
0a346c23cbd5
Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
71 @Override |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13983
diff
changeset
|
72 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
|
73 return new DefaultVirtualFrame(frameDescriptor, arguments); |
11934
dca16d6f9d65
TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents:
11279
diff
changeset
|
74 } |
dca16d6f9d65
TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents:
11279
diff
changeset
|
75 |
dca16d6f9d65
TruffleRuntime.createVirtualFrame.
Chris Seaton <chris.seaton@oracle.com>
parents:
11279
diff
changeset
|
76 @Override |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13983
diff
changeset
|
77 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
|
78 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
|
79 } |
0a346c23cbd5
Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
80 |
0a346c23cbd5
Add ability to create materialized frame to Truffle runtime.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
81 @Override |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
13983
diff
changeset
|
82 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
|
83 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
|
84 } |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
85 |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
86 @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
|
87 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
|
88 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
|
89 } |
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
|
90 |
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
|
91 @Override |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
92 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
|
93 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
|
94 } |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
95 |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
96 @Override |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7712
diff
changeset
|
97 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
|
98 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
|
99 } |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
100 |
15564
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
107 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
|
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 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
110 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
|
111 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
|
112 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
|
113 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
|
114 } |
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 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
|
117 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
|
118 } |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
119 |
a3b0ecef8a15
Truffle: Provide default implementation on non-Graal VMs for stack trace functionality.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
15093
diff
changeset
|
120 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
|
121 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
|
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 |
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
|
124 @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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 } |
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 return result; |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
134 } |
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
135 |
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
|
136 @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
|
137 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
|
138 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
|
139 } |
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 |
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 @Override |
17036
7b45e33b7986
Truffle: made TruffleRuntime#getCallTargets return a Collection and simplified its implementation.
Christian Humer <christian.humer@gmail.com>
parents:
16992
diff
changeset
|
142 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
|
143 return Collections.unmodifiableSet(callTargets.keySet()); |
16992
5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents:
16916
diff
changeset
|
144 } |
5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents:
16916
diff
changeset
|
145 |
5a1d764f6afc
Truffle: added support for Runtime#getCallTargets()
Christian Humer <christian.humer@gmail.com>
parents:
16916
diff
changeset
|
146 @Override |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
147 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
|
148 return currentFrames.get(); |
15064
f675818d9ad0
new getStackTrace and getCurrentFrame functionality in TruffleRuntime
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14991
diff
changeset
|
149 } |
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
|
150 |
18220
890d284b2771
Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents:
17149
diff
changeset
|
151 public <T> T getCapability(Class<T> capability) { |
19311
b54b548047ac
Truffle: also offer UnsafeAccessFactory in DefaultTruffleRuntime
Andreas Woess <andreas.woess@jku.at>
parents:
18961
diff
changeset
|
152 if (capability == UnsafeAccessFactory.class) { |
b54b548047ac
Truffle: also offer UnsafeAccessFactory in DefaultTruffleRuntime
Andreas Woess <andreas.woess@jku.at>
parents:
18961
diff
changeset
|
153 return capability.cast(new UnsafeAccessFactoryImpl()); |
b54b548047ac
Truffle: also offer UnsafeAccessFactory in DefaultTruffleRuntime
Andreas Woess <andreas.woess@jku.at>
parents:
18961
diff
changeset
|
154 } |
18220
890d284b2771
Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents:
17149
diff
changeset
|
155 return null; |
890d284b2771
Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents:
17149
diff
changeset
|
156 } |
890d284b2771
Truffle: add TruffleRuntime#getCapability method
Andreas Woess <andreas.woess@jku.at>
parents:
17149
diff
changeset
|
157 |
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
|
158 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
|
159 } |
16916
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
160 |
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
161 public LoopNode createLoopNode(RepeatingNode repeating) { |
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
162 if (!(repeating instanceof Node)) { |
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
163 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
|
164 } |
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
165 return new DefaultLoopNode(repeating); |
534a87f866dc
Truffle: new experimental LoopNode API.
Christian Humer <christian.humer@gmail.com>
parents:
16535
diff
changeset
|
166 } |
18485
e3c95cbbb50c
Truffle Instrumentation: major API revision, based around the Probe and Instrument classes; add Instrumentable API for language implementors, with most details automated; reimplemented to handle AST splitting automatically; more JUnit tests.
Michael Van De Vanter <michael.van.de.vanter@oracle.com>
parents:
18386
diff
changeset
|
167 |
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
|
168 } |