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

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

Issue 145513002: Turn FastNewContextStub into a HydrogenCodeStub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/ia32/code-stubs-ia32.cc » ('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 655213ec891ac61469f6867df9ea5ea054e8afeb..5b1ae39c7dd6727cf95574968674346c4a836f88 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -1330,6 +1330,60 @@ Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
template<>
+HValue* CodeStubGraphBuilder<FastNewContextStub>::BuildCodeStub() {
+ int length = casted_stub()->slots() + Context::MIN_CONTEXT_SLOTS;
+
+ // Get the function.
+ HParameter* function = GetParameter(FastNewContextStub::kFunction);
+
+ // Allocate the context in new space.
+ HAllocate* function_context = Add<HAllocate>(
+ Add<HConstant>(length * kPointerSize + FixedArray::kHeaderSize),
+ HType::Tagged(), NOT_TENURED, FIXED_ARRAY_TYPE);
+
+ // Set up the object header.
+ AddStoreMapConstant(function_context,
+ isolate()->factory()->function_context_map());
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForFixedArrayLength(),
+ Add<HConstant>(length));
+
+ // Set up the fixed slots.
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForContextSlot(Context::CLOSURE_INDEX),
+ function);
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForContextSlot(Context::PREVIOUS_INDEX),
+ context());
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX),
+ graph()->GetConstant0());
+
+ // Copy the global object from the previous context.
+ HValue* global_object = Add<HLoadNamedField>(
+ context(), HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX));
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForContextSlot(
+ Context::GLOBAL_OBJECT_INDEX),
+ global_object);
+
+ // Initialize the rest of the slots to undefined.
+ for (int i = Context::MIN_CONTEXT_SLOTS; i < length; ++i) {
+ Add<HStoreNamedField>(function_context,
+ HObjectAccess::ForContextSlot(i),
+ graph()->GetConstantUndefined());
+ }
+
+ return function_context;
+}
+
+
+Handle<Code> FastNewContextStub::GenerateCode(Isolate* isolate) {
+ return DoGenerateCode(isolate, this);
+}
+
+
+template<>
HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() {
HValue* receiver = GetParameter(0);
HValue* key = GetParameter(1);
« no previous file with comments | « src/code-stubs.cc ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698