Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java @ 22744:339272c9d519
Test updates for revised Polyglot/Instrumentation APIs
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Wed, 30 Sep 2015 22:10:52 -0700 |
parents | 4dab2545d435 |
children | 615f3bbbb174 |
rev | line source |
---|---|
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.truffle.hotspot; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
22614
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
25 import static com.oracle.graal.truffle.hotspot.UnsafeAccess.UNSAFE; |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
22614
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
27 import java.lang.reflect.Field; |
22054 | 28 |
22614
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
29 import jdk.internal.jvmci.code.CodeCacheProvider; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
30 import jdk.internal.jvmci.code.CompilationResult; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
31 import jdk.internal.jvmci.code.CompilationResult.Mark; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
32 import jdk.internal.jvmci.common.JVMCIError; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
33 import jdk.internal.jvmci.hotspot.HotSpotCodeCacheProvider; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
34 import jdk.internal.jvmci.hotspot.HotSpotVMConfig; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
35 |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
36 import com.oracle.graal.asm.Assembler; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
37 import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
38 import com.oracle.graal.hotspot.meta.HotSpotRegistersProvider; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
39 import com.oracle.graal.lir.asm.CompilationResultBuilder; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
40 import com.oracle.graal.lir.asm.FrameContext; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
41 import com.oracle.graal.lir.framemap.FrameMap; |
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
42 import com.oracle.graal.truffle.OptimizedCallTarget; |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 /** |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14574
diff
changeset
|
45 * Mechanism for injecting special code into {@link OptimizedCallTarget#call(Object[])} . |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 */ |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder { |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
48 protected final HotSpotVMConfig config; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
49 protected final HotSpotRegistersProvider registers; |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
14032
d1c1f103d42c
renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents:
13231
diff
changeset
|
51 public OptimizedCallTargetInstrumentation(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, FrameContext frameContext, |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
52 CompilationResult compilationResult, HotSpotVMConfig config, HotSpotRegistersProvider registers) { |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult); |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
54 this.config = config; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
55 this.registers = registers; |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 } |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 @Override |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 public Mark recordMark(Object id) { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 Mark mark = super.recordMark(id); |
21413
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18443
diff
changeset
|
61 HotSpotCodeCacheProvider hsCodeCache = (HotSpotCodeCacheProvider) codeCache; |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18443
diff
changeset
|
62 if ((int) id == hsCodeCache.config.MARKID_VERIFIED_ENTRY) { |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
63 injectTailCallCode(); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 } |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 return mark; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 } |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 |
15040
288c23143d47
Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents:
14991
diff
changeset
|
68 protected static int getFieldOffset(String name, Class<?> declaringClass) { |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
69 try { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
70 declaringClass.getDeclaredField(name).setAccessible(true); |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
71 Field field = declaringClass.getDeclaredField(name); |
22614
9f0e536ee385
restricted Unsafe capability access to package or class scope (GRAAL-1257)
Doug Simon <doug.simon@oracle.com>
parents:
22317
diff
changeset
|
72 return (int) UNSAFE.objectFieldOffset(field); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 } catch (NoSuchFieldException | SecurityException e) { |
21543
93c50cefb9e8
moved GraalInternalError to com.oracle.jvmci.common and renamed it to JVMCIError (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21541
diff
changeset
|
74 throw JVMCIError.shouldNotReachHere(); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
75 } |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
76 } |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
77 |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
78 /** |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 * Injects code into the verified entry point of that makes a tail-call to the target callee. |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 */ |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22614
diff
changeset
|
81 protected abstract void injectTailCallCode(); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 } |