Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/OptimizedCallTargetInstrumentation.java @ 21413:15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
converted some uses of GraalInternalError to InternalError
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 18 May 2015 22:27:24 +0200 |
parents | 1c92d437179b |
children | 1da7aef31a08 |
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.*; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.hotspot.meta.*; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.lir.asm.*; |
18443
1c92d437179b
FrameMapBuilder: move into package.
Josef Eisl <josef.eisl@jku.at>
parents:
15291
diff
changeset
|
34 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
|
35 import com.oracle.graal.truffle.*; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 /** |
14991
64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
14574
diff
changeset
|
38 * 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
|
39 */ |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 public abstract class OptimizedCallTargetInstrumentation extends CompilationResultBuilder { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
14032
d1c1f103d42c
renamed com.oracle.graal.asm.AbstractAssembler to com.oracle.graal.asm.Assembler
twisti
parents:
13231
diff
changeset
|
42 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
|
43 CompilationResult compilationResult) { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 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
|
45 } |
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 @Override |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 public Mark recordMark(Object id) { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 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
|
50 HotSpotCodeCacheProvider hsCodeCache = (HotSpotCodeCacheProvider) codeCache; |
15a46a918fc1
removed unnecessary HotSpotCodeCache.MarkId enum (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
18443
diff
changeset
|
51 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
|
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 } |