Mercurial > hg > truffle
annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java @ 22298:e2e5168618fc
FrameDescriptor.findFrameSlot() should not be called in compiled code.
author | Benoit Daloze <benoit.daloze@jku.at> |
---|---|
date | Sat, 10 Oct 2015 12:25:47 +0200 |
parents | dc83cc1f94f2 |
children | 079cd9183128 |
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:
9952
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:
9952
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:
9952
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.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
|
26 |
22157
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
27 import com.oracle.truffle.api.Assumption; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
28 import com.oracle.truffle.api.CompilerAsserts; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
29 import com.oracle.truffle.api.Truffle; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
30 import java.util.ArrayList; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
31 import java.util.Collections; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
32 import java.util.HashMap; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
33 import java.util.List; |
dc83cc1f94f2
Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
21966
diff
changeset
|
34 import java.util.Set; |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
35 |
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
|
36 /** |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
37 * Descriptor of the slots of frame objects. Multiple frame instances are associated with one such |
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
38 * descriptor. |
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 */ |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
40 public final class FrameDescriptor implements Cloneable { |
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
|
41 |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
42 private final Object defaultValue; |
12644
e122dc0436be
convert FrameSlot interface to a final class.
Andreas Woess <andreas.woess@jku.at>
parents:
11810
diff
changeset
|
43 private final ArrayList<FrameSlot> slots; |
e122dc0436be
convert FrameSlot interface to a final class.
Andreas Woess <andreas.woess@jku.at>
parents:
11810
diff
changeset
|
44 private final HashMap<Object, FrameSlot> identifierToSlotMap; |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
45 private Assumption version; |
11810
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
46 private HashMap<Object, Assumption> identifierToNotInFrameAssumptionMap; |
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
|
47 |
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
|
48 public FrameDescriptor() { |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
49 this(null); |
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 } |
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 |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
52 public FrameDescriptor(Object defaultValue) { |
21966
5023b913e2ba
Help the partial evaluator / language developer by marking API methods as neverPartOfCompilation() when they are too complicated to be compiled.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
21951
diff
changeset
|
53 CompilerAsserts.neverPartOfCompilation(); |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
54 this.defaultValue = defaultValue; |
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
|
55 slots = new ArrayList<>(); |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
56 identifierToSlotMap = new HashMap<>(); |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
57 version = createVersion(); |
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
|
58 } |
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 |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
60 public static FrameDescriptor create() { |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
61 return new FrameDescriptor(); |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
62 } |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
63 |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
64 public static FrameDescriptor create(Object defaultValue) { |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
65 return new FrameDescriptor(defaultValue); |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
66 } |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
67 |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
68 public FrameSlot addFrameSlot(Object identifier) { |
16727
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
69 return addFrameSlot(identifier, null, FrameSlotKind.Illegal); |
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
|
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 |
9321
cd1a1d92b3e3
Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents:
9258
diff
changeset
|
72 public FrameSlot addFrameSlot(Object identifier, FrameSlotKind kind) { |
16727
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
73 return addFrameSlot(identifier, null, kind); |
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
74 } |
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
75 |
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
76 public FrameSlot addFrameSlot(Object identifier, Object info, FrameSlotKind kind) { |
16051
da9b9b625818
Truffle FrameDescriptor: add compiler asserts
Bernhard Urban <bernhard.urban@jku.at>
parents:
13875
diff
changeset
|
77 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
78 assert !identifierToSlotMap.containsKey(identifier); |
16727
9d55732d0880
additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16051
diff
changeset
|
79 FrameSlot slot = new FrameSlot(this, identifier, info, slots.size(), kind); |
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
|
80 slots.add(slot); |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
81 identifierToSlotMap.put(identifier, slot); |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
82 updateVersion(); |
11810
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
83 invalidateNotInFrameAssumption(identifier); |
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
|
84 return slot; |
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
|
85 } |
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
|
86 |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
87 public FrameSlot findFrameSlot(Object identifier) { |
22298
e2e5168618fc
FrameDescriptor.findFrameSlot() should not be called in compiled code.
Benoit Daloze <benoit.daloze@jku.at>
parents:
22157
diff
changeset
|
88 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
89 return identifierToSlotMap.get(identifier); |
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
|
90 } |
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
|
91 |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
92 public FrameSlot findOrAddFrameSlot(Object identifier) { |
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
93 FrameSlot result = findFrameSlot(identifier); |
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
|
94 if (result != null) { |
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
|
95 return result; |
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
|
96 } |
7722
f07cafa29db1
Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7530
diff
changeset
|
97 return addFrameSlot(identifier); |
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
|
98 } |
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
|
99 |
9321
cd1a1d92b3e3
Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents:
9258
diff
changeset
|
100 public FrameSlot findOrAddFrameSlot(Object identifier, FrameSlotKind kind) { |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
101 FrameSlot result = findFrameSlot(identifier); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
102 if (result != null) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
103 return result; |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
104 } |
9321
cd1a1d92b3e3
Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents:
9258
diff
changeset
|
105 return addFrameSlot(identifier, kind); |
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
|
106 } |
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
|
107 |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
108 public FrameSlot findOrAddFrameSlot(Object identifier, Object info, FrameSlotKind kind) { |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
109 FrameSlot result = findFrameSlot(identifier); |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
110 if (result != null) { |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
111 return result; |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
112 } |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
113 return addFrameSlot(identifier, info, kind); |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
114 } |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
115 |
13875
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
116 public void removeFrameSlot(Object identifier) { |
16051
da9b9b625818
Truffle FrameDescriptor: add compiler asserts
Bernhard Urban <bernhard.urban@jku.at>
parents:
13875
diff
changeset
|
117 CompilerAsserts.neverPartOfCompilation("interpreter-only. includes hashmap operations."); |
13875
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
118 assert identifierToSlotMap.containsKey(identifier); |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
119 slots.remove(identifierToSlotMap.get(identifier)); |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
120 identifierToSlotMap.remove(identifier); |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
121 updateVersion(); |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
122 getNotInFrameAssumption(identifier); |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
123 } |
042a2d972174
support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents:
12644
diff
changeset
|
124 |
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
|
125 public int getSize() { |
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
|
126 return slots.size(); |
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
|
127 } |
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
|
128 |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7267
diff
changeset
|
129 public List<? extends FrameSlot> getSlots() { |
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
|
130 return Collections.unmodifiableList(slots); |
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
|
131 } |
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
|
132 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
133 /** |
11808
0c4d7b468dd7
include isValid in Assumption.toString(); minor javadoc fix.
Andreas Woess <andreas.woess@jku.at>
parents:
11343
diff
changeset
|
134 * Retrieve the list of all the identifiers associated with this frame descriptor. |
16051
da9b9b625818
Truffle FrameDescriptor: add compiler asserts
Bernhard Urban <bernhard.urban@jku.at>
parents:
13875
diff
changeset
|
135 * |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
136 * @return the list of all the identifiers in this frame descriptor |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
137 */ |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
138 public Set<Object> getIdentifiers() { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
139 return Collections.unmodifiableSet(identifierToSlotMap.keySet()); |
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
|
140 } |
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
|
141 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
142 public FrameDescriptor copy() { |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
143 FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
144 for (int i = 0; i < this.getSlots().size(); i++) { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
145 Object identifier = this.getSlots().get(i).getIdentifier(); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
146 clonedFrameDescriptor.addFrameSlot(identifier); |
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
|
147 } |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
148 return clonedFrameDescriptor; |
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
|
149 } |
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
|
150 |
9952
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
151 public FrameDescriptor shallowCopy() { |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
152 FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue); |
9952
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
153 clonedFrameDescriptor.slots.addAll(slots); |
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
154 clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap); |
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
155 return clonedFrameDescriptor; |
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
156 } |
5d91b0b67cba
Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
9521
diff
changeset
|
157 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
158 void updateVersion() { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
159 version.invalidate(); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
160 version = createVersion(); |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
161 } |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
162 |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
163 public Assumption getVersion() { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
164 return version; |
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
|
165 } |
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
|
166 |
9258
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
167 private static Assumption createVersion() { |
07f8d136a05e
Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
7722
diff
changeset
|
168 return Truffle.getRuntime().createAssumption("frame version"); |
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
|
169 } |
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
|
170 |
18161
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
171 public Object getDefaultValue() { |
94f16a759646
Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents:
16727
diff
changeset
|
172 return defaultValue; |
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
|
173 } |
11810
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
174 |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
175 public Assumption getNotInFrameAssumption(Object identifier) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
176 if (identifierToSlotMap.containsKey(identifier)) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
177 throw new IllegalArgumentException("Cannot get not-in-frame assumption for existing frame slot!"); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
178 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
179 |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
180 if (identifierToNotInFrameAssumptionMap == null) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
181 identifierToNotInFrameAssumptionMap = new HashMap<>(); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
182 } else { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
183 Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
184 if (assumption != null) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
185 return assumption; |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
186 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
187 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
188 Assumption assumption = Truffle.getRuntime().createAssumption("not in frame: " + identifier); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
189 identifierToNotInFrameAssumptionMap.put(identifier, assumption); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
190 return assumption; |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
191 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
192 |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
193 private void invalidateNotInFrameAssumption(Object identifier) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
194 if (identifierToNotInFrameAssumptionMap != null) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
195 Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
196 if (assumption != null) { |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
197 assumption.invalidate(); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
198 identifierToNotInFrameAssumptionMap.remove(identifier); |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
199 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
200 } |
91a676d0bbbe
Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents:
11808
diff
changeset
|
201 } |
20818
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
202 |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
203 @Override |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
204 public String toString() { |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
205 StringBuilder sb = new StringBuilder(); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
206 sb.append("FrameDescriptor@").append(Integer.toHexString(hashCode())); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
207 sb.append("{"); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
208 boolean comma = false; |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
209 for (FrameSlot slot : slots) { |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
210 if (comma) { |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
211 sb.append(", "); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
212 } else { |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
213 comma = true; |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
214 } |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
215 sb.append(slot.getIndex()).append(":").append(slot.getIdentifier()); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
216 } |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
217 sb.append("}"); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
218 return sb.toString(); |
79d212bfee22
Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents:
18161
diff
changeset
|
219 } |
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
|
220 } |