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

Side by Side Diff: src/full-codegen/x64/full-codegen-x64.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/mips64/full-codegen-mips64.cc ('k') | src/globals.h » ('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_X64 5 #if V8_TARGET_ARCH_X64
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 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 context()->Plug(rax); 1232 context()->Plug(rax);
1233 break; 1233 break;
1234 } 1234 }
1235 1235
1236 case VariableLocation::PARAMETER: 1236 case VariableLocation::PARAMETER:
1237 case VariableLocation::LOCAL: 1237 case VariableLocation::LOCAL:
1238 case VariableLocation::CONTEXT: { 1238 case VariableLocation::CONTEXT: {
1239 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode); 1239 DCHECK_EQ(NOT_INSIDE_TYPEOF, typeof_mode);
1240 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" 1240 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot"
1241 : "[ Stack slot"); 1241 : "[ Stack slot");
1242 if (proxy->needs_hole_check()) { 1242 if (proxy->hole_check_mode() == HoleCheckMode::kRequired) {
1243 // Throw a reference error when using an uninitialized let/const 1243 // Throw a reference error when using an uninitialized let/const
1244 // binding in harmony mode. 1244 // binding in harmony mode.
1245 DCHECK(IsLexicalVariableMode(var->mode())); 1245 DCHECK(IsLexicalVariableMode(var->mode()));
1246 Label done; 1246 Label done;
1247 GetVar(rax, var); 1247 GetVar(rax, var);
1248 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex); 1248 __ CompareRoot(rax, Heap::kTheHoleValueRootIndex);
1249 __ j(not_equal, &done, Label::kNear); 1249 __ j(not_equal, &done, Label::kNear);
1250 __ Push(var->name()); 1250 __ Push(var->name());
1251 __ CallRuntime(Runtime::kThrowReferenceError); 1251 __ CallRuntime(Runtime::kThrowReferenceError);
1252 __ bind(&done); 1252 __ bind(&done);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1663 // Deoptimization point in case the binary operation may have side effects. 1663 // Deoptimization point in case the binary operation may have side effects.
1664 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER); 1664 PrepareForBailout(expr->binary_operation(), BailoutState::TOS_REGISTER);
1665 } else { 1665 } else {
1666 VisitForAccumulatorValue(expr->value()); 1666 VisitForAccumulatorValue(expr->value());
1667 } 1667 }
1668 1668
1669 SetExpressionPosition(expr); 1669 SetExpressionPosition(expr);
1670 1670
1671 // Store the value. 1671 // Store the value.
1672 switch (assign_type) { 1672 switch (assign_type) {
1673 case VARIABLE: 1673 case VARIABLE: {
1674 EmitVariableAssignment(expr->target()->AsVariableProxy()->var(), 1674 VariableProxy* proxy = expr->target()->AsVariableProxy();
1675 expr->op(), expr->AssignmentSlot()); 1675 EmitVariableAssignment(proxy->var(), expr->op(), expr->AssignmentSlot(),
1676 proxy->hole_check_mode());
1676 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 1677 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
1677 context()->Plug(rax); 1678 context()->Plug(rax);
1678 break; 1679 break;
1680 }
1679 case NAMED_PROPERTY: 1681 case NAMED_PROPERTY:
1680 EmitNamedPropertyAssignment(expr); 1682 EmitNamedPropertyAssignment(expr);
1681 break; 1683 break;
1682 case NAMED_SUPER_PROPERTY: 1684 case NAMED_SUPER_PROPERTY:
1683 EmitNamedSuperPropertyStore(property); 1685 EmitNamedSuperPropertyStore(property);
1684 context()->Plug(rax); 1686 context()->Plug(rax);
1685 break; 1687 break;
1686 case KEYED_SUPER_PROPERTY: 1688 case KEYED_SUPER_PROPERTY:
1687 EmitKeyedSuperPropertyStore(property); 1689 EmitKeyedSuperPropertyStore(property);
1688 context()->Plug(rax); 1690 context()->Plug(rax);
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(rax); // Preserve value. 1931 PushOperand(rax); // Preserve value.
1929 VisitForAccumulatorValue(prop->obj()); 1932 VisitForAccumulatorValue(prop->obj());
1930 __ Move(StoreDescriptor::ReceiverRegister(), rax); 1933 __ Move(StoreDescriptor::ReceiverRegister(), rax);
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
1987 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot( 1990 void FullCodeGenerator::EmitStoreToStackLocalOrContextSlot(
1988 Variable* var, MemOperand location) { 1991 Variable* var, MemOperand location) {
1989 __ movp(location, rax); 1992 __ movp(location, rax);
1990 if (var->IsContextSlot()) { 1993 if (var->IsContextSlot()) {
1991 __ movp(rdx, rax); 1994 __ movp(rdx, rax);
1992 __ RecordWriteContextSlot( 1995 __ RecordWriteContextSlot(
1993 rcx, Context::SlotOffset(var->index()), rdx, rbx, kDontSaveFPRegs); 1996 rcx, Context::SlotOffset(var->index()), rdx, rbx, 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 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister()); 2005 __ LoadGlobalObject(StoreDescriptor::ReceiverRegister());
2003 CallStoreIC(slot, var->name()); 2006 CallStoreIC(slot, var->name());
2004 2007
2005 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) { 2008 } else if (IsLexicalVariableMode(var->mode()) && op != Token::INIT) {
2006 DCHECK(!var->IsLookupSlot()); 2009 DCHECK(!var->IsLookupSlot());
2007 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); 2010 DCHECK(var->IsStackAllocated() || var->IsContextSlot());
2008 MemOperand location = VarOperand(var, rcx); 2011 MemOperand location = VarOperand(var, rcx);
2009 // Perform an initialization check for lexically declared variables. 2012 // Perform an initialization check for lexically declared variables.
2010 if (var->binding_needs_init()) { 2013 if (hole_check_mode == HoleCheckMode::kRequired) {
2011 Label assign; 2014 Label assign;
2012 __ movp(rdx, location); 2015 __ movp(rdx, location);
2013 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex); 2016 __ CompareRoot(rdx, Heap::kTheHoleValueRootIndex);
2014 __ j(not_equal, &assign, Label::kNear); 2017 __ j(not_equal, &assign, Label::kNear);
2015 __ Push(var->name()); 2018 __ Push(var->name());
2016 __ CallRuntime(Runtime::kThrowReferenceError); 2019 __ CallRuntime(Runtime::kThrowReferenceError);
2017 __ bind(&assign); 2020 __ bind(&assign);
2018 } 2021 }
2019 if (var->mode() != CONST) { 2022 if (var->mode() != CONST) {
2020 EmitStoreToStackLocalOrContextSlot(var, location); 2023 EmitStoreToStackLocalOrContextSlot(var, location);
(...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3066 __ movp(rdx, rax); 3069 __ movp(rdx, rax);
3067 __ Move(rax, Smi::FromInt(1)); 3070 __ Move(rax, Smi::FromInt(1));
3068 Handle<Code> code = 3071 Handle<Code> code =
3069 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code(); 3072 CodeFactory::BinaryOpIC(isolate(), expr->binary_op()).code();
3070 CallIC(code, expr->CountBinOpFeedbackId()); 3073 CallIC(code, expr->CountBinOpFeedbackId());
3071 patch_site.EmitPatchInfo(); 3074 patch_site.EmitPatchInfo();
3072 __ bind(&done); 3075 __ bind(&done);
3073 3076
3074 // Store the value returned in rax. 3077 // Store the value returned in rax.
3075 switch (assign_type) { 3078 switch (assign_type) {
3076 case VARIABLE: 3079 case VARIABLE: {
3080 VariableProxy* proxy = expr->expression()->AsVariableProxy();
3077 if (expr->is_postfix()) { 3081 if (expr->is_postfix()) {
3078 // Perform the assignment as if via '='. 3082 // Perform the assignment as if via '='.
3079 { EffectContext context(this); 3083 { EffectContext context(this);
3080 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3084 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
3081 Token::ASSIGN, expr->CountSlot()); 3085 proxy->hole_check_mode());
3082 PrepareForBailoutForId(expr->AssignmentId(), 3086 PrepareForBailoutForId(expr->AssignmentId(),
3083 BailoutState::TOS_REGISTER); 3087 BailoutState::TOS_REGISTER);
3084 context.Plug(rax); 3088 context.Plug(rax);
3085 } 3089 }
3086 // For all contexts except kEffect: We have the result on 3090 // For all contexts except kEffect: We have the result on
3087 // top of the stack. 3091 // top of the stack.
3088 if (!context()->IsEffect()) { 3092 if (!context()->IsEffect()) {
3089 context()->PlugTOS(); 3093 context()->PlugTOS();
3090 } 3094 }
3091 } else { 3095 } else {
3092 // Perform the assignment as if via '='. 3096 // Perform the assignment as if via '='.
3093 EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(), 3097 EmitVariableAssignment(proxy->var(), Token::ASSIGN, expr->CountSlot(),
3094 Token::ASSIGN, expr->CountSlot()); 3098 proxy->hole_check_mode());
3095 PrepareForBailoutForId(expr->AssignmentId(), 3099 PrepareForBailoutForId(expr->AssignmentId(),
3096 BailoutState::TOS_REGISTER); 3100 BailoutState::TOS_REGISTER);
3097 context()->Plug(rax); 3101 context()->Plug(rax);
3098 } 3102 }
3099 break; 3103 break;
3104 }
3100 case NAMED_PROPERTY: { 3105 case NAMED_PROPERTY: {
3101 PopOperand(StoreDescriptor::ReceiverRegister()); 3106 PopOperand(StoreDescriptor::ReceiverRegister());
3102 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value()); 3107 CallStoreIC(expr->CountSlot(), prop->key()->AsLiteral()->value());
3103 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER); 3108 PrepareForBailoutForId(expr->AssignmentId(), BailoutState::TOS_REGISTER);
3104 if (expr->is_postfix()) { 3109 if (expr->is_postfix()) {
3105 if (!context()->IsEffect()) { 3110 if (!context()->IsEffect()) {
3106 context()->PlugTOS(); 3111 context()->PlugTOS();
3107 } 3112 }
3108 } else { 3113 } else {
3109 context()->Plug(rax); 3114 context()->Plug(rax);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 DCHECK_EQ( 3516 DCHECK_EQ(
3512 isolate->builtins()->OnStackReplacement()->entry(), 3517 isolate->builtins()->OnStackReplacement()->entry(),
3513 Assembler::target_address_at(call_target_address, unoptimized_code)); 3518 Assembler::target_address_at(call_target_address, unoptimized_code));
3514 return ON_STACK_REPLACEMENT; 3519 return ON_STACK_REPLACEMENT;
3515 } 3520 }
3516 3521
3517 } // namespace internal 3522 } // namespace internal
3518 } // namespace v8 3523 } // namespace v8
3519 3524
3520 #endif // V8_TARGET_ARCH_X64 3525 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/full-codegen/mips64/full-codegen-mips64.cc ('k') | src/globals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698