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/full-codegen/full-codegen.h" | 7 #include "src/full-codegen/full-codegen.h" |
8 #include "src/ast/compile-time-value.h" | 8 #include "src/ast/compile-time-value.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/code-factory.h" | 10 #include "src/code-factory.h" |
(...skipping 1269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 context()->Plug(r0); | 1280 context()->Plug(r0); |
1281 break; | 1281 break; |
1282 } | 1282 } |
1283 | 1283 |
1284 case VariableLocation::PARAMETER: | 1284 case VariableLocation::PARAMETER: |
1285 case VariableLocation::LOCAL: | 1285 case VariableLocation::LOCAL: |
1286 case VariableLocation::CONTEXT: { | 1286 case VariableLocation::CONTEXT: { |
1287 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1287 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
1288 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1288 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1289 : "[ Stack variable"); | 1289 : "[ Stack variable"); |
1290 if (proxy->needs_hole_check()) { | 1290 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) { |
1291 // Throw a reference error when using an uninitialized let/const | 1291 // Throw a reference error when using an uninitialized let/const |
1292 // binding in harmony mode. | 1292 // binding in harmony mode. |
1293 Label done; | 1293 Label done; |
1294 GetVar(r0, var); | 1294 GetVar(r0, var); |
1295 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); | 1295 __ CompareRoot(r0, Heap::kTheHoleValueRootIndex); |
1296 __ b(ne, &done); | 1296 __ b(ne, &done); |
1297 __ mov(r0, Operand(var->name())); | 1297 __ mov(r0, Operand(var->name())); |
1298 __ push(r0); | 1298 __ push(r0); |
1299 __ CallRuntime(Runtime::kThrowReferenceError); | 1299 __ CallRuntime(Runtime::kThrowReferenceError); |
1300 __ bind(&done); | 1300 __ bind(&done); |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 // Deoptimization point in case the binary operation may have side effects. | 1723 // Deoptimization point in case the binary operation may have side effects. |
1724 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); | 1724 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); |
1725 } else { | 1725 } else { |
1726 VisitForAccumulatorValue(expr->value()); | 1726 VisitForAccumulatorValue(expr->value()); |
1727 } | 1727 } |
1728 | 1728 |
1729 SetExpressionPosition(expr); | 1729 SetExpressionPosition(expr); |
1730 | 1730 |
1731 // Store the value. | 1731 // Store the value. |
1732 switch (assign_type) { | 1732 switch (assign_type) { |
1733 case VARIABLE: | 1733 case VARIABLE: { |
1734 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1734 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
1735 expr->op(), expr->AssignmentSlot()); | 1735 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(), |
| 1736 proxy->hole_check_mode()); |
1736 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 1737 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
1737 context()->Plug(r0); | 1738 context()->Plug(r0); |
1738 break; | 1739 break; |
| 1740 } |
1739 case NAMED_PROPERTY: | 1741 case NAMED_PROPERTY: |
1740 EmitNamedPropertyAssignment(expr); | 1742 EmitNamedPropertyAssignment(expr); |
1741 break; | 1743 break; |
1742 case NAMED_SUPER_PROPERTY: | 1744 case NAMED_SUPER_PROPERTY: |
1743 EmitNamedSuperPropertyStore(property); | 1745 EmitNamedSuperPropertyStore(property); |
1744 context()->Plug(r0); | 1746 context()->Plug(r0); |
1745 break; | 1747 break; |
1746 case KEYED_SUPER_PROPERTY: | 1748 case KEYED_SUPER_PROPERTY: |
1747 EmitKeyedSuperPropertyStore(property); | 1749 EmitKeyedSuperPropertyStore(property); |
1748 context()->Plug(r0); | 1750 context()->Plug(r0); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 | 2012 |
2011 void FullCodeGenerator::EmitAssignment(Expression* expr, | 2013 void FullCodeGenerator::EmitAssignment(Expression* expr, |
2012 FeedbackVectorSlot slot) { | 2014 FeedbackVectorSlot slot) { |
2013 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 2015 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
2014 | 2016 |
2015 Property* prop = expr->AsProperty(); | 2017 Property* prop = expr->AsProperty(); |
2016 LhsKind assign_type = Property::GetAssignType(prop); | 2018 LhsKind assign_type = Property::GetAssignType(prop); |
2017 | 2019 |
2018 switch (assign_type) { | 2020 switch (assign_type) { |
2019 case VARIABLE: { | 2021 case VARIABLE: { |
2020 Variable* var = expr->AsVariableProxy()->var(); | 2022 VariableProxy* proxy = expr->AsVariableProxy(); |
2021 EffectContext context(this); | 2023 EffectContext context(this); |
2022 EmitVariableAssignment(var, Token::ASSIGN, slot); | 2024 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot, |
| 2025 proxy->hole_check_mode()); |
2023 break; | 2026 break; |
2024 } | 2027 } |
2025 case NAMED_PROPERTY: { | 2028 case NAMED_PROPERTY: { |
2026 PushOperand(r0); // Preserve value. | 2029 PushOperand(r0); // Preserve value. |
2027 VisitForAccumulatorValue(prop->obj()); | 2030 VisitForAccumulatorValue(prop->obj()); |
2028 __ Move(StoreDescriptor::ReceiverRegister(), r0); | 2031 __ Move(StoreDescriptor::ReceiverRegister(), r0); |
2029 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 2032 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
2030 CallStoreIC(slot, prop->key()->AsLiteral()->value()); | 2033 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
2031 break; | 2034 break; |
2032 } | 2035 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2087 __ str(result_register(), location); | 2090 __ str(result_register(), location); |
2088 if (var->IsContextSlot()) { | 2091 if (var->IsContextSlot()) { |
2089 // RecordWrite may destroy all its register arguments. | 2092 // RecordWrite may destroy all its register arguments. |
2090 __ mov(r3, result_register()); | 2093 __ mov(r3, result_register()); |
2091 int offset = Context::SlotOffset(var->index()); | 2094 int offset = Context::SlotOffset(var->index()); |
2092 __ RecordWriteContextSlot( | 2095 __ RecordWriteContextSlot( |
2093 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); | 2096 r1, offset, r3, r2, kLRHasBeenSaved, kDontSaveFPRegs); |
2094 } | 2097 } |
2095 } | 2098 } |
2096 | 2099 |
2097 | |
2098 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2100 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2099 FeedbackVectorSlot slot) { | 2101 FeedbackVectorSlot slot, |
| 2102 HoleCheckMode hole_check_mode) { |
2100 if (var->IsUnallocated()) { | 2103 if (var->IsUnallocated()) { |
2101 // Global var, const, or let. | 2104 // Global var, const, or let. |
2102 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); | 2105 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); |
2103 CallStoreIC(slot, var->name()); | 2106 CallStoreIC(slot, var->name()); |
2104 | 2107 |
2105 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 2108 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
2106 DCHECK(!var->IsLookupSlot()); | 2109 DCHECK(!var->IsLookupSlot()); |
2107 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2110 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2108 MemOperand location = VarOperand(var, r1); | 2111 MemOperand location = VarOperand(var, r1); |
2109 // Perform an initialization check for lexically declared variables. | 2112 // Perform an initialization check for lexically declared variables. |
2110 if (var->binding_needs_init()) { | 2113 if (hole_check_mode == HoleCheckMode::kRequired) { |
2111 Label assign; | 2114 Label assign; |
2112 __ ldr(r3, location); | 2115 __ ldr(r3, location); |
2113 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); | 2116 __ CompareRoot(r3, Heap::kTheHoleValueRootIndex); |
2114 __ b(ne, &assign); | 2117 __ b(ne, &assign); |
2115 __ mov(r3, Operand(var->name())); | 2118 __ mov(r3, Operand(var->name())); |
2116 __ push(r3); | 2119 __ push(r3); |
2117 __ CallRuntime(Runtime::kThrowReferenceError); | 2120 __ CallRuntime(Runtime::kThrowReferenceError); |
2118 __ bind(&assign); | 2121 __ bind(&assign); |
2119 } | 2122 } |
2120 if (var->mode() != CONST) { | 2123 if (var->mode() != CONST) { |
(...skipping 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 | 3184 |
3182 SetExpressionPosition(expr); | 3185 SetExpressionPosition(expr); |
3183 | 3186 |
3184 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), Token::ADD).code(); | 3187 Handle<Code> code = CodeFactory::BinaryOpIC(isolate(), Token::ADD).code(); |
3185 CallIC(code, expr->CountBinOpFeedbackId()); | 3188 CallIC(code, expr->CountBinOpFeedbackId()); |
3186 patch_site.EmitPatchInfo(); | 3189 patch_site.EmitPatchInfo(); |
3187 __ bind(&done); | 3190 __ bind(&done); |
3188 | 3191 |
3189 // Store the value returned in r0. | 3192 // Store the value returned in r0. |
3190 switch (assign_type) { | 3193 switch (assign_type) { |
3191 case VARIABLE: | 3194 case VARIABLE: { |
| 3195 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
3192 if (expr->is_postfix()) { | 3196 if (expr->is_postfix()) { |
3193 { EffectContext context(this); | 3197 { EffectContext context(this); |
3194 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3198 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
3195 Token::ASSIGN, expr->CountSlot()); | 3199 proxy->hole_check_mode()); |
3196 PrepareForBailoutForId(expr->AssignmentId(), | 3200 PrepareForBailoutForId(expr->AssignmentId(), |
3197 BailoutState::TOS_REGISTER); | 3201 BailoutState::TOS_REGISTER); |
3198 context.Plug(r0); | 3202 context.Plug(r0); |
3199 } | 3203 } |
3200 // For all contexts except EffectConstant We have the result on | 3204 // For all contexts except EffectConstant We have the result on |
3201 // top of the stack. | 3205 // top of the stack. |
3202 if (!context()->IsEffect()) { | 3206 if (!context()->IsEffect()) { |
3203 context()->PlugTOS(); | 3207 context()->PlugTOS(); |
3204 } | 3208 } |
3205 } else { | 3209 } else { |
3206 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3210 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
3207 Token::ASSIGN, expr->CountSlot()); | 3211 proxy->hole_check_mode()); |
3208 PrepareForBailoutForId(expr->AssignmentId(), | 3212 PrepareForBailoutForId(expr->AssignmentId(), |
3209 BailoutState::TOS_REGISTER); | 3213 BailoutState::TOS_REGISTER); |
3210 context()->Plug(r0); | 3214 context()->Plug(r0); |
3211 } | 3215 } |
3212 break; | 3216 break; |
| 3217 } |
3213 case NAMED_PROPERTY: { | 3218 case NAMED_PROPERTY: { |
3214 PopOperand(StoreDescriptor::ReceiverRegister()); | 3219 PopOperand(StoreDescriptor::ReceiverRegister()); |
3215 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); | 3220 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
3216 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 3221 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3217 if (expr->is_postfix()) { | 3222 if (expr->is_postfix()) { |
3218 if (!context()->IsEffect()) { | 3223 if (!context()->IsEffect()) { |
3219 context()->PlugTOS(); | 3224 context()->PlugTOS(); |
3220 } | 3225 } |
3221 } else { | 3226 } else { |
3222 context()->Plug(r0); | 3227 context()->Plug(r0); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3693 DCHECK(interrupt_address == | 3698 DCHECK(interrupt_address == |
3694 isolate->builtins()->OnStackReplacement()->entry()); | 3699 isolate->builtins()->OnStackReplacement()->entry()); |
3695 return ON_STACK_REPLACEMENT; | 3700 return ON_STACK_REPLACEMENT; |
3696 } | 3701 } |
3697 | 3702 |
3698 | 3703 |
3699 } // namespace internal | 3704 } // namespace internal |
3700 } // namespace v8 | 3705 } // namespace v8 |
3701 | 3706 |
3702 #endif // V8_TARGET_ARCH_ARM | 3707 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |