Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 23903053: reland 16744: add context save for GenerateFastApiCall (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm/stub-cache-arm.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after
1013 // 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
1014 // 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
1015 // 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
1016 // flag. 1016 // flag.
1017 return FLAG_sim_stack_alignment; 1017 return FLAG_sim_stack_alignment;
1018 #endif // V8_HOST_ARCH_ARM 1018 #endif // V8_HOST_ARCH_ARM
1019 } 1019 }
1020 1020
1021 1021
1022 void MacroAssembler::LeaveExitFrame(bool save_doubles, 1022 void MacroAssembler::LeaveExitFrame(bool save_doubles,
1023 Register argument_count) { 1023 Register argument_count,
1024 bool restore_context) {
1024 // Optionally restore all double registers. 1025 // Optionally restore all double registers.
1025 if (save_doubles) { 1026 if (save_doubles) {
1026 // Calculate the stack location of the saved doubles and restore them. 1027 // Calculate the stack location of the saved doubles and restore them.
1027 const int offset = 2 * kPointerSize; 1028 const int offset = 2 * kPointerSize;
1028 sub(r3, fp, 1029 sub(r3, fp,
1029 Operand(offset + DwVfpRegister::kMaxNumRegisters * kDoubleSize)); 1030 Operand(offset + DwVfpRegister::kMaxNumRegisters * kDoubleSize));
1030 RestoreFPRegs(r3, ip); 1031 RestoreFPRegs(r3, ip);
1031 } 1032 }
1032 1033
1033 // Clear top frame. 1034 // Clear top frame.
1034 mov(r3, Operand::Zero()); 1035 mov(r3, Operand::Zero());
1035 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); 1036 mov(ip, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate())));
1036 str(r3, MemOperand(ip)); 1037 str(r3, MemOperand(ip));
1037 1038
1039
1038 // Restore current context from top and clear it in debug mode. 1040 // Restore current context from top and clear it in debug mode.
1041 if (restore_context) {
1042 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
1043 ldr(cp, MemOperand(ip));
1044 }
1045 #ifdef DEBUG
1039 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); 1046 mov(ip, Operand(ExternalReference(Isolate::kContextAddress, isolate())));
1040 ldr(cp, MemOperand(ip));
1041 #ifdef DEBUG
1042 str(r3, MemOperand(ip)); 1047 str(r3, MemOperand(ip));
1043 #endif 1048 #endif
1044 1049
1045 // Tear down the exit frame, pop the arguments, and return. 1050 // Tear down the exit frame, pop the arguments, and return.
1046 mov(sp, Operand(fp)); 1051 mov(sp, Operand(fp));
1047 ldm(ia_w, sp, fp.bit() | lr.bit()); 1052 ldm(ia_w, sp, fp.bit() | lr.bit());
1048 if (argument_count.is_valid()) { 1053 if (argument_count.is_valid()) {
1049 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2)); 1054 add(sp, sp, Operand(argument_count, LSL, kPointerSizeLog2));
1050 } 1055 }
1051 } 1056 }
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 stub->CompilingCallsToThisStubIsGCSafe(isolate())); 2278 stub->CompilingCallsToThisStubIsGCSafe(isolate()));
2274 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, cond); 2279 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET, cond);
2275 } 2280 }
2276 2281
2277 2282
2278 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { 2283 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
2279 return ref0.address() - ref1.address(); 2284 return ref0.address() - ref1.address();
2280 } 2285 }
2281 2286
2282 2287
2283 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, 2288 void MacroAssembler::CallApiFunctionAndReturn(
2284 Address function_address, 2289 ExternalReference function,
2285 ExternalReference thunk_ref, 2290 Address function_address,
2286 Register thunk_last_arg, 2291 ExternalReference thunk_ref,
2287 int stack_space, 2292 Register thunk_last_arg,
2288 int return_value_offset) { 2293 int stack_space,
2294 MemOperand return_value_operand,
2295 MemOperand* context_restore_operand) {
2289 ExternalReference next_address = 2296 ExternalReference next_address =
2290 ExternalReference::handle_scope_next_address(isolate()); 2297 ExternalReference::handle_scope_next_address(isolate());
2291 const int kNextOffset = 0; 2298 const int kNextOffset = 0;
2292 const int kLimitOffset = AddressOffset( 2299 const int kLimitOffset = AddressOffset(
2293 ExternalReference::handle_scope_limit_address(isolate()), 2300 ExternalReference::handle_scope_limit_address(isolate()),
2294 next_address); 2301 next_address);
2295 const int kLevelOffset = AddressOffset( 2302 const int kLevelOffset = AddressOffset(
2296 ExternalReference::handle_scope_level_address(isolate()), 2303 ExternalReference::handle_scope_level_address(isolate()),
2297 next_address); 2304 next_address);
2298 2305
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2342 if (FLAG_log_timer_events) { 2349 if (FLAG_log_timer_events) {
2343 FrameScope frame(this, StackFrame::MANUAL); 2350 FrameScope frame(this, StackFrame::MANUAL);
2344 PushSafepointRegisters(); 2351 PushSafepointRegisters();
2345 PrepareCallCFunction(1, r0); 2352 PrepareCallCFunction(1, r0);
2346 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); 2353 mov(r0, Operand(ExternalReference::isolate_address(isolate())));
2347 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); 2354 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1);
2348 PopSafepointRegisters(); 2355 PopSafepointRegisters();
2349 } 2356 }
2350 2357
2351 Label promote_scheduled_exception; 2358 Label promote_scheduled_exception;
2359 Label exception_handled;
2352 Label delete_allocated_handles; 2360 Label delete_allocated_handles;
2353 Label leave_exit_frame; 2361 Label leave_exit_frame;
2354 Label return_value_loaded; 2362 Label return_value_loaded;
2355 2363
2356 // load value from ReturnValue 2364 // load value from ReturnValue
2357 ldr(r0, MemOperand(fp, return_value_offset*kPointerSize)); 2365 ldr(r0, return_value_operand);
2358 bind(&return_value_loaded); 2366 bind(&return_value_loaded);
2359 // No more valid handles (the result handle was the last one). Restore 2367 // No more valid handles (the result handle was the last one). Restore
2360 // previous handle scope. 2368 // previous handle scope.
2361 str(r4, MemOperand(r7, kNextOffset)); 2369 str(r4, MemOperand(r7, kNextOffset));
2362 if (emit_debug_code()) { 2370 if (emit_debug_code()) {
2363 ldr(r1, MemOperand(r7, kLevelOffset)); 2371 ldr(r1, MemOperand(r7, kLevelOffset));
2364 cmp(r1, r6); 2372 cmp(r1, r6);
2365 Check(eq, kUnexpectedLevelAfterReturnFromApiCall); 2373 Check(eq, kUnexpectedLevelAfterReturnFromApiCall);
2366 } 2374 }
2367 sub(r6, r6, Operand(1)); 2375 sub(r6, r6, Operand(1));
2368 str(r6, MemOperand(r7, kLevelOffset)); 2376 str(r6, MemOperand(r7, kLevelOffset));
2369 ldr(ip, MemOperand(r7, kLimitOffset)); 2377 ldr(ip, MemOperand(r7, kLimitOffset));
2370 cmp(r5, ip); 2378 cmp(r5, ip);
2371 b(ne, &delete_allocated_handles); 2379 b(ne, &delete_allocated_handles);
2372 2380
2373 // Check if the function scheduled an exception. 2381 // Check if the function scheduled an exception.
2374 bind(&leave_exit_frame); 2382 bind(&leave_exit_frame);
2375 LoadRoot(r4, Heap::kTheHoleValueRootIndex); 2383 LoadRoot(r4, Heap::kTheHoleValueRootIndex);
2376 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate()))); 2384 mov(ip, Operand(ExternalReference::scheduled_exception_address(isolate())));
2377 ldr(r5, MemOperand(ip)); 2385 ldr(r5, MemOperand(ip));
2378 cmp(r4, r5); 2386 cmp(r4, r5);
2379 b(ne, &promote_scheduled_exception); 2387 b(ne, &promote_scheduled_exception);
2388 bind(&exception_handled);
2380 2389
2390 bool restore_context = context_restore_operand != NULL;
2391 if (restore_context) {
2392 ldr(cp, *context_restore_operand);
2393 }
2381 // LeaveExitFrame expects unwind space to be in a register. 2394 // LeaveExitFrame expects unwind space to be in a register.
2382 mov(r4, Operand(stack_space)); 2395 mov(r4, Operand(stack_space));
2383 LeaveExitFrame(false, r4); 2396 LeaveExitFrame(false, r4, !restore_context);
2384 mov(pc, lr); 2397 mov(pc, lr);
2385 2398
2386 bind(&promote_scheduled_exception); 2399 bind(&promote_scheduled_exception);
2387 TailCallExternalReference( 2400 {
2388 ExternalReference(Runtime::kPromoteScheduledException, isolate()), 2401 FrameScope frame(this, StackFrame::INTERNAL);
2389 0, 2402 CallExternalReference(
2390 1); 2403 ExternalReference(Runtime::kPromoteScheduledException, isolate()),
2404 0);
2405 }
2406 jmp(&exception_handled);
2391 2407
2392 // HandleScope limit has changed. Delete allocated extensions. 2408 // HandleScope limit has changed. Delete allocated extensions.
2393 bind(&delete_allocated_handles); 2409 bind(&delete_allocated_handles);
2394 str(r5, MemOperand(r7, kLimitOffset)); 2410 str(r5, MemOperand(r7, kLimitOffset));
2395 mov(r4, r0); 2411 mov(r4, r0);
2396 PrepareCallCFunction(1, r5); 2412 PrepareCallCFunction(1, r5);
2397 mov(r0, Operand(ExternalReference::isolate_address(isolate()))); 2413 mov(r0, Operand(ExternalReference::isolate_address(isolate())));
2398 CallCFunction( 2414 CallCFunction(
2399 ExternalReference::delete_handle_scope_extensions(isolate()), 1); 2415 ExternalReference::delete_handle_scope_extensions(isolate()), 1);
2400 mov(r0, r4); 2416 mov(r0, r4);
(...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after
3884 void CodePatcher::EmitCondition(Condition cond) { 3900 void CodePatcher::EmitCondition(Condition cond) {
3885 Instr instr = Assembler::instr_at(masm_.pc_); 3901 Instr instr = Assembler::instr_at(masm_.pc_);
3886 instr = (instr & ~kCondMask) | cond; 3902 instr = (instr & ~kCondMask) | cond;
3887 masm_.emit(instr); 3903 masm_.emit(instr);
3888 } 3904 }
3889 3905
3890 3906
3891 } } // namespace v8::internal 3907 } } // namespace v8::internal
3892 3908
3893 #endif // V8_TARGET_ARCH_ARM 3909 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/arm/macro-assembler-arm.h ('k') | src/arm/stub-cache-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698