annotate src/cpu/sparc/vm/macroAssembler_sparc.cpp @ 10102:f2e682ef3156

8012335: G1: Fix bug with compressed oops in template interpreter on x86 and sparc. Summary: In do_oop_store the uncompressed value of the oop being stored needs to be preserved and passed to g1_write_barrier_post. This is necessary for the heap region cross check to work correctly. Reviewed-by: coleenp, johnc Contributed-by: Martin Doerr <martin.doerr@sap.com>
author johnc
date Wed, 17 Apr 2013 10:57:02 -0700
parents a5de0cc2f91c
children 8d52e305a777
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1 /*
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4 *
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
7 * published by the Free Software Foundation.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
8 *
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
13 * accompanied this code).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
14 *
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
18 *
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
21 * questions.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
22 *
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
23 */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
24
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
25 #include "precompiled.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
26 #include "asm/assembler.inline.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
27 #include "compiler/disassembler.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
28 #include "gc_interface/collectedHeap.inline.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
29 #include "interpreter/interpreter.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
30 #include "memory/cardTableModRefBS.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
31 #include "memory/resourceArea.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
32 #include "prims/methodHandles.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
33 #include "runtime/biasedLocking.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
34 #include "runtime/interfaceSupport.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
35 #include "runtime/objectMonitor.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
36 #include "runtime/os.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
37 #include "runtime/sharedRuntime.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
38 #include "runtime/stubRoutines.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7476
diff changeset
39 #include "utilities/macros.hpp"
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7476
diff changeset
40 #if INCLUDE_ALL_GCS
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
41 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
42 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
43 #include "gc_implementation/g1/heapRegion.hpp"
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7476
diff changeset
44 #endif // INCLUDE_ALL_GCS
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
45
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
46 #ifdef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
47 #define BLOCK_COMMENT(str) /* nothing */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
48 #define STOP(error) stop(error)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
49 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
50 #define BLOCK_COMMENT(str) block_comment(str)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
51 #define STOP(error) block_comment(error); stop(error)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
52 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
53
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
54 // Convert the raw encoding form into the form expected by the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
55 // constructor for Address.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
56 Address Address::make_raw(int base, int index, int scale, int disp, relocInfo::relocType disp_reloc) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
57 assert(scale == 0, "not supported");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
58 RelocationHolder rspec;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
59 if (disp_reloc != relocInfo::none) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
60 rspec = Relocation::spec_simple(disp_reloc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
61 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
62
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
63 Register rindex = as_Register(index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
64 if (rindex != G0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
65 Address madr(as_Register(base), rindex);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
66 madr._rspec = rspec;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
67 return madr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
68 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
69 Address madr(as_Register(base), disp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
70 madr._rspec = rspec;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
71 return madr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
72 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
73 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
74
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
75 Address Argument::address_in_frame() const {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
76 // Warning: In LP64 mode disp will occupy more than 10 bits, but
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
77 // op codes such as ld or ldx, only access disp() to get
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
78 // their simm13 argument.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
79 int disp = ((_number - Argument::n_register_parameters + frame::memory_parameter_word_sp_offset) * BytesPerWord) + STACK_BIAS;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
80 if (is_in())
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
81 return Address(FP, disp); // In argument.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
82 else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
83 return Address(SP, disp); // Out argument.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
84 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
85
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
86 static const char* argumentNames[][2] = {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
87 {"A0","P0"}, {"A1","P1"}, {"A2","P2"}, {"A3","P3"}, {"A4","P4"},
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
88 {"A5","P5"}, {"A6","P6"}, {"A7","P7"}, {"A8","P8"}, {"A9","P9"},
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
89 {"A(n>9)","P(n>9)"}
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
90 };
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
91
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
92 const char* Argument::name() const {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
93 int nofArgs = sizeof argumentNames / sizeof argumentNames[0];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
94 int num = number();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
95 if (num >= nofArgs) num = nofArgs - 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
96 return argumentNames[num][is_in() ? 1 : 0];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
97 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
98
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
99 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
100 // On RISC, there's no benefit to verifying instruction boundaries.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
101 bool AbstractAssembler::pd_check_instruction_mark() { return false; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
102 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
103
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
104 // Patch instruction inst at offset inst_pos to refer to dest_pos
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
105 // and return the resulting instruction.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
106 // We should have pcs, not offsets, but since all is relative, it will work out
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
107 // OK.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
108 int MacroAssembler::patched_branch(int dest_pos, int inst, int inst_pos) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
109 int m; // mask for displacement field
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
110 int v; // new value for displacement field
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
111 const int word_aligned_ones = -4;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
112 switch (inv_op(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
113 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
114 case call_op: m = wdisp(word_aligned_ones, 0, 30); v = wdisp(dest_pos, inst_pos, 30); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
115 case branch_op:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
116 switch (inv_op2(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
117 case fbp_op2: m = wdisp( word_aligned_ones, 0, 19); v = wdisp( dest_pos, inst_pos, 19); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
118 case bp_op2: m = wdisp( word_aligned_ones, 0, 19); v = wdisp( dest_pos, inst_pos, 19); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
119 case fb_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
120 case br_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
121 case cb_op2: m = wdisp( word_aligned_ones, 0, 22); v = wdisp( dest_pos, inst_pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
122 case bpr_op2: {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
123 if (is_cbcond(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
124 m = wdisp10(word_aligned_ones, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
125 v = wdisp10(dest_pos, inst_pos);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
126 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
127 m = wdisp16(word_aligned_ones, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
128 v = wdisp16(dest_pos, inst_pos);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
129 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
130 break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
131 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
132 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
133 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
134 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
135 return inst & ~m | v;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
136 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
137
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
138 // Return the offset of the branch destionation of instruction inst
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
139 // at offset pos.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
140 // Should have pcs, but since all is relative, it works out.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
141 int MacroAssembler::branch_destination(int inst, int pos) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
142 int r;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
143 switch (inv_op(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
144 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
145 case call_op: r = inv_wdisp(inst, pos, 30); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
146 case branch_op:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
147 switch (inv_op2(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
148 case fbp_op2: r = inv_wdisp( inst, pos, 19); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
149 case bp_op2: r = inv_wdisp( inst, pos, 19); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
150 case fb_op2: r = inv_wdisp( inst, pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
151 case br_op2: r = inv_wdisp( inst, pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
152 case cb_op2: r = inv_wdisp( inst, pos, 22); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
153 case bpr_op2: {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
154 if (is_cbcond(inst)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
155 r = inv_wdisp10(inst, pos);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
156 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
157 r = inv_wdisp16(inst, pos);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
158 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
159 break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
160 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
161 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
162 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
163 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
164 return r;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
165 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
166
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
167 void MacroAssembler::null_check(Register reg, int offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
168 if (needs_explicit_null_check((intptr_t)offset)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
169 // provoke OS NULL exception if reg = NULL by
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
170 // accessing M[reg] w/o changing any registers
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
171 ld_ptr(reg, 0, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
172 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
173 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
174 // nothing to do, (later) access of M[reg + offset]
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
175 // will provoke OS NULL exception if reg = NULL
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
176 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
177 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
178
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
179 // Ring buffer jumps
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
180
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
181 #ifndef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
182 void MacroAssembler::ret( bool trace ) { if (trace) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
183 mov(I7, O7); // traceable register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
184 JMP(O7, 2 * BytesPerInstWord);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
185 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
186 jmpl( I7, 2 * BytesPerInstWord, G0 );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
187 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
188 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
189
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
190 void MacroAssembler::retl( bool trace ) { if (trace) JMP(O7, 2 * BytesPerInstWord);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
191 else jmpl( O7, 2 * BytesPerInstWord, G0 ); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
192 #endif /* PRODUCT */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
193
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
194
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
195 void MacroAssembler::jmp2(Register r1, Register r2, const char* file, int line ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
196 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
197 // This can only be traceable if r1 & r2 are visible after a window save
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
198 if (TraceJumps) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
199 #ifndef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
200 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
201 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
202 ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
203 add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
204 sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
205 add(O2, O1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
206
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
207 add(r1->after_save(), r2->after_save(), O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
208 set((intptr_t)file, O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
209 set(line, O4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
210 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
211 // get nearby pc, store jmp target
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
212 call(L, relocInfo::none); // No relocation for call to pc+0x8
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
213 delayed()->st(O2, O1, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
214 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
215
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
216 // store nearby pc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
217 st(O7, O1, sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
218 // store file
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
219 st(O3, O1, 2*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
220 // store line
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
221 st(O4, O1, 3*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
222 add(O0, 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
223 and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
224 st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
225 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
226 #endif /* PRODUCT */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
227 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
228 jmpl(r1, r2, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
229 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
230 void MacroAssembler::jmp(Register r1, int offset, const char* file, int line ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
231 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
232 // This can only be traceable if r1 is visible after a window save
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
233 if (TraceJumps) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
234 #ifndef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
235 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
236 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
237 ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
238 add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
239 sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
240 add(O2, O1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
241
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
242 add(r1->after_save(), offset, O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
243 set((intptr_t)file, O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
244 set(line, O4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
245 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
246 // get nearby pc, store jmp target
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
247 call(L, relocInfo::none); // No relocation for call to pc+0x8
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
248 delayed()->st(O2, O1, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
249 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
250
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
251 // store nearby pc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
252 st(O7, O1, sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
253 // store file
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
254 st(O3, O1, 2*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
255 // store line
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
256 st(O4, O1, 3*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
257 add(O0, 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
258 and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
259 st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
260 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
261 #endif /* PRODUCT */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
262 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
263 jmp(r1, offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
264 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
265
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
266 // This code sequence is relocatable to any address, even on LP64.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
267 void MacroAssembler::jumpl(const AddressLiteral& addrlit, Register temp, Register d, int offset, const char* file, int line) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
268 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
269 // Force fixed length sethi because NativeJump and NativeFarCall don't handle
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
270 // variable length instruction streams.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
271 patchable_sethi(addrlit, temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
272 Address a(temp, addrlit.low10() + offset); // Add the offset to the displacement.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
273 if (TraceJumps) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
274 #ifndef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
275 // Must do the add here so relocation can find the remainder of the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
276 // value to be relocated.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
277 add(a.base(), a.disp(), a.base(), addrlit.rspec(offset));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
278 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
279 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
280 ld(G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()), O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
281 add(G2_thread, in_bytes(JavaThread::jmp_ring_offset()), O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
282 sll(O0, exact_log2(4*sizeof(intptr_t)), O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
283 add(O2, O1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
284
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
285 set((intptr_t)file, O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
286 set(line, O4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
287 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
288
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
289 // get nearby pc, store jmp target
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
290 call(L, relocInfo::none); // No relocation for call to pc+0x8
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
291 delayed()->st(a.base()->after_save(), O1, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
292 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
293
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
294 // store nearby pc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
295 st(O7, O1, sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
296 // store file
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
297 st(O3, O1, 2*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
298 // store line
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
299 st(O4, O1, 3*sizeof(intptr_t));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
300 add(O0, 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
301 and3(O0, JavaThread::jump_ring_buffer_size - 1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
302 st(O0, G2_thread, in_bytes(JavaThread::jmp_ring_index_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
303 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
304 jmpl(a.base(), G0, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
305 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
306 jmpl(a.base(), a.disp(), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
307 #endif /* PRODUCT */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
308 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
309 jmpl(a.base(), a.disp(), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
310 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
311 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
312
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
313 void MacroAssembler::jump(const AddressLiteral& addrlit, Register temp, int offset, const char* file, int line) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
314 jumpl(addrlit, temp, G0, offset, file, line);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
315 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
316
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
317
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
318 // Conditional breakpoint (for assertion checks in assembly code)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
319 void MacroAssembler::breakpoint_trap(Condition c, CC cc) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
320 trap(c, cc, G0, ST_RESERVED_FOR_USER_0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
321 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
322
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
323 // We want to use ST_BREAKPOINT here, but the debugger is confused by it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
324 void MacroAssembler::breakpoint_trap() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
325 trap(ST_RESERVED_FOR_USER_0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
326 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
327
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
328 // flush windows (except current) using flushw instruction if avail.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
329 void MacroAssembler::flush_windows() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
330 if (VM_Version::v9_instructions_work()) flushw();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
331 else flush_windows_trap();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
332 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
333
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
334 // Write serialization page so VM thread can do a pseudo remote membar
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
335 // We use the current thread pointer to calculate a thread specific
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
336 // offset to write to within the page. This minimizes bus traffic
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
337 // due to cache line collision.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
338 void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
339 srl(thread, os::get_serialize_page_shift_count(), tmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
340 if (Assembler::is_simm13(os::vm_page_size())) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
341 and3(tmp2, (os::vm_page_size() - sizeof(int)), tmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
342 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
343 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
344 set((os::vm_page_size() - sizeof(int)), tmp1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
345 and3(tmp2, tmp1, tmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
346 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
347 set(os::get_memory_serialize_page(), tmp1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
348 st(G0, tmp1, tmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
349 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
350
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
351
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
352
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
353 void MacroAssembler::enter() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
354 Unimplemented();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
355 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
356
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
357 void MacroAssembler::leave() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
358 Unimplemented();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
359 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
360
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
361 void MacroAssembler::mult(Register s1, Register s2, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
362 if(VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
363 mulx (s1, s2, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
364 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
365 smul (s1, s2, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
366 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
367 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
368
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
369 void MacroAssembler::mult(Register s1, int simm13a, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
370 if(VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
371 mulx (s1, simm13a, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
372 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
373 smul (s1, simm13a, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
374 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
375 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
376
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
377
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
378 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
379 void MacroAssembler::read_ccr_v8_assert(Register ccr_save) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
380 const Register s1 = G3_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
381 const Register s2 = G4_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
382 Label get_psr_test;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
383 // Get the condition codes the V8 way.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
384 read_ccr_trap(s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
385 mov(ccr_save, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
386 // This is a test of V8 which has icc but not xcc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
387 // so mask off the xcc bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
388 and3(s2, 0xf, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
389 // Compare condition codes from the V8 and V9 ways.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
390 subcc(s2, s1, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
391 br(Assembler::notEqual, true, Assembler::pt, get_psr_test);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
392 delayed()->breakpoint_trap();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
393 bind(get_psr_test);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
394 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
395
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
396 void MacroAssembler::write_ccr_v8_assert(Register ccr_save) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
397 const Register s1 = G3_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
398 const Register s2 = G4_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
399 Label set_psr_test;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
400 // Write out the saved condition codes the V8 way
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
401 write_ccr_trap(ccr_save, s1, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
402 // Read back the condition codes using the V9 instruction
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
403 rdccr(s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
404 mov(ccr_save, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
405 // This is a test of V8 which has icc but not xcc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
406 // so mask off the xcc bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
407 and3(s2, 0xf, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
408 and3(s1, 0xf, s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
409 // Compare the V8 way with the V9 way.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
410 subcc(s2, s1, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
411 br(Assembler::notEqual, true, Assembler::pt, set_psr_test);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
412 delayed()->breakpoint_trap();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
413 bind(set_psr_test);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
414 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
415 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
416 #define read_ccr_v8_assert(x)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
417 #define write_ccr_v8_assert(x)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
418 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
419
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
420 void MacroAssembler::read_ccr(Register ccr_save) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
421 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
422 rdccr(ccr_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
423 // Test code sequence used on V8. Do not move above rdccr.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
424 read_ccr_v8_assert(ccr_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
425 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
426 read_ccr_trap(ccr_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
427 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
428 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
429
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
430 void MacroAssembler::write_ccr(Register ccr_save) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
431 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
432 // Test code sequence used on V8. Do not move below wrccr.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
433 write_ccr_v8_assert(ccr_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
434 wrccr(ccr_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
435 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
436 const Register temp_reg1 = G3_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
437 const Register temp_reg2 = G4_scratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
438 write_ccr_trap(ccr_save, temp_reg1, temp_reg2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
439 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
440 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
441
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
442
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
443 // Calls to C land
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
444
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
445 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
446 // a hook for debugging
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
447 static Thread* reinitialize_thread() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
448 return ThreadLocalStorage::thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
449 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
450 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
451 #define reinitialize_thread ThreadLocalStorage::thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
452 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
453
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
454 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
455 address last_get_thread = NULL;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
456 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
457
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
458 // call this when G2_thread is not known to be valid
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
459 void MacroAssembler::get_thread() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
460 save_frame(0); // to avoid clobbering O0
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
461 mov(G1, L0); // avoid clobbering G1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
462 mov(G5_method, L1); // avoid clobbering G5
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
463 mov(G3, L2); // avoid clobbering G3 also
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
464 mov(G4, L5); // avoid clobbering G4
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
465 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
466 AddressLiteral last_get_thread_addrlit(&last_get_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
467 set(last_get_thread_addrlit, L3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
468 inc(L4, get_pc(L4) + 2 * BytesPerInstWord); // skip getpc() code + inc + st_ptr to point L4 at call
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
469 st_ptr(L4, L3, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
470 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
471 call(CAST_FROM_FN_PTR(address, reinitialize_thread), relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
472 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
473 mov(L0, G1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
474 mov(L1, G5_method);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
475 mov(L2, G3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
476 mov(L5, G4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
477 restore(O0, 0, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
478 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
479
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
480 static Thread* verify_thread_subroutine(Thread* gthread_value) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
481 Thread* correct_value = ThreadLocalStorage::thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
482 guarantee(gthread_value == correct_value, "G2_thread value must be the thread");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
483 return correct_value;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
484 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
485
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
486 void MacroAssembler::verify_thread() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
487 if (VerifyThread) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
488 // NOTE: this chops off the heads of the 64-bit O registers.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
489 #ifdef CC_INTERP
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
490 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
491 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
492 // make sure G2_thread contains the right value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
493 save_frame_and_mov(0, Lmethod, Lmethod); // to avoid clobbering O0 (and propagate Lmethod for -Xprof)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
494 mov(G1, L1); // avoid clobbering G1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
495 // G2 saved below
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
496 mov(G3, L3); // avoid clobbering G3
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
497 mov(G4, L4); // avoid clobbering G4
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
498 mov(G5_method, L5); // avoid clobbering G5_method
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
499 #endif /* CC_INTERP */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
500 #if defined(COMPILER2) && !defined(_LP64)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
501 // Save & restore possible 64-bit Long arguments in G-regs
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
502 srlx(G1,32,L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
503 srlx(G4,32,L6);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
504 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
505 call(CAST_FROM_FN_PTR(address,verify_thread_subroutine), relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
506 delayed()->mov(G2_thread, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
507
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
508 mov(L1, G1); // Restore G1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
509 // G2 restored below
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
510 mov(L3, G3); // restore G3
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
511 mov(L4, G4); // restore G4
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
512 mov(L5, G5_method); // restore G5_method
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
513 #if defined(COMPILER2) && !defined(_LP64)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
514 // Save & restore possible 64-bit Long arguments in G-regs
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
515 sllx(L0,32,G2); // Move old high G1 bits high in G2
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
516 srl(G1, 0,G1); // Clear current high G1 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
517 or3 (G1,G2,G1); // Recover 64-bit G1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
518 sllx(L6,32,G2); // Move old high G4 bits high in G2
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
519 srl(G4, 0,G4); // Clear current high G4 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
520 or3 (G4,G2,G4); // Recover 64-bit G4
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
521 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
522 restore(O0, 0, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
523 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
524 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
525
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
526
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
527 void MacroAssembler::save_thread(const Register thread_cache) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
528 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
529 if (thread_cache->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
530 assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
531 mov(G2_thread, thread_cache);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
532 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
533 if (VerifyThread) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
534 // smash G2_thread, as if the VM were about to anyway
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
535 set(0x67676767, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
536 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
537 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
538
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
539
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
540 void MacroAssembler::restore_thread(const Register thread_cache) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
541 if (thread_cache->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
542 assert(thread_cache->is_local() || thread_cache->is_in(), "bad volatile");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
543 mov(thread_cache, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
544 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
545 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
546 // do it the slow way
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
547 get_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
548 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
549 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
550
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
551
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
552 // %%% maybe get rid of [re]set_last_Java_frame
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
553 void MacroAssembler::set_last_Java_frame(Register last_java_sp, Register last_Java_pc) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
554 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
555 Address flags(G2_thread, JavaThread::frame_anchor_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
556 JavaFrameAnchor::flags_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
557 Address pc_addr(G2_thread, JavaThread::last_Java_pc_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
558
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
559 // Always set last_Java_pc and flags first because once last_Java_sp is visible
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
560 // has_last_Java_frame is true and users will look at the rest of the fields.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
561 // (Note: flags should always be zero before we get here so doesn't need to be set.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
562
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
563 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
564 // Verify that flags was zeroed on return to Java
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
565 Label PcOk;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
566 save_frame(0); // to avoid clobbering O0
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
567 ld_ptr(pc_addr, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
568 br_null_short(L0, Assembler::pt, PcOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
569 STOP("last_Java_pc not zeroed before leaving Java");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
570 bind(PcOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
571
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
572 // Verify that flags was zeroed on return to Java
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
573 Label FlagsOk;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
574 ld(flags, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
575 tst(L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
576 br(Assembler::zero, false, Assembler::pt, FlagsOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
577 delayed() -> restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
578 STOP("flags not zeroed before leaving Java");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
579 bind(FlagsOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
580 #endif /* ASSERT */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
581 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
582 // When returning from calling out from Java mode the frame anchor's last_Java_pc
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
583 // will always be set to NULL. It is set here so that if we are doing a call to
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
584 // native (not VM) that we capture the known pc and don't have to rely on the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
585 // native call having a standard frame linkage where we can find the pc.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
586
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
587 if (last_Java_pc->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
588 st_ptr(last_Java_pc, pc_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
589 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
590
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
591 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
592 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
593 // Make sure that we have an odd stack
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
594 Label StackOk;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
595 andcc(last_java_sp, 0x01, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
596 br(Assembler::notZero, false, Assembler::pt, StackOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
597 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
598 STOP("Stack Not Biased in set_last_Java_frame");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
599 bind(StackOk);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
600 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
601 assert( last_java_sp != G4_scratch, "bad register usage in set_last_Java_frame");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
602 add( last_java_sp, STACK_BIAS, G4_scratch );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
603 st_ptr(G4_scratch, G2_thread, JavaThread::last_Java_sp_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
604 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
605 st_ptr(last_java_sp, G2_thread, JavaThread::last_Java_sp_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
606 #endif // _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
607 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
608
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
609 void MacroAssembler::reset_last_Java_frame(void) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
610 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
611
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
612 Address sp_addr(G2_thread, JavaThread::last_Java_sp_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
613 Address pc_addr(G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::last_Java_pc_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
614 Address flags (G2_thread, JavaThread::frame_anchor_offset() + JavaFrameAnchor::flags_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
615
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
616 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
617 // check that it WAS previously set
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
618 #ifdef CC_INTERP
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
619 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
620 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
621 save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod to helper frame for -Xprof
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
622 #endif /* CC_INTERP */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
623 ld_ptr(sp_addr, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
624 tst(L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
625 breakpoint_trap(Assembler::zero, Assembler::ptr_cc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
626 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
627 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
628
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
629 st_ptr(G0, sp_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
630 // Always return last_Java_pc to zero
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
631 st_ptr(G0, pc_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
632 // Always null flags after return to Java
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
633 st(G0, flags);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
634 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
635
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
636
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
637 void MacroAssembler::call_VM_base(
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
638 Register oop_result,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
639 Register thread_cache,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
640 Register last_java_sp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
641 address entry_point,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
642 int number_of_arguments,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
643 bool check_exceptions)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
644 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
645 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
646
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
647 // determine last_java_sp register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
648 if (!last_java_sp->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
649 last_java_sp = SP;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
650 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
651 // debugging support
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
652 assert(number_of_arguments >= 0 , "cannot have negative number of arguments");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
653
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
654 // 64-bit last_java_sp is biased!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
655 set_last_Java_frame(last_java_sp, noreg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
656 if (VerifyThread) mov(G2_thread, O0); // about to be smashed; pass early
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
657 save_thread(thread_cache);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
658 // do the call
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
659 call(entry_point, relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
660 if (!VerifyThread)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
661 delayed()->mov(G2_thread, O0); // pass thread as first argument
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
662 else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
663 delayed()->nop(); // (thread already passed)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
664 restore_thread(thread_cache);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
665 reset_last_Java_frame();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
666
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
667 // check for pending exceptions. use Gtemp as scratch register.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
668 if (check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
669 check_and_forward_exception(Gtemp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
670 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
671
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
672 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
673 set(badHeapWordVal, G3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
674 set(badHeapWordVal, G4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
675 set(badHeapWordVal, G5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
676 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
677
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
678 // get oop result if there is one and reset the value in the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
679 if (oop_result->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
680 get_vm_result(oop_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
681 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
682 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
683
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
684 void MacroAssembler::check_and_forward_exception(Register scratch_reg)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
685 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
686 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
687
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
688 check_and_handle_popframe(scratch_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
689 check_and_handle_earlyret(scratch_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
690
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
691 Address exception_addr(G2_thread, Thread::pending_exception_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
692 ld_ptr(exception_addr, scratch_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
693 br_null_short(scratch_reg, pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
694 // we use O7 linkage so that forward_exception_entry has the issuing PC
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
695 call(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
696 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
697 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
698 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
699
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
700
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
701 void MacroAssembler::check_and_handle_popframe(Register scratch_reg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
702 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
703
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
704
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
705 void MacroAssembler::check_and_handle_earlyret(Register scratch_reg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
706 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
707
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
708
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
709 void MacroAssembler::call_VM(Register oop_result, address entry_point, int number_of_arguments, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
710 call_VM_base(oop_result, noreg, noreg, entry_point, number_of_arguments, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
711 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
712
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
713
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
714 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
715 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
716 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
717 call_VM(oop_result, entry_point, 1, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
718 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
719
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
720
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
721 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
722 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
723 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
724 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
725 call_VM(oop_result, entry_point, 2, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
726 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
727
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
728
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
729 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
730 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
731 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
732 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
733 mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
734 call_VM(oop_result, entry_point, 3, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
735 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
736
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
737
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
738
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
739 // Note: The following call_VM overloadings are useful when a "save"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
740 // has already been performed by a stub, and the last Java frame is
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
741 // the previous one. In that case, last_java_sp must be passed as FP
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
742 // instead of SP.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
743
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
744
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
745 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, int number_of_arguments, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
746 call_VM_base(oop_result, noreg, last_java_sp, entry_point, number_of_arguments, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
747 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
748
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
749
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
750 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
751 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
752 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
753 call_VM(oop_result, last_java_sp, entry_point, 1, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
754 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
755
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
756
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
757 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
758 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
759 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
760 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
761 call_VM(oop_result, last_java_sp, entry_point, 2, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
762 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
763
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
764
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
765 void MacroAssembler::call_VM(Register oop_result, Register last_java_sp, address entry_point, Register arg_1, Register arg_2, Register arg_3, bool check_exceptions) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
766 // O0 is reserved for the thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
767 mov(arg_1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
768 mov(arg_2, O2); assert(arg_2 != O1, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
769 mov(arg_3, O3); assert(arg_3 != O1 && arg_3 != O2, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
770 call_VM(oop_result, last_java_sp, entry_point, 3, check_exceptions);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
771 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
772
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
773
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
774
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
775 void MacroAssembler::call_VM_leaf_base(Register thread_cache, address entry_point, int number_of_arguments) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
776 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
777 save_thread(thread_cache);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
778 // do the call
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
779 call(entry_point, relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
780 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
781 restore_thread(thread_cache);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
782 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
783 set(badHeapWordVal, G3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
784 set(badHeapWordVal, G4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
785 set(badHeapWordVal, G5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
786 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
787 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
788
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
789
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
790 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, int number_of_arguments) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
791 call_VM_leaf_base(thread_cache, entry_point, number_of_arguments);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
792 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
793
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
794
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
795 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
796 mov(arg_1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
797 call_VM_leaf(thread_cache, entry_point, 1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
798 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
799
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
800
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
801 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
802 mov(arg_1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
803 mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
804 call_VM_leaf(thread_cache, entry_point, 2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
805 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
806
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
807
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
808 void MacroAssembler::call_VM_leaf(Register thread_cache, address entry_point, Register arg_1, Register arg_2, Register arg_3) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
809 mov(arg_1, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
810 mov(arg_2, O1); assert(arg_2 != O0, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
811 mov(arg_3, O2); assert(arg_3 != O0 && arg_3 != O1, "smashed argument");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
812 call_VM_leaf(thread_cache, entry_point, 3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
813 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
814
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
815
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
816 void MacroAssembler::get_vm_result(Register oop_result) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
817 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
818 Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
819 ld_ptr( vm_result_addr, oop_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
820 st_ptr(G0, vm_result_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
821 verify_oop(oop_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
822 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
823
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
824
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
825 void MacroAssembler::get_vm_result_2(Register metadata_result) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
826 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
827 Address vm_result_addr_2(G2_thread, JavaThread::vm_result_2_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
828 ld_ptr(vm_result_addr_2, metadata_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
829 st_ptr(G0, vm_result_addr_2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
830 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
831
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
832
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
833 // We require that C code which does not return a value in vm_result will
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
834 // leave it undisturbed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
835 void MacroAssembler::set_vm_result(Register oop_result) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
836 verify_thread();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
837 Address vm_result_addr(G2_thread, JavaThread::vm_result_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
838 verify_oop(oop_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
839
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
840 # ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
841 // Check that we are not overwriting any other oop.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
842 #ifdef CC_INTERP
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
843 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
844 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
845 save_frame_and_mov(0, Lmethod, Lmethod); // Propagate Lmethod for -Xprof
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
846 #endif /* CC_INTERP */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
847 ld_ptr(vm_result_addr, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
848 tst(L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
849 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
850 breakpoint_trap(notZero, Assembler::ptr_cc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
851 // }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
852 # endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
853
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
854 st_ptr(oop_result, vm_result_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
855 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
856
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
857
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
858 void MacroAssembler::ic_call(address entry, bool emit_delay) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
859 RelocationHolder rspec = virtual_call_Relocation::spec(pc());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
860 patchable_set((intptr_t)Universe::non_oop_word(), G5_inline_cache_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
861 relocate(rspec);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
862 call(entry, relocInfo::none);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
863 if (emit_delay) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
864 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
865 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
866 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
867
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
868
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
869 void MacroAssembler::card_table_write(jbyte* byte_map_base,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
870 Register tmp, Register obj) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
871 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
872 srlx(obj, CardTableModRefBS::card_shift, obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
873 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
874 srl(obj, CardTableModRefBS::card_shift, obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
875 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
876 assert(tmp != obj, "need separate temp reg");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
877 set((address) byte_map_base, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
878 stb(G0, tmp, obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
879 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
880
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
881
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
882 void MacroAssembler::internal_sethi(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
883 address save_pc;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
884 int shiftcnt;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
885 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
886 # ifdef CHECK_DELAY
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
887 assert_not_delayed((char*) "cannot put two instructions in delay slot");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
888 # endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
889 v9_dep();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
890 save_pc = pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
891
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
892 int msb32 = (int) (addrlit.value() >> 32);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
893 int lsb32 = (int) (addrlit.value());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
894
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
895 if (msb32 == 0 && lsb32 >= 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
896 Assembler::sethi(lsb32, d, addrlit.rspec());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
897 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
898 else if (msb32 == -1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
899 Assembler::sethi(~lsb32, d, addrlit.rspec());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
900 xor3(d, ~low10(~0), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
901 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
902 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
903 Assembler::sethi(msb32, d, addrlit.rspec()); // msb 22-bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
904 if (msb32 & 0x3ff) // Any bits?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
905 or3(d, msb32 & 0x3ff, d); // msb 32-bits are now in lsb 32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
906 if (lsb32 & 0xFFFFFC00) { // done?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
907 if ((lsb32 >> 20) & 0xfff) { // Any bits set?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
908 sllx(d, 12, d); // Make room for next 12 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
909 or3(d, (lsb32 >> 20) & 0xfff, d); // Or in next 12
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
910 shiftcnt = 0; // We already shifted
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
911 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
912 else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
913 shiftcnt = 12;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
914 if ((lsb32 >> 10) & 0x3ff) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
915 sllx(d, shiftcnt + 10, d); // Make room for last 10 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
916 or3(d, (lsb32 >> 10) & 0x3ff, d); // Or in next 10
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
917 shiftcnt = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
918 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
919 else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
920 shiftcnt = 10;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
921 sllx(d, shiftcnt + 10, d); // Shift leaving disp field 0'd
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
922 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
923 else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
924 sllx(d, 32, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
925 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
926 // Pad out the instruction sequence so it can be patched later.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
927 if (ForceRelocatable || (addrlit.rtype() != relocInfo::none &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
928 addrlit.rtype() != relocInfo::runtime_call_type)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
929 while (pc() < (save_pc + (7 * BytesPerInstWord)))
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
930 nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
931 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
932 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
933 Assembler::sethi(addrlit.value(), d, addrlit.rspec());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
934 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
935 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
936
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
937
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
938 void MacroAssembler::sethi(const AddressLiteral& addrlit, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
939 internal_sethi(addrlit, d, false);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
940 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
941
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
942
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
943 void MacroAssembler::patchable_sethi(const AddressLiteral& addrlit, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
944 internal_sethi(addrlit, d, true);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
945 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
946
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
947
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
948 int MacroAssembler::insts_for_sethi(address a, bool worst_case) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
949 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
950 if (worst_case) return 7;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
951 intptr_t iaddr = (intptr_t) a;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
952 int msb32 = (int) (iaddr >> 32);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
953 int lsb32 = (int) (iaddr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
954 int count;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
955 if (msb32 == 0 && lsb32 >= 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
956 count = 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
957 else if (msb32 == -1)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
958 count = 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
959 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
960 count = 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
961 if (msb32 & 0x3ff)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
962 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
963 if (lsb32 & 0xFFFFFC00 ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
964 if ((lsb32 >> 20) & 0xfff) count += 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
965 if ((lsb32 >> 10) & 0x3ff) count += 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
966 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
967 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
968 return count;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
969 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
970 return 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
971 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
972 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
973
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
974 int MacroAssembler::worst_case_insts_for_set() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
975 return insts_for_sethi(NULL, true) + 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
976 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
977
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
978
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
979 // Keep in sync with MacroAssembler::insts_for_internal_set
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
980 void MacroAssembler::internal_set(const AddressLiteral& addrlit, Register d, bool ForceRelocatable) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
981 intptr_t value = addrlit.value();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
982
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
983 if (!ForceRelocatable && addrlit.rspec().type() == relocInfo::none) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
984 // can optimize
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
985 if (-4096 <= value && value <= 4095) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
986 or3(G0, value, d); // setsw (this leaves upper 32 bits sign-extended)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
987 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
988 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
989 if (inv_hi22(hi22(value)) == value) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
990 sethi(addrlit, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
991 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
992 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
993 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
994 assert_not_delayed((char*) "cannot put two instructions in delay slot");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
995 internal_sethi(addrlit, d, ForceRelocatable);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
996 if (ForceRelocatable || addrlit.rspec().type() != relocInfo::none || addrlit.low10() != 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
997 add(d, addrlit.low10(), d, addrlit.rspec());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
998 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
999 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1000
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1001 // Keep in sync with MacroAssembler::internal_set
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1002 int MacroAssembler::insts_for_internal_set(intptr_t value) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1003 // can optimize
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1004 if (-4096 <= value && value <= 4095) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1005 return 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1006 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1007 if (inv_hi22(hi22(value)) == value) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1008 return insts_for_sethi((address) value);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1009 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1010 int count = insts_for_sethi((address) value);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1011 AddressLiteral al(value);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1012 if (al.low10() != 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1013 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1014 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1015 return count;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1016 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1017
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1018 void MacroAssembler::set(const AddressLiteral& al, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1019 internal_set(al, d, false);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1020 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1021
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1022 void MacroAssembler::set(intptr_t value, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1023 AddressLiteral al(value);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1024 internal_set(al, d, false);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1025 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1026
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1027 void MacroAssembler::set(address addr, Register d, RelocationHolder const& rspec) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1028 AddressLiteral al(addr, rspec);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1029 internal_set(al, d, false);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1030 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1031
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1032 void MacroAssembler::patchable_set(const AddressLiteral& al, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1033 internal_set(al, d, true);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1034 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1035
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1036 void MacroAssembler::patchable_set(intptr_t value, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1037 AddressLiteral al(value);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1038 internal_set(al, d, true);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1039 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1040
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1041
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1042 void MacroAssembler::set64(jlong value, Register d, Register tmp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1043 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1044 v9_dep();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1045
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1046 int hi = (int)(value >> 32);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1047 int lo = (int)(value & ~0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1048 // (Matcher::isSimpleConstant64 knows about the following optimizations.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1049 if (Assembler::is_simm13(lo) && value == lo) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1050 or3(G0, lo, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1051 } else if (hi == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1052 Assembler::sethi(lo, d); // hardware version zero-extends to upper 32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1053 if (low10(lo) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1054 or3(d, low10(lo), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1055 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1056 else if (hi == -1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1057 Assembler::sethi(~lo, d); // hardware version zero-extends to upper 32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1058 xor3(d, low10(lo) ^ ~low10(~0), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1059 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1060 else if (lo == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1061 if (Assembler::is_simm13(hi)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1062 or3(G0, hi, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1063 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1064 Assembler::sethi(hi, d); // hardware version zero-extends to upper 32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1065 if (low10(hi) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1066 or3(d, low10(hi), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1067 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1068 sllx(d, 32, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1069 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1070 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1071 Assembler::sethi(hi, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1072 Assembler::sethi(lo, d); // macro assembler version sign-extends
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1073 if (low10(hi) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1074 or3 (tmp, low10(hi), tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1075 if (low10(lo) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1076 or3 ( d, low10(lo), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1077 sllx(tmp, 32, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1078 or3 (d, tmp, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1079 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1080 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1081
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1082 int MacroAssembler::insts_for_set64(jlong value) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1083 v9_dep();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1084
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1085 int hi = (int) (value >> 32);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1086 int lo = (int) (value & ~0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1087 int count = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1088
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1089 // (Matcher::isSimpleConstant64 knows about the following optimizations.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1090 if (Assembler::is_simm13(lo) && value == lo) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1091 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1092 } else if (hi == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1093 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1094 if (low10(lo) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1095 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1096 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1097 else if (hi == -1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1098 count += 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1099 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1100 else if (lo == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1101 if (Assembler::is_simm13(hi)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1102 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1103 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1104 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1105 if (low10(hi) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1106 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1107 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1108 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1109 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1110 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1111 count += 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1112 if (low10(hi) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1113 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1114 if (low10(lo) != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1115 count++;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1116 count += 2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1117 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1118 return count;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1119 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1120
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1121 // compute size in bytes of sparc frame, given
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1122 // number of extraWords
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1123 int MacroAssembler::total_frame_size_in_bytes(int extraWords) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1124
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1125 int nWords = frame::memory_parameter_word_sp_offset;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1126
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1127 nWords += extraWords;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1128
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1129 if (nWords & 1) ++nWords; // round up to double-word
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1130
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1131 return nWords * BytesPerWord;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1132 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1133
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1134
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1135 // save_frame: given number of "extra" words in frame,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1136 // issue approp. save instruction (p 200, v8 manual)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1137
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1138 void MacroAssembler::save_frame(int extraWords) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1139 int delta = -total_frame_size_in_bytes(extraWords);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1140 if (is_simm13(delta)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1141 save(SP, delta, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1142 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1143 set(delta, G3_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1144 save(SP, G3_scratch, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1145 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1146 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1147
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1148
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1149 void MacroAssembler::save_frame_c1(int size_in_bytes) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1150 if (is_simm13(-size_in_bytes)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1151 save(SP, -size_in_bytes, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1152 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1153 set(-size_in_bytes, G3_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1154 save(SP, G3_scratch, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1155 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1156 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1157
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1158
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1159 void MacroAssembler::save_frame_and_mov(int extraWords,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1160 Register s1, Register d1,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1161 Register s2, Register d2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1162 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1163
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1164 // The trick here is to use precisely the same memory word
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1165 // that trap handlers also use to save the register.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1166 // This word cannot be used for any other purpose, but
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1167 // it works fine to save the register's value, whether or not
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1168 // an interrupt flushes register windows at any given moment!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1169 Address s1_addr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1170 if (s1->is_valid() && (s1->is_in() || s1->is_local())) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1171 s1_addr = s1->address_in_saved_window();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1172 st_ptr(s1, s1_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1173 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1174
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1175 Address s2_addr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1176 if (s2->is_valid() && (s2->is_in() || s2->is_local())) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1177 s2_addr = s2->address_in_saved_window();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1178 st_ptr(s2, s2_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1179 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1180
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1181 save_frame(extraWords);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1182
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1183 if (s1_addr.base() == SP) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1184 ld_ptr(s1_addr.after_save(), d1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1185 } else if (s1->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1186 mov(s1->after_save(), d1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1187 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1188
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1189 if (s2_addr.base() == SP) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1190 ld_ptr(s2_addr.after_save(), d2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1191 } else if (s2->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1192 mov(s2->after_save(), d2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1193 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1194 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1195
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1196
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1197 AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1198 assert(oop_recorder() != NULL, "this assembler needs a Recorder");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1199 int index = oop_recorder()->allocate_metadata_index(obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1200 RelocationHolder rspec = metadata_Relocation::spec(index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1201 return AddressLiteral((address)obj, rspec);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1202 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1203
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1204 AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1205 assert(oop_recorder() != NULL, "this assembler needs a Recorder");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1206 int index = oop_recorder()->find_index(obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1207 RelocationHolder rspec = metadata_Relocation::spec(index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1208 return AddressLiteral((address)obj, rspec);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1209 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1210
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1211
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1212 AddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1213 assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1214 assert(Universe::heap()->is_in_reserved(JNIHandles::resolve(obj)), "not an oop");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1215 int oop_index = oop_recorder()->find_index(obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1216 return AddressLiteral(obj, oop_Relocation::spec(oop_index));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1217 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1218
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1219 void MacroAssembler::set_narrow_oop(jobject obj, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1220 assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1221 int oop_index = oop_recorder()->find_index(obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1222 RelocationHolder rspec = oop_Relocation::spec(oop_index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1223
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1224 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1225 // Relocation with special format (see relocInfo_sparc.hpp).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1226 relocate(rspec, 1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1227 // Assembler::sethi(0x3fffff, d);
7476
ffa87474d7a4 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 7420
diff changeset
1228 emit_int32( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(0x3fffff) );
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1229 // Don't add relocation for 'add'. Do patching during 'sethi' processing.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1230 add(d, 0x3ff, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1231
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1232 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1233
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1234 void MacroAssembler::set_narrow_klass(Klass* k, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1235 assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1236 int klass_index = oop_recorder()->find_index(k);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1237 RelocationHolder rspec = metadata_Relocation::spec(klass_index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1238 narrowOop encoded_k = oopDesc::encode_klass(k);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1239
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1240 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1241 // Relocation with special format (see relocInfo_sparc.hpp).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1242 relocate(rspec, 1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1243 // Assembler::sethi(encoded_k, d);
7476
ffa87474d7a4 8004537: replace AbstractAssembler emit_long with emit_int32
twisti
parents: 7420
diff changeset
1244 emit_int32( op(branch_op) | rd(d) | op2(sethi_op2) | hi22(encoded_k) );
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1245 // Don't add relocation for 'add'. Do patching during 'sethi' processing.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1246 add(d, low10(encoded_k), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1247
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1248 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1249
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1250 void MacroAssembler::align(int modulus) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1251 while (offset() % modulus != 0) nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1252 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1253
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1254
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1255 void MacroAssembler::safepoint() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1256 relocate(breakpoint_Relocation::spec(breakpoint_Relocation::safepoint));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1257 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1258
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1259
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1260 void RegistersForDebugging::print(outputStream* s) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1261 FlagSetting fs(Debugging, true);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1262 int j;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1263 for (j = 0; j < 8; ++j) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1264 if (j != 6) { s->print("i%d = ", j); os::print_location(s, i[j]); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1265 else { s->print( "fp = " ); os::print_location(s, i[j]); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1266 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1267 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1268
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1269 for (j = 0; j < 8; ++j) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1270 s->print("l%d = ", j); os::print_location(s, l[j]);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1271 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1272 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1273
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1274 for (j = 0; j < 8; ++j) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1275 if (j != 6) { s->print("o%d = ", j); os::print_location(s, o[j]); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1276 else { s->print( "sp = " ); os::print_location(s, o[j]); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1277 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1278 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1279
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1280 for (j = 0; j < 8; ++j) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1281 s->print("g%d = ", j); os::print_location(s, g[j]);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1282 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1283 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1284
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1285 // print out floats with compression
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1286 for (j = 0; j < 32; ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1287 jfloat val = f[j];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1288 int last = j;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1289 for ( ; last+1 < 32; ++last ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1290 char b1[1024], b2[1024];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1291 sprintf(b1, "%f", val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1292 sprintf(b2, "%f", f[last+1]);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1293 if (strcmp(b1, b2))
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1294 break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1295 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1296 s->print("f%d", j);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1297 if ( j != last ) s->print(" - f%d", last);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1298 s->print(" = %f", val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1299 s->fill_to(25);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1300 s->print_cr(" (0x%x)", val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1301 j = last + 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1302 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1303 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1304
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1305 // and doubles (evens only)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1306 for (j = 0; j < 32; ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1307 jdouble val = d[j];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1308 int last = j;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1309 for ( ; last+1 < 32; ++last ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1310 char b1[1024], b2[1024];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1311 sprintf(b1, "%f", val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1312 sprintf(b2, "%f", d[last+1]);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1313 if (strcmp(b1, b2))
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1314 break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1315 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1316 s->print("d%d", 2 * j);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1317 if ( j != last ) s->print(" - d%d", last);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1318 s->print(" = %f", val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1319 s->fill_to(30);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1320 s->print("(0x%x)", *(int*)&val);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1321 s->fill_to(42);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1322 s->print_cr("(0x%x)", *(1 + (int*)&val));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1323 j = last + 1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1324 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1325 s->cr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1326 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1327
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1328 void RegistersForDebugging::save_registers(MacroAssembler* a) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1329 a->sub(FP, round_to(sizeof(RegistersForDebugging), sizeof(jdouble)) - STACK_BIAS, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1330 a->flush_windows();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1331 int i;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1332 for (i = 0; i < 8; ++i) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1333 a->ld_ptr(as_iRegister(i)->address_in_saved_window().after_save(), L1); a->st_ptr( L1, O0, i_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1334 a->ld_ptr(as_lRegister(i)->address_in_saved_window().after_save(), L1); a->st_ptr( L1, O0, l_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1335 a->st_ptr(as_oRegister(i)->after_save(), O0, o_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1336 a->st_ptr(as_gRegister(i)->after_save(), O0, g_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1337 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1338 for (i = 0; i < 32; ++i) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1339 a->stf(FloatRegisterImpl::S, as_FloatRegister(i), O0, f_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1340 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1341 for (i = 0; i < (VM_Version::v9_instructions_work() ? 64 : 32); i += 2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1342 a->stf(FloatRegisterImpl::D, as_FloatRegister(i), O0, d_offset(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1343 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1344 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1345
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1346 void RegistersForDebugging::restore_registers(MacroAssembler* a, Register r) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1347 for (int i = 1; i < 8; ++i) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1348 a->ld_ptr(r, g_offset(i), as_gRegister(i));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1349 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1350 for (int j = 0; j < 32; ++j) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1351 a->ldf(FloatRegisterImpl::S, O0, f_offset(j), as_FloatRegister(j));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1352 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1353 for (int k = 0; k < (VM_Version::v9_instructions_work() ? 64 : 32); k += 2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1354 a->ldf(FloatRegisterImpl::D, O0, d_offset(k), as_FloatRegister(k));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1355 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1356 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1357
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1358
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1359 // pushes double TOS element of FPU stack on CPU stack; pops from FPU stack
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1360 void MacroAssembler::push_fTOS() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1361 // %%%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1362 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1363
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1364 // pops double TOS element from CPU stack and pushes on FPU stack
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1365 void MacroAssembler::pop_fTOS() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1366 // %%%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1367 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1368
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1369 void MacroAssembler::empty_FPU_stack() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1370 // %%%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1371 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1372
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1373 void MacroAssembler::_verify_oop(Register reg, const char* msg, const char * file, int line) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1374 // plausibility check for oops
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1375 if (!VerifyOops) return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1376
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1377 if (reg == G0) return; // always NULL, which is always an oop
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1378
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1379 BLOCK_COMMENT("verify_oop {");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1380 char buffer[64];
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1381 #ifdef COMPILER1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1382 if (CommentedAssembly) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1383 snprintf(buffer, sizeof(buffer), "verify_oop at %d", offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1384 block_comment(buffer);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1385 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1386 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1387
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1388 const char* real_msg = NULL;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1389 {
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1390 ResourceMark rm;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1391 stringStream ss;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1392 ss.print("%s at offset %d (%s:%d)", msg, offset(), file, line);
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1393 real_msg = code_string(ss.as_string());
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1394 }
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1395
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1396 // Call indirectly to solve generation ordering problem
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1397 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1398
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1399 // Make some space on stack above the current register window.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1400 // Enough to hold 8 64-bit registers.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1401 add(SP,-8*8,SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1402
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1403 // Save some 64-bit registers; a normal 'save' chops the heads off
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1404 // of 64-bit longs in the 32-bit build.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1405 stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1406 stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1407 mov(reg,O0); // Move arg into O0; arg might be in O7 which is about to be crushed
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1408 stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1409
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1410 // Size of set() should stay the same
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1411 patchable_set((intptr_t)real_msg, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1412 // Load address to call to into O7
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1413 load_ptr_contents(a, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1414 // Register call to verify_oop_subroutine
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1415 callr(O7, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1416 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1417 // recover frame size
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1418 add(SP, 8*8,SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1419 BLOCK_COMMENT("} verify_oop");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1420 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1421
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1422 void MacroAssembler::_verify_oop_addr(Address addr, const char* msg, const char * file, int line) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1423 // plausibility check for oops
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1424 if (!VerifyOops) return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1425
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1426 const char* real_msg = NULL;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1427 {
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1428 ResourceMark rm;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1429 stringStream ss;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1430 ss.print("%s at SP+%d (%s:%d)", msg, addr.disp(), file, line);
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1431 real_msg = code_string(ss.as_string());
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1432 }
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1433
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1434 // Call indirectly to solve generation ordering problem
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1435 AddressLiteral a(StubRoutines::verify_oop_subroutine_entry_address());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1436
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1437 // Make some space on stack above the current register window.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1438 // Enough to hold 8 64-bit registers.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1439 add(SP,-8*8,SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1440
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1441 // Save some 64-bit registers; a normal 'save' chops the heads off
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1442 // of 64-bit longs in the 32-bit build.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1443 stx(O0,SP,frame::register_save_words*wordSize+STACK_BIAS+0*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1444 stx(O1,SP,frame::register_save_words*wordSize+STACK_BIAS+1*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1445 ld_ptr(addr.base(), addr.disp() + 8*8, O0); // Load arg into O0; arg might be in O7 which is about to be crushed
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1446 stx(O7,SP,frame::register_save_words*wordSize+STACK_BIAS+7*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1447
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1448 // Size of set() should stay the same
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1449 patchable_set((intptr_t)real_msg, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1450 // Load address to call to into O7
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1451 load_ptr_contents(a, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1452 // Register call to verify_oop_subroutine
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1453 callr(O7, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1454 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1455 // recover frame size
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1456 add(SP, 8*8,SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1457 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1458
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1459 // side-door communication with signalHandler in os_solaris.cpp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1460 address MacroAssembler::_verify_oop_implicit_branch[3] = { NULL };
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1461
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1462 // This macro is expanded just once; it creates shared code. Contract:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1463 // receives an oop in O0. Must restore O0 & O7 from TLS. Must not smash ANY
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1464 // registers, including flags. May not use a register 'save', as this blows
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1465 // the high bits of the O-regs if they contain Long values. Acts as a 'leaf'
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1466 // call.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1467 void MacroAssembler::verify_oop_subroutine() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1468 assert( VM_Version::v9_instructions_work(), "VerifyOops not supported for V8" );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1469
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1470 // Leaf call; no frame.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1471 Label succeed, fail, null_or_fail;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1472
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1473 // O0 and O7 were saved already (O0 in O0's TLS home, O7 in O5's TLS home).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1474 // O0 is now the oop to be checked. O7 is the return address.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1475 Register O0_obj = O0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1476
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1477 // Save some more registers for temps.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1478 stx(O2,SP,frame::register_save_words*wordSize+STACK_BIAS+2*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1479 stx(O3,SP,frame::register_save_words*wordSize+STACK_BIAS+3*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1480 stx(O4,SP,frame::register_save_words*wordSize+STACK_BIAS+4*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1481 stx(O5,SP,frame::register_save_words*wordSize+STACK_BIAS+5*8);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1482
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1483 // Save flags
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1484 Register O5_save_flags = O5;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1485 rdccr( O5_save_flags );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1486
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1487 { // count number of verifies
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1488 Register O2_adr = O2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1489 Register O3_accum = O3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1490 inc_counter(StubRoutines::verify_oop_count_addr(), O2_adr, O3_accum);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1491 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1492
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1493 Register O2_mask = O2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1494 Register O3_bits = O3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1495 Register O4_temp = O4;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1496
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1497 // mark lower end of faulting range
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1498 assert(_verify_oop_implicit_branch[0] == NULL, "set once");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1499 _verify_oop_implicit_branch[0] = pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1500
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1501 // We can't check the mark oop because it could be in the process of
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1502 // locking or unlocking while this is running.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1503 set(Universe::verify_oop_mask (), O2_mask);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1504 set(Universe::verify_oop_bits (), O3_bits);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1505
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1506 // assert((obj & oop_mask) == oop_bits);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1507 and3(O0_obj, O2_mask, O4_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1508 cmp_and_brx_short(O4_temp, O3_bits, notEqual, pn, null_or_fail);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1509
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1510 if ((NULL_WORD & Universe::verify_oop_mask()) == Universe::verify_oop_bits()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1511 // the null_or_fail case is useless; must test for null separately
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1512 br_null_short(O0_obj, pn, succeed);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1513 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1514
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1515 // Check the Klass* of this object for being in the right area of memory.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1516 // Cannot do the load in the delay above slot in case O0 is null
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1517 load_klass(O0_obj, O0_obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1518 // assert((klass != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1519 br_null_short(O0_obj, pn, fail);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1520 // TODO: Future assert that klass is lower 4g memory for UseCompressedKlassPointers
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1521
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1522 wrccr( O5_save_flags ); // Restore CCR's
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1523
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1524 // mark upper end of faulting range
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1525 _verify_oop_implicit_branch[1] = pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1526
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1527 //-----------------------
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1528 // all tests pass
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1529 bind(succeed);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1530
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1531 // Restore prior 64-bit registers
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1532 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+0*8,O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1533 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+1*8,O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1534 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+2*8,O2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1535 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+3*8,O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1536 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+4*8,O4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1537 ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+5*8,O5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1538
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1539 retl(); // Leaf return; restore prior O7 in delay slot
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1540 delayed()->ldx(SP,frame::register_save_words*wordSize+STACK_BIAS+7*8,O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1541
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1542 //-----------------------
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1543 bind(null_or_fail); // nulls are less common but OK
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1544 br_null(O0_obj, false, pt, succeed);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1545 delayed()->wrccr( O5_save_flags ); // Restore CCR's
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1546
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1547 //-----------------------
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1548 // report failure:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1549 bind(fail);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1550 _verify_oop_implicit_branch[2] = pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1551
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1552 wrccr( O5_save_flags ); // Restore CCR's
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1553
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1554 save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1555
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1556 // stop_subroutine expects message pointer in I1.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1557 mov(I1, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1558
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1559 // Restore prior 64-bit registers
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1560 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+0*8,I0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1561 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+1*8,I1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1562 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+2*8,I2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1563 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+3*8,I3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1564 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+4*8,I4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1565 ldx(FP,frame::register_save_words*wordSize+STACK_BIAS+5*8,I5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1566
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1567 // factor long stop-sequence into subroutine to save space
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1568 assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1569
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1570 // call indirectly to solve generation ordering problem
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1571 AddressLiteral al(StubRoutines::Sparc::stop_subroutine_entry_address());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1572 load_ptr_contents(al, O5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1573 jmpl(O5, 0, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1574 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1575 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1576
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1577
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1578 void MacroAssembler::stop(const char* msg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1579 // save frame first to get O7 for return address
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1580 // add one word to size in case struct is odd number of words long
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1581 // It must be doubleword-aligned for storing doubles into it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1582
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1583 save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1584
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1585 // stop_subroutine expects message pointer in I1.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1586 // Size of set() should stay the same
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1587 patchable_set((intptr_t)msg, O1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1588
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1589 // factor long stop-sequence into subroutine to save space
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1590 assert(StubRoutines::Sparc::stop_subroutine_entry_address(), "hasn't been generated yet");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1591
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1592 // call indirectly to solve generation ordering problem
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1593 AddressLiteral a(StubRoutines::Sparc::stop_subroutine_entry_address());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1594 load_ptr_contents(a, O5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1595 jmpl(O5, 0, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1596 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1597
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1598 breakpoint_trap(); // make stop actually stop rather than writing
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1599 // unnoticeable results in the output files.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1600
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1601 // restore(); done in callee to save space!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1602 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1603
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1604
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1605 void MacroAssembler::warn(const char* msg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1606 save_frame(::round_to(sizeof(RegistersForDebugging) / BytesPerWord, 2));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1607 RegistersForDebugging::save_registers(this);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1608 mov(O0, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1609 // Size of set() should stay the same
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1610 patchable_set((intptr_t)msg, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1611 call( CAST_FROM_FN_PTR(address, warning) );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1612 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1613 // ret();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1614 // delayed()->restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1615 RegistersForDebugging::restore_registers(this, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1616 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1617 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1618
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1619
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1620 void MacroAssembler::untested(const char* what) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1621 // We must be able to turn interactive prompting off
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1622 // in order to run automated test scripts on the VM
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1623 // Use the flag ShowMessageBoxOnError
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1624
8767
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1625 const char* b = NULL;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1626 {
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1627 ResourceMark rm;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1628 stringStream ss;
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1629 ss.print("untested: %s", what);
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1630 b = code_string(ss.as_string());
a5de0cc2f91c 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 8001
diff changeset
1631 }
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1632 if (ShowMessageBoxOnError) { STOP(b); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1633 else { warn(b); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1634 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1635
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1636
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1637 void MacroAssembler::stop_subroutine() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1638 RegistersForDebugging::save_registers(this);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1639
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1640 // for the sake of the debugger, stick a PC on the current frame
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1641 // (this assumes that the caller has performed an extra "save")
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1642 mov(I7, L7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1643 add(O7, -7 * BytesPerInt, I7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1644
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1645 save_frame(); // one more save to free up another O7 register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1646 mov(I0, O1); // addr of reg save area
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1647
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1648 // We expect pointer to message in I1. Caller must set it up in O1
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1649 mov(I1, O0); // get msg
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1650 call (CAST_FROM_FN_PTR(address, MacroAssembler::debug), relocInfo::runtime_call_type);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1651 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1652
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1653 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1654
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1655 RegistersForDebugging::restore_registers(this, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1656
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1657 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1658 call(CAST_FROM_FN_PTR(address,breakpoint));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1659 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1660 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1661
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1662 mov(L7, I7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1663 retl();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1664 delayed()->restore(); // see stop above
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1665 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1666
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1667
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1668 void MacroAssembler::debug(char* msg, RegistersForDebugging* regs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1669 if ( ShowMessageBoxOnError ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1670 JavaThread* thread = JavaThread::current();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1671 JavaThreadState saved_state = thread->thread_state();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1672 thread->set_thread_state(_thread_in_vm);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1673 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1674 // In order to get locks work, we need to fake a in_VM state
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1675 ttyLocker ttyl;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1676 ::tty->print_cr("EXECUTION STOPPED: %s\n", msg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1677 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1678 BytecodeCounter::print();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1679 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1680 if (os::message_box(msg, "Execution stopped, print registers?"))
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1681 regs->print(::tty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1682 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1683 BREAKPOINT;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1684 ThreadStateTransition::transition(JavaThread::current(), _thread_in_vm, saved_state);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1685 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1686 else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1687 ::tty->print_cr("=============== DEBUG MESSAGE: %s ================\n", msg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1688 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1689 assert(false, err_msg("DEBUG MESSAGE: %s", msg));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1690 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1691
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1692
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1693 void MacroAssembler::calc_mem_param_words(Register Rparam_words, Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1694 subcc( Rparam_words, Argument::n_register_parameters, Rresult); // how many mem words?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1695 Label no_extras;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1696 br( negative, true, pt, no_extras ); // if neg, clear reg
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1697 delayed()->set(0, Rresult); // annuled, so only if taken
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1698 bind( no_extras );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1699 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1700
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1701
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1702 void MacroAssembler::calc_frame_size(Register Rextra_words, Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1703 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1704 add(Rextra_words, frame::memory_parameter_word_sp_offset, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1705 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1706 add(Rextra_words, frame::memory_parameter_word_sp_offset + 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1707 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1708 bclr(1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1709 sll(Rresult, LogBytesPerWord, Rresult); // Rresult has total frame bytes
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1710 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1711
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1712
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1713 void MacroAssembler::calc_frame_size_and_save(Register Rextra_words, Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1714 calc_frame_size(Rextra_words, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1715 neg(Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1716 save(SP, Rresult, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1717 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1718
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1719
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1720 // ---------------------------------------------------------
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1721 Assembler::RCondition cond2rcond(Assembler::Condition c) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1722 switch (c) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1723 /*case zero: */
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1724 case Assembler::equal: return Assembler::rc_z;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1725 case Assembler::lessEqual: return Assembler::rc_lez;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1726 case Assembler::less: return Assembler::rc_lz;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1727 /*case notZero:*/
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1728 case Assembler::notEqual: return Assembler::rc_nz;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1729 case Assembler::greater: return Assembler::rc_gz;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1730 case Assembler::greaterEqual: return Assembler::rc_gez;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1731 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1732 ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1733 return Assembler::rc_z;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1734 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1735
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1736 // compares (32 bit) register with zero and branches. NOT FOR USE WITH 64-bit POINTERS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1737 void MacroAssembler::cmp_zero_and_br(Condition c, Register s1, Label& L, bool a, Predict p) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1738 tst(s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1739 br (c, a, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1740 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1741
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1742 // Compares a pointer register with zero and branches on null.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1743 // Does a test & branch on 32-bit systems and a register-branch on 64-bit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1744 void MacroAssembler::br_null( Register s1, bool a, Predict p, Label& L ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1745 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1746 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1747 bpr( rc_z, a, p, s1, L );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1748 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1749 tst(s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1750 br ( zero, a, p, L );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1751 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1752 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1753
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1754 void MacroAssembler::br_notnull( Register s1, bool a, Predict p, Label& L ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1755 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1756 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1757 bpr( rc_nz, a, p, s1, L );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1758 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1759 tst(s1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1760 br ( notZero, a, p, L );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1761 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1762 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1763
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1764 // Compare registers and branch with nop in delay slot or cbcond without delay slot.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1765
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1766 // Compare integer (32 bit) values (icc only).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1767 void MacroAssembler::cmp_and_br_short(Register s1, Register s2, Condition c,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1768 Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1769 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1770 if (use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1771 Assembler::cbcond(c, icc, s1, s2, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1772 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1773 cmp(s1, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1774 br(c, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1775 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1776 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1777 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1778
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1779 // Compare integer (32 bit) values (icc only).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1780 void MacroAssembler::cmp_and_br_short(Register s1, int simm13a, Condition c,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1781 Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1782 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1783 if (is_simm(simm13a,5) && use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1784 Assembler::cbcond(c, icc, s1, simm13a, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1785 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1786 cmp(s1, simm13a);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1787 br(c, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1788 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1789 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1790 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1791
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1792 // Branch that tests xcc in LP64 and icc in !LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1793 void MacroAssembler::cmp_and_brx_short(Register s1, Register s2, Condition c,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1794 Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1795 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1796 if (use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1797 Assembler::cbcond(c, ptr_cc, s1, s2, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1798 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1799 cmp(s1, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1800 brx(c, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1801 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1802 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1803 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1804
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1805 // Branch that tests xcc in LP64 and icc in !LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1806 void MacroAssembler::cmp_and_brx_short(Register s1, int simm13a, Condition c,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1807 Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1808 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1809 if (is_simm(simm13a,5) && use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1810 Assembler::cbcond(c, ptr_cc, s1, simm13a, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1811 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1812 cmp(s1, simm13a);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1813 brx(c, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1814 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1815 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1816 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1817
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1818 // Short branch version for compares a pointer with zero.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1819
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1820 void MacroAssembler::br_null_short(Register s1, Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1821 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1822 if (use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1823 Assembler::cbcond(zero, ptr_cc, s1, 0, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1824 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1825 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1826 br_null(s1, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1827 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1828 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1829
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1830 void MacroAssembler::br_notnull_short(Register s1, Predict p, Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1831 assert_not_delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1832 if (use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1833 Assembler::cbcond(notZero, ptr_cc, s1, 0, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1834 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1835 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1836 br_notnull(s1, false, p, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1837 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1838 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1839
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1840 // Unconditional short branch
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1841 void MacroAssembler::ba_short(Label& L) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1842 if (use_cbcond(L)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1843 Assembler::cbcond(equal, icc, G0, G0, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1844 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1845 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1846 br(always, false, pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1847 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1848 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1849
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1850 // instruction sequences factored across compiler & interpreter
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1851
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1852
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1853 void MacroAssembler::lcmp( Register Ra_hi, Register Ra_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1854 Register Rb_hi, Register Rb_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1855 Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1856
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1857 Label check_low_parts, done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1858
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1859 cmp(Ra_hi, Rb_hi ); // compare hi parts
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1860 br(equal, true, pt, check_low_parts);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1861 delayed()->cmp(Ra_low, Rb_low); // test low parts
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1862
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1863 // And, with an unsigned comparison, it does not matter if the numbers
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1864 // are negative or not.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1865 // E.g., -2 cmp -1: the low parts are 0xfffffffe and 0xffffffff.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1866 // The second one is bigger (unsignedly).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1867
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1868 // Other notes: The first move in each triplet can be unconditional
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1869 // (and therefore probably prefetchable).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1870 // And the equals case for the high part does not need testing,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1871 // since that triplet is reached only after finding the high halves differ.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1872
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1873 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1874 mov(-1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1875 ba(done); delayed()-> movcc(greater, false, icc, 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1876 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1877 br(less, true, pt, done); delayed()-> set(-1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1878 br(greater, true, pt, done); delayed()-> set( 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1879 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1880
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1881 bind( check_low_parts );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1882
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1883 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1884 mov( -1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1885 movcc(equal, false, icc, 0, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1886 movcc(greaterUnsigned, false, icc, 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1887 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1888 set(-1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1889 br(equal, true, pt, done); delayed()->set( 0, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1890 br(greaterUnsigned, true, pt, done); delayed()->set( 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1891 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1892 bind( done );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1893 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1894
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1895 void MacroAssembler::lneg( Register Rhi, Register Rlow ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1896 subcc( G0, Rlow, Rlow );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1897 subc( G0, Rhi, Rhi );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1898 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1899
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1900 void MacroAssembler::lshl( Register Rin_high, Register Rin_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1901 Register Rcount,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1902 Register Rout_high, Register Rout_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1903 Register Rtemp ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1904
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1905
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1906 Register Ralt_count = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1907 Register Rxfer_bits = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1908
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1909 assert( Ralt_count != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1910 && Ralt_count != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1911 && Ralt_count != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1912 && Rxfer_bits != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1913 && Rxfer_bits != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1914 && Rxfer_bits != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1915 && Rxfer_bits != Rout_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1916 && Rout_low != Rin_high,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1917 "register alias checks");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1918
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1919 Label big_shift, done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1920
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1921 // This code can be optimized to use the 64 bit shifts in V9.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1922 // Here we use the 32 bit shifts.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1923
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1924 and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1925 subcc(Rcount, 31, Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1926 br(greater, true, pn, big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1927 delayed()->dec(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1928
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1929 // shift < 32 bits, Ralt_count = Rcount-31
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1930
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1931 // We get the transfer bits by shifting right by 32-count the low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1932 // register. This is done by shifting right by 31-count and then by one
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1933 // more to take care of the special (rare) case where count is zero
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1934 // (shifting by 32 would not work).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1935
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1936 neg(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1937
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1938 // The order of the next two instructions is critical in the case where
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1939 // Rin and Rout are the same and should not be reversed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1940
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1941 srl(Rin_low, Ralt_count, Rxfer_bits); // shift right by 31-count
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1942 if (Rcount != Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1943 sll(Rin_low, Rcount, Rout_low); // low half
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1944 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1945 sll(Rin_high, Rcount, Rout_high);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1946 if (Rcount == Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1947 sll(Rin_low, Rcount, Rout_low); // low half
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1948 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1949 srl(Rxfer_bits, 1, Rxfer_bits ); // shift right by one more
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1950 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1951 delayed()->or3(Rout_high, Rxfer_bits, Rout_high); // new hi value: or in shifted old hi part and xfer from low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1952
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1953 // shift >= 32 bits, Ralt_count = Rcount-32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1954 bind(big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1955 sll(Rin_low, Ralt_count, Rout_high );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1956 clr(Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1957
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1958 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1959 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1960
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1961
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1962 void MacroAssembler::lshr( Register Rin_high, Register Rin_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1963 Register Rcount,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1964 Register Rout_high, Register Rout_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1965 Register Rtemp ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1966
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1967 Register Ralt_count = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1968 Register Rxfer_bits = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1969
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1970 assert( Ralt_count != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1971 && Ralt_count != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1972 && Ralt_count != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1973 && Rxfer_bits != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1974 && Rxfer_bits != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1975 && Rxfer_bits != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1976 && Rxfer_bits != Rout_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1977 && Rout_high != Rin_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1978 "register alias checks");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1979
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1980 Label big_shift, done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1981
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1982 // This code can be optimized to use the 64 bit shifts in V9.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1983 // Here we use the 32 bit shifts.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1984
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1985 and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1986 subcc(Rcount, 31, Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1987 br(greater, true, pn, big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1988 delayed()->dec(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1989
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1990 // shift < 32 bits, Ralt_count = Rcount-31
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1991
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1992 // We get the transfer bits by shifting left by 32-count the high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1993 // register. This is done by shifting left by 31-count and then by one
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1994 // more to take care of the special (rare) case where count is zero
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1995 // (shifting by 32 would not work).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1996
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1997 neg(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1998 if (Rcount != Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
1999 srl(Rin_low, Rcount, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2000 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2001
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2002 // The order of the next two instructions is critical in the case where
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2003 // Rin and Rout are the same and should not be reversed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2004
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2005 sll(Rin_high, Ralt_count, Rxfer_bits); // shift left by 31-count
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2006 sra(Rin_high, Rcount, Rout_high ); // high half
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2007 sll(Rxfer_bits, 1, Rxfer_bits); // shift left by one more
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2008 if (Rcount == Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2009 srl(Rin_low, Rcount, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2010 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2011 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2012 delayed()->or3(Rout_low, Rxfer_bits, Rout_low); // new low value: or shifted old low part and xfer from high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2013
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2014 // shift >= 32 bits, Ralt_count = Rcount-32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2015 bind(big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2016
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2017 sra(Rin_high, Ralt_count, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2018 sra(Rin_high, 31, Rout_high); // sign into hi
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2019
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2020 bind( done );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2021 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2022
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2023
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2024
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2025 void MacroAssembler::lushr( Register Rin_high, Register Rin_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2026 Register Rcount,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2027 Register Rout_high, Register Rout_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2028 Register Rtemp ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2029
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2030 Register Ralt_count = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2031 Register Rxfer_bits = Rtemp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2032
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2033 assert( Ralt_count != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2034 && Ralt_count != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2035 && Ralt_count != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2036 && Rxfer_bits != Rin_low
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2037 && Rxfer_bits != Rin_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2038 && Rxfer_bits != Rcount
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2039 && Rxfer_bits != Rout_high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2040 && Rout_high != Rin_low,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2041 "register alias checks");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2042
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2043 Label big_shift, done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2044
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2045 // This code can be optimized to use the 64 bit shifts in V9.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2046 // Here we use the 32 bit shifts.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2047
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2048 and3( Rcount, 0x3f, Rcount); // take least significant 6 bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2049 subcc(Rcount, 31, Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2050 br(greater, true, pn, big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2051 delayed()->dec(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2052
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2053 // shift < 32 bits, Ralt_count = Rcount-31
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2054
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2055 // We get the transfer bits by shifting left by 32-count the high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2056 // register. This is done by shifting left by 31-count and then by one
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2057 // more to take care of the special (rare) case where count is zero
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2058 // (shifting by 32 would not work).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2059
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2060 neg(Ralt_count);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2061 if (Rcount != Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2062 srl(Rin_low, Rcount, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2063 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2064
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2065 // The order of the next two instructions is critical in the case where
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2066 // Rin and Rout are the same and should not be reversed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2067
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2068 sll(Rin_high, Ralt_count, Rxfer_bits); // shift left by 31-count
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2069 srl(Rin_high, Rcount, Rout_high ); // high half
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2070 sll(Rxfer_bits, 1, Rxfer_bits); // shift left by one more
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2071 if (Rcount == Rout_low) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2072 srl(Rin_low, Rcount, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2073 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2074 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2075 delayed()->or3(Rout_low, Rxfer_bits, Rout_low); // new low value: or shifted old low part and xfer from high
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2076
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2077 // shift >= 32 bits, Ralt_count = Rcount-32
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2078 bind(big_shift);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2079
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2080 srl(Rin_high, Ralt_count, Rout_low);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2081 clr(Rout_high);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2082
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2083 bind( done );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2084 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2085
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2086 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2087 void MacroAssembler::lcmp( Register Ra, Register Rb, Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2088 cmp(Ra, Rb);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2089 mov(-1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2090 movcc(equal, false, xcc, 0, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2091 movcc(greater, false, xcc, 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2092 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2093 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2094
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2095
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2096 void MacroAssembler::load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2097 switch (size_in_bytes) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2098 case 8: ld_long(src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2099 case 4: ld( src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2100 case 2: is_signed ? ldsh(src, dst) : lduh(src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2101 case 1: is_signed ? ldsb(src, dst) : ldub(src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2102 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2103 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2104 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2105
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2106 void MacroAssembler::store_sized_value(Register src, Address dst, size_t size_in_bytes) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2107 switch (size_in_bytes) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2108 case 8: st_long(src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2109 case 4: st( src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2110 case 2: sth( src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2111 case 1: stb( src, dst); break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2112 default: ShouldNotReachHere();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2113 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2114 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2115
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2116
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2117 void MacroAssembler::float_cmp( bool is_float, int unordered_result,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2118 FloatRegister Fa, FloatRegister Fb,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2119 Register Rresult) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2120
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2121 fcmp(is_float ? FloatRegisterImpl::S : FloatRegisterImpl::D, fcc0, Fa, Fb);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2122
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2123 Condition lt = unordered_result == -1 ? f_unorderedOrLess : f_less;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2124 Condition eq = f_equal;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2125 Condition gt = unordered_result == 1 ? f_unorderedOrGreater : f_greater;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2126
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2127 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2128
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2129 mov(-1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2130 movcc(eq, true, fcc0, 0, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2131 movcc(gt, true, fcc0, 1, Rresult);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2132
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2133 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2134 Label done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2135
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2136 set( -1, Rresult );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2137 //fb(lt, true, pn, done); delayed()->set( -1, Rresult );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2138 fb( eq, true, pn, done); delayed()->set( 0, Rresult );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2139 fb( gt, true, pn, done); delayed()->set( 1, Rresult );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2140
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2141 bind (done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2142 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2143 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2144
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2145
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2146 void MacroAssembler::fneg( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2147 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2148 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2149 Assembler::fneg(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2150 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2151 if (w == FloatRegisterImpl::S) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2152 Assembler::fneg(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2153 } else if (w == FloatRegisterImpl::D) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2154 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2155 assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2156 ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2157
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2158 Assembler::fneg(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2159 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2160 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2161 assert(w == FloatRegisterImpl::Q, "Invalid float register width");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2162
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2163 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2164 assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2165 ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2166
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2167 Assembler::fneg(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2168 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2169 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2170 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2171 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2172 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2173 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2174
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2175 void MacroAssembler::fmov( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2176 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2177 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2178 Assembler::fmov(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2179 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2180 if (w == FloatRegisterImpl::S) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2181 Assembler::fmov(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2182 } else if (w == FloatRegisterImpl::D) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2183 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2184 assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2185 ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2186
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2187 Assembler::fmov(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2188 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2189 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2190 assert(w == FloatRegisterImpl::Q, "Invalid float register width");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2191
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2192 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2193 assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2194 ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2195
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2196 Assembler::fmov(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2197 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2198 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2199 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2200 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2201 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2202 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2203
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2204 void MacroAssembler::fabs( FloatRegisterImpl::Width w, FloatRegister s, FloatRegister d)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2205 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2206 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2207 Assembler::fabs(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2208 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2209 if (w == FloatRegisterImpl::S) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2210 Assembler::fabs(w, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2211 } else if (w == FloatRegisterImpl::D) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2212 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2213 assert(((s->encoding(FloatRegisterImpl::D) & 1) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2214 ((d->encoding(FloatRegisterImpl::D) & 1) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2215
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2216 Assembler::fabs(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2217 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2218 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2219 assert(w == FloatRegisterImpl::Q, "Invalid float register width");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2220
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2221 // number() does a sanity check on the alignment.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2222 assert(((s->encoding(FloatRegisterImpl::D) & 3) == 0) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2223 ((d->encoding(FloatRegisterImpl::D) & 3) == 0), "float register alignment check");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2224
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2225 Assembler::fabs(FloatRegisterImpl::S, s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2226 Assembler::fmov(FloatRegisterImpl::S, s->successor(), d->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2227 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor(), d->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2228 Assembler::fmov(FloatRegisterImpl::S, s->successor()->successor()->successor(), d->successor()->successor()->successor());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2229 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2230 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2231 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2232
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2233 void MacroAssembler::save_all_globals_into_locals() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2234 mov(G1,L1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2235 mov(G2,L2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2236 mov(G3,L3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2237 mov(G4,L4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2238 mov(G5,L5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2239 mov(G6,L6);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2240 mov(G7,L7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2241 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2242
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2243 void MacroAssembler::restore_globals_from_locals() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2244 mov(L1,G1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2245 mov(L2,G2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2246 mov(L3,G3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2247 mov(L4,G4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2248 mov(L5,G5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2249 mov(L6,G6);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2250 mov(L7,G7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2251 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2252
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2253 // Use for 64 bit operation.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2254 void MacroAssembler::casx_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg, address lock_addr, bool use_call_vm)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2255 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2256 // store ptr_reg as the new top value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2257 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2258 casx(top_ptr_reg, top_reg, ptr_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2259 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2260 cas_under_lock(top_ptr_reg, top_reg, ptr_reg, lock_addr, use_call_vm);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2261 #endif // _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2262 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2263
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2264 // [RGV] This routine does not handle 64 bit operations.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2265 // use casx_under_lock() or casx directly!!!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2266 void MacroAssembler::cas_under_lock(Register top_ptr_reg, Register top_reg, Register ptr_reg, address lock_addr, bool use_call_vm)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2267 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2268 // store ptr_reg as the new top value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2269 if (VM_Version::v9_instructions_work()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2270 cas(top_ptr_reg, top_reg, ptr_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2271 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2272
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2273 // If the register is not an out nor global, it is not visible
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2274 // after the save. Allocate a register for it, save its
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2275 // value in the register save area (the save may not flush
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2276 // registers to the save area).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2277
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2278 Register top_ptr_reg_after_save;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2279 Register top_reg_after_save;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2280 Register ptr_reg_after_save;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2281
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2282 if (top_ptr_reg->is_out() || top_ptr_reg->is_global()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2283 top_ptr_reg_after_save = top_ptr_reg->after_save();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2284 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2285 Address reg_save_addr = top_ptr_reg->address_in_saved_window();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2286 top_ptr_reg_after_save = L0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2287 st(top_ptr_reg, reg_save_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2288 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2289
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2290 if (top_reg->is_out() || top_reg->is_global()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2291 top_reg_after_save = top_reg->after_save();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2292 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2293 Address reg_save_addr = top_reg->address_in_saved_window();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2294 top_reg_after_save = L1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2295 st(top_reg, reg_save_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2296 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2297
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2298 if (ptr_reg->is_out() || ptr_reg->is_global()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2299 ptr_reg_after_save = ptr_reg->after_save();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2300 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2301 Address reg_save_addr = ptr_reg->address_in_saved_window();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2302 ptr_reg_after_save = L2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2303 st(ptr_reg, reg_save_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2304 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2305
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2306 const Register& lock_reg = L3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2307 const Register& lock_ptr_reg = L4;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2308 const Register& value_reg = L5;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2309 const Register& yield_reg = L6;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2310 const Register& yieldall_reg = L7;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2311
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2312 save_frame();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2313
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2314 if (top_ptr_reg_after_save == L0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2315 ld(top_ptr_reg->address_in_saved_window().after_save(), top_ptr_reg_after_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2316 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2317
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2318 if (top_reg_after_save == L1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2319 ld(top_reg->address_in_saved_window().after_save(), top_reg_after_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2320 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2321
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2322 if (ptr_reg_after_save == L2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2323 ld(ptr_reg->address_in_saved_window().after_save(), ptr_reg_after_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2324 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2325
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2326 Label(retry_get_lock);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2327 Label(not_same);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2328 Label(dont_yield);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2329
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2330 assert(lock_addr, "lock_address should be non null for v8");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2331 set((intptr_t)lock_addr, lock_ptr_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2332 // Initialize yield counter
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2333 mov(G0,yield_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2334 mov(G0, yieldall_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2335 set(StubRoutines::Sparc::locked, lock_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2336
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2337 bind(retry_get_lock);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2338 cmp_and_br_short(yield_reg, V8AtomicOperationUnderLockSpinCount, Assembler::less, Assembler::pt, dont_yield);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2339
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2340 if(use_call_vm) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2341 Untested("Need to verify global reg consistancy");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2342 call_VM(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::yield_all), yieldall_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2343 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2344 // Save the regs and make space for a C call
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2345 save(SP, -96, SP);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2346 save_all_globals_into_locals();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2347 call(CAST_FROM_FN_PTR(address,os::yield_all));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2348 delayed()->mov(yieldall_reg, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2349 restore_globals_from_locals();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2350 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2351 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2352
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2353 // reset the counter
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2354 mov(G0,yield_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2355 add(yieldall_reg, 1, yieldall_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2356
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2357 bind(dont_yield);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2358 // try to get lock
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2359 Assembler::swap(lock_ptr_reg, 0, lock_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2360
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2361 // did we get the lock?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2362 cmp(lock_reg, StubRoutines::Sparc::unlocked);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2363 br(Assembler::notEqual, true, Assembler::pn, retry_get_lock);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2364 delayed()->add(yield_reg,1,yield_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2365
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2366 // yes, got lock. do we have the same top?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2367 ld(top_ptr_reg_after_save, 0, value_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2368 cmp_and_br_short(value_reg, top_reg_after_save, Assembler::notEqual, Assembler::pn, not_same);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2369
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2370 // yes, same top.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2371 st(ptr_reg_after_save, top_ptr_reg_after_save, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2372 membar(Assembler::StoreStore);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2373
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2374 bind(not_same);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2375 mov(value_reg, ptr_reg_after_save);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2376 st(lock_reg, lock_ptr_reg, 0); // unlock
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2377
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2378 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2379 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2380 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2381
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2382 RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2383 Register tmp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2384 int offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2385 intptr_t value = *delayed_value_addr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2386 if (value != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2387 return RegisterOrConstant(value + offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2388
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2389 // load indirectly to solve generation ordering problem
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2390 AddressLiteral a(delayed_value_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2391 load_ptr_contents(a, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2392
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2393 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2394 tst(tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2395 breakpoint_trap(zero, xcc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2396 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2397
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2398 if (offset != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2399 add(tmp, offset, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2400
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2401 return RegisterOrConstant(tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2402 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2403
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2404
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2405 RegisterOrConstant MacroAssembler::regcon_andn_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2406 assert(d.register_or_noreg() != G0, "lost side effect");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2407 if ((s2.is_constant() && s2.as_constant() == 0) ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2408 (s2.is_register() && s2.as_register() == G0)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2409 // Do nothing, just move value.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2410 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2411 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2412 mov(s1.as_register(), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2413 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2414 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2415 return s1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2416 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2417 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2418
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2419 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2420 assert_different_registers(s1.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2421 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2422 andn(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2423 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2424 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2425 if (s2.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2426 assert_different_registers(s2.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2427 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2428 set(s1.as_constant(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2429 andn(temp, s2.as_register(), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2430 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2431 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2432 intptr_t res = s1.as_constant() & ~s2.as_constant();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2433 return res;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2434 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2435 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2436 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2437
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2438 RegisterOrConstant MacroAssembler::regcon_inc_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2439 assert(d.register_or_noreg() != G0, "lost side effect");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2440 if ((s2.is_constant() && s2.as_constant() == 0) ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2441 (s2.is_register() && s2.as_register() == G0)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2442 // Do nothing, just move value.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2443 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2444 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2445 mov(s1.as_register(), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2446 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2447 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2448 return s1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2449 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2450 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2451
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2452 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2453 assert_different_registers(s1.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2454 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2455 add(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2456 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2457 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2458 if (s2.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2459 assert_different_registers(s2.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2460 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2461 add(s2.as_register(), ensure_simm13_or_reg(s1, temp), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2462 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2463 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2464 intptr_t res = s1.as_constant() + s2.as_constant();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2465 return res;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2466 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2467 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2468 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2469
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2470 RegisterOrConstant MacroAssembler::regcon_sll_ptr(RegisterOrConstant s1, RegisterOrConstant s2, RegisterOrConstant d, Register temp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2471 assert(d.register_or_noreg() != G0, "lost side effect");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2472 if (!is_simm13(s2.constant_or_zero()))
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2473 s2 = (s2.as_constant() & 0xFF);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2474 if ((s2.is_constant() && s2.as_constant() == 0) ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2475 (s2.is_register() && s2.as_register() == G0)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2476 // Do nothing, just move value.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2477 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2478 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2479 mov(s1.as_register(), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2480 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2481 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2482 return s1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2483 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2484 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2485
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2486 if (s1.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2487 assert_different_registers(s1.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2488 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2489 sll_ptr(s1.as_register(), ensure_simm13_or_reg(s2, temp), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2490 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2491 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2492 if (s2.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2493 assert_different_registers(s2.as_register(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2494 if (d.is_constant()) d = temp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2495 set(s1.as_constant(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2496 sll_ptr(temp, s2.as_register(), d.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2497 return d;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2498 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2499 intptr_t res = s1.as_constant() << s2.as_constant();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2500 return res;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2501 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2502 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2503 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2504
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2505
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2506 // Look up the method for a megamorphic invokeinterface call.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2507 // The target method is determined by <intf_klass, itable_index>.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2508 // The receiver klass is in recv_klass.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2509 // On success, the result will be in method_result, and execution falls through.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2510 // On failure, execution transfers to the given label.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2511 void MacroAssembler::lookup_interface_method(Register recv_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2512 Register intf_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2513 RegisterOrConstant itable_index,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2514 Register method_result,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2515 Register scan_temp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2516 Register sethi_temp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2517 Label& L_no_such_interface) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2518 assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2519 assert(itable_index.is_constant() || itable_index.as_register() == method_result,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2520 "caller must use same register for non-constant itable index as for method");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2521
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2522 Label L_no_such_interface_restore;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2523 bool did_save = false;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2524 if (scan_temp == noreg || sethi_temp == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2525 Register recv_2 = recv_klass->is_global() ? recv_klass : L0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2526 Register intf_2 = intf_klass->is_global() ? intf_klass : L1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2527 assert(method_result->is_global(), "must be able to return value");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2528 scan_temp = L2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2529 sethi_temp = L3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2530 save_frame_and_mov(0, recv_klass, recv_2, intf_klass, intf_2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2531 recv_klass = recv_2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2532 intf_klass = intf_2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2533 did_save = true;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2534 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2535
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2536 // Compute start of first itableOffsetEntry (which is at the end of the vtable)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2537 int vtable_base = InstanceKlass::vtable_start_offset() * wordSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2538 int scan_step = itableOffsetEntry::size() * wordSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2539 int vte_size = vtableEntry::size() * wordSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2540
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2541 lduw(recv_klass, InstanceKlass::vtable_length_offset() * wordSize, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2542 // %%% We should store the aligned, prescaled offset in the klassoop.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2543 // Then the next several instructions would fold away.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2544
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2545 int round_to_unit = ((HeapWordsPerLong > 1) ? BytesPerLong : 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2546 int itb_offset = vtable_base;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2547 if (round_to_unit != 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2548 // hoist first instruction of round_to(scan_temp, BytesPerLong):
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2549 itb_offset += round_to_unit - wordSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2550 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2551 int itb_scale = exact_log2(vtableEntry::size() * wordSize);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2552 sll(scan_temp, itb_scale, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2553 add(scan_temp, itb_offset, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2554 if (round_to_unit != 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2555 // Round up to align_object_offset boundary
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2556 // see code for InstanceKlass::start_of_itable!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2557 // Was: round_to(scan_temp, BytesPerLong);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2558 // Hoisted: add(scan_temp, BytesPerLong-1, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2559 and3(scan_temp, -round_to_unit, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2560 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2561 add(recv_klass, scan_temp, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2562
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2563 // Adjust recv_klass by scaled itable_index, so we can free itable_index.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2564 RegisterOrConstant itable_offset = itable_index;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2565 itable_offset = regcon_sll_ptr(itable_index, exact_log2(itableMethodEntry::size() * wordSize), itable_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2566 itable_offset = regcon_inc_ptr(itable_offset, itableMethodEntry::method_offset_in_bytes(), itable_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2567 add(recv_klass, ensure_simm13_or_reg(itable_offset, sethi_temp), recv_klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2568
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2569 // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2570 // if (scan->interface() == intf) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2571 // result = (klass + scan->offset() + itable_index);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2572 // }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2573 // }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2574 Label L_search, L_found_method;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2575
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2576 for (int peel = 1; peel >= 0; peel--) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2577 // %%%% Could load both offset and interface in one ldx, if they were
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2578 // in the opposite order. This would save a load.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2579 ld_ptr(scan_temp, itableOffsetEntry::interface_offset_in_bytes(), method_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2580
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2581 // Check that this entry is non-null. A null entry means that
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2582 // the receiver class doesn't implement the interface, and wasn't the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2583 // same as when the caller was compiled.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2584 bpr(Assembler::rc_z, false, Assembler::pn, method_result, did_save ? L_no_such_interface_restore : L_no_such_interface);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2585 delayed()->cmp(method_result, intf_klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2586
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2587 if (peel) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2588 brx(Assembler::equal, false, Assembler::pt, L_found_method);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2589 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2590 brx(Assembler::notEqual, false, Assembler::pn, L_search);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2591 // (invert the test to fall through to found_method...)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2592 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2593 delayed()->add(scan_temp, scan_step, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2594
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2595 if (!peel) break;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2596
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2597 bind(L_search);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2598 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2599
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2600 bind(L_found_method);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2601
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2602 // Got a hit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2603 int ito_offset = itableOffsetEntry::offset_offset_in_bytes();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2604 // scan_temp[-scan_step] points to the vtable offset we need
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2605 ito_offset -= scan_step;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2606 lduw(scan_temp, ito_offset, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2607 ld_ptr(recv_klass, scan_temp, method_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2608
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2609 if (did_save) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2610 Label L_done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2611 ba(L_done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2612 delayed()->restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2613
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2614 bind(L_no_such_interface_restore);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2615 ba(L_no_such_interface);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2616 delayed()->restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2617
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2618 bind(L_done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2619 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2620 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2621
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2622
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2623 // virtual method calling
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2624 void MacroAssembler::lookup_virtual_method(Register recv_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2625 RegisterOrConstant vtable_index,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2626 Register method_result) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2627 assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2628 Register sethi_temp = method_result;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2629 const int base = (InstanceKlass::vtable_start_offset() * wordSize +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2630 // method pointer offset within the vtable entry:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2631 vtableEntry::method_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2632 RegisterOrConstant vtable_offset = vtable_index;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2633 // Each of the following three lines potentially generates an instruction.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2634 // But the total number of address formation instructions will always be
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2635 // at most two, and will often be zero. In any case, it will be optimal.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2636 // If vtable_index is a register, we will have (sll_ptr N,x; inc_ptr B,x; ld_ptr k,x).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2637 // If vtable_index is a constant, we will have at most (set B+X<<N,t; ld_ptr k,t).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2638 vtable_offset = regcon_sll_ptr(vtable_index, exact_log2(vtableEntry::size() * wordSize), vtable_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2639 vtable_offset = regcon_inc_ptr(vtable_offset, base, vtable_offset, sethi_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2640 Address vtable_entry_addr(recv_klass, ensure_simm13_or_reg(vtable_offset, sethi_temp));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2641 ld_ptr(vtable_entry_addr, method_result);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2642 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2643
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2644
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2645 void MacroAssembler::check_klass_subtype(Register sub_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2646 Register super_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2647 Register temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2648 Register temp2_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2649 Label& L_success) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2650 Register sub_2 = sub_klass;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2651 Register sup_2 = super_klass;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2652 if (!sub_2->is_global()) sub_2 = L0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2653 if (!sup_2->is_global()) sup_2 = L1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2654 bool did_save = false;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2655 if (temp_reg == noreg || temp2_reg == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2656 temp_reg = L2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2657 temp2_reg = L3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2658 save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2659 sub_klass = sub_2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2660 super_klass = sup_2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2661 did_save = true;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2662 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2663 Label L_failure, L_pop_to_failure, L_pop_to_success;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2664 check_klass_subtype_fast_path(sub_klass, super_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2665 temp_reg, temp2_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2666 (did_save ? &L_pop_to_success : &L_success),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2667 (did_save ? &L_pop_to_failure : &L_failure), NULL);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2668
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2669 if (!did_save)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2670 save_frame_and_mov(0, sub_klass, sub_2, super_klass, sup_2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2671 check_klass_subtype_slow_path(sub_2, sup_2,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2672 L2, L3, L4, L5,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2673 NULL, &L_pop_to_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2674
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2675 // on success:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2676 bind(L_pop_to_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2677 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2678 ba_short(L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2679
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2680 // on failure:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2681 bind(L_pop_to_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2682 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2683 bind(L_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2684 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2685
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2686
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2687 void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2688 Register super_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2689 Register temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2690 Register temp2_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2691 Label* L_success,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2692 Label* L_failure,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2693 Label* L_slow_path,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2694 RegisterOrConstant super_check_offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2695 int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2696 int sco_offset = in_bytes(Klass::super_check_offset_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2697
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2698 bool must_load_sco = (super_check_offset.constant_or_zero() == -1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2699 bool need_slow_path = (must_load_sco ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2700 super_check_offset.constant_or_zero() == sco_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2701
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2702 assert_different_registers(sub_klass, super_klass, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2703 if (super_check_offset.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2704 assert_different_registers(sub_klass, super_klass, temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2705 super_check_offset.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2706 } else if (must_load_sco) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2707 assert(temp2_reg != noreg, "supply either a temp or a register offset");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2708 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2709
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2710 Label L_fallthrough;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2711 int label_nulls = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2712 if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2713 if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2714 if (L_slow_path == NULL) { L_slow_path = &L_fallthrough; label_nulls++; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2715 assert(label_nulls <= 1 ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2716 (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2717 "at most one NULL in the batch, usually");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2718
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2719 // If the pointers are equal, we are done (e.g., String[] elements).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2720 // This self-check enables sharing of secondary supertype arrays among
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2721 // non-primary types such as array-of-interface. Otherwise, each such
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2722 // type would need its own customized SSA.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2723 // We move this check to the front of the fast path because many
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2724 // type checks are in fact trivially successful in this manner,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2725 // so we get a nicely predicted branch right at the start of the check.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2726 cmp(super_klass, sub_klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2727 brx(Assembler::equal, false, Assembler::pn, *L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2728 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2729
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2730 // Check the supertype display:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2731 if (must_load_sco) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2732 // The super check offset is always positive...
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2733 lduw(super_klass, sco_offset, temp2_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2734 super_check_offset = RegisterOrConstant(temp2_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2735 // super_check_offset is register.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2736 assert_different_registers(sub_klass, super_klass, temp_reg, super_check_offset.as_register());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2737 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2738 ld_ptr(sub_klass, super_check_offset, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2739 cmp(super_klass, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2740
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2741 // This check has worked decisively for primary supers.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2742 // Secondary supers are sought in the super_cache ('super_cache_addr').
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2743 // (Secondary supers are interfaces and very deeply nested subtypes.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2744 // This works in the same check above because of a tricky aliasing
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2745 // between the super_cache and the primary super display elements.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2746 // (The 'super_check_addr' can address either, as the case requires.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2747 // Note that the cache is updated below if it does not help us find
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2748 // what we need immediately.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2749 // So if it was a primary super, we can just fail immediately.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2750 // Otherwise, it's the slow path for us (no success at this point).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2751
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2752 // Hacked ba(), which may only be used just before L_fallthrough.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2753 #define FINAL_JUMP(label) \
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2754 if (&(label) != &L_fallthrough) { \
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2755 ba(label); delayed()->nop(); \
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2756 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2757
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2758 if (super_check_offset.is_register()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2759 brx(Assembler::equal, false, Assembler::pn, *L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2760 delayed()->cmp(super_check_offset.as_register(), sc_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2761
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2762 if (L_failure == &L_fallthrough) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2763 brx(Assembler::equal, false, Assembler::pt, *L_slow_path);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2764 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2765 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2766 brx(Assembler::notEqual, false, Assembler::pn, *L_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2767 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2768 FINAL_JUMP(*L_slow_path);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2769 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2770 } else if (super_check_offset.as_constant() == sc_offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2771 // Need a slow path; fast failure is impossible.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2772 if (L_slow_path == &L_fallthrough) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2773 brx(Assembler::equal, false, Assembler::pt, *L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2774 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2775 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2776 brx(Assembler::notEqual, false, Assembler::pn, *L_slow_path);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2777 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2778 FINAL_JUMP(*L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2779 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2780 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2781 // No slow path; it's a fast decision.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2782 if (L_failure == &L_fallthrough) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2783 brx(Assembler::equal, false, Assembler::pt, *L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2784 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2785 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2786 brx(Assembler::notEqual, false, Assembler::pn, *L_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2787 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2788 FINAL_JUMP(*L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2789 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2790 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2791
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2792 bind(L_fallthrough);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2793
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2794 #undef FINAL_JUMP
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2795 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2796
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2797
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2798 void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2799 Register super_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2800 Register count_temp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2801 Register scan_temp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2802 Register scratch_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2803 Register coop_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2804 Label* L_success,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2805 Label* L_failure) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2806 assert_different_registers(sub_klass, super_klass,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2807 count_temp, scan_temp, scratch_reg, coop_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2808
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2809 Label L_fallthrough, L_loop;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2810 int label_nulls = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2811 if (L_success == NULL) { L_success = &L_fallthrough; label_nulls++; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2812 if (L_failure == NULL) { L_failure = &L_fallthrough; label_nulls++; }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2813 assert(label_nulls <= 1, "at most one NULL in the batch");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2814
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2815 // a couple of useful fields in sub_klass:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2816 int ss_offset = in_bytes(Klass::secondary_supers_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2817 int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2818
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2819 // Do a linear scan of the secondary super-klass chain.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2820 // This code is rarely used, so simplicity is a virtue here.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2821
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2822 #ifndef PRODUCT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2823 int* pst_counter = &SharedRuntime::_partial_subtype_ctr;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2824 inc_counter((address) pst_counter, count_temp, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2825 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2826
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2827 // We will consult the secondary-super array.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2828 ld_ptr(sub_klass, ss_offset, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2829
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2830 Register search_key = super_klass;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2831
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2832 // Load the array length. (Positive movl does right thing on LP64.)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2833 lduw(scan_temp, Array<Klass*>::length_offset_in_bytes(), count_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2834
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2835 // Check for empty secondary super list
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2836 tst(count_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2837
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2838 // In the array of super classes elements are pointer sized.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2839 int element_size = wordSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2840
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2841 // Top of search loop
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2842 bind(L_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2843 br(Assembler::equal, false, Assembler::pn, *L_failure);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2844 delayed()->add(scan_temp, element_size, scan_temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2845
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2846 // Skip the array header in all array accesses.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2847 int elem_offset = Array<Klass*>::base_offset_in_bytes();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2848 elem_offset -= element_size; // the scan pointer was pre-incremented also
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2849
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2850 // Load next super to check
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2851 ld_ptr( scan_temp, elem_offset, scratch_reg );
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2852
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2853 // Look for Rsuper_klass on Rsub_klass's secondary super-class-overflow list
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2854 cmp(scratch_reg, search_key);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2855
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2856 // A miss means we are NOT a subtype and need to keep looping
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2857 brx(Assembler::notEqual, false, Assembler::pn, L_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2858 delayed()->deccc(count_temp); // decrement trip counter in delay slot
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2859
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2860 // Success. Cache the super we found and proceed in triumph.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2861 st_ptr(super_klass, sub_klass, sc_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2862
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2863 if (L_success != &L_fallthrough) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2864 ba(*L_success);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2865 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2866 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2867
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2868 bind(L_fallthrough);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2869 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2870
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2871
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2872 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2873 Register temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2874 int extra_slot_offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2875 // cf. TemplateTable::prepare_invoke(), if (load_receiver).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2876 int stackElementSize = Interpreter::stackElementSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2877 int offset = extra_slot_offset * stackElementSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2878 if (arg_slot.is_constant()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2879 offset += arg_slot.as_constant() * stackElementSize;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2880 return offset;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2881 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2882 assert(temp_reg != noreg, "must specify");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2883 sll_ptr(arg_slot.as_register(), exact_log2(stackElementSize), temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2884 if (offset != 0)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2885 add(temp_reg, offset, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2886 return temp_reg;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2887 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2888 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2889
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2890
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2891 Address MacroAssembler::argument_address(RegisterOrConstant arg_slot,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2892 Register temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2893 int extra_slot_offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2894 return Address(Gargs, argument_offset(arg_slot, temp_reg, extra_slot_offset));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2895 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2896
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2897
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2898 void MacroAssembler::biased_locking_enter(Register obj_reg, Register mark_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2899 Register temp_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2900 Label& done, Label* slow_case,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2901 BiasedLockingCounters* counters) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2902 assert(UseBiasedLocking, "why call this otherwise?");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2903
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2904 if (PrintBiasedLockingStatistics) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2905 assert_different_registers(obj_reg, mark_reg, temp_reg, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2906 if (counters == NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2907 counters = BiasedLocking::counters();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2908 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2909
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2910 Label cas_label;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2911
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2912 // Biased locking
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2913 // See whether the lock is currently biased toward our thread and
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2914 // whether the epoch is still valid
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2915 // Note that the runtime guarantees sufficient alignment of JavaThread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2916 // pointers to allow age to be placed into low bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2917 assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2918 and3(mark_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2919 cmp_and_brx_short(temp_reg, markOopDesc::biased_lock_pattern, Assembler::notEqual, Assembler::pn, cas_label);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2920
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2921 load_klass(obj_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2922 ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2923 or3(G2_thread, temp_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2924 xor3(mark_reg, temp_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2925 andcc(temp_reg, ~((int) markOopDesc::age_mask_in_place), temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2926 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2927 cond_inc(Assembler::equal, (address) counters->biased_lock_entry_count_addr(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2928 // Reload mark_reg as we may need it later
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2929 ld_ptr(Address(obj_reg, oopDesc::mark_offset_in_bytes()), mark_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2930 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2931 brx(Assembler::equal, true, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2932 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2933
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2934 Label try_revoke_bias;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2935 Label try_rebias;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2936 Address mark_addr = Address(obj_reg, oopDesc::mark_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2937 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2938
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2939 // At this point we know that the header has the bias pattern and
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2940 // that we are not the bias owner in the current epoch. We need to
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2941 // figure out more details about the state of the header in order to
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2942 // know what operations can be legally performed on the object's
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2943 // header.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2944
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2945 // If the low three bits in the xor result aren't clear, that means
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2946 // the prototype header is no longer biased and we have to revoke
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2947 // the bias on this object.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2948 btst(markOopDesc::biased_lock_mask_in_place, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2949 brx(Assembler::notZero, false, Assembler::pn, try_revoke_bias);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2950
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2951 // Biasing is still enabled for this data type. See whether the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2952 // epoch of the current bias is still valid, meaning that the epoch
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2953 // bits of the mark word are equal to the epoch bits of the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2954 // prototype header. (Note that the prototype header's epoch bits
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2955 // only change at a safepoint.) If not, attempt to rebias the object
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2956 // toward the current thread. Note that we must be absolutely sure
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2957 // that the current epoch is invalid in order to do this because
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2958 // otherwise the manipulations it performs on the mark word are
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2959 // illegal.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2960 delayed()->btst(markOopDesc::epoch_mask_in_place, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2961 brx(Assembler::notZero, false, Assembler::pn, try_rebias);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2962
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2963 // The epoch of the current bias is still valid but we know nothing
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2964 // about the owner; it might be set or it might be clear. Try to
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2965 // acquire the bias of the object using an atomic operation. If this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2966 // fails we will go in to the runtime to revoke the object's bias.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2967 // Note that we first construct the presumed unbiased header so we
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2968 // don't accidentally blow away another thread's valid bias.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2969 delayed()->and3(mark_reg,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2970 markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2971 mark_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2972 or3(G2_thread, mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2973 casn(mark_addr.base(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2974 // If the biasing toward our thread failed, this means that
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2975 // another thread succeeded in biasing it toward itself and we
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2976 // need to revoke that bias. The revocation will occur in the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2977 // interpreter runtime in the slow case.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2978 cmp(mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2979 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2980 cond_inc(Assembler::zero, (address) counters->anonymously_biased_lock_entry_count_addr(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2981 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2982 if (slow_case != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2983 brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2984 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2985 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2986 ba_short(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2987
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2988 bind(try_rebias);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2989 // At this point we know the epoch has expired, meaning that the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2990 // current "bias owner", if any, is actually invalid. Under these
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2991 // circumstances _only_, we are allowed to use the current header's
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2992 // value as the comparison value when doing the cas to acquire the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2993 // bias in the current epoch. In other words, we allow transfer of
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2994 // the bias from one thread to another directly in this situation.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2995 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2996 // FIXME: due to a lack of registers we currently blow away the age
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2997 // bits in this situation. Should attempt to preserve them.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2998 load_klass(obj_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
2999 ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3000 or3(G2_thread, temp_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3001 casn(mark_addr.base(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3002 // If the biasing toward our thread failed, this means that
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3003 // another thread succeeded in biasing it toward itself and we
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3004 // need to revoke that bias. The revocation will occur in the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3005 // interpreter runtime in the slow case.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3006 cmp(mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3007 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3008 cond_inc(Assembler::zero, (address) counters->rebiased_lock_entry_count_addr(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3009 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3010 if (slow_case != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3011 brx(Assembler::notEqual, true, Assembler::pn, *slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3012 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3013 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3014 ba_short(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3015
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3016 bind(try_revoke_bias);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3017 // The prototype mark in the klass doesn't have the bias bit set any
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3018 // more, indicating that objects of this data type are not supposed
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3019 // to be biased any more. We are going to try to reset the mark of
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3020 // this object to the prototype value and fall through to the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3021 // CAS-based locking scheme. Note that if our CAS fails, it means
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3022 // that another thread raced us for the privilege of revoking the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3023 // bias of this particular object, so it's okay to continue in the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3024 // normal locking code.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3025 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3026 // FIXME: due to a lack of registers we currently blow away the age
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3027 // bits in this situation. Should attempt to preserve them.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3028 load_klass(obj_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3029 ld_ptr(Address(temp_reg, Klass::prototype_header_offset()), temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3030 casn(mark_addr.base(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3031 // Fall through to the normal CAS-based lock, because no matter what
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3032 // the result of the above CAS, some thread must have succeeded in
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3033 // removing the bias bit from the object's header.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3034 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3035 cmp(mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3036 cond_inc(Assembler::zero, (address) counters->revoked_lock_entry_count_addr(), mark_reg, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3037 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3038
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3039 bind(cas_label);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3040 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3041
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3042 void MacroAssembler::biased_locking_exit (Address mark_addr, Register temp_reg, Label& done,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3043 bool allow_delay_slot_filling) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3044 // Check for biased locking unlock case, which is a no-op
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3045 // Note: we do not have to check the thread ID for two reasons.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3046 // First, the interpreter checks for IllegalMonitorStateException at
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3047 // a higher level. Second, if the bias was revoked while we held the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3048 // lock, the object could not be rebiased toward another thread, so
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3049 // the bias bit would be clear.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3050 ld_ptr(mark_addr, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3051 and3(temp_reg, markOopDesc::biased_lock_mask_in_place, temp_reg);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3052 cmp(temp_reg, markOopDesc::biased_lock_pattern);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3053 brx(Assembler::equal, allow_delay_slot_filling, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3054 delayed();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3055 if (!allow_delay_slot_filling) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3056 nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3057 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3058 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3059
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3060
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3061 // CASN -- 32-64 bit switch hitter similar to the synthetic CASN provided by
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3062 // Solaris/SPARC's "as". Another apt name would be cas_ptr()
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3063
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3064 void MacroAssembler::casn (Register addr_reg, Register cmp_reg, Register set_reg ) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3065 casx_under_lock (addr_reg, cmp_reg, set_reg, (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3066 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3067
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3068
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3069
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3070 // compiler_lock_object() and compiler_unlock_object() are direct transliterations
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3071 // of i486.ad fast_lock() and fast_unlock(). See those methods for detailed comments.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3072 // The code could be tightened up considerably.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3073 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3074 // box->dhw disposition - post-conditions at DONE_LABEL.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3075 // - Successful inflated lock: box->dhw != 0.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3076 // Any non-zero value suffices.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3077 // Consider G2_thread, rsp, boxReg, or unused_mark()
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3078 // - Successful Stack-lock: box->dhw == mark.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3079 // box->dhw must contain the displaced mark word value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3080 // - Failure -- icc.ZFlag == 0 and box->dhw is undefined.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3081 // The slow-path fast_enter() and slow_enter() operators
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3082 // are responsible for setting box->dhw = NonZero (typically ::unused_mark).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3083 // - Biased: box->dhw is undefined
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3084 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3085 // SPARC refworkload performance - specifically jetstream and scimark - are
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3086 // extremely sensitive to the size of the code emitted by compiler_lock_object
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3087 // and compiler_unlock_object. Critically, the key factor is code size, not path
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3088 // length. (Simply experiments to pad CLO with unexecuted NOPs demonstrte the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3089 // effect).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3090
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3091
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3092 void MacroAssembler::compiler_lock_object(Register Roop, Register Rmark,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3093 Register Rbox, Register Rscratch,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3094 BiasedLockingCounters* counters,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3095 bool try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3096 Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3097
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3098 verify_oop(Roop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3099 Label done ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3100
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3101 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3102 inc_counter((address) counters->total_entry_count_addr(), Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3103 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3104
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3105 if (EmitSync & 1) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3106 mov(3, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3107 st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3108 cmp(SP, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3109 return ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3110 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3111
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3112 if (EmitSync & 2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3113
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3114 // Fetch object's markword
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3115 ld_ptr(mark_addr, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3116
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3117 if (try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3118 biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3119 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3120
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3121 // Save Rbox in Rscratch to be used for the cas operation
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3122 mov(Rbox, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3123
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3124 // set Rmark to markOop | markOopDesc::unlocked_value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3125 or3(Rmark, markOopDesc::unlocked_value, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3126
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3127 // Initialize the box. (Must happen before we update the object mark!)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3128 st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3129
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3130 // compare object markOop with Rmark and if equal exchange Rscratch with object markOop
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3131 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3132 casx_under_lock(mark_addr.base(), Rmark, Rscratch,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3133 (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3134
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3135 // if compare/exchange succeeded we found an unlocked object and we now have locked it
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3136 // hence we are done
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3137 cmp(Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3138 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3139 sub(Rscratch, STACK_BIAS, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3140 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3141 brx(Assembler::equal, false, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3142 delayed()->sub(Rscratch, SP, Rscratch); //pull next instruction into delay slot
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3143
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3144 // we did not find an unlocked object so see if this is a recursive case
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3145 // sub(Rscratch, SP, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3146 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3147 andcc(Rscratch, 0xfffff003, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3148 st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3149 bind (done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3150 return ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3151 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3152
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3153 Label Egress ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3154
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3155 if (EmitSync & 256) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3156 Label IsInflated ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3157
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3158 ld_ptr(mark_addr, Rmark); // fetch obj->mark
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3159 // Triage: biased, stack-locked, neutral, inflated
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3160 if (try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3161 biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3162 // Invariant: if control reaches this point in the emitted stream
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3163 // then Rmark has not been modified.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3164 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3165
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3166 // Store mark into displaced mark field in the on-stack basic-lock "box"
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3167 // Critically, this must happen before the CAS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3168 // Maximize the ST-CAS distance to minimize the ST-before-CAS penalty.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3169 st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3170 andcc(Rmark, 2, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3171 brx(Assembler::notZero, false, Assembler::pn, IsInflated);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3172 delayed()->
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3173
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3174 // Try stack-lock acquisition.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3175 // Beware: the 1st instruction is in a delay slot
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3176 mov(Rbox, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3177 or3(Rmark, markOopDesc::unlocked_value, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3178 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3179 casn(mark_addr.base(), Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3180 cmp(Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3181 brx(Assembler::equal, false, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3182 delayed()->sub(Rscratch, SP, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3183
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3184 // Stack-lock attempt failed - check for recursive stack-lock.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3185 // See the comments below about how we might remove this case.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3186 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3187 sub(Rscratch, STACK_BIAS, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3188 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3189 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3190 andcc(Rscratch, 0xfffff003, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3191 br(Assembler::always, false, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3192 delayed()-> st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3193
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3194 bind(IsInflated);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3195 if (EmitSync & 64) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3196 // If m->owner != null goto IsLocked
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3197 // Pessimistic form: Test-and-CAS vs CAS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3198 // The optimistic form avoids RTS->RTO cache line upgrades.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3199 ld_ptr(Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3200 andcc(Rscratch, Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3201 brx(Assembler::notZero, false, Assembler::pn, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3202 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3203 // m->owner == null : it's unlocked.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3204 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3205
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3206 // Try to CAS m->owner from null to Self
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3207 // Invariant: if we acquire the lock then _recursions should be 0.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3208 add(Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3209 mov(G2_thread, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3210 casn(Rmark, G0, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3211 cmp(Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3212 // Intentional fall-through into done
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3213 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3214 // Aggressively avoid the Store-before-CAS penalty
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3215 // Defer the store into box->dhw until after the CAS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3216 Label IsInflated, Recursive ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3217
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3218 // Anticipate CAS -- Avoid RTS->RTO upgrade
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3219 // prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3220
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3221 ld_ptr(mark_addr, Rmark); // fetch obj->mark
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3222 // Triage: biased, stack-locked, neutral, inflated
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3223
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3224 if (try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3225 biased_locking_enter(Roop, Rmark, Rscratch, done, NULL, counters);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3226 // Invariant: if control reaches this point in the emitted stream
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3227 // then Rmark has not been modified.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3228 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3229 andcc(Rmark, 2, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3230 brx(Assembler::notZero, false, Assembler::pn, IsInflated);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3231 delayed()-> // Beware - dangling delay-slot
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3232
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3233 // Try stack-lock acquisition.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3234 // Transiently install BUSY (0) encoding in the mark word.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3235 // if the CAS of 0 into the mark was successful then we execute:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3236 // ST box->dhw = mark -- save fetched mark in on-stack basiclock box
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3237 // ST obj->mark = box -- overwrite transient 0 value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3238 // This presumes TSO, of course.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3239
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3240 mov(0, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3241 or3(Rmark, markOopDesc::unlocked_value, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3242 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3243 casn(mark_addr.base(), Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3244 // prefetch (mark_addr, Assembler::severalWritesAndPossiblyReads);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3245 cmp(Rscratch, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3246 brx(Assembler::notZero, false, Assembler::pn, Recursive);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3247 delayed()->st_ptr(Rmark, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3248 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3249 cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3250 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3251 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3252 delayed()->st_ptr(Rbox, mark_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3253
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3254 bind(Recursive);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3255 // Stack-lock attempt failed - check for recursive stack-lock.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3256 // Tests show that we can remove the recursive case with no impact
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3257 // on refworkload 0.83. If we need to reduce the size of the code
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3258 // emitted by compiler_lock_object() the recursive case is perfect
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3259 // candidate.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3260 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3261 // A more extreme idea is to always inflate on stack-lock recursion.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3262 // This lets us eliminate the recursive checks in compiler_lock_object
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3263 // and compiler_unlock_object and the (box->dhw == 0) encoding.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3264 // A brief experiment - requiring changes to synchronizer.cpp, interpreter,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3265 // and showed a performance *increase*. In the same experiment I eliminated
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3266 // the fast-path stack-lock code from the interpreter and always passed
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3267 // control to the "slow" operators in synchronizer.cpp.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3268
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3269 // RScratch contains the fetched obj->mark value from the failed CASN.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3270 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3271 sub(Rscratch, STACK_BIAS, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3272 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3273 sub(Rscratch, SP, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3274 assert(os::vm_page_size() > 0xfff, "page size too small - change the constant");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3275 andcc(Rscratch, 0xfffff003, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3276 if (counters != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3277 // Accounting needs the Rscratch register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3278 st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3279 cond_inc(Assembler::equal, (address) counters->fast_path_entry_count_addr(), Rmark, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3280 ba_short(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3281 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3282 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3283 delayed()->st_ptr(Rscratch, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3284 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3285
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3286 bind (IsInflated);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3287 if (EmitSync & 64) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3288 // If m->owner != null goto IsLocked
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3289 // Test-and-CAS vs CAS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3290 // Pessimistic form avoids futile (doomed) CAS attempts
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3291 // The optimistic form avoids RTS->RTO cache line upgrades.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3292 ld_ptr(Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3293 andcc(Rscratch, Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3294 brx(Assembler::notZero, false, Assembler::pn, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3295 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3296 // m->owner == null : it's unlocked.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3297 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3298
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3299 // Try to CAS m->owner from null to Self
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3300 // Invariant: if we acquire the lock then _recursions should be 0.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3301 add(Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3302 mov(G2_thread, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3303 casn(Rmark, G0, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3304 cmp(Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3305 // ST box->displaced_header = NonZero.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3306 // Any non-zero value suffices:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3307 // unused_mark(), G2_thread, RBox, RScratch, rsp, etc.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3308 st_ptr(Rbox, Rbox, BasicLock::displaced_header_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3309 // Intentional fall-through into done
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3310 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3311
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3312 bind (done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3313 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3314
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3315 void MacroAssembler::compiler_unlock_object(Register Roop, Register Rmark,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3316 Register Rbox, Register Rscratch,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3317 bool try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3318 Address mark_addr(Roop, oopDesc::mark_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3319
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3320 Label done ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3321
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3322 if (EmitSync & 4) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3323 cmp(SP, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3324 return ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3325 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3326
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3327 if (EmitSync & 8) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3328 if (try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3329 biased_locking_exit(mark_addr, Rscratch, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3330 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3331
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3332 // Test first if it is a fast recursive unlock
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3333 ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3334 br_null_short(Rmark, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3335
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3336 // Check if it is still a light weight lock, this is is true if we see
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3337 // the stack address of the basicLock in the markOop of the object
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3338 assert(mark_addr.disp() == 0, "cas must take a zero displacement");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3339 casx_under_lock(mark_addr.base(), Rbox, Rmark,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3340 (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3341 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3342 delayed()->cmp(Rbox, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3343 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3344 return ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3345 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3346
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3347 // Beware ... If the aggregate size of the code emitted by CLO and CUO is
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3348 // is too large performance rolls abruptly off a cliff.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3349 // This could be related to inlining policies, code cache management, or
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3350 // I$ effects.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3351 Label LStacked ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3352
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3353 if (try_bias) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3354 // TODO: eliminate redundant LDs of obj->mark
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3355 biased_locking_exit(mark_addr, Rscratch, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3356 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3357
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3358 ld_ptr(Roop, oopDesc::mark_offset_in_bytes(), Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3359 ld_ptr(Rbox, BasicLock::displaced_header_offset_in_bytes(), Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3360 andcc(Rscratch, Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3361 brx(Assembler::zero, false, Assembler::pn, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3362 delayed()->nop(); // consider: relocate fetch of mark, above, into this DS
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3363 andcc(Rmark, 2, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3364 brx(Assembler::zero, false, Assembler::pt, LStacked);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3365 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3366
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3367 // It's inflated
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3368 // Conceptually we need a #loadstore|#storestore "release" MEMBAR before
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3369 // the ST of 0 into _owner which releases the lock. This prevents loads
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3370 // and stores within the critical section from reordering (floating)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3371 // past the store that releases the lock. But TSO is a strong memory model
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3372 // and that particular flavor of barrier is a noop, so we can safely elide it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3373 // Note that we use 1-0 locking by default for the inflated case. We
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3374 // close the resultant (and rare) race by having contented threads in
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3375 // monitorenter periodically poll _owner.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3376 ld_ptr(Rmark, ObjectMonitor::owner_offset_in_bytes() - 2, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3377 ld_ptr(Rmark, ObjectMonitor::recursions_offset_in_bytes() - 2, Rbox);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3378 xor3(Rscratch, G2_thread, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3379 orcc(Rbox, Rscratch, Rbox);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3380 brx(Assembler::notZero, false, Assembler::pn, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3381 delayed()->
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3382 ld_ptr(Rmark, ObjectMonitor::EntryList_offset_in_bytes() - 2, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3383 ld_ptr(Rmark, ObjectMonitor::cxq_offset_in_bytes() - 2, Rbox);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3384 orcc(Rbox, Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3385 if (EmitSync & 65536) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3386 Label LSucc ;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3387 brx(Assembler::notZero, false, Assembler::pn, LSucc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3388 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3389 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3390 delayed()->st_ptr(G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3391
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3392 bind(LSucc);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3393 st_ptr(G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3394 if (os::is_MP()) { membar (StoreLoad); }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3395 ld_ptr(Rmark, ObjectMonitor::succ_offset_in_bytes() - 2, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3396 andcc(Rscratch, Rscratch, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3397 brx(Assembler::notZero, false, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3398 delayed()->andcc(G0, G0, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3399 add(Rmark, ObjectMonitor::owner_offset_in_bytes()-2, Rmark);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3400 mov(G2_thread, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3401 casn(Rmark, G0, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3402 // invert icc.zf and goto done
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3403 br_notnull(Rscratch, false, Assembler::pt, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3404 delayed()->cmp(G0, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3405 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3406 delayed()->cmp(G0, 1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3407 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3408 brx(Assembler::notZero, false, Assembler::pn, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3409 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3410 ba(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3411 delayed()->st_ptr(G0, Rmark, ObjectMonitor::owner_offset_in_bytes() - 2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3412 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3413
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3414 bind (LStacked);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3415 // Consider: we could replace the expensive CAS in the exit
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3416 // path with a simple ST of the displaced mark value fetched from
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3417 // the on-stack basiclock box. That admits a race where a thread T2
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3418 // in the slow lock path -- inflating with monitor M -- could race a
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3419 // thread T1 in the fast unlock path, resulting in a missed wakeup for T2.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3420 // More precisely T1 in the stack-lock unlock path could "stomp" the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3421 // inflated mark value M installed by T2, resulting in an orphan
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3422 // object monitor M and T2 becoming stranded. We can remedy that situation
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3423 // by having T2 periodically poll the object's mark word using timed wait
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3424 // operations. If T2 discovers that a stomp has occurred it vacates
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3425 // the monitor M and wakes any other threads stranded on the now-orphan M.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3426 // In addition the monitor scavenger, which performs deflation,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3427 // would also need to check for orpan monitors and stranded threads.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3428 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3429 // Finally, inflation is also used when T2 needs to assign a hashCode
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3430 // to O and O is stack-locked by T1. The "stomp" race could cause
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3431 // an assigned hashCode value to be lost. We can avoid that condition
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3432 // and provide the necessary hashCode stability invariants by ensuring
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3433 // that hashCode generation is idempotent between copying GCs.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3434 // For example we could compute the hashCode of an object O as
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3435 // O's heap address XOR some high quality RNG value that is refreshed
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3436 // at GC-time. The monitor scavenger would install the hashCode
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3437 // found in any orphan monitors. Again, the mechanism admits a
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3438 // lost-update "stomp" WAW race but detects and recovers as needed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3439 //
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3440 // A prototype implementation showed excellent results, although
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3441 // the scavenger and timeout code was rather involved.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3442
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3443 casn(mark_addr.base(), Rbox, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3444 cmp(Rbox, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3445 // Intentional fall through into done ...
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3446
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3447 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3448 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3449
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3450
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3451
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3452 void MacroAssembler::print_CPU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3453 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3454 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3455
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3456 void MacroAssembler::verify_FPU(int stack_depth, const char* s) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3457 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3458 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3459
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3460 void MacroAssembler::push_IU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3461 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3462 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3463
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3464
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3465 void MacroAssembler::pop_IU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3466 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3467 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3468
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3469
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3470 void MacroAssembler::push_FPU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3471 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3472 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3473
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3474
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3475 void MacroAssembler::pop_FPU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3476 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3477 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3478
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3479
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3480 void MacroAssembler::push_CPU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3481 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3482 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3483
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3484
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3485 void MacroAssembler::pop_CPU_state() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3486 // %%%%% need to implement this
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3487 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3488
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3489
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3490
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3491 void MacroAssembler::verify_tlab() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3492 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3493 if (UseTLAB && VerifyOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3494 Label next, next2, ok;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3495 Register t1 = L0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3496 Register t2 = L1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3497 Register t3 = L2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3498
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3499 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3500 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3501 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3502 or3(t1, t2, t3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3503 cmp_and_br_short(t1, t2, Assembler::greaterEqual, Assembler::pn, next);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3504 STOP("assert(top >= start)");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3505 should_not_reach_here();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3506
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3507 bind(next);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3508 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3509 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3510 or3(t3, t2, t3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3511 cmp_and_br_short(t1, t2, Assembler::lessEqual, Assembler::pn, next2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3512 STOP("assert(top <= end)");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3513 should_not_reach_here();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3514
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3515 bind(next2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3516 and3(t3, MinObjAlignmentInBytesMask, t3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3517 cmp_and_br_short(t3, 0, Assembler::lessEqual, Assembler::pn, ok);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3518 STOP("assert(aligned)");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3519 should_not_reach_here();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3520
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3521 bind(ok);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3522 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3523 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3524 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3525 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3526
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3527
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3528 void MacroAssembler::eden_allocate(
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3529 Register obj, // result: pointer to object after successful allocation
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3530 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3531 int con_size_in_bytes, // object size in bytes if known at compile time
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3532 Register t1, // temp register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3533 Register t2, // temp register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3534 Label& slow_case // continuation point if fast allocation fails
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3535 ){
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3536 // make sure arguments make sense
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3537 assert_different_registers(obj, var_size_in_bytes, t1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3538 assert(0 <= con_size_in_bytes && Assembler::is_simm13(con_size_in_bytes), "illegal object size");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3539 assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3540
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3541 if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3542 // No allocation in the shared eden.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3543 ba_short(slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3544 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3545 // get eden boundaries
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3546 // note: we need both top & top_addr!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3547 const Register top_addr = t1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3548 const Register end = t2;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3549
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3550 CollectedHeap* ch = Universe::heap();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3551 set((intx)ch->top_addr(), top_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3552 intx delta = (intx)ch->end_addr() - (intx)ch->top_addr();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3553 ld_ptr(top_addr, delta, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3554 ld_ptr(top_addr, 0, obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3555
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3556 // try to allocate
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3557 Label retry;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3558 bind(retry);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3559 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3560 // make sure eden top is properly aligned
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3561 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3562 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3563 btst(MinObjAlignmentInBytesMask, obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3564 br(Assembler::zero, false, Assembler::pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3565 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3566 STOP("eden top is not properly aligned");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3567 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3568 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3569 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3570 const Register free = end;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3571 sub(end, obj, free); // compute amount of free space
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3572 if (var_size_in_bytes->is_valid()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3573 // size is unknown at compile time
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3574 cmp(free, var_size_in_bytes);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3575 br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3576 delayed()->add(obj, var_size_in_bytes, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3577 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3578 // size is known at compile time
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3579 cmp(free, con_size_in_bytes);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3580 br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3581 delayed()->add(obj, con_size_in_bytes, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3582 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3583 // Compare obj with the value at top_addr; if still equal, swap the value of
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3584 // end with the value at top_addr. If not equal, read the value at top_addr
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3585 // into end.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3586 casx_under_lock(top_addr, obj, end, (address)StubRoutines::Sparc::atomic_memory_operation_lock_addr());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3587 // if someone beat us on the allocation, try again, otherwise continue
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3588 cmp(obj, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3589 brx(Assembler::notEqual, false, Assembler::pn, retry);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3590 delayed()->mov(end, obj); // nop if successfull since obj == end
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3591
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3592 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3593 // make sure eden top is properly aligned
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3594 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3595 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3596 const Register top_addr = t1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3597
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3598 set((intx)ch->top_addr(), top_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3599 ld_ptr(top_addr, 0, top_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3600 btst(MinObjAlignmentInBytesMask, top_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3601 br(Assembler::zero, false, Assembler::pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3602 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3603 STOP("eden top is not properly aligned");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3604 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3605 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3606 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3607 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3608 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3609
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3610
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3611 void MacroAssembler::tlab_allocate(
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3612 Register obj, // result: pointer to object after successful allocation
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3613 Register var_size_in_bytes, // object size in bytes if unknown at compile time; invalid otherwise
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3614 int con_size_in_bytes, // object size in bytes if known at compile time
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3615 Register t1, // temp register
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3616 Label& slow_case // continuation point if fast allocation fails
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3617 ){
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3618 // make sure arguments make sense
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3619 assert_different_registers(obj, var_size_in_bytes, t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3620 assert(0 <= con_size_in_bytes && is_simm13(con_size_in_bytes), "illegal object size");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3621 assert((con_size_in_bytes & MinObjAlignmentInBytesMask) == 0, "object size is not multiple of alignment");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3622
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3623 const Register free = t1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3624
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3625 verify_tlab();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3626
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3627 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), obj);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3628
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3629 // calculate amount of free space
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3630 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), free);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3631 sub(free, obj, free);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3632
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3633 Label done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3634 if (var_size_in_bytes == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3635 cmp(free, con_size_in_bytes);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3636 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3637 cmp(free, var_size_in_bytes);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3638 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3639 br(Assembler::less, false, Assembler::pn, slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3640 // calculate the new top pointer
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3641 if (var_size_in_bytes == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3642 delayed()->add(obj, con_size_in_bytes, free);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3643 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3644 delayed()->add(obj, var_size_in_bytes, free);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3645 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3646
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3647 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3648
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3649 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3650 // make sure new free pointer is properly aligned
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3651 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3652 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3653 btst(MinObjAlignmentInBytesMask, free);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3654 br(Assembler::zero, false, Assembler::pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3655 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3656 STOP("updated TLAB free is not properly aligned");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3657 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3658 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3659 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3660
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3661 // update the tlab top pointer
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3662 st_ptr(free, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3663 verify_tlab();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3664 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3665
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3666
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3667 void MacroAssembler::tlab_refill(Label& retry, Label& try_eden, Label& slow_case) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3668 Register top = O0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3669 Register t1 = G1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3670 Register t2 = G3;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3671 Register t3 = O1;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3672 assert_different_registers(top, t1, t2, t3, G4, G5 /* preserve G4 and G5 */);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3673 Label do_refill, discard_tlab;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3674
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3675 if (CMSIncrementalMode || !Universe::heap()->supports_inline_contig_alloc()) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3676 // No allocation in the shared eden.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3677 ba_short(slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3678 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3679
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3680 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), top);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3681 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3682 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3683
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3684 // calculate amount of free space
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3685 sub(t1, top, t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3686 srl_ptr(t1, LogHeapWordSize, t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3687
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3688 // Retain tlab and allocate object in shared space if
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3689 // the amount free in the tlab is too large to discard.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3690 cmp(t1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3691 brx(Assembler::lessEqual, false, Assembler::pt, discard_tlab);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3692
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3693 // increment waste limit to prevent getting stuck on this slow path
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3694 delayed()->add(t2, ThreadLocalAllocBuffer::refill_waste_limit_increment(), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3695 st_ptr(t2, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3696 if (TLABStats) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3697 // increment number of slow_allocations
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3698 ld(G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3699 add(t2, 1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3700 stw(t2, G2_thread, in_bytes(JavaThread::tlab_slow_allocations_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3701 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3702 ba_short(try_eden);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3703
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3704 bind(discard_tlab);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3705 if (TLABStats) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3706 // increment number of refills
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3707 ld(G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3708 add(t2, 1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3709 stw(t2, G2_thread, in_bytes(JavaThread::tlab_number_of_refills_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3710 // accumulate wastage
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3711 ld(G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3712 add(t2, t1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3713 stw(t2, G2_thread, in_bytes(JavaThread::tlab_fast_refill_waste_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3714 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3715
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3716 // if tlab is currently allocated (top or end != null) then
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3717 // fill [top, end + alignment_reserve) with array object
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3718 br_null_short(top, Assembler::pn, do_refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3719
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3720 set((intptr_t)markOopDesc::prototype()->copy_set_hash(0x2), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3721 st_ptr(t2, top, oopDesc::mark_offset_in_bytes()); // set up the mark word
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3722 // set klass to intArrayKlass
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3723 sub(t1, typeArrayOopDesc::header_size(T_INT), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3724 add(t1, ThreadLocalAllocBuffer::alignment_reserve(), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3725 sll_ptr(t1, log2_intptr(HeapWordSize/sizeof(jint)), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3726 st(t1, top, arrayOopDesc::length_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3727 set((intptr_t)Universe::intArrayKlassObj_addr(), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3728 ld_ptr(t2, 0, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3729 // store klass last. concurrent gcs assumes klass length is valid if
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3730 // klass field is not null.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3731 store_klass(t2, top);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3732 verify_oop(top);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3733
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3734 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_start_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3735 sub(top, t1, t1); // size of tlab's allocated portion
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3736 incr_allocated_bytes(t1, t2, t3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3737
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3738 // refill the tlab with an eden allocation
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3739 bind(do_refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3740 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3741 sll_ptr(t1, LogHeapWordSize, t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3742 // allocate new tlab, address returned in top
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3743 eden_allocate(top, t1, 0, t2, t3, slow_case);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3744
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3745 st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_start_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3746 st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3747 #ifdef ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3748 // check that tlab_size (t1) is still valid
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3749 {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3750 Label ok;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3751 ld_ptr(G2_thread, in_bytes(JavaThread::tlab_size_offset()), t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3752 sll_ptr(t2, LogHeapWordSize, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3753 cmp_and_br_short(t1, t2, Assembler::equal, Assembler::pt, ok);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3754 STOP("assert(t1 == tlab_size)");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3755 should_not_reach_here();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3756
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3757 bind(ok);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3758 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3759 #endif // ASSERT
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3760 add(top, t1, top); // t1 is tlab_size
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3761 sub(top, ThreadLocalAllocBuffer::alignment_reserve_in_bytes(), top);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3762 st_ptr(top, G2_thread, in_bytes(JavaThread::tlab_end_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3763 verify_tlab();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3764 ba_short(retry);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3765 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3766
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3767 void MacroAssembler::incr_allocated_bytes(RegisterOrConstant size_in_bytes,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3768 Register t1, Register t2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3769 // Bump total bytes allocated by this thread
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3770 assert(t1->is_global(), "must be global reg"); // so all 64 bits are saved on a context switch
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3771 assert_different_registers(size_in_bytes.register_or_noreg(), t1, t2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3772 // v8 support has gone the way of the dodo
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3773 ldx(G2_thread, in_bytes(JavaThread::allocated_bytes_offset()), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3774 add(t1, ensure_simm13_or_reg(size_in_bytes, t2), t1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3775 stx(t1, G2_thread, in_bytes(JavaThread::allocated_bytes_offset()));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3776 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3777
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3778 Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3779 switch (cond) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3780 // Note some conditions are synonyms for others
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3781 case Assembler::never: return Assembler::always;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3782 case Assembler::zero: return Assembler::notZero;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3783 case Assembler::lessEqual: return Assembler::greater;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3784 case Assembler::less: return Assembler::greaterEqual;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3785 case Assembler::lessEqualUnsigned: return Assembler::greaterUnsigned;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3786 case Assembler::lessUnsigned: return Assembler::greaterEqualUnsigned;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3787 case Assembler::negative: return Assembler::positive;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3788 case Assembler::overflowSet: return Assembler::overflowClear;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3789 case Assembler::always: return Assembler::never;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3790 case Assembler::notZero: return Assembler::zero;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3791 case Assembler::greater: return Assembler::lessEqual;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3792 case Assembler::greaterEqual: return Assembler::less;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3793 case Assembler::greaterUnsigned: return Assembler::lessEqualUnsigned;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3794 case Assembler::greaterEqualUnsigned: return Assembler::lessUnsigned;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3795 case Assembler::positive: return Assembler::negative;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3796 case Assembler::overflowClear: return Assembler::overflowSet;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3797 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3798
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3799 ShouldNotReachHere(); return Assembler::overflowClear;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3800 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3801
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3802 void MacroAssembler::cond_inc(Assembler::Condition cond, address counter_ptr,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3803 Register Rtmp1, Register Rtmp2 /*, Register Rtmp3, Register Rtmp4 */) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3804 Condition negated_cond = negate_condition(cond);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3805 Label L;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3806 brx(negated_cond, false, Assembler::pt, L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3807 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3808 inc_counter(counter_ptr, Rtmp1, Rtmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3809 bind(L);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3810 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3811
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3812 void MacroAssembler::inc_counter(address counter_addr, Register Rtmp1, Register Rtmp2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3813 AddressLiteral addrlit(counter_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3814 sethi(addrlit, Rtmp1); // Move hi22 bits into temporary register.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3815 Address addr(Rtmp1, addrlit.low10()); // Build an address with low10 bits.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3816 ld(addr, Rtmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3817 inc(Rtmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3818 st(Rtmp2, addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3819 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3820
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3821 void MacroAssembler::inc_counter(int* counter_addr, Register Rtmp1, Register Rtmp2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3822 inc_counter((address) counter_addr, Rtmp1, Rtmp2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3823 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3824
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3825 SkipIfEqual::SkipIfEqual(
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3826 MacroAssembler* masm, Register temp, const bool* flag_addr,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3827 Assembler::Condition condition) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3828 _masm = masm;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3829 AddressLiteral flag(flag_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3830 _masm->sethi(flag, temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3831 _masm->ldub(temp, flag.low10(), temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3832 _masm->tst(temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3833 _masm->br(condition, false, Assembler::pt, _label);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3834 _masm->delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3835 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3836
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3837 SkipIfEqual::~SkipIfEqual() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3838 _masm->bind(_label);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3839 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3840
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3841
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3842 // Writes to stack successive pages until offset reached to check for
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3843 // stack overflow + shadow pages. This clobbers tsp and scratch.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3844 void MacroAssembler::bang_stack_size(Register Rsize, Register Rtsp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3845 Register Rscratch) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3846 // Use stack pointer in temp stack pointer
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3847 mov(SP, Rtsp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3848
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3849 // Bang stack for total size given plus stack shadow page size.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3850 // Bang one page at a time because a large size can overflow yellow and
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3851 // red zones (the bang will fail but stack overflow handling can't tell that
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3852 // it was a stack overflow bang vs a regular segv).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3853 int offset = os::vm_page_size();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3854 Register Roffset = Rscratch;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3855
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3856 Label loop;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3857 bind(loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3858 set((-offset)+STACK_BIAS, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3859 st(G0, Rtsp, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3860 set(offset, Roffset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3861 sub(Rsize, Roffset, Rsize);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3862 cmp(Rsize, G0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3863 br(Assembler::greater, false, Assembler::pn, loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3864 delayed()->sub(Rtsp, Roffset, Rtsp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3865
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3866 // Bang down shadow pages too.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3867 // The -1 because we already subtracted 1 page.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3868 for (int i = 0; i< StackShadowPages-1; i++) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3869 set((-i*offset)+STACK_BIAS, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3870 st(G0, Rtsp, Rscratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3871 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3872 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3873
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3874 ///////////////////////////////////////////////////////////////////////////////////
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7476
diff changeset
3875 #if INCLUDE_ALL_GCS
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3876
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3877 static address satb_log_enqueue_with_frame = NULL;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3878 static u_char* satb_log_enqueue_with_frame_end = NULL;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3879
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3880 static address satb_log_enqueue_frameless = NULL;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3881 static u_char* satb_log_enqueue_frameless_end = NULL;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3882
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3883 static int EnqueueCodeSize = 128 DEBUG_ONLY( + 256); // Instructions?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3884
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3885 static void generate_satb_log_enqueue(bool with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3886 BufferBlob* bb = BufferBlob::create("enqueue_with_frame", EnqueueCodeSize);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3887 CodeBuffer buf(bb);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3888 MacroAssembler masm(&buf);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3889
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3890 #define __ masm.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3891
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3892 address start = __ pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3893 Register pre_val;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3894
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3895 Label refill, restart;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3896 if (with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3897 __ save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3898 pre_val = I0; // Was O0 before the save.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3899 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3900 pre_val = O0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3901 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3902
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3903 int satb_q_index_byte_offset =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3904 in_bytes(JavaThread::satb_mark_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3905 PtrQueue::byte_offset_of_index());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3906
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3907 int satb_q_buf_byte_offset =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3908 in_bytes(JavaThread::satb_mark_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3909 PtrQueue::byte_offset_of_buf());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3910
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3911 assert(in_bytes(PtrQueue::byte_width_of_index()) == sizeof(intptr_t) &&
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3912 in_bytes(PtrQueue::byte_width_of_buf()) == sizeof(intptr_t),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3913 "check sizes in assembly below");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3914
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3915 __ bind(restart);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3916
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3917 // Load the index into the SATB buffer. PtrQueue::_index is a size_t
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3918 // so ld_ptr is appropriate.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3919 __ ld_ptr(G2_thread, satb_q_index_byte_offset, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3920
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3921 // index == 0?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3922 __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3923
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3924 __ ld_ptr(G2_thread, satb_q_buf_byte_offset, L1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3925 __ sub(L0, oopSize, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3926
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3927 __ st_ptr(pre_val, L1, L0); // [_buf + index] := I0
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3928 if (!with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3929 // Use return-from-leaf
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3930 __ retl();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3931 __ delayed()->st_ptr(L0, G2_thread, satb_q_index_byte_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3932 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3933 // Not delayed.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3934 __ st_ptr(L0, G2_thread, satb_q_index_byte_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3935 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3936 if (with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3937 __ ret();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3938 __ delayed()->restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3939 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3940 __ bind(refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3941
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3942 address handle_zero =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3943 CAST_FROM_FN_PTR(address,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3944 &SATBMarkQueueSet::handle_zero_index_for_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3945 // This should be rare enough that we can afford to save all the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3946 // scratch registers that the calling context might be using.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3947 __ mov(G1_scratch, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3948 __ mov(G3_scratch, L1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3949 __ mov(G4, L2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3950 // We need the value of O0 above (for the write into the buffer), so we
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3951 // save and restore it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3952 __ mov(O0, L3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3953 // Since the call will overwrite O7, we save and restore that, as well.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3954 __ mov(O7, L4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3955 __ call_VM_leaf(L5, handle_zero, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3956 __ mov(L0, G1_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3957 __ mov(L1, G3_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3958 __ mov(L2, G4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3959 __ mov(L3, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3960 __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3961 __ delayed()->mov(L4, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3962
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3963 if (with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3964 satb_log_enqueue_with_frame = start;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3965 satb_log_enqueue_with_frame_end = __ pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3966 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3967 satb_log_enqueue_frameless = start;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3968 satb_log_enqueue_frameless_end = __ pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3969 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3970
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3971 #undef __
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3972 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3973
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3974 static inline void generate_satb_log_enqueue_if_necessary(bool with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3975 if (with_frame) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3976 if (satb_log_enqueue_with_frame == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3977 generate_satb_log_enqueue(with_frame);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3978 assert(satb_log_enqueue_with_frame != 0, "postcondition.");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3979 if (G1SATBPrintStubs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3980 tty->print_cr("Generated with-frame satb enqueue:");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3981 Disassembler::decode((u_char*)satb_log_enqueue_with_frame,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3982 satb_log_enqueue_with_frame_end,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3983 tty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3984 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3985 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3986 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3987 if (satb_log_enqueue_frameless == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3988 generate_satb_log_enqueue(with_frame);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3989 assert(satb_log_enqueue_frameless != 0, "postcondition.");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3990 if (G1SATBPrintStubs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3991 tty->print_cr("Generated frameless satb enqueue:");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3992 Disassembler::decode((u_char*)satb_log_enqueue_frameless,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3993 satb_log_enqueue_frameless_end,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3994 tty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3995 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3996 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3997 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3998 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
3999
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4000 void MacroAssembler::g1_write_barrier_pre(Register obj,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4001 Register index,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4002 int offset,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4003 Register pre_val,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4004 Register tmp,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4005 bool preserve_o_regs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4006 Label filtered;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4007
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4008 if (obj == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4009 // We are not loading the previous value so make
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4010 // sure that we don't trash the value in pre_val
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4011 // with the code below.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4012 assert_different_registers(pre_val, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4013 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4014 // We will be loading the previous value
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4015 // in this code so...
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4016 assert(offset == 0 || index == noreg, "choose one");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4017 assert(pre_val == noreg, "check this code");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4018 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4019
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4020 // Is marking active?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4021 if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4022 ld(G2,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4023 in_bytes(JavaThread::satb_mark_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4024 PtrQueue::byte_offset_of_active()),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4025 tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4026 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4027 guarantee(in_bytes(PtrQueue::byte_width_of_active()) == 1,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4028 "Assumption");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4029 ldsb(G2,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4030 in_bytes(JavaThread::satb_mark_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4031 PtrQueue::byte_offset_of_active()),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4032 tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4033 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4034
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4035 // Is marking active?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4036 cmp_and_br_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4037
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4038 // Do we need to load the previous value?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4039 if (obj != noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4040 // Load the previous value...
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4041 if (index == noreg) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4042 if (Assembler::is_simm13(offset)) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4043 load_heap_oop(obj, offset, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4044 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4045 set(offset, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4046 load_heap_oop(obj, tmp, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4047 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4048 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4049 load_heap_oop(obj, index, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4050 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4051 // Previous value has been loaded into tmp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4052 pre_val = tmp;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4053 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4054
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4055 assert(pre_val != noreg, "must have a real register");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4056
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4057 // Is the previous value null?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4058 cmp_and_brx_short(pre_val, G0, Assembler::equal, Assembler::pt, filtered);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4059
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4060 // OK, it's not filtered, so we'll need to call enqueue. In the normal
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4061 // case, pre_val will be a scratch G-reg, but there are some cases in
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4062 // which it's an O-reg. In the first case, do a normal call. In the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4063 // latter, do a save here and call the frameless version.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4064
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4065 guarantee(pre_val->is_global() || pre_val->is_out(),
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4066 "Or we need to think harder.");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4067
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4068 if (pre_val->is_global() && !preserve_o_regs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4069 generate_satb_log_enqueue_if_necessary(true); // with frame
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4070
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4071 call(satb_log_enqueue_with_frame);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4072 delayed()->mov(pre_val, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4073 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4074 generate_satb_log_enqueue_if_necessary(false); // frameless
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4075
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4076 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4077 call(satb_log_enqueue_frameless);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4078 delayed()->mov(pre_val->after_save(), O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4079 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4080 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4081
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4082 bind(filtered);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4083 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4084
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4085 static address dirty_card_log_enqueue = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4086 static u_char* dirty_card_log_enqueue_end = 0;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4087
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4088 // This gets to assume that o0 contains the object address.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4089 static void generate_dirty_card_log_enqueue(jbyte* byte_map_base) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4090 BufferBlob* bb = BufferBlob::create("dirty_card_enqueue", EnqueueCodeSize*2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4091 CodeBuffer buf(bb);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4092 MacroAssembler masm(&buf);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4093 #define __ masm.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4094 address start = __ pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4095
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4096 Label not_already_dirty, restart, refill;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4097
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4098 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4099 __ srlx(O0, CardTableModRefBS::card_shift, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4100 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4101 __ srl(O0, CardTableModRefBS::card_shift, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4102 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4103 AddressLiteral addrlit(byte_map_base);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4104 __ set(addrlit, O1); // O1 := <card table base>
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4105 __ ldub(O0, O1, O2); // O2 := [O0 + O1]
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4106
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4107 assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4108 __ cmp_and_br_short(O2, G0, Assembler::notEqual, Assembler::pt, not_already_dirty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4109
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4110 // We didn't take the branch, so we're already dirty: return.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4111 // Use return-from-leaf
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4112 __ retl();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4113 __ delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4114
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4115 // Not dirty.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4116 __ bind(not_already_dirty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4117
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4118 // Get O0 + O1 into a reg by itself
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4119 __ add(O0, O1, O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4120
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4121 // First, dirty it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4122 __ stb(G0, O3, G0); // [cardPtr] := 0 (i.e., dirty).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4123
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4124 int dirty_card_q_index_byte_offset =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4125 in_bytes(JavaThread::dirty_card_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4126 PtrQueue::byte_offset_of_index());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4127 int dirty_card_q_buf_byte_offset =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4128 in_bytes(JavaThread::dirty_card_queue_offset() +
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4129 PtrQueue::byte_offset_of_buf());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4130 __ bind(restart);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4131
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4132 // Load the index into the update buffer. PtrQueue::_index is
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4133 // a size_t so ld_ptr is appropriate here.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4134 __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4135
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4136 // index == 0?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4137 __ cmp_and_brx_short(L0, G0, Assembler::equal, Assembler::pn, refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4138
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4139 __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, L1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4140 __ sub(L0, oopSize, L0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4141
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4142 __ st_ptr(O3, L1, L0); // [_buf + index] := I0
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4143 // Use return-from-leaf
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4144 __ retl();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4145 __ delayed()->st_ptr(L0, G2_thread, dirty_card_q_index_byte_offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4146
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4147 __ bind(refill);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4148 address handle_zero =
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4149 CAST_FROM_FN_PTR(address,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4150 &DirtyCardQueueSet::handle_zero_index_for_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4151 // This should be rare enough that we can afford to save all the
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4152 // scratch registers that the calling context might be using.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4153 __ mov(G1_scratch, L3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4154 __ mov(G3_scratch, L5);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4155 // We need the value of O3 above (for the write into the buffer), so we
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4156 // save and restore it.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4157 __ mov(O3, L6);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4158 // Since the call will overwrite O7, we save and restore that, as well.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4159 __ mov(O7, L4);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4160
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4161 __ call_VM_leaf(L7_thread_cache, handle_zero, G2_thread);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4162 __ mov(L3, G1_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4163 __ mov(L5, G3_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4164 __ mov(L6, O3);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4165 __ br(Assembler::always, /*annul*/false, Assembler::pt, restart);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4166 __ delayed()->mov(L4, O7);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4167
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4168 dirty_card_log_enqueue = start;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4169 dirty_card_log_enqueue_end = __ pc();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4170 // XXX Should have a guarantee here about not going off the end!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4171 // Does it already do so? Do an experiment...
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4172
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4173 #undef __
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4174
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4175 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4176
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4177 static inline void
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4178 generate_dirty_card_log_enqueue_if_necessary(jbyte* byte_map_base) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4179 if (dirty_card_log_enqueue == 0) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4180 generate_dirty_card_log_enqueue(byte_map_base);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4181 assert(dirty_card_log_enqueue != 0, "postcondition.");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4182 if (G1SATBPrintStubs) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4183 tty->print_cr("Generated dirty_card enqueue:");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4184 Disassembler::decode((u_char*)dirty_card_log_enqueue,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4185 dirty_card_log_enqueue_end,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4186 tty);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4187 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4188 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4189 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4190
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4191
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4192 void MacroAssembler::g1_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4193
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4194 Label filtered;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4195 MacroAssembler* post_filter_masm = this;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4196
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4197 if (new_val == G0) return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4198
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4199 G1SATBCardTableModRefBS* bs = (G1SATBCardTableModRefBS*) Universe::heap()->barrier_set();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4200 assert(bs->kind() == BarrierSet::G1SATBCT ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4201 bs->kind() == BarrierSet::G1SATBCTLogging, "wrong barrier");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4202
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4203 if (G1RSBarrierRegionFilter) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4204 xor3(store_addr, new_val, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4205 #ifdef _LP64
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4206 srlx(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4207 #else
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4208 srl(tmp, HeapRegion::LogOfHRGrainBytes, tmp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4209 #endif
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4210
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4211 // XXX Should I predict this taken or not? Does it matter?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4212 cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pt, filtered);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4213 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4214
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4215 // If the "store_addr" register is an "in" or "local" register, move it to
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4216 // a scratch reg so we can pass it as an argument.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4217 bool use_scr = !(store_addr->is_global() || store_addr->is_out());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4218 // Pick a scratch register different from "tmp".
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4219 Register scr = (tmp == G1_scratch ? G3_scratch : G1_scratch);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4220 // Make sure we use up the delay slot!
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4221 if (use_scr) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4222 post_filter_masm->mov(store_addr, scr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4223 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4224 post_filter_masm->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4225 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4226 generate_dirty_card_log_enqueue_if_necessary(bs->byte_map_base);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4227 save_frame(0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4228 call(dirty_card_log_enqueue);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4229 if (use_scr) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4230 delayed()->mov(scr, O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4231 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4232 delayed()->mov(store_addr->after_save(), O0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4233 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4234 restore();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4235
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4236 bind(filtered);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4237 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4238
8001
db9981fd3124 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 7476
diff changeset
4239 #endif // INCLUDE_ALL_GCS
7204
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4240 ///////////////////////////////////////////////////////////////////////////////////
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4241
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4242 void MacroAssembler::card_write_barrier_post(Register store_addr, Register new_val, Register tmp) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4243 // If we're writing constant NULL, we can skip the write barrier.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4244 if (new_val == G0) return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4245 CardTableModRefBS* bs = (CardTableModRefBS*) Universe::heap()->barrier_set();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4246 assert(bs->kind() == BarrierSet::CardTableModRef ||
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4247 bs->kind() == BarrierSet::CardTableExtension, "wrong barrier");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4248 card_table_write(bs->byte_map_base, tmp, store_addr);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4249 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4250
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4251 void MacroAssembler::load_klass(Register src_oop, Register klass) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4252 // The number of bytes in this code is used by
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4253 // MachCallDynamicJavaNode::ret_addr_offset()
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4254 // if this changes, change that.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4255 if (UseCompressedKlassPointers) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4256 lduw(src_oop, oopDesc::klass_offset_in_bytes(), klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4257 decode_klass_not_null(klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4258 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4259 ld_ptr(src_oop, oopDesc::klass_offset_in_bytes(), klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4260 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4261 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4262
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4263 void MacroAssembler::store_klass(Register klass, Register dst_oop) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4264 if (UseCompressedKlassPointers) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4265 assert(dst_oop != klass, "not enough registers");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4266 encode_klass_not_null(klass);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4267 st(klass, dst_oop, oopDesc::klass_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4268 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4269 st_ptr(klass, dst_oop, oopDesc::klass_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4270 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4271 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4272
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4273 void MacroAssembler::store_klass_gap(Register s, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4274 if (UseCompressedKlassPointers) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4275 assert(s != d, "not enough registers");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4276 st(s, d, oopDesc::klass_gap_offset_in_bytes());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4277 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4278 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4279
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4280 void MacroAssembler::load_heap_oop(const Address& s, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4281 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4282 lduw(s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4283 decode_heap_oop(d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4284 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4285 ld_ptr(s, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4286 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4287 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4288
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4289 void MacroAssembler::load_heap_oop(Register s1, Register s2, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4290 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4291 lduw(s1, s2, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4292 decode_heap_oop(d, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4293 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4294 ld_ptr(s1, s2, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4295 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4296 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4297
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4298 void MacroAssembler::load_heap_oop(Register s1, int simm13a, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4299 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4300 lduw(s1, simm13a, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4301 decode_heap_oop(d, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4302 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4303 ld_ptr(s1, simm13a, d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4304 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4305 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4306
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4307 void MacroAssembler::load_heap_oop(Register s1, RegisterOrConstant s2, Register d) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4308 if (s2.is_constant()) load_heap_oop(s1, s2.as_constant(), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4309 else load_heap_oop(s1, s2.as_register(), d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4310 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4311
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4312 void MacroAssembler::store_heap_oop(Register d, Register s1, Register s2) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4313 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4314 assert(s1 != d && s2 != d, "not enough registers");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4315 encode_heap_oop(d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4316 st(d, s1, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4317 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4318 st_ptr(d, s1, s2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4319 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4320 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4321
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4322 void MacroAssembler::store_heap_oop(Register d, Register s1, int simm13a) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4323 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4324 assert(s1 != d, "not enough registers");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4325 encode_heap_oop(d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4326 st(d, s1, simm13a);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4327 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4328 st_ptr(d, s1, simm13a);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4329 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4330 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4331
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4332 void MacroAssembler::store_heap_oop(Register d, const Address& a, int offset) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4333 if (UseCompressedOops) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4334 assert(a.base() != d, "not enough registers");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4335 encode_heap_oop(d);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4336 st(d, a, offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4337 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4338 st_ptr(d, a, offset);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4339 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4340 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4341
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4342
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4343 void MacroAssembler::encode_heap_oop(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4344 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4345 assert (Universe::heap() != NULL, "java heap should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4346 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4347 verify_oop(src);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4348 if (Universe::narrow_oop_base() == NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4349 srlx(src, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4350 return;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4351 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4352 Label done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4353 if (src == dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4354 // optimize for frequent case src == dst
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4355 bpr(rc_nz, true, Assembler::pt, src, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4356 delayed() -> sub(src, G6_heapbase, dst); // annuled if not taken
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4357 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4358 srlx(src, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4359 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4360 bpr(rc_z, false, Assembler::pn, src, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4361 delayed() -> mov(G0, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4362 // could be moved before branch, and annulate delay,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4363 // but may add some unneeded work decoding null
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4364 sub(src, G6_heapbase, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4365 srlx(dst, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4366 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4367 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4368 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4369
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4370
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4371 void MacroAssembler::encode_heap_oop_not_null(Register r) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4372 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4373 assert (Universe::heap() != NULL, "java heap should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4374 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4375 verify_oop(r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4376 if (Universe::narrow_oop_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4377 sub(r, G6_heapbase, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4378 srlx(r, LogMinObjAlignmentInBytes, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4379 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4380
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4381 void MacroAssembler::encode_heap_oop_not_null(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4382 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4383 assert (Universe::heap() != NULL, "java heap should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4384 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4385 verify_oop(src);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4386 if (Universe::narrow_oop_base() == NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4387 srlx(src, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4388 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4389 sub(src, G6_heapbase, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4390 srlx(dst, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4391 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4392 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4393
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4394 // Same algorithm as oops.inline.hpp decode_heap_oop.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4395 void MacroAssembler::decode_heap_oop(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4396 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4397 assert (Universe::heap() != NULL, "java heap should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4398 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4399 sllx(src, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4400 if (Universe::narrow_oop_base() != NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4401 Label done;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4402 bpr(rc_nz, true, Assembler::pt, dst, done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4403 delayed() -> add(dst, G6_heapbase, dst); // annuled if not taken
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4404 bind(done);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4405 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4406 verify_oop(dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4407 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4408
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4409 void MacroAssembler::decode_heap_oop_not_null(Register r) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4410 // Do not add assert code to this unless you change vtableStubs_sparc.cpp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4411 // pd_code_size_limit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4412 // Also do not verify_oop as this is called by verify_oop.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4413 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4414 assert (Universe::heap() != NULL, "java heap should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4415 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4416 sllx(r, LogMinObjAlignmentInBytes, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4417 if (Universe::narrow_oop_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4418 add(r, G6_heapbase, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4419 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4420
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4421 void MacroAssembler::decode_heap_oop_not_null(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4422 // Do not add assert code to this unless you change vtableStubs_sparc.cpp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4423 // pd_code_size_limit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4424 // Also do not verify_oop as this is called by verify_oop.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4425 assert (UseCompressedOops, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4426 assert (LogMinObjAlignmentInBytes == Universe::narrow_oop_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4427 sllx(src, LogMinObjAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4428 if (Universe::narrow_oop_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4429 add(dst, G6_heapbase, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4430 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4431
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4432 void MacroAssembler::encode_klass_not_null(Register r) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4433 assert(Metaspace::is_initialized(), "metaspace should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4434 assert (UseCompressedKlassPointers, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4435 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4436 if (Universe::narrow_klass_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4437 sub(r, G6_heapbase, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4438 srlx(r, LogKlassAlignmentInBytes, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4439 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4440
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4441 void MacroAssembler::encode_klass_not_null(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4442 assert(Metaspace::is_initialized(), "metaspace should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4443 assert (UseCompressedKlassPointers, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4444 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4445 if (Universe::narrow_klass_base() == NULL) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4446 srlx(src, LogKlassAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4447 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4448 sub(src, G6_heapbase, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4449 srlx(dst, LogKlassAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4450 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4451 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4452
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4453 void MacroAssembler::decode_klass_not_null(Register r) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4454 assert(Metaspace::is_initialized(), "metaspace should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4455 // Do not add assert code to this unless you change vtableStubs_sparc.cpp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4456 // pd_code_size_limit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4457 assert (UseCompressedKlassPointers, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4458 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4459 sllx(r, LogKlassAlignmentInBytes, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4460 if (Universe::narrow_klass_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4461 add(r, G6_heapbase, r);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4462 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4463
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4464 void MacroAssembler::decode_klass_not_null(Register src, Register dst) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4465 assert(Metaspace::is_initialized(), "metaspace should be initialized");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4466 // Do not add assert code to this unless you change vtableStubs_sparc.cpp
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4467 // pd_code_size_limit.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4468 assert (UseCompressedKlassPointers, "must be compressed");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4469 assert (LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4470 sllx(src, LogKlassAlignmentInBytes, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4471 if (Universe::narrow_klass_base() != NULL)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4472 add(dst, G6_heapbase, dst);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4473 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4474
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4475 void MacroAssembler::reinit_heapbase() {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4476 if (UseCompressedOops || UseCompressedKlassPointers) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4477 AddressLiteral base(Universe::narrow_ptrs_base_addr());
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4478 load_ptr_contents(base, G6_heapbase);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4479 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4480 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4481
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4482 // Compare char[] arrays aligned to 4 bytes.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4483 void MacroAssembler::char_arrays_equals(Register ary1, Register ary2,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4484 Register limit, Register result,
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4485 Register chr1, Register chr2, Label& Ldone) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4486 Label Lvector, Lloop;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4487 assert(chr1 == result, "should be the same");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4488
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4489 // Note: limit contains number of bytes (2*char_elements) != 0.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4490 andcc(limit, 0x2, chr1); // trailing character ?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4491 br(Assembler::zero, false, Assembler::pt, Lvector);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4492 delayed()->nop();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4493
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4494 // compare the trailing char
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4495 sub(limit, sizeof(jchar), limit);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4496 lduh(ary1, limit, chr1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4497 lduh(ary2, limit, chr2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4498 cmp(chr1, chr2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4499 br(Assembler::notEqual, true, Assembler::pt, Ldone);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4500 delayed()->mov(G0, result); // not equal
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4501
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4502 // only one char ?
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4503 cmp_zero_and_br(zero, limit, Ldone, true, Assembler::pn);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4504 delayed()->add(G0, 1, result); // zero-length arrays are equal
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4505
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4506 // word by word compare, dont't need alignment check
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4507 bind(Lvector);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4508 // Shift ary1 and ary2 to the end of the arrays, negate limit
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4509 add(ary1, limit, ary1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4510 add(ary2, limit, ary2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4511 neg(limit, limit);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4512
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4513 lduw(ary1, limit, chr1);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4514 bind(Lloop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4515 lduw(ary2, limit, chr2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4516 cmp(chr1, chr2);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4517 br(Assembler::notEqual, true, Assembler::pt, Ldone);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4518 delayed()->mov(G0, result); // not equal
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4519 inccc(limit, 2*sizeof(jchar));
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4520 // annul LDUW if branch is not taken to prevent access past end of array
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4521 br(Assembler::notZero, true, Assembler::pt, Lloop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4522 delayed()->lduw(ary1, limit, chr1); // hoisted
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4523
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4524 // Caller should set it:
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4525 // add(G0, 1, result); // equals
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4526 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4527
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4528 // Use BIS for zeroing (count is in bytes).
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4529 void MacroAssembler::bis_zeroing(Register to, Register count, Register temp, Label& Ldone) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4530 assert(UseBlockZeroing && VM_Version::has_block_zeroing(), "only works with BIS zeroing");
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4531 Register end = count;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4532 int cache_line_size = VM_Version::prefetch_data_size();
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4533 // Minimum count when BIS zeroing can be used since
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4534 // it needs membar which is expensive.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4535 int block_zero_size = MAX2(cache_line_size*3, (int)BlockZeroingLowLimit);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4536
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4537 Label small_loop;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4538 // Check if count is negative (dead code) or zero.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4539 // Note, count uses 64bit in 64 bit VM.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4540 cmp_and_brx_short(count, 0, Assembler::lessEqual, Assembler::pn, Ldone);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4541
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4542 // Use BIS zeroing only for big arrays since it requires membar.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4543 if (Assembler::is_simm13(block_zero_size)) { // < 4096
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4544 cmp(count, block_zero_size);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4545 } else {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4546 set(block_zero_size, temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4547 cmp(count, temp);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4548 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4549 br(Assembler::lessUnsigned, false, Assembler::pt, small_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4550 delayed()->add(to, count, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4551
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4552 // Note: size is >= three (32 bytes) cache lines.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4553
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4554 // Clean the beginning of space up to next cache line.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4555 for (int offs = 0; offs < cache_line_size; offs += 8) {
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4556 stx(G0, to, offs);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4557 }
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4558
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4559 // align to next cache line
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4560 add(to, cache_line_size, to);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4561 and3(to, -cache_line_size, to);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4562
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4563 // Note: size left >= two (32 bytes) cache lines.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4564
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4565 // BIS should not be used to zero tail (64 bytes)
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4566 // to avoid zeroing a header of the following object.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4567 sub(end, (cache_line_size*2)-8, end);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4568
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4569 Label bis_loop;
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4570 bind(bis_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4571 stxa(G0, to, G0, Assembler::ASI_ST_BLKINIT_PRIMARY);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4572 add(to, cache_line_size, to);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4573 cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, bis_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4574
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4575 // BIS needs membar.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4576 membar(Assembler::StoreLoad);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4577
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4578 add(end, (cache_line_size*2)-8, end); // restore end
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4579 cmp_and_brx_short(to, end, Assembler::greaterEqualUnsigned, Assembler::pn, Ldone);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4580
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4581 // Clean the tail.
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4582 bind(small_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4583 stx(G0, to, 0);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4584 add(to, 8, to);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4585 cmp_and_brx_short(to, end, Assembler::lessUnsigned, Assembler::pt, small_loop);
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4586 nop(); // Separate short branches
f0c2369fda5a 8003250: SPARC: move MacroAssembler into separate file
twisti
parents:
diff changeset
4587 }