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

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: REBASE 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
« no previous file with comments | « src/code-stubs.cc ('k') | src/elements-kind.h » ('j') | no next file with comments »
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 d8eaae019076f0d09111882c53849433b1d7ee73..b6e5ffd2ce8632429c51346df84143e15d040525 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -909,4 +909,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
« no previous file with comments | « src/code-stubs.cc ('k') | src/elements-kind.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698