blob: 9122945df1a99b68fbf97e1a77c3bd4ccb36f673 [file] [log] [blame]
Elliott Hughes2faa5f12012-01-30 14:42:07 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070016
Ian Rogers0cfe1fb2011-08-26 03:29:44 -070017#include <vector>
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070018
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070019#include "calling_convention.h"
Ian Rogers0571d352011-11-03 19:51:38 -070020#include "class_linker.h"
Brian Carlstrom3320cf42011-10-04 14:58:28 -070021#include "compiled_method.h"
Elliott Hughes46f060a2012-03-09 17:36:50 -080022#include "compiler.h"
Elliott Hughes3e778f72012-05-21 15:29:52 -070023#include "disassembler.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070024#include "jni_internal.h"
Brian Carlstrom3320cf42011-10-04 14:58:28 -070025#include "logging.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070026#include "macros.h"
Ian Rogers57b86d42012-03-27 16:05:41 -070027#include "oat/runtime/oat_support_entrypoints.h"
28#include "oat/utils/assembler.h"
29#include "oat/utils/managed_register.h"
Elliott Hughes3e778f72012-05-21 15:29:52 -070030#include "oat/utils/arm/managed_register_arm.h"
jeffhao7fbee072012-08-24 17:56:54 -070031#include "oat/utils/mips/managed_register_mips.h"
Elliott Hughes3e778f72012-05-21 15:29:52 -070032#include "oat/utils/x86/managed_register_x86.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070033#include "thread.h"
Ian Rogers2c8f6532011-09-02 17:16:34 -070034#include "UniquePtr.h"
Ian Rogersb033c752011-07-20 12:22:35 -070035
Elliott Hughes46f060a2012-03-09 17:36:50 -080036#define __ jni_asm->
37
Ian Rogersb033c752011-07-20 12:22:35 -070038namespace art {
39
Ian Rogers00f7d0e2012-07-19 15:28:27 -070040static void CopyParameter(Assembler* jni_asm,
41 ManagedRuntimeCallingConvention* mr_conv,
42 JniCallingConvention* jni_conv,
43 size_t frame_size, size_t out_arg_size);
44static void SetNativeParameter(Assembler* jni_asm,
45 JniCallingConvention* jni_conv,
46 ManagedRegister in_reg);
47
48// Generate the JNI bridge for the given method, general contract:
49// - Arguments are in the managed runtime format, either on stack or in
50// registers, a reference to the method object is supplied as part of this
51// convention.
52//
53CompiledMethod* ArtJniCompileMethodInternal(Compiler& compiler,
54 uint32_t access_flags, uint32_t method_idx,
55 const DexFile& dex_file) {
56 const bool is_native = (access_flags & kAccNative) != 0;
57 CHECK(is_native);
58 const bool is_static = (access_flags & kAccStatic) != 0;
59 const bool is_synchronized = (access_flags & kAccSynchronized) != 0;
60 const char* shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx));
61 InstructionSet instruction_set = compiler.GetInstructionSet();
62 if (instruction_set == kThumb2) {
63 instruction_set = kArm;
Ian Rogers2c8f6532011-09-02 17:16:34 -070064 }
Ian Rogers00f7d0e2012-07-19 15:28:27 -070065 // Calling conventions used to iterate over parameters to method
66 UniquePtr<JniCallingConvention> jni_conv(
67 JniCallingConvention::Create(is_static, is_synchronized, shorty, instruction_set));
68 UniquePtr<ManagedRuntimeCallingConvention> mr_conv(
69 ManagedRuntimeCallingConvention::Create(is_static, is_synchronized, shorty, instruction_set));
70
71 // Assembler that holds generated instructions
72 UniquePtr<Assembler> jni_asm(Assembler::Create(instruction_set));
73 bool should_disassemble = false;
74
75 // Offsets into data structures
76 // TODO: if cross compiling these offsets are for the host not the target
77 const Offset functions(OFFSETOF_MEMBER(JNIEnvExt, functions));
78 const Offset monitor_enter(OFFSETOF_MEMBER(JNINativeInterface, MonitorEnter));
79 const Offset monitor_exit(OFFSETOF_MEMBER(JNINativeInterface, MonitorExit));
80
81 // 1. Build the frame saving all callee saves
82 const size_t frame_size(jni_conv->FrameSize());
83 const std::vector<ManagedRegister>& callee_save_regs = jni_conv->CalleeSaveRegisters();
84 __ BuildFrame(frame_size, mr_conv->MethodRegister(), callee_save_regs, mr_conv->EntrySpills());
85
86 // 2. Set up the StackIndirectReferenceTable
87 mr_conv->ResetIterator(FrameOffset(frame_size));
88 jni_conv->ResetIterator(FrameOffset(0));
89 __ StoreImmediateToFrame(jni_conv->SirtNumRefsOffset(),
90 jni_conv->ReferenceCount(),
91 mr_conv->InterproceduralScratchRegister());
92 __ CopyRawPtrFromThread(jni_conv->SirtLinkOffset(),
93 Thread::TopSirtOffset(),
94 mr_conv->InterproceduralScratchRegister());
95 __ StoreStackOffsetToThread(Thread::TopSirtOffset(),
96 jni_conv->SirtOffset(),
97 mr_conv->InterproceduralScratchRegister());
98
99 // 3. Place incoming reference arguments into SIRT
100 jni_conv->Next(); // Skip JNIEnv*
101 // 3.5. Create Class argument for static methods out of passed method
102 if (is_static) {
103 FrameOffset sirt_offset = jni_conv->CurrentParamSirtEntryOffset();
104 // Check sirt offset is within frame
105 CHECK_LT(sirt_offset.Uint32Value(), frame_size);
106 __ LoadRef(jni_conv->InterproceduralScratchRegister(),
107 mr_conv->MethodRegister(), Method::DeclaringClassOffset());
108 __ VerifyObject(jni_conv->InterproceduralScratchRegister(), false);
109 __ StoreRef(sirt_offset, jni_conv->InterproceduralScratchRegister());
110 jni_conv->Next(); // in SIRT so move to next argument
111 }
112 while (mr_conv->HasNext()) {
113 CHECK(jni_conv->HasNext());
114 bool ref_param = jni_conv->IsCurrentParamAReference();
115 CHECK(!ref_param || mr_conv->IsCurrentParamAReference());
116 // References need placing in SIRT and the entry value passing
117 if (ref_param) {
118 // Compute SIRT entry, note null is placed in the SIRT but its boxed value
119 // must be NULL
120 FrameOffset sirt_offset = jni_conv->CurrentParamSirtEntryOffset();
121 // Check SIRT offset is within frame and doesn't run into the saved segment state
122 CHECK_LT(sirt_offset.Uint32Value(), frame_size);
123 CHECK_NE(sirt_offset.Uint32Value(),
124 jni_conv->SavedLocalReferenceCookieOffset().Uint32Value());
125 bool input_in_reg = mr_conv->IsCurrentParamInRegister();
126 bool input_on_stack = mr_conv->IsCurrentParamOnStack();
127 CHECK(input_in_reg || input_on_stack);
128
129 if (input_in_reg) {
130 ManagedRegister in_reg = mr_conv->CurrentParamRegister();
131 __ VerifyObject(in_reg, mr_conv->IsCurrentArgPossiblyNull());
132 __ StoreRef(sirt_offset, in_reg);
133 } else if (input_on_stack) {
134 FrameOffset in_off = mr_conv->CurrentParamStackOffset();
135 __ VerifyObject(in_off, mr_conv->IsCurrentArgPossiblyNull());
136 __ CopyRef(sirt_offset, in_off,
137 mr_conv->InterproceduralScratchRegister());
138 }
139 }
140 mr_conv->Next();
141 jni_conv->Next();
142 }
143
144 // 4. Write out the end of the quick frames.
145 __ StoreStackPointerToThread(Thread::TopOfManagedStackOffset());
146 __ StoreImmediateToThread(Thread::TopOfManagedStackPcOffset(), 0,
147 mr_conv->InterproceduralScratchRegister());
148
149 // 5. Move frame down to allow space for out going args.
150 const size_t out_arg_size = jni_conv->OutArgSize();
151 __ IncreaseFrameSize(out_arg_size);
152
153
154 // 6. Call into appropriate JniMethodStart passing Thread* so that transition out of Runnable
155 // can occur. The result is the saved JNI local state that is restored by the exit call. We
156 // abuse the JNI calling convention here, that is guaranteed to support passing 2 pointer
157 // arguments.
158 uintptr_t jni_start = is_synchronized ? ENTRYPOINT_OFFSET(pJniMethodStartSynchronized)
159 : ENTRYPOINT_OFFSET(pJniMethodStart);
160 jni_conv->ResetIterator(FrameOffset(out_arg_size));
161 FrameOffset locked_object_sirt_offset(0);
162 if (is_synchronized) {
163 // Pass object for locking.
164 jni_conv->Next(); // Skip JNIEnv.
165 locked_object_sirt_offset = jni_conv->CurrentParamSirtEntryOffset();
166 jni_conv->ResetIterator(FrameOffset(out_arg_size));
167 if (jni_conv->IsCurrentParamOnStack()) {
168 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
169 __ CreateSirtEntry(out_off, locked_object_sirt_offset,
170 mr_conv->InterproceduralScratchRegister(),
171 false);
172 } else {
173 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
174 __ CreateSirtEntry(out_reg, locked_object_sirt_offset,
175 ManagedRegister::NoRegister(), false);
176 }
177 jni_conv->Next();
178 }
179 if (jni_conv->IsCurrentParamInRegister()) {
180 __ GetCurrentThread(jni_conv->CurrentParamRegister());
181 __ Call(jni_conv->CurrentParamRegister(), Offset(jni_start),
182 jni_conv->InterproceduralScratchRegister());
183 } else {
184 __ GetCurrentThread(jni_conv->CurrentParamStackOffset(),
185 jni_conv->InterproceduralScratchRegister());
186 __ Call(ThreadOffset(jni_start), jni_conv->InterproceduralScratchRegister());
187 }
188 if (is_synchronized) { // Check for exceptions from monitor enter.
189 __ ExceptionPoll(jni_conv->InterproceduralScratchRegister(), out_arg_size);
190 }
191 FrameOffset saved_cookie_offset = jni_conv->SavedLocalReferenceCookieOffset();
192 __ Store(saved_cookie_offset, jni_conv->IntReturnRegister(), 4);
193
194 // 7. Iterate over arguments placing values from managed calling convention in
195 // to the convention required for a native call (shuffling). For references
196 // place an index/pointer to the reference after checking whether it is
197 // NULL (which must be encoded as NULL).
198 // Note: we do this prior to materializing the JNIEnv* and static's jclass to
199 // give as many free registers for the shuffle as possible
200 mr_conv->ResetIterator(FrameOffset(frame_size+out_arg_size));
201 uint32_t args_count = 0;
202 while (mr_conv->HasNext()) {
203 args_count++;
204 mr_conv->Next();
205 }
206
207 // Do a backward pass over arguments, so that the generated code will be "mov
208 // R2, R3; mov R1, R2" instead of "mov R1, R2; mov R2, R3."
209 // TODO: A reverse iterator to improve readability.
210 for (uint32_t i = 0; i < args_count; ++i) {
211 mr_conv->ResetIterator(FrameOffset(frame_size + out_arg_size));
212 jni_conv->ResetIterator(FrameOffset(out_arg_size));
213 jni_conv->Next(); // Skip JNIEnv*.
214 if (is_static) {
215 jni_conv->Next(); // Skip Class for now.
216 }
217 // Skip to the argument we're interested in.
218 for (uint32_t j = 0; j < args_count - i - 1; ++j) {
219 mr_conv->Next();
220 jni_conv->Next();
221 }
222 CopyParameter(jni_asm.get(), mr_conv.get(), jni_conv.get(), frame_size, out_arg_size);
223 }
224 if (is_static) {
225 // Create argument for Class
226 mr_conv->ResetIterator(FrameOffset(frame_size+out_arg_size));
227 jni_conv->ResetIterator(FrameOffset(out_arg_size));
228 jni_conv->Next(); // Skip JNIEnv*
229 FrameOffset sirt_offset = jni_conv->CurrentParamSirtEntryOffset();
230 if (jni_conv->IsCurrentParamOnStack()) {
231 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
232 __ CreateSirtEntry(out_off, sirt_offset,
233 mr_conv->InterproceduralScratchRegister(),
234 false);
235 } else {
236 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
237 __ CreateSirtEntry(out_reg, sirt_offset,
238 ManagedRegister::NoRegister(), false);
239 }
240 }
241
242 // 8. Create 1st argument, the JNI environment ptr.
243 jni_conv->ResetIterator(FrameOffset(out_arg_size));
244 // Register that will hold local indirect reference table
245 if (jni_conv->IsCurrentParamInRegister()) {
246 ManagedRegister jni_env = jni_conv->CurrentParamRegister();
247 DCHECK(!jni_env.Equals(jni_conv->InterproceduralScratchRegister()));
248 __ LoadRawPtrFromThread(jni_env, Thread::JniEnvOffset());
249 } else {
250 FrameOffset jni_env = jni_conv->CurrentParamStackOffset();
251 __ CopyRawPtrFromThread(jni_env, Thread::JniEnvOffset(),
252 jni_conv->InterproceduralScratchRegister());
253 }
254
255 // 9. Plant call to native code associated with method.
256 __ Call(jni_conv->MethodStackOffset(), Method::NativeMethodOffset(),
257 mr_conv->InterproceduralScratchRegister());
258
259 // 10. Fix differences in result widths.
260 if (instruction_set == kX86) {
261 if (jni_conv->GetReturnType() == Primitive::kPrimByte ||
262 jni_conv->GetReturnType() == Primitive::kPrimShort) {
263 __ SignExtend(jni_conv->ReturnRegister(),
264 Primitive::ComponentSize(jni_conv->GetReturnType()));
265 } else if (jni_conv->GetReturnType() == Primitive::kPrimBoolean ||
266 jni_conv->GetReturnType() == Primitive::kPrimChar) {
267 __ ZeroExtend(jni_conv->ReturnRegister(),
268 Primitive::ComponentSize(jni_conv->GetReturnType()));
269 }
270 }
271
272 // 11. Save return value
273 bool reference_return = jni_conv->IsReturnAReference();
274 FrameOffset return_save_location = jni_conv->ReturnValueSaveLocation();
275 if (jni_conv->SizeOfReturnValue() != 0 && !reference_return) {
276 CHECK_LT(return_save_location.Uint32Value(), frame_size+out_arg_size);
277 __ Store(return_save_location, jni_conv->ReturnRegister(), jni_conv->SizeOfReturnValue());
278 }
279
280 // 12. Call into JNI method end possibly passing a returned reference, the method and the current
281 // thread.
282 {
283 // Modify iterator for call, important offsets were saved above.
284 size_t jni_end_arg_count = 0;
285 if (reference_return) { jni_end_arg_count++; }
286 if (is_synchronized) { jni_end_arg_count++; }
287 const char* jni_end_shorty = jni_end_arg_count == 0 ? "I"
288 : (jni_end_arg_count == 1 ? "II" : "III");
289 jni_conv.reset(JniCallingConvention::Create(is_static, is_synchronized, jni_end_shorty,
290 instruction_set));
291 // Ensure out arguments will fit in space taken before (we expect this due to stack alignment).
292 size_t jni_end_out_arg_size = jni_conv->OutArgSize();
293 CHECK_LE(jni_end_out_arg_size, out_arg_size);
294 jni_conv->ResetIterator(FrameOffset(jni_end_out_arg_size));
295 }
296 uintptr_t jni_end;
297 if (reference_return) {
298 // Pass result.
299 jni_end = is_synchronized ? ENTRYPOINT_OFFSET(pJniMethodEndWithReferenceSynchronized)
300 : ENTRYPOINT_OFFSET(pJniMethodEndWithReference);
301 SetNativeParameter(jni_asm.get(), jni_conv.get(), jni_conv->ReturnRegister());
302 jni_conv->Next();
303 } else {
304 jni_end = is_synchronized ? ENTRYPOINT_OFFSET(pJniMethodEndSynchronized)
305 : ENTRYPOINT_OFFSET(pJniMethodEnd);
306 }
307 // Pass saved local reference state.
308 if (jni_conv->IsCurrentParamOnStack()) {
309 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
310 __ Copy(out_off, saved_cookie_offset, jni_conv->InterproceduralScratchRegister(), 4);
311 } else {
312 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
313 __ Load(out_reg, saved_cookie_offset, 4);
314 }
315 jni_conv->Next();
316 if (is_synchronized) {
317 // Pass object for unlocking.
318 if (jni_conv->IsCurrentParamOnStack()) {
319 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
320 __ CreateSirtEntry(out_off, locked_object_sirt_offset,
321 jni_conv->InterproceduralScratchRegister(),
322 false);
323 } else {
324 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
325 __ CreateSirtEntry(out_reg, locked_object_sirt_offset,
326 ManagedRegister::NoRegister(), false);
327 }
328 jni_conv->Next();
329 }
330 if (jni_conv->IsCurrentParamInRegister()) {
331 __ GetCurrentThread(jni_conv->CurrentParamRegister());
332 __ Call(jni_conv->CurrentParamRegister(), Offset(jni_end),
333 jni_conv->InterproceduralScratchRegister());
334 } else {
335 __ GetCurrentThread(jni_conv->CurrentParamStackOffset(),
336 jni_conv->InterproceduralScratchRegister());
337 __ Call(ThreadOffset(jni_end), jni_conv->InterproceduralScratchRegister());
338 }
339
340 // 13. Reload return value
341 if (jni_conv->SizeOfReturnValue() != 0 && !reference_return) {
342 __ Load(mr_conv->ReturnRegister(), return_save_location, mr_conv->SizeOfReturnValue());
343 }
344
345 // 14. Move frame up now we're done with the out arg space.
346 __ DecreaseFrameSize(out_arg_size);
347
348 // 15. Process pending exceptions from JNI call or monitor exit.
349 __ ExceptionPoll(jni_conv->InterproceduralScratchRegister(), 0);
350
351 // 16. Remove activation - no need to restore callee save registers because we didn't clobber
352 // them.
353 __ RemoveFrame(frame_size, std::vector<ManagedRegister>());
354
355 // 17. Finalize code generation
356 __ EmitSlowPaths();
357 size_t cs = __ CodeSize();
358 std::vector<uint8_t> managed_code(cs);
359 MemoryRegion code(&managed_code[0], managed_code.size());
360 __ FinalizeInstructions(code);
361 if (should_disassemble) {
362 UniquePtr<Disassembler> disassembler(Disassembler::Create(instruction_set));
363 disassembler->Dump(LOG(INFO), &managed_code[0], &managed_code[managed_code.size()]);
364 }
365 return new CompiledMethod(instruction_set,
366 managed_code,
367 frame_size,
368 jni_conv->CoreSpillMask(),
369 jni_conv->FpSpillMask());
Ian Rogers2c8f6532011-09-02 17:16:34 -0700370}
371
Elliott Hughes46f060a2012-03-09 17:36:50 -0800372// Copy a single parameter from the managed to the JNI calling convention
373static void CopyParameter(Assembler* jni_asm,
374 ManagedRuntimeCallingConvention* mr_conv,
375 JniCallingConvention* jni_conv,
376 size_t frame_size, size_t out_arg_size) {
377 bool input_in_reg = mr_conv->IsCurrentParamInRegister();
378 bool output_in_reg = jni_conv->IsCurrentParamInRegister();
379 FrameOffset sirt_offset(0);
380 bool null_allowed = false;
381 bool ref_param = jni_conv->IsCurrentParamAReference();
382 CHECK(!ref_param || mr_conv->IsCurrentParamAReference());
383 // input may be in register, on stack or both - but not none!
384 CHECK(input_in_reg || mr_conv->IsCurrentParamOnStack());
385 if (output_in_reg) { // output shouldn't straddle registers and stack
386 CHECK(!jni_conv->IsCurrentParamOnStack());
387 } else {
388 CHECK(jni_conv->IsCurrentParamOnStack());
389 }
390 // References need placing in SIRT and the entry address passing
391 if (ref_param) {
392 null_allowed = mr_conv->IsCurrentArgPossiblyNull();
393 // Compute SIRT offset. Note null is placed in the SIRT but the jobject
394 // passed to the native code must be null (not a pointer into the SIRT
395 // as with regular references).
396 sirt_offset = jni_conv->CurrentParamSirtEntryOffset();
397 // Check SIRT offset is within frame.
398 CHECK_LT(sirt_offset.Uint32Value(), (frame_size + out_arg_size));
399 }
400 if (input_in_reg && output_in_reg) {
401 ManagedRegister in_reg = mr_conv->CurrentParamRegister();
402 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
403 if (ref_param) {
404 __ CreateSirtEntry(out_reg, sirt_offset, in_reg, null_allowed);
405 } else {
406 if (!mr_conv->IsCurrentParamOnStack()) {
407 // regular non-straddling move
Ian Rogersb5d09b22012-03-06 22:14:17 -0800408 __ Move(out_reg, in_reg, mr_conv->CurrentParamSize());
Elliott Hughes46f060a2012-03-09 17:36:50 -0800409 } else {
410 UNIMPLEMENTED(FATAL); // we currently don't expect to see this case
411 }
412 }
413 } else if (!input_in_reg && !output_in_reg) {
414 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
415 if (ref_param) {
416 __ CreateSirtEntry(out_off, sirt_offset, mr_conv->InterproceduralScratchRegister(),
417 null_allowed);
418 } else {
419 FrameOffset in_off = mr_conv->CurrentParamStackOffset();
420 size_t param_size = mr_conv->CurrentParamSize();
421 CHECK_EQ(param_size, jni_conv->CurrentParamSize());
422 __ Copy(out_off, in_off, mr_conv->InterproceduralScratchRegister(), param_size);
423 }
424 } else if (!input_in_reg && output_in_reg) {
425 FrameOffset in_off = mr_conv->CurrentParamStackOffset();
426 ManagedRegister out_reg = jni_conv->CurrentParamRegister();
427 // Check that incoming stack arguments are above the current stack frame.
428 CHECK_GT(in_off.Uint32Value(), frame_size);
429 if (ref_param) {
430 __ CreateSirtEntry(out_reg, sirt_offset, ManagedRegister::NoRegister(), null_allowed);
431 } else {
432 size_t param_size = mr_conv->CurrentParamSize();
433 CHECK_EQ(param_size, jni_conv->CurrentParamSize());
434 __ Load(out_reg, in_off, param_size);
435 }
436 } else {
437 CHECK(input_in_reg && !output_in_reg);
438 ManagedRegister in_reg = mr_conv->CurrentParamRegister();
439 FrameOffset out_off = jni_conv->CurrentParamStackOffset();
440 // Check outgoing argument is within frame
441 CHECK_LT(out_off.Uint32Value(), frame_size);
442 if (ref_param) {
443 // TODO: recycle value in in_reg rather than reload from SIRT
444 __ CreateSirtEntry(out_off, sirt_offset, mr_conv->InterproceduralScratchRegister(),
445 null_allowed);
446 } else {
447 size_t param_size = mr_conv->CurrentParamSize();
448 CHECK_EQ(param_size, jni_conv->CurrentParamSize());
449 if (!mr_conv->IsCurrentParamOnStack()) {
450 // regular non-straddling store
451 __ Store(out_off, in_reg, param_size);
452 } else {
453 // store where input straddles registers and stack
454 CHECK_EQ(param_size, 8u);
455 FrameOffset in_off = mr_conv->CurrentParamStackOffset();
456 __ StoreSpanning(out_off, in_reg, in_off, mr_conv->InterproceduralScratchRegister());
457 }
458 }
459 }
460}
461
462static void SetNativeParameter(Assembler* jni_asm,
463 JniCallingConvention* jni_conv,
464 ManagedRegister in_reg) {
465 if (jni_conv->IsCurrentParamOnStack()) {
466 FrameOffset dest = jni_conv->CurrentParamStackOffset();
467 __ StoreRawPtr(dest, in_reg);
468 } else {
469 if (!jni_conv->CurrentParamRegister().Equals(in_reg)) {
Ian Rogersb5d09b22012-03-06 22:14:17 -0800470 __ Move(jni_conv->CurrentParamRegister(), in_reg, jni_conv->CurrentParamSize());
Elliott Hughes46f060a2012-03-09 17:36:50 -0800471 }
472 }
473}
Ian Rogers2c8f6532011-09-02 17:16:34 -0700474
Ian Rogersb033c752011-07-20 12:22:35 -0700475} // namespace art
Elliott Hughes46f060a2012-03-09 17:36:50 -0800476
477extern "C" art::CompiledMethod* ArtJniCompileMethod(art::Compiler& compiler,
478 uint32_t access_flags, uint32_t method_idx,
Elliott Hughes46f060a2012-03-09 17:36:50 -0800479 const art::DexFile& dex_file) {
Ian Rogers57b86d42012-03-27 16:05:41 -0700480 return ArtJniCompileMethodInternal(compiler, access_flags, method_idx, dex_file);
Elliott Hughes46f060a2012-03-09 17:36:50 -0800481}