Commit c71e5e12 authored by jarin's avatar jarin Committed by Commit bot

[crankshaft] Always force number representation for increment.

BUG=chromium:664087

Review-Url: https://codereview.chromium.org/2491333002
Cr-Commit-Position: refs/heads/master@{#40900}
parent 6f4464ec
...@@ -10386,17 +10386,13 @@ static Representation RepresentationFor(AstType* type) { ...@@ -10386,17 +10386,13 @@ static Representation RepresentationFor(AstType* type) {
return Representation::Tagged(); return Representation::Tagged();
} }
HInstruction* HOptimizedGraphBuilder::BuildIncrement(CountOperation* expr) {
HInstruction* HOptimizedGraphBuilder::BuildIncrement(
bool returns_original_input,
CountOperation* expr) {
// The input to the count operation is on top of the expression stack. // The input to the count operation is on top of the expression stack.
Representation rep = RepresentationFor(expr->type()); Representation rep = RepresentationFor(expr->type());
if (rep.IsNone() || rep.IsTagged()) { if (rep.IsNone() || rep.IsTagged()) {
rep = Representation::Smi(); rep = Representation::Smi();
} }
if (returns_original_input) {
// We need an explicit HValue representing ToNumber(input). The // We need an explicit HValue representing ToNumber(input). The
// actual HChange instruction we need is (sometimes) added in a later // actual HChange instruction we need is (sometimes) added in a later
// phase, so it is not available now to be used as an input to HAdd and // phase, so it is not available now to be used as an input to HAdd and
...@@ -10407,7 +10403,6 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement( ...@@ -10407,7 +10403,6 @@ HInstruction* HOptimizedGraphBuilder::BuildIncrement(
number_input->SetFlag(HInstruction::kCannotBeTagged); number_input->SetFlag(HInstruction::kCannotBeTagged);
} }
Push(number_input); Push(number_input);
}
// The addition has no side effects, so we do not need // The addition has no side effects, so we do not need
// to simulate the expression stack after this instruction. // to simulate the expression stack after this instruction.
...@@ -10466,7 +10461,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -10466,7 +10461,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) {
DCHECK(prop == NULL); DCHECK(prop == NULL);
CHECK_ALIVE(VisitForValue(target)); CHECK_ALIVE(VisitForValue(target));
after = BuildIncrement(returns_original_input, expr); after = BuildIncrement(expr);
input = returns_original_input ? Top() : Pop(); input = returns_original_input ? Top() : Pop();
Push(after); Push(after);
...@@ -10519,7 +10514,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) { ...@@ -10519,7 +10514,7 @@ void HOptimizedGraphBuilder::VisitCountOperation(CountOperation* expr) {
CHECK_ALIVE(PushLoad(prop, object, key)); CHECK_ALIVE(PushLoad(prop, object, key));
after = BuildIncrement(returns_original_input, expr); after = BuildIncrement(expr);
if (returns_original_input) { if (returns_original_input) {
input = Pop(); input = Pop();
......
...@@ -2687,8 +2687,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, ...@@ -2687,8 +2687,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder,
HValue* left, HValue* left,
HValue* right, HValue* right,
PushBeforeSimulateBehavior push_sim_result); PushBeforeSimulateBehavior push_sim_result);
HInstruction* BuildIncrement(bool returns_original_input, HInstruction* BuildIncrement(CountOperation* expr);
CountOperation* expr);
HInstruction* BuildKeyedGeneric(PropertyAccessType access_type, HInstruction* BuildKeyedGeneric(PropertyAccessType access_type,
Expression* expr, FeedbackVectorSlot slot, Expression* expr, FeedbackVectorSlot slot,
HValue* object, HValue* key, HValue* value); HValue* object, HValue* key, HValue* value);
......
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
function g() {
throw 1;
}
var v = { valueOf : g };
function foo(v) {
v++;
}
%NeverOptimizeFunction(g);
assertThrows(function () { foo(v); });
assertThrows(function () { foo(v); });
%OptimizeFunctionOnNextCall(foo);
assertThrows(function () { foo(v); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment