From: jkummerow@chromium.org Date: Thu, 23 May 2013 09:17:01 +0000 (+0000) Subject: Avoid creating duplicate entries for a value when merging HSimulates X-Git-Tag: upstream/4.7.83~14159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f691f48c14dc861a8a0d33a49fb3ea849d69093e;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index fdfd059..14bd8f9 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -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() && diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 4a0aeff..24264d3 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2016,8 +2016,9 @@ void HSimulate::MergeWith(ZoneList* list) { ZoneList* 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(","); } } } diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 90fea07..ecfc859 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -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 values_; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index fe639e2..6bb9fe2 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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));