Commit fded35e0 authored by danno@chromium.org's avatar danno@chromium.org

Fix bugs in IfBuilder and improve functionality

R=mstarzinger@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14327 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c47af882
...@@ -823,11 +823,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { ...@@ -823,11 +823,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
HEnvironment* last_environment = pred->last_environment(); HEnvironment* last_environment = pred->last_environment();
for (int i = 0; i < block->phis()->length(); ++i) { for (int i = 0; i < block->phis()->length(); ++i) {
HPhi* phi = block->phis()->at(i); HPhi* phi = block->phis()->at(i);
last_environment->SetValueAt(phi->merged_index(), phi); if (phi->merged_index() < last_environment->length()) {
last_environment->SetValueAt(phi->merged_index(), phi);
}
} }
for (int i = 0; i < block->deleted_phis()->length(); ++i) { for (int i = 0; i < block->deleted_phis()->length(); ++i) {
last_environment->SetValueAt(block->deleted_phis()->at(i), if (block->deleted_phis()->at(i) < last_environment->length()) {
graph_->GetConstantUndefined()); last_environment->SetValueAt(block->deleted_phis()->at(i),
graph_->GetConstantUndefined());
}
} }
block->UpdateEnvironment(last_environment); block->UpdateEnvironment(last_environment);
// Pick up the outgoing argument count of one of the predecessors. // Pick up the outgoing argument count of one of the predecessors.
......
...@@ -203,31 +203,32 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() { ...@@ -203,31 +203,32 @@ HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
NULL, NULL,
FAST_ELEMENTS)); FAST_ELEMENTS));
CheckBuilder builder(this, BailoutId::StubEntry()); CheckBuilder builder(this);
builder.CheckNotUndefined(boilerplate); builder.CheckNotUndefined(boilerplate);
if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) { if (mode == FastCloneShallowArrayStub::CLONE_ANY_ELEMENTS) {
HValue* elements = HValue* elements =
AddInstruction(new(zone) HLoadElements(boilerplate, NULL)); AddInstruction(new(zone) HLoadElements(boilerplate, NULL));
IfBuilder if_fixed_cow(this, BailoutId::StubEntry()); IfBuilder if_fixed_cow(this);
if_fixed_cow.BeginIfMapEquals(elements, factory->fixed_cow_array_map()); if_fixed_cow.IfCompareMap(elements, factory->fixed_cow_array_map());
if_fixed_cow.Then();
environment()->Push(BuildCloneShallowArray(context(), environment()->Push(BuildCloneShallowArray(context(),
boilerplate, boilerplate,
alloc_site_mode, alloc_site_mode,
FAST_ELEMENTS, FAST_ELEMENTS,
0/*copy-on-write*/)); 0/*copy-on-write*/));
if_fixed_cow.BeginElse(); if_fixed_cow.Else();
IfBuilder if_fixed(this, BailoutId::StubEntry()); IfBuilder if_fixed(this);
if_fixed.BeginIfMapEquals(elements, factory->fixed_array_map()); if_fixed.IfCompareMap(elements, factory->fixed_array_map());
if_fixed.Then();
environment()->Push(BuildCloneShallowArray(context(), environment()->Push(BuildCloneShallowArray(context(),
boilerplate, boilerplate,
alloc_site_mode, alloc_site_mode,
FAST_ELEMENTS, FAST_ELEMENTS,
length)); length));
if_fixed.BeginElse(); if_fixed.Else();
environment()->Push(BuildCloneShallowArray(context(), environment()->Push(BuildCloneShallowArray(context(),
boilerplate, boilerplate,
alloc_site_mode, alloc_site_mode,
...@@ -264,7 +265,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() { ...@@ -264,7 +265,7 @@ HValue* CodeStubGraphBuilder<FastCloneShallowObjectStub>::BuildCodeStub() {
NULL, NULL,
FAST_ELEMENTS)); FAST_ELEMENTS));
CheckBuilder builder(this, BailoutId::StubEntry()); CheckBuilder builder(this);
builder.CheckNotUndefined(boilerplate); builder.CheckNotUndefined(boilerplate);
int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize; int size = JSObject::kHeaderSize + casted_stub()->length() * kPointerSize;
...@@ -356,13 +357,14 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { ...@@ -356,13 +357,14 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
ElementsKind to_kind = casted_stub()->to_kind(); ElementsKind to_kind = casted_stub()->to_kind();
BuildNewSpaceArrayCheck(array_length, to_kind); BuildNewSpaceArrayCheck(array_length, to_kind);
IfBuilder if_builder(this, BailoutId::StubEntry()); IfBuilder if_builder(this);
if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ); if_builder.IfCompare(array_length, graph()->GetConstant0(), Token::EQ);
if_builder.Then();
// Nothing to do, just change the map. // Nothing to do, just change the map.
if_builder.BeginElse(); if_builder.Else();
HInstruction* elements = HInstruction* elements =
AddInstruction(new(zone) HLoadElements(js_array, js_array)); AddInstruction(new(zone) HLoadElements(js_array, js_array));
...@@ -375,8 +377,7 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() { ...@@ -375,8 +377,7 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
BuildCopyElements(context(), elements, BuildCopyElements(context(), elements,
casted_stub()->from_kind(), new_elements, casted_stub()->from_kind(), new_elements,
to_kind, array_length, elements_length, to_kind, array_length, elements_length);
BailoutId::StubEntry());
Factory* factory = isolate()->factory(); Factory* factory = isolate()->factory();
......
This diff is collapsed.
This diff is collapsed.
...@@ -884,11 +884,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { ...@@ -884,11 +884,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
HEnvironment* last_environment = pred->last_environment(); HEnvironment* last_environment = pred->last_environment();
for (int i = 0; i < block->phis()->length(); ++i) { for (int i = 0; i < block->phis()->length(); ++i) {
HPhi* phi = block->phis()->at(i); HPhi* phi = block->phis()->at(i);
last_environment->SetValueAt(phi->merged_index(), phi); if (phi->merged_index() < last_environment->length()) {
last_environment->SetValueAt(phi->merged_index(), phi);
}
} }
for (int i = 0; i < block->deleted_phis()->length(); ++i) { for (int i = 0; i < block->deleted_phis()->length(); ++i) {
last_environment->SetValueAt(block->deleted_phis()->at(i), if (block->deleted_phis()->at(i) < last_environment->length()) {
graph_->GetConstantUndefined()); last_environment->SetValueAt(block->deleted_phis()->at(i),
graph_->GetConstantUndefined());
}
} }
block->UpdateEnvironment(last_environment); block->UpdateEnvironment(last_environment);
// Pick up the outgoing argument count of one of the predecessors. // Pick up the outgoing argument count of one of the predecessors.
......
...@@ -831,11 +831,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { ...@@ -831,11 +831,15 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
HEnvironment* last_environment = pred->last_environment(); HEnvironment* last_environment = pred->last_environment();
for (int i = 0; i < block->phis()->length(); ++i) { for (int i = 0; i < block->phis()->length(); ++i) {
HPhi* phi = block->phis()->at(i); HPhi* phi = block->phis()->at(i);
last_environment->SetValueAt(phi->merged_index(), phi); if (phi->merged_index() < last_environment->length()) {
last_environment->SetValueAt(phi->merged_index(), phi);
}
} }
for (int i = 0; i < block->deleted_phis()->length(); ++i) { for (int i = 0; i < block->deleted_phis()->length(); ++i) {
last_environment->SetValueAt(block->deleted_phis()->at(i), if (block->deleted_phis()->at(i) < last_environment->length()) {
graph_->GetConstantUndefined()); last_environment->SetValueAt(block->deleted_phis()->at(i),
graph_->GetConstantUndefined());
}
} }
block->UpdateEnvironment(last_environment); block->UpdateEnvironment(last_environment);
// Pick up the outgoing argument count of one of the predecessors. // Pick up the outgoing argument count of one of the predecessors.
......
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