Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java @ 23348:9306a9611097
Update JVMCI import: Make CallingConvention.Type extensible; remove unused stackOnly parameter
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Thu, 21 Jan 2016 14:24:24 -0800 |
parents | 52f4acf6f365 |
children | 39f9960bb6ae |
rev | line source |
---|---|
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
23316
52f4acf6f365
Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents:
23222
diff
changeset
|
2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
13231
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.amd64; |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
23348
9306a9611097
Update JVMCI import: Make CallingConvention.Type extensible; remove unused stackOnly parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents:
23316
diff
changeset
|
25 import static jdk.vm.ci.hotspot.HotSpotCallingConventionType.JavaCall; |
22790
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22743
diff
changeset
|
26 import jdk.vm.ci.amd64.AMD64; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22743
diff
changeset
|
27 import jdk.vm.ci.code.CodeCacheProvider; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22743
diff
changeset
|
28 import jdk.vm.ci.code.InstalledCode; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22743
diff
changeset
|
29 import jdk.vm.ci.code.Register; |
615f3bbbb174
Update jvmci and truffle import: Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22743
diff
changeset
|
30 import jdk.vm.ci.meta.JavaKind; |
22054 | 31 |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
32 import com.oracle.graal.asm.Assembler; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
33 import com.oracle.graal.asm.Label; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
34 import com.oracle.graal.asm.amd64.AMD64Address; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
35 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
36 import com.oracle.graal.asm.amd64.AMD64MacroAssembler; |
23316
52f4acf6f365
Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents:
23222
diff
changeset
|
37 import com.oracle.graal.code.CompilationResult; |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
38 import com.oracle.graal.compiler.common.spi.ForeignCallsProvider; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
39 import com.oracle.graal.lir.asm.CompilationResultBuilder; |
23316
52f4acf6f365
Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents:
23222
diff
changeset
|
40 import com.oracle.graal.lir.asm.DataBuilder; |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
41 import com.oracle.graal.lir.asm.FrameContext; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
42 import com.oracle.graal.lir.framemap.FrameMap; |
23222
56359eb3abfa
moved @ServiceProvider mechanism from JVMCI to Graal (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents:
22790
diff
changeset
|
43 import com.oracle.graal.serviceprovider.ServiceProvider; |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
44 import com.oracle.graal.truffle.hotspot.OptimizedCallTargetInstrumentation; |
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
45 import com.oracle.graal.truffle.hotspot.OptimizedCallTargetInstrumentationFactory; |
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 @ServiceProvider(OptimizedCallTargetInstrumentationFactory.class) |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
48 public class AMD64OptimizedCallTargetInstrumentationFactory extends OptimizedCallTargetInstrumentationFactory { |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 |
23316
52f4acf6f365
Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents:
23222
diff
changeset
|
50 public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, Assembler asm, DataBuilder dataBuilder, FrameContext frameContext, |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 CompilationResult compilationResult) { |
23316
52f4acf6f365
Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents:
23222
diff
changeset
|
52 return new OptimizedCallTargetInstrumentation(codeCache, foreignCalls, frameMap, asm, dataBuilder, frameContext, compilationResult, config, registers) { |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 @Override |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
54 protected void injectTailCallCode() { |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 @SuppressWarnings("hiding") |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 AMD64MacroAssembler asm = (AMD64MacroAssembler) this.asm; |
23348
9306a9611097
Update JVMCI import: Make CallingConvention.Type extensible; remove unused stackOnly parameter
Christian Wimmer <christian.wimmer@oracle.com>
parents:
23316
diff
changeset
|
57 Register thisRegister = codeCache.getRegisterConfig().getCallingConventionRegisters(JavaCall, JavaKind.Object)[0]; |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 Register spillRegister = AMD64.r10; // TODO(mg): fix me |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 Label doProlog = new Label(); |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 |
22743
bcfb44655eb9
Updated imported jvmci version: updated InstalledCodeInvalidationTest
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22637
diff
changeset
|
61 AMD64Address codeBlobAddress = new AMD64Address(thisRegister, getFieldOffset("entryPoint", InstalledCode.class)); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 asm.movq(spillRegister, codeBlobAddress); |
22743
bcfb44655eb9
Updated imported jvmci version: updated InstalledCodeInvalidationTest
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
22637
diff
changeset
|
63 asm.testq(spillRegister, spillRegister); |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 asm.jcc(ConditionFlag.Equal, doProlog); |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 asm.jmp(spillRegister); |
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 asm.bind(doProlog); |
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 |
22637
4dab2545d435
removed HotSpotGraalRuntime singleton - it's now owned by a HotSpotGraalCompiler instance (GRAAL-1235)
Doug Simon <doug.simon@oracle.com>
parents:
22604
diff
changeset
|
72 @Override |
13231
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
73 public String getArchitecture() { |
dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 return "AMD64"; |
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 } |