annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents 5324104ac4f3
children 6df25b1418be
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
25 import com.oracle.jvmci.code.CodeCacheProvider;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
26 import com.oracle.jvmci.code.CompilationResult;
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
27 import com.oracle.jvmci.code.ForeignCallsProvider;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import java.lang.reflect.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21551
diff changeset
30 import com.oracle.jvmci.code.CompilationResult.Mark;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.asm.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
32 import com.oracle.graal.hotspot.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
33 import com.oracle.graal.hotspot.meta.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
34 import com.oracle.graal.lir.asm.*;
18443
1c92d437179b FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents: 15291
diff changeset
35 import com.oracle.graal.lir.framemap.*;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.truffle.*;
21541
5e868236654f moved UnsafeAccess to com.oracle.jvmci.common (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
37 import com.oracle.jvmci.common.*;
21551
5324104ac4f3 moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21543
diff changeset
38 import com.oracle.jvmci.hotspot.*;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
39
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
40 /**
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14574
diff changeset
41 * 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
42 */
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
43 public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
44
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 13231
diff changeset
45 public OptimizedCallTargetInstrumentation(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, FrameContext frameContext,
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
46 CompilationResult compilationResult) {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47 super(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 @Override
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
51 public Mark recordMark(Object id) {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 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
53 HotSpotCodeCacheProvider hsCodeCache = (HotSpotCodeCacheProvider) codeCache;
15a46a918fc1 removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 18443
diff changeset
54 if ((int) id == hsCodeCache.config.MARKID_VERIFIED_ENTRY) {
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 HotSpotRegistersProvider registers = HotSpotGraalRuntime.runtime().getHostProviders().getRegisters();
14574
6bab029d6e3a removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents: 14032
diff changeset
56 injectTailCallCode(HotSpotGraalRuntime.runtime().getConfig(), registers);
13231
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 return mark;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
59 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 14991
diff changeset
61 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
62 try {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 declaringClass.getDeclaredField(name).setAccessible(true);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 Field field = declaringClass.getDeclaredField(name);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 return (int) UnsafeAccess.unsafe.objectFieldOffset(field);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
66 } 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
67 throw JVMCIError.shouldNotReachHere();
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
68 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
69 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
70
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 /**
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 * 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
73 */
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
74 protected abstract void injectTailCallCode(HotSpotVMConfig config, HotSpotRegistersProvider registers);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
75 }