annotate graal/com.oracle.truffle.api/src/com/oracle/truffle/api/impl/DefaultVirtualFrame.java @ 20023:cef214c6d74a

extract methods to avoid code duplication
author Christian Wirth <christian.wirth@oracle.com>
date Tue, 24 Mar 2015 17:33:15 +0100
parents 94f16a759646
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
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import java.util.*;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import com.oracle.truffle.api.*;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 import com.oracle.truffle.api.frame.*;
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
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
32 /**
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
33 * 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
34 * {@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
35 * {@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
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 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
38
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 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
40 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
41 private Object[] locals;
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
42 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
43
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
44 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
45 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
46 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
47 this.locals = new Object[descriptor.getSize()];
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 14991
diff changeset
48 Arrays.fill(locals, descriptor.getDefaultValue());
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
49 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
50 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 @Override
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13760
diff changeset
53 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
54 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
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
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api 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 @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
58 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
59 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
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
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api 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 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
63 public Object getObject(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
64 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
65 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
66 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 @Override
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
69 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
70 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
71 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
72 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 @Override
11427
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
75 public byte getByte(FrameSlot slot) throws FrameSlotTypeException {
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
76 verifyGet(slot, FrameSlotKind.Byte);
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
77 return (byte) locals[slot.getIndex()];
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
78 }
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
79
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
80 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
81 public void setByte(FrameSlot slot, byte value) {
11427
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
82 verifySet(slot, FrameSlotKind.Byte);
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
83 locals[slot.getIndex()] = value;
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
84 }
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
85
51dcddfa25a6 Truffle: add Byte to Frame
Christian Wirth <christian.wirth@oracle.com>
parents: 11279
diff changeset
86 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
87 public boolean getBoolean(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
88 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
89 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
90 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
93 public void setBoolean(FrameSlot slot, boolean value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
94 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
95 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
96 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 @Override
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
99 public int getInt(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
100 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
101 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
102 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api 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 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
105 public void setInt(FrameSlot slot, int value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
106 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
107 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
108 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
110 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
111 public long getLong(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
112 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
113 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
114 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
116 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
117 public void setLong(FrameSlot slot, long value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
118 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
119 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
120 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
122 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
123 public float getFloat(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
124 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
125 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
126 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
129 public void setFloat(FrameSlot slot, float value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
130 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
131 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
132 }
a4b84ba6dc2e Introduction of the Truffle API for efficient implementation of dynamic languages on top of the Graal VM. New projects com.oracle.truffle.api for the API definition and com.oracle.truffle.api.test for API tests and documentation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
134 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
135 public double getDouble(FrameSlot slot) throws FrameSlotTypeException {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
136 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
137 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
138 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
139
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
140 @Override
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
141 public void setDouble(FrameSlot slot, double value) {
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
142 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
143 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
144 }
7721
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
145
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
146 @Override
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
147 public FrameDescriptor getFrameDescriptor() {
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
148 return this.descriptor;
1a2d258d481a Added getFrameDescriptor() to Frame interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 7530
diff changeset
149 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
150
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
151 @Override
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
152 public Object getValue(FrameSlot slot) {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
153 int slotIndex = getSlotIndexChecked(slot);
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
154 return locals[slotIndex];
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
155 }
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
156
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
157 private int getSlotIndexChecked(FrameSlot slot) {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
158 int slotIndex = slot.getIndex();
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
159 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
160 if (!resize()) {
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
161 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
162 }
9258
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
163 }
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
164 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
165 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
166
12405
139b84d713bc Truffle API adjustments: Simplify frame handling. Introduce cast for MaterializedFrame objects.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 11638
diff changeset
167 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
168 int slotIndex = getSlotIndexChecked(slot);
9321
cd1a1d92b3e3 Frame API: Introduce FrameSlotKind.
Andreas Woess <andreas.woess@jku.at>
parents: 9278
diff changeset
169 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
170 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
171
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
172 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
173 int slotIndex = getSlotIndexChecked(slot);
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
174 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
175 if (accessKind == FrameSlotKind.Object ? tag != 0 : tag != accessKind.ordinal()) {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
176 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
177 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
178 }
07f8d136a05e Truffle API changes for the Frame API. Introduction of Assumptions class.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 8567
diff changeset
179
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
180 private boolean resize() {
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
181 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
182 int newSize = descriptor.getSize();
11638
269e6794e1ec Truffle: Frame restructuring.
Andreas Woess <andreas.woess@jku.at>
parents: 11427
diff changeset
183 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
184 locals = Arrays.copyOf(locals, newSize);
18161
94f16a759646 Truffle: remove FrameTypeConversion interface
Andreas Woess <andreas.woess@jku.at>
parents: 14991
diff changeset
185 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
186 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
187 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
188 }
13201
833f8e96d0a5 Truffle: improved error mesage for accessing unknonw frame slots.
Christian Humer <christian.humer@gmail.com>
parents: 12643
diff changeset
189 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
190 }
9952
5d91b0b67cba Introduce Frame.isInitialized in the Truffle API.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9330
diff changeset
191
12643
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
192 private byte getTag(FrameSlot slot) {
20023
cef214c6d74a extract methods to avoid code duplication
Christian Wirth <christian.wirth@oracle.com>
parents: 18161
diff changeset
193 int slotIndex = getSlotIndexChecked(slot);
12643
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
194 return tags[slotIndex];
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
195 }
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
196
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
197 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
198 public boolean isObject(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
199 return getTag(slot) == FrameSlotKind.Object.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
202 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
203 public boolean isByte(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
204 return getTag(slot) == FrameSlotKind.Byte.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
207 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
208 public boolean isBoolean(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
209 return getTag(slot) == FrameSlotKind.Boolean.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
212 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
213 public boolean isInt(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
214 return getTag(slot) == FrameSlotKind.Int.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
217 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
218 public boolean isLong(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
219 return getTag(slot) == FrameSlotKind.Long.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
222 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
223 public boolean isFloat(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
224 return getTag(slot) == FrameSlotKind.Float.ordinal();
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
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
227 @Override
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
228 public boolean isDouble(FrameSlot slot) {
856a9864ed93 Frame: add is<Type> methods.
Andreas Woess <andreas.woess@jku.at>
parents: 12405
diff changeset
229 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
230 }
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
231 }