Check elimination now sets known successor branch of HCompareObjectEqAndBranch (correctness fix).
BUG=chromium:352058 LOG=N R=bmeurer@chromium.org Review URL: https://codereview.chromium.org/196383018 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19964 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
fac6b67b2c
commit
f77c51b0a6
@ -88,6 +88,10 @@ class HCheckTable : public ZoneObject {
|
||||
ReduceCompareMap(HCompareMap::cast(instr));
|
||||
break;
|
||||
}
|
||||
case HValue::kCompareObjectEqAndBranch: {
|
||||
ReduceCompareObjectEqAndBranch(HCompareObjectEqAndBranch::cast(instr));
|
||||
break;
|
||||
}
|
||||
case HValue::kTransitionElementsKind: {
|
||||
ReduceTransitionElementsKind(
|
||||
HTransitionElementsKind::cast(instr));
|
||||
@ -479,6 +483,23 @@ class HCheckTable : public ZoneObject {
|
||||
instr->block()->MarkSuccEdgeUnreachable(unreachable_succ);
|
||||
}
|
||||
|
||||
void ReduceCompareObjectEqAndBranch(HCompareObjectEqAndBranch* instr) {
|
||||
MapSet maps_left = FindMaps(instr->left()->ActualValue());
|
||||
if (maps_left == NULL) return;
|
||||
MapSet maps_right = FindMaps(instr->right()->ActualValue());
|
||||
if (maps_right == NULL) return;
|
||||
MapSet intersection = maps_left->Intersect(maps_right, phase_->zone());
|
||||
if (intersection->size() > 0) return;
|
||||
|
||||
TRACE(("Marking redundant CompareObjectEqAndBranch #%d at B%d as false\n",
|
||||
instr->id(), instr->block()->block_id()));
|
||||
int succ = 1;
|
||||
instr->set_known_successor_index(succ);
|
||||
|
||||
int unreachable_succ = 1 - succ;
|
||||
instr->block()->MarkSuccEdgeUnreachable(unreachable_succ);
|
||||
}
|
||||
|
||||
void ReduceTransitionElementsKind(HTransitionElementsKind* instr) {
|
||||
MapSet maps = FindMaps(instr->object()->ActualValue());
|
||||
// Can only learn more about an object that already has a known set of maps.
|
||||
|
@ -3098,6 +3098,10 @@ void HCompareObjectEqAndBranch::PrintDataTo(StringStream* stream) {
|
||||
|
||||
|
||||
bool HCompareObjectEqAndBranch::KnownSuccessorBlock(HBasicBlock** block) {
|
||||
if (known_successor_index() != kNoKnownSuccessorIndex) {
|
||||
*block = SuccessorAt(known_successor_index());
|
||||
return true;
|
||||
}
|
||||
if (FLAG_fold_constants && left()->IsConstant() && right()->IsConstant()) {
|
||||
*block = HConstant::cast(left())->DataEquals(HConstant::cast(right()))
|
||||
? FirstSuccessor() : SecondSuccessor();
|
||||
|
@ -4288,6 +4288,12 @@ class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
|
||||
|
||||
virtual bool KnownSuccessorBlock(HBasicBlock** block) V8_OVERRIDE;
|
||||
|
||||
static const int kNoKnownSuccessorIndex = -1;
|
||||
int known_successor_index() const { return known_successor_index_; }
|
||||
void set_known_successor_index(int known_successor_index) {
|
||||
known_successor_index_ = known_successor_index;
|
||||
}
|
||||
|
||||
HValue* left() { return OperandAt(0); }
|
||||
HValue* right() { return OperandAt(1); }
|
||||
|
||||
@ -4307,7 +4313,8 @@ class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
|
||||
HCompareObjectEqAndBranch(HValue* left,
|
||||
HValue* right,
|
||||
HBasicBlock* true_target = NULL,
|
||||
HBasicBlock* false_target = NULL) {
|
||||
HBasicBlock* false_target = NULL)
|
||||
: known_successor_index_(kNoKnownSuccessorIndex) {
|
||||
ASSERT(!left->IsConstant() ||
|
||||
(!HConstant::cast(left)->HasInteger32Value() ||
|
||||
HConstant::cast(left)->HasSmiValue()));
|
||||
@ -4319,6 +4326,8 @@ class HCompareObjectEqAndBranch : public HTemplateControlInstruction<2, 2> {
|
||||
SetSuccessorAt(0, true_target);
|
||||
SetSuccessorAt(1, false_target);
|
||||
}
|
||||
|
||||
int known_successor_index_;
|
||||
};
|
||||
|
||||
|
||||
|
17
test/mjsunit/regress/regress-crbug-352058.js
Normal file
17
test/mjsunit/regress/regress-crbug-352058.js
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2014 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 --check-elimination --stress-opt
|
||||
|
||||
var v0 = this;
|
||||
var v2 = this;
|
||||
function f() {
|
||||
v2 = [1.2, 2.3];
|
||||
v0 = [12, 23];
|
||||
}
|
||||
|
||||
f();
|
||||
f();
|
||||
%OptimizeFunctionOnNextCall(f);
|
||||
f();
|
Loading…
Reference in New Issue
Block a user