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_X87 | 5 #if V8_TARGET_ARCH_X87 |
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 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 break; | 1195 break; |
1196 } | 1196 } |
1197 | 1197 |
1198 case VariableLocation::PARAMETER: | 1198 case VariableLocation::PARAMETER: |
1199 case VariableLocation::LOCAL: | 1199 case VariableLocation::LOCAL: |
1200 case VariableLocation::CONTEXT: { | 1200 case VariableLocation::CONTEXT: { |
1201 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); | 1201 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); |
1202 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1202 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1203 : "[ Stack variable"); | 1203 : "[ Stack variable"); |
1204 | 1204 |
1205 if (proxy->needs_hole_check()) { | 1205 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) { |
1206 // Throw a reference error when using an uninitialized let/const | 1206 // Throw a reference error when using an uninitialized let/const |
1207 // binding in harmony mode. | 1207 // binding in harmony mode. |
1208 Label done; | 1208 Label done; |
1209 GetVar(eax, var); | 1209 GetVar(eax, var); |
1210 __ cmp(eax, isolate()->factory()->the_hole_value()); | 1210 __ cmp(eax, isolate()->factory()->the_hole_value()); |
1211 __ j(not_equal, &done, Label::kNear); | 1211 __ j(not_equal, &done, Label::kNear); |
1212 __ push(Immediate(var->name())); | 1212 __ push(Immediate(var->name())); |
1213 __ CallRuntime(Runtime::kThrowReferenceError); | 1213 __ CallRuntime(Runtime::kThrowReferenceError); |
1214 __ bind(&done); | 1214 __ bind(&done); |
1215 context()->Plug(eax); | 1215 context()->Plug(eax); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 // Deoptimization point in case the binary operation may have side effects. | 1628 // Deoptimization point in case the binary operation may have side effects. |
1629 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); | 1629 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); |
1630 } else { | 1630 } else { |
1631 VisitForAccumulatorValue(expr->value()); | 1631 VisitForAccumulatorValue(expr->value()); |
1632 } | 1632 } |
1633 | 1633 |
1634 SetExpressionPosition(expr); | 1634 SetExpressionPosition(expr); |
1635 | 1635 |
1636 // Store the value. | 1636 // Store the value. |
1637 switch (assign_type) { | 1637 switch (assign_type) { |
1638 case VARIABLE: | 1638 case VARIABLE: { |
1639 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), | 1639 VariableProxy* proxy = expr->target()->AsVariableProxy(); |
1640 expr->op(), expr->AssignmentSlot()); | 1640 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(), |
| 1641 proxy->hole_check_mode()); |
1641 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 1642 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
1642 context()->Plug(eax); | 1643 context()->Plug(eax); |
1643 break; | 1644 break; |
| 1645 } |
1644 case NAMED_PROPERTY: | 1646 case NAMED_PROPERTY: |
1645 EmitNamedPropertyAssignment(expr); | 1647 EmitNamedPropertyAssignment(expr); |
1646 break; | 1648 break; |
1647 case NAMED_SUPER_PROPERTY: | 1649 case NAMED_SUPER_PROPERTY: |
1648 EmitNamedSuperPropertyStore(property); | 1650 EmitNamedSuperPropertyStore(property); |
1649 context()->Plug(result_register()); | 1651 context()->Plug(result_register()); |
1650 break; | 1652 break; |
1651 case KEYED_SUPER_PROPERTY: | 1653 case KEYED_SUPER_PROPERTY: |
1652 EmitKeyedSuperPropertyStore(property); | 1654 EmitKeyedSuperPropertyStore(property); |
1653 context()->Plug(result_register()); | 1655 context()->Plug(result_register()); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1914 |
1913 void FullCodeGenerator::EmitAssignment(Expression* expr, | 1915 void FullCodeGenerator::EmitAssignment(Expression* expr, |
1914 FeedbackVectorSlot slot) { | 1916 FeedbackVectorSlot slot) { |
1915 DCHECK(expr->IsValidReferenceExpressionOrThis()); | 1917 DCHECK(expr->IsValidReferenceExpressionOrThis()); |
1916 | 1918 |
1917 Property* prop = expr->AsProperty(); | 1919 Property* prop = expr->AsProperty(); |
1918 LhsKind assign_type = Property::GetAssignType(prop); | 1920 LhsKind assign_type = Property::GetAssignType(prop); |
1919 | 1921 |
1920 switch (assign_type) { | 1922 switch (assign_type) { |
1921 case VARIABLE: { | 1923 case VARIABLE: { |
1922 Variable* var = expr->AsVariableProxy()->var(); | 1924 VariableProxy* proxy = expr->AsVariableProxy(); |
1923 EffectContext context(this); | 1925 EffectContext context(this); |
1924 EmitVariableAssignment(var, Token::ASSIGN, slot); | 1926 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot, |
| 1927 proxy->hole_check_mode()); |
1925 break; | 1928 break; |
1926 } | 1929 } |
1927 case NAMED_PROPERTY: { | 1930 case NAMED_PROPERTY: { |
1928 PushOperand(eax); // Preserve value. | 1931 PushOperand(eax); // Preserve value. |
1929 VisitForAccumulatorValue(prop->obj()); | 1932 VisitForAccumulatorValue(prop->obj()); |
1930 __ Move(StoreDescriptor::ReceiverRegister(), eax); | 1933 __ Move(StoreDescriptor::ReceiverRegister(), eax); |
1931 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. | 1934 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. |
1932 CallStoreIC(slot, prop->key()->AsLiteral()->value()); | 1935 CallStoreIC(slot, prop->key()->AsLiteral()->value()); |
1933 break; | 1936 break; |
1934 } | 1937 } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( | 1990 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( |
1988 Variable* var, MemOperand location) { | 1991 Variable* var, MemOperand location) { |
1989 __ mov(location, eax); | 1992 __ mov(location, eax); |
1990 if (var->IsContextSlot()) { | 1993 if (var->IsContextSlot()) { |
1991 __ mov(edx, eax); | 1994 __ mov(edx, eax); |
1992 int offset = Context::SlotOffset(var->index()); | 1995 int offset = Context::SlotOffset(var->index()); |
1993 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); | 1996 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
1994 } | 1997 } |
1995 } | 1998 } |
1996 | 1999 |
1997 | |
1998 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2000 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
1999 FeedbackVectorSlot slot) { | 2001 FeedbackVectorSlot slot, |
| 2002 HoleCheckMode hole_check_mode) { |
2000 if (var->IsUnallocated()) { | 2003 if (var->IsUnallocated()) { |
2001 // Global var, const, or let. | 2004 // Global var, const, or let. |
2002 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); | 2005 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); |
2003 __ mov(StoreDescriptor::ReceiverRegister(), | 2006 __ mov(StoreDescriptor::ReceiverRegister(), |
2004 ContextOperand(StoreDescriptor::ReceiverRegister(), | 2007 ContextOperand(StoreDescriptor::ReceiverRegister(), |
2005 Context::EXTENSION_INDEX)); | 2008 Context::EXTENSION_INDEX)); |
2006 CallStoreIC(slot, var->name()); | 2009 CallStoreIC(slot, var->name()); |
2007 | 2010 |
2008 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { | 2011 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { |
2009 DCHECK(!var->IsLookupSlot()); | 2012 DCHECK(!var->IsLookupSlot()); |
2010 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2013 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2011 MemOperand location = VarOperand(var, ecx); | 2014 MemOperand location = VarOperand(var, ecx); |
2012 // Perform an initialization check for lexically declared variables. | 2015 // Perform an initialization check for lexically declared variables. |
2013 if (var->binding_needs_init()) { | 2016 if (hole_check_mode == HoleCheckMode::kRequired) { |
2014 Label assign; | 2017 Label assign; |
2015 __ mov(edx, location); | 2018 __ mov(edx, location); |
2016 __ cmp(edx, isolate()->factory()->the_hole_value()); | 2019 __ cmp(edx, isolate()->factory()->the_hole_value()); |
2017 __ j(not_equal, &assign, Label::kNear); | 2020 __ j(not_equal, &assign, Label::kNear); |
2018 __ push(Immediate(var->name())); | 2021 __ push(Immediate(var->name())); |
2019 __ CallRuntime(Runtime::kThrowReferenceError); | 2022 __ CallRuntime(Runtime::kThrowReferenceError); |
2020 __ bind(&assign); | 2023 __ bind(&assign); |
2021 } | 2024 } |
2022 if (var->mode() != CONST) { | 2025 if (var->mode() != CONST) { |
2023 EmitStoreToStackLocalOrContextSlot(var, location); | 2026 EmitStoreToStackLocalOrContextSlot(var, location); |
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3069 __ mov(edx, eax); | 3072 __ mov(edx, eax); |
3070 __ mov(eax, Immediate(Smi::FromInt(1))); | 3073 __ mov(eax, Immediate(Smi::FromInt(1))); |
3071 Handle<Code> code = | 3074 Handle<Code> code = |
3072 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); | 3075 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); |
3073 CallIC(code, expr->CountBinOpFeedbackId()); | 3076 CallIC(code, expr->CountBinOpFeedbackId()); |
3074 patch_site.EmitPatchInfo(); | 3077 patch_site.EmitPatchInfo(); |
3075 __ bind(&done); | 3078 __ bind(&done); |
3076 | 3079 |
3077 // Store the value returned in eax. | 3080 // Store the value returned in eax. |
3078 switch (assign_type) { | 3081 switch (assign_type) { |
3079 case VARIABLE: | 3082 case VARIABLE: { |
| 3083 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
3080 if (expr->is_postfix()) { | 3084 if (expr->is_postfix()) { |
3081 // Perform the assignment as if via '='. | 3085 // Perform the assignment as if via '='. |
3082 { EffectContext context(this); | 3086 { EffectContext context(this); |
3083 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3087 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
3084 Token::ASSIGN, expr->CountSlot()); | 3088 proxy->hole_check_mode()); |
3085 PrepareForBailoutForId(expr->AssignmentId(), | 3089 PrepareForBailoutForId(expr->AssignmentId(), |
3086 BailoutState::TOS_REGISTER); | 3090 BailoutState::TOS_REGISTER); |
3087 context.Plug(eax); | 3091 context.Plug(eax); |
3088 } | 3092 } |
3089 // For all contexts except EffectContext We have the result on | 3093 // For all contexts except EffectContext We have the result on |
3090 // top of the stack. | 3094 // top of the stack. |
3091 if (!context()->IsEffect()) { | 3095 if (!context()->IsEffect()) { |
3092 context()->PlugTOS(); | 3096 context()->PlugTOS(); |
3093 } | 3097 } |
3094 } else { | 3098 } else { |
3095 // Perform the assignment as if via '='. | 3099 // Perform the assignment as if via '='. |
3096 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), | 3100 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(), |
3097 Token::ASSIGN, expr->CountSlot()); | 3101 proxy->hole_check_mode()); |
3098 PrepareForBailoutForId(expr->AssignmentId(), | 3102 PrepareForBailoutForId(expr->AssignmentId(), |
3099 BailoutState::TOS_REGISTER); | 3103 BailoutState::TOS_REGISTER); |
3100 context()->Plug(eax); | 3104 context()->Plug(eax); |
3101 } | 3105 } |
3102 break; | 3106 break; |
| 3107 } |
3103 case NAMED_PROPERTY: { | 3108 case NAMED_PROPERTY: { |
3104 PopOperand(StoreDescriptor::ReceiverRegister()); | 3109 PopOperand(StoreDescriptor::ReceiverRegister()); |
3105 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); | 3110 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); |
3106 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); | 3111 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); |
3107 if (expr->is_postfix()) { | 3112 if (expr->is_postfix()) { |
3108 if (!context()->IsEffect()) { | 3113 if (!context()->IsEffect()) { |
3109 context()->PlugTOS(); | 3114 context()->PlugTOS(); |
3110 } | 3115 } |
3111 } else { | 3116 } else { |
3112 context()->Plug(eax); | 3117 context()->Plug(eax); |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3515 isolate->builtins()->OnStackReplacement()->entry(), | 3520 isolate->builtins()->OnStackReplacement()->entry(), |
3516 Assembler::target_address_at(call_target_address, unoptimized_code)); | 3521 Assembler::target_address_at(call_target_address, unoptimized_code)); |
3517 return ON_STACK_REPLACEMENT; | 3522 return ON_STACK_REPLACEMENT; |
3518 } | 3523 } |
3519 | 3524 |
3520 | 3525 |
3521 } // namespace internal | 3526 } // namespace internal |
3522 } // namespace v8 | 3527 } // namespace v8 |
3523 | 3528 |
3524 #endif // V8_TARGET_ARCH_X87 | 3529 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |