Avoid creating duplicate entries for a value when merging HSimulates

R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/15660003

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14766 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 308e6975
......@@ -148,7 +148,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
HParameter::REGISTER_PARAMETER,
Representation::Integer32());
stack_parameter_count->set_type(HType::Smi());
// it's essential to bind this value to the environment in case of deopt
// It's essential to bind this value to the environment in case of deopt.
AddInstruction(stack_parameter_count);
start_environment->Bind(param_count, stack_parameter_count);
arguments_length_ = stack_parameter_count;
......@@ -169,7 +169,7 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
HValue* return_value = BuildCodeStub();
// We might have extra expressions to pop from the stack in addition to the
// arguments above
// arguments above.
HInstruction* stack_pop_count = stack_parameter_count;
if (descriptor_->function_mode_ == JS_FUNCTION_STUB_MODE) {
if (!stack_parameter_count->IsConstant() &&
......
......@@ -2016,8 +2016,9 @@ void HSimulate::MergeWith(ZoneList<HSimulate*>* list) {
ZoneList<HValue*>* from_values = &from->values_;
for (int i = 0; i < from_values->length(); ++i) {
if (from->HasAssignedIndexAt(i)) {
AddAssignedValue(from->GetAssignedIndexAt(i),
from_values->at(i));
int index = from->GetAssignedIndexAt(i);
if (HasValueForIndex(index)) continue;
AddAssignedValue(index, from_values->at(i));
} else {
if (pop_count_ > 0) {
pop_count_--;
......@@ -2038,13 +2039,13 @@ void HSimulate::PrintDataTo(StringStream* stream) {
if (values_.length() > 0) {
if (pop_count_ > 0) stream->Add(" /");
for (int i = values_.length() - 1; i >= 0; --i) {
if (i > 0) stream->Add(",");
if (HasAssignedIndexAt(i)) {
stream->Add(" var[%d] = ", GetAssignedIndexAt(i));
} else {
stream->Add(" push ");
}
values_[i]->PrintNameTo(stream);
if (i > 0) stream->Add(",");
}
}
}
......
......@@ -1858,6 +1858,12 @@ class HSimulate: public HInstruction {
// use lists are correctly updated.
SetOperandAt(values_.length() - 1, value);
}
bool HasValueForIndex(int index) {
for (int i = 0; i < assigned_indexes_.length(); ++i) {
if (assigned_indexes_[i] == index) return true;
}
return false;
}
BailoutId ast_id_;
int pop_count_;
ZoneList<HValue*> values_;
......
......@@ -157,7 +157,7 @@ HSimulate* HBasicBlock::CreateSimulate(BailoutId ast_id,
HSimulate* instr =
new(zone()) HSimulate(ast_id, pop_count, zone(), removable);
// Order of pushed values: newest (top of stack) first. This allows
// HSimulate::MergeInto() to easily append additional pushed values
// HSimulate::MergeWith() to easily append additional pushed values
// that are older (from further down the stack).
for (int i = 0; i < push_count; ++i) {
instr->AddPushedValue(environment->ExpressionStackAt(i));
......
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