OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 // If needed, restore wanted bits of FPSCR. | 726 // If needed, restore wanted bits of FPSCR. |
727 Label fpscr_done; | 727 Label fpscr_done; |
728 vmrs(scratch); | 728 vmrs(scratch); |
729 tst(scratch, Operand(kVFPDefaultNaNModeControlBit)); | 729 tst(scratch, Operand(kVFPDefaultNaNModeControlBit)); |
730 b(ne, &fpscr_done); | 730 b(ne, &fpscr_done); |
731 orr(scratch, scratch, Operand(kVFPDefaultNaNModeControlBit)); | 731 orr(scratch, scratch, Operand(kVFPDefaultNaNModeControlBit)); |
732 vmsr(scratch); | 732 vmsr(scratch); |
733 bind(&fpscr_done); | 733 bind(&fpscr_done); |
734 } | 734 } |
735 | 735 |
736 | 736 void MacroAssembler::VFPCanonicalizeNaN(const DwVfpRegister value, |
737 void MacroAssembler::VFPCanonicalizeNaN(const DwVfpRegister dst, | |
738 const DwVfpRegister src, | |
739 const Condition cond) { | 737 const Condition cond) { |
740 vsub(dst, src, kDoubleRegZero, cond); | 738 vsub(value, value, kDoubleRegZero, cond); |
741 } | 739 } |
742 | 740 |
743 | 741 |
744 void MacroAssembler::VFPCompareAndSetFlags(const DwVfpRegister src1, | 742 void MacroAssembler::VFPCompareAndSetFlags(const DwVfpRegister src1, |
745 const DwVfpRegister src2, | 743 const DwVfpRegister src2, |
746 const Condition cond) { | 744 const Condition cond) { |
747 // Compare and move FPSCR flags to the normal condition flags. | 745 // Compare and move FPSCR flags to the normal condition flags. |
748 VFPCompareAndLoadFlags(src1, src2, pc, cond); | 746 VFPCompareAndLoadFlags(src1, src2, pc, cond); |
749 } | 747 } |
750 | 748 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 // If we are using the simulator then we should always align to the expected | 1013 // If we are using the simulator then we should always align to the expected |
1016 // alignment. As the simulator is used to generate snapshots we do not know | 1014 // alignment. As the simulator is used to generate snapshots we do not know |
1017 // if the target platform will need alignment, so this is controlled from a | 1015 // if the target platform will need alignment, so this is controlled from a |
1018 // flag. | 1016 // flag. |
1019 return FLAG_sim_stack_alignment; | 1017 return FLAG_sim_stack_alignment; |
1020 #endif // V8_HOST_ARCH_ARM | 1018 #endif // V8_HOST_ARCH_ARM |
1021 } | 1019 } |
1022 | 1020 |
1023 | 1021 |
1024 void MacroAssembler::LeaveExitFrame(bool save_doubles, | 1022 void MacroAssembler::LeaveExitFrame(bool save_doubles, |
1025 Register argument_count, | 1023 Register argument_count) { |
1026 bool restore_context) { | |
1027 // Optionally restore all double registers. | 1024 // Optionally restore all double registers. |
1028 if (save_doubles) { | 1025 if (save_doubles) { |
1029 // Calculate the stack location of the saved doubles and restore them. | 1026 // Calculate the stack location of the saved doubles and restore them. |
1030 const int offset = 2 * kPointerSize; | 1027 const int offset = 2 * kPointerSize; |
1031 sub(r3, fp, | 1028 sub(r3, fp, |
1032 Operand(offset + DwVfpRegister::kMaxNumRegisters * kDoubleSize)); | 1029 Operand(offset + DwVfpRegister::kMaxNumRegisters * kDoubleSize)); |
1033 RestoreFPRegs(r3, ip); | 1030 RestoreFPRegs(r3, ip); |
1034 } | 1031 } |
1035 | 1032 |
1036 // Clear top frame. | 1033 // Clear top frame. |
1037 mov(r3, Operand::Zero()); | 1034 mov(r3, Operand::Zero()); |
1038 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 1035 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
1039 str(r3, MemOperand(ip)); | 1036 str(r3, MemOperand(ip)); |
1040 | 1037 |
1041 | |
1042 // Restore current context from top and clear it in debug mode. | 1038 // Restore current context from top and clear it in debug mode. |
1043 if (restore_context) { | 1039 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
1044 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 1040 ldr(cp, MemOperand(ip)); |
1045 ldr(cp, MemOperand(ip)); | |
1046 } | |
1047 #ifdef DEBUG | 1041 #ifdef DEBUG |
1048 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | |
1049 str(r3, MemOperand(ip)); | 1042 str(r3, MemOperand(ip)); |
1050 #endif | 1043 #endif |
1051 | 1044 |
1052 // Tear down the exit frame, pop the arguments, and return. | 1045 // Tear down the exit frame, pop the arguments, and return. |
1053 mov(sp, Operand(fp)); | 1046 mov(sp, Operand(fp)); |
1054 ldm(ia_w, sp, fp.bit() | lr.bit()); | 1047 ldm(ia_w, sp, fp.bit() | lr.bit()); |
1055 if (argument_count.is_valid()) { | 1048 if (argument_count.is_valid()) { |
1056 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); | 1049 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); |
1057 } | 1050 } |
1058 } | 1051 } |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 stub->CompilingCallsToThisStubIsGCSafe(isolate())); | 2273 stub->CompilingCallsToThisStubIsGCSafe(isolate())); |
2281 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, cond); | 2274 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, cond); |
2282 } | 2275 } |
2283 | 2276 |
2284 | 2277 |
2285 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 2278 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
2286 return ref0.address() - ref1.address(); | 2279 return ref0.address() - ref1.address(); |
2287 } | 2280 } |
2288 | 2281 |
2289 | 2282 |
2290 void MacroAssembler::CallApiFunctionAndReturn( | 2283 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
2291 ExternalReference function, | 2284 Address function_address, |
2292 Address function_address, | 2285 ExternalReference thunk_ref, |
2293 ExternalReference thunk_ref, | 2286 Register thunk_last_arg, |
2294 Register thunk_last_arg, | 2287 int stack_space, |
2295 int stack_space, | 2288 int return_value_offset) { |
2296 MemOperand return_value_operand, | |
2297 MemOperand* context_restore_operand) { | |
2298 ExternalReference next_address = | 2289 ExternalReference next_address = |
2299 ExternalReference::handle_scope_next_address(isolate()); | 2290 ExternalReference::handle_scope_next_address(isolate()); |
2300 const int kNextOffset = 0; | 2291 const int kNextOffset = 0; |
2301 const int kLimitOffset = AddressOffset( | 2292 const int kLimitOffset = AddressOffset( |
2302 ExternalReference::handle_scope_limit_address(isolate()), | 2293 ExternalReference::handle_scope_limit_address(isolate()), |
2303 next_address); | 2294 next_address); |
2304 const int kLevelOffset = AddressOffset( | 2295 const int kLevelOffset = AddressOffset( |
2305 ExternalReference::handle_scope_level_address(isolate()), | 2296 ExternalReference::handle_scope_level_address(isolate()), |
2306 next_address); | 2297 next_address); |
2307 | 2298 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2351 if (FLAG_log_timer_events) { | 2342 if (FLAG_log_timer_events) { |
2352 FrameScope frame(this, StackFrame::MANUAL); | 2343 FrameScope frame(this, StackFrame::MANUAL); |
2353 PushSafepointRegisters(); | 2344 PushSafepointRegisters(); |
2354 PrepareCallCFunction(1, r0); | 2345 PrepareCallCFunction(1, r0); |
2355 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2346 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); |
2356 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); | 2347 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
2357 PopSafepointRegisters(); | 2348 PopSafepointRegisters(); |
2358 } | 2349 } |
2359 | 2350 |
2360 Label promote_scheduled_exception; | 2351 Label promote_scheduled_exception; |
2361 Label exception_handled; | |
2362 Label delete_allocated_handles; | 2352 Label delete_allocated_handles; |
2363 Label leave_exit_frame; | 2353 Label leave_exit_frame; |
2364 Label return_value_loaded; | 2354 Label return_value_loaded; |
2365 | 2355 |
2366 // load value from ReturnValue | 2356 // load value from ReturnValue |
2367 ldr(r0, return_value_operand); | 2357 ldr(r0, MemOperand(fp, return_value_offset*kPointerSize)); |
2368 bind(&return_value_loaded); | 2358 bind(&return_value_loaded); |
2369 // No more valid handles (the result handle was the last one). Restore | 2359 // No more valid handles (the result handle was the last one). Restore |
2370 // previous handle scope. | 2360 // previous handle scope. |
2371 str(r4, MemOperand(r7, kNextOffset)); | 2361 str(r4, MemOperand(r7, kNextOffset)); |
2372 if (emit_debug_code()) { | 2362 if (emit_debug_code()) { |
2373 ldr(r1, MemOperand(r7, kLevelOffset)); | 2363 ldr(r1, MemOperand(r7, kLevelOffset)); |
2374 cmp(r1, r6); | 2364 cmp(r1, r6); |
2375 Check(eq, kUnexpectedLevelAfterReturnFromApiCall); | 2365 Check(eq, kUnexpectedLevelAfterReturnFromApiCall); |
2376 } | 2366 } |
2377 sub(r6, r6, Operand(1)); | 2367 sub(r6, r6, Operand(1)); |
2378 str(r6, MemOperand(r7, kLevelOffset)); | 2368 str(r6, MemOperand(r7, kLevelOffset)); |
2379 ldr(ip, MemOperand(r7, kLimitOffset)); | 2369 ldr(ip, MemOperand(r7, kLimitOffset)); |
2380 cmp(r5, ip); | 2370 cmp(r5, ip); |
2381 b(ne, &delete_allocated_handles); | 2371 b(ne, &delete_allocated_handles); |
2382 | 2372 |
2383 // Check if the function scheduled an exception. | 2373 // Check if the function scheduled an exception. |
2384 bind(&leave_exit_frame); | 2374 bind(&leave_exit_frame); |
2385 LoadRoot(r4, Heap::kTheHoleValueRootIndex); | 2375 LoadRoot(r4, Heap::kTheHoleValueRootIndex); |
2386 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate()))); | 2376 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate()))); |
2387 ldr(r5, MemOperand(ip)); | 2377 ldr(r5, MemOperand(ip)); |
2388 cmp(r4, r5); | 2378 cmp(r4, r5); |
2389 b(ne, &promote_scheduled_exception); | 2379 b(ne, &promote_scheduled_exception); |
2390 bind(&exception_handled); | |
2391 | 2380 |
2392 bool restore_context = context_restore_operand != NULL; | |
2393 if (restore_context) { | |
2394 ldr(cp, *context_restore_operand); | |
2395 } | |
2396 // LeaveExitFrame expects unwind space to be in a register. | 2381 // LeaveExitFrame expects unwind space to be in a register. |
2397 mov(r4, Operand(stack_space)); | 2382 mov(r4, Operand(stack_space)); |
2398 LeaveExitFrame(false, r4, !restore_context); | 2383 LeaveExitFrame(false, r4); |
2399 mov(pc, lr); | 2384 mov(pc, lr); |
2400 | 2385 |
2401 bind(&promote_scheduled_exception); | 2386 bind(&promote_scheduled_exception); |
2402 { | 2387 TailCallExternalReference( |
2403 FrameScope frame(this, StackFrame::INTERNAL); | 2388 ExternalReference(Runtime::kPromoteScheduledException, isolate()), |
2404 CallExternalReference( | 2389 0, |
2405 ExternalReference(Runtime::kPromoteScheduledException, isolate()), | 2390 1); |
2406 0); | |
2407 } | |
2408 jmp(&exception_handled); | |
2409 | 2391 |
2410 // HandleScope limit has changed. Delete allocated extensions. | 2392 // HandleScope limit has changed. Delete allocated extensions. |
2411 bind(&delete_allocated_handles); | 2393 bind(&delete_allocated_handles); |
2412 str(r5, MemOperand(r7, kLimitOffset)); | 2394 str(r5, MemOperand(r7, kLimitOffset)); |
2413 mov(r4, r0); | 2395 mov(r4, r0); |
2414 PrepareCallCFunction(1, r5); | 2396 PrepareCallCFunction(1, r5); |
2415 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); | 2397 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); |
2416 CallCFunction( | 2398 CallCFunction( |
2417 ExternalReference::delete_handle_scope_extensions(isolate()), 1); | 2399 ExternalReference::delete_handle_scope_extensions(isolate()), 1); |
2418 mov(r0, r4); | 2400 mov(r0, r4); |
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3902 void CodePatcher::EmitCondition(Condition cond) { | 3884 void CodePatcher::EmitCondition(Condition cond) { |
3903 Instr instr = Assembler::instr_at(masm_.pc_); | 3885 Instr instr = Assembler::instr_at(masm_.pc_); |
3904 instr = (instr & ~kCondMask) | cond; | 3886 instr = (instr & ~kCondMask) | cond; |
3905 masm_.emit(instr); | 3887 masm_.emit(instr); |
3906 } | 3888 } |
3907 | 3889 |
3908 | 3890 |
3909 } } // namespace v8::internal | 3891 } } // namespace v8::internal |
3910 | 3892 |
3911 #endif // V8_TARGET_ARCH_ARM | 3893 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |