annotate truffle/com.oracle.truffle.api.interop/src/com/oracle/truffle/api/interop/GenericObjectAccessNode.java @ 22502:d2b4fe945c23

Add missing Truffle boundary
author Christian Wimmer <christian.wimmer@oracle.com>
date Wed, 16 Dec 2015 15:32:23 -0800
parents a016a0239ad9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22123
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
1 /*
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
4 *
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation. Oracle designates this
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
8 * particular file as subject to the "Classpath" exception as provided
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
9 * by Oracle in the LICENSE file that accompanied this code.
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
10 *
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
11 * This code is distributed in the hope that it will be useful, but WITHOUT
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
14 * version 2 for more details (a copy is included in the LICENSE file that
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
15 * accompanied this code).
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
16 *
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License version
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
18 * 2 along with this work; if not, write to the Free Software Foundation,
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
20 *
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
22 * or visit www.oracle.com if you need additional information or have any
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
23 * questions.
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
24 */
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
25 package com.oracle.truffle.api.interop;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
26
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
27 import com.oracle.truffle.api.CallTarget;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
28 import com.oracle.truffle.api.CompilerDirectives;
22502
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
29 import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
22123
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
30 import com.oracle.truffle.api.Truffle;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
31 import com.oracle.truffle.api.frame.VirtualFrame;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
32 import com.oracle.truffle.api.nodes.IndirectCallNode;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
33
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
34 final class GenericObjectAccessNode extends ObjectAccessNode {
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
35 private final Message access;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
36 @Child private IndirectCallNode indirectCallNode;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
37
22318
a016a0239ad9 Optimize argument access for foreign access functions.
Christian Humer <christian.humer@oracle.com>
parents: 22123
diff changeset
38 @Child private ForeignAccessArguments accessArguments = new ForeignAccessArguments();
a016a0239ad9 Optimize argument access for foreign access functions.
Christian Humer <christian.humer@oracle.com>
parents: 22123
diff changeset
39
22123
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
40 public GenericObjectAccessNode(Message access) {
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
41 this.access = access;
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
42 indirectCallNode = Truffle.getRuntime().createIndirectCallNode();
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
43 }
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
44
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
45 public GenericObjectAccessNode(GenericObjectAccessNode prev) {
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
46 this(prev.access);
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
47 }
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
48
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
49 @Override
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
50 public Object executeWith(VirtualFrame frame, TruffleObject truffleObject, Object[] arguments) {
22502
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
51 final CallTarget ct = findCallTarget(truffleObject);
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
52 return indirectCallNode.call(frame, ct, accessArguments.executeCreate(truffleObject, arguments));
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
53 }
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
54
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
55 @TruffleBoundary
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
56 protected CallTarget findCallTarget(TruffleObject truffleObject) {
22123
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
57 final ForeignAccess fa = truffleObject.getForeignAccess();
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
58 final CallTarget ct = fa.access(access);
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
59 if (ct == null) {
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
60 throw messageNotRecognizedException(fa);
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
61 }
22502
d2b4fe945c23 Add missing Truffle boundary
Christian Wimmer <christian.wimmer@oracle.com>
parents: 22318
diff changeset
62 return ct;
22123
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
63 }
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
64
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
65 @CompilerDirectives.TruffleBoundary
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
66 private RuntimeException messageNotRecognizedException(final ForeignAccess fa) {
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
67 throw new IllegalStateException("Message " + access + " not recognized by " + fa);
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
68 }
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
69
329fe954f6f2 Can compile Truffle API with following javac lints: -Xlint:all,-auxiliaryclass,-try,-processing
Jaroslav Tulach <jaroslav.tulach@oracle.com>
parents:
diff changeset
70 }