annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java @ 15291:471e28b8f03b

Move UnsafeAccess to graal.compiler.common.
author Josef Eisl <josef.eisl@jku.at>
date Tue, 22 Apr 2014 15:24:14 +0200
parents 96bb07a5d667
children 1c92d437179b
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
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
25 import java.lang.reflect.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
26
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.api.code.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.api.code.CompilationResult.Mark;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.asm.*;
15193
96bb07a5d667 Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents: 15040
diff changeset
30 import com.oracle.graal.compiler.common.*;
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.hotspot.*;
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14574
diff changeset
32 import com.oracle.graal.hotspot.meta.HotSpotCodeCacheProvider.MarkId;
13231
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.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.lir.asm.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
36 import com.oracle.graal.truffle.*;
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
37
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
38 /**
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 14574
diff changeset
39 * 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
40 */
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
41 public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
42
14032
d1c1f103d42c renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents: 13231
diff changeset
43 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
44 CompilationResult compilationResult) {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
45 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
46 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
47
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 @Override
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
49 public Mark recordMark(Object id) {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50 Mark mark = super.recordMark(id);
14574
6bab029d6e3a removed com/oracle/graal/hotspot/bridge/Marks.java and replaced with enum
twisti
parents: 14032
diff changeset
51 if (MarkId.getEnum((int) id) == MarkId.VERIFIED_ENTRY) {
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
52 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
53 injectTailCallCode(HotSpotGraalRuntime.runtime().getConfig(), registers);
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
54 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
55 return mark;
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
15040
288c23143d47 Fix most raw type references.
Josef Eisl <josef.eisl@jku.at>
parents: 14991
diff changeset
58 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
59 try {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
60 declaringClass.getDeclaredField(name).setAccessible(true);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
61 Field field = declaringClass.getDeclaredField(name);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62 return (int) UnsafeAccess.unsafe.objectFieldOffset(field);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
63 } catch (NoSuchFieldException | SecurityException e) {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
64 throw GraalInternalError.shouldNotReachHere();
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
65 }
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
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 * 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
70 */
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 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
72 }