15104
|
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.hotspot.amd64;
|
|
24
|
|
25 import static com.oracle.graal.amd64.AMD64.*;
|
|
26 import static com.oracle.graal.api.code.ValueUtil.*;
|
|
27 import static com.oracle.graal.lir.LIRInstruction.OperandFlag.*;
|
|
28
|
|
29 import com.oracle.graal.api.code.*;
|
|
30 import com.oracle.graal.api.meta.*;
|
|
31 import com.oracle.graal.asm.amd64.*;
|
|
32 import com.oracle.graal.hotspot.*;
|
|
33 import com.oracle.graal.lir.*;
|
|
34 import com.oracle.graal.lir.amd64.*;
|
|
35 import com.oracle.graal.lir.asm.*;
|
|
36
|
|
37 /**
|
|
38 * Pushes an interpreter frame to the stack.
|
|
39 */
|
|
40 @Opcode("PUSH_INTERPRETER_FRAME")
|
|
41 final class AMD64HotSpotPushInterpreterFrameOp extends AMD64LIRInstruction {
|
|
42
|
|
43 @Alive(REG) AllocatableValue frameSize;
|
|
44 @Alive(REG) AllocatableValue framePc;
|
|
45 @Alive(REG) AllocatableValue senderSp;
|
|
46 @Alive(REG) AllocatableValue initialInfo;
|
|
47
|
|
48 AMD64HotSpotPushInterpreterFrameOp(AllocatableValue frameSize, AllocatableValue framePc, AllocatableValue senderSp, AllocatableValue initialInfo) {
|
|
49 this.frameSize = frameSize;
|
|
50 this.framePc = framePc;
|
|
51 this.senderSp = senderSp;
|
|
52 this.initialInfo = initialInfo;
|
|
53 }
|
|
54
|
|
55 @Override
|
|
56 public void emitCode(CompilationResultBuilder crb, AMD64MacroAssembler masm) {
|
|
57 final Register frameSizeRegister = asRegister(frameSize);
|
|
58 final Register framePcRegister = asRegister(framePc);
|
|
59 final Register senderSpRegister = asRegister(senderSp);
|
|
60 final Register initialInfoRegister = asRegister(initialInfo);
|
|
61 final HotSpotVMConfig config = HotSpotGraalRuntime.runtime().getConfig();
|
|
62 final int wordSize = HotSpotGraalRuntime.runtime().getTarget().wordSize;
|
|
63
|
|
64 // We'll push PC and BP by hand.
|
|
65 masm.subq(frameSizeRegister, 2 * wordSize);
|
|
66
|
|
67 // Push return address.
|
|
68 masm.push(framePcRegister);
|
|
69
|
|
70 // Prolog
|
|
71 masm.push(initialInfoRegister);
|
|
72 masm.movq(initialInfoRegister, rsp);
|
|
73 masm.subq(rsp, frameSizeRegister);
|
|
74
|
|
75 // This value is corrected by layout_activation_impl.
|
|
76 masm.movptr(new AMD64Address(initialInfoRegister, config.frameInterpreterFrameLastSpOffset * wordSize), 0);
|
|
77
|
|
78 // Make the frame walkable.
|
|
79 masm.movq(new AMD64Address(initialInfoRegister, config.frameInterpreterFrameSenderSpOffset * wordSize), senderSpRegister);
|
|
80 }
|
|
81 }
|