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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM | 7 #if V8_TARGET_ARCH_ARM |
8 | 8 |
9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3111 } | 3111 } |
3112 | 3112 |
3113 | 3113 |
3114 void FullCodeGenerator::EmitLoadSuperConstructor() { | 3114 void FullCodeGenerator::EmitLoadSuperConstructor() { |
3115 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 3115 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
3116 __ Push(r0); | 3116 __ Push(r0); |
3117 __ CallRuntime(Runtime::kGetPrototype, 1); | 3117 __ CallRuntime(Runtime::kGetPrototype, 1); |
3118 } | 3118 } |
3119 | 3119 |
3120 | 3120 |
3121 void FullCodeGenerator::EmitInitializeThisAfterSuper( | |
3122 SuperReference* super_ref) { | |
3123 Variable* this_var = super_ref->this_var()->var(); | |
3124 GetVar(r1, this_var); | |
3125 __ CompareRoot(r1, Heap::kTheHoleValueRootIndex); | |
3126 Label uninitialized_this; | |
3127 __ b(eq, &uninitialized_this); | |
3128 __ mov(r0, Operand(this_var->name())); | |
3129 __ Push(r0); | |
3130 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
3131 __ bind(&uninitialized_this); | |
3132 | |
3133 EmitVariableAssignment(this_var, Token::INIT_CONST); | |
3134 } | |
3135 | |
3136 | |
3121 void FullCodeGenerator::VisitCall(Call* expr) { | 3137 void FullCodeGenerator::VisitCall(Call* expr) { |
3122 #ifdef DEBUG | 3138 #ifdef DEBUG |
3123 // We want to verify that RecordJSReturnSite gets called on all paths | 3139 // We want to verify that RecordJSReturnSite gets called on all paths |
3124 // through this function. Avoid early returns. | 3140 // through this function. Avoid early returns. |
3125 expr->return_is_recorded_ = false; | 3141 expr->return_is_recorded_ = false; |
3126 #endif | 3142 #endif |
3127 | 3143 |
3128 Comment cmnt(masm_, "[ Call"); | 3144 Comment cmnt(masm_, "[ Call"); |
3129 Expression* callee = expr->expression(); | 3145 Expression* callee = expr->expression(); |
3130 Call::CallType call_type = expr->GetCallType(isolate()); | 3146 Call::CallType call_type = expr->GetCallType(isolate()); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3334 __ Move(r2, FeedbackVector()); | 3350 __ Move(r2, FeedbackVector()); |
3335 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3351 __ mov(r3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
3336 | 3352 |
3337 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3353 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3338 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3354 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3339 | 3355 |
3340 __ Drop(1); | 3356 __ Drop(1); |
3341 | 3357 |
3342 RecordJSReturnSite(expr); | 3358 RecordJSReturnSite(expr); |
3343 | 3359 |
3344 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3360 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference()); |
3345 Variable* this_var = super_ref->this_var()->var(); | |
3346 GetVar(r1, this_var); | |
3347 __ CompareRoot(r1, Heap::kTheHoleValueRootIndex); | |
3348 Label uninitialized_this; | |
3349 __ b(eq, &uninitialized_this); | |
3350 __ mov(r0, Operand(this_var->name())); | |
3351 __ Push(r0); | |
3352 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
3353 __ bind(&uninitialized_this); | |
3354 | |
3355 EmitVariableAssignment(this_var, Token::INIT_CONST); | |
3356 context()->Plug(r0); | 3361 context()->Plug(r0); |
3357 } | 3362 } |
3358 | 3363 |
3359 | 3364 |
3360 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3365 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3361 ZoneList<Expression*>* args = expr->arguments(); | 3366 ZoneList<Expression*>* args = expr->arguments(); |
3362 DCHECK(args->length() == 1); | 3367 DCHECK(args->length() == 1); |
3363 | 3368 |
3364 VisitForAccumulatorValue(args->at(0)); | 3369 VisitForAccumulatorValue(args->at(0)); |
3365 | 3370 |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4601 DCHECK(expr->arguments()->length() == 0); | 4606 DCHECK(expr->arguments()->length() == 0); |
4602 ExternalReference debug_is_active = | 4607 ExternalReference debug_is_active = |
4603 ExternalReference::debug_is_active_address(isolate()); | 4608 ExternalReference::debug_is_active_address(isolate()); |
4604 __ mov(ip, Operand(debug_is_active)); | 4609 __ mov(ip, Operand(debug_is_active)); |
4605 __ ldrb(r0, MemOperand(ip)); | 4610 __ ldrb(r0, MemOperand(ip)); |
4606 __ SmiTag(r0); | 4611 __ SmiTag(r0); |
4607 context()->Plug(r0); | 4612 context()->Plug(r0); |
4608 } | 4613 } |
4609 | 4614 |
4610 | 4615 |
4616 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { | |
4617 // Assert: expr === CallRuntime("ReflectConstruct") | |
arv (Not doing code reviews)
2015/04/08 18:58:59
DCHECK_EQ(expr->raw_name(), ...)
| |
4618 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); | |
4619 ZoneList<Expression*>* args = call->arguments(); | |
4620 DCHECK_EQ(3, args->length()); | |
4621 | |
4622 SuperReference* super_reference = args->at(0)->AsSuperReference(); | |
4623 | |
4624 // Load ReflectConstruct function | |
4625 EmitLoadJSRuntimeFunction(call); | |
4626 | |
4627 // Push the target function under the receiver. | |
4628 __ ldr(ip, MemOperand(sp, 0)); | |
4629 __ push(ip); | |
4630 __ str(r0, MemOperand(sp, kPointerSize)); | |
4631 | |
4632 // Push super | |
4633 EmitLoadSuperConstructor(); | |
4634 __ Push(result_register()); | |
4635 | |
4636 // Push arguments array | |
4637 VisitForStackValue(args->at(1)); | |
4638 | |
4639 // Push NewTarget | |
4640 DCHECK(args->at(2)->IsVariableProxy()); | |
4641 VisitForStackValue(args->at(2)); | |
4642 | |
4643 EmitCallJSRuntimeFunction(call); | |
4644 | |
4645 // Restore context register. | |
4646 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | |
4647 context()->DropAndPlug(1, r0); | |
4648 | |
4649 EmitInitializeThisAfterSuper(super_reference); | |
4650 } | |
4651 | |
4652 | |
4653 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | |
4654 // Push the builtins object as the receiver. | |
4655 Register receiver = LoadDescriptor::ReceiverRegister(); | |
4656 __ ldr(receiver, GlobalObjectOperand()); | |
4657 __ ldr(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | |
4658 __ push(receiver); | |
4659 | |
4660 // Load the function from the receiver. | |
4661 __ mov(LoadDescriptor::NameRegister(), Operand(expr->name())); | |
4662 if (FLAG_vector_ics) { | |
4663 __ mov(VectorLoadICDescriptor::SlotRegister(), | |
4664 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | |
4665 CallLoadIC(NOT_CONTEXTUAL); | |
4666 } else { | |
4667 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4668 } | |
4669 } | |
4670 | |
4671 | |
4672 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | |
4673 ZoneList<Expression*>* args = expr->arguments(); | |
4674 int arg_count = args->length(); | |
4675 | |
4676 // Record source position of the IC call. | |
4677 SetSourcePosition(expr->position()); | |
4678 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
4679 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
4680 __ CallStub(&stub); | |
4681 } | |
4682 | |
4683 | |
4611 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4684 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
4612 ZoneList<Expression*>* args = expr->arguments(); | 4685 ZoneList<Expression*>* args = expr->arguments(); |
4613 int arg_count = args->length(); | 4686 int arg_count = args->length(); |
4614 | 4687 |
4615 if (expr->is_jsruntime()) { | 4688 if (expr->is_jsruntime()) { |
4616 Comment cmnt(masm_, "[ CallRuntime"); | 4689 Comment cmnt(masm_, "[ CallRuntime"); |
4617 // Push the builtins object as the receiver. | 4690 EmitLoadJSRuntimeFunction(expr); |
4618 Register receiver = LoadDescriptor::ReceiverRegister(); | |
4619 __ ldr(receiver, GlobalObjectOperand()); | |
4620 __ ldr(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | |
4621 __ push(receiver); | |
4622 | |
4623 // Load the function from the receiver. | |
4624 __ mov(LoadDescriptor::NameRegister(), Operand(expr->name())); | |
4625 if (FLAG_vector_ics) { | |
4626 __ mov(VectorLoadICDescriptor::SlotRegister(), | |
4627 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | |
4628 CallLoadIC(NOT_CONTEXTUAL); | |
4629 } else { | |
4630 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4631 } | |
4632 | 4691 |
4633 // Push the target function under the receiver. | 4692 // Push the target function under the receiver. |
4634 __ ldr(ip, MemOperand(sp, 0)); | 4693 __ ldr(ip, MemOperand(sp, 0)); |
4635 __ push(ip); | 4694 __ push(ip); |
4636 __ str(r0, MemOperand(sp, kPointerSize)); | 4695 __ str(r0, MemOperand(sp, kPointerSize)); |
4637 | 4696 |
4638 // Push the arguments ("left-to-right"). | 4697 // Push the arguments ("left-to-right"). |
4639 for (int i = 0; i < arg_count; i++) { | 4698 for (int i = 0; i < arg_count; i++) { |
4640 VisitForStackValue(args->at(i)); | 4699 VisitForStackValue(args->at(i)); |
4641 } | 4700 } |
4642 | 4701 |
4643 // Record source position of the IC call. | 4702 EmitCallJSRuntimeFunction(expr); |
4644 SetSourcePosition(expr->position()); | |
4645 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
4646 __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
4647 __ CallStub(&stub); | |
4648 | 4703 |
4649 // Restore context register. | 4704 // Restore context register. |
4650 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4705 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4651 | 4706 |
4652 context()->DropAndPlug(1, r0); | 4707 context()->DropAndPlug(1, r0); |
4653 | 4708 |
4654 } else { | 4709 } else { |
4655 const Runtime::Function* function = expr->function(); | 4710 const Runtime::Function* function = expr->function(); |
4656 switch (function->function_id) { | 4711 switch (function->function_id) { |
4657 #define CALL_INTRINSIC_GENERATOR(Name) \ | 4712 #define CALL_INTRINSIC_GENERATOR(Name) \ |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5478 | 5533 |
5479 DCHECK(interrupt_address == | 5534 DCHECK(interrupt_address == |
5480 isolate->builtins()->OsrAfterStackCheck()->entry()); | 5535 isolate->builtins()->OsrAfterStackCheck()->entry()); |
5481 return OSR_AFTER_STACK_CHECK; | 5536 return OSR_AFTER_STACK_CHECK; |
5482 } | 5537 } |
5483 | 5538 |
5484 | 5539 |
5485 } } // namespace v8::internal | 5540 } } // namespace v8::internal |
5486 | 5541 |
5487 #endif // V8_TARGET_ARCH_ARM | 5542 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |