annotate graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java @ 23394:964f28c04d7b default tip

Don't fill the code cache with nmethods from CTW
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Fri, 05 Feb 2016 22:48:36 -0800
parents 39f9960bb6ae
children
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 /*
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
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21720
diff changeset
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;
23370
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
39 import com.oracle.graal.hotspot.amd64.AMD64HotSpotBackend;
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
40 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
41 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
42 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
43 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
44 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
45 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
46 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
47
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
48 @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
49 public class AMD64OptimizedCallTargetInstrumentationFactory extends OptimizedCallTargetInstrumentationFactory {
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
50
23316
52f4acf6f365 Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents: 23222
diff changeset
51 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
52 CompilationResult compilationResult) {
23316
52f4acf6f365 Update import: Move CompilationResult and DataSection from JVMCI to Graal.
Roland Schatz <roland.schatz@oracle.com>
parents: 23222
diff changeset
53 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
54 @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
55 protected void injectTailCallCode() {
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
56 @SuppressWarnings("hiding")
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
57 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
58 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
59 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
60 Label doProlog = new Label();
23370
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
61 int pos = asm.position();
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
62
22743
bcfb44655eb9 Updated imported jvmci version: updated InstalledCodeInvalidationTest
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22637
diff changeset
63 AMD64Address codeBlobAddress = new AMD64Address(thisRegister, getFieldOffset("entryPoint", InstalledCode.class));
23370
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
64 /*
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
65 * The first instruction must be at least 5 bytes long to be safe for not entrant
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
66 * patching, so force a wider encoding of the movq instruction.
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
67 */
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
68 asm.movq(spillRegister, codeBlobAddress, true);
39f9960bb6ae Ensure the tail call machinery for Truffle follows hotspot rules for first instruction size
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23348
diff changeset
69 assert asm.position() - pos >= AMD64HotSpotBackend.PATCHED_VERIFIED_ENTRY_POINT_INSTRUCTION_SIZE;
22743
bcfb44655eb9 Updated imported jvmci version: updated InstalledCodeInvalidationTest
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22637
diff changeset
70 asm.testq(spillRegister, spillRegister);
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
71 asm.jcc(ConditionFlag.Equal, doProlog);
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
72 asm.jmp(spillRegister);
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 asm.bind(doProlog);
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
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
79 @Override
13231
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
80 public String getArchitecture() {
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
81 return "AMD64";
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
82 }
dad021298158 use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
Doug Simon <doug.simon@oracle.com>
parents:
diff changeset
83 }