| 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_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
| 8 | 8 |
| 9 // Note on Mips implementation: | 9 // Note on Mips implementation: |
| 10 // | 10 // |
| (...skipping 3072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 } | 3083 } |
| 3084 | 3084 |
| 3085 | 3085 |
| 3086 void FullCodeGenerator::EmitLoadSuperConstructor() { | 3086 void FullCodeGenerator::EmitLoadSuperConstructor() { |
| 3087 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 3087 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 3088 __ Push(a0); | 3088 __ Push(a0); |
| 3089 __ CallRuntime(Runtime::kGetPrototype, 1); | 3089 __ CallRuntime(Runtime::kGetPrototype, 1); |
| 3090 } | 3090 } |
| 3091 | 3091 |
| 3092 | 3092 |
| 3093 void FullCodeGenerator::EmitInitializeThisAfterSuper( |
| 3094 SuperReference* super_ref) { |
| 3095 Variable* this_var = super_ref->this_var()->var(); |
| 3096 GetVar(a1, this_var); |
| 3097 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 3098 Label uninitialized_this; |
| 3099 __ Branch(&uninitialized_this, eq, a1, Operand(at)); |
| 3100 __ li(a0, Operand(this_var->name())); |
| 3101 __ Push(a0); |
| 3102 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 3103 __ bind(&uninitialized_this); |
| 3104 |
| 3105 EmitVariableAssignment(this_var, Token::INIT_CONST); |
| 3106 } |
| 3107 |
| 3108 |
| 3093 void FullCodeGenerator::VisitCall(Call* expr) { | 3109 void FullCodeGenerator::VisitCall(Call* expr) { |
| 3094 #ifdef DEBUG | 3110 #ifdef DEBUG |
| 3095 // We want to verify that RecordJSReturnSite gets called on all paths | 3111 // We want to verify that RecordJSReturnSite gets called on all paths |
| 3096 // through this function. Avoid early returns. | 3112 // through this function. Avoid early returns. |
| 3097 expr->return_is_recorded_ = false; | 3113 expr->return_is_recorded_ = false; |
| 3098 #endif | 3114 #endif |
| 3099 | 3115 |
| 3100 Comment cmnt(masm_, "[ Call"); | 3116 Comment cmnt(masm_, "[ Call"); |
| 3101 Expression* callee = expr->expression(); | 3117 Expression* callee = expr->expression(); |
| 3102 Call::CallType call_type = expr->GetCallType(isolate()); | 3118 Call::CallType call_type = expr->GetCallType(isolate()); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 __ li(a2, FeedbackVector()); | 3320 __ li(a2, FeedbackVector()); |
| 3305 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3321 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
| 3306 | 3322 |
| 3307 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3323 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
| 3308 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3324 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
| 3309 | 3325 |
| 3310 __ Drop(1); | 3326 __ Drop(1); |
| 3311 | 3327 |
| 3312 RecordJSReturnSite(expr); | 3328 RecordJSReturnSite(expr); |
| 3313 | 3329 |
| 3314 SuperReference* super_ref = expr->expression()->AsSuperReference(); | 3330 EmitInitializeThisAfterSuper(expr->expression()->AsSuperReference()); |
| 3315 Variable* this_var = super_ref->this_var()->var(); | |
| 3316 GetVar(a1, this_var); | |
| 3317 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
| 3318 Label uninitialized_this; | |
| 3319 __ Branch(&uninitialized_this, eq, a1, Operand(at)); | |
| 3320 __ li(a0, Operand(this_var->name())); | |
| 3321 __ Push(a0); | |
| 3322 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
| 3323 __ bind(&uninitialized_this); | |
| 3324 | |
| 3325 EmitVariableAssignment(this_var, Token::INIT_CONST); | |
| 3326 context()->Plug(v0); | 3331 context()->Plug(v0); |
| 3327 } | 3332 } |
| 3328 | 3333 |
| 3329 | 3334 |
| 3330 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3335 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
| 3331 ZoneList<Expression*>* args = expr->arguments(); | 3336 ZoneList<Expression*>* args = expr->arguments(); |
| 3332 DCHECK(args->length() == 1); | 3337 DCHECK(args->length() == 1); |
| 3333 | 3338 |
| 3334 VisitForAccumulatorValue(args->at(0)); | 3339 VisitForAccumulatorValue(args->at(0)); |
| 3335 | 3340 |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4607 DCHECK(expr->arguments()->length() == 0); | 4612 DCHECK(expr->arguments()->length() == 0); |
| 4608 ExternalReference debug_is_active = | 4613 ExternalReference debug_is_active = |
| 4609 ExternalReference::debug_is_active_address(isolate()); | 4614 ExternalReference::debug_is_active_address(isolate()); |
| 4610 __ li(at, Operand(debug_is_active)); | 4615 __ li(at, Operand(debug_is_active)); |
| 4611 __ lbu(v0, MemOperand(at)); | 4616 __ lbu(v0, MemOperand(at)); |
| 4612 __ SmiTag(v0); | 4617 __ SmiTag(v0); |
| 4613 context()->Plug(v0); | 4618 context()->Plug(v0); |
| 4614 } | 4619 } |
| 4615 | 4620 |
| 4616 | 4621 |
| 4622 void FullCodeGenerator::EmitCallSuperWithSpread(CallRuntime* expr) { |
| 4623 // Assert: expr === CallRuntime("ReflectConstruct") |
| 4624 CallRuntime* call = expr->arguments()->at(0)->AsCallRuntime(); |
| 4625 ZoneList<Expression*>* args = call->arguments(); |
| 4626 DCHECK_EQ(3, args->length()); |
| 4627 |
| 4628 SuperReference* super_reference = args->at(0)->AsSuperReference(); |
| 4629 |
| 4630 // Load ReflectConstruct function |
| 4631 EmitLoadJSRuntimeFunction(call); |
| 4632 |
| 4633 // Push the target function under the receiver. |
| 4634 __ ld(at, MemOperand(sp, 0)); |
| 4635 __ push(at); |
| 4636 __ sd(v0, MemOperand(sp, kPointerSize)); |
| 4637 |
| 4638 // Push super |
| 4639 EmitLoadSuperConstructor(); |
| 4640 __ Push(result_register()); |
| 4641 |
| 4642 // Push arguments array |
| 4643 VisitForStackValue(args->at(1)); |
| 4644 |
| 4645 // Push NewTarget |
| 4646 DCHECK(args->at(2)->IsVariableProxy()); |
| 4647 VisitForStackValue(args->at(2)); |
| 4648 |
| 4649 EmitCallJSRuntimeFunction(call); |
| 4650 |
| 4651 // Restore context register. |
| 4652 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 4653 context()->DropAndPlug(1, v0); |
| 4654 |
| 4655 EmitInitializeThisAfterSuper(super_reference); |
| 4656 } |
| 4657 |
| 4658 |
| 4659 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
| 4660 // Push the builtins object as the receiver. |
| 4661 Register receiver = LoadDescriptor::ReceiverRegister(); |
| 4662 __ ld(receiver, GlobalObjectOperand()); |
| 4663 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); |
| 4664 __ push(receiver); |
| 4665 |
| 4666 // Load the function from the receiver. |
| 4667 __ li(LoadDescriptor::NameRegister(), Operand(expr->name())); |
| 4668 if (FLAG_vector_ics) { |
| 4669 __ li(VectorLoadICDescriptor::SlotRegister(), |
| 4670 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
| 4671 CallLoadIC(NOT_CONTEXTUAL); |
| 4672 } else { |
| 4673 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); |
| 4674 } |
| 4675 } |
| 4676 |
| 4677 |
| 4678 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
| 4679 ZoneList<Expression*>* args = expr->arguments(); |
| 4680 int arg_count = args->length(); |
| 4681 |
| 4682 // Record source position of the IC call. |
| 4683 SetSourcePosition(expr->position()); |
| 4684 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
| 4685 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); |
| 4686 __ CallStub(&stub); |
| 4687 } |
| 4688 |
| 4689 |
| 4617 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 4690 void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 4618 ZoneList<Expression*>* args = expr->arguments(); | 4691 ZoneList<Expression*>* args = expr->arguments(); |
| 4619 int arg_count = args->length(); | 4692 int arg_count = args->length(); |
| 4620 | 4693 |
| 4621 if (expr->is_jsruntime()) { | 4694 if (expr->is_jsruntime()) { |
| 4622 Comment cmnt(masm_, "[ CallRuntime"); | 4695 Comment cmnt(masm_, "[ CallRuntime"); |
| 4623 // Push the builtins object as the receiver. | 4696 EmitLoadJSRuntimeFunction(expr); |
| 4624 Register receiver = LoadDescriptor::ReceiverRegister(); | |
| 4625 __ ld(receiver, GlobalObjectOperand()); | |
| 4626 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | |
| 4627 __ push(receiver); | |
| 4628 | |
| 4629 // Load the function from the receiver. | |
| 4630 __ li(LoadDescriptor::NameRegister(), Operand(expr->name())); | |
| 4631 if (FLAG_vector_ics) { | |
| 4632 __ li(VectorLoadICDescriptor::SlotRegister(), | |
| 4633 Operand(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | |
| 4634 CallLoadIC(NOT_CONTEXTUAL); | |
| 4635 } else { | |
| 4636 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
| 4637 } | |
| 4638 | 4697 |
| 4639 // Push the target function under the receiver. | 4698 // Push the target function under the receiver. |
| 4640 __ ld(at, MemOperand(sp, 0)); | 4699 __ ld(at, MemOperand(sp, 0)); |
| 4641 __ push(at); | 4700 __ push(at); |
| 4642 __ sd(v0, MemOperand(sp, kPointerSize)); | 4701 __ sd(v0, MemOperand(sp, kPointerSize)); |
| 4643 | 4702 |
| 4644 // Push the arguments ("left-to-right"). | 4703 // Push the arguments ("left-to-right"). |
| 4645 for (int i = 0; i < arg_count; i++) { | 4704 for (int i = 0; i < arg_count; i++) { |
| 4646 VisitForStackValue(args->at(i)); | 4705 VisitForStackValue(args->at(i)); |
| 4647 } | 4706 } |
| 4648 | 4707 |
| 4649 // Record source position of the IC call. | 4708 EmitCallJSRuntimeFunction(expr); |
| 4650 SetSourcePosition(expr->position()); | |
| 4651 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | |
| 4652 __ ld(a1, MemOperand(sp, (arg_count + 1) * kPointerSize)); | |
| 4653 __ CallStub(&stub); | |
| 4654 | 4709 |
| 4655 // Restore context register. | 4710 // Restore context register. |
| 4656 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4711 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 4657 | 4712 |
| 4658 context()->DropAndPlug(1, v0); | 4713 context()->DropAndPlug(1, v0); |
| 4659 } else { | 4714 } else { |
| 4660 const Runtime::Function* function = expr->function(); | 4715 const Runtime::Function* function = expr->function(); |
| 4661 switch (function->function_id) { | 4716 switch (function->function_id) { |
| 4662 #define CALL_INTRINSIC_GENERATOR(Name) \ | 4717 #define CALL_INTRINSIC_GENERATOR(Name) \ |
| 4663 case Runtime::kInline##Name: { \ | 4718 case Runtime::kInline##Name: { \ |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5423 Assembler::target_address_at(pc_immediate_load_address)) == | 5478 Assembler::target_address_at(pc_immediate_load_address)) == |
| 5424 reinterpret_cast<uint64_t>( | 5479 reinterpret_cast<uint64_t>( |
| 5425 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5480 isolate->builtins()->OsrAfterStackCheck()->entry())); |
| 5426 return OSR_AFTER_STACK_CHECK; | 5481 return OSR_AFTER_STACK_CHECK; |
| 5427 } | 5482 } |
| 5428 | 5483 |
| 5429 | 5484 |
| 5430 } } // namespace v8::internal | 5485 } } // namespace v8::internal |
| 5431 | 5486 |
| 5432 #endif // V8_TARGET_ARCH_MIPS64 | 5487 #endif // V8_TARGET_ARCH_MIPS64 |
| OLD | NEW |