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

Using fully qualified imports
author Jaroslav Tulach <jaroslav.tulach@oracle.com>
date Wed, 16 Sep 2015 11:33:22 +0200
parents 9c8c0937da41
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: 10911
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: 10911
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: 10911
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * accompanied this code).
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 *
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 * questions.
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 */
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.impl;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26
22157
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
27 import com.oracle.truffle.api.TruffleRuntime;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
28 import com.oracle.truffle.api.frame.FrameDescriptor;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
29 import com.oracle.truffle.api.frame.FrameSlot;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
30 import com.oracle.truffle.api.frame.FrameSlotKind;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
31 import com.oracle.truffle.api.frame.FrameSlotTypeException;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
32 import com.oracle.truffle.api.frame.MaterializedFrame;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
33 import com.oracle.truffle.api.frame.VirtualFrame;
dc83cc1f94f2 Using fully qualified imports
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents: 21951
diff changeset
34 import java.util.Arrays;
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
35
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13201
diff changeset
36 /**
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13201
diff changeset
37 * This is an implementation-specific class. Do not use or instantiate it. Instead, use
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
38 * {@link TruffleRuntime#createVirtualFrame(Object[], FrameDescriptor)} to create a
13760
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13201
diff changeset
39 * {@link VirtualFrame}.
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13201
diff changeset
40 */
a12017c18d5d Truffle API cleanup: Reduce the visibility of classes and constructors that are not intended to be instantiated by guest language implementations; provide abstract class RootCallTarget as a CallTarget to a RootNode
Christian Wimmer <christian.wimmer@oracle.com>
parents: 13201
diff changeset
41 final class DefaultVirtualFrame implements VirtualFrame {
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
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
43 private final FrameDescriptor descriptor;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
44 private final Object[] arguments;
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
45 private Object[] locals;
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
46 private byte[] tags;
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
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
48 DefaultVirtualFrame(FrameDescriptor descriptor, Object[] arguments) {
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 this.descriptor = descriptor;
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 this.arguments = arguments;
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 this.locals = new Object[descriptor.getSize()];
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 14991
diff changeset
52 Arrays.fill(locals, descriptor.getDefaultValue());
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
53 this.tags = new byte[descriptor.getSize()];
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 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
57 public Object[] getArguments() {
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
58 return arguments;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 }
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
60
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 @Override
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 public MaterializedFrame materialize() {
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
63 return new DefaultMaterializedFrame(this);
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
64 }
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
65
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
67 public Object getObject(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
68 verifyGet(slot, FrameSlotKind.Object);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
69 return locals[slot.getIndex()];
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
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
72 @Override
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
73 public void setObject(FrameSlot slot, Object value) {
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
74 verifySet(slot, FrameSlotKind.Object);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
75 locals[slot.getIndex()] = value;
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
76 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
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
78 @Override
11427
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
79 public byte getByte(FrameSlot slot) throws FrameSlotTypeException {
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
80 verifyGet(slot, FrameSlotKind.Byte);
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
81 return (byte) locals[slot.getIndex()];
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
82 }
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
83
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
84 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
85 public void setByte(FrameSlot slot, byte value) {
11427
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
86 verifySet(slot, FrameSlotKind.Byte);
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
87 locals[slot.getIndex()] = value;
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
88 }
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
89
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
90 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
91 public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
92 verifyGet(slot, FrameSlotKind.Boolean);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
93 return (boolean) locals[slot.getIndex()];
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 }
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
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 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
97 public void setBoolean(FrameSlot slot, boolean value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
98 verifySet(slot, FrameSlotKind.Boolean);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
99 locals[slot.getIndex()] = value;
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
100 }
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
101
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
102 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
103 public int getInt(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
104 verifyGet(slot, FrameSlotKind.Int);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
105 return (int) locals[slot.getIndex()];
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
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
108 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
109 public void setInt(FrameSlot slot, int value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
110 verifySet(slot, FrameSlotKind.Int);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
111 locals[slot.getIndex()] = value;
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
112 }
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
113
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
114 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
115 public long getLong(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
116 verifyGet(slot, FrameSlotKind.Long);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
117 return (long) locals[slot.getIndex()];
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
118 }
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
119
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
120 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
121 public void setLong(FrameSlot slot, long value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
122 verifySet(slot, FrameSlotKind.Long);
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
123 locals[slot.getIndex()] = value;
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
124 }
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
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
126 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
127 public float getFloat(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
128 verifyGet(slot, FrameSlotKind.Float);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
129 return (float) locals[slot.getIndex()];
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 }
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 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
133 public void setFloat(FrameSlot slot, float value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
134 verifySet(slot, FrameSlotKind.Float);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
135 locals[slot.getIndex()] = value;
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
136 }
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
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
138 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
139 public double getDouble(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
140 verifyGet(slot, FrameSlotKind.Double);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
141 return (double) locals[slot.getIndex()];
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
142 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
143
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
144 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
145 public void setDouble(FrameSlot slot, double value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
146 verifySet(slot, FrameSlotKind.Double);
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
147 locals[slot.getIndex()] = value;
7267
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 }
7721
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
149
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
150 @Override
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
151 public FrameDescriptor getFrameDescriptor() {
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
152 return this.descriptor;
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
153 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
154
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
155 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
156 public Object getValue(FrameSlot slot) {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
157 int slotIndex = getSlotIndexChecked(slot);
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
158 return locals[slotIndex];
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
159 }
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
160
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
161 private int getSlotIndexChecked(FrameSlot slot) {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
162 int slotIndex = slot.getIndex();
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
163 if (slotIndex >= tags.length) {
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
164 if (!resize()) {
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
165 throw new IllegalArgumentException(String.format("The frame slot '%s' is not known by the frame descriptor.", slot));
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
166 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
167 }
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
168 return slotIndex;
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
169 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
170
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
171 private void verifySet(FrameSlot slot, FrameSlotKind accessKind) {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
172 int slotIndex = getSlotIndexChecked(slot);
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
173 tags[slotIndex] = (byte) accessKind.ordinal();
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
174 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
175
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
176 private void verifyGet(FrameSlot slot, FrameSlotKind accessKind) throws FrameSlotTypeException {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
177 int slotIndex = getSlotIndexChecked(slot);
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
178 byte tag = tags[slotIndex];
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
179 if (accessKind == FrameSlotKind.Object ? tag != 0 : tag != accessKind.ordinal()) {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
180 throw new FrameSlotTypeException();
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
181 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
182 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
183
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
184 private boolean resize() {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
185 int oldSize = tags.length;
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
186 int newSize = descriptor.getSize();
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
187 if (newSize > oldSize) {
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
188 locals = Arrays.copyOf(locals, newSize);
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 14991
diff changeset
189 Arrays.fill(locals, oldSize, newSize, descriptor.getDefaultValue());
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
190 tags = Arrays.copyOf(tags, newSize);
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
191 return true;
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
192 }
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
193 return false;
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
194 }
9952
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9330
diff changeset
195
12643
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
196 private byte getTag(FrameSlot slot) {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
197 int slotIndex = getSlotIndexChecked(slot);
12643
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
198 return tags[slotIndex];
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
199 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
200
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
201 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
202 public boolean isObject(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
203 return getTag(slot) == FrameSlotKind.Object.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
204 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
205
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
206 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
207 public boolean isByte(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
208 return getTag(slot) == FrameSlotKind.Byte.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
209 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
210
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
211 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
212 public boolean isBoolean(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
213 return getTag(slot) == FrameSlotKind.Boolean.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
214 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
215
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
216 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
217 public boolean isInt(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
218 return getTag(slot) == FrameSlotKind.Int.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
219 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
220
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
221 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
222 public boolean isLong(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
223 return getTag(slot) == FrameSlotKind.Long.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
224 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
225
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
226 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
227 public boolean isFloat(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
228 return getTag(slot) == FrameSlotKind.Float.ordinal();
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
229 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
230
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
231 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
232 public boolean isDouble(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
233 return getTag(slot) == FrameSlotKind.Double.ordinal();
9952
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9330
diff changeset
234 }
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
235 }