annotate graal/com.oracle.graal.hotspot.sparc/src/com/oracle/graal/hotspot/sparc/SPARCHotSpotBackend.java @ 10854:e1fcdda22831

SPARC: can compile some stubs now but they don't work yet
author twisti
date Mon, 22 Jul 2013 22:26:49 -0700
parents 7a8d6ba83a04
children 563c6d1994c0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.hotspot.sparc;
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
25 import java.util.*;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
26
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
27 import sun.misc.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
28
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.api.code.*;
9621
e97dc9bbfedc introduced installedCodeOwner parameter of type ResolvedJavaMethod to GraalCompiler.compileGraph to properly distinguish the source method of a graph from the method under which the code compiled for the graph will be installed
Doug Simon <doug.simon@oracle.com>
parents: 9615
diff changeset
30 import com.oracle.graal.api.meta.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
31 import com.oracle.graal.asm.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
32 import com.oracle.graal.asm.sparc.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
33 import com.oracle.graal.asm.sparc.SPARCAssembler.*;
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
34 import com.oracle.graal.compiler.gen.LIRGenerator;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 import com.oracle.graal.hotspot.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
36 import com.oracle.graal.hotspot.bridge.*;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 import com.oracle.graal.hotspot.meta.*;
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
38 import com.oracle.graal.hotspot.stubs.Stub;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 import com.oracle.graal.lir.*;
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 import com.oracle.graal.lir.asm.*;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
41 import com.oracle.graal.lir.sparc.*;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 import com.oracle.graal.nodes.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
43
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
44 import static com.oracle.graal.sparc.SPARC.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
45 import static com.oracle.graal.asm.sparc.SPARCMacroAssembler.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
46 import static com.oracle.graal.api.code.CallingConvention.Type.*;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
47 import static com.oracle.graal.api.code.ValueUtil.*;
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
48 import static com.oracle.graal.phases.GraalOptions.*;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
49 import static java.lang.reflect.Modifier.*;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 /**
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 * HotSpot SPARC specific backend.
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 */
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 public class SPARCHotSpotBackend extends HotSpotBackend {
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
56 private static final Unsafe unsafe = Unsafe.getUnsafe();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
57
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 public SPARCHotSpotBackend(HotSpotRuntime runtime, TargetDescription target) {
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 super(runtime, target);
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 }
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 @Override
9613
0c17815817a4 removed LIRGenerator.method field
Doug Simon <doug.simon@oracle.com>
parents: 9612
diff changeset
63 public LIRGenerator newLIRGenerator(StructuredGraph graph, FrameMap frameMap, CallingConvention cc, LIR lir) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
64 return new SPARCHotSpotLIRGenerator(graph, runtime(), target, frameMap, cc, lir);
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 }
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
67 /**
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
68 * Emits code to do stack overflow checking.
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
69 *
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
70 * @param afterFrameInit specifies if the stack pointer has already been adjusted to allocate
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
71 * the current frame
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
72 */
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
73 protected static void emitStackOverflowCheck(TargetMethodAssembler tasm, boolean afterFrameInit) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
74 if (StackShadowPages.getValue() > 0) {
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
75 SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
76 final int frameSize = tasm.frameMap.frameSize();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
77 if (frameSize > 0) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
78 int lastFramePage = frameSize / unsafe.pageSize();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
79 // emit multiple stack bangs for methods with frames larger than a page
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
80 for (int i = 0; i <= lastFramePage; i++) {
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
81 int disp = (i + StackShadowPages.getValue()) * unsafe.pageSize();
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
82 if (afterFrameInit) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
83 disp -= frameSize;
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
84 }
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
85 tasm.blockComment("[stack overflow check]");
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
86 // Use SPARCAddress to get the final displacement including the stack bias.
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
87 SPARCAddress address = new SPARCAddress(sp, -disp);
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
88 if (SPARCAssembler.isSimm13(address.getDisplacement())) {
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
89 new Stx(g0, address).emit(masm);
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
90 } else {
10792
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
91 new Setx(address.getDisplacement(), g3).emit(masm);
7a8d6ba83a04 SPARC: fixes and more stuff works
twisti
parents: 10694
diff changeset
92 new Stx(g0, new SPARCAddress(sp, g3)).emit(masm);
10694
31266ceb86ef SPARC: Can compile and run two or three methods of a bootstrap.
twisti
parents: 10686
diff changeset
93 }
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
94 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
95 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
96 }
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
97 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
98
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
99 public class HotSpotFrameContext implements FrameContext {
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
100
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
101 final boolean isStub;
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
102
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
103 HotSpotFrameContext(boolean isStub) {
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
104 this.isStub = isStub;
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
105 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
106
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
107 @Override
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
108 public void enter(TargetMethodAssembler tasm) {
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
109 final int alignment = target.wordSize * 2;
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
110 final int frameSize = (tasm.frameMap.frameSize() + (alignment - 1)) & ~(alignment - 1);
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
111 assert frameSize % alignment == 0 : "must preserve 2*wordSize alignment";
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
112
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
113 SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
114 if (!isStub) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
115 emitStackOverflowCheck(tasm, false);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
116 }
10686
73122b5edf6a SPARC: Can compile simple methods and do static calls.
twisti
parents: 10470
diff changeset
117 new Save(sp, -frameSize, sp).emit(masm);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
118
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
119 if (ZapStackOnMethodEntry.getValue()) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
120 final int slotSize = 8;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
121 for (int i = 0; i < frameSize / slotSize; ++i) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
122 // 0xC1C1C1C1
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
123 new Stx(g0, new SPARCAddress(sp, i * slotSize)).emit(masm);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
124 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
125 }
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
126 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
127
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
128 @Override
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
129 public void leave(TargetMethodAssembler tasm) {
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
130 SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
131 new RestoreWindow().emit(masm);
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
132 }
9432
6680389bd36f Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 8281
diff changeset
133 }
6680389bd36f Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 8281
diff changeset
134
6680389bd36f Make assembler creation in backend more extensible.
Roland Schatz <roland.schatz@oracle.com>
parents: 8281
diff changeset
135 @Override
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
136 protected AbstractAssembler createAssembler(FrameMap frameMap) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
137 return new SPARCMacroAssembler(target, frameMap.registerConfig);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
138 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
139
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
140 @Override
8281
8fde1be81b2d LIRGenerator is transmitted across backend passes instead of just the LIR so that backend-specific, per-compilation information can be attached to the backend-specific LIRGenerator object
Doug Simon <doug.simon@oracle.com>
parents: 7743
diff changeset
141 public TargetMethodAssembler newAssembler(LIRGenerator lirGen, CompilationResult compilationResult) {
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
142 SPARCHotSpotLIRGenerator gen = (SPARCHotSpotLIRGenerator) lirGen;
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
143 FrameMap frameMap = gen.frameMap;
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
144 assert gen.deoptimizationRescueSlot == null || frameMap.frameNeedsAllocating() : "method that can deoptimize must have a frame";
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
145
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
146 Stub stub = gen.getStub();
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
147 AbstractAssembler masm = createAssembler(frameMap);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
148 // On SPARC we always use stack frames.
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
149 HotSpotFrameContext frameContext = new HotSpotFrameContext(stub != null);
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
150 TargetMethodAssembler tasm = new TargetMethodAssembler(target, runtime(), frameMap, masm, frameContext, compilationResult);
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
151 tasm.setFrameSize(frameMap.frameSize());
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
152 StackSlot deoptimizationRescueSlot = gen.deoptimizationRescueSlot;
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
153 if (deoptimizationRescueSlot != null && stub == null) {
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
154 tasm.compilationResult.setCustomStackAreaOffset(frameMap.offsetForStackSlot(deoptimizationRescueSlot));
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
155 }
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
156
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
157 if (stub != null) {
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
158 // SPARC stubs always enter a frame which saves the registers.
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
159 final Set<Register> definedRegisters = new HashSet<>();
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
160 stub.initDestroyedRegisters(definedRegisters);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
161 }
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
162
9814
e723f9031785 re-architected SPARC assembler to be Fmt class specific, initial arithmetic
Morris Meyer <morris.meyer@oracle.com>
parents: 9621
diff changeset
163 return tasm;
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 }
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 @Override
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
167 public void emitCode(TargetMethodAssembler tasm, LIRGenerator lirGen, ResolvedJavaMethod installedCodeOwner) {
10470
53ba9df05fa2 fixed remaining SPARC warnings using ecj
twisti
parents: 10465
diff changeset
168 SPARCMacroAssembler masm = (SPARCMacroAssembler) tasm.asm;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
169 FrameMap frameMap = tasm.frameMap;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
170 RegisterConfig regConfig = frameMap.registerConfig;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
171 HotSpotVMConfig config = runtime().config;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
172 Label unverifiedStub = installedCodeOwner == null || isStatic(installedCodeOwner.getModifiers()) ? null : new Label();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
173
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
174 // Emit the prefix
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
175
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
176 if (unverifiedStub != null) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
177 tasm.recordMark(Marks.MARK_UNVERIFIED_ENTRY);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
178 // We need to use JavaCall here because we haven't entered the frame yet.
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
179 CallingConvention cc = regConfig.getCallingConvention(JavaCall, null, new JavaType[]{runtime().lookupJavaType(Object.class)}, target, false);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
180 Register inlineCacheKlass = g5; // see MacroAssembler::ic_call
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
181 Register scratch = g3;
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
182 Register receiver = asRegister(cc.getArgument(0));
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
183 SPARCAddress src = new SPARCAddress(receiver, config.hubOffset);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
184
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
185 new Ldx(src, scratch).emit(masm);
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
186 new Cmp(scratch, inlineCacheKlass).emit(masm);
10470
53ba9df05fa2 fixed remaining SPARC warnings using ecj
twisti
parents: 10465
diff changeset
187 new Bpne(CC.Xcc, unverifiedStub).emit(masm);
53ba9df05fa2 fixed remaining SPARC warnings using ecj
twisti
parents: 10465
diff changeset
188 new Nop().emit(masm); // delay slot
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
189 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
190
10470
53ba9df05fa2 fixed remaining SPARC warnings using ecj
twisti
parents: 10465
diff changeset
191 masm.align(config.codeEntryAlignment);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
192 tasm.recordMark(Marks.MARK_OSR_ENTRY);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
193 tasm.recordMark(Marks.MARK_VERIFIED_ENTRY);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
194
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
195 // Emit code for the LIR
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
196 lirGen.lir.emitCode(tasm);
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
197
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
198 HotSpotFrameContext frameContext = (HotSpotFrameContext) tasm.frameContext;
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
199 if (frameContext != null && !frameContext.isStub) {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
200 tasm.recordMark(Marks.MARK_EXCEPTION_HANDLER_ENTRY);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
201 SPARCCall.directCall(tasm, masm, runtime().lookupForeignCall(EXCEPTION_HANDLER), null, false, null);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
202 tasm.recordMark(Marks.MARK_DEOPT_HANDLER_ENTRY);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
203 SPARCCall.directCall(tasm, masm, runtime().lookupForeignCall(DEOPT_HANDLER), null, false, null);
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
204 } else {
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
205 // No need to emit the stubs for entries back into the method since
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
206 // it has no calls that can cause such "return" entries
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
207 assert !frameMap.accessesCallerFrame() : lirGen.getGraph();
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
208 }
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
209
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
210 if (unverifiedStub != null) {
10470
53ba9df05fa2 fixed remaining SPARC warnings using ecj
twisti
parents: 10465
diff changeset
211 masm.bind(unverifiedStub);
10854
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
212 Register scratch = g3;
e1fcdda22831 SPARC: can compile some stubs now but they don't work yet
twisti
parents: 10792
diff changeset
213 SPARCCall.indirectJmp(tasm, masm, scratch, runtime().lookupForeignCall(IC_MISS_HANDLER));
10459
f78079947084 some basic SPARC arithmetic works
twisti
parents: 9864
diff changeset
214 }
7740
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 }
5f8101629080 Add projects and skeletons for SPARC port.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }