annotate truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/frame/FrameDescriptor.java @ 22548:6b76a24fffbd default tip

Use all variables: a, b, u,v and x, y
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Thu, 14 Jan 2016 14:20:57 +0100
parents cda3eebfa777
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
11279
494b818b527c Adding "Classpath" exception to the classes in the com.oracle.truffle.api and the com.oracle.truffle.api.dsl package.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 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 java.util.ArrayList;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21966
diff changeset
28 import java.util.Collections;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21966
diff changeset
29 import java.util.HashMap;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21966
diff changeset
30 import java.util.List;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21966
diff changeset
31 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
32
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
33 import com.oracle.truffle.api.Assumption;
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
34 import com.oracle.truffle.api.CompilerAsserts;
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
35 import com.oracle.truffle.api.Truffle;
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
36
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
37 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
38 * 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
39 * 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
40 */
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
41 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
42
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
43 private final Object defaultValue;
12644
e122dc0436be convert FrameSlot interface to a final class.
Andreas Woess <andreas.woess@jku.at>
parents: 11810
diff changeset
44 private final ArrayList<FrameSlot> slots;
e122dc0436be convert FrameSlot interface to a final class.
Andreas Woess <andreas.woess@jku.at>
parents: 11810
diff changeset
45 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
46 private Assumption version;
11810
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
47 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
48
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
49 private static final String NEVER_PART_OF_COMPILATION_MESSAGE = "interpreter-only. includes hashmap operations.";
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
50
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
51 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
52 * Constructs empty descriptor. The {@link #getDefaultValue()} is <code>null</code>.
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
53 */
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
54 public FrameDescriptor() {
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
55 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
56 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
58 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
59 * Constructs new descriptor with specified {@link #getDefaultValue()}.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
60 *
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
61 * @param defaultValue to be returned from {@link #getDefaultValue()}
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
62 */
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
63 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
64 CompilerAsserts.neverPartOfCompilation();
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
65 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
66 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
67 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
68 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
69 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
71 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
72 * Use {@link #FrameDescriptor()}.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
73 *
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
74 * @return new instance of the descriptor
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
75 * @deprecated
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
76 */
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
77 @Deprecated
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
78 public static FrameDescriptor create() {
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
79 return new FrameDescriptor();
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
80 }
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
81
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
82 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
83 * Use {@link #FrameDescriptor(java.lang.Object) }.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
84 *
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
85 * @return new instance of the descriptor
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
86 * @deprecated
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
87 */
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
88 @Deprecated
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
89 public static FrameDescriptor create(Object defaultValue) {
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
90 return new FrameDescriptor(defaultValue);
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
91 }
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
92
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
93 /**
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
94 * Adds frame slot. Delegates to
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
95 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
96 * addFrameSlot}(identifier, <code>null</code>, {@link FrameSlotKind#Illegal}). This is a slow
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
97 * operation that switches to interpreter mode.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
98 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
99 * @param identifier key for the slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
100 * @return the newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
101 */
7722
f07cafa29db1 Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
102 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
103 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
104 }
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
105
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
106 /**
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
107 * Adds frame slot. Delegates to
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
108 * {@link #addFrameSlot(java.lang.Object, java.lang.Object, com.oracle.truffle.api.frame.FrameSlotKind)
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
109 * addFrameSlot}(identifier, <code>null</code>, <code>kind</code>). This is a slow operation
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
110 * that switches to interpreter mode.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
111 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
112 * @param identifier key for the slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
113 * @param kind the kind of the new slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
114 * @return the newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
115 */
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9258
diff changeset
116 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
117 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
118 }
9d55732d0880 additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16051
diff changeset
119
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
120 /**
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
121 * Adds new frame slot to {@link #getSlots()} list. This is a slow operation that switches to
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
122 * interpreter mode.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
123 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
124 * @param identifier key for the slot - it needs proper {@link #equals(java.lang.Object)} and
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
125 * {@link Object#hashCode()} implementations
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
126 * @param info additional {@link FrameSlot#getInfo() information for the slot}
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
127 * @param kind the kind of the new slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
128 * @return the newly created slot
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
129 * @throws IllegalArgumentException if a frame slot with the same identifier exists
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
130 */
16727
9d55732d0880 additional info field on FrameSlot nodes (for language-specific use)
Lukas Stadler <lukas.stadler@oracle.com>
parents: 16051
diff changeset
131 public FrameSlot addFrameSlot(Object identifier, Object info, FrameSlotKind kind) {
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
132 CompilerAsserts.neverPartOfCompilation(NEVER_PART_OF_COMPILATION_MESSAGE);
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
133 if (identifierToSlotMap.containsKey(identifier)) {
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
134 throw new IllegalArgumentException("duplicate frame slot: " + identifier);
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
135 }
22522
cda3eebfa777 Documenting FrameSlot methods. Deprecating FrameSlot constructor in favor of FrameDescriptor.addFrameSlot.
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22513
diff changeset
136 FrameSlot slot = new FrameSlot(this, identifier, info, kind, slots.size());
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
137 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
138 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
139 updateVersion();
11810
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
140 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
141 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
142 }
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
143
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
144 /**
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
145 * Finds an existing slot. This is a slow operation.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
146 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
147 * @param identifier the key of the slot to search for
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
148 * @return the slot or <code>null</code>
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
149 */
7722
f07cafa29db1 Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
150 public FrameSlot findFrameSlot(Object identifier) {
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
151 CompilerAsserts.neverPartOfCompilation(NEVER_PART_OF_COMPILATION_MESSAGE);
7722
f07cafa29db1 Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
152 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
153 }
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
154
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
155 /**
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
156 * Finds an existing slot or creates new one. This is a slow operation.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
157 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
158 * @param identifier the key of the slot to search for
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
159 * @return the slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
160 */
7722
f07cafa29db1 Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
161 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
162 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
163 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
164 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
165 }
7722
f07cafa29db1 Allow arbitrary objects to serve as identifiers for a frame slot.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
166 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
167 }
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
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
169 /**
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
170 * Finds an existing slot or creates new one. This is a slow operation.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
171 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
172 * @param identifier the key of the slot to search for
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
173 * @param kind the kind for the newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
174 * @return the found or newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
175 */
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9258
diff changeset
176 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
177 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
178 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
179 return result;
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
180 }
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9258
diff changeset
181 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
182 }
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
183
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
184 /**
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
185 * Finds an existing slot or creates new one. This is a slow operation.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
186 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
187 * @param identifier the key of the slot to search for
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
188 * @param info info for the newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
189 * @param kind the kind for the newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
190 * @return the found or newly created slot
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
191 */
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
192 public FrameSlot findOrAddFrameSlot(Object identifier, Object info, FrameSlotKind kind) {
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
193 FrameSlot result = findFrameSlot(identifier);
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
194 if (result != null) {
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
195 return result;
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
196 }
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
197 return addFrameSlot(identifier, info, kind);
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
198 }
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
199
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
200 /**
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
201 * Removes a slot. If the identifier is found, its slot is removed from this descriptor. This is
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
202 * a slow operation.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
203 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
204 * @param identifier identifies the slot to remove
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
205 * @throws IllegalArgumentException if no such frame slot exists
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
206 */
13875
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
207 public void removeFrameSlot(Object identifier) {
22513
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
208 CompilerAsserts.neverPartOfCompilation(NEVER_PART_OF_COMPILATION_MESSAGE);
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
209 if (!identifierToSlotMap.containsKey(identifier)) {
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
210 throw new IllegalArgumentException("no such frame slot: " + identifier);
8d5a558f4279 turn FrameDescriptor assertions into checks that throw IllegalArgumentException
Andreas Woess <andreas.woess@oracle.com>
parents: 22506
diff changeset
211 }
13875
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
212 slots.remove(identifierToSlotMap.get(identifier));
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
213 identifierToSlotMap.remove(identifier);
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
214 updateVersion();
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
215 getNotInFrameAssumption(identifier);
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
216 }
042a2d972174 support frame slot removal
Michael Haupt <michael.haupt@oracle.com>
parents: 12644
diff changeset
217
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
218 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
219 * Returns number of slots in the descriptor.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
220 *
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
221 * @return the same value as {@link #getSlots()}.{@link List#size()} would return
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
222 */
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
223 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
224 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
225 }
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
226
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
227 /**
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
228 * Current set of slots in the descriptor.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
229 *
22432
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
230 * @return unmodifiable list of {@link FrameSlot}
079cd9183128 Documenting and testing some aspects of FrameDescriptor behavior
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22298
diff changeset
231 */
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7267
diff changeset
232 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
233 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
234 }
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
235
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
236 /**
11808
0c4d7b468dd7 include isValid in Assumption.toString(); minor javadoc fix.
Andreas Woess <andreas.woess@jku.at>
parents: 11343
diff changeset
237 * 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
238 *
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
239 * @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
240 */
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
241 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
242 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
243 }
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
244
22434
c11ce7d2e2c3 Documenting that FrameDescriptor#copy doesn't copy info and kind - isn't that an error?
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22433
diff changeset
245 /**
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
246 * Deeper copy of the descriptor. Copies all slots in the descriptor, but only their
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
247 * {@linkplain FrameSlot#getIdentifier() identifier} and {@linkplain FrameSlot#getInfo() info}
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
248 * but not their {@linkplain FrameSlot#getKind() kind}!
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
249 *
22435
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
250 * @return new instance of a descriptor with copies of values from this one
22434
c11ce7d2e2c3 Documenting that FrameDescriptor#copy doesn't copy info and kind - isn't that an error?
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22433
diff changeset
251 */
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
252 public FrameDescriptor copy() {
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
253 FrameDescriptor clonedFrameDescriptor = new FrameDescriptor(this.defaultValue);
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
254 for (int i = 0; i < slots.size(); i++) {
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
255 FrameSlot slot = slots.get(i);
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
256 clonedFrameDescriptor.addFrameSlot(slot.getIdentifier(), slot.getInfo(), 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
257 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
258 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
259 }
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
260
22435
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
261 /**
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
262 * Shallow copy of the descriptor. Re-uses the existing slots in new descriptor. As a result, if
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
263 * you {@link FrameSlot#setKind(com.oracle.truffle.api.frame.FrameSlotKind) change kind} of one
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
264 * of the slots it is changed in the original as well as in the shallow copy.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
265 *
22435
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
266 * @return new instance of a descriptor with copies of values from this one
dc2bfc816011 Documenting and testing behavior of FrameDescriptor#shallowCopy
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22434
diff changeset
267 */
9952
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9521
diff changeset
268 public FrameDescriptor shallowCopy() {
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
269 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
270 clonedFrameDescriptor.slots.addAll(slots);
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9521
diff changeset
271 clonedFrameDescriptor.identifierToSlotMap.putAll(identifierToSlotMap);
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9521
diff changeset
272 return clonedFrameDescriptor;
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9521
diff changeset
273 }
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9521
diff changeset
274
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
275 /**
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
276 * Invalidates the current, and create a new version assumption.
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
277 */
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
278 void updateVersion() {
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
279 version.invalidate();
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
280 version = createVersion();
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
281 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
282
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
283 /**
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
284 * Returns an assumption reflecting the frame's current version, which is updated every time a
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
285 * slot is added or removed, or an existing slot's kind is changed. This assumption is
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
286 * associated with compiled code that depends on the internal frame layout.
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
287 *
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
288 * @return an assumption invalidated when a slot is added or removed, or a slot kind changed.
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
289 */
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
290 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
291 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
292 }
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
293
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7722
diff changeset
294 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
295 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
296 }
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
297
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
298 /**
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
299 * Default value for the created slots.
22490
fa86f9f3848d change FrameDescriptor#copy to also copy info
Andreas Woess <andreas.woess@oracle.com>
parents: 22435
diff changeset
300 *
22433
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
301 * @return value provided to {@link #FrameDescriptor(java.lang.Object)}
7f3fbd797e39 More Javadoc for FrameDescriptor
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 22432
diff changeset
302 */
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
303 public Object getDefaultValue() {
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 16727
diff changeset
304 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
305 }
11810
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
306
22491
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
307 /**
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
308 * Make an assumption that no slot with the specified identifier is present in this frame
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
309 * descriptor. Invalidated when a frame slot with the identifier is added.
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
310 *
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
311 * @param identifier frame slot identifier
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
312 * @return an assumption that this frame descriptor does not contain a slot with the identifier
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
313 * @throws IllegalArgumentException if the frame descriptor contains a slot with the identifier
a73f1d7a5a3e document FrameDescriptor methods getVersion and getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22490
diff changeset
314 */
11810
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
315 public Assumption getNotInFrameAssumption(Object identifier) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
316 if (identifierToSlotMap.containsKey(identifier)) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
317 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
318 }
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
319
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
320 if (identifierToNotInFrameAssumptionMap == null) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
321 identifierToNotInFrameAssumptionMap = new HashMap<>();
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
322 } else {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
323 Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier);
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
324 if (assumption != null) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
325 return assumption;
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
326 }
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
327 }
22506
67d312302970 avoid string concatenation in FrameDescriptor#getNotInFrameAssumption
Andreas Woess <andreas.woess@oracle.com>
parents: 22491
diff changeset
328 Assumption assumption = Truffle.getRuntime().createAssumption("identifier not in frame");
11810
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
329 identifierToNotInFrameAssumptionMap.put(identifier, assumption);
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
330 return assumption;
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
331 }
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
332
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
333 private void invalidateNotInFrameAssumption(Object identifier) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
334 if (identifierToNotInFrameAssumptionMap != null) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
335 Assumption assumption = identifierToNotInFrameAssumptionMap.get(identifier);
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
336 if (assumption != null) {
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
337 assumption.invalidate();
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
338 identifierToNotInFrameAssumptionMap.remove(identifier);
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
339 }
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
340 }
91a676d0bbbe Truffle: add not-in-frame assumption feature.
Andreas Woess <andreas.woess@jku.at>
parents: 11808
diff changeset
341 }
20818
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
342
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
343 @Override
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
344 public String toString() {
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
345 StringBuilder sb = new StringBuilder();
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
346 sb.append("FrameDescriptor@").append(Integer.toHexString(hashCode()));
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
347 sb.append("{");
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
348 boolean comma = false;
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
349 for (FrameSlot slot : slots) {
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
350 if (comma) {
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
351 sb.append(", ");
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
352 } else {
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
353 comma = true;
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
354 }
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
355 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
356 }
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
357 sb.append("}");
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
358 return sb.toString();
79d212bfee22 Truffle: include slots in FrameDescriptor#toString()
Andreas Woess <andreas.woess@oracle.com>
parents: 18161
diff changeset
359 }
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
360 }