annotate src/cpu/sparc/vm/methodHandles_sparc.cpp @ 2142:8012aa3ccede

4926272: methodOopDesc::method_from_bcp is unsafe Reviewed-by: coleenp, jrose, kvn, dcubed
author never
date Thu, 13 Jan 2011 22:15:41 -0800
parents 8d0b933dda2d
children d810e9a3fc33
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1507
diff changeset
2 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
4 *
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
7 * published by the Free Software Foundation.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
8 *
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
13 * accompanied this code).
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
14 *
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1507
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1507
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1507
diff changeset
21 * questions.
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
22 *
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
23 */
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1916
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1916
diff changeset
26 #include "interpreter/interpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1916
diff changeset
27 #include "memory/allocation.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1916
diff changeset
28 #include "prims/methodHandles.hpp"
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
29
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
30 #define __ _masm->
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
31
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
32 #ifdef PRODUCT
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
33 #define BLOCK_COMMENT(str) /* nothing */
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
34 #else
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
35 #define BLOCK_COMMENT(str) __ block_comment(str)
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
36 #endif
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
37
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
38 #define BIND(label) bind(label); BLOCK_COMMENT(#label ":")
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
39
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
40 address MethodHandleEntry::start_compiled_entry(MacroAssembler* _masm,
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
41 address interpreted_entry) {
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
42 // Just before the actual machine code entry point, allocate space
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
43 // for a MethodHandleEntry::Data record, so that we can manage everything
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
44 // from one base pointer.
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
45 __ align(wordSize);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
46 address target = __ pc() + sizeof(Data);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
47 while (__ pc() < target) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
48 __ nop();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
49 __ align(wordSize);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
50 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
51
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
52 MethodHandleEntry* me = (MethodHandleEntry*) __ pc();
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
53 me->set_end_address(__ pc()); // set a temporary end_address
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
54 me->set_from_interpreted_entry(interpreted_entry);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
55 me->set_type_checking_entry(NULL);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
56
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
57 return (address) me;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
58 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
59
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
60 MethodHandleEntry* MethodHandleEntry::finish_compiled_entry(MacroAssembler* _masm,
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
61 address start_addr) {
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
62 MethodHandleEntry* me = (MethodHandleEntry*) start_addr;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
63 assert(me->end_address() == start_addr, "valid ME");
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
64
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
65 // Fill in the real end_address:
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
66 __ align(wordSize);
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
67 me->set_end_address(__ pc());
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
68
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
69 return me;
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
70 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
71
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
72
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
73 // Code generation
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
74 address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm) {
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
75 // I5_savedSP/O5_savedSP: sender SP (must preserve)
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
76 // G4 (Gargs): incoming argument list (must preserve)
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
77 // G5_method: invoke methodOop
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
78 // G3_method_handle: receiver method handle (must load from sp[MethodTypeForm.vmslots])
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
79 // O0, O1, O2, O3, O4: garbage temps, blown away
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
80 Register O0_mtype = O0;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
81 Register O1_scratch = O1;
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
82 Register O2_scratch = O2;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
83 Register O3_scratch = O3;
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
84 Register O4_argslot = O4;
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
85 Register O4_argbase = O4;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
86
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
87 // emit WrongMethodType path first, to enable back-branch from main path
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
88 Label wrong_method_type;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
89 __ bind(wrong_method_type);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
90 Label invoke_generic_slow_path;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
91 assert(methodOopDesc::intrinsic_id_size_in_bytes() == sizeof(u1), "");;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
92 __ ldub(Address(G5_method, methodOopDesc::intrinsic_id_offset_in_bytes()), O1_scratch);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
93 __ cmp(O1_scratch, (int) vmIntrinsics::_invokeExact);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
94 __ brx(Assembler::notEqual, false, Assembler::pt, invoke_generic_slow_path);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
95 __ delayed()->nop();
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
96 __ mov(O0_mtype, G5_method_type); // required by throw_WrongMethodType
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
97 // mov(G3_method_handle, G3_method_handle); // already in this register
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
98 __ jump_to(AddressLiteral(Interpreter::throw_WrongMethodType_entry()), O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
99 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
100
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
101 // here's where control starts out:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
102 __ align(CodeEntryAlignment);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
103 address entry_point = __ pc();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
104
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
105 // fetch the MethodType from the method handle
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
106 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
107 Register tem = G5_method;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
108 for (jint* pchase = methodOopDesc::method_type_offsets_chain(); (*pchase) != -1; pchase++) {
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
109 __ ld_ptr(Address(tem, *pchase), O0_mtype);
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
110 tem = O0_mtype; // in case there is another indirection
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
111 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
112 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
113
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
114 // given the MethodType, find out where the MH argument is buried
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
115 __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O4_argslot);
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
116 __ ldsw( Address(O4_argslot, __ delayed_value(java_dyn_MethodTypeForm::vmslots_offset_in_bytes, O1_scratch)), O4_argslot);
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
117 __ add(Gargs, __ argument_offset(O4_argslot, 1), O4_argbase);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
118 // Note: argument_address uses its input as a scratch register!
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
119 __ ld_ptr(Address(O4_argbase, -Interpreter::stackElementSize), G3_method_handle);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
120
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
121 trace_method_handle(_masm, "invokeExact");
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
122
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
123 __ check_method_handle_type(O0_mtype, G3_method_handle, O1_scratch, wrong_method_type);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
124 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
125
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
126 // for invokeGeneric (only), apply argument and result conversions on the fly
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
127 __ bind(invoke_generic_slow_path);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
128 #ifdef ASSERT
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
129 { Label L;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
130 __ ldub(Address(G5_method, methodOopDesc::intrinsic_id_offset_in_bytes()), O1_scratch);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
131 __ cmp(O1_scratch, (int) vmIntrinsics::_invokeGeneric);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
132 __ brx(Assembler::equal, false, Assembler::pt, L);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
133 __ delayed()->nop();
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
134 __ stop("bad methodOop::intrinsic_id");
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
135 __ bind(L);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
136 }
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
137 #endif //ASSERT
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
138
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
139 // make room on the stack for another pointer:
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
140 insert_arg_slots(_masm, 2 * stack_move_unit(), _INSERT_REF_MASK, O4_argbase, O1_scratch, O2_scratch, O3_scratch);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
141 // load up an adapter from the calling type (Java weaves this)
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
142 Register O2_form = O2_scratch;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
143 Register O3_adapter = O3_scratch;
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
144 __ load_heap_oop(Address(O0_mtype, __ delayed_value(java_dyn_MethodType::form_offset_in_bytes, O1_scratch)), O2_form);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
145 // load_heap_oop(Address(O2_form, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
146 // deal with old JDK versions:
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
147 __ add( Address(O2_form, __ delayed_value(java_dyn_MethodTypeForm::genericInvoker_offset_in_bytes, O1_scratch)), O3_adapter);
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
148 __ cmp(O3_adapter, O2_form);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
149 Label sorry_no_invoke_generic;
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
150 __ brx(Assembler::lessUnsigned, false, Assembler::pn, sorry_no_invoke_generic);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
151 __ delayed()->nop();
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
152
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
153 __ load_heap_oop(Address(O3_adapter, 0), O3_adapter);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
154 __ tst(O3_adapter);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
155 __ brx(Assembler::zero, false, Assembler::pn, sorry_no_invoke_generic);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
156 __ delayed()->nop();
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
157 __ st_ptr(O3_adapter, Address(O4_argbase, 1 * Interpreter::stackElementSize));
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
158 // As a trusted first argument, pass the type being called, so the adapter knows
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
159 // the actual types of the arguments and return values.
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
160 // (Generic invokers are shared among form-families of method-type.)
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
161 __ st_ptr(O0_mtype, Address(O4_argbase, 0 * Interpreter::stackElementSize));
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
162 // FIXME: assert that O3_adapter is of the right method-type.
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
163 __ mov(O3_adapter, G3_method_handle);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
164 trace_method_handle(_masm, "invokeGeneric");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
165 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
166
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
167 __ bind(sorry_no_invoke_generic); // no invokeGeneric implementation available!
1916
e62345fd6a46 6997459: JSR 292 after 6994093 getting: on return to interpreted call, restored SP is corrupted
twisti
parents: 1911
diff changeset
168 __ mov(O0_mtype, G5_method_type); // required by throw_WrongMethodType
1911
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
169 // mov(G3_method_handle, G3_method_handle); // already in this register
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
170 __ jump_to(AddressLiteral(Interpreter::throw_WrongMethodType_entry()), O1_scratch);
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
171 __ delayed()->nop();
fff777a71346 6994093: MethodHandle.invokeGeneric needs porting to SPARC
jrose
parents: 1901
diff changeset
172
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
173 return entry_point;
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
174 }
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
175
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
176
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
177 #ifdef ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
178 static void verify_argslot(MacroAssembler* _masm, Register argslot_reg, Register temp_reg, const char* error_message) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
179 // Verify that argslot lies within (Gargs, FP].
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
180 Label L_ok, L_bad;
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
181 BLOCK_COMMENT("{ verify_argslot");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
182 #ifdef _LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
183 __ add(FP, STACK_BIAS, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
184 __ cmp(argslot_reg, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
185 #else
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
186 __ cmp(argslot_reg, FP);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
187 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
188 __ brx(Assembler::greaterUnsigned, false, Assembler::pn, L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
189 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
190 __ cmp(Gargs, argslot_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
191 __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
192 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
193 __ bind(L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
194 __ stop(error_message);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
195 __ bind(L_ok);
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
196 BLOCK_COMMENT("} verify_argslot");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
197 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
198 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
199
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
200
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
201 // Helper to insert argument slots into the stack.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
202 // arg_slots must be a multiple of stack_move_unit() and <= 0
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
203 void MethodHandles::insert_arg_slots(MacroAssembler* _masm,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
204 RegisterOrConstant arg_slots,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
205 int arg_mask,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
206 Register argslot_reg,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
207 Register temp_reg, Register temp2_reg, Register temp3_reg) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
208 assert(temp3_reg != noreg, "temp3 required");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
209 assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
210 (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
211
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
212 #ifdef ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
213 verify_argslot(_masm, argslot_reg, temp_reg, "insertion point must fall within current frame");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
214 if (arg_slots.is_register()) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
215 Label L_ok, L_bad;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
216 __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
217 __ br(Assembler::greater, false, Assembler::pn, L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
218 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
219 __ btst(-stack_move_unit() - 1, arg_slots.as_register());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
220 __ br(Assembler::zero, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
221 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
222 __ bind(L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
223 __ stop("assert arg_slots <= 0 and clear low bits");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
224 __ bind(L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
225 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
226 assert(arg_slots.as_constant() <= 0, "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
227 assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
228 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
229 #endif // ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
230
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
231 #ifdef _LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
232 if (arg_slots.is_register()) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
233 // Was arg_slots register loaded as signed int?
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
234 Label L_ok;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
235 __ sll(arg_slots.as_register(), BitsPerInt, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
236 __ sra(temp_reg, BitsPerInt, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
237 __ cmp(arg_slots.as_register(), temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
238 __ br(Assembler::equal, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
239 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
240 __ stop("arg_slots register not loaded as signed int");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
241 __ bind(L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
242 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
243 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
244
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
245 // Make space on the stack for the inserted argument(s).
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
246 // Then pull down everything shallower than argslot_reg.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
247 // The stacked return address gets pulled down with everything else.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
248 // That is, copy [sp, argslot) downward by -size words. In pseudo-code:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
249 // sp -= size;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
250 // for (temp = sp + size; temp < argslot; temp++)
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
251 // temp[-size] = temp[0]
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
252 // argslot -= size;
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
253 BLOCK_COMMENT("insert_arg_slots {");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
254 RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
255
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
256 // Keep the stack pointer 2*wordSize aligned.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
257 const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
258 RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
259 __ add(SP, masked_offset, SP);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
260
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
261 __ mov(Gargs, temp_reg); // source pointer for copy
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
262 __ add(Gargs, offset, Gargs);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
263
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
264 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
265 Label loop;
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
266 __ BIND(loop);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
267 // pull one word down each time through the loop
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
268 __ ld_ptr(Address(temp_reg, 0), temp2_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
269 __ st_ptr(temp2_reg, Address(temp_reg, offset));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
270 __ add(temp_reg, wordSize, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
271 __ cmp(temp_reg, argslot_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
272 __ brx(Assembler::less, false, Assembler::pt, loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
273 __ delayed()->nop(); // FILLME
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
274 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
275
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
276 // Now move the argslot down, to point to the opened-up space.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
277 __ add(argslot_reg, offset, argslot_reg);
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
278 BLOCK_COMMENT("} insert_arg_slots");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
279 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
280
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
281
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
282 // Helper to remove argument slots from the stack.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
283 // arg_slots must be a multiple of stack_move_unit() and >= 0
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
284 void MethodHandles::remove_arg_slots(MacroAssembler* _masm,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
285 RegisterOrConstant arg_slots,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
286 Register argslot_reg,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
287 Register temp_reg, Register temp2_reg, Register temp3_reg) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
288 assert(temp3_reg != noreg, "temp3 required");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
289 assert_different_registers(argslot_reg, temp_reg, temp2_reg, temp3_reg,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
290 (!arg_slots.is_register() ? Gargs : arg_slots.as_register()));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
291
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
292 RegisterOrConstant offset = __ regcon_sll_ptr(arg_slots, LogBytesPerWord, temp3_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
293
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
294 #ifdef ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
295 // Verify that [argslot..argslot+size) lies within (Gargs, FP).
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
296 __ add(argslot_reg, offset, temp2_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
297 verify_argslot(_masm, temp2_reg, temp_reg, "deleted argument(s) must fall within current frame");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
298 if (arg_slots.is_register()) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
299 Label L_ok, L_bad;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
300 __ cmp(arg_slots.as_register(), (int32_t) NULL_WORD);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
301 __ br(Assembler::less, false, Assembler::pn, L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
302 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
303 __ btst(-stack_move_unit() - 1, arg_slots.as_register());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
304 __ br(Assembler::zero, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
305 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
306 __ bind(L_bad);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
307 __ stop("assert arg_slots >= 0 and clear low bits");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
308 __ bind(L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
309 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
310 assert(arg_slots.as_constant() >= 0, "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
311 assert(arg_slots.as_constant() % -stack_move_unit() == 0, "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
312 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
313 #endif // ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
314
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
315 BLOCK_COMMENT("remove_arg_slots {");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
316 // Pull up everything shallower than argslot.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
317 // Then remove the excess space on the stack.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
318 // The stacked return address gets pulled up with everything else.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
319 // That is, copy [sp, argslot) upward by size words. In pseudo-code:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
320 // for (temp = argslot-1; temp >= sp; --temp)
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
321 // temp[size] = temp[0]
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
322 // argslot += size;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
323 // sp += size;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
324 __ sub(argslot_reg, wordSize, temp_reg); // source pointer for copy
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
325 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
326 Label loop;
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
327 __ BIND(loop);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
328 // pull one word up each time through the loop
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
329 __ ld_ptr(Address(temp_reg, 0), temp2_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
330 __ st_ptr(temp2_reg, Address(temp_reg, offset));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
331 __ sub(temp_reg, wordSize, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
332 __ cmp(temp_reg, Gargs);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
333 __ brx(Assembler::greaterEqual, false, Assembler::pt, loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
334 __ delayed()->nop(); // FILLME
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
335 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
336
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
337 // Now move the argslot up, to point to the just-copied block.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
338 __ add(Gargs, offset, Gargs);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
339 // And adjust the argslot address to point at the deletion point.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
340 __ add(argslot_reg, offset, argslot_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
341
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
342 // Keep the stack pointer 2*wordSize aligned.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
343 const int TwoWordAlignmentMask = right_n_bits(LogBytesPerWord + 1);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
344 RegisterOrConstant masked_offset = __ regcon_andn_ptr(offset, TwoWordAlignmentMask, temp_reg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
345 __ add(SP, masked_offset, SP);
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
346 BLOCK_COMMENT("} remove_arg_slots");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
347 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
348
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
349
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
350 #ifndef PRODUCT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
351 extern "C" void print_method_handle(oop mh);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
352 void trace_method_handle_stub(const char* adaptername,
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
353 oopDesc* mh) {
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
354 printf("MH %s mh="INTPTR_FORMAT"\n", adaptername, (intptr_t) mh);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
355 print_method_handle(mh);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
356 }
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
357 void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
358 if (!TraceMethodHandles) return;
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
359 BLOCK_COMMENT("trace_method_handle {");
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
360 // save: Gargs, O5_savedSP
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
361 __ save_frame(16);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
362 __ set((intptr_t) adaptername, O0);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
363 __ mov(G3_method_handle, O1);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
364 __ mov(G3_method_handle, L3);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
365 __ mov(Gargs, L4);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
366 __ mov(G5_method_type, L5);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
367 __ call_VM_leaf(L7, CAST_FROM_FN_PTR(address, trace_method_handle_stub));
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
368
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
369 __ mov(L3, G3_method_handle);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
370 __ mov(L4, Gargs);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
371 __ mov(L5, G5_method_type);
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
372 __ restore();
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
373 BLOCK_COMMENT("} trace_method_handle");
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
374 }
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
375 #endif // PRODUCT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
376
1507
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
377 // which conversion op types are implemented here?
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
378 int MethodHandles::adapter_conversion_ops_supported_mask() {
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
379 return ((1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_ONLY)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
380 |(1<<sun_dyn_AdapterMethodHandle::OP_RETYPE_RAW)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
381 |(1<<sun_dyn_AdapterMethodHandle::OP_CHECK_CAST)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
382 |(1<<sun_dyn_AdapterMethodHandle::OP_PRIM_TO_PRIM)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
383 |(1<<sun_dyn_AdapterMethodHandle::OP_REF_TO_PRIM)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
384 |(1<<sun_dyn_AdapterMethodHandle::OP_SWAP_ARGS)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
385 |(1<<sun_dyn_AdapterMethodHandle::OP_ROT_ARGS)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
386 |(1<<sun_dyn_AdapterMethodHandle::OP_DUP_ARGS)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
387 |(1<<sun_dyn_AdapterMethodHandle::OP_DROP_ARGS)
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
388 //|(1<<sun_dyn_AdapterMethodHandle::OP_SPREAD_ARGS) //BUG!
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
389 );
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
390 // FIXME: MethodHandlesTest gets a crash if we enable OP_SPREAD_ARGS.
cd5dbf694d45 6939134: JSR 292 adjustments to method handle invocation
jrose
parents: 1506
diff changeset
391 }
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
392
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
393 //------------------------------------------------------------------------------
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
394 // MethodHandles::generate_method_handle_stub
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
395 //
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
396 // Generate an "entry" field for a method handle.
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
397 // This determines how the method handle will respond to calls.
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
398 void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHandles::EntryKind ek, TRAPS) {
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
399 // Here is the register state during an interpreted call,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
400 // as set up by generate_method_handle_interpreter_entry():
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
401 // - G5: garbage temp (was MethodHandle.invoke methodOop, unused)
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
402 // - G3: receiver method handle
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
403 // - O5_savedSP: sender SP (must preserve)
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
404
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
405 const Register O0_argslot = O0;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
406 const Register O1_scratch = O1;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
407 const Register O2_scratch = O2;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
408 const Register O3_scratch = O3;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
409 const Register G5_index = G5;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
410
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
411 // Argument registers for _raise_exception.
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
412 const Register O0_code = O0;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
413 const Register O1_actual = O1;
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
414 const Register O2_required = O2;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
415
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
416 guarantee(java_dyn_MethodHandle::vmentry_offset_in_bytes() != 0, "must have offsets");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
417
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
418 // Some handy addresses:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
419 Address G5_method_fie( G5_method, in_bytes(methodOopDesc::from_interpreted_offset()));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
420
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
421 Address G3_mh_vmtarget( G3_method_handle, java_dyn_MethodHandle::vmtarget_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
422
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
423 Address G3_dmh_vmindex( G3_method_handle, sun_dyn_DirectMethodHandle::vmindex_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
424
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
425 Address G3_bmh_vmargslot( G3_method_handle, sun_dyn_BoundMethodHandle::vmargslot_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
426 Address G3_bmh_argument( G3_method_handle, sun_dyn_BoundMethodHandle::argument_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
427
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
428 Address G3_amh_vmargslot( G3_method_handle, sun_dyn_AdapterMethodHandle::vmargslot_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
429 Address G3_amh_argument ( G3_method_handle, sun_dyn_AdapterMethodHandle::argument_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
430 Address G3_amh_conversion(G3_method_handle, sun_dyn_AdapterMethodHandle::conversion_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
431
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
432 const int java_mirror_offset = klassOopDesc::klass_part_offset_in_bytes() + Klass::java_mirror_offset_in_bytes();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
433
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
434 if (have_entry(ek)) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
435 __ nop(); // empty stubs make SG sick
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
436 return;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
437 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
438
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
439 address interp_entry = __ pc();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
440
1849
5beba6174298 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC
twisti
parents: 1846
diff changeset
441 trace_method_handle(_masm, entry_name(ek));
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
442
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
443 switch ((int) ek) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
444 case _raise_exception:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
445 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
446 // Not a real MH entry, but rather shared code for raising an
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
447 // exception. Since we use a C2I adapter to set up the
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
448 // interpreter state, arguments are expected in compiler
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
449 // argument registers.
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
450 methodHandle mh(raise_exception_method());
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
451 address c2i_entry = methodOopDesc::make_adapters(mh, CATCH);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
452
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
453 __ mov(O5_savedSP, SP); // Cut the stack back to where the caller started.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
454
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
455 Label L_no_method;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
456 // FIXME: fill in _raise_exception_method with a suitable sun.dyn method
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
457 __ set(AddressLiteral((address) &_raise_exception_method), G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
458 __ ld_ptr(Address(G5_method, 0), G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
459 __ tst(G5_method);
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
460 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
461 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
462
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
463 const int jobject_oop_offset = 0;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
464 __ ld_ptr(Address(G5_method, jobject_oop_offset), G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
465 __ tst(G5_method);
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
466 __ brx(Assembler::zero, false, Assembler::pn, L_no_method);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
467 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
468
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
469 __ verify_oop(G5_method);
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
470 __ jump_to(AddressLiteral(c2i_entry), O3_scratch);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
471 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
472
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
473 // If we get here, the Java runtime did not do its job of creating the exception.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
474 // Do something that is at least causes a valid throw from the interpreter.
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
475 __ bind(L_no_method);
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
476 __ unimplemented("call throw_WrongMethodType_entry");
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
477 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
478 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
479
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
480 case _invokestatic_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
481 case _invokespecial_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
482 {
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
483 __ load_heap_oop(G3_mh_vmtarget, G5_method); // target is a methodOop
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
484 __ verify_oop(G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
485 // Same as TemplateTable::invokestatic or invokespecial,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
486 // minus the CP setup and profiling:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
487 if (ek == _invokespecial_mh) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
488 // Must load & check the first argument before entering the target method.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
489 __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
490 __ ld_ptr(__ argument_address(O0_argslot), G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
491 __ null_check(G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
492 __ verify_oop(G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
493 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
494 __ jump_indirect_to(G5_method_fie, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
495 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
496 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
497 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
498
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
499 case _invokevirtual_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
500 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
501 // Same as TemplateTable::invokevirtual,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
502 // minus the CP setup and profiling:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
504 // Pick out the vtable index and receiver offset from the MH,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
505 // and then we can discard it:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
506 __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
507 __ ldsw(G3_dmh_vmindex, G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
508 // Note: The verifier allows us to ignore G3_mh_vmtarget.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
509 __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
510 __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
511
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
512 // Get receiver klass:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
513 Register O0_klass = O0_argslot;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
514 __ load_klass(G3_method_handle, O0_klass);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
515 __ verify_oop(O0_klass);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
516
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
517 // Get target methodOop & entry point:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
518 const int base = instanceKlass::vtable_start_offset() * wordSize;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
519 assert(vtableEntry::size() * wordSize == wordSize, "adjust the scaling in the code below");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
520
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
521 __ sll_ptr(G5_index, LogBytesPerWord, G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
522 __ add(O0_klass, G5_index, O0_klass);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
523 Address vtable_entry_addr(O0_klass, base + vtableEntry::method_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
524 __ ld_ptr(vtable_entry_addr, G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
525
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
526 __ verify_oop(G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
527 __ jump_indirect_to(G5_method_fie, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
528 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
529 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
530 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
531
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
532 case _invokeinterface_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
533 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
534 // Same as TemplateTable::invokeinterface,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
535 // minus the CP setup and profiling:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
536 __ load_method_handle_vmslots(O0_argslot, G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
537 Register O1_intf = O1_scratch;
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
538 __ load_heap_oop(G3_mh_vmtarget, O1_intf);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
539 __ ldsw(G3_dmh_vmindex, G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
540 __ ld_ptr(__ argument_address(O0_argslot, -1), G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
541 __ null_check(G3_method_handle, oopDesc::klass_offset_in_bytes());
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
542
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
543 // Get receiver klass:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
544 Register O0_klass = O0_argslot;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
545 __ load_klass(G3_method_handle, O0_klass);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
546 __ verify_oop(O0_klass);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
547
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
548 // Get interface:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
549 Label no_such_interface;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
550 __ verify_oop(O1_intf);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
551 __ lookup_interface_method(O0_klass, O1_intf,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
552 // Note: next two args must be the same:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
553 G5_index, G5_method,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
554 O2_scratch,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
555 O3_scratch,
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
556 no_such_interface);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
557
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
558 __ verify_oop(G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
559 __ jump_indirect_to(G5_method_fie, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
560 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
561
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
562 __ bind(no_such_interface);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
563 // Throw an exception.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
564 // For historical reasons, it will be IncompatibleClassChangeError.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
565 __ unimplemented("not tested yet");
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
566 __ ld_ptr(Address(O1_intf, java_mirror_offset), O2_required); // required interface
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
567 __ mov( O0_klass, O1_actual); // bad receiver
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
568 __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
569 __ delayed()->mov(Bytecodes::_invokeinterface, O0_code); // who is complaining?
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
570 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
571 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
572
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
573 case _bound_ref_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
574 case _bound_int_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
575 case _bound_long_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
576 case _bound_ref_direct_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
577 case _bound_int_direct_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
578 case _bound_long_direct_mh:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
579 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
580 const bool direct_to_method = (ek >= _bound_ref_direct_mh);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
581 BasicType arg_type = T_ILLEGAL;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
582 int arg_mask = _INSERT_NO_MASK;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
583 int arg_slots = -1;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
584 get_ek_bound_mh_info(ek, arg_type, arg_mask, arg_slots);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
585
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
586 // Make room for the new argument:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
587 __ ldsw(G3_bmh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
588 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
589
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
590 insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, O0_argslot, O1_scratch, O2_scratch, G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
591
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
592 // Store bound argument into the new stack slot:
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
593 __ load_heap_oop(G3_bmh_argument, O1_scratch);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
594 if (arg_type == T_OBJECT) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
595 __ st_ptr(O1_scratch, Address(O0_argslot, 0));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
596 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
597 Address prim_value_addr(O1_scratch, java_lang_boxing_object::value_offset_in_bytes(arg_type));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
598 __ load_sized_value(prim_value_addr, O2_scratch, type2aelembytes(arg_type), is_signed_subword_type(arg_type));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
599 if (arg_slots == 2) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
600 __ unimplemented("not yet tested");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
601 #ifndef _LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
602 __ signx(O2_scratch, O3_scratch); // Sign extend
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
603 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
604 __ st_long(O2_scratch, Address(O0_argslot, 0)); // Uses O2/O3 on !_LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
605 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
606 __ st_ptr( O2_scratch, Address(O0_argslot, 0));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
607 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
608 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
609
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
610 if (direct_to_method) {
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
611 __ load_heap_oop(G3_mh_vmtarget, G5_method); // target is a methodOop
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
612 __ verify_oop(G5_method);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
613 __ jump_indirect_to(G5_method_fie, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
614 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
615 } else {
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
616 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle); // target is a methodOop
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
617 __ verify_oop(G3_method_handle);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
618 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
619 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
620 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
621 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
622
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
623 case _adapter_retype_only:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
624 case _adapter_retype_raw:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
625 // Immediately jump to the next MH layer:
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
626 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
627 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
628 // This is OK when all parameter types widen.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
629 // It is also OK when a return type narrows.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
630 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
631
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
632 case _adapter_check_cast:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
633 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
634 // Temps:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
635 Register G5_klass = G5_index; // Interesting AMH data.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
636
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
637 // Check a reference argument before jumping to the next layer of MH:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
638 __ ldsw(G3_amh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
639 Address vmarg = __ argument_address(O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
640
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
641 // What class are we casting to?
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
642 __ load_heap_oop(G3_amh_argument, G5_klass); // This is a Class object!
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
643 __ load_heap_oop(Address(G5_klass, java_lang_Class::klass_offset_in_bytes()), G5_klass);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
644
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
645 Label done;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
646 __ ld_ptr(vmarg, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
647 __ tst(O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
648 __ brx(Assembler::zero, false, Assembler::pn, done); // No cast if null.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
649 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
650 __ load_klass(O1_scratch, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
651
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
652 // Live at this point:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
653 // - G5_klass : klass required by the target method
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
654 // - O1_scratch : argument klass to test
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
655 // - G3_method_handle: adapter method handle
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
656 __ check_klass_subtype(O1_scratch, G5_klass, O0_argslot, O2_scratch, done);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
657
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
658 // If we get here, the type check failed!
2088
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
659 __ load_heap_oop(G3_amh_argument, O2_required); // required class
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
660 __ ld_ptr( vmarg, O1_actual); // bad object
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
661 __ jump_to(AddressLiteral(from_interpreted_entry(_raise_exception)), O3_scratch);
8d0b933dda2d 7007377: JSR 292 MethodHandlesTest.testCastFailure fails on SPARC with -Xcomp +DeoptimizeALot
twisti
parents: 2009
diff changeset
662 __ delayed()->mov(Bytecodes::_checkcast, O0_code); // who is complaining?
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
663
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
664 __ bind(done);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
665 // Get the new MH:
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
666 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
667 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
668 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
669 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
670
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
671 case _adapter_prim_to_prim:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
672 case _adapter_ref_to_prim:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
673 // Handled completely by optimized cases.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
674 __ stop("init_AdapterMethodHandle should not issue this");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
675 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
676
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
677 case _adapter_opt_i2i: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
678 //case _adapter_opt_f2i: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
679 case _adapter_opt_l2i: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
680 case _adapter_opt_unboxi: // optimized subcase of adapt_ref_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
681 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
682 // Perform an in-place conversion to int or an int subword.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
683 __ ldsw(G3_amh_vmargslot, O0_argslot);
2009
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
684 Address value;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
685 Address vmarg = __ argument_address(O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
686 bool value_left_justified = false;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
687
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
688 switch (ek) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
689 case _adapter_opt_i2i:
1901
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
690 value = vmarg;
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
691 break;
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
692 case _adapter_opt_l2i:
1901
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
693 {
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
694 // just delete the extra slot
2009
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
695 #ifdef _LP64
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
696 // In V9, longs are given 2 64-bit slots in the interpreter, but the
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
697 // data is passed in only 1 slot.
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
698 // Keep the second slot.
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
699 __ add(Gargs, __ argument_offset(O0_argslot, -1), O0_argslot);
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
700 remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch);
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
701 value = Address(O0_argslot, 4); // Get least-significant 32-bit of 64-bit value.
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
702 vmarg = Address(O0_argslot, Interpreter::stackElementSize);
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
703 #else
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
704 // Keep the first slot.
1901
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
705 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
706 remove_arg_slots(_masm, -stack_move_unit(), O0_argslot, O1_scratch, O2_scratch, O3_scratch);
2009
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
707 value = Address(O0_argslot, 0);
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
708 vmarg = value;
b856cd7f4e60 7003798: test/compiler/6991596 fails with true != false
twisti
parents: 1972
diff changeset
709 #endif
1901
7aff5786cc02 6991596: JSR 292 unimplemented adapter_opt_i2i and adapter_opt_l2i on SPARC
twisti
parents: 1849
diff changeset
710 }
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
711 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
712 case _adapter_opt_unboxi:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
713 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
714 // Load the value up from the heap.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
715 __ ld_ptr(vmarg, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
716 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_INT);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
717 #ifdef ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
718 for (int bt = T_BOOLEAN; bt < T_INT; bt++) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
719 if (is_subword_type(BasicType(bt)))
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
720 assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(BasicType(bt)), "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
721 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
722 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
723 __ null_check(O1_scratch, value_offset);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
724 value = Address(O1_scratch, value_offset);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
725 #ifdef _BIG_ENDIAN
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
726 // Values stored in objects are packed.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
727 value_left_justified = true;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
728 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
729 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
730 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
731 default:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
732 ShouldNotReachHere();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
733 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
734
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
735 // This check is required on _BIG_ENDIAN
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
736 Register G5_vminfo = G5_index;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
737 __ ldsw(G3_amh_conversion, G5_vminfo);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
738 assert(CONV_VMINFO_SHIFT == 0, "preshifted");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
739
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
740 // Original 32-bit vmdata word must be of this form:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
741 // | MBZ:6 | signBitCount:8 | srcDstTypes:8 | conversionOp:8 |
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
742 __ lduw(value, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
743 if (!value_left_justified)
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
744 __ sll(O1_scratch, G5_vminfo, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
745 Label zero_extend, done;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
746 __ btst(CONV_VMINFO_SIGN_FLAG, G5_vminfo);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
747 __ br(Assembler::zero, false, Assembler::pn, zero_extend);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
748 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
749
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
750 // this path is taken for int->byte, int->short
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
751 __ sra(O1_scratch, G5_vminfo, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
752 __ ba(false, done);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
753 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
754
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
755 __ bind(zero_extend);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
756 // this is taken for int->char
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
757 __ srl(O1_scratch, G5_vminfo, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
758
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
759 __ bind(done);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
760 __ st(O1_scratch, vmarg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
761
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
762 // Get the new MH:
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
763 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
764 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
765 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
766 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
767
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
768 case _adapter_opt_i2l: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
769 case _adapter_opt_unboxl: // optimized subcase of adapt_ref_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
770 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
771 // Perform an in-place int-to-long or ref-to-long conversion.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
772 __ ldsw(G3_amh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
773
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
774 // On big-endian machine we duplicate the slot and store the MSW
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
775 // in the first slot.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
776 __ add(Gargs, __ argument_offset(O0_argslot, 1), O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
777
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
778 insert_arg_slots(_masm, stack_move_unit(), _INSERT_INT_MASK, O0_argslot, O1_scratch, O2_scratch, G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
779
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
780 Address arg_lsw(O0_argslot, 0);
1506
2338d41fbd81 6943304: remove tagged stack interpreter
twisti
parents: 1503
diff changeset
781 Address arg_msw(O0_argslot, -Interpreter::stackElementSize);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
782
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
783 switch (ek) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
784 case _adapter_opt_i2l:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
785 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
786 __ ldsw(arg_lsw, O2_scratch); // Load LSW
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
787 #ifndef _LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
788 __ signx(O2_scratch, O3_scratch); // Sign extend
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
789 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
790 __ st_long(O2_scratch, arg_msw); // Uses O2/O3 on !_LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
791 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
792 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
793 case _adapter_opt_unboxl:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
794 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
795 // Load the value up from the heap.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
796 __ ld_ptr(arg_lsw, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
797 int value_offset = java_lang_boxing_object::value_offset_in_bytes(T_LONG);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
798 assert(value_offset == java_lang_boxing_object::value_offset_in_bytes(T_DOUBLE), "");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
799 __ null_check(O1_scratch, value_offset);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
800 __ ld_long(Address(O1_scratch, value_offset), O2_scratch); // Uses O2/O3 on !_LP64
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
801 __ st_long(O2_scratch, arg_msw);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
802 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
803 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
804 default:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
805 ShouldNotReachHere();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
806 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
807
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
808 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
809 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
810 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
811 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
812
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
813 case _adapter_opt_f2d: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
814 case _adapter_opt_d2f: // optimized subcase of adapt_prim_to_prim
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
815 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
816 // perform an in-place floating primitive conversion
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
817 __ unimplemented(entry_name(ek));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
818 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
819 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
820
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
821 case _adapter_prim_to_ref:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
822 __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
823 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
824
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
825 case _adapter_swap_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
826 case _adapter_rot_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
827 // handled completely by optimized cases
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
828 __ stop("init_AdapterMethodHandle should not issue this");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
829 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
830
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
831 case _adapter_opt_swap_1:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
832 case _adapter_opt_swap_2:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
833 case _adapter_opt_rot_1_up:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
834 case _adapter_opt_rot_1_down:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
835 case _adapter_opt_rot_2_up:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
836 case _adapter_opt_rot_2_down:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
837 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
838 int swap_bytes = 0, rotate = 0;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
839 get_ek_adapter_opt_swap_rot_info(ek, swap_bytes, rotate);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
840
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
841 // 'argslot' is the position of the first argument to swap.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
842 __ ldsw(G3_amh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
843 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
844
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
845 // 'vminfo' is the second.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
846 Register O1_destslot = O1_scratch;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
847 __ ldsw(G3_amh_conversion, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
848 assert(CONV_VMINFO_SHIFT == 0, "preshifted");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
849 __ and3(O1_destslot, CONV_VMINFO_MASK, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
850 __ add(Gargs, __ argument_offset(O1_destslot), O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
851
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
852 if (!rotate) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
853 for (int i = 0; i < swap_bytes; i += wordSize) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
854 __ ld_ptr(Address(O0_argslot, i), O2_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
855 __ ld_ptr(Address(O1_destslot, i), O3_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
856 __ st_ptr(O3_scratch, Address(O0_argslot, i));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
857 __ st_ptr(O2_scratch, Address(O1_destslot, i));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
858 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
859 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
860 // Save the first chunk, which is going to get overwritten.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
861 switch (swap_bytes) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
862 case 4 : __ lduw(Address(O0_argslot, 0), O2_scratch); break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
863 case 16: __ ldx( Address(O0_argslot, 8), O3_scratch); //fall-thru
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
864 case 8 : __ ldx( Address(O0_argslot, 0), O2_scratch); break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
865 default: ShouldNotReachHere();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
866 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
867
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
868 if (rotate > 0) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
869 // Rorate upward.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
870 __ sub(O0_argslot, swap_bytes, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
871 #if ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
872 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
873 // Verify that argslot > destslot, by at least swap_bytes.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
874 Label L_ok;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
875 __ cmp(O0_argslot, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
876 __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
877 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
878 __ stop("source must be above destination (upward rotation)");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
879 __ bind(L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
880 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
881 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
882 // Work argslot down to destslot, copying contiguous data upwards.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
883 // Pseudo-code:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
884 // argslot = src_addr - swap_bytes
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
885 // destslot = dest_addr
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
886 // while (argslot >= destslot) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
887 // *(argslot + swap_bytes) = *(argslot + 0);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
888 // argslot--;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
889 // }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
890 Label loop;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
891 __ bind(loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
892 __ ld_ptr(Address(O0_argslot, 0), G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
893 __ st_ptr(G5_index, Address(O0_argslot, swap_bytes));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
894 __ sub(O0_argslot, wordSize, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
895 __ cmp(O0_argslot, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
896 __ brx(Assembler::greaterEqualUnsigned, false, Assembler::pt, loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
897 __ delayed()->nop(); // FILLME
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
898 } else {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
899 __ add(O0_argslot, swap_bytes, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
900 #if ASSERT
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
901 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
902 // Verify that argslot < destslot, by at least swap_bytes.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
903 Label L_ok;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
904 __ cmp(O0_argslot, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
905 __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
906 __ delayed()->nop();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
907 __ stop("source must be above destination (upward rotation)");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
908 __ bind(L_ok);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
909 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
910 #endif
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
911 // Work argslot up to destslot, copying contiguous data downwards.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
912 // Pseudo-code:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
913 // argslot = src_addr + swap_bytes
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
914 // destslot = dest_addr
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
915 // while (argslot >= destslot) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
916 // *(argslot - swap_bytes) = *(argslot + 0);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
917 // argslot++;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
918 // }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
919 Label loop;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
920 __ bind(loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
921 __ ld_ptr(Address(O0_argslot, 0), G5_index);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
922 __ st_ptr(G5_index, Address(O0_argslot, -swap_bytes));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
923 __ add(O0_argslot, wordSize, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
924 __ cmp(O0_argslot, O1_destslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
925 __ brx(Assembler::lessEqualUnsigned, false, Assembler::pt, loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
926 __ delayed()->nop(); // FILLME
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
927 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
928
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
929 // Store the original first chunk into the destination slot, now free.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
930 switch (swap_bytes) {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
931 case 4 : __ stw(O2_scratch, Address(O1_destslot, 0)); break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
932 case 16: __ stx(O3_scratch, Address(O1_destslot, 8)); // fall-thru
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
933 case 8 : __ stx(O2_scratch, Address(O1_destslot, 0)); break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
934 default: ShouldNotReachHere();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
935 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
936 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
937
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
938 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
939 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
940 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
941 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
942
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
943 case _adapter_dup_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
944 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
945 // 'argslot' is the position of the first argument to duplicate.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
946 __ ldsw(G3_amh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
947 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
948
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
949 // 'stack_move' is negative number of words to duplicate.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
950 Register G5_stack_move = G5_index;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
951 __ ldsw(G3_amh_conversion, G5_stack_move);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
952 __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
953
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
954 // Remember the old Gargs (argslot[0]).
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
955 Register O1_oldarg = O1_scratch;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
956 __ mov(Gargs, O1_oldarg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
957
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
958 // Move Gargs down to make room for dups.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
959 __ sll_ptr(G5_stack_move, LogBytesPerWord, G5_stack_move);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
960 __ add(Gargs, G5_stack_move, Gargs);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
961
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
962 // Compute the new Gargs (argslot[0]).
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
963 Register O2_newarg = O2_scratch;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
964 __ mov(Gargs, O2_newarg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
965
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
966 // Copy from oldarg[0...] down to newarg[0...]
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
967 // Pseude-code:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
968 // O1_oldarg = old-Gargs
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
969 // O2_newarg = new-Gargs
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
970 // O0_argslot = argslot
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
971 // while (O2_newarg < O1_oldarg) *O2_newarg = *O0_argslot++
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
972 Label loop;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
973 __ bind(loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
974 __ ld_ptr(Address(O0_argslot, 0), O3_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
975 __ st_ptr(O3_scratch, Address(O2_newarg, 0));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
976 __ add(O0_argslot, wordSize, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
977 __ add(O2_newarg, wordSize, O2_newarg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
978 __ cmp(O2_newarg, O1_oldarg);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
979 __ brx(Assembler::less, false, Assembler::pt, loop);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
980 __ delayed()->nop(); // FILLME
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
981
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
982 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
983 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
984 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
985 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
986
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
987 case _adapter_drop_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
988 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
989 // 'argslot' is the position of the first argument to nuke.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
990 __ ldsw(G3_amh_vmargslot, O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
991 __ add(Gargs, __ argument_offset(O0_argslot), O0_argslot);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
992
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
993 // 'stack_move' is number of words to drop.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
994 Register G5_stack_move = G5_index;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
995 __ ldsw(G3_amh_conversion, G5_stack_move);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
996 __ sra(G5_stack_move, CONV_STACK_MOVE_SHIFT, G5_stack_move);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
997
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
998 remove_arg_slots(_masm, G5_stack_move, O0_argslot, O1_scratch, O2_scratch, O3_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
999
1846
d55217dc206f 6829194: JSR 292 needs to support compressed oops
twisti
parents: 1579
diff changeset
1000 __ load_heap_oop(G3_mh_vmtarget, G3_method_handle);
1503
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1001 __ jump_to_method_handle_entry(G3_method_handle, O1_scratch);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1002 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1003 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1004
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1005 case _adapter_collect_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1006 __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1007 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1008
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1009 case _adapter_spread_args:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1010 // Handled completely by optimized cases.
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1011 __ stop("init_AdapterMethodHandle should not issue this");
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1012 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1013
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1014 case _adapter_opt_spread_0:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1015 case _adapter_opt_spread_1:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1016 case _adapter_opt_spread_more:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1017 {
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1018 // spread an array out into a group of arguments
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1019 __ unimplemented(entry_name(ek));
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1020 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1021 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1022
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1023 case _adapter_flyby:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1024 case _adapter_ricochet:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1025 __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1026 break;
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1027
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1028 default:
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1029 ShouldNotReachHere();
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1030 }
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1031
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1032 address me_cookie = MethodHandleEntry::start_compiled_entry(_masm, interp_entry);
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1033 __ unimplemented(entry_name(ek)); // %%% FIXME: NYI
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1034
c640000b7cc1 6829193: JSR 292 needs to support SPARC
twisti
parents: 710
diff changeset
1035 init_entry(ek, MethodHandleEntry::finish_compiled_entry(_masm, me_cookie));
710
e5b0439ef4ae 6655638: dynamic languages need method handles
jrose
parents:
diff changeset
1036 }