annotate src/cpu/ppc/vm/macroAssembler_ppc.cpp @ 14413:7687c56b6693

8024379: Adapt PPC64 port to 8003424 Reviewed-by: coleenp
author goetz
date Fri, 06 Sep 2013 10:13:17 +0200
parents ec28f9c041ff
children a0d02bb625e2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1 /*
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3 * Copyright 2012, 2013 SAP AG. All rights reserved.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
5 *
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
6 * This code is free software; you can redistribute it and/or modify it
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
7 * under the terms of the GNU General Public License version 2 only, as
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
8 * published by the Free Software Foundation.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
9 *
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
10 * This code is distributed in the hope that it will be useful, but WITHOUT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
13 * version 2 for more details (a copy is included in the LICENSE file that
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
14 * accompanied this code).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
15 *
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License version
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
17 * 2 along with this work; if not, write to the Free Software Foundation,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
19 *
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
21 * or visit www.oracle.com if you need additional information or have any
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
22 * questions.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
23 *
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
24 */
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
25
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
26 #include "precompiled.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
27 #include "asm/assembler.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
28 #include "asm/assembler.inline.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
29 #include "asm/macroAssembler.inline.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
30 #include "compiler/disassembler.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
31 #include "gc_interface/collectedHeap.inline.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
32 #include "interpreter/interpreter.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
33 #include "memory/cardTableModRefBS.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
34 #include "memory/resourceArea.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
35 #include "prims/methodHandles.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
36 #include "runtime/biasedLocking.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
37 #include "runtime/interfaceSupport.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
38 #include "runtime/objectMonitor.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
39 #include "runtime/os.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
40 #include "runtime/sharedRuntime.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
41 #include "runtime/stubRoutines.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
42 #include "utilities/macros.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
43 #if INCLUDE_ALL_GCS
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
44 #include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
45 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
46 #include "gc_implementation/g1/heapRegion.hpp"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
47 #endif // INCLUDE_ALL_GCS
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
48
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
49 #ifdef PRODUCT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
50 #define BLOCK_COMMENT(str) // nothing
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
51 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
52 #define BLOCK_COMMENT(str) block_comment(str)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
53 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
54
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
55 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
56 // On RISC, there's no benefit to verifying instruction boundaries.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
57 bool AbstractAssembler::pd_check_instruction_mark() { return false; }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
58 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
59
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
60 void MacroAssembler::ld_largeoffset_unchecked(Register d, int si31, Register a, int emit_filler_nop) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
61 assert(Assembler::is_simm(si31, 31) && si31 >= 0, "si31 out of range");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
62 if (Assembler::is_simm(si31, 16)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
63 ld(d, si31, a);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
64 if (emit_filler_nop) nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
65 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
66 const int hi = MacroAssembler::largeoffset_si16_si16_hi(si31);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
67 const int lo = MacroAssembler::largeoffset_si16_si16_lo(si31);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
68 addis(d, a, hi);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
69 ld(d, lo, d);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
70 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
71 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
72
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
73 void MacroAssembler::ld_largeoffset(Register d, int si31, Register a, int emit_filler_nop) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
74 assert_different_registers(d, a);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
75 ld_largeoffset_unchecked(d, si31, a, emit_filler_nop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
76 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
77
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
78 void MacroAssembler::load_sized_value(Register dst, RegisterOrConstant offs, Register base,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
79 size_t size_in_bytes, bool is_signed) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
80 switch (size_in_bytes) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
81 case 8: ld(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
82 case 4: is_signed ? lwa(dst, offs, base) : lwz(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
83 case 2: is_signed ? lha(dst, offs, base) : lhz(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
84 case 1: lbz(dst, offs, base); if (is_signed) extsb(dst, dst); break; // lba doesn't exist :(
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
85 default: ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
86 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
87 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
88
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
89 void MacroAssembler::store_sized_value(Register dst, RegisterOrConstant offs, Register base,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
90 size_t size_in_bytes) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
91 switch (size_in_bytes) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
92 case 8: std(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
93 case 4: stw(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
94 case 2: sth(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
95 case 1: stb(dst, offs, base); break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
96 default: ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
97 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
98 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
99
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
100 void MacroAssembler::align(int modulus) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
101 while (offset() % modulus != 0) nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
102 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
103
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
104 // Issue instructions that calculate given TOC from global TOC.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
105 void MacroAssembler::calculate_address_from_global_toc(Register dst, address addr, bool hi16, bool lo16,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
106 bool add_relocation, bool emit_dummy_addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
107 int offset = -1;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
108 if (emit_dummy_addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
109 offset = -128; // dummy address
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
110 } else if (addr != (address)(intptr_t)-1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
111 offset = MacroAssembler::offset_to_global_toc(addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
112 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
113
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
114 if (hi16) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
115 addis(dst, R29, MacroAssembler::largeoffset_si16_si16_hi(offset));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
116 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
117 if (lo16) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
118 if (add_relocation) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
119 // Relocate at the addi to avoid confusion with a load from the method's TOC.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
120 relocate(internal_word_Relocation::spec(addr));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
121 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
122 addi(dst, dst, MacroAssembler::largeoffset_si16_si16_lo(offset));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
123 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
124 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
125
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
126 int MacroAssembler::patch_calculate_address_from_global_toc_at(address a, address bound, address addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
127 const int offset = MacroAssembler::offset_to_global_toc(addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
128
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
129 const address inst2_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
130 const int inst2 = *(int *)inst2_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
131
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
132 // The relocation points to the second instruction, the addi,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
133 // and the addi reads and writes the same register dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
134 const int dst = inv_rt_field(inst2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
135 assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
136
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
137 // Now, find the preceding addis which writes to dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
138 int inst1 = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
139 address inst1_addr = inst2_addr - BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
140 while (inst1_addr >= bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
141 inst1 = *(int *) inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
142 if (is_addis(inst1) && inv_rt_field(inst1) == dst) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
143 // Stop, found the addis which writes dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
144 break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
145 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
146 inst1_addr -= BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
147 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
148
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
149 assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
150 set_imm((int *)inst1_addr, MacroAssembler::largeoffset_si16_si16_hi(offset));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
151 set_imm((int *)inst2_addr, MacroAssembler::largeoffset_si16_si16_lo(offset));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
152 return (int)((intptr_t)addr - (intptr_t)inst1_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
153 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
154
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
155 address MacroAssembler::get_address_of_calculate_address_from_global_toc_at(address a, address bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
156 const address inst2_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
157 const int inst2 = *(int *)inst2_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
158
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
159 // The relocation points to the second instruction, the addi,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
160 // and the addi reads and writes the same register dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
161 const int dst = inv_rt_field(inst2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
162 assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
163
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
164 // Now, find the preceding addis which writes to dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
165 int inst1 = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
166 address inst1_addr = inst2_addr - BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
167 while (inst1_addr >= bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
168 inst1 = *(int *) inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
169 if (is_addis(inst1) && inv_rt_field(inst1) == dst) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
170 // stop, found the addis which writes dst
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
171 break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
172 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
173 inst1_addr -= BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
174 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
175
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
176 assert(is_addis(inst1) && inv_ra_field(inst1) == 29 /* R29 */, "source must be global TOC");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
177
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
178 int offset = (get_imm(inst1_addr, 0) << 16) + get_imm(inst2_addr, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
179 // -1 is a special case
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
180 if (offset == -1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
181 return (address)(intptr_t)-1;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
182 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
183 return global_toc() + offset;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
184 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
185 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
186
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
187 #ifdef _LP64
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
188 // Patch compressed oops or klass constants.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
189 int MacroAssembler::patch_set_narrow_oop(address a, address bound, narrowOop data) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
190 assert(UseCompressedOops, "Should only patch compressed oops");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
191
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
192 const address inst2_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
193 const int inst2 = *(int *)inst2_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
194
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
195 // The relocation points to the second instruction, the addi,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
196 // and the addi reads and writes the same register dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
197 const int dst = inv_rt_field(inst2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
198 assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
199 // Now, find the preceding addis which writes to dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
200 int inst1 = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
201 address inst1_addr = inst2_addr - BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
202 bool inst1_found = false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
203 while (inst1_addr >= bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
204 inst1 = *(int *)inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
205 if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break; }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
206 inst1_addr -= BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
207 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
208 assert(inst1_found, "inst is not lis");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
209
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
210 int xc = (data >> 16) & 0xffff;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
211 int xd = (data >> 0) & 0xffff;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
212
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
213 set_imm((int *)inst1_addr,((short)(xc + ((xd & 0x8000) != 0 ? 1 : 0)))); // see enc_load_con_narrow1/2
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
214 set_imm((int *)inst2_addr, (short)(xd));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
215 return (int)((intptr_t)inst2_addr - (intptr_t)inst1_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
216 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
217
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
218 // Get compressed oop or klass constant.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
219 narrowOop MacroAssembler::get_narrow_oop(address a, address bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
220 assert(UseCompressedOops, "Should only patch compressed oops");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
221
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
222 const address inst2_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
223 const int inst2 = *(int *)inst2_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
224
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
225 // The relocation points to the second instruction, the addi,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
226 // and the addi reads and writes the same register dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
227 const int dst = inv_rt_field(inst2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
228 assert(is_addi(inst2) && inv_ra_field(inst2) == dst, "must be addi reading and writing dst");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
229 // Now, find the preceding lis which writes to dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
230 int inst1 = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
231 address inst1_addr = inst2_addr - BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
232 bool inst1_found = false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
233
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
234 while (inst1_addr >= bound) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
235 inst1 = *(int *) inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
236 if (is_lis(inst1) && inv_rs_field(inst1) == dst) { inst1_found = true; break;}
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
237 inst1_addr -= BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
238 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
239 assert(inst1_found, "inst is not lis");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
240
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
241 uint xl = ((unsigned int) (get_imm(inst2_addr,0) & 0xffff));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
242 uint xh = (((((xl & 0x8000) != 0 ? -1 : 0) + get_imm(inst1_addr,0)) & 0xffff) << 16);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
243 return (int) (xl | xh);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
244 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
245 #endif // _LP64
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
246
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
247 void MacroAssembler::load_const_from_method_toc(Register dst, AddressLiteral& a, Register toc) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
248 int toc_offset = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
249 // Use RelocationHolder::none for the constant pool entry, otherwise
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
250 // we will end up with a failing NativeCall::verify(x) where x is
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
251 // the address of the constant pool entry.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
252 // FIXME: We should insert relocation information for oops at the constant
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
253 // pool entries instead of inserting it at the loads; patching of a constant
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
254 // pool entry should be less expensive.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
255 Unimplemented();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
256 if (false) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
257 address oop_address = address_constant((address)a.value(), RelocationHolder::none);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
258 // Relocate at the pc of the load.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
259 relocate(a.rspec());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
260 toc_offset = (int)(oop_address - code()->consts()->start());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
261 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
262 ld_largeoffset_unchecked(dst, toc_offset, toc, true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
263 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
264
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
265 bool MacroAssembler::is_load_const_from_method_toc_at(address a) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
266 const address inst1_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
267 const int inst1 = *(int *)inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
268
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
269 // The relocation points to the ld or the addis.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
270 return (is_ld(inst1)) ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
271 (is_addis(inst1) && inv_ra_field(inst1) != 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
272 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
273
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
274 int MacroAssembler::get_offset_of_load_const_from_method_toc_at(address a) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
275 assert(is_load_const_from_method_toc_at(a), "must be load_const_from_method_toc");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
276
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
277 const address inst1_addr = a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
278 const int inst1 = *(int *)inst1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
279
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
280 if (is_ld(inst1)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
281 return inv_d1_field(inst1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
282 } else if (is_addis(inst1)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
283 const int dst = inv_rt_field(inst1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
284
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
285 // Now, find the succeeding ld which reads and writes to dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
286 address inst2_addr = inst1_addr + BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
287 int inst2 = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
288 while (true) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
289 inst2 = *(int *) inst2_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
290 if (is_ld(inst2) && inv_ra_field(inst2) == dst && inv_rt_field(inst2) == dst) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
291 // Stop, found the ld which reads and writes dst.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
292 break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
293 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
294 inst2_addr += BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
295 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
296 return (inv_d1_field(inst1) << 16) + inv_d1_field(inst2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
297 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
298 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
299 return 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
300 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
301
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
302 // Get the constant from a `load_const' sequence.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
303 long MacroAssembler::get_const(address a) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
304 assert(is_load_const_at(a), "not a load of a constant");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
305 const int *p = (const int*) a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
306 unsigned long x = (((unsigned long) (get_imm(a,0) & 0xffff)) << 48);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
307 if (is_ori(*(p+1))) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
308 x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 32);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
309 x |= (((unsigned long) (get_imm(a,3) & 0xffff)) << 16);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
310 x |= (((unsigned long) (get_imm(a,4) & 0xffff)));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
311 } else if (is_lis(*(p+1))) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
312 x |= (((unsigned long) (get_imm(a,2) & 0xffff)) << 32);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
313 x |= (((unsigned long) (get_imm(a,1) & 0xffff)) << 16);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
314 x |= (((unsigned long) (get_imm(a,3) & 0xffff)));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
315 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
316 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
317 return (long) 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
318 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
319 return (long) x;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
320 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
321
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
322 // Patch the 64 bit constant of a `load_const' sequence. This is a low
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
323 // level procedure. It neither flushes the instruction cache nor is it
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
324 // mt safe.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
325 void MacroAssembler::patch_const(address a, long x) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
326 assert(is_load_const_at(a), "not a load of a constant");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
327 int *p = (int*) a;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
328 if (is_ori(*(p+1))) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
329 set_imm(0 + p, (x >> 48) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
330 set_imm(1 + p, (x >> 32) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
331 set_imm(3 + p, (x >> 16) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
332 set_imm(4 + p, x & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
333 } else if (is_lis(*(p+1))) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
334 set_imm(0 + p, (x >> 48) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
335 set_imm(2 + p, (x >> 32) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
336 set_imm(1 + p, (x >> 16) & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
337 set_imm(3 + p, x & 0xffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
338 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
339 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
340 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
341 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
342
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
343 AddressLiteral MacroAssembler::allocate_metadata_address(Metadata* obj) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
344 assert(oop_recorder() != NULL, "this assembler needs a Recorder");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
345 int index = oop_recorder()->allocate_metadata_index(obj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
346 RelocationHolder rspec = metadata_Relocation::spec(index);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
347 return AddressLiteral((address)obj, rspec);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
348 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
349
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
350 AddressLiteral MacroAssembler::constant_metadata_address(Metadata* obj) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
351 assert(oop_recorder() != NULL, "this assembler needs a Recorder");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
352 int index = oop_recorder()->find_index(obj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
353 RelocationHolder rspec = metadata_Relocation::spec(index);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
354 return AddressLiteral((address)obj, rspec);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
355 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
356
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
357 AddressLiteral MacroAssembler::allocate_oop_address(jobject obj) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
358 assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
359 int oop_index = oop_recorder()->allocate_oop_index(obj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
360 return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
361 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
362
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
363 AddressLiteral MacroAssembler::constant_oop_address(jobject obj) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
364 assert(oop_recorder() != NULL, "this assembler needs an OopRecorder");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
365 int oop_index = oop_recorder()->find_index(obj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
366 return AddressLiteral(address(obj), oop_Relocation::spec(oop_index));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
367 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
368
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
369 RegisterOrConstant MacroAssembler::delayed_value_impl(intptr_t* delayed_value_addr,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
370 Register tmp, int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
371 intptr_t value = *delayed_value_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
372 if (value != 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
373 return RegisterOrConstant(value + offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
374 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
375
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
376 // Load indirectly to solve generation ordering problem.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
377 // static address, no relocation
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
378 int simm16_offset = load_const_optimized(tmp, delayed_value_addr, noreg, true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
379 ld(tmp, simm16_offset, tmp); // must be aligned ((xa & 3) == 0)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
380
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
381 if (offset != 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
382 addi(tmp, tmp, offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
383 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
384
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
385 return RegisterOrConstant(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
386 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
387
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
388 #ifndef PRODUCT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
389 void MacroAssembler::pd_print_patched_instruction(address branch) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
390 Unimplemented(); // TODO: PPC port
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
391 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
392 #endif // ndef PRODUCT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
393
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
394 // Conditional far branch for destinations encodable in 24+2 bits.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
395 void MacroAssembler::bc_far(int boint, int biint, Label& dest, int optimize) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
396
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
397 // If requested by flag optimize, relocate the bc_far as a
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
398 // runtime_call and prepare for optimizing it when the code gets
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
399 // relocated.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
400 if (optimize == bc_far_optimize_on_relocate) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
401 relocate(relocInfo::runtime_call_type);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
402 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
403
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
404 // variant 2:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
405 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
406 // b!cxx SKIP
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
407 // bxx DEST
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
408 // SKIP:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
409 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
410
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
411 const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
412 opposite_bcond(inv_boint_bcond(boint)));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
413
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
414 // We emit two branches.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
415 // First, a conditional branch which jumps around the far branch.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
416 const address not_taken_pc = pc() + 2 * BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
417 const address bc_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
418 bc(opposite_boint, biint, not_taken_pc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
419
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
420 const int bc_instr = *(int*)bc_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
421 assert(not_taken_pc == (address)inv_bd_field(bc_instr, (intptr_t)bc_pc), "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
422 assert(opposite_boint == inv_bo_field(bc_instr), "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
423 assert(boint == add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(bc_instr))),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
424 opposite_bcond(inv_boint_bcond(inv_bo_field(bc_instr)))),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
425 "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
426 assert(biint == inv_bi_field(bc_instr), "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
427
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
428 // Second, an unconditional far branch which jumps to dest.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
429 // Note: target(dest) remembers the current pc (see CodeSection::target)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
430 // and returns the current pc if the label is not bound yet; when
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
431 // the label gets bound, the unconditional far branch will be patched.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
432 const address target_pc = target(dest);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
433 const address b_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
434 b(target_pc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
435
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
436 assert(not_taken_pc == pc(), "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
437 assert(dest.is_bound() || target_pc == b_pc, "postcondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
438 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
439
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
440 bool MacroAssembler::is_bc_far_at(address instruction_addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
441 return is_bc_far_variant1_at(instruction_addr) ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
442 is_bc_far_variant2_at(instruction_addr) ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
443 is_bc_far_variant3_at(instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
444 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
445
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
446 address MacroAssembler::get_dest_of_bc_far_at(address instruction_addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
447 if (is_bc_far_variant1_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
448 const address instruction_1_addr = instruction_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
449 const int instruction_1 = *(int*)instruction_1_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
450 return (address)inv_bd_field(instruction_1, (intptr_t)instruction_1_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
451 } else if (is_bc_far_variant2_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
452 const address instruction_2_addr = instruction_addr + 4;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
453 return bxx_destination(instruction_2_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
454 } else if (is_bc_far_variant3_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
455 return instruction_addr + 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
456 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
457 // variant 4 ???
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
458 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
459 return NULL;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
460 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
461 void MacroAssembler::set_dest_of_bc_far_at(address instruction_addr, address dest) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
462
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
463 if (is_bc_far_variant3_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
464 // variant 3, far cond branch to the next instruction, already patched to nops:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
465 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
466 // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
467 // endgroup
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
468 // SKIP/DEST:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
469 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
470 return;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
471 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
472
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
473 // first, extract boint and biint from the current branch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
474 int boint = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
475 int biint = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
476
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
477 ResourceMark rm;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
478 const int code_size = 2 * BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
479 CodeBuffer buf(instruction_addr, code_size);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
480 MacroAssembler masm(&buf);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
481 if (is_bc_far_variant2_at(instruction_addr) && dest == instruction_addr + 8) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
482 // Far branch to next instruction: Optimize it by patching nops (produce variant 3).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
483 masm.nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
484 masm.endgroup();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
485 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
486 if (is_bc_far_variant1_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
487 // variant 1, the 1st instruction contains the destination address:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
488 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
489 // bcxx DEST
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
490 // endgroup
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
491 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
492 const int instruction_1 = *(int*)(instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
493 boint = inv_bo_field(instruction_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
494 biint = inv_bi_field(instruction_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
495 } else if (is_bc_far_variant2_at(instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
496 // variant 2, the 2nd instruction contains the destination address:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
497 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
498 // b!cxx SKIP
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
499 // bxx DEST
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
500 // SKIP:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
501 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
502 const int instruction_1 = *(int*)(instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
503 boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(inv_bo_field(instruction_1))),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
504 opposite_bcond(inv_boint_bcond(inv_bo_field(instruction_1))));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
505 biint = inv_bi_field(instruction_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
506 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
507 // variant 4???
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
508 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
509 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
510
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
511 // second, set the new branch destination and optimize the code
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
512 if (dest != instruction_addr + 4 && // the bc_far is still unbound!
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
513 masm.is_within_range_of_bcxx(dest, instruction_addr)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
514 // variant 1:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
515 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
516 // bcxx DEST
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
517 // endgroup
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
518 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
519 masm.bc(boint, biint, dest);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
520 masm.endgroup();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
521 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
522 // variant 2:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
523 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
524 // b!cxx SKIP
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
525 // bxx DEST
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
526 // SKIP:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
527 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
528 const int opposite_boint = add_bhint_to_boint(opposite_bhint(inv_boint_bhint(boint)),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
529 opposite_bcond(inv_boint_bcond(boint)));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
530 const address not_taken_pc = masm.pc() + 2 * BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
531 masm.bc(opposite_boint, biint, not_taken_pc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
532 masm.b(dest);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
533 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
534 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
535 ICache::invalidate_range(instruction_addr, code_size);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
536 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
537
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
538 // Emit a NOT mt-safe patchable 64 bit absolute call/jump.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
539 void MacroAssembler::bxx64_patchable(address dest, relocInfo::relocType rt, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
540 // get current pc
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
541 uint64_t start_pc = (uint64_t) pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
542
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
543 const address pc_of_bl = (address) (start_pc + (6*BytesPerInstWord)); // bl is last
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
544 const address pc_of_b = (address) (start_pc + (0*BytesPerInstWord)); // b is first
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
545
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
546 // relocate here
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
547 if (rt != relocInfo::none) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
548 relocate(rt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
549 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
550
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
551 if ( ReoptimizeCallSequences &&
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
552 (( link && is_within_range_of_b(dest, pc_of_bl)) ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
553 (!link && is_within_range_of_b(dest, pc_of_b)))) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
554 // variant 2:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
555 // Emit an optimized, pc-relative call/jump.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
556
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
557 if (link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
558 // some padding
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
559 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
560 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
561 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
562 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
563 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
564 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
565
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
566 // do the call
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
567 assert(pc() == pc_of_bl, "just checking");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
568 bl(dest, relocInfo::none);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
569 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
570 // do the jump
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
571 assert(pc() == pc_of_b, "just checking");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
572 b(dest, relocInfo::none);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
573
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
574 // some padding
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
575 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
576 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
577 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
578 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
579 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
580 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
581 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
582
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
583 // Assert that we can identify the emitted call/jump.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
584 assert(is_bxx64_patchable_variant2_at((address)start_pc, link),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
585 "can't identify emitted call");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
586 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
587 // variant 1:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
588
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
589 mr(R0, R11); // spill R11 -> R0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
590
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
591 // Load the destination address into CTR,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
592 // calculate destination relative to global toc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
593 calculate_address_from_global_toc(R11, dest, true, true, false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
594
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
595 mtctr(R11);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
596 mr(R11, R0); // spill R11 <- R0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
597 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
598
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
599 // do the call/jump
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
600 if (link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
601 bctrl();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
602 } else{
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
603 bctr();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
604 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
605 // Assert that we can identify the emitted call/jump.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
606 assert(is_bxx64_patchable_variant1b_at((address)start_pc, link),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
607 "can't identify emitted call");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
608 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
609
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
610 // Assert that we can identify the emitted call/jump.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
611 assert(is_bxx64_patchable_at((address)start_pc, link),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
612 "can't identify emitted call");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
613 assert(get_dest_of_bxx64_patchable_at((address)start_pc, link) == dest,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
614 "wrong encoding of dest address");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
615 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
616
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
617 // Identify a bxx64_patchable instruction.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
618 bool MacroAssembler::is_bxx64_patchable_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
619 return is_bxx64_patchable_variant1b_at(instruction_addr, link)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
620 //|| is_bxx64_patchable_variant1_at(instruction_addr, link)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
621 || is_bxx64_patchable_variant2_at(instruction_addr, link);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
622 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
623
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
624 // Does the call64_patchable instruction use a pc-relative encoding of
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
625 // the call destination?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
626 bool MacroAssembler::is_bxx64_patchable_pcrelative_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
627 // variant 2 is pc-relative
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
628 return is_bxx64_patchable_variant2_at(instruction_addr, link);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
629 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
630
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
631 // Identify variant 1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
632 bool MacroAssembler::is_bxx64_patchable_variant1_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
633 unsigned int* instr = (unsigned int*) instruction_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
634 return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l]
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
635 && is_mtctr(instr[5]) // mtctr
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
636 && is_load_const_at(instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
637 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
638
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
639 // Identify variant 1b: load destination relative to global toc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
640 bool MacroAssembler::is_bxx64_patchable_variant1b_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
641 unsigned int* instr = (unsigned int*) instruction_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
642 return (link ? is_bctrl(instr[6]) : is_bctr(instr[6])) // bctr[l]
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
643 && is_mtctr(instr[3]) // mtctr
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
644 && is_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord, instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
645 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
646
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
647 // Identify variant 2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
648 bool MacroAssembler::is_bxx64_patchable_variant2_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
649 unsigned int* instr = (unsigned int*) instruction_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
650 if (link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
651 return is_bl (instr[6]) // bl dest is last
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
652 && is_nop(instr[0]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
653 && is_nop(instr[1]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
654 && is_nop(instr[2]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
655 && is_nop(instr[3]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
656 && is_nop(instr[4]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
657 && is_nop(instr[5]); // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
658 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
659 return is_b (instr[0]) // b dest is first
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
660 && is_nop(instr[1]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
661 && is_nop(instr[2]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
662 && is_nop(instr[3]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
663 && is_nop(instr[4]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
664 && is_nop(instr[5]) // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
665 && is_nop(instr[6]); // nop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
666 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
667 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
668
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
669 // Set dest address of a bxx64_patchable instruction.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
670 void MacroAssembler::set_dest_of_bxx64_patchable_at(address instruction_addr, address dest, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
671 ResourceMark rm;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
672 int code_size = MacroAssembler::bxx64_patchable_size;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
673 CodeBuffer buf(instruction_addr, code_size);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
674 MacroAssembler masm(&buf);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
675 masm.bxx64_patchable(dest, relocInfo::none, link);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
676 ICache::invalidate_range(instruction_addr, code_size);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
677 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
678
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
679 // Get dest address of a bxx64_patchable instruction.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
680 address MacroAssembler::get_dest_of_bxx64_patchable_at(address instruction_addr, bool link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
681 if (is_bxx64_patchable_variant1_at(instruction_addr, link)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
682 return (address) (unsigned long) get_const(instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
683 } else if (is_bxx64_patchable_variant2_at(instruction_addr, link)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
684 unsigned int* instr = (unsigned int*) instruction_addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
685 if (link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
686 const int instr_idx = 6; // bl is last
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
687 int branchoffset = branch_destination(instr[instr_idx], 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
688 return instruction_addr + branchoffset + instr_idx*BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
689 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
690 const int instr_idx = 0; // b is first
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
691 int branchoffset = branch_destination(instr[instr_idx], 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
692 return instruction_addr + branchoffset + instr_idx*BytesPerInstWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
693 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
694 // Load dest relative to global toc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
695 } else if (is_bxx64_patchable_variant1b_at(instruction_addr, link)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
696 return get_address_of_calculate_address_from_global_toc_at(instruction_addr + 2*BytesPerInstWord,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
697 instruction_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
698 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
699 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
700 return NULL;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
701 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
702 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
703
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
704 // Uses ordering which corresponds to ABI:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
705 // _savegpr0_14: std r14,-144(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
706 // _savegpr0_15: std r15,-136(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
707 // _savegpr0_16: std r16,-128(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
708 void MacroAssembler::save_nonvolatile_gprs(Register dst, int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
709 std(R14, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
710 std(R15, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
711 std(R16, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
712 std(R17, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
713 std(R18, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
714 std(R19, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
715 std(R20, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
716 std(R21, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
717 std(R22, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
718 std(R23, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
719 std(R24, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
720 std(R25, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
721 std(R26, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
722 std(R27, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
723 std(R28, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
724 std(R29, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
725 std(R30, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
726 std(R31, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
727
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
728 stfd(F14, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
729 stfd(F15, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
730 stfd(F16, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
731 stfd(F17, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
732 stfd(F18, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
733 stfd(F19, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
734 stfd(F20, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
735 stfd(F21, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
736 stfd(F22, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
737 stfd(F23, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
738 stfd(F24, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
739 stfd(F25, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
740 stfd(F26, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
741 stfd(F27, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
742 stfd(F28, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
743 stfd(F29, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
744 stfd(F30, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
745 stfd(F31, offset, dst);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
746 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
747
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
748 // Uses ordering which corresponds to ABI:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
749 // _restgpr0_14: ld r14,-144(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
750 // _restgpr0_15: ld r15,-136(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
751 // _restgpr0_16: ld r16,-128(r1)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
752 void MacroAssembler::restore_nonvolatile_gprs(Register src, int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
753 ld(R14, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
754 ld(R15, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
755 ld(R16, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
756 ld(R17, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
757 ld(R18, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
758 ld(R19, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
759 ld(R20, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
760 ld(R21, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
761 ld(R22, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
762 ld(R23, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
763 ld(R24, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
764 ld(R25, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
765 ld(R26, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
766 ld(R27, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
767 ld(R28, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
768 ld(R29, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
769 ld(R30, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
770 ld(R31, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
771
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
772 // FP registers
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
773 lfd(F14, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
774 lfd(F15, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
775 lfd(F16, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
776 lfd(F17, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
777 lfd(F18, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
778 lfd(F19, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
779 lfd(F20, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
780 lfd(F21, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
781 lfd(F22, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
782 lfd(F23, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
783 lfd(F24, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
784 lfd(F25, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
785 lfd(F26, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
786 lfd(F27, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
787 lfd(F28, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
788 lfd(F29, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
789 lfd(F30, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
790 lfd(F31, offset, src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
791 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
792
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
793 // For verify_oops.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
794 void MacroAssembler::save_volatile_gprs(Register dst, int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
795 std(R3, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
796 std(R4, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
797 std(R5, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
798 std(R6, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
799 std(R7, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
800 std(R8, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
801 std(R9, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
802 std(R10, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
803 std(R11, offset, dst); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
804 std(R12, offset, dst);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
805 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
806
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
807 // For verify_oops.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
808 void MacroAssembler::restore_volatile_gprs(Register src, int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
809 ld(R3, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
810 ld(R4, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
811 ld(R5, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
812 ld(R6, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
813 ld(R7, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
814 ld(R8, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
815 ld(R9, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
816 ld(R10, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
817 ld(R11, offset, src); offset += 8;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
818 ld(R12, offset, src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
819 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
820
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
821 void MacroAssembler::save_LR_CR(Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
822 mfcr(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
823 std(tmp, _abi(cr), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
824 mflr(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
825 std(tmp, _abi(lr), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
826 // Tmp must contain lr on exit! (see return_addr and prolog in ppc64.ad)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
827 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
828
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
829 void MacroAssembler::restore_LR_CR(Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
830 assert(tmp != R1_SP, "must be distinct");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
831 ld(tmp, _abi(lr), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
832 mtlr(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
833 ld(tmp, _abi(cr), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
834 mtcr(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
835 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
836
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
837 address MacroAssembler::get_PC_trash_LR(Register result) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
838 Label L;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
839 bl(L);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
840 bind(L);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
841 address lr_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
842 mflr(result);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
843 return lr_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
844 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
845
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
846 void MacroAssembler::resize_frame(Register offset, Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
847 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
848 assert_different_registers(offset, tmp, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
849 andi_(tmp, offset, frame::alignment_in_bytes-1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
850 asm_assert_eq("resize_frame: unaligned", 0x204);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
851 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
852
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
853 // tmp <- *(SP)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
854 ld(tmp, _abi(callers_sp), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
855 // addr <- SP + offset;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
856 // *(addr) <- tmp;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
857 // SP <- addr
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
858 stdux(tmp, R1_SP, offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
859 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
860
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
861 void MacroAssembler::resize_frame(int offset, Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
862 assert(is_simm(offset, 16), "too big an offset");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
863 assert_different_registers(tmp, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
864 assert((offset & (frame::alignment_in_bytes-1))==0, "resize_frame: unaligned");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
865 // tmp <- *(SP)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
866 ld(tmp, _abi(callers_sp), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
867 // addr <- SP + offset;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
868 // *(addr) <- tmp;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
869 // SP <- addr
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
870 stdu(tmp, offset, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
871 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
872
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
873 void MacroAssembler::resize_frame_absolute(Register addr, Register tmp1, Register tmp2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
874 // (addr == tmp1) || (addr == tmp2) is allowed here!
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
875 assert(tmp1 != tmp2, "must be distinct");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
876
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
877 // compute offset w.r.t. current stack pointer
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
878 // tmp_1 <- addr - SP (!)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
879 subf(tmp1, R1_SP, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
880
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
881 // atomically update SP keeping back link.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
882 resize_frame(tmp1/* offset */, tmp2/* tmp */);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
883 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
884
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
885 void MacroAssembler::push_frame(Register bytes, Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
886 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
887 assert(bytes != R0, "r0 not allowed here");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
888 andi_(R0, bytes, frame::alignment_in_bytes-1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
889 asm_assert_eq("push_frame(Reg, Reg): unaligned", 0x203);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
890 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
891 neg(tmp, bytes);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
892 stdux(R1_SP, R1_SP, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
893 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
894
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
895 // Push a frame of size `bytes'.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
896 void MacroAssembler::push_frame(unsigned int bytes, Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
897 long offset = align_addr(bytes, frame::alignment_in_bytes);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
898 if (is_simm(-offset, 16)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
899 stdu(R1_SP, -offset, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
900 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
901 load_const(tmp, -offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
902 stdux(R1_SP, R1_SP, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
903 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
904 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
905
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
906 // Push a frame of size `bytes' plus abi112 on top.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
907 void MacroAssembler::push_frame_abi112(unsigned int bytes, Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
908 push_frame(bytes + frame::abi_112_size, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
909 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
910
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
911 // Setup up a new C frame with a spill area for non-volatile GPRs and
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
912 // additional space for local variables.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
913 void MacroAssembler::push_frame_abi112_nonvolatiles(unsigned int bytes,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
914 Register tmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
915 push_frame(bytes + frame::abi_112_size + frame::spill_nonvolatiles_size, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
916 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
917
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
918 // Pop current C frame.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
919 void MacroAssembler::pop_frame() {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
920 ld(R1_SP, _abi(callers_sp), R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
921 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
922
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
923 // Generic version of a call to C function via a function descriptor
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
924 // with variable support for C calling conventions (TOC, ENV, etc.).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
925 // Updates and returns _last_calls_return_pc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
926 address MacroAssembler::branch_to(Register function_descriptor, bool and_link, bool save_toc_before_call,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
927 bool restore_toc_after_call, bool load_toc_of_callee, bool load_env_of_callee) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
928 // we emit standard ptrgl glue code here
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
929 assert((function_descriptor != R0), "function_descriptor cannot be R0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
930
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
931 // retrieve necessary entries from the function descriptor
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
932 ld(R0, in_bytes(FunctionDescriptor::entry_offset()), function_descriptor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
933 mtctr(R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
934
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
935 if (load_toc_of_callee) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
936 ld(R2_TOC, in_bytes(FunctionDescriptor::toc_offset()), function_descriptor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
937 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
938 if (load_env_of_callee) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
939 ld(R11, in_bytes(FunctionDescriptor::env_offset()), function_descriptor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
940 } else if (load_toc_of_callee) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
941 li(R11, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
942 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
943
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
944 // do a call or a branch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
945 if (and_link) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
946 bctrl();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
947 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
948 bctr();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
949 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
950 _last_calls_return_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
951
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
952 return _last_calls_return_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
953 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
954
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
955 // Call a C function via a function descriptor and use full C calling
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
956 // conventions.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
957 // We don't use the TOC in generated code, so there is no need to save
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
958 // and restore its value.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
959 address MacroAssembler::call_c(Register fd) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
960 return branch_to(fd, /*and_link=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
961 /*save toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
962 /*restore toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
963 /*load toc=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
964 /*load env=*/true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
965 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
966
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
967 address MacroAssembler::call_c(const FunctionDescriptor* fd, relocInfo::relocType rt) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
968 if (rt != relocInfo::none) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
969 // this call needs to be relocatable
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
970 if (!ReoptimizeCallSequences
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
971 || (rt != relocInfo::runtime_call_type && rt != relocInfo::none)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
972 || fd == NULL // support code-size estimation
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
973 || !fd->is_friend_function()
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
974 || fd->entry() == NULL) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
975 // it's not a friend function as defined by class FunctionDescriptor,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
976 // so do a full call-c here.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
977 load_const(R11, (address)fd, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
978
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
979 bool has_env = (fd != NULL && fd->env() != NULL);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
980 return branch_to(R11, /*and_link=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
981 /*save toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
982 /*restore toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
983 /*load toc=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
984 /*load env=*/has_env);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
985 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
986 // It's a friend function. Load the entry point and don't care about
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
987 // toc and env. Use an optimizable call instruction, but ensure the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
988 // same code-size as in the case of a non-friend function.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
989 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
990 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
991 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
992 bl64_patchable(fd->entry(), rt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
993 _last_calls_return_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
994 return _last_calls_return_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
995 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
996 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
997 // This call does not need to be relocatable, do more aggressive
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
998 // optimizations.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
999 if (!ReoptimizeCallSequences
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1000 || !fd->is_friend_function()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1001 // It's not a friend function as defined by class FunctionDescriptor,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1002 // so do a full call-c here.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1003 load_const(R11, (address)fd, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1004 return branch_to(R11, /*and_link=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1005 /*save toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1006 /*restore toc=*/false,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1007 /*load toc=*/true,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1008 /*load env=*/true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1009 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1010 // it's a friend function, load the entry point and don't care about
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1011 // toc and env.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1012 address dest = fd->entry();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1013 if (is_within_range_of_b(dest, pc())) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1014 bl(dest);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1015 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1016 bl64_patchable(dest, rt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1017 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1018 _last_calls_return_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1019 return _last_calls_return_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1020 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1021 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1022 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1023
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1024 // Call a C function. All constants needed reside in TOC.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1025 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1026 // Read the address to call from the TOC.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1027 // Read env from TOC, if fd specifies an env.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1028 // Read new TOC from TOC.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1029 address MacroAssembler::call_c_using_toc(const FunctionDescriptor* fd,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1030 relocInfo::relocType rt, Register toc) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1031 if (!ReoptimizeCallSequences
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1032 || (rt != relocInfo::runtime_call_type && rt != relocInfo::none)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1033 || !fd->is_friend_function()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1034 // It's not a friend function as defined by class FunctionDescriptor,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1035 // so do a full call-c here.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1036 assert(fd->entry() != NULL, "function must be linked");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1037
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1038 AddressLiteral fd_entry(fd->entry());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1039 load_const_from_method_toc(R11, fd_entry, toc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1040 mtctr(R11);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1041 if (fd->env() == NULL) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1042 li(R11, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1043 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1044 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1045 AddressLiteral fd_env(fd->env());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1046 load_const_from_method_toc(R11, fd_env, toc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1047 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1048 AddressLiteral fd_toc(fd->toc());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1049 load_toc_from_toc(R2_TOC, fd_toc, toc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1050 // R2_TOC is killed.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1051 bctrl();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1052 _last_calls_return_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1053 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1054 // It's a friend function, load the entry point and don't care about
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1055 // toc and env. Use an optimizable call instruction, but ensure the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1056 // same code-size as in the case of a non-friend function.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1057 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1058 bl64_patchable(fd->entry(), rt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1059 _last_calls_return_pc = pc();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1060 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1061 return _last_calls_return_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1062 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1063
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1064 void MacroAssembler::call_VM_base(Register oop_result,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1065 Register last_java_sp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1066 address entry_point,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1067 bool check_exceptions) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1068 BLOCK_COMMENT("call_VM {");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1069 // Determine last_java_sp register.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1070 if (!last_java_sp->is_valid()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1071 last_java_sp = R1_SP;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1072 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1073 set_top_ijava_frame_at_SP_as_last_Java_frame(last_java_sp, R11_scratch1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1074
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1075 // ARG1 must hold thread address.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1076 mr(R3_ARG1, R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1077
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1078 address return_pc = call_c((FunctionDescriptor*)entry_point, relocInfo::none);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1079
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1080 reset_last_Java_frame();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1081
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1082 // Check for pending exceptions.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1083 if (check_exceptions) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1084 // We don't check for exceptions here.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1085 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1086 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1087
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1088 // Get oop result if there is one and reset the value in the thread.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1089 if (oop_result->is_valid()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1090 get_vm_result(oop_result);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1091 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1092
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1093 _last_calls_return_pc = return_pc;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1094 BLOCK_COMMENT("} call_VM");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1095 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1096
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1097 void MacroAssembler::call_VM_leaf_base(address entry_point) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1098 BLOCK_COMMENT("call_VM_leaf {");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1099 call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, entry_point), relocInfo::none);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1100 BLOCK_COMMENT("} call_VM_leaf");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1101 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1102
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1103 void MacroAssembler::call_VM(Register oop_result, address entry_point, bool check_exceptions) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1104 call_VM_base(oop_result, noreg, entry_point, check_exceptions);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1105 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1106
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1107 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1108 bool check_exceptions) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1109 // R3_ARG1 is reserved for the thread.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1110 mr_if_needed(R4_ARG2, arg_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1111 call_VM(oop_result, entry_point, check_exceptions);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1112 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1113
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1114 void MacroAssembler::call_VM(Register oop_result, address entry_point, Register arg_1, Register arg_2,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1115 bool check_exceptions) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1116 // R3_ARG1 is reserved for the thread
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1117 mr_if_needed(R4_ARG2, arg_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1118 assert(arg_2 != R4_ARG2, "smashed argument");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1119 mr_if_needed(R5_ARG3, arg_2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1120 call_VM(oop_result, entry_point, check_exceptions);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1121 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1122
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1123 void MacroAssembler::call_VM_leaf(address entry_point) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1124 call_VM_leaf_base(entry_point);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1125 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1126
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1127 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1128 mr_if_needed(R3_ARG1, arg_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1129 call_VM_leaf(entry_point);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1130 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1131
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1132 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1133 mr_if_needed(R3_ARG1, arg_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1134 assert(arg_2 != R3_ARG1, "smashed argument");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1135 mr_if_needed(R4_ARG2, arg_2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1136 call_VM_leaf(entry_point);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1137 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1138
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1139 void MacroAssembler::call_VM_leaf(address entry_point, Register arg_1, Register arg_2, Register arg_3) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1140 mr_if_needed(R3_ARG1, arg_1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1141 assert(arg_2 != R3_ARG1, "smashed argument");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1142 mr_if_needed(R4_ARG2, arg_2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1143 assert(arg_3 != R3_ARG1 && arg_3 != R4_ARG2, "smashed argument");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1144 mr_if_needed(R5_ARG3, arg_3);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1145 call_VM_leaf(entry_point);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1146 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1147
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1148 // Check whether instruction is a read access to the polling page
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1149 // which was emitted by load_from_polling_page(..).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1150 bool MacroAssembler::is_load_from_polling_page(int instruction, void* ucontext,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1151 address* polling_address_ptr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1152 if (!is_ld(instruction))
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1153 return false; // It's not a ld. Fail.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1154
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1155 int rt = inv_rt_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1156 int ra = inv_ra_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1157 int ds = inv_ds_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1158 if (!(ds == 0 && ra != 0 && rt == 0)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1159 return false; // It's not a ld(r0, X, ra). Fail.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1160 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1161
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1162 if (!ucontext) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1163 // Set polling address.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1164 if (polling_address_ptr != NULL) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1165 *polling_address_ptr = NULL;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1166 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1167 return true; // No ucontext given. Can't check value of ra. Assume true.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1168 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1169
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1170 #ifdef LINUX
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1171 // Ucontext given. Check that register ra contains the address of
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1172 // the safepoing polling page.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1173 ucontext_t* uc = (ucontext_t*) ucontext;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1174 // Set polling address.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1175 address addr = (address)uc->uc_mcontext.regs->gpr[ra] + (ssize_t)ds;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1176 if (polling_address_ptr != NULL) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1177 *polling_address_ptr = addr;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1178 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1179 return os::is_poll_address(addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1180 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1181 // Not on Linux, ucontext must be NULL.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1182 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1183 return false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1184 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1185 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1186
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1187 bool MacroAssembler::is_memory_serialization(int instruction, JavaThread* thread, void* ucontext) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1188 #ifdef LINUX
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1189 ucontext_t* uc = (ucontext_t*) ucontext;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1190
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1191 if (is_stwx(instruction) || is_stwux(instruction)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1192 int ra = inv_ra_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1193 int rb = inv_rb_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1194
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1195 // look up content of ra and rb in ucontext
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1196 address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1197 long rb_val=(long)uc->uc_mcontext.regs->gpr[rb];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1198 return os::is_memory_serialize_page(thread, ra_val+rb_val);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1199 } else if (is_stw(instruction) || is_stwu(instruction)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1200 int ra = inv_ra_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1201 int d1 = inv_d1_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1202
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1203 // look up content of ra in ucontext
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1204 address ra_val=(address)uc->uc_mcontext.regs->gpr[ra];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1205 return os::is_memory_serialize_page(thread, ra_val+d1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1206 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1207 return false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1208 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1209 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1210 // workaround not needed on !LINUX :-)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1211 ShouldNotCallThis();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1212 return false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1213 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1214 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1215
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1216 void MacroAssembler::bang_stack_with_offset(int offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1217 // When increasing the stack, the old stack pointer will be written
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1218 // to the new top of stack according to the PPC64 abi.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1219 // Therefore, stack banging is not necessary when increasing
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1220 // the stack by <= os::vm_page_size() bytes.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1221 // When increasing the stack by a larger amount, this method is
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1222 // called repeatedly to bang the intermediate pages.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1223
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1224 // Stack grows down, caller passes positive offset.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1225 assert(offset > 0, "must bang with positive offset");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1226
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1227 long stdoffset = -offset;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1228
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1229 if (is_simm(stdoffset, 16)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1230 // Signed 16 bit offset, a simple std is ok.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1231 if (UseLoadInstructionsForStackBangingPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1232 ld(R0, (int)(signed short)stdoffset, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1233 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1234 std(R0,(int)(signed short)stdoffset, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1235 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1236 } else if (is_simm(stdoffset, 31)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1237 const int hi = MacroAssembler::largeoffset_si16_si16_hi(stdoffset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1238 const int lo = MacroAssembler::largeoffset_si16_si16_lo(stdoffset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1239
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1240 Register tmp = R11;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1241 addis(tmp, R1_SP, hi);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1242 if (UseLoadInstructionsForStackBangingPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1243 ld(R0, lo, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1244 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1245 std(R0, lo, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1246 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1247 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1248 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1249 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1250 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1251
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1252 // If instruction is a stack bang of the form
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1253 // std R0, x(Ry), (see bang_stack_with_offset())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1254 // stdu R1_SP, x(R1_SP), (see push_frame(), resize_frame())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1255 // or stdux R1_SP, Rx, R1_SP (see push_frame(), resize_frame())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1256 // return the banged address. Otherwise, return 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1257 address MacroAssembler::get_stack_bang_address(int instruction, void *ucontext) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1258 #ifdef LINUX
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1259 ucontext_t* uc = (ucontext_t*) ucontext;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1260 int rs = inv_rs_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1261 int ra = inv_ra_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1262 if ( (is_ld(instruction) && rs == 0 && UseLoadInstructionsForStackBangingPPC64)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1263 || (is_std(instruction) && rs == 0 && !UseLoadInstructionsForStackBangingPPC64)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1264 || (is_stdu(instruction) && rs == 1)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1265 int ds = inv_ds_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1266 // return banged address
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1267 return ds+(address)uc->uc_mcontext.regs->gpr[ra];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1268 } else if (is_stdux(instruction) && rs == 1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1269 int rb = inv_rb_field(instruction);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1270 address sp = (address)uc->uc_mcontext.regs->gpr[1];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1271 long rb_val = (long)uc->uc_mcontext.regs->gpr[rb];
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1272 return ra != 1 || rb_val >= 0 ? NULL // not a stack bang
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1273 : sp + rb_val; // banged address
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1274 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1275 return NULL; // not a stack bang
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1276 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1277 // workaround not needed on !LINUX :-)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1278 ShouldNotCallThis();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1279 return NULL;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1280 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1281 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1282
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1283 // CmpxchgX sets condition register to cmpX(current, compare).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1284 void MacroAssembler::cmpxchgw(ConditionRegister flag, Register dest_current_value,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1285 Register compare_value, Register exchange_value,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1286 Register addr_base, int semantics, bool cmpxchgx_hint,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1287 Register int_flag_success, bool contention_hint) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1288 Label retry;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1289 Label failed;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1290 Label done;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1291
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1292 // Save one branch if result is returned via register and
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1293 // result register is different from the other ones.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1294 bool use_result_reg = (int_flag_success != noreg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1295 bool preset_result_reg = (int_flag_success != dest_current_value && int_flag_success != compare_value &&
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1296 int_flag_success != exchange_value && int_flag_success != addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1297
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1298 // release/fence semantics
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1299 if (semantics & MemBarRel) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1300 release();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1301 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1302
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1303 if (use_result_reg && preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1304 li(int_flag_success, 0); // preset (assume cas failed)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1305 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1306
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1307 // Add simple guard in order to reduce risk of starving under high contention (recommended by IBM).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1308 if (contention_hint) { // Don't try to reserve if cmp fails.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1309 lwz(dest_current_value, 0, addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1310 cmpw(flag, dest_current_value, compare_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1311 bne(flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1312 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1313
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1314 // atomic emulation loop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1315 bind(retry);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1316
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1317 lwarx(dest_current_value, addr_base, cmpxchgx_hint);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1318 cmpw(flag, dest_current_value, compare_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1319 if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1320 bne_predict_not_taken(flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1321 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1322 bne( flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1323 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1324 // branch to done => (flag == ne), (dest_current_value != compare_value)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1325 // fall through => (flag == eq), (dest_current_value == compare_value)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1326
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1327 stwcx_(exchange_value, addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1328 if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1329 bne_predict_not_taken(CCR0, retry); // StXcx_ sets CCR0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1330 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1331 bne( CCR0, retry); // StXcx_ sets CCR0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1332 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1333 // fall through => (flag == eq), (dest_current_value == compare_value), (swapped)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1334
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1335 // Result in register (must do this at the end because int_flag_success can be the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1336 // same register as one above).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1337 if (use_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1338 li(int_flag_success, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1339 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1340
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1341 if (semantics & MemBarFenceAfter) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1342 fence();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1343 } else if (semantics & MemBarAcq) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1344 isync();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1345 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1346
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1347 if (use_result_reg && !preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1348 b(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1349 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1350
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1351 bind(failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1352 if (use_result_reg && !preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1353 li(int_flag_success, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1354 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1355
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1356 bind(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1357 // (flag == ne) => (dest_current_value != compare_value), (!swapped)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1358 // (flag == eq) => (dest_current_value == compare_value), ( swapped)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1359 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1360
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1361 // Preforms atomic compare exchange:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1362 // if (compare_value == *addr_base)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1363 // *addr_base = exchange_value
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1364 // int_flag_success = 1;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1365 // else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1366 // int_flag_success = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1367 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1368 // ConditionRegister flag = cmp(compare_value, *addr_base)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1369 // Register dest_current_value = *addr_base
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1370 // Register compare_value Used to compare with value in memory
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1371 // Register exchange_value Written to memory if compare_value == *addr_base
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1372 // Register addr_base The memory location to compareXChange
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1373 // Register int_flag_success Set to 1 if exchange_value was written to *addr_base
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1374 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1375 // To avoid the costly compare exchange the value is tested beforehand.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1376 // Several special cases exist to avoid that unnecessary information is generated.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1377 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1378 void MacroAssembler::cmpxchgd(ConditionRegister flag,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1379 Register dest_current_value, Register compare_value, Register exchange_value,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1380 Register addr_base, int semantics, bool cmpxchgx_hint,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1381 Register int_flag_success, Label* failed_ext, bool contention_hint) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1382 Label retry;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1383 Label failed_int;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1384 Label& failed = (failed_ext != NULL) ? *failed_ext : failed_int;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1385 Label done;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1386
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1387 // Save one branch if result is returned via register and result register is different from the other ones.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1388 bool use_result_reg = (int_flag_success!=noreg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1389 bool preset_result_reg = (int_flag_success!=dest_current_value && int_flag_success!=compare_value &&
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1390 int_flag_success!=exchange_value && int_flag_success!=addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1391 assert(int_flag_success == noreg || failed_ext == NULL, "cannot have both");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1392
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1393 // release/fence semantics
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1394 if (semantics & MemBarRel) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1395 release();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1396 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1397
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1398 if (use_result_reg && preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1399 li(int_flag_success, 0); // preset (assume cas failed)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1400 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1401
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1402 // Add simple guard in order to reduce risk of starving under high contention (recommended by IBM).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1403 if (contention_hint) { // Don't try to reserve if cmp fails.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1404 ld(dest_current_value, 0, addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1405 cmpd(flag, dest_current_value, compare_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1406 bne(flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1407 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1409 // atomic emulation loop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1410 bind(retry);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1411
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1412 ldarx(dest_current_value, addr_base, cmpxchgx_hint);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1413 cmpd(flag, dest_current_value, compare_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1414 if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1415 bne_predict_not_taken(flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1416 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1417 bne( flag, failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1418 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1419
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1420 stdcx_(exchange_value, addr_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1421 if (UseStaticBranchPredictionInCompareAndSwapPPC64) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1422 bne_predict_not_taken(CCR0, retry); // stXcx_ sets CCR0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1423 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1424 bne( CCR0, retry); // stXcx_ sets CCR0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1425 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1426
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1427 // result in register (must do this at the end because int_flag_success can be the same register as one above)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1428 if (use_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1429 li(int_flag_success, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1430 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1431
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1432 // POWER6 doesn't need isync in CAS.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1433 // Always emit isync to be on the safe side.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1434 if (semantics & MemBarFenceAfter) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1435 fence();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1436 } else if (semantics & MemBarAcq) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1437 isync();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1438 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1439
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1440 if (use_result_reg && !preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1441 b(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1442 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1443
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1444 bind(failed_int);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1445 if (use_result_reg && !preset_result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1446 li(int_flag_success, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1447 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1448
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1449 bind(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1450 // (flag == ne) => (dest_current_value != compare_value), (!swapped)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1451 // (flag == eq) => (dest_current_value == compare_value), ( swapped)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1452 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1453
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1454 // Look up the method for a megamorphic invokeinterface call.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1455 // The target method is determined by <intf_klass, itable_index>.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1456 // The receiver klass is in recv_klass.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1457 // On success, the result will be in method_result, and execution falls through.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1458 // On failure, execution transfers to the given label.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1459 void MacroAssembler::lookup_interface_method(Register recv_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1460 Register intf_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1461 RegisterOrConstant itable_index,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1462 Register method_result,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1463 Register scan_temp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1464 Register sethi_temp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1465 Label& L_no_such_interface) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1466 assert_different_registers(recv_klass, intf_klass, method_result, scan_temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1467 assert(itable_index.is_constant() || itable_index.as_register() == method_result,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1468 "caller must use same register for non-constant itable index as for method");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1469
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1470 // Compute start of first itableOffsetEntry (which is at the end of the vtable).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1471 int vtable_base = InstanceKlass::vtable_start_offset() * wordSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1472 int itentry_off = itableMethodEntry::method_offset_in_bytes();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1473 int logMEsize = exact_log2(itableMethodEntry::size() * wordSize);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1474 int scan_step = itableOffsetEntry::size() * wordSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1475 int log_vte_size= exact_log2(vtableEntry::size() * wordSize);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1476
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1477 lwz(scan_temp, InstanceKlass::vtable_length_offset() * wordSize, recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1478 // %%% We should store the aligned, prescaled offset in the klassoop.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1479 // Then the next several instructions would fold away.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1480
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1481 sldi(scan_temp, scan_temp, log_vte_size);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1482 addi(scan_temp, scan_temp, vtable_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1483 add(scan_temp, recv_klass, scan_temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1484
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1485 // Adjust recv_klass by scaled itable_index, so we can free itable_index.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1486 if (itable_index.is_register()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1487 Register itable_offset = itable_index.as_register();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1488 sldi(itable_offset, itable_offset, logMEsize);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1489 if (itentry_off) addi(itable_offset, itable_offset, itentry_off);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1490 add(recv_klass, itable_offset, recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1491 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1492 long itable_offset = (long)itable_index.as_constant();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1493 load_const_optimized(sethi_temp, (itable_offset<<logMEsize)+itentry_off); // static address, no relocation
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1494 add(recv_klass, sethi_temp, recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1495 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1496
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1497 // for (scan = klass->itable(); scan->interface() != NULL; scan += scan_step) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1498 // if (scan->interface() == intf) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1499 // result = (klass + scan->offset() + itable_index);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1500 // }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1501 // }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1502 Label search, found_method;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1503
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1504 for (int peel = 1; peel >= 0; peel--) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1505 // %%%% Could load both offset and interface in one ldx, if they were
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1506 // in the opposite order. This would save a load.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1507 ld(method_result, itableOffsetEntry::interface_offset_in_bytes(), scan_temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1508
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1509 // Check that this entry is non-null. A null entry means that
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1510 // the receiver class doesn't implement the interface, and wasn't the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1511 // same as when the caller was compiled.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1512 cmpd(CCR0, method_result, intf_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1513
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1514 if (peel) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1515 beq(CCR0, found_method);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1516 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1517 bne(CCR0, search);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1518 // (invert the test to fall through to found_method...)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1519 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1520
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1521 if (!peel) break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1522
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1523 bind(search);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1524
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1525 cmpdi(CCR0, method_result, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1526 beq(CCR0, L_no_such_interface);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1527 addi(scan_temp, scan_temp, scan_step);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1528 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1529
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1530 bind(found_method);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1531
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1532 // Got a hit.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1533 int ito_offset = itableOffsetEntry::offset_offset_in_bytes();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1534 lwz(scan_temp, ito_offset, scan_temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1535 ldx(method_result, scan_temp, recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1536 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1537
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1538 // virtual method calling
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1539 void MacroAssembler::lookup_virtual_method(Register recv_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1540 RegisterOrConstant vtable_index,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1541 Register method_result) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1542
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1543 assert_different_registers(recv_klass, method_result, vtable_index.register_or_noreg());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1544
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1545 const int base = InstanceKlass::vtable_start_offset() * wordSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1546 assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1547
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1548 if (vtable_index.is_register()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1549 sldi(vtable_index.as_register(), vtable_index.as_register(), LogBytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1550 add(recv_klass, vtable_index.as_register(), recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1551 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1552 addi(recv_klass, recv_klass, vtable_index.as_constant() << LogBytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1553 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1554 ld(R19_method, base + vtableEntry::method_offset_in_bytes(), recv_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1555 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1556
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1557 /////////////////////////////////////////// subtype checking ////////////////////////////////////////////
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1558
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1559 void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1560 Register super_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1561 Register temp1_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1562 Register temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1563 Label& L_success,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1564 Label& L_failure) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1565
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1566 const Register check_cache_offset = temp1_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1567 const Register cached_super = temp2_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1568
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1569 assert_different_registers(sub_klass, super_klass, check_cache_offset, cached_super);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1570
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1571 int sco_offset = in_bytes(Klass::super_check_offset_offset());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1572 int sc_offset = in_bytes(Klass::secondary_super_cache_offset());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1573
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1574 // If the pointers are equal, we are done (e.g., String[] elements).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1575 // This self-check enables sharing of secondary supertype arrays among
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1576 // non-primary types such as array-of-interface. Otherwise, each such
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1577 // type would need its own customized SSA.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1578 // We move this check to the front of the fast path because many
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1579 // type checks are in fact trivially successful in this manner,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1580 // so we get a nicely predicted branch right at the start of the check.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1581 cmpd(CCR0, sub_klass, super_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1582 beq(CCR0, L_success);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1583
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1584 // Check the supertype display:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1585 lwz(check_cache_offset, sco_offset, super_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1586 // The loaded value is the offset from KlassOopDesc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1587
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1588 ldx(cached_super, check_cache_offset, sub_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1589 cmpd(CCR0, cached_super, super_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1590 beq(CCR0, L_success);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1591
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1592 // This check has worked decisively for primary supers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1593 // Secondary supers are sought in the super_cache ('super_cache_addr').
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1594 // (Secondary supers are interfaces and very deeply nested subtypes.)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1595 // This works in the same check above because of a tricky aliasing
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1596 // between the super_cache and the primary super display elements.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1597 // (The 'super_check_addr' can address either, as the case requires.)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1598 // Note that the cache is updated below if it does not help us find
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1599 // what we need immediately.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1600 // So if it was a primary super, we can just fail immediately.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1601 // Otherwise, it's the slow path for us (no success at this point).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1602
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1603 cmpwi(CCR0, check_cache_offset, sc_offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1604 bne(CCR0, L_failure);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1605 // bind(slow_path); // fallthru
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1606 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1607
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1608 void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1609 Register super_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1610 Register temp1_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1611 Register temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1612 Label* L_success,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1613 Register result_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1614 const Register array_ptr = temp1_reg; // current value from cache array
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1615 const Register temp = temp2_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1616
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1617 assert_different_registers(sub_klass, super_klass, array_ptr, temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1618
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1619 int source_offset = in_bytes(Klass::secondary_supers_offset());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1620 int target_offset = in_bytes(Klass::secondary_super_cache_offset());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1621
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1622 int length_offset = Array<Klass*>::length_offset_in_bytes();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1623 int base_offset = Array<Klass*>::base_offset_in_bytes();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1624
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1625 Label hit, loop, failure, fallthru;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1626
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1627 ld(array_ptr, source_offset, sub_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1628
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1629 //assert(4 == arrayOopDesc::length_length_in_bytes(), "precondition violated.");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1630 lwz(temp, length_offset, array_ptr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1631 cmpwi(CCR0, temp, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1632 beq(CCR0, result_reg!=noreg ? failure : fallthru); // length 0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1633
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1634 mtctr(temp); // load ctr
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1635
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1636 bind(loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1637 // Oops in table are NO MORE compressed.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1638 ld(temp, base_offset, array_ptr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1639 cmpd(CCR0, temp, super_klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1640 beq(CCR0, hit);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1641 addi(array_ptr, array_ptr, BytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1642 bdnz(loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1643
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1644 bind(failure);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1645 if (result_reg!=noreg) li(result_reg, 1); // load non-zero result (indicates a miss)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1646 b(fallthru);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1647
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1648 bind(hit);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1649 std(super_klass, target_offset, sub_klass); // save result to cache
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1650 if (result_reg != noreg) li(result_reg, 0); // load zero result (indicates a hit)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1651 if (L_success != NULL) b(*L_success);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1652
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1653 bind(fallthru);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1654 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1655
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1656 // Try fast path, then go to slow one if not successful
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1657 void MacroAssembler::check_klass_subtype(Register sub_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1658 Register super_klass,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1659 Register temp1_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1660 Register temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1661 Label& L_success) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1662 Label L_failure;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1663 check_klass_subtype_fast_path(sub_klass, super_klass, temp1_reg, temp2_reg, L_success, L_failure);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1664 check_klass_subtype_slow_path(sub_klass, super_klass, temp1_reg, temp2_reg, &L_success);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1665 bind(L_failure); // Fallthru if not successful.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1666 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1667
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1668 void MacroAssembler::check_method_handle_type(Register mtype_reg, Register mh_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1669 Register temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1670 Label& wrong_method_type) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1671 assert_different_registers(mtype_reg, mh_reg, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1672 // Compare method type against that of the receiver.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1673 load_heap_oop_not_null(temp_reg, delayed_value(java_lang_invoke_MethodHandle::type_offset_in_bytes, temp_reg), mh_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1674 cmpd(CCR0, temp_reg, mtype_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1675 bne(CCR0, wrong_method_type);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1676 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1677
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1678 RegisterOrConstant MacroAssembler::argument_offset(RegisterOrConstant arg_slot,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1679 Register temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1680 int extra_slot_offset) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1681 // cf. TemplateTable::prepare_invoke(), if (load_receiver).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1682 int stackElementSize = Interpreter::stackElementSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1683 int offset = extra_slot_offset * stackElementSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1684 if (arg_slot.is_constant()) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1685 offset += arg_slot.as_constant() * stackElementSize;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1686 return offset;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1687 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1688 assert(temp_reg != noreg, "must specify");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1689 sldi(temp_reg, arg_slot.as_register(), exact_log2(stackElementSize));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1690 if (offset != 0)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1691 addi(temp_reg, temp_reg, offset);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1692 return temp_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1693 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1694 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1695
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1696 void MacroAssembler::biased_locking_enter(ConditionRegister cr_reg, Register obj_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1697 Register mark_reg, Register temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1698 Register temp2_reg, Label& done, Label* slow_case) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1699 assert(UseBiasedLocking, "why call this otherwise?");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1700
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1701 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1702 assert_different_registers(obj_reg, mark_reg, temp_reg, temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1703 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1704
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1705 Label cas_label;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1706
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1707 // Branch to done if fast path fails and no slow_case provided.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1708 Label *slow_case_int = (slow_case != NULL) ? slow_case : &done;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1709
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1710 // Biased locking
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1711 // See whether the lock is currently biased toward our thread and
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1712 // whether the epoch is still valid
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1713 // Note that the runtime guarantees sufficient alignment of JavaThread
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1714 // pointers to allow age to be placed into low bits
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1715 assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1716 "biased locking makes assumptions about bit layout");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1717
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1718 if (PrintBiasedLockingStatistics) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1719 load_const(temp_reg, (address) BiasedLocking::total_entry_count_addr(), temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1720 lwz(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1721 addi(temp2_reg, temp2_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1722 stw(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1723 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1724
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1725 andi(temp_reg, mark_reg, markOopDesc::biased_lock_mask_in_place);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1726 cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1727 bne(cr_reg, cas_label);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1728
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1729 load_klass_with_trap_null_check(temp_reg, obj_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1730
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1731 load_const_optimized(temp2_reg, ~((int) markOopDesc::age_mask_in_place));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1732 ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1733 orr(temp_reg, R16_thread, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1734 xorr(temp_reg, mark_reg, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1735 andr(temp_reg, temp_reg, temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1736 cmpdi(cr_reg, temp_reg, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1737 if (PrintBiasedLockingStatistics) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1738 Label l;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1739 bne(cr_reg, l);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1740 load_const(mark_reg, (address) BiasedLocking::biased_lock_entry_count_addr());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1741 lwz(temp2_reg, 0, mark_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1742 addi(temp2_reg, temp2_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1743 stw(temp2_reg, 0, mark_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1744 // restore mark_reg
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1745 ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1746 bind(l);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1747 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1748 beq(cr_reg, done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1749
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1750 Label try_revoke_bias;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1751 Label try_rebias;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1752
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1753 // At this point we know that the header has the bias pattern and
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1754 // that we are not the bias owner in the current epoch. We need to
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1755 // figure out more details about the state of the header in order to
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1756 // know what operations can be legally performed on the object's
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1757 // header.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1758
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1759 // If the low three bits in the xor result aren't clear, that means
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1760 // the prototype header is no longer biased and we have to revoke
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1761 // the bias on this object.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1762 andi(temp2_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1763 cmpwi(cr_reg, temp2_reg, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1764 bne(cr_reg, try_revoke_bias);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1765
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1766 // Biasing is still enabled for this data type. See whether the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1767 // epoch of the current bias is still valid, meaning that the epoch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1768 // bits of the mark word are equal to the epoch bits of the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1769 // prototype header. (Note that the prototype header's epoch bits
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1770 // only change at a safepoint.) If not, attempt to rebias the object
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1771 // toward the current thread. Note that we must be absolutely sure
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1772 // that the current epoch is invalid in order to do this because
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1773 // otherwise the manipulations it performs on the mark word are
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1774 // illegal.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1775
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1776 int shift_amount = 64 - markOopDesc::epoch_shift;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1777 // rotate epoch bits to right (little) end and set other bits to 0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1778 // [ big part | epoch | little part ] -> [ 0..0 | epoch ]
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1779 rldicl_(temp2_reg, temp_reg, shift_amount, 64 - markOopDesc::epoch_bits);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1780 // branch if epoch bits are != 0, i.e. they differ, because the epoch has been incremented
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1781 bne(CCR0, try_rebias);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1782
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1783 // The epoch of the current bias is still valid but we know nothing
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1784 // about the owner; it might be set or it might be clear. Try to
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1785 // acquire the bias of the object using an atomic operation. If this
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1786 // fails we will go in to the runtime to revoke the object's bias.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1787 // Note that we first construct the presumed unbiased header so we
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1788 // don't accidentally blow away another thread's valid bias.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1789 andi(mark_reg, mark_reg, (markOopDesc::biased_lock_mask_in_place |
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1790 markOopDesc::age_mask_in_place |
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1791 markOopDesc::epoch_mask_in_place));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1792 orr(temp_reg, R16_thread, mark_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1793
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1794 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1795
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1796 // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1797 fence(); // TODO: replace by MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq ?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1798 cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1799 /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1800 /*where=*/obj_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1801 MacroAssembler::MemBarAcq,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1802 MacroAssembler::cmpxchgx_hint_acquire_lock(),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1803 noreg, slow_case_int); // bail out if failed
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1804
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1805 // If the biasing toward our thread failed, this means that
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1806 // another thread succeeded in biasing it toward itself and we
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1807 // need to revoke that bias. The revocation will occur in the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1808 // interpreter runtime in the slow case.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1809 if (PrintBiasedLockingStatistics) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1810 load_const(temp_reg, (address) BiasedLocking::anonymously_biased_lock_entry_count_addr(), temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1811 lwz(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1812 addi(temp2_reg, temp2_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1813 stw(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1814 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1815 b(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1816
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1817 bind(try_rebias);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1818 // At this point we know the epoch has expired, meaning that the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1819 // current "bias owner", if any, is actually invalid. Under these
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1820 // circumstances _only_, we are allowed to use the current header's
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1821 // value as the comparison value when doing the cas to acquire the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1822 // bias in the current epoch. In other words, we allow transfer of
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1823 // the bias from one thread to another directly in this situation.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1824 andi(temp_reg, mark_reg, markOopDesc::age_mask_in_place);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1825 orr(temp_reg, R16_thread, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1826 load_klass_with_trap_null_check(temp2_reg, obj_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1827 ld(temp2_reg, in_bytes(Klass::prototype_header_offset()), temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1828 orr(temp_reg, temp_reg, temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1829
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1830 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1831
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1832 // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1833 fence(); // TODO: replace by MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq ?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1834 cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1835 /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1836 /*where=*/obj_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1837 MacroAssembler::MemBarAcq,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1838 MacroAssembler::cmpxchgx_hint_acquire_lock(),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1839 noreg, slow_case_int); // bail out if failed
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1840
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1841 // If the biasing toward our thread failed, this means that
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1842 // another thread succeeded in biasing it toward itself and we
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1843 // need to revoke that bias. The revocation will occur in the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1844 // interpreter runtime in the slow case.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1845 if (PrintBiasedLockingStatistics) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1846 load_const(temp_reg, (address) BiasedLocking::rebiased_lock_entry_count_addr(), temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1847 lwz(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1848 addi(temp2_reg, temp2_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1849 stw(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1850 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1851 b(done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1852
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1853 bind(try_revoke_bias);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1854 // The prototype mark in the klass doesn't have the bias bit set any
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1855 // more, indicating that objects of this data type are not supposed
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1856 // to be biased any more. We are going to try to reset the mark of
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1857 // this object to the prototype value and fall through to the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1858 // CAS-based locking scheme. Note that if our CAS fails, it means
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1859 // that another thread raced us for the privilege of revoking the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1860 // bias of this particular object, so it's okay to continue in the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1861 // normal locking code.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1862 load_klass_with_trap_null_check(temp_reg, obj_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1863 ld(temp_reg, in_bytes(Klass::prototype_header_offset()), temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1864 andi(temp2_reg, mark_reg, markOopDesc::age_mask_in_place);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1865 orr(temp_reg, temp_reg, temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1866
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1867 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1868
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1869 // CmpxchgX sets cr_reg to cmpX(temp2_reg, mark_reg).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1870 fence(); // TODO: replace by MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq ?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1871 cmpxchgd(/*flag=*/cr_reg, /*current_value=*/temp2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1872 /*compare_value=*/mark_reg, /*exchange_value=*/temp_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1873 /*where=*/obj_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1874 MacroAssembler::MemBarAcq,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1875 MacroAssembler::cmpxchgx_hint_acquire_lock());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1876
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1877 // reload markOop in mark_reg before continuing with lightweight locking
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1878 ld(mark_reg, oopDesc::mark_offset_in_bytes(), obj_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1879
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1880 // Fall through to the normal CAS-based lock, because no matter what
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1881 // the result of the above CAS, some thread must have succeeded in
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1882 // removing the bias bit from the object's header.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1883 if (PrintBiasedLockingStatistics) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1884 Label l;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1885 bne(cr_reg, l);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1886 load_const(temp_reg, (address) BiasedLocking::revoked_lock_entry_count_addr(), temp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1887 lwz(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1888 addi(temp2_reg, temp2_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1889 stw(temp2_reg, 0, temp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1890 bind(l);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1891 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1892
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1893 bind(cas_label);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1894 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1895
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1896 void MacroAssembler::biased_locking_exit (ConditionRegister cr_reg, Register mark_addr, Register temp_reg, Label& done) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1897 // Check for biased locking unlock case, which is a no-op
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1898 // Note: we do not have to check the thread ID for two reasons.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1899 // First, the interpreter checks for IllegalMonitorStateException at
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1900 // a higher level. Second, if the bias was revoked while we held the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1901 // lock, the object could not be rebiased toward another thread, so
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1902 // the bias bit would be clear.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1903
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1904 ld(temp_reg, 0, mark_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1905 andi(temp_reg, temp_reg, markOopDesc::biased_lock_mask_in_place);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1906
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1907 cmpwi(cr_reg, temp_reg, markOopDesc::biased_lock_pattern);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1908 beq(cr_reg, done);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1909 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1910
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1911 // "The box" is the space on the stack where we copy the object mark.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1912 void MacroAssembler::compiler_fast_lock_object(ConditionRegister flag, Register oop, Register box,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1913 Register temp, Register displaced_header, Register current_header) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1914 assert_different_registers(oop, box, temp, displaced_header, current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1915 assert(flag != CCR0, "bad condition register");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1916 Label cont;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1917 Label object_has_monitor;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1918 Label cas_failed;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1919
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1920 // Load markOop from object into displaced_header.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1921 ld(displaced_header, oopDesc::mark_offset_in_bytes(), oop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1922
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1923
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1924 // Always do locking in runtime.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1925 if (EmitSync & 0x01) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1926 cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1927 return;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1928 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1929
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1930 if (UseBiasedLocking) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1931 biased_locking_enter(flag, oop, displaced_header, temp, current_header, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1932 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1933
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1934 // Handle existing monitor.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1935 if ((EmitSync & 0x02) == 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1936 // The object has an existing monitor iff (mark & monitor_value) != 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1937 andi_(temp, displaced_header, markOopDesc::monitor_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1938 bne(CCR0, object_has_monitor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1939 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1940
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1941 // Set displaced_header to be (markOop of object | UNLOCK_VALUE).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1942 ori(displaced_header, displaced_header, markOopDesc::unlocked_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1943
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1944 // Load Compare Value application register.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1945
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1946 // Initialize the box. (Must happen before we update the object mark!)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1947 std(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1948
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1949 // Must fence, otherwise, preceding store(s) may float below cmpxchg.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1950 // Compare object markOop with mark and if equal exchange scratch1 with object markOop.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1951 // CmpxchgX sets cr_reg to cmpX(current, displaced).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1952 cmpxchgd(/*flag=*/flag,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1953 /*current_value=*/current_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1954 /*compare_value=*/displaced_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1955 /*exchange_value=*/box,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1956 /*where=*/oop,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1957 MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1958 MacroAssembler::cmpxchgx_hint_acquire_lock(),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1959 noreg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1960 &cas_failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1961 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1962
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1963 // If the compare-and-exchange succeeded, then we found an unlocked
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1964 // object and we have now locked it.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1965 b(cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1966
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1967 bind(cas_failed);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1968 // We did not see an unlocked object so try the fast recursive case.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1969
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1970 // Check if the owner is self by comparing the value in the markOop of object
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1971 // (current_header) with the stack pointer.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1972 sub(current_header, current_header, R1_SP);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1973 load_const_optimized(temp, (address) (~(os::vm_page_size()-1) |
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1974 markOopDesc::lock_mask_in_place));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1975
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1976 and_(R0/*==0?*/, current_header, temp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1977 // If condition is true we are cont and hence we can store 0 as the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1978 // displaced header in the box, which indicates that it is a recursive lock.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1979 mcrf(flag,CCR0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1980 std(R0/*==0, perhaps*/, BasicLock::displaced_header_offset_in_bytes(), box);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1981
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1982 // Handle existing monitor.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1983 if ((EmitSync & 0x02) == 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1984 b(cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1985
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1986 bind(object_has_monitor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1987 // The object's monitor m is unlocked iff m->owner == NULL,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1988 // otherwise m->owner may contain a thread or a stack address.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1989 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1990 // Try to CAS m->owner from NULL to current thread.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1991 addi(temp, displaced_header, ObjectMonitor::owner_offset_in_bytes()-markOopDesc::monitor_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1992 li(displaced_header, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1993 // CmpxchgX sets flag to cmpX(current, displaced).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1994 cmpxchgd(/*flag=*/flag,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1995 /*current_value=*/current_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1996 /*compare_value=*/displaced_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1997 /*exchange_value=*/R16_thread,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1998 /*where=*/temp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
1999 MacroAssembler::MemBarRel | MacroAssembler::MemBarAcq,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2000 MacroAssembler::cmpxchgx_hint_acquire_lock());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2001
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2002 // Store a non-null value into the box.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2003 std(box, BasicLock::displaced_header_offset_in_bytes(), box);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2004
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2005 # ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2006 bne(flag, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2007 // We have acquired the monitor, check some invariants.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2008 addi(/*monitor=*/temp, temp, -ObjectMonitor::owner_offset_in_bytes());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2009 // Invariant 1: _recursions should be 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2010 //assert(ObjectMonitor::recursions_size_in_bytes() == 8, "unexpected size");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2011 asm_assert_mem8_is_zero(ObjectMonitor::recursions_offset_in_bytes(), temp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2012 "monitor->_recursions should be 0", -1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2013 // Invariant 2: OwnerIsThread shouldn't be 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2014 //assert(ObjectMonitor::OwnerIsThread_size_in_bytes() == 4, "unexpected size");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2015 //asm_assert_mem4_isnot_zero(ObjectMonitor::OwnerIsThread_offset_in_bytes(), temp,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2016 // "monitor->OwnerIsThread shouldn't be 0", -1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2017 # endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2018 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2019
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2020 bind(cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2021 // flag == EQ indicates success
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2022 // flag == NE indicates failure
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2023 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2024
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2025 void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Register oop, Register box,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2026 Register temp, Register displaced_header, Register current_header) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2027 assert_different_registers(oop, box, temp, displaced_header, current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2028 assert(flag != CCR0, "bad condition register");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2029 Label cont;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2030 Label object_has_monitor;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2031
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2032 // Always do locking in runtime.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2033 if (EmitSync & 0x01) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2034 cmpdi(flag, oop, 0); // Oop can't be 0 here => always false.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2035 return;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2036 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2037
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2038 if (UseBiasedLocking) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2039 biased_locking_exit(flag, oop, current_header, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2040 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2041
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2042 // Find the lock address and load the displaced header from the stack.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2043 ld(displaced_header, BasicLock::displaced_header_offset_in_bytes(), box);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2044
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2045 // If the displaced header is 0, we have a recursive unlock.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2046 cmpdi(flag, displaced_header, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2047 beq(flag, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2048
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2049 // Handle existing monitor.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2050 if ((EmitSync & 0x02) == 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2051 // The object has an existing monitor iff (mark & monitor_value) != 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2052 ld(current_header, oopDesc::mark_offset_in_bytes(), oop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2053 andi(temp, current_header, markOopDesc::monitor_value);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2054 cmpdi(flag, temp, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2055 bne(flag, object_has_monitor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2056 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2057
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2058
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2059 // Check if it is still a light weight lock, this is is true if we see
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2060 // the stack address of the basicLock in the markOop of the object.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2061 // Cmpxchg sets flag to cmpd(current_header, box).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2062 cmpxchgd(/*flag=*/flag,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2063 /*current_value=*/current_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2064 /*compare_value=*/box,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2065 /*exchange_value=*/displaced_header,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2066 /*where=*/oop,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2067 MacroAssembler::MemBarRel,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2068 MacroAssembler::cmpxchgx_hint_release_lock(),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2069 noreg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2070 &cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2071
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2072 assert(oopDesc::mark_offset_in_bytes() == 0, "offset of _mark is not 0");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2073
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2074 // Handle existing monitor.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2075 if ((EmitSync & 0x02) == 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2076 b(cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2077
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2078 bind(object_has_monitor);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2079 addi(current_header, current_header, -markOopDesc::monitor_value); // monitor
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2080 ld(temp, ObjectMonitor::owner_offset_in_bytes(), current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2081 ld(displaced_header, ObjectMonitor::recursions_offset_in_bytes(), current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2082 xorr(temp, R16_thread, temp); // Will be 0 if we are the owner.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2083 orr(temp, temp, displaced_header); // Will be 0 if there are 0 recursions.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2084 cmpdi(flag, temp, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2085 bne(flag, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2086
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2087 ld(temp, ObjectMonitor::EntryList_offset_in_bytes(), current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2088 ld(displaced_header, ObjectMonitor::cxq_offset_in_bytes(), current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2089 orr(temp, temp, displaced_header); // Will be 0 if both are 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2090 cmpdi(flag, temp, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2091 bne(flag, cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2092 release();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2093 std(temp, ObjectMonitor::owner_offset_in_bytes(), current_header);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2094 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2095
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2096 bind(cont);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2097 // flag == EQ indicates success
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2098 // flag == NE indicates failure
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2099 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2100
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2101 // Write serialization page so VM thread can do a pseudo remote membar.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2102 // We use the current thread pointer to calculate a thread specific
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2103 // offset to write to within the page. This minimizes bus traffic
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2104 // due to cache line collision.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2105 void MacroAssembler::serialize_memory(Register thread, Register tmp1, Register tmp2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2106 srdi(tmp2, thread, os::get_serialize_page_shift_count());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2107
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2108 int mask = os::vm_page_size() - sizeof(int);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2109 if (Assembler::is_simm(mask, 16)) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2110 andi(tmp2, tmp2, mask);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2111 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2112 lis(tmp1, (int)((signed short) (mask >> 16)));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2113 ori(tmp1, tmp1, mask & 0x0000ffff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2114 andr(tmp2, tmp2, tmp1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2115 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2116
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2117 load_const(tmp1, (long) os::get_memory_serialize_page());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2118 release();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2119 stwx(R0, tmp1, tmp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2120 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2121
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2122
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2123 // GC barrier helper macros
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2124
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2125 // Write the card table byte if needed.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2126 void MacroAssembler::card_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2127 CardTableModRefBS* bs = (CardTableModRefBS*) Universe::heap()->barrier_set();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2128 assert(bs->kind() == BarrierSet::CardTableModRef ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2129 bs->kind() == BarrierSet::CardTableExtension, "wrong barrier");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2130 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2131 cmpdi(CCR0, Rnew_val, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2132 asm_assert_ne("null oop not allowed", 0x321);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2133 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2134 card_table_write(bs->byte_map_base, Rtmp, Rstore_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2135 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2136
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2137 // Write the card table byte.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2138 void MacroAssembler::card_table_write(jbyte* byte_map_base, Register Rtmp, Register Robj) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2139 assert_different_registers(Robj, Rtmp, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2140 load_const_optimized(Rtmp, (address)byte_map_base, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2141 srdi(Robj, Robj, CardTableModRefBS::card_shift);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2142 li(R0, 0); // dirty
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2143 if (UseConcMarkSweepGC) release();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2144 stbx(R0, Rtmp, Robj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2145 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2146
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2147 #ifndef SERIALGC
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2148
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2149 // General G1 pre-barrier generator.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2150 // Goal: record the previous value if it is not null.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2151 void MacroAssembler::g1_write_barrier_pre(Register Robj, RegisterOrConstant offset, Register Rpre_val,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2152 Register Rtmp1, Register Rtmp2, bool needs_frame) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2153 Label runtime, filtered;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2154
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2155 // Is marking active?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2156 if (in_bytes(PtrQueue::byte_width_of_active()) == 4) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2157 lwz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_active()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2158 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2159 guarantee(in_bytes(PtrQueue::byte_width_of_active()) == 1, "Assumption");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2160 lbz(Rtmp1, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_active()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2161 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2162 cmpdi(CCR0, Rtmp1, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2163 beq(CCR0, filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2164
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2165 // Do we need to load the previous value?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2166 if (Robj != noreg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2167 // Load the previous value...
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2168 if (UseCompressedOops) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2169 lwz(Rpre_val, offset, Robj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2170 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2171 ld(Rpre_val, offset, Robj);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2172 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2173 // Previous value has been loaded into Rpre_val.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2174 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2175 assert(Rpre_val != noreg, "must have a real register");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2176
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2177 // Is the previous value null?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2178 cmpdi(CCR0, Rpre_val, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2179 beq(CCR0, filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2180
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2181 if (Robj != noreg && UseCompressedOops) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2182 decode_heap_oop_not_null(Rpre_val);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2183 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2184
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2185 // OK, it's not filtered, so we'll need to call enqueue. In the normal
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2186 // case, pre_val will be a scratch G-reg, but there are some cases in
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2187 // which it's an O-reg. In the first case, do a normal call. In the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2188 // latter, do a save here and call the frameless version.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2189
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2190 // Can we store original value in the thread's buffer?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2191 // Is index == 0?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2192 // (The index field is typed as size_t.)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2193 const Register Rbuffer = Rtmp1, Rindex = Rtmp2;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2194
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2195 ld(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_index()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2196 cmpdi(CCR0, Rindex, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2197 beq(CCR0, runtime); // If index == 0, goto runtime.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2198 ld(Rbuffer, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_buf()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2199
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2200 addi(Rindex, Rindex, -wordSize); // Decrement index.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2201 std(Rindex, in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_index()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2202
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2203 // Record the previous value.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2204 stdx(Rpre_val, Rbuffer, Rindex);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2205 b(filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2206
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2207 bind(runtime);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2208
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2209 // VM call need frame to access(write) O register.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2210 if (needs_frame) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2211 save_LR_CR(Rtmp1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2212 push_frame_abi112(0, Rtmp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2213 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2214
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2215 if (Rpre_val->is_volatile() && Robj == noreg) mr(R31, Rpre_val); // Save pre_val across C call if it was preloaded.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2216 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), Rpre_val, R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2217 if (Rpre_val->is_volatile() && Robj == noreg) mr(Rpre_val, R31); // restore
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2218
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2219 if (needs_frame) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2220 pop_frame();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2221 restore_LR_CR(Rtmp1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2222 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2223
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2224 bind(filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2225 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2226
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2227 // General G1 post-barrier generator
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2228 // Store cross-region card.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2229 void MacroAssembler::g1_write_barrier_post(Register Rstore_addr, Register Rnew_val, Register Rtmp1, Register Rtmp2, Register Rtmp3, Label *filtered_ext) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2230 Label runtime, filtered_int;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2231 Label& filtered = (filtered_ext != NULL) ? *filtered_ext : filtered_int;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2232 assert_different_registers(Rstore_addr, Rnew_val, Rtmp1, Rtmp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2233
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2234 G1SATBCardTableModRefBS* bs = (G1SATBCardTableModRefBS*) Universe::heap()->barrier_set();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2235 assert(bs->kind() == BarrierSet::G1SATBCT ||
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2236 bs->kind() == BarrierSet::G1SATBCTLogging, "wrong barrier");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2237
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2238 // Does store cross heap regions?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2239 if (G1RSBarrierRegionFilter) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2240 xorr(Rtmp1, Rstore_addr, Rnew_val);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2241 srdi_(Rtmp1, Rtmp1, HeapRegion::LogOfHRGrainBytes);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2242 beq(CCR0, filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2243 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2244
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2245 // Crosses regions, storing NULL?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2246 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2247 cmpdi(CCR0, Rnew_val, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2248 asm_assert_ne("null oop not allowed (G1)", 0x322); // Checked by caller on PPC64, so following branch is obsolete:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2249 //beq(CCR0, filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2250 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2251
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2252 // Storing region crossing non-NULL, is card already dirty?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2253 assert(sizeof(*bs->byte_map_base) == sizeof(jbyte), "adjust this code");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2254 const Register Rcard_addr = Rtmp1;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2255 Register Rbase = Rtmp2;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2256 load_const_optimized(Rbase, (address)bs->byte_map_base, /*temp*/ Rtmp3);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2257
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2258 srdi(Rcard_addr, Rstore_addr, CardTableModRefBS::card_shift);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2259
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2260 // Get the address of the card.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2261 lbzx(/*card value*/ Rtmp3, Rbase, Rcard_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2262
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2263 assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2264 cmpwi(CCR0, Rtmp3 /* card value */, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2265 beq(CCR0, filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2266
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2267 // Storing a region crossing, non-NULL oop, card is clean.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2268 // Dirty card and log.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2269 li(Rtmp3, 0); // dirty
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2270 //release(); // G1: oops are allowed to get visible after dirty marking.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2271 stbx(Rtmp3, Rbase, Rcard_addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2272
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2273 add(Rcard_addr, Rbase, Rcard_addr); // This is the address which needs to get enqueued.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2274 Rbase = noreg; // end of lifetime
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2275
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2276 const Register Rqueue_index = Rtmp2,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2277 Rqueue_buf = Rtmp3;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2278 ld(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_index()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2279 cmpdi(CCR0, Rqueue_index, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2280 beq(CCR0, runtime); // index == 0 then jump to runtime
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2281 ld(Rqueue_buf, in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_buf()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2282
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2283 addi(Rqueue_index, Rqueue_index, -wordSize); // decrement index
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2284 std(Rqueue_index, in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_index()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2285
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2286 stdx(Rcard_addr, Rqueue_buf, Rqueue_index); // store card
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2287 b(filtered);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2288
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2289 bind(runtime);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2290
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2291 // Save the live input values.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2292 call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_post), Rcard_addr, R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2293
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2294 bind(filtered_int);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2295 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2296 #endif // SERIALGC
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2297
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2298 // Values for last_Java_pc, and last_Java_sp must comply to the rules
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2299 // in frame_ppc64.hpp.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2300 void MacroAssembler::set_last_Java_frame(Register last_Java_sp, Register last_Java_pc) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2301 // Always set last_Java_pc and flags first because once last_Java_sp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2302 // is visible has_last_Java_frame is true and users will look at the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2303 // rest of the fields. (Note: flags should always be zero before we
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2304 // get here so doesn't need to be set.)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2305
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2306 // Verify that last_Java_pc was zeroed on return to Java
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2307 asm_assert_mem8_is_zero(in_bytes(JavaThread::last_Java_pc_offset()), R16_thread,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2308 "last_Java_pc not zeroed before leaving Java", 0x200);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2309
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2310 // When returning from calling out from Java mode the frame anchor's
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2311 // last_Java_pc will always be set to NULL. It is set here so that
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2312 // if we are doing a call to native (not VM) that we capture the
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2313 // known pc and don't have to rely on the native call having a
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2314 // standard frame linkage where we can find the pc.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2315 if (last_Java_pc != noreg)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2316 std(last_Java_pc, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2317
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2318 // set last_Java_sp last
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2319 std(last_Java_sp, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2320 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2321
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2322 void MacroAssembler::reset_last_Java_frame(void) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2323 asm_assert_mem8_isnot_zero(in_bytes(JavaThread::last_Java_sp_offset()),
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2324 R16_thread, "SP was not set, still zero", 0x202);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2325
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2326 BLOCK_COMMENT("reset_last_Java_frame {");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2327 li(R0, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2328
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2329 // _last_Java_sp = 0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2330 std(R0, in_bytes(JavaThread::last_Java_sp_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2331
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2332 // _last_Java_pc = 0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2333 std(R0, in_bytes(JavaThread::last_Java_pc_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2334 BLOCK_COMMENT("} reset_last_Java_frame");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2335 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2336
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2337 void MacroAssembler::set_top_ijava_frame_at_SP_as_last_Java_frame(Register sp, Register tmp1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2338 assert_different_registers(sp, tmp1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2339
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2340 // sp points to a TOP_IJAVA_FRAME, retrieve frame's PC via
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2341 // TOP_IJAVA_FRAME_ABI.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2342 // FIXME: assert that we really have a TOP_IJAVA_FRAME here!
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2343 #ifdef CC_INTERP
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2344 ld(tmp1/*pc*/, _top_ijava_frame_abi(frame_manager_lr), sp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2345 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2346 Unimplemented();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2347 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2348
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2349 set_last_Java_frame(/*sp=*/sp, /*pc=*/tmp1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2350 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2351
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2352 void MacroAssembler::get_vm_result(Register oop_result) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2353 // Read:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2354 // R16_thread
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2355 // R16_thread->in_bytes(JavaThread::vm_result_offset())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2356 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2357 // Updated:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2358 // oop_result
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2359 // R16_thread->in_bytes(JavaThread::vm_result_offset())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2360
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2361 ld(oop_result, in_bytes(JavaThread::vm_result_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2362 li(R0, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2363 std(R0, in_bytes(JavaThread::vm_result_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2364
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2365 verify_oop(oop_result);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2366 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2367
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2368 void MacroAssembler::get_vm_result_2(Register metadata_result) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2369 // Read:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2370 // R16_thread
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2371 // R16_thread->in_bytes(JavaThread::vm_result_2_offset())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2372 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2373 // Updated:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2374 // metadata_result
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2375 // R16_thread->in_bytes(JavaThread::vm_result_2_offset())
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2376
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2377 ld(metadata_result, in_bytes(JavaThread::vm_result_2_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2378 li(R0, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2379 std(R0, in_bytes(JavaThread::vm_result_2_offset()), R16_thread);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2380 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2381
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2382
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2383 void MacroAssembler::encode_klass_not_null(Register dst, Register src) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2384 if (src == noreg) src = dst;
14413
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2385 assert(Universe::narrow_klass_base() != NULL, "Base should be initialized");
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2386 load_const(R0, Universe::narrow_klass_base());
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2387 sub(dst, src, R0);
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2388 if (Universe::narrow_klass_shift() != 0) {
14408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2389 srdi(dst, src, Universe::narrow_klass_shift());
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2390 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2391 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2392
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2393 void MacroAssembler::store_klass(Register dst_oop, Register klass, Register ck) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2394 if (UseCompressedKlassPointers) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2395 encode_klass_not_null(ck, klass);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2396 stw(ck, oopDesc::klass_offset_in_bytes(), dst_oop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2397 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2398 std(klass, oopDesc::klass_offset_in_bytes(), dst_oop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2399 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2400 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2401
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2402 void MacroAssembler::decode_klass_not_null(Register dst, Register src) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2403 if (src == noreg) src = dst;
14413
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2404 Register shifted_src = src;
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2405 assert(Universe::narrow_klass_base() != NULL, "Base should be initialized");
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2406 if (Universe::narrow_klass_shift() != 0) {
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2407 shifted_src = dst;
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2408 sldi(shifted_src, src, Universe::narrow_klass_shift());
14408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2409 }
14413
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2410 load_const(R0, Universe::narrow_klass_base());
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2411 add(dst, shifted_src, R0);
14408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2412 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2413
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2414 void MacroAssembler::load_klass(Register dst, Register src) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2415 if (UseCompressedKlassPointers) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2416 lwz(dst, oopDesc::klass_offset_in_bytes(), src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2417 // Attention: no null check here!
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2418 decode_klass_not_null(dst, dst);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2419 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2420 ld(dst, oopDesc::klass_offset_in_bytes(), src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2421 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2422 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2423
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2424 void MacroAssembler::load_klass_with_trap_null_check(Register dst, Register src) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2425 if (false NOT_LINUX(|| true) /*!os::zero_page_read_protected()*/) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2426 if (TrapBasedNullChecks) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2427 trap_null_check(src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2428 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2429 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2430 load_klass(dst, src);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2431 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2432
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2433 void MacroAssembler::reinit_heapbase(Register d, Register tmp) {
14413
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2434 if (Universe::heap() != NULL) {
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2435 if (Universe::narrow_oop_base() == NULL) {
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2436 Assembler::xorr(R30, R30, R30);
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2437 } else {
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2438 load_const(R30, Universe::narrow_ptrs_base(), tmp);
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2439 }
7687c56b6693 8024379: Adapt PPC64 port to 8003424
goetz
parents: 14408
diff changeset
2440 } else {
14408
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2441 load_const(R30, Universe::narrow_ptrs_base_addr(), tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2442 ld(R30, 0, R30);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2443 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2444 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2445
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2446 /////////////////////////////////////////// String intrinsics ////////////////////////////////////////////
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2447
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2448 // Search for a single jchar in an jchar[].
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2449 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2450 // Assumes that result differs from all other registers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2451 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2452 // Haystack, needle are the addresses of jchar-arrays.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2453 // NeedleChar is needle[0] if it is known at compile time.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2454 // Haycnt is the length of the haystack. We assume haycnt >=1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2455 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2456 // Preserves haystack, haycnt, kills all other registers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2457 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2458 // If needle == R0, we search for the constant needleChar.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2459 void MacroAssembler::string_indexof_1(Register result, Register haystack, Register haycnt,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2460 Register needle, jchar needleChar,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2461 Register tmp1, Register tmp2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2462
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2463 assert_different_registers(result, haystack, haycnt, needle, tmp1, tmp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2464
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2465 Label L_InnerLoop, L_FinalCheck, L_Found1, L_Found2, L_Found3, L_NotFound, L_End;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2466 Register needle0 = needle, // Contains needle[0].
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2467 addr = tmp1,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2468 ch1 = tmp2,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2469 ch2 = R0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2470
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2471 //2 (variable) or 3 (const):
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2472 if (needle != R0) lhz(needle0, 0, needle); // Preload needle character, needle has len==1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2473 dcbtct(haystack, 0x00); // Indicate R/O access to haystack.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2474
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2475 srwi_(tmp2, haycnt, 1); // Shift right by exact_log2(UNROLL_FACTOR).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2476 mr(addr, haystack);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2477 beq(CCR0, L_FinalCheck);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2478 mtctr(tmp2); // Move to count register.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2479 //8:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2480 bind(L_InnerLoop); // Main work horse (2x unrolled search loop).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2481 lhz(ch1, 0, addr); // Load characters from haystack.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2482 lhz(ch2, 2, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2483 (needle != R0) ? cmpw(CCR0, ch1, needle0) : cmplwi(CCR0, ch1, needleChar);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2484 (needle != R0) ? cmpw(CCR1, ch2, needle0) : cmplwi(CCR1, ch2, needleChar);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2485 beq(CCR0, L_Found1); // Did we find the needle?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2486 beq(CCR1, L_Found2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2487 addi(addr, addr, 4);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2488 bdnz(L_InnerLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2489 //16:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2490 bind(L_FinalCheck);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2491 andi_(R0, haycnt, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2492 beq(CCR0, L_NotFound);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2493 lhz(ch1, 0, addr); // One position left at which we have to compare.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2494 (needle != R0) ? cmpw(CCR1, ch1, needle0) : cmplwi(CCR1, ch1, needleChar);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2495 beq(CCR1, L_Found3);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2496 //21:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2497 bind(L_NotFound);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2498 li(result, -1); // Not found.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2499 b(L_End);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2500
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2501 bind(L_Found2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2502 addi(addr, addr, 2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2503 //24:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2504 bind(L_Found1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2505 bind(L_Found3); // Return index ...
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2506 subf(addr, haystack, addr); // relative to haystack,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2507 srdi(result, addr, 1); // in characters.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2508 bind(L_End);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2509 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2510
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2511
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2512 // Implementation of IndexOf for jchar arrays.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2513 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2514 // The length of haystack and needle are not constant, i.e. passed in a register.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2515 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2516 // Preserves registers haystack, needle.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2517 // Kills registers haycnt, needlecnt.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2518 // Assumes that result differs from all other registers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2519 // Haystack, needle are the addresses of jchar-arrays.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2520 // Haycnt, needlecnt are the lengths of them, respectively.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2521 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2522 // Needlecntval must be zero or 15-bit unsigned immediate and > 1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2523 void MacroAssembler::string_indexof(Register result, Register haystack, Register haycnt,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2524 Register needle, ciTypeArray* needle_values, Register needlecnt, int needlecntval,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2525 Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2526
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2527 // Ensure 0<needlecnt<=haycnt in ideal graph as prerequisite!
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2528 Label L_TooShort, L_Found, L_NotFound, L_End;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2529 Register last_addr = haycnt, // Kill haycnt at the beginning.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2530 addr = tmp1,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2531 n_start = tmp2,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2532 ch1 = tmp3,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2533 ch2 = R0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2534
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2535 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2536 // Prepare for main loop: optimized for needle count >=2, bail out otherwise.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2537 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2538
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2539 //1 (variable) or 3 (const):
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2540 dcbtct(needle, 0x00); // Indicate R/O access to str1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2541 dcbtct(haystack, 0x00); // Indicate R/O access to str2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2542
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2543 // Compute last haystack addr to use if no match gets found.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2544 if (needlecntval == 0) { // variable needlecnt
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2545 //3:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2546 subf(ch1, needlecnt, haycnt); // Last character index to compare is haycnt-needlecnt.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2547 addi(addr, haystack, -2); // Accesses use pre-increment.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2548 cmpwi(CCR6, needlecnt, 2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2549 blt(CCR6, L_TooShort); // Variable needlecnt: handle short needle separately.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2550 slwi(ch1, ch1, 1); // Scale to number of bytes.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2551 lwz(n_start, 0, needle); // Load first 2 characters of needle.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2552 add(last_addr, haystack, ch1); // Point to last address to compare (haystack+2*(haycnt-needlecnt)).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2553 addi(needlecnt, needlecnt, -2); // Rest of needle.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2554 } else { // constant needlecnt
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2555 guarantee(needlecntval != 1, "IndexOf with single-character needle must be handled separately");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2556 assert((needlecntval & 0x7fff) == needlecntval, "wrong immediate");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2557 //5:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2558 addi(ch1, haycnt, -needlecntval); // Last character index to compare is haycnt-needlecnt.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2559 lwz(n_start, 0, needle); // Load first 2 characters of needle.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2560 addi(addr, haystack, -2); // Accesses use pre-increment.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2561 slwi(ch1, ch1, 1); // Scale to number of bytes.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2562 add(last_addr, haystack, ch1); // Point to last address to compare (haystack+2*(haycnt-needlecnt)).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2563 li(needlecnt, needlecntval-2); // Rest of needle.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2564 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2565
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2566 // Main Loop (now we have at least 3 characters).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2567 //11:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2568 Label L_OuterLoop, L_InnerLoop, L_FinalCheck, L_Comp1, L_Comp2, L_Comp3;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2569 bind(L_OuterLoop); // Search for 1st 2 characters.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2570 Register addr_diff = tmp4;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2571 subf(addr_diff, addr, last_addr); // Difference between already checked address and last address to check.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2572 addi(addr, addr, 2); // This is the new address we want to use for comparing.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2573 srdi_(ch2, addr_diff, 2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2574 beq(CCR0, L_FinalCheck); // 2 characters left?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2575 mtctr(ch2); // addr_diff/4
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2576 //16:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2577 bind(L_InnerLoop); // Main work horse (2x unrolled search loop)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2578 lwz(ch1, 0, addr); // Load 2 characters of haystack (ignore alignment).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2579 lwz(ch2, 2, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2580 cmpw(CCR0, ch1, n_start); // Compare 2 characters (1 would be sufficient but try to reduce branches to CompLoop).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2581 cmpw(CCR1, ch2, n_start);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2582 beq(CCR0, L_Comp1); // Did we find the needle start?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2583 beq(CCR1, L_Comp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2584 addi(addr, addr, 4);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2585 bdnz(L_InnerLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2586 //24:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2587 bind(L_FinalCheck);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2588 rldicl_(addr_diff, addr_diff, 64-1, 63); // Remaining characters not covered by InnerLoop: (addr_diff>>1)&1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2589 beq(CCR0, L_NotFound);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2590 lwz(ch1, 0, addr); // One position left at which we have to compare.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2591 cmpw(CCR1, ch1, n_start);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2592 beq(CCR1, L_Comp3);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2593 //29:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2594 bind(L_NotFound);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2595 li(result, -1); // not found
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2596 b(L_End);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2597
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2598
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2599 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2600 // Special Case: unfortunately, the variable needle case can be called with needlecnt<2
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2601 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2602 //31:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2603 if ((needlecntval>>1) !=1 ) { // Const needlecnt is 2 or 3? Reduce code size.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2604 int nopcnt = 5;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2605 if (needlecntval !=0 ) ++nopcnt; // Balance alignment (other case: see below).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2606 if (needlecntval == 0) { // We have to handle these cases separately.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2607 Label L_OneCharLoop;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2608 bind(L_TooShort);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2609 mtctr(haycnt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2610 lhz(n_start, 0, needle); // First character of needle
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2611 bind(L_OneCharLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2612 lhzu(ch1, 2, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2613 cmpw(CCR1, ch1, n_start);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2614 beq(CCR1, L_Found); // Did we find the one character needle?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2615 bdnz(L_OneCharLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2616 li(result, -1); // Not found.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2617 b(L_End);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2618 } // 8 instructions, so no impact on alignment.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2619 for (int x = 0; x < nopcnt; ++x) nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2620 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2621
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2622 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2623 // Regular Case Part II: compare rest of needle (first 2 characters have been compared already)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2624 // **************************************************************************************************
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2625
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2626 // Compare the rest
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2627 //36 if needlecntval==0, else 37:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2628 bind(L_Comp2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2629 addi(addr, addr, 2); // First comparison has failed, 2nd one hit.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2630 bind(L_Comp1); // Addr points to possible needle start.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2631 bind(L_Comp3); // Could have created a copy and use a different return address but saving code size here.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2632 if (needlecntval != 2) { // Const needlecnt==2?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2633 if (needlecntval != 3) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2634 if (needlecntval == 0) beq(CCR6, L_Found); // Variable needlecnt==2?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2635 Register ind_reg = tmp4;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2636 li(ind_reg, 2*2); // First 2 characters are already compared, use index 2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2637 mtctr(needlecnt); // Decremented by 2, still > 0.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2638 //40:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2639 Label L_CompLoop;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2640 bind(L_CompLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2641 lhzx(ch2, needle, ind_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2642 lhzx(ch1, addr, ind_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2643 cmpw(CCR1, ch1, ch2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2644 bne(CCR1, L_OuterLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2645 addi(ind_reg, ind_reg, 2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2646 bdnz(L_CompLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2647 } else { // No loop required if there's only one needle character left.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2648 lhz(ch2, 2*2, needle);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2649 lhz(ch1, 2*2, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2650 cmpw(CCR1, ch1, ch2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2651 bne(CCR1, L_OuterLoop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2652 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2653 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2654 // Return index ...
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2655 //46:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2656 bind(L_Found);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2657 subf(addr, haystack, addr); // relative to haystack, ...
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2658 srdi(result, addr, 1); // in characters.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2659 //48:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2660 bind(L_End);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2661 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2662
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2663 // Implementation of Compare for jchar arrays.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2664 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2665 // Kills the registers str1, str2, cnt1, cnt2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2666 // Kills cr0, ctr.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2667 // Assumes that result differes from the input registers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2668 void MacroAssembler::string_compare(Register str1_reg, Register str2_reg, Register cnt1_reg, Register cnt2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2669 Register result_reg, Register tmp_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2670 assert_different_registers(result_reg, str1_reg, str2_reg, cnt1_reg, cnt2_reg, tmp_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2671
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2672 Label Ldone, Lslow_case, Lslow_loop, Lfast_loop;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2673 Register cnt_diff = R0,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2674 limit_reg = cnt1_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2675 chr1_reg = result_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2676 chr2_reg = cnt2_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2677 addr_diff = str2_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2678
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2679 // Offset 0 should be 32 byte aligned.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2680 //-4:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2681 dcbtct(str1_reg, 0x00); // Indicate R/O access to str1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2682 dcbtct(str2_reg, 0x00); // Indicate R/O access to str2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2683 //-2:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2684 // Compute min(cnt1, cnt2) and check if 0 (bail out if we don't need to compare characters).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2685 subf(result_reg, cnt2_reg, cnt1_reg); // difference between cnt1/2
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2686 subf_(addr_diff, str1_reg, str2_reg); // alias?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2687 beq(CCR0, Ldone); // return cnt difference if both ones are identical
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2688 srawi(limit_reg, result_reg, 31); // generate signmask (cnt1/2 must be non-negative so cnt_diff can't overflow)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2689 mr(cnt_diff, result_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2690 andr(limit_reg, result_reg, limit_reg); // difference or zero (negative): cnt1<cnt2 ? cnt1-cnt2 : 0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2691 add_(limit_reg, cnt2_reg, limit_reg); // min(cnt1, cnt2)==0?
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2692 beq(CCR0, Ldone); // return cnt difference if one has 0 length
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2693
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2694 lhz(chr1_reg, 0, str1_reg); // optional: early out if first characters mismatch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2695 lhzx(chr2_reg, str1_reg, addr_diff); // optional: early out if first characters mismatch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2696 addi(tmp_reg, limit_reg, -1); // min(cnt1, cnt2)-1
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2697 subf_(result_reg, chr2_reg, chr1_reg); // optional: early out if first characters mismatch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2698 bne(CCR0, Ldone); // optional: early out if first characters mismatch
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2699
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2700 // Set loop counter by scaling down tmp_reg
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2701 srawi_(chr2_reg, tmp_reg, exact_log2(4)); // (min(cnt1, cnt2)-1)/4
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2702 ble(CCR0, Lslow_case); // need >4 characters for fast loop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2703 andi(limit_reg, tmp_reg, 4-1); // remaining characters
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2704
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2705 // Adapt str1_reg str2_reg for the first loop iteration
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2706 mtctr(chr2_reg); // (min(cnt1, cnt2)-1)/4
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2707 addi(limit_reg, limit_reg, 4+1); // compare last 5-8 characters in slow_case if mismatch found in fast_loop
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2708 //16:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2709 // Compare the rest of the characters
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2710 bind(Lfast_loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2711 ld(chr1_reg, 0, str1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2712 ldx(chr2_reg, str1_reg, addr_diff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2713 cmpd(CCR0, chr2_reg, chr1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2714 bne(CCR0, Lslow_case); // return chr1_reg
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2715 addi(str1_reg, str1_reg, 4*2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2716 bdnz(Lfast_loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2717 addi(limit_reg, limit_reg, -4); // no mismatch found in fast_loop, only 1-4 characters missing
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2718 //23:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2719 bind(Lslow_case);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2720 mtctr(limit_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2721 //24:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2722 bind(Lslow_loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2723 lhz(chr1_reg, 0, str1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2724 lhzx(chr2_reg, str1_reg, addr_diff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2725 subf_(result_reg, chr2_reg, chr1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2726 bne(CCR0, Ldone); // return chr1_reg
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2727 addi(str1_reg, str1_reg, 1*2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2728 bdnz(Lslow_loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2729 //30:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2730 // If strings are equal up to min length, return the length difference.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2731 mr(result_reg, cnt_diff);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2732 nop(); // alignment
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2733 //32:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2734 // Otherwise, return the difference between the first mismatched chars.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2735 bind(Ldone);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2736 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2737
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2738
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2739 // Compare char[] arrays.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2740 //
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2741 // str1_reg USE only
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2742 // str2_reg USE only
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2743 // cnt_reg USE_DEF, due to tmp reg shortage
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2744 // result_reg DEF only, might compromise USE only registers
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2745 void MacroAssembler::char_arrays_equals(Register str1_reg, Register str2_reg, Register cnt_reg, Register result_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2746 Register tmp1_reg, Register tmp2_reg, Register tmp3_reg, Register tmp4_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2747 Register tmp5_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2748
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2749 // Str1 may be the same register as str2 which can occur e.g. after scalar replacement.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2750 assert_different_registers(result_reg, str1_reg, cnt_reg, tmp1_reg, tmp2_reg, tmp3_reg, tmp4_reg, tmp5_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2751 assert_different_registers(result_reg, str2_reg, cnt_reg, tmp1_reg, tmp2_reg, tmp3_reg, tmp4_reg, tmp5_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2752
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2753 // Offset 0 should be 32 byte aligned.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2754 Label Linit_cbc, Lcbc, Lloop, Ldone_true, Ldone_false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2755 Register index_reg = tmp5_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2756 Register cbc_iter = tmp4_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2757
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2758 //-1:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2759 dcbtct(str1_reg, 0x00); // Indicate R/O access to str1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2760 dcbtct(str2_reg, 0x00); // Indicate R/O access to str2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2761 //1:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2762 andi(cbc_iter, cnt_reg, 4-1); // Remaining iterations after 4 java characters per iteration loop.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2763 li(index_reg, 0); // init
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2764 li(result_reg, 0); // assume false
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2765 srwi_(tmp2_reg, cnt_reg, exact_log2(4)); // Div: 4 java characters per iteration (main loop).
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2766
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2767 cmpwi(CCR1, cbc_iter, 0); // CCR1 = (cbc_iter==0)
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2768 beq(CCR0, Linit_cbc); // too short
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2769 mtctr(tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2770 //8:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2771 bind(Lloop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2772 ldx(tmp1_reg, str1_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2773 ldx(tmp2_reg, str2_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2774 cmpd(CCR0, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2775 bne(CCR0, Ldone_false); // Unequal char pair found -> done.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2776 addi(index_reg, index_reg, 4*sizeof(jchar));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2777 bdnz(Lloop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2778 //14:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2779 bind(Linit_cbc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2780 beq(CCR1, Ldone_true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2781 mtctr(cbc_iter);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2782 //16:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2783 bind(Lcbc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2784 lhzx(tmp1_reg, str1_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2785 lhzx(tmp2_reg, str2_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2786 cmpw(CCR0, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2787 bne(CCR0, Ldone_false); // Unequal char pair found -> done.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2788 addi(index_reg, index_reg, 1*sizeof(jchar));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2789 bdnz(Lcbc);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2790 nop();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2791 bind(Ldone_true);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2792 li(result_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2793 //24:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2794 bind(Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2795 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2796
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2797
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2798 void MacroAssembler::char_arrays_equalsImm(Register str1_reg, Register str2_reg, int cntval, Register result_reg,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2799 Register tmp1_reg, Register tmp2_reg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2800 // Str1 may be the same register as str2 which can occur e.g. after scalar replacement.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2801 assert_different_registers(result_reg, str1_reg, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2802 assert_different_registers(result_reg, str2_reg, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2803 assert(sizeof(jchar) == 2, "must be");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2804 assert(cntval >= 0 && ((cntval & 0x7fff) == cntval), "wrong immediate");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2805
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2806 Label Ldone_false;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2807
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2808 if (cntval < 16) { // short case
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2809 if (cntval != 0) li(result_reg, 0); // assume false
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2810
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2811 const int num_bytes = cntval*sizeof(jchar);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2812 int index = 0;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2813 for (int next_index; (next_index = index + 8) <= num_bytes; index = next_index) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2814 ld(tmp1_reg, index, str1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2815 ld(tmp2_reg, index, str2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2816 cmpd(CCR0, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2817 bne(CCR0, Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2818 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2819 if (cntval & 2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2820 lwz(tmp1_reg, index, str1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2821 lwz(tmp2_reg, index, str2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2822 cmpw(CCR0, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2823 bne(CCR0, Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2824 index += 4;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2825 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2826 if (cntval & 1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2827 lhz(tmp1_reg, index, str1_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2828 lhz(tmp2_reg, index, str2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2829 cmpw(CCR0, tmp1_reg, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2830 bne(CCR0, Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2831 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2832 // fallthrough: true
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2833 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2834 Label Lloop;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2835 Register index_reg = tmp1_reg;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2836 const int loopcnt = cntval/4;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2837 assert(loopcnt > 0, "must be");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2838 // Offset 0 should be 32 byte aligned.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2839 //2:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2840 dcbtct(str1_reg, 0x00); // Indicate R/O access to str1.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2841 dcbtct(str2_reg, 0x00); // Indicate R/O access to str2.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2842 li(tmp2_reg, loopcnt);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2843 li(index_reg, 0); // init
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2844 li(result_reg, 0); // assume false
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2845 mtctr(tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2846 //8:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2847 bind(Lloop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2848 ldx(R0, str1_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2849 ldx(tmp2_reg, str2_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2850 cmpd(CCR0, R0, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2851 bne(CCR0, Ldone_false); // Unequal char pair found -> done.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2852 addi(index_reg, index_reg, 4*sizeof(jchar));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2853 bdnz(Lloop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2854 //14:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2855 if (cntval & 2) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2856 lwzx(R0, str1_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2857 lwzx(tmp2_reg, str2_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2858 cmpw(CCR0, R0, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2859 bne(CCR0, Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2860 if (cntval & 1) addi(index_reg, index_reg, 2*sizeof(jchar));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2861 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2862 if (cntval & 1) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2863 lhzx(R0, str1_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2864 lhzx(tmp2_reg, str2_reg, index_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2865 cmpw(CCR0, R0, tmp2_reg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2866 bne(CCR0, Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2867 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2868 // fallthru: true
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2869 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2870 li(result_reg, 1);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2871 bind(Ldone_false);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2872 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2873
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2874
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2875 void MacroAssembler::asm_assert(bool check_equal, const char *msg, int id) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2876 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2877 Label ok;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2878 if (check_equal) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2879 beq(CCR0, ok);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2880 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2881 bne(CCR0, ok);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2882 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2883 stop(msg, id);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2884 bind(ok);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2885 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2886 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2887
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2888 void MacroAssembler::asm_assert_mems_zero(bool check_equal, int size, int mem_offset,
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2889 Register mem_base, const char* msg, int id) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2890 #ifdef ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2891 switch (size) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2892 case 4:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2893 lwz(R0, mem_offset, mem_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2894 cmpwi(CCR0, R0, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2895 break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2896 case 8:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2897 ld(R0, mem_offset, mem_base);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2898 cmpdi(CCR0, R0, 0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2899 break;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2900 default:
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2901 ShouldNotReachHere();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2902 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2903 asm_assert(check_equal, msg, id);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2904 #endif // ASSERT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2905 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2906
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2907 void MacroAssembler::verify_thread() {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2908 if (VerifyThread) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2909 unimplemented("'VerifyThread' currently not implemented on PPC");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2910 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2911 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2912
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2913 // READ: oop. KILL: R0. Volatile floats perhaps.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2914 void MacroAssembler::verify_oop(Register oop, const char* msg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2915 if (!VerifyOops) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2916 return;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2917 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2918 // will be preserved.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2919 Register tmp = R11;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2920 assert(oop != tmp, "precondition");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2921 unsigned int nbytes_save = 10*8; // 10 volatile gprs
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2922 address/* FunctionDescriptor** */fd =
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2923 StubRoutines::verify_oop_subroutine_entry_address();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2924 // save tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2925 mr(R0, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2926 // kill tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2927 save_LR_CR(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2928 push_frame_abi112(nbytes_save, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2929 // restore tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2930 mr(tmp, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2931 save_volatile_gprs(R1_SP, 112); // except R0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2932 // load FunctionDescriptor**
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2933 load_const(tmp, fd);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2934 // load FunctionDescriptor*
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2935 ld(tmp, 0, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2936 mr(R4_ARG2, oop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2937 load_const(R3_ARG1, (address)msg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2938 // call destination for its side effect
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2939 call_c(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2940 restore_volatile_gprs(R1_SP, 112); // except R0
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2941 pop_frame();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2942 // save tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2943 mr(R0, tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2944 // kill tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2945 restore_LR_CR(tmp);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2946 // restore tmp
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2947 mr(tmp, R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2948 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2949
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2950 const char* stop_types[] = {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2951 "stop",
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2952 "untested",
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2953 "unimplemented",
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2954 "shouldnotreachhere"
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2955 };
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2956
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2957 static void stop_on_request(int tp, const char* msg) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2958 tty->print("PPC assembly code requires stop: (%s) %s\n", (void *)stop_types[tp%/*stop_end*/4], msg);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2959 guarantee(false, err_msg("PPC assembly code requires stop: %s", msg));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2960 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2961
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2962 // Call a C-function that prints output.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2963 void MacroAssembler::stop(int type, const char* msg, int id) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2964 #ifndef PRODUCT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2965 block_comment(err_msg("stop: %s %s {", stop_types[type%stop_end], msg));
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2966 #else
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2967 block_comment("stop {");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2968 #endif
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2969
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2970 // setup arguments
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2971 load_const_optimized(R3_ARG1, type);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2972 load_const_optimized(R4_ARG2, (void *)msg, /*tmp=*/R0);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2973 call_VM_leaf(CAST_FROM_FN_PTR(address, stop_on_request), R3_ARG1, R4_ARG2);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2974 illtrap();
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2975 emit_int32(id);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2976 block_comment("} stop;");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2977 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2978
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2979 #ifndef PRODUCT
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2980 // Write pattern 0x0101010101010101 in memory region [low-before, high+after].
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2981 // Val, addr are temp registers.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2982 // If low == addr, addr is killed.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2983 // High is preserved.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2984 void MacroAssembler::zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2985 if (!ZapMemory) return;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2986
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2987 assert_different_registers(low, val);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2988
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2989 BLOCK_COMMENT("zap memory region {");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2990 load_const_optimized(val, 0x0101010101010101);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2991 int size = before + after;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2992 if (low == high && size < 5 && size > 0) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2993 int offset = -before*BytesPerWord;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2994 for (int i = 0; i < size; ++i) {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2995 std(val, offset, low);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2996 offset += (1*BytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2997 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2998 } else {
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
2999 addi(addr, low, -before*BytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3000 assert_different_registers(high, val);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3001 if (after) addi(high, high, after * BytesPerWord);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3002 Label loop;
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3003 bind(loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3004 std(val, 0, addr);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3005 addi(addr, addr, 8);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3006 cmpd(CCR6, addr, high);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3007 ble(CCR6, loop);
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3008 if (after) addi(high, high, -after * BytesPerWord); // Correct back to old value.
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3009 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3010 BLOCK_COMMENT("} zap memory region");
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3011 }
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3012
ec28f9c041ff 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
3013 #endif // !PRODUCT