8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // Platform-specific definitions for method handles.
26 // These definitions are inlined into class MethodHandles.
27
28 public:
29
30 // The stack just after the recursive call from a ricochet frame
31 // looks something like this. Offsets are marked in words, not bytes.
32 // rsi (r13 on LP64) is part of the interpreter calling sequence
33 // which tells the callee where is my real rsp (for frame walking).
34 // (...lower memory addresses)
35 // rsp: [ return pc ] always the global RicochetBlob::bounce_addr
36 // rsp+1: [ recursive arg N ]
37 // rsp+2: [ recursive arg N-1 ]
38 // ...
39 // rsp+N: [ recursive arg 1 ]
40 // rsp+N+1: [ recursive method handle ]
41 // ...
42 // rbp-6: [ cleanup continuation pc ] <-- (struct RicochetFrame)
43 // rbp-5: [ saved target MH ] the MH we will call on the saved args
44 // rbp-4: [ saved args layout oop ] an int[] array which describes argument layout
45 // rbp-3: [ saved args pointer ] address of transformed adapter arg M (slot 0)
46 // rbp-2: [ conversion ] information about how the return value is used
47 // rbp-1: [ exact sender sp ] exact TOS (rsi/r13) of original sender frame
171 // This value is not used for much, but it apparently must be nonzero.
172 static int frame_size_in_bytes() { return sender_link_offset_in_bytes(); }
173
174 #ifdef ASSERT
175 // The magic number is supposed to help find ricochet frames within the bytes of stack dumps.
176 enum { MAGIC_NUMBER_1 = 0xFEED03E, MAGIC_NUMBER_2 = 0xBEEF03E };
177 static int magic_number_1_offset_in_bytes() { return -wordSize; }
178 static int magic_number_2_offset_in_bytes() { return sizeof(RicochetFrame); }
179 intptr_t magic_number_1() const { return *(intptr_t*)((address)this + magic_number_1_offset_in_bytes()); };
180 intptr_t magic_number_2() const { return *(intptr_t*)((address)this + magic_number_2_offset_in_bytes()); };
181 #endif //ASSERT
182
183 enum { RETURN_VALUE_PLACEHOLDER = (NOT_DEBUG(0) DEBUG_ONLY(42)) };
184
185 static void verify_offsets() NOT_DEBUG_RETURN;
186 void verify() const NOT_DEBUG_RETURN; // check for MAGIC_NUMBER, etc.
187 void zap_arguments() NOT_DEBUG_RETURN;
188
189 static void generate_ricochet_blob(MacroAssembler* _masm,
190 // output params:
191 int* frame_size_in_words, int* bounce_offset, int* exception_offset);
192
193 static void enter_ricochet_frame(MacroAssembler* _masm,
194 Register rcx_recv,
195 Register rax_argv,
196 address return_handler,
197 Register rbx_temp);
198 static void leave_ricochet_frame(MacroAssembler* _masm,
199 Register rcx_recv,
200 Register new_sp_reg,
201 Register sender_pc_reg);
202
203 static Address frame_address(int offset = 0) {
204 // The RicochetFrame is found by subtracting a constant offset from rbp.
205 return Address(rbp, - sender_link_offset_in_bytes() + offset);
206 }
207
208 static RicochetFrame* from_frame(const frame& fr) {
209 address bp = (address) fr.fp();
210 RicochetFrame* rf = (RicochetFrame*)(bp - sender_link_offset_in_bytes());
211 rf->verify();
|
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 // Platform-specific definitions for method handles.
26 // These definitions are inlined into class MethodHandles.
27
28 // Adapters
29 enum /* platform_dependent_constants */ {
30 adapter_code_size = NOT_LP64(30000 DEBUG_ONLY(+ 10000)) LP64_ONLY(80000 DEBUG_ONLY(+ 120000))
31 };
32
33 public:
34
35 // The stack just after the recursive call from a ricochet frame
36 // looks something like this. Offsets are marked in words, not bytes.
37 // rsi (r13 on LP64) is part of the interpreter calling sequence
38 // which tells the callee where is my real rsp (for frame walking).
39 // (...lower memory addresses)
40 // rsp: [ return pc ] always the global RicochetBlob::bounce_addr
41 // rsp+1: [ recursive arg N ]
42 // rsp+2: [ recursive arg N-1 ]
43 // ...
44 // rsp+N: [ recursive arg 1 ]
45 // rsp+N+1: [ recursive method handle ]
46 // ...
47 // rbp-6: [ cleanup continuation pc ] <-- (struct RicochetFrame)
48 // rbp-5: [ saved target MH ] the MH we will call on the saved args
49 // rbp-4: [ saved args layout oop ] an int[] array which describes argument layout
50 // rbp-3: [ saved args pointer ] address of transformed adapter arg M (slot 0)
51 // rbp-2: [ conversion ] information about how the return value is used
52 // rbp-1: [ exact sender sp ] exact TOS (rsi/r13) of original sender frame
176 // This value is not used for much, but it apparently must be nonzero.
177 static int frame_size_in_bytes() { return sender_link_offset_in_bytes(); }
178
179 #ifdef ASSERT
180 // The magic number is supposed to help find ricochet frames within the bytes of stack dumps.
181 enum { MAGIC_NUMBER_1 = 0xFEED03E, MAGIC_NUMBER_2 = 0xBEEF03E };
182 static int magic_number_1_offset_in_bytes() { return -wordSize; }
183 static int magic_number_2_offset_in_bytes() { return sizeof(RicochetFrame); }
184 intptr_t magic_number_1() const { return *(intptr_t*)((address)this + magic_number_1_offset_in_bytes()); };
185 intptr_t magic_number_2() const { return *(intptr_t*)((address)this + magic_number_2_offset_in_bytes()); };
186 #endif //ASSERT
187
188 enum { RETURN_VALUE_PLACEHOLDER = (NOT_DEBUG(0) DEBUG_ONLY(42)) };
189
190 static void verify_offsets() NOT_DEBUG_RETURN;
191 void verify() const NOT_DEBUG_RETURN; // check for MAGIC_NUMBER, etc.
192 void zap_arguments() NOT_DEBUG_RETURN;
193
194 static void generate_ricochet_blob(MacroAssembler* _masm,
195 // output params:
196 int* bounce_offset,
197 int* exception_offset,
198 int* frame_size_in_words);
199
200 static void enter_ricochet_frame(MacroAssembler* _masm,
201 Register rcx_recv,
202 Register rax_argv,
203 address return_handler,
204 Register rbx_temp);
205 static void leave_ricochet_frame(MacroAssembler* _masm,
206 Register rcx_recv,
207 Register new_sp_reg,
208 Register sender_pc_reg);
209
210 static Address frame_address(int offset = 0) {
211 // The RicochetFrame is found by subtracting a constant offset from rbp.
212 return Address(rbp, - sender_link_offset_in_bytes() + offset);
213 }
214
215 static RicochetFrame* from_frame(const frame& fr) {
216 address bp = (address) fr.fp();
217 RicochetFrame* rf = (RicochetFrame*)(bp - sender_link_offset_in_bytes());
218 rf->verify();
|