1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
567 __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
568 // This is OK when all parameter types widen.
569 // It is also OK when a return type narrows.
570 break;
571
572 case _adapter_check_cast:
573 {
574 // temps:
575 Register rbx_klass = rbx_temp; // interesting AMH data
576
577 // check a reference argument before jumping to the next layer of MH:
578 __ movl(rax_argslot, rcx_amh_vmargslot);
579 vmarg = __ argument_address(rax_argslot);
580
581 // What class are we casting to?
582 __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object!
583 __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes()));
584
585 Label done;
586 __ movptr(rdx_temp, vmarg);
587 __ testl(rdx_temp, rdx_temp);
588 __ jccb(Assembler::zero, done); // no cast if null
589 __ load_klass(rdx_temp, rdx_temp);
590
591 // live at this point:
592 // - rbx_klass: klass required by the target method
593 // - rdx_temp: argument klass to test
594 // - rcx_recv: adapter method handle
595 __ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done);
596
597 // If we get here, the type check failed!
598 // Call the wrong_method_type stub, passing the failing argument type in rax.
599 Register rax_mtype = rax_argslot;
600 __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field
601 __ movptr(rdx_temp, vmarg);
602
603 __ pushptr(rcx_amh_argument); // required class
604 __ push(rdx_temp); // bad object
605 __ push((int)Bytecodes::_checkcast); // who is complaining?
606 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
607
|
1 /*
2 * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
567 __ jump_to_method_handle_entry(rcx_recv, rdx_temp);
568 // This is OK when all parameter types widen.
569 // It is also OK when a return type narrows.
570 break;
571
572 case _adapter_check_cast:
573 {
574 // temps:
575 Register rbx_klass = rbx_temp; // interesting AMH data
576
577 // check a reference argument before jumping to the next layer of MH:
578 __ movl(rax_argslot, rcx_amh_vmargslot);
579 vmarg = __ argument_address(rax_argslot);
580
581 // What class are we casting to?
582 __ movptr(rbx_klass, rcx_amh_argument); // this is a Class object!
583 __ movptr(rbx_klass, Address(rbx_klass, java_lang_Class::klass_offset_in_bytes()));
584
585 Label done;
586 __ movptr(rdx_temp, vmarg);
587 __ testptr(rdx_temp, rdx_temp);
588 __ jccb(Assembler::zero, done); // no cast if null
589 __ load_klass(rdx_temp, rdx_temp);
590
591 // live at this point:
592 // - rbx_klass: klass required by the target method
593 // - rdx_temp: argument klass to test
594 // - rcx_recv: adapter method handle
595 __ check_klass_subtype(rdx_temp, rbx_klass, rax_argslot, done);
596
597 // If we get here, the type check failed!
598 // Call the wrong_method_type stub, passing the failing argument type in rax.
599 Register rax_mtype = rax_argslot;
600 __ movl(rax_argslot, rcx_amh_vmargslot); // reload argslot field
601 __ movptr(rdx_temp, vmarg);
602
603 __ pushptr(rcx_amh_argument); // required class
604 __ push(rdx_temp); // bad object
605 __ push((int)Bytecodes::_checkcast); // who is complaining?
606 __ jump(ExternalAddress(from_interpreted_entry(_raise_exception)));
607
|