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

Side by Side Diff: src/crankshaft/hydrogen.cc

Issue 2491333002: [crankshaft] Always force number representation for increment. (Closed)
Patch Set: Remove redundant parameter 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/crankshaft/hydrogen.h ('k') | test/mjsunit/regress/regress-664087.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/crankshaft/hydrogen.h" 5 #include "src/crankshaft/hydrogen.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/allocation-site-scopes.h" 10 #include "src/allocation-site-scopes.h"
(...skipping 10368 matching lines...) Expand 10 before | Expand all | Expand 10 after
10379 10379
10380 static Representation RepresentationFor(AstType* type) { 10380 static Representation RepresentationFor(AstType* type) {
10381 DisallowHeapAllocation no_allocation; 10381 DisallowHeapAllocation no_allocation;
10382 if (type->Is(AstType::None())) return Representation::None(); 10382 if (type->Is(AstType::None())) return Representation::None();
10383 if (type->Is(AstType::SignedSmall())) return Representation::Smi(); 10383 if (type->Is(AstType::SignedSmall())) return Representation::Smi();
10384 if (type->Is(AstType::Signed32())) return Representation::Integer32(); 10384 if (type->Is(AstType::Signed32())) return Representation::Integer32();
10385 if (type->Is(AstType::Number())) return Representation::Double(); 10385 if (type->Is(AstType::Number())) return Representation::Double();
10386 return Representation::Tagged(); 10386 return Representation::Tagged();
10387 } 10387 }
10388 10388
10389 10389 HInstruction* HOptimizedGraphBuilder::BuildIncrement(CountOperation* expr) {
10390 HInstruction* HOptimizedGraphBuilder::BuildIncrement(
10391 bool returns_original_input,
10392 CountOperation* expr) {
10393 // The input to the count operation is on top of the expression stack. 10390 // The input to the count operation is on top of the expression stack.
10394 Representation rep = RepresentationFor(expr->type()); 10391 Representation rep = RepresentationFor(expr->type());
10395 if (rep.IsNone() || rep.IsTagged()) { 10392 if (rep.IsNone() || rep.IsTagged()) {
10396 rep = Representation::Smi(); 10393 rep = Representation::Smi();
10397 } 10394 }
10398 10395
10399 if (returns_original_input) { 10396 // We need an explicit HValue representing ToNumber(input). The
10400 // We need an explicit HValue representing ToNumber(input). The 10397 // actual HChange instruction we need is (sometimes) added in a later
10401 // actual HChange instruction we need is (sometimes) added in a later 10398 // phase, so it is not available now to be used as an input to HAdd and
10402 // phase, so it is not available now to be used as an input to HAdd and 10399 // as the return value.
10403 // as the return value. 10400 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep);
10404 HInstruction* number_input = AddUncasted<HForceRepresentation>(Pop(), rep); 10401 if (!rep.IsDouble()) {
10405 if (!rep.IsDouble()) { 10402 number_input->SetFlag(HInstruction::kFlexibleRepresentation);
10406 number_input->SetFlag(HInstruction::kFlexibleRepresentation); 10403 number_input->SetFlag(HInstruction::kCannotBeTagged);
10407 number_input->SetFlag(HInstruction::kCannotBeTagged);
10408 }
10409 Push(number_input);
10410 } 10404 }
10405 Push(number_input);
10411 10406
10412 // The addition has no side effects, so we do not need 10407 // The addition has no side effects, so we do not need
10413 // to simulate the expression stack after this instruction. 10408 // to simulate the expression stack after this instruction.
10414 // Any later failures deopt to the load of the input or earlier. 10409 // Any later failures deopt to the load of the input or earlier.
10415 HConstant* delta = (expr->op() == Token::INC) 10410 HConstant* delta = (expr->op() == Token::INC)
10416 ? graph()->GetConstant1() 10411 ? graph()->GetConstant1()
10417 : graph()->GetConstantMinus1(); 10412 : graph()->GetConstantMinus1();
10418 HInstruction* instr = AddUncasted<HAdd>(Top(), delta); 10413 HInstruction* instr = AddUncasted<HAdd>(Top(), delta);
10419 if (instr->IsAdd()) { 10414 if (instr->IsAdd()) {
10420 HAdd* add = HAdd::cast(instr); 10415 HAdd* add = HAdd::cast(instr);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
10459 10454
10460 if (proxy != NULL) { 10455 if (proxy != NULL) {
10461 Variable* var = proxy->var(); 10456 Variable* var = proxy->var();
10462 if (var->mode() == CONST) { 10457 if (var->mode() == CONST) {
10463 return Bailout(kNonInitializerAssignmentToConst); 10458 return Bailout(kNonInitializerAssignmentToConst);
10464 } 10459 }
10465 // Argument of the count operation is a variable, not a property. 10460 // Argument of the count operation is a variable, not a property.
10466 DCHECK(prop == NULL); 10461 DCHECK(prop == NULL);
10467 CHECK_ALIVE(VisitForValue(target)); 10462 CHECK_ALIVE(VisitForValue(target));
10468 10463
10469 after = BuildIncrement(returns_original_input, expr); 10464 after = BuildIncrement(expr);
10470 input = returns_original_input ? Top() : Pop(); 10465 input = returns_original_input ? Top() : Pop();
10471 Push(after); 10466 Push(after);
10472 10467
10473 switch (var->location()) { 10468 switch (var->location()) {
10474 case VariableLocation::UNALLOCATED: 10469 case VariableLocation::UNALLOCATED:
10475 HandleGlobalVariableAssignment(var, after, expr->CountSlot(), 10470 HandleGlobalVariableAssignment(var, after, expr->CountSlot(),
10476 expr->AssignmentId()); 10471 expr->AssignmentId());
10477 break; 10472 break;
10478 10473
10479 case VariableLocation::PARAMETER: 10474 case VariableLocation::PARAMETER:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
10512 HValue* object = Top(); 10507 HValue* object = Top();
10513 10508
10514 HValue* key = NULL; 10509 HValue* key = NULL;
10515 if (!prop->key()->IsPropertyName() || prop->IsStringAccess()) { 10510 if (!prop->key()->IsPropertyName() || prop->IsStringAccess()) {
10516 CHECK_ALIVE(VisitForValue(prop->key())); 10511 CHECK_ALIVE(VisitForValue(prop->key()));
10517 key = Top(); 10512 key = Top();
10518 } 10513 }
10519 10514
10520 CHECK_ALIVE(PushLoad(prop, object, key)); 10515 CHECK_ALIVE(PushLoad(prop, object, key));
10521 10516
10522 after = BuildIncrement(returns_original_input, expr); 10517 after = BuildIncrement(expr);
10523 10518
10524 if (returns_original_input) { 10519 if (returns_original_input) {
10525 input = Pop(); 10520 input = Pop();
10526 // Drop object and key to push it again in the effect context below. 10521 // Drop object and key to push it again in the effect context below.
10527 Drop(key == NULL ? 1 : 2); 10522 Drop(key == NULL ? 1 : 2);
10528 environment()->SetExpressionStackAt(0, input); 10523 environment()->SetExpressionStackAt(0, input);
10529 CHECK_ALIVE(BuildStoreForEffect(expr, prop, expr->CountSlot(), expr->id(), 10524 CHECK_ALIVE(BuildStoreForEffect(expr, prop, expr->CountSlot(), expr->id(),
10530 expr->AssignmentId(), object, key, after)); 10525 expr->AssignmentId(), object, key, after));
10531 return ast_context()->ReturnValue(Pop()); 10526 return ast_context()->ReturnValue(Pop());
10532 } 10527 }
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after
13045 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 13040 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
13046 } 13041 }
13047 13042
13048 #ifdef DEBUG 13043 #ifdef DEBUG
13049 graph_->Verify(false); // No full verify. 13044 graph_->Verify(false); // No full verify.
13050 #endif 13045 #endif
13051 } 13046 }
13052 13047
13053 } // namespace internal 13048 } // namespace internal
13054 } // namespace v8 13049 } // namespace v8
OLDNEW
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | test/mjsunit/regress/regress-664087.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698