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

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

Issue 18881004: Turn ElementsTransitionAndStore stub into a HydrogenCodeStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 5 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
Index: src/code-stubs-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index fad8cfba2b9912a7600b4958d9955d2800ad482f..227a3490d35e0d1a8c61aa0b6e9ce89b30ed4510 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -905,4 +905,75 @@ Handle<Code> StoreGlobalStub::GenerateCode() {
}
+template<>
+HValue* CodeStubGraphBuilder<ElementsTransitionAndStoreStub>::BuildCodeStub() {
+ ElementsTransitionAndStoreStub* stub = casted_stub();
+ ElementsKind from_kind = stub->from();
+ ElementsKind to_kind = stub->to();
+
+ HValue* value = GetParameter(0);
+ HValue* target_map = GetParameter(1);
+ HValue* key = GetParameter(2);
+ HValue* object = GetParameter(3);
+
+ if (FLAG_trace_elements_transitions) {
+ // Tracing elements transitions is the job of the runtime.
+ current_block()->FinishExitWithDeoptimization(HDeoptimize::kUseAll);
+ set_current_block(NULL);
+ return value;
+ }
+
+ info()->MarkAsSavesCallerDoubles();
+
+ if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) {
+ Add<HTrapAllocationMemento>(object);
+ }
+
+ // Check if we need to transition the array elements first
+ // (either SMI -> Double or Double -> Object).
+ if (DoesTransitionChangeElementsBufferFormat(from_kind, to_kind)) {
+ HInstruction* array_length = NULL;
+ if (stub->is_jsarray()) {
+ array_length = AddLoad(object, HObjectAccess::ForArrayLength());
+ } else {
+ array_length = AddLoadFixedArrayLength(AddLoadElements(object));
+ }
+ array_length->set_type(HType::Smi());
+
+ IfBuilder if_builder(this);
+
+ // Check if we have any elements.
+ if_builder.IfNot<HCompareNumericAndBranch>(array_length,
+ graph()->GetConstant0(),
+ Token::EQ);
+ if_builder.Then();
+
+ HInstruction* elements = AddLoadElements(object);
+
+ HInstruction* elements_length = AddLoadFixedArrayLength(elements);
+
+ BuildGrowElementsCapacity(object, elements, from_kind, to_kind,
+ array_length, elements_length);
+
+ if_builder.End();
+ }
+
+ // Set transitioned map.
+ AddStore(object, HObjectAccess::ForMap(), target_map);
+
+ // Generate the actual store.
+ BuildUncheckedMonomorphicElementAccess(object, key, value, NULL,
+ stub->is_jsarray(), to_kind,
+ true, ALLOW_RETURN_HOLE,
+ stub->store_mode());
+
+ return value;
+}
+
+
+Handle<Code> ElementsTransitionAndStoreStub::GenerateCode() {
+ return DoGenerateCode(this);
+}
+
+
} } // namespace v8::internal
« src/code-stubs.h ('K') | « src/code-stubs.cc ('k') | src/elements-kind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698