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 1971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 if (result_saved) { | 1982 if (result_saved) { |
1983 __ Pop(); // literal index | 1983 __ Pop(); // literal index |
1984 context()->PlugTOS(); | 1984 context()->PlugTOS(); |
1985 } else { | 1985 } else { |
1986 context()->Plug(v0); | 1986 context()->Plug(v0); |
1987 } | 1987 } |
1988 } | 1988 } |
1989 | 1989 |
1990 | 1990 |
1991 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1991 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
1992 DCHECK(expr->target()->IsValidReferenceExpression()); | 1992 DCHECK(expr->target()->IsValidReferenceExpressionOrThis()); |
1993 | 1993 |
1994 Comment cmnt(masm_, "[ Assignment"); | 1994 Comment cmnt(masm_, "[ Assignment"); |
1995 SetExpressionPosition(expr, INSERT_BREAK); | 1995 SetExpressionPosition(expr, INSERT_BREAK); |
1996 | 1996 |
1997 Property* property = expr->target()->AsProperty(); | 1997 Property* property = expr->target()->AsProperty(); |
1998 LhsKind assign_type = Property::GetAssignType(property); | 1998 LhsKind assign_type = Property::GetAssignType(property); |
1999 | 1999 |
2000 // Evaluate LHS expression. | 2000 // Evaluate LHS expression. |
2001 switch (assign_type) { | 2001 switch (assign_type) { |
2002 case VARIABLE: | 2002 case VARIABLE: |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2652 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code(); | 2652 CodeFactory::BinaryOpIC(isolate(), op, strength(language_mode())).code(); |
2653 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. | 2653 JumpPatchSite patch_site(masm_); // unbound, signals no inlined smi code. |
2654 CallIC(code, expr->BinaryOperationFeedbackId()); | 2654 CallIC(code, expr->BinaryOperationFeedbackId()); |
2655 patch_site.EmitPatchInfo(); | 2655 patch_site.EmitPatchInfo(); |
2656 context()->Plug(v0); | 2656 context()->Plug(v0); |
2657 } | 2657 } |
2658 | 2658 |
2659 | 2659 |
2660 void FullCodeGenerator::EmitAssignment(Expression* expr, | 2660 void FullCodeGenerator::EmitAssignment(Expression* expr, |
2661 FeedbackVectorICSlot slot) { | 2661 FeedbackVectorICSlot slot) { |
2662 DCHECK(expr->IsValidReferenceExpression()); | 2662 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
2663 | 2663 |
2664 Property* prop = expr->AsProperty(); | 2664 Property* prop = expr->AsProperty(); |
2665 LhsKind assign_type = Property::GetAssignType(prop); | 2665 LhsKind assign_type = Property::GetAssignType(prop); |
2666 | 2666 |
2667 switch (assign_type) { | 2667 switch (assign_type) { |
2668 case VARIABLE: { | 2668 case VARIABLE: { |
2669 Variable* var = expr->AsVariableProxy()->var(); | 2669 Variable* var = expr->AsVariableProxy()->var(); |
2670 EffectContext context(this); | 2670 EffectContext context(this); |
2671 EmitVariableAssignment(var, Token::ASSIGN, slot); | 2671 EmitVariableAssignment(var, Token::ASSIGN, slot); |
2672 break; | 2672 break; |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2801 MemOperand location = VarOperand(var, a1); | 2801 MemOperand location = VarOperand(var, a1); |
2802 __ ld(a3, location); | 2802 __ ld(a3, location); |
2803 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | 2803 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
2804 __ Branch(&const_error, ne, a3, Operand(at)); | 2804 __ Branch(&const_error, ne, a3, Operand(at)); |
2805 __ li(a3, Operand(var->name())); | 2805 __ li(a3, Operand(var->name())); |
2806 __ push(a3); | 2806 __ push(a3); |
2807 __ CallRuntime(Runtime::kThrowReferenceError, 1); | 2807 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
2808 __ bind(&const_error); | 2808 __ bind(&const_error); |
2809 __ CallRuntime(Runtime::kThrowConstAssignError, 0); | 2809 __ CallRuntime(Runtime::kThrowConstAssignError, 0); |
2810 | 2810 |
| 2811 } else if (var->is_this() && op == Token::INIT_CONST) { |
| 2812 // Initializing assignment to const {this} needs a write barrier. |
| 2813 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
| 2814 Label uninitialized_this; |
| 2815 MemOperand location = VarOperand(var, a1); |
| 2816 __ ld(a3, location); |
| 2817 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); |
| 2818 __ Branch(&uninitialized_this, eq, a3, Operand(at)); |
| 2819 __ li(a0, Operand(var->name())); |
| 2820 __ Push(a0); |
| 2821 __ CallRuntime(Runtime::kThrowReferenceError, 1); |
| 2822 __ bind(&uninitialized_this); |
| 2823 EmitStoreToStackLocalOrContextSlot(var, location); |
| 2824 |
2811 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { | 2825 } else if (!var->is_const_mode() || op == Token::INIT_CONST) { |
2812 if (var->IsLookupSlot()) { | 2826 if (var->IsLookupSlot()) { |
2813 // Assignment to var. | 2827 // Assignment to var. |
2814 __ li(a4, Operand(var->name())); | 2828 __ li(a4, Operand(var->name())); |
2815 __ li(a3, Operand(Smi::FromInt(language_mode()))); | 2829 __ li(a3, Operand(Smi::FromInt(language_mode()))); |
2816 // jssp[0] : language mode. | 2830 // jssp[0] : language mode. |
2817 // jssp[8] : name. | 2831 // jssp[8] : name. |
2818 // jssp[16] : context. | 2832 // jssp[16] : context. |
2819 // jssp[24] : value. | 2833 // jssp[24] : value. |
2820 __ Push(v0, cp, a4, a3); | 2834 __ Push(v0, cp, a4, a3); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3153 | 3167 |
3154 // a1: the start position of the scope the calls resides in. | 3168 // a1: the start position of the scope the calls resides in. |
3155 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); | 3169 __ li(a1, Operand(Smi::FromInt(scope()->start_position()))); |
3156 | 3170 |
3157 // Do the runtime call. | 3171 // Do the runtime call. |
3158 __ Push(a6, a5, a4, a1); | 3172 __ Push(a6, a5, a4, a1); |
3159 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); | 3173 __ CallRuntime(Runtime::kResolvePossiblyDirectEval, 5); |
3160 } | 3174 } |
3161 | 3175 |
3162 | 3176 |
3163 void FullCodeGenerator::EmitInitializeThisAfterSuper( | |
3164 SuperCallReference* super_ref, FeedbackVectorICSlot slot) { | |
3165 Variable* this_var = super_ref->this_var()->var(); | |
3166 GetVar(a1, this_var); | |
3167 __ LoadRoot(at, Heap::kTheHoleValueRootIndex); | |
3168 Label uninitialized_this; | |
3169 __ Branch(&uninitialized_this, eq, a1, Operand(at)); | |
3170 __ li(a0, Operand(this_var->name())); | |
3171 __ Push(a0); | |
3172 __ CallRuntime(Runtime::kThrowReferenceError, 1); | |
3173 __ bind(&uninitialized_this); | |
3174 | |
3175 EmitVariableAssignment(this_var, Token::INIT_CONST, slot); | |
3176 } | |
3177 | |
3178 | |
3179 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. | 3177 // See http://www.ecma-international.org/ecma-262/6.0/#sec-function-calls. |
3180 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { | 3178 void FullCodeGenerator::PushCalleeAndWithBaseObject(Call* expr) { |
3181 VariableProxy* callee = expr->expression()->AsVariableProxy(); | 3179 VariableProxy* callee = expr->expression()->AsVariableProxy(); |
3182 if (callee->var()->IsLookupSlot()) { | 3180 if (callee->var()->IsLookupSlot()) { |
3183 Label slow, done; | 3181 Label slow, done; |
3184 | 3182 |
3185 SetExpressionPosition(callee); | 3183 SetExpressionPosition(callee); |
3186 // Generate code for loading from variables potentially shadowed by | 3184 // Generate code for loading from variables potentially shadowed by |
3187 // eval-introduced variables. | 3185 // eval-introduced variables. |
3188 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); | 3186 EmitDynamicLookupFastCase(callee, NOT_INSIDE_TYPEOF, &slow, &done); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3388 } | 3386 } |
3389 | 3387 |
3390 __ li(a2, FeedbackVector()); | 3388 __ li(a2, FeedbackVector()); |
3391 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); | 3389 __ li(a3, Operand(SmiFromSlot(expr->CallFeedbackSlot()))); |
3392 | 3390 |
3393 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); | 3391 CallConstructStub stub(isolate(), SUPER_CALL_RECORD_TARGET); |
3394 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); | 3392 __ Call(stub.GetCode(), RelocInfo::CONSTRUCT_CALL); |
3395 | 3393 |
3396 RecordJSReturnSite(expr); | 3394 RecordJSReturnSite(expr); |
3397 | 3395 |
3398 EmitInitializeThisAfterSuper(super_call_ref, expr->CallFeedbackICSlot()); | |
3399 context()->Plug(v0); | 3396 context()->Plug(v0); |
3400 } | 3397 } |
3401 | 3398 |
3402 | 3399 |
3403 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { | 3400 void FullCodeGenerator::EmitIsSmi(CallRuntime* expr) { |
3404 ZoneList<Expression*>* args = expr->arguments(); | 3401 ZoneList<Expression*>* args = expr->arguments(); |
3405 DCHECK(args->length() == 1); | 3402 DCHECK(args->length() == 1); |
3406 | 3403 |
3407 VisitForAccumulatorValue(args->at(0)); | 3404 VisitForAccumulatorValue(args->at(0)); |
3408 | 3405 |
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4756 | 4753 |
4757 // Push NewTarget | 4754 // Push NewTarget |
4758 DCHECK(args->at(2)->IsVariableProxy()); | 4755 DCHECK(args->at(2)->IsVariableProxy()); |
4759 VisitForStackValue(args->at(2)); | 4756 VisitForStackValue(args->at(2)); |
4760 | 4757 |
4761 EmitCallJSRuntimeFunction(call); | 4758 EmitCallJSRuntimeFunction(call); |
4762 | 4759 |
4763 // Restore context register. | 4760 // Restore context register. |
4764 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 4761 __ ld(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
4765 context()->DropAndPlug(1, v0); | 4762 context()->DropAndPlug(1, v0); |
4766 | |
4767 // TODO(mvstanton): with FLAG_vector_stores this needs a slot id. | |
4768 EmitInitializeThisAfterSuper(super_call_ref); | |
4769 } | 4763 } |
4770 | 4764 |
4771 | 4765 |
4772 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4766 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4773 // Push the builtins object as the receiver. | 4767 // Push the builtins object as the receiver. |
4774 Register receiver = LoadDescriptor::ReceiverRegister(); | 4768 Register receiver = LoadDescriptor::ReceiverRegister(); |
4775 __ ld(receiver, GlobalObjectOperand()); | 4769 __ ld(receiver, GlobalObjectOperand()); |
4776 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); | 4770 __ ld(receiver, FieldMemOperand(receiver, GlobalObject::kBuiltinsOffset)); |
4777 __ push(receiver); | 4771 __ push(receiver); |
4778 | 4772 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4955 break; | 4949 break; |
4956 } | 4950 } |
4957 | 4951 |
4958 default: | 4952 default: |
4959 UNREACHABLE(); | 4953 UNREACHABLE(); |
4960 } | 4954 } |
4961 } | 4955 } |
4962 | 4956 |
4963 | 4957 |
4964 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { | 4958 void FullCodeGenerator::VisitCountOperation(CountOperation* expr) { |
4965 DCHECK(expr->expression()->IsValidReferenceExpression()); | 4959 DCHECK(expr->expression()->IsValidReferenceExpressionOrThis()); |
4966 | 4960 |
4967 Comment cmnt(masm_, "[ CountOperation"); | 4961 Comment cmnt(masm_, "[ CountOperation"); |
4968 | 4962 |
4969 Property* prop = expr->expression()->AsProperty(); | 4963 Property* prop = expr->expression()->AsProperty(); |
4970 LhsKind assign_type = Property::GetAssignType(prop); | 4964 LhsKind assign_type = Property::GetAssignType(prop); |
4971 | 4965 |
4972 // Evaluate expression and get value. | 4966 // Evaluate expression and get value. |
4973 if (assign_type == VARIABLE) { | 4967 if (assign_type == VARIABLE) { |
4974 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); | 4968 DCHECK(expr->expression()->AsVariableProxy()->var() != NULL); |
4975 AccumulatorValueContext context(this); | 4969 AccumulatorValueContext context(this); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5594 reinterpret_cast<uint64_t>( | 5588 reinterpret_cast<uint64_t>( |
5595 isolate->builtins()->OsrAfterStackCheck()->entry())); | 5589 isolate->builtins()->OsrAfterStackCheck()->entry())); |
5596 return OSR_AFTER_STACK_CHECK; | 5590 return OSR_AFTER_STACK_CHECK; |
5597 } | 5591 } |
5598 | 5592 |
5599 | 5593 |
5600 } // namespace internal | 5594 } // namespace internal |
5601 } // namespace v8 | 5595 } // namespace v8 |
5602 | 5596 |
5603 #endif // V8_TARGET_ARCH_MIPS64 | 5597 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |