Mercurial > hg > graal-compiler
comparison graal/com.oracle.graal.truffle.hotspot.amd64/src/com/oracle/graal/truffle/hotspot/amd64/AMD64OptimizedCallTargetInstrumentationFactory.java @ 13231:dad021298158
use CompilationResultBuilderFactory to do patching of OptimizedCallTarget.call()
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 03 Dec 2013 16:49:12 +0100 |
parents | |
children | f1f33d1ff3e2 |
comparison
equal
deleted
inserted
replaced
13230:01080e31692d | 13231:dad021298158 |
---|---|
1 /* | |
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.truffle.hotspot.amd64; | |
24 | |
25 import com.oracle.graal.amd64.*; | |
26 import com.oracle.graal.api.code.CallingConvention.Type; | |
27 import com.oracle.graal.api.code.*; | |
28 import com.oracle.graal.api.meta.*; | |
29 import com.oracle.graal.api.runtime.*; | |
30 import com.oracle.graal.asm.*; | |
31 import com.oracle.graal.asm.amd64.*; | |
32 import com.oracle.graal.asm.amd64.AMD64Assembler.ConditionFlag; | |
33 import com.oracle.graal.hotspot.*; | |
34 import com.oracle.graal.hotspot.amd64.*; | |
35 import com.oracle.graal.hotspot.meta.*; | |
36 import com.oracle.graal.lir.*; | |
37 import com.oracle.graal.lir.asm.*; | |
38 import com.oracle.graal.truffle.*; | |
39 import com.oracle.graal.truffle.hotspot.*; | |
40 | |
41 @ServiceProvider(OptimizedCallTargetInstrumentationFactory.class) | |
42 public class AMD64OptimizedCallTargetInstrumentationFactory implements OptimizedCallTargetInstrumentationFactory { | |
43 | |
44 public CompilationResultBuilder createBuilder(CodeCacheProvider codeCache, ForeignCallsProvider foreignCalls, FrameMap frameMap, AbstractAssembler asm, FrameContext frameContext, | |
45 CompilationResult compilationResult) { | |
46 return new OptimizedCallTargetInstrumentation(codeCache, foreignCalls, frameMap, asm, frameContext, compilationResult) { | |
47 @Override | |
48 protected void injectTailCallCode(HotSpotVMConfig config, HotSpotRegistersProvider registers) { | |
49 @SuppressWarnings("hiding") | |
50 AMD64MacroAssembler asm = (AMD64MacroAssembler) this.asm; | |
51 Register thisRegister = codeCache.getRegisterConfig().getCallingConventionRegisters(Type.JavaCall, Kind.Object)[0]; | |
52 Register spillRegister = AMD64.r10; // TODO(mg): fix me | |
53 AMD64Address nMethodAddress = new AMD64Address(thisRegister, getFieldOffset("installedCode", OptimizedCallTarget.class)); | |
54 if (config.useCompressedOops) { | |
55 asm.movl(spillRegister, nMethodAddress); | |
56 AMD64HotSpotMove.decodePointer(asm, spillRegister, registers.getHeapBaseRegister(), config.narrowOopBase, config.narrowOopShift, config.logMinObjAlignment()); | |
57 } else { | |
58 asm.movq(spillRegister, nMethodAddress); | |
59 } | |
60 Label doProlog = new Label(); | |
61 | |
62 asm.cmpq(spillRegister, 0); | |
63 asm.jcc(ConditionFlag.Equal, doProlog); | |
64 | |
65 AMD64Address codeBlobAddress = new AMD64Address(spillRegister, getFieldOffset("codeBlob", HotSpotInstalledCode.class)); | |
66 asm.movq(spillRegister, codeBlobAddress); | |
67 asm.cmpq(spillRegister, 0); | |
68 asm.jcc(ConditionFlag.Equal, doProlog); | |
69 | |
70 AMD64Address verifiedEntryPointAddress = new AMD64Address(spillRegister, config.nmethodEntryOffset); | |
71 asm.movq(spillRegister, verifiedEntryPointAddress); | |
72 asm.jmp(spillRegister); | |
73 | |
74 asm.bind(doProlog); | |
75 } | |
76 }; | |
77 } | |
78 | |
79 public void setInstrumentedMethod(ResolvedJavaMethod method) { | |
80 HotSpotResolvedJavaMethod hsMethod = (HotSpotResolvedJavaMethod) method; | |
81 hsMethod.setDontInline(); | |
82 } | |
83 | |
84 public String getArchitecture() { | |
85 return "AMD64"; | |
86 } | |
87 } |