1 /*
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2016 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
453 // word index to byte offset. Since this is a java object, it can be compressed.
454 Register tmp = index; // reuse
455 sldi(tmp, index, LogBytesPerHeapOop);
456 // Load pointer for resolved_references[] objArray.
457 ld(result, ConstantPool::cache_offset_in_bytes(), result);
458 ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result);
459 // JNIHandles::resolve(result)
460 ld(result, 0, result);
461 #ifdef ASSERT
462 Label index_ok;
463 lwa(R0, arrayOopDesc::length_offset_in_bytes(), result);
464 sldi(R0, R0, LogBytesPerHeapOop);
465 cmpd(CCR0, tmp, R0);
466 blt(CCR0, index_ok);
467 stop("resolved reference index out of bounds", 0x09256);
468 bind(index_ok);
469 #endif
470 // Add in the index.
471 add(result, tmp, result);
472 load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, is_null);
473 }
474
475 // Generate a subtype check: branch to ok_is_subtype if sub_klass is
476 // a subtype of super_klass. Blows registers Rsub_klass, tmp1, tmp2.
477 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, Register Rsuper_klass, Register Rtmp1,
478 Register Rtmp2, Register Rtmp3, Label &ok_is_subtype) {
479 // Profile the not-null value's klass.
480 profile_typecheck(Rsub_klass, Rtmp1, Rtmp2);
481 check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype);
482 profile_typecheck_failed(Rtmp1, Rtmp2);
483 }
484
485 // Separate these two to allow for delay slot in middle.
486 // These are used to do a test and full jump to exception-throwing code.
487
488 // Check that index is in range for array, then shift index by index_shift,
489 // and put arrayOop + shifted_index into res.
490 // Note: res is still shy of address by array offset into object.
491
492 void InterpreterMacroAssembler::index_check_without_pop(Register Rarray, Register Rindex,
|
1 /*
2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 *
453 // word index to byte offset. Since this is a java object, it can be compressed.
454 Register tmp = index; // reuse
455 sldi(tmp, index, LogBytesPerHeapOop);
456 // Load pointer for resolved_references[] objArray.
457 ld(result, ConstantPool::cache_offset_in_bytes(), result);
458 ld(result, ConstantPoolCache::resolved_references_offset_in_bytes(), result);
459 // JNIHandles::resolve(result)
460 ld(result, 0, result);
461 #ifdef ASSERT
462 Label index_ok;
463 lwa(R0, arrayOopDesc::length_offset_in_bytes(), result);
464 sldi(R0, R0, LogBytesPerHeapOop);
465 cmpd(CCR0, tmp, R0);
466 blt(CCR0, index_ok);
467 stop("resolved reference index out of bounds", 0x09256);
468 bind(index_ok);
469 #endif
470 // Add in the index.
471 add(result, tmp, result);
472 load_heap_oop(result, arrayOopDesc::base_offset_in_bytes(T_OBJECT), result, is_null);
473 }
474
475 // load cpool->resolved_klass_at(index)
476 void InterpreterMacroAssembler::load_resolved_klass_at_offset(Register Rcpool, Register Roffset, Register Rklass) {
477 // int value = *(Rcpool->int_at_addr(which));
478 // int resolved_klass_index = extract_low_short_from_int(value);
479 add(Roffset, Rcpool, Roffset);
480 #if defined(VM_LITTLE_ENDIAN)
481 lhz(Roffset, sizeof(ConstantPool), Roffset); // Roffset = resolved_klass_index
482 #else
483 lhz(Roffset, sizeof(ConstantPool) + 2, Roffset); // Roffset = resolved_klass_index
484 #endif
485
486 ld(Rklass, ConstantPool::resolved_klasses_offset_in_bytes(), Rcpool); // Rklass = Rcpool->_resolved_klasses
487
488 sldi(Roffset, Roffset, LogBytesPerWord);
489 addi(Roffset, Roffset, Array<Klass*>::base_offset_in_bytes());
490 isync(); // Order load of instance Klass wrt. tags.
491 ldx(Rklass, Rklass, Roffset);
492 }
493
494 // Generate a subtype check: branch to ok_is_subtype if sub_klass is
495 // a subtype of super_klass. Blows registers Rsub_klass, tmp1, tmp2.
496 void InterpreterMacroAssembler::gen_subtype_check(Register Rsub_klass, Register Rsuper_klass, Register Rtmp1,
497 Register Rtmp2, Register Rtmp3, Label &ok_is_subtype) {
498 // Profile the not-null value's klass.
499 profile_typecheck(Rsub_klass, Rtmp1, Rtmp2);
500 check_klass_subtype(Rsub_klass, Rsuper_klass, Rtmp1, Rtmp2, ok_is_subtype);
501 profile_typecheck_failed(Rtmp1, Rtmp2);
502 }
503
504 // Separate these two to allow for delay slot in middle.
505 // These are used to do a test and full jump to exception-throwing code.
506
507 // Check that index is in range for array, then shift index by index_shift,
508 // and put arrayOop + shifted_index into res.
509 // Note: res is still shy of address by array offset into object.
510
511 void InterpreterMacroAssembler::index_check_without_pop(Register Rarray, Register Rindex,
|