1 /*
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2013, 2015 SAP AG. 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.
358 __ align(32, 12);
359 __ bind(notInt);
360 #ifdef ASSERT
361 // String and Object are rewritten to fast_aldc
362 __ cmpdi(CCR0, Rscratch2, JVM_CONSTANT_Float);
363 __ asm_assert_eq("unexpected type", 0x8765);
364 #endif
365 __ lfsx(F15_ftos, Rcpool, Rscratch1);
366 __ push(ftos);
367
368 __ align(32, 12);
369 __ bind(exit);
370 }
371
372 // Fast path for caching oop constants.
373 void TemplateTable::fast_aldc(bool wide) {
374 transition(vtos, atos);
375
376 int index_size = wide ? sizeof(u2) : sizeof(u1);
377 const Register Rscratch = R11_scratch1;
378 Label resolved;
379
380 // We are resolved if the resolved reference cache entry contains a
381 // non-null object (CallSite, etc.)
382 __ get_cache_index_at_bcp(Rscratch, 1, index_size); // Load index.
383 __ load_resolved_reference_at_index(R17_tos, Rscratch);
384 __ cmpdi(CCR0, R17_tos, 0);
385 __ bne(CCR0, resolved);
386 __ load_const_optimized(R3_ARG1, (int)bytecode());
387
388 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
389
390 // First time invocation - must resolve first.
391 __ call_VM(R17_tos, entry, R3_ARG1);
392
393 __ align(32, 12);
394 __ bind(resolved);
395 __ verify_oop(R17_tos);
396 }
397
398 void TemplateTable::ldc2_w() {
399 transition(vtos, vtos);
400 Label Llong, Lexit;
401
402 Register Rindex = R11_scratch1,
403 Rcpool = R12_scratch2,
404 Rtag = R3_ARG1;
405 __ get_cpool_and_tags(Rcpool, Rtag);
406 __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
407
408 const int base_offset = ConstantPool::header_size() * wordSize;
409 const int tags_offset = Array<u1>::base_offset_in_bytes();
410 // Get type from tags.
411 __ addi(Rcpool, Rcpool, base_offset);
412 __ addi(Rtag, Rtag, tags_offset);
413
414 __ lbzx(Rtag, Rtag, Rindex);
3778 __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ClassCastException_entry);
3779 __ mtctr(R11_scratch1);
3780 __ bctr();
3781
3782 // Profile the null case.
3783 __ align(32, 12);
3784 __ bind(Lis_null);
3785 __ profile_null_seen(R11_scratch1, Rtags); // Rtags used as scratch.
3786
3787 __ align(32, 12);
3788 __ bind(Ldone);
3789 }
3790
3791 // Output:
3792 // - tos == 0: Obj was null or not an instance of class.
3793 // - tos == 1: Obj was an instance of class.
3794 void TemplateTable::instanceof() {
3795 transition(atos, itos);
3796
3797 Label Ldone, Lis_null, Lquicked, Lresolved;
3798 Register Roffset = R5_ARG3,
3799 RobjKlass = R4_ARG2,
3800 RspecifiedKlass = R6_ARG4, // Generate_ClassCastException_verbose_handler will expect the value in this register.
3801 Rcpool = R11_scratch1,
3802 Rtags = R12_scratch2;
3803
3804 // Null does not pass.
3805 __ cmpdi(CCR0, R17_tos, 0);
3806 __ beq(CCR0, Lis_null);
3807
3808 // Get constant pool tag to find out if the bytecode has already been "quickened".
3809 __ get_cpool_and_tags(Rcpool, Rtags);
3810
3811 __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3812
3813 __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3814 __ lbzx(Rtags, Rtags, Roffset);
3815
3816 __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3817 __ beq(CCR0, Lquicked);
3818
3819 // Call into the VM to "quicken" instanceof.
3820 __ push_ptr(); // for GC
|
1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * Copyright 2013, 2015 SAP AG. 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.
358 __ align(32, 12);
359 __ bind(notInt);
360 #ifdef ASSERT
361 // String and Object are rewritten to fast_aldc
362 __ cmpdi(CCR0, Rscratch2, JVM_CONSTANT_Float);
363 __ asm_assert_eq("unexpected type", 0x8765);
364 #endif
365 __ lfsx(F15_ftos, Rcpool, Rscratch1);
366 __ push(ftos);
367
368 __ align(32, 12);
369 __ bind(exit);
370 }
371
372 // Fast path for caching oop constants.
373 void TemplateTable::fast_aldc(bool wide) {
374 transition(vtos, atos);
375
376 int index_size = wide ? sizeof(u2) : sizeof(u1);
377 const Register Rscratch = R11_scratch1;
378 Label is_null;
379
380 // We are resolved if the resolved reference cache entry contains a
381 // non-null object (CallSite, etc.)
382 __ get_cache_index_at_bcp(Rscratch, 1, index_size); // Load index.
383 __ load_resolved_reference_at_index(R17_tos, Rscratch, &is_null);
384 __ verify_oop(R17_tos);
385 __ dispatch_epilog(atos, Bytecodes::length_for(bytecode()));
386
387 __ bind(is_null);
388 __ load_const_optimized(R3_ARG1, (int)bytecode());
389
390 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
391
392 // First time invocation - must resolve first.
393 __ call_VM(R17_tos, entry, R3_ARG1);
394 __ verify_oop(R17_tos);
395 }
396
397 void TemplateTable::ldc2_w() {
398 transition(vtos, vtos);
399 Label Llong, Lexit;
400
401 Register Rindex = R11_scratch1,
402 Rcpool = R12_scratch2,
403 Rtag = R3_ARG1;
404 __ get_cpool_and_tags(Rcpool, Rtag);
405 __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
406
407 const int base_offset = ConstantPool::header_size() * wordSize;
408 const int tags_offset = Array<u1>::base_offset_in_bytes();
409 // Get type from tags.
410 __ addi(Rcpool, Rcpool, base_offset);
411 __ addi(Rtag, Rtag, tags_offset);
412
413 __ lbzx(Rtag, Rtag, Rindex);
3777 __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ClassCastException_entry);
3778 __ mtctr(R11_scratch1);
3779 __ bctr();
3780
3781 // Profile the null case.
3782 __ align(32, 12);
3783 __ bind(Lis_null);
3784 __ profile_null_seen(R11_scratch1, Rtags); // Rtags used as scratch.
3785
3786 __ align(32, 12);
3787 __ bind(Ldone);
3788 }
3789
3790 // Output:
3791 // - tos == 0: Obj was null or not an instance of class.
3792 // - tos == 1: Obj was an instance of class.
3793 void TemplateTable::instanceof() {
3794 transition(atos, itos);
3795
3796 Label Ldone, Lis_null, Lquicked, Lresolved;
3797 Register Roffset = R6_ARG4,
3798 RobjKlass = R4_ARG2,
3799 RspecifiedKlass = R5_ARG3,
3800 Rcpool = R11_scratch1,
3801 Rtags = R12_scratch2;
3802
3803 // Null does not pass.
3804 __ cmpdi(CCR0, R17_tos, 0);
3805 __ beq(CCR0, Lis_null);
3806
3807 // Get constant pool tag to find out if the bytecode has already been "quickened".
3808 __ get_cpool_and_tags(Rcpool, Rtags);
3809
3810 __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
3811
3812 __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
3813 __ lbzx(Rtags, Rtags, Roffset);
3814
3815 __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
3816 __ beq(CCR0, Lquicked);
3817
3818 // Call into the VM to "quicken" instanceof.
3819 __ push_ptr(); // for GC
|