| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_ARM | 5 #if V8_TARGET_ARCH_ARM |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 5388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5399 __ str(r5, MemOperand(r9, kLimitOffset)); | 5399 __ str(r5, MemOperand(r9, kLimitOffset)); |
| 5400 __ mov(r4, r0); | 5400 __ mov(r4, r0); |
| 5401 __ PrepareCallCFunction(1, r5); | 5401 __ PrepareCallCFunction(1, r5); |
| 5402 __ mov(r0, Operand(ExternalReference::isolate_address(isolate))); | 5402 __ mov(r0, Operand(ExternalReference::isolate_address(isolate))); |
| 5403 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), | 5403 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), |
| 5404 1); | 5404 1); |
| 5405 __ mov(r0, r4); | 5405 __ mov(r0, r4); |
| 5406 __ jmp(&leave_exit_frame); | 5406 __ jmp(&leave_exit_frame); |
| 5407 } | 5407 } |
| 5408 | 5408 |
| 5409 void CallApiCallbackStub::Generate(MacroAssembler* masm) { | 5409 static void CallApiFunctionStubHelper(MacroAssembler* masm, |
| 5410 const ParameterCount& argc, |
| 5411 bool return_first_arg, |
| 5412 bool call_data_undefined, bool is_lazy) { |
| 5410 // ----------- S t a t e ------------- | 5413 // ----------- S t a t e ------------- |
| 5411 // -- r0 : callee | 5414 // -- r0 : callee |
| 5412 // -- r4 : call_data | 5415 // -- r4 : call_data |
| 5413 // -- r2 : holder | 5416 // -- r2 : holder |
| 5414 // -- r1 : api_function_address | 5417 // -- r1 : api_function_address |
| 5418 // -- r3 : number of arguments if argc is a register |
| 5415 // -- cp : context | 5419 // -- cp : context |
| 5416 // -- | 5420 // -- |
| 5417 // -- sp[0] : last argument | 5421 // -- sp[0] : last argument |
| 5418 // -- ... | 5422 // -- ... |
| 5419 // -- sp[(argc - 1)* 4] : first argument | 5423 // -- sp[(argc - 1)* 4] : first argument |
| 5420 // -- sp[argc * 4] : receiver | 5424 // -- sp[argc * 4] : receiver |
| 5421 // ----------------------------------- | 5425 // ----------------------------------- |
| 5422 | 5426 |
| 5423 Register callee = r0; | 5427 Register callee = r0; |
| 5424 Register call_data = r4; | 5428 Register call_data = r4; |
| 5425 Register holder = r2; | 5429 Register holder = r2; |
| 5426 Register api_function_address = r1; | 5430 Register api_function_address = r1; |
| 5427 Register context = cp; | 5431 Register context = cp; |
| 5428 | 5432 |
| 5429 typedef FunctionCallbackArguments FCA; | 5433 typedef FunctionCallbackArguments FCA; |
| 5430 | 5434 |
| 5431 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 5435 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
| 5432 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 5436 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
| 5433 STATIC_ASSERT(FCA::kDataIndex == 4); | 5437 STATIC_ASSERT(FCA::kDataIndex == 4); |
| 5434 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 5438 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
| 5435 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 5439 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
| 5436 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 5440 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
| 5437 STATIC_ASSERT(FCA::kHolderIndex == 0); | 5441 STATIC_ASSERT(FCA::kHolderIndex == 0); |
| 5438 STATIC_ASSERT(FCA::kArgsLength == 7); | 5442 STATIC_ASSERT(FCA::kArgsLength == 7); |
| 5439 | 5443 |
| 5444 DCHECK(argc.is_immediate() || r3.is(argc.reg())); |
| 5445 |
| 5440 // context save | 5446 // context save |
| 5441 __ push(context); | 5447 __ push(context); |
| 5442 if (!is_lazy()) { | 5448 if (!is_lazy) { |
| 5443 // load context from callee | 5449 // load context from callee |
| 5444 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 5450 __ ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
| 5445 } | 5451 } |
| 5446 | 5452 |
| 5447 // callee | 5453 // callee |
| 5448 __ push(callee); | 5454 __ push(callee); |
| 5449 | 5455 |
| 5450 // call data | 5456 // call data |
| 5451 __ push(call_data); | 5457 __ push(call_data); |
| 5452 | 5458 |
| 5453 Register scratch = call_data; | 5459 Register scratch = call_data; |
| 5454 if (!call_data_undefined()) { | 5460 if (!call_data_undefined) { |
| 5455 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 5461 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); |
| 5456 } | 5462 } |
| 5457 // return value | 5463 // return value |
| 5458 __ push(scratch); | 5464 __ push(scratch); |
| 5459 // return value default | 5465 // return value default |
| 5460 __ push(scratch); | 5466 __ push(scratch); |
| 5461 // isolate | 5467 // isolate |
| 5462 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); | 5468 __ mov(scratch, Operand(ExternalReference::isolate_address(masm->isolate()))); |
| 5463 __ push(scratch); | 5469 __ push(scratch); |
| 5464 // holder | 5470 // holder |
| 5465 __ push(holder); | 5471 __ push(holder); |
| 5466 | 5472 |
| 5467 // Prepare arguments. | 5473 // Prepare arguments. |
| 5468 __ mov(scratch, sp); | 5474 __ mov(scratch, sp); |
| 5469 | 5475 |
| 5470 // Allocate the v8::Arguments structure in the arguments' space since | 5476 // Allocate the v8::Arguments structure in the arguments' space since |
| 5471 // it's not controlled by GC. | 5477 // it's not controlled by GC. |
| 5472 const int kApiStackSpace = 4; | 5478 const int kApiStackSpace = 4; |
| 5473 | 5479 |
| 5474 FrameScope frame_scope(masm, StackFrame::MANUAL); | 5480 FrameScope frame_scope(masm, StackFrame::MANUAL); |
| 5475 __ EnterExitFrame(false, kApiStackSpace); | 5481 __ EnterExitFrame(false, kApiStackSpace); |
| 5476 | 5482 |
| 5477 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); | 5483 DCHECK(!api_function_address.is(r0) && !scratch.is(r0)); |
| 5478 // r0 = FunctionCallbackInfo& | 5484 // r0 = FunctionCallbackInfo& |
| 5479 // Arguments is after the return address. | 5485 // Arguments is after the return address. |
| 5480 __ add(r0, sp, Operand(1 * kPointerSize)); | 5486 __ add(r0, sp, Operand(1 * kPointerSize)); |
| 5481 // FunctionCallbackInfo::implicit_args_ | 5487 // FunctionCallbackInfo::implicit_args_ |
| 5482 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); | 5488 __ str(scratch, MemOperand(r0, 0 * kPointerSize)); |
| 5483 // FunctionCallbackInfo::values_ | 5489 if (argc.is_immediate()) { |
| 5484 __ add(ip, scratch, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize)); | 5490 // FunctionCallbackInfo::values_ |
| 5485 __ str(ip, MemOperand(r0, 1 * kPointerSize)); | 5491 __ add(ip, scratch, |
| 5486 // FunctionCallbackInfo::length_ = argc | 5492 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); |
| 5487 __ mov(ip, Operand(argc())); | 5493 __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
| 5488 __ str(ip, MemOperand(r0, 2 * kPointerSize)); | 5494 // FunctionCallbackInfo::length_ = argc |
| 5489 // FunctionCallbackInfo::is_construct_call_ = 0 | 5495 __ mov(ip, Operand(argc.immediate())); |
| 5490 __ mov(ip, Operand::Zero()); | 5496 __ str(ip, MemOperand(r0, 2 * kPointerSize)); |
| 5491 __ str(ip, MemOperand(r0, 3 * kPointerSize)); | 5497 // FunctionCallbackInfo::is_construct_call_ = 0 |
| 5498 __ mov(ip, Operand::Zero()); |
| 5499 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 5500 } else { |
| 5501 // FunctionCallbackInfo::values_ |
| 5502 __ add(ip, scratch, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
| 5503 __ add(ip, ip, Operand((FCA::kArgsLength - 1) * kPointerSize)); |
| 5504 __ str(ip, MemOperand(r0, 1 * kPointerSize)); |
| 5505 // FunctionCallbackInfo::length_ = argc |
| 5506 __ str(argc.reg(), MemOperand(r0, 2 * kPointerSize)); |
| 5507 // FunctionCallbackInfo::is_construct_call_ |
| 5508 __ add(argc.reg(), argc.reg(), Operand(FCA::kArgsLength + 1)); |
| 5509 __ mov(ip, Operand(argc.reg(), LSL, kPointerSizeLog2)); |
| 5510 __ str(ip, MemOperand(r0, 3 * kPointerSize)); |
| 5511 } |
| 5492 | 5512 |
| 5493 ExternalReference thunk_ref = | 5513 ExternalReference thunk_ref = |
| 5494 ExternalReference::invoke_function_callback(masm->isolate()); | 5514 ExternalReference::invoke_function_callback(masm->isolate()); |
| 5495 | 5515 |
| 5496 AllowExternalCallThatCantCauseGC scope(masm); | 5516 AllowExternalCallThatCantCauseGC scope(masm); |
| 5497 MemOperand context_restore_operand( | 5517 MemOperand context_restore_operand( |
| 5498 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 5518 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
| 5499 // Stores return the first js argument | 5519 // Stores return the first js argument |
| 5500 int return_value_offset = 0; | 5520 int return_value_offset = 0; |
| 5501 if (is_store()) { | 5521 if (return_first_arg) { |
| 5502 return_value_offset = 2 + FCA::kArgsLength; | 5522 return_value_offset = 2 + FCA::kArgsLength; |
| 5503 } else { | 5523 } else { |
| 5504 return_value_offset = 2 + FCA::kReturnValueOffset; | 5524 return_value_offset = 2 + FCA::kReturnValueOffset; |
| 5505 } | 5525 } |
| 5506 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 5526 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
| 5507 int stack_space = 0; | 5527 int stack_space = 0; |
| 5508 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); | 5528 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); |
| 5509 MemOperand* stack_space_operand = &is_construct_call_operand; | 5529 MemOperand* stack_space_operand = &is_construct_call_operand; |
| 5510 stack_space = argc() + FCA::kArgsLength + 1; | 5530 if (argc.is_immediate()) { |
| 5511 stack_space_operand = NULL; | 5531 stack_space = argc.immediate() + FCA::kArgsLength + 1; |
| 5512 | 5532 stack_space_operand = NULL; |
| 5533 } |
| 5513 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 5534 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
| 5514 stack_space_operand, return_value_operand, | 5535 stack_space_operand, return_value_operand, |
| 5515 &context_restore_operand); | 5536 &context_restore_operand); |
| 5516 } | 5537 } |
| 5517 | 5538 |
| 5518 | 5539 |
| 5540 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
| 5541 bool call_data_undefined = this->call_data_undefined(); |
| 5542 CallApiFunctionStubHelper(masm, ParameterCount(r3), false, |
| 5543 call_data_undefined, false); |
| 5544 } |
| 5545 |
| 5546 |
| 5547 void CallApiAccessorStub::Generate(MacroAssembler* masm) { |
| 5548 bool is_store = this->is_store(); |
| 5549 int argc = this->argc(); |
| 5550 bool call_data_undefined = this->call_data_undefined(); |
| 5551 bool is_lazy = this->is_lazy(); |
| 5552 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, |
| 5553 call_data_undefined, is_lazy); |
| 5554 } |
| 5555 |
| 5556 |
| 5519 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5557 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
| 5520 // ----------- S t a t e ------------- | 5558 // ----------- S t a t e ------------- |
| 5521 // -- sp[0] : name | 5559 // -- sp[0] : name |
| 5522 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ | 5560 // -- sp[4 .. (4 + kArgsLength*4)] : v8::PropertyCallbackInfo::args_ |
| 5523 // -- ... | 5561 // -- ... |
| 5524 // -- r2 : api_function_address | 5562 // -- r2 : api_function_address |
| 5525 // ----------------------------------- | 5563 // ----------------------------------- |
| 5526 | 5564 |
| 5527 Register api_function_address = ApiGetterDescriptor::function_address(); | 5565 Register api_function_address = ApiGetterDescriptor::function_address(); |
| 5528 DCHECK(api_function_address.is(r2)); | 5566 DCHECK(api_function_address.is(r2)); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 5553 kStackUnwindSpace, NULL, return_value_operand, NULL); | 5591 kStackUnwindSpace, NULL, return_value_operand, NULL); |
| 5554 } | 5592 } |
| 5555 | 5593 |
| 5556 | 5594 |
| 5557 #undef __ | 5595 #undef __ |
| 5558 | 5596 |
| 5559 } // namespace internal | 5597 } // namespace internal |
| 5560 } // namespace v8 | 5598 } // namespace v8 |
| 5561 | 5599 |
| 5562 #endif // V8_TARGET_ARCH_ARM | 5600 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |