Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Unified Diff: src/code-stubs-hydrogen.cc

Issue 12221064: Implement many KeyedStoreStubs using Crankshaft (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/code-stubs.cc ('k') | src/heap.h » ('j') | src/hydrogen.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index 17c1f275abb82e54ff8350ec7122e406bebbdbde..f1cd27ec17c951d72fbd6373f360d9501f89fff1 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -100,6 +100,8 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
next_block->SetJoinId(BailoutId::StubEntry());
set_current_block(next_block);
+ start_environment->set_ast_id(BailoutId::StubEntry());
+
HConstant* undefined_constant = new(zone) HConstant(
isolate()->factory()->undefined_value(), Representation::Tagged());
AddInstruction(undefined_constant);
@@ -198,8 +200,7 @@ void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
HInstruction* load = BuildUncheckedMonomorphicElementAccess(
GetParameter(0), GetParameter(1), NULL, NULL,
casted_stub()->is_js_array(), casted_stub()->elements_kind(),
- false, Representation::Tagged());
- AddInstruction(load);
+ false, STANDARD_STORE, Representation::Tagged());
HReturn* ret = new(zone) HReturn(load, context());
current_block()->Finish(ret);
@@ -214,6 +215,28 @@ Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
template <>
+void CodeStubGraphBuilder<KeyedStoreFastElementStub>::BuildCodeStub() {
+ Zone* zone = this->zone();
+
+ BuildUncheckedMonomorphicElementAccess(
+ GetParameter(0), GetParameter(1), GetParameter(2), NULL,
+ casted_stub()->is_js_array(), casted_stub()->elements_kind(),
+ true, casted_stub()->store_mode(), Representation::Tagged());
+ AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
+
+ HReturn* ret = new(zone) HReturn(GetParameter(2), context());
+ current_block()->Finish(ret);
+}
+
+
+Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
+ CodeStubGraphBuilder<KeyedStoreFastElementStub> builder(this);
+ LChunk* chunk = OptimizeGraph(builder.CreateGraph());
+ return chunk->Codegen(Code::COMPILED_STUB);
+}
+
+
+template <>
void CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
Zone* zone = this->zone();
@@ -229,27 +252,16 @@ void CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
js_array,
HType::Smi()));
- Heap* heap = isolate()->heap();
- const int kMinFreeNewSpaceAfterGC =
- ((heap->InitialSemiSpaceSize() - sizeof(FixedArrayBase)) / 2) /
- kDoubleSize;
-
- HConstant* max_alloc_size =
- new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32());
- AddInstruction(max_alloc_size);
- // Since we're forcing Integer32 representation for this HBoundsCheck,
- // there's no need to Smi-check the index.
- AddInstruction(
- new(zone) HBoundsCheck(array_length, max_alloc_size,
- DONT_ALLOW_SMI_KEY, Representation::Integer32()));
+ ElementsKind to_kind = casted_stub()->to_kind();
+ BuildNewSpaceArrayCheck(array_length, to_kind);
IfBuilder if_builder(this, BailoutId::StubEntry());
- if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ);
+ if_builder.BeginIf(array_length, graph()->GetConstant0(), Token::EQ);
// Nothing to do, just change the map.
- if_builder.BeginFalse();
+ if_builder.BeginElse();
HInstruction* elements =
AddInstruction(new(zone) HLoadElements(js_array, js_array));
@@ -257,37 +269,17 @@ void CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
HInstruction* elements_length =
AddInstruction(new(zone) HFixedArrayBaseLength(elements));
- ElementsKind to_kind = casted_stub()->to_kind();
HValue* new_elements =
- BuildAllocateElements(context(), to_kind, elements_length);
-
- // Fast elements kinds need to be initialized in case statements below cause a
- // garbage collection.
- Factory* factory = isolate()->factory();
-
- ASSERT(!IsFastSmiElementsKind(to_kind));
- double nan_double = FixedDoubleArray::hole_nan_as_double();
- HValue* hole = IsFastObjectElementsKind(to_kind)
- ? AddInstruction(new(zone) HConstant(factory->the_hole_value(),
- Representation::Tagged()))
- : AddInstruction(new(zone) HConstant(nan_double,
- Representation::Double()));
-
- LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement,
- BailoutId::StubEntry());
-
- HValue* zero = graph()->GetConstant0();
- HValue* start = IsFastElementsKind(to_kind) ? zero : array_length;
- HValue* key = builder.BeginBody(start, elements_length, Token::LT);
-
- AddInstruction(new(zone) HStoreKeyed(new_elements, key, hole, to_kind));
- AddSimulate(BailoutId::StubEntry(), REMOVABLE_SIMULATE);
-
- builder.EndBody();
+ BuildAllocateElements(context(), to_kind, elements_length,
+ BailoutId::StubEntry());
BuildCopyElements(context(), elements,
casted_stub()->from_kind(), new_elements,
- to_kind, array_length);
+ to_kind, array_length, elements_length,
+ BailoutId::StubEntry());
+
+ Isolate* isolate = graph()->isolate();
Jakob Kummerow 2013/03/11 16:36:07 not necessary, can use [this->]isolate() directly
danno 2013/03/13 15:36:26 Done.
+ Factory* factory = isolate->factory();
AddInstruction(new(zone) HStoreNamedField(js_array,
factory->elements_field_string(),
« no previous file with comments | « src/code-stubs.cc ('k') | src/heap.h » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698