Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/full-codegen/ia32/full-codegen-ia32.cc

Issue 2441543005: [full-codegen] Eliminate unnecessary hole checks for stores (Closed)
Patch Set: Merge and fix modules Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_IA32 5 #if V8_TARGET_ARCH_IA32
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 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 break; 1203 break;
1204 } 1204 }
1205 1205
1206 case VariableLocation::PARAMETER: 1206 case VariableLocation::PARAMETER:
1207 case VariableLocation::LOCAL: 1207 case VariableLocation::LOCAL:
1208 case VariableLocation::CONTEXT: { 1208 case VariableLocation::CONTEXT: {
1209 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1209 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1210 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" 1210 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable"
1211 : "[ Stack variable"); 1211 : "[ Stack variable");
1212 1212
1213 if (proxy->needs_hole_check()) { 1213 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) {
1214 // Throw a reference error when using an uninitialized let/const 1214 // Throw a reference error when using an uninitialized let/const
1215 // binding in harmony mode. 1215 // binding in harmony mode.
1216 Label done; 1216 Label done;
1217 GetVar(eax, var); 1217 GetVar(eax, var);
1218 __ cmp(eax, isolate()->factory()->the_hole_value()); 1218 __ cmp(eax, isolate()->factory()->the_hole_value());
1219 __ j(not_equal, &done, Label::kNear); 1219 __ j(not_equal, &done, Label::kNear);
1220 __ push(Immediate(var->name())); 1220 __ push(Immediate(var->name()));
1221 __ CallRuntime(Runtime::kThrowReferenceError); 1221 __ CallRuntime(Runtime::kThrowReferenceError);
1222 __ bind(&done); 1222 __ bind(&done);
1223 context()->Plug(eax); 1223 context()->Plug(eax);
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 // Deoptimization point in case the binary operation may have side effects. 1636 // Deoptimization point in case the binary operation may have side effects.
1637 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); 1637 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER);
1638 } else { 1638 } else {
1639 VisitForAccumulatorValue(expr->value()); 1639 VisitForAccumulatorValue(expr->value());
1640 } 1640 }
1641 1641
1642 SetExpressionPosition(expr); 1642 SetExpressionPosition(expr);
1643 1643
1644 // Store the value. 1644 // Store the value.
1645 switch (assign_type) { 1645 switch (assign_type) {
1646 case VARIABLE: 1646 case VARIABLE: {
1647 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), 1647 VariableProxy* proxy = expr->target()->AsVariableProxy();
1648 expr->op(), expr->AssignmentSlot()); 1648 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(),
1649 proxy->hole_check_mode());
1649 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 1650 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
1650 context()->Plug(eax); 1651 context()->Plug(eax);
1651 break; 1652 break;
1653 }
1652 case NAMED_PROPERTY: 1654 case NAMED_PROPERTY:
1653 EmitNamedPropertyAssignment(expr); 1655 EmitNamedPropertyAssignment(expr);
1654 break; 1656 break;
1655 case NAMED_SUPER_PROPERTY: 1657 case NAMED_SUPER_PROPERTY:
1656 EmitNamedSuperPropertyStore(property); 1658 EmitNamedSuperPropertyStore(property);
1657 context()->Plug(result_register()); 1659 context()->Plug(result_register());
1658 break; 1660 break;
1659 case KEYED_SUPER_PROPERTY: 1661 case KEYED_SUPER_PROPERTY:
1660 EmitKeyedSuperPropertyStore(property); 1662 EmitKeyedSuperPropertyStore(property);
1661 context()->Plug(result_register()); 1663 context()->Plug(result_register());
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 1922
1921 void FullCodeGenerator::EmitAssignment(Expression* expr, 1923 void FullCodeGenerator::EmitAssignment(Expression* expr,
1922 FeedbackVectorSlot slot) { 1924 FeedbackVectorSlot slot) {
1923 DCHECK(expr->IsValidReferenceExpressionOrThis()); 1925 DCHECK(expr->IsValidReferenceExpressionOrThis());
1924 1926
1925 Property* prop = expr->AsProperty(); 1927 Property* prop = expr->AsProperty();
1926 LhsKind assign_type = Property::GetAssignType(prop); 1928 LhsKind assign_type = Property::GetAssignType(prop);
1927 1929
1928 switch (assign_type) { 1930 switch (assign_type) {
1929 case VARIABLE: { 1931 case VARIABLE: {
1930 Variable* var = expr->AsVariableProxy()->var(); 1932 VariableProxy* proxy = expr->AsVariableProxy();
1931 EffectContext context(this); 1933 EffectContext context(this);
1932 EmitVariableAssignment(var, Token::ASSIGN, slot); 1934 EmitVariableAssignment(proxy->var(), Token::ASSIGN, slot,
1935 proxy->hole_check_mode());
1933 break; 1936 break;
1934 } 1937 }
1935 case NAMED_PROPERTY: { 1938 case NAMED_PROPERTY: {
1936 PushOperand(eax); // Preserve value. 1939 PushOperand(eax); // Preserve value.
1937 VisitForAccumulatorValue(prop->obj()); 1940 VisitForAccumulatorValue(prop->obj());
1938 __ Move(StoreDescriptor::ReceiverRegister(), eax); 1941 __ Move(StoreDescriptor::ReceiverRegister(), eax);
1939 PopOperand(StoreDescriptor::ValueRegister()); // Restore value. 1942 PopOperand(StoreDescriptor::ValueRegister()); // Restore value.
1940 CallStoreIC(slot, prop->key()->AsLiteral()->value()); 1943 CallStoreIC(slot, prop->key()->AsLiteral()->value());
1941 break; 1944 break;
1942 } 1945 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( 1998 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
1996 Variable* var, MemOperand location) { 1999 Variable* var, MemOperand location) {
1997 __ mov(location, eax); 2000 __ mov(location, eax);
1998 if (var->IsContextSlot()) { 2001 if (var->IsContextSlot()) {
1999 __ mov(edx, eax); 2002 __ mov(edx, eax);
2000 int offset = Context::SlotOffset(var->index()); 2003 int offset = Context::SlotOffset(var->index());
2001 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); 2004 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs);
2002 } 2005 }
2003 } 2006 }
2004 2007
2005
2006 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, 2008 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
2007 FeedbackVectorSlot slot) { 2009 FeedbackVectorSlot slot,
2010 HoleCheckMode hole_check_mode) {
2008 if (var->IsUnallocated()) { 2011 if (var->IsUnallocated()) {
2009 // Global var, const, or let. 2012 // Global var, const, or let.
2010 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); 2013 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand());
2011 __ mov(StoreDescriptor::ReceiverRegister(), 2014 __ mov(StoreDescriptor::ReceiverRegister(),
2012 ContextOperand(StoreDescriptor::ReceiverRegister(), 2015 ContextOperand(StoreDescriptor::ReceiverRegister(),
2013 Context::EXTENSION_INDEX)); 2016 Context::EXTENSION_INDEX));
2014 CallStoreIC(slot, var->name()); 2017 CallStoreIC(slot, var->name());
2015 2018
2016 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2019 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2017 DCHECK(!var->IsLookupSlot()); 2020 DCHECK(!var->IsLookupSlot());
2018 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2021 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2019 MemOperand location = VarOperand(var, ecx); 2022 MemOperand location = VarOperand(var, ecx);
2020 // Perform an initialization check for lexically declared variables. 2023 // Perform an initialization check for lexically declared variables.
2021 if (var->binding_needs_init()) { 2024 if (hole_check_mode == HoleCheckMode::kRequired) {
2022 Label assign; 2025 Label assign;
2023 __ mov(edx, location); 2026 __ mov(edx, location);
2024 __ cmp(edx, isolate()->factory()->the_hole_value()); 2027 __ cmp(edx, isolate()->factory()->the_hole_value());
2025 __ j(not_equal, &assign, Label::kNear); 2028 __ j(not_equal, &assign, Label::kNear);
2026 __ push(Immediate(var->name())); 2029 __ push(Immediate(var->name()));
2027 __ CallRuntime(Runtime::kThrowReferenceError); 2030 __ CallRuntime(Runtime::kThrowReferenceError);
2028 __ bind(&assign); 2031 __ bind(&assign);
2029 } 2032 }
2030 if (var->mode() != CONST) { 2033 if (var->mode() != CONST) {
2031 EmitStoreToStackLocalOrContextSlot(var, location); 2034 EmitStoreToStackLocalOrContextSlot(var, location);
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3077 __ mov(edx, eax); 3080 __ mov(edx, eax);
3078 __ mov(eax, Immediate(Smi::FromInt(1))); 3081 __ mov(eax, Immediate(Smi::FromInt(1)));
3079 Handle<Code> code = 3082 Handle<Code> code =
3080 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); 3083 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code();
3081 CallIC(code, expr->CountBinOpFeedbackId()); 3084 CallIC(code, expr->CountBinOpFeedbackId());
3082 patch_site.EmitPatchInfo(); 3085 patch_site.EmitPatchInfo();
3083 __ bind(&done); 3086 __ bind(&done);
3084 3087
3085 // Store the value returned in eax. 3088 // Store the value returned in eax.
3086 switch (assign_type) { 3089 switch (assign_type) {
3087 case VARIABLE: 3090 case VARIABLE: {
3091 VariableProxy* proxy = expr->expression()->AsVariableProxy();
3088 if (expr->is_postfix()) { 3092 if (expr->is_postfix()) {
3089 // Perform the assignment as if via '='. 3093 // Perform the assignment as if via '='.
3090 { EffectContext context(this); 3094 { EffectContext context(this);
3091 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3095 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
3092 Token::ASSIGN, expr->CountSlot()); 3096 proxy->hole_check_mode());
3093 PrepareForBailoutForId(expr->AssignmentId(), 3097 PrepareForBailoutForId(expr->AssignmentId(),
3094 BailoutState::TOS_REGISTER); 3098 BailoutState::TOS_REGISTER);
3095 context.Plug(eax); 3099 context.Plug(eax);
3096 } 3100 }
3097 // For all contexts except EffectContext We have the result on 3101 // For all contexts except EffectContext We have the result on
3098 // top of the stack. 3102 // top of the stack.
3099 if (!context()->IsEffect()) { 3103 if (!context()->IsEffect()) {
3100 context()->PlugTOS(); 3104 context()->PlugTOS();
3101 } 3105 }
3102 } else { 3106 } else {
3103 // Perform the assignment as if via '='. 3107 // Perform the assignment as if via '='.
3104 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3108 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
3105 Token::ASSIGN, expr->CountSlot()); 3109 proxy->hole_check_mode());
3106 PrepareForBailoutForId(expr->AssignmentId(), 3110 PrepareForBailoutForId(expr->AssignmentId(),
3107 BailoutState::TOS_REGISTER); 3111 BailoutState::TOS_REGISTER);
3108 context()->Plug(eax); 3112 context()->Plug(eax);
3109 } 3113 }
3110 break; 3114 break;
3115 }
3111 case NAMED_PROPERTY: { 3116 case NAMED_PROPERTY: {
3112 PopOperand(StoreDescriptor::ReceiverRegister()); 3117 PopOperand(StoreDescriptor::ReceiverRegister());
3113 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); 3118 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
3114 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3119 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3115 if (expr->is_postfix()) { 3120 if (expr->is_postfix()) {
3116 if (!context()->IsEffect()) { 3121 if (!context()->IsEffect()) {
3117 context()->PlugTOS(); 3122 context()->PlugTOS();
3118 } 3123 }
3119 } else { 3124 } else {
3120 context()->Plug(eax); 3125 context()->Plug(eax);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
3523 isolate->builtins()->OnStackReplacement()->entry(), 3528 isolate->builtins()->OnStackReplacement()->entry(),
3524 Assembler::target_address_at(call_target_address, unoptimized_code)); 3529 Assembler::target_address_at(call_target_address, unoptimized_code));
3525 return ON_STACK_REPLACEMENT; 3530 return ON_STACK_REPLACEMENT;
3526 } 3531 }
3527 3532
3528 3533
3529 } // namespace internal 3534 } // namespace internal
3530 } // namespace v8 3535 } // namespace v8
3531 3536
3532 #endif // V8_TARGET_ARCH_IA32 3537 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/full-codegen/full-codegen.cc ('k') | src/full-codegen/mips/full-codegen-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698