12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include <sys/types.h>
27
28 #include "precompiled.hpp"
29 #include "jvm.h"
30 #include "asm/assembler.hpp"
31 #include "asm/assembler.inline.hpp"
32 #include "gc/shared/cardTable.hpp"
33 #include "gc/shared/barrierSetAssembler.hpp"
34 #include "gc/shared/cardTableBarrierSet.hpp"
35 #include "interpreter/interpreter.hpp"
36 #include "compiler/disassembler.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "nativeInst_aarch64.hpp"
39 #include "oops/compressedOops.inline.hpp"
40 #include "oops/klass.inline.hpp"
41 #include "oops/oop.hpp"
42 #include "opto/compile.hpp"
43 #include "opto/intrinsicnode.hpp"
44 #include "opto/node.hpp"
45 #include "runtime/biasedLocking.hpp"
46 #include "runtime/icache.hpp"
47 #include "runtime/interfaceSupport.inline.hpp"
48 #include "runtime/jniHandles.inline.hpp"
49 #include "runtime/sharedRuntime.hpp"
50 #include "runtime/thread.hpp"
51 #if INCLUDE_ALL_GCS
2075 }
2076 #ifdef ASSERT
2077 void MacroAssembler::verify_heapbase(const char* msg) {
2078 #if 0
2079 assert (UseCompressedOops || UseCompressedClassPointers, "should be compressed");
2080 assert (Universe::heap() != NULL, "java heap should be initialized");
2081 if (CheckCompressedOops) {
2082 Label ok;
2083 push(1 << rscratch1->encoding(), sp); // cmpptr trashes rscratch1
2084 cmpptr(rheapbase, ExternalAddress((address)Universe::narrow_ptrs_base_addr()));
2085 br(Assembler::EQ, ok);
2086 stop(msg);
2087 bind(ok);
2088 pop(1 << rscratch1->encoding(), sp);
2089 }
2090 #endif
2091 }
2092 #endif
2093
2094 void MacroAssembler::resolve_jobject(Register value, Register thread, Register tmp) {
2095 BarrierSetAssembler *bs = Universe::heap()->barrier_set()->barrier_set_assembler();
2096 Label done, not_weak;
2097 cbz(value, done); // Use NULL as-is.
2098
2099 STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
2100 tbz(r0, 0, not_weak); // Test for jweak tag.
2101
2102 // Resolve jweak.
2103 bs->load_at(this, IN_ROOT | ON_PHANTOM_OOP_REF, T_OBJECT,
2104 value, Address(value, -JNIHandles::weak_tag_value), tmp, thread);
2105 verify_oop(value);
2106 b(done);
2107
2108 bind(not_weak);
2109 // Resolve (untagged) jobject.
2110 bs->load_at(this, IN_ROOT | ON_STRONG_OOP_REF, T_OBJECT,
2111 value, Address(value, 0), tmp, thread);
2112 verify_oop(value);
2113 bind(done);
2114 }
2115
4299
4300 InstructionMark im(this);
4301 code_section()->relocate(inst_mark(), dest.rspec());
4302 // 8143067: Ensure that the adrp can reach the dest from anywhere within
4303 // the code cache so that if it is relocated we know it will still reach
4304 if (offset_high >= -(1<<20) && offset_low < (1<<20)) {
4305 _adrp(reg1, dest.target());
4306 } else {
4307 unsigned long target = (unsigned long)dest.target();
4308 unsigned long adrp_target
4309 = (target & 0xffffffffUL) | ((unsigned long)pc() & 0xffff00000000UL);
4310
4311 _adrp(reg1, (address)adrp_target);
4312 movk(reg1, target >> 32, 32);
4313 }
4314 byte_offset = (unsigned long)dest.target() & 0xfff;
4315 }
4316
4317 void MacroAssembler::load_byte_map_base(Register reg) {
4318 jbyte *byte_map_base =
4319 ((CardTableBarrierSet*)(Universe::heap()->barrier_set()))->card_table()->byte_map_base();
4320
4321 if (is_valid_AArch64_address((address)byte_map_base)) {
4322 // Strictly speaking the byte_map_base isn't an address at all,
4323 // and it might even be negative.
4324 unsigned long offset;
4325 adrp(reg, ExternalAddress((address)byte_map_base), offset);
4326 // We expect offset to be zero with most collectors.
4327 if (offset != 0) {
4328 add(reg, reg, offset);
4329 }
4330 } else {
4331 mov(reg, (uint64_t)byte_map_base);
4332 }
4333 }
4334
4335 void MacroAssembler::build_frame(int framesize) {
4336 assert(framesize > 0, "framesize must be > 0");
4337 if (framesize < ((1 << 9) + 2 * wordSize)) {
4338 sub(sp, sp, framesize);
4339 stp(rfp, lr, Address(sp, framesize - 2 * wordSize));
|
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #include <sys/types.h>
27
28 #include "precompiled.hpp"
29 #include "jvm.h"
30 #include "asm/assembler.hpp"
31 #include "asm/assembler.inline.hpp"
32 #include "gc/shared/barrierSet.hpp"
33 #include "gc/shared/cardTable.hpp"
34 #include "gc/shared/barrierSetAssembler.hpp"
35 #include "gc/shared/cardTableBarrierSet.hpp"
36 #include "interpreter/interpreter.hpp"
37 #include "compiler/disassembler.hpp"
38 #include "memory/resourceArea.hpp"
39 #include "nativeInst_aarch64.hpp"
40 #include "oops/compressedOops.inline.hpp"
41 #include "oops/klass.inline.hpp"
42 #include "oops/oop.hpp"
43 #include "opto/compile.hpp"
44 #include "opto/intrinsicnode.hpp"
45 #include "opto/node.hpp"
46 #include "runtime/biasedLocking.hpp"
47 #include "runtime/icache.hpp"
48 #include "runtime/interfaceSupport.inline.hpp"
49 #include "runtime/jniHandles.inline.hpp"
50 #include "runtime/sharedRuntime.hpp"
51 #include "runtime/thread.hpp"
52 #if INCLUDE_ALL_GCS
2076 }
2077 #ifdef ASSERT
2078 void MacroAssembler::verify_heapbase(const char* msg) {
2079 #if 0
2080 assert (UseCompressedOops || UseCompressedClassPointers, "should be compressed");
2081 assert (Universe::heap() != NULL, "java heap should be initialized");
2082 if (CheckCompressedOops) {
2083 Label ok;
2084 push(1 << rscratch1->encoding(), sp); // cmpptr trashes rscratch1
2085 cmpptr(rheapbase, ExternalAddress((address)Universe::narrow_ptrs_base_addr()));
2086 br(Assembler::EQ, ok);
2087 stop(msg);
2088 bind(ok);
2089 pop(1 << rscratch1->encoding(), sp);
2090 }
2091 #endif
2092 }
2093 #endif
2094
2095 void MacroAssembler::resolve_jobject(Register value, Register thread, Register tmp) {
2096 BarrierSetAssembler *bs = BarrierSet::barrier_set()->barrier_set_assembler();
2097 Label done, not_weak;
2098 cbz(value, done); // Use NULL as-is.
2099
2100 STATIC_ASSERT(JNIHandles::weak_tag_mask == 1u);
2101 tbz(r0, 0, not_weak); // Test for jweak tag.
2102
2103 // Resolve jweak.
2104 bs->load_at(this, IN_ROOT | ON_PHANTOM_OOP_REF, T_OBJECT,
2105 value, Address(value, -JNIHandles::weak_tag_value), tmp, thread);
2106 verify_oop(value);
2107 b(done);
2108
2109 bind(not_weak);
2110 // Resolve (untagged) jobject.
2111 bs->load_at(this, IN_ROOT | ON_STRONG_OOP_REF, T_OBJECT,
2112 value, Address(value, 0), tmp, thread);
2113 verify_oop(value);
2114 bind(done);
2115 }
2116
4300
4301 InstructionMark im(this);
4302 code_section()->relocate(inst_mark(), dest.rspec());
4303 // 8143067: Ensure that the adrp can reach the dest from anywhere within
4304 // the code cache so that if it is relocated we know it will still reach
4305 if (offset_high >= -(1<<20) && offset_low < (1<<20)) {
4306 _adrp(reg1, dest.target());
4307 } else {
4308 unsigned long target = (unsigned long)dest.target();
4309 unsigned long adrp_target
4310 = (target & 0xffffffffUL) | ((unsigned long)pc() & 0xffff00000000UL);
4311
4312 _adrp(reg1, (address)adrp_target);
4313 movk(reg1, target >> 32, 32);
4314 }
4315 byte_offset = (unsigned long)dest.target() & 0xfff;
4316 }
4317
4318 void MacroAssembler::load_byte_map_base(Register reg) {
4319 jbyte *byte_map_base =
4320 ((CardTableBarrierSet*)(BarrierSet::barrier_set()))->card_table()->byte_map_base();
4321
4322 if (is_valid_AArch64_address((address)byte_map_base)) {
4323 // Strictly speaking the byte_map_base isn't an address at all,
4324 // and it might even be negative.
4325 unsigned long offset;
4326 adrp(reg, ExternalAddress((address)byte_map_base), offset);
4327 // We expect offset to be zero with most collectors.
4328 if (offset != 0) {
4329 add(reg, reg, offset);
4330 }
4331 } else {
4332 mov(reg, (uint64_t)byte_map_base);
4333 }
4334 }
4335
4336 void MacroAssembler::build_frame(int framesize) {
4337 assert(framesize > 0, "framesize must be > 0");
4338 if (framesize < ((1 << 9) + 2 * wordSize)) {
4339 sub(sp, sp, framesize);
4340 stp(rfp, lr, Address(sp, framesize - 2 * wordSize));
|