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

Unified Diff: src/heap.cc

Issue 371913002: Revert "Only create arguments-maps in the bootstrapper, remove now obsolete ValueType flag." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/heap.h ('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/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 2fa7702db07192dc18e976ead0ee29b441e38bce..d390788d261cd479bec9a1cd4df0d6d22f0fe283 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -3569,6 +3569,58 @@ AllocationResult Heap::Allocate(Map* map, AllocationSpace space,
}
+AllocationResult Heap::AllocateArgumentsObject(Object* callee, int length) {
+ // To get fast allocation and map sharing for arguments objects we
+ // allocate them based on an arguments boilerplate.
+
+ JSObject* boilerplate;
+ int arguments_object_size;
+ bool strict_mode_callee = callee->IsJSFunction() &&
+ JSFunction::cast(callee)->shared()->strict_mode() == STRICT;
+ if (strict_mode_callee) {
+ boilerplate =
+ isolate()->context()->native_context()->strict_arguments_boilerplate();
+ arguments_object_size = kStrictArgumentsObjectSize;
+ } else {
+ boilerplate =
+ isolate()->context()->native_context()->sloppy_arguments_boilerplate();
+ arguments_object_size = kSloppyArgumentsObjectSize;
+ }
+
+ // Check that the size of the boilerplate matches our
+ // expectations. The ArgumentsAccessStub::GenerateNewObject relies
+ // on the size being a known constant.
+ ASSERT(arguments_object_size == boilerplate->map()->instance_size());
+
+ // Do the allocation.
+ HeapObject* result;
+ { AllocationResult allocation =
+ AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE);
+ if (!allocation.To(&result)) return allocation;
+ }
+
+ // Copy the content. The arguments boilerplate doesn't have any
+ // fields that point to new space so it's safe to skip the write
+ // barrier here.
+ CopyBlock(result->address(), boilerplate->address(), JSObject::kHeaderSize);
+
+ // Set the length property.
+ JSObject* js_obj = JSObject::cast(result);
+ js_obj->InObjectPropertyAtPut(
+ kArgumentsLengthIndex, Smi::FromInt(length), SKIP_WRITE_BARRIER);
+ // Set the callee property for sloppy mode arguments object only.
+ if (!strict_mode_callee) {
+ js_obj->InObjectPropertyAtPut(kArgumentsCalleeIndex, callee);
+ }
+
+ // Check the state of the object
+ ASSERT(js_obj->HasFastProperties());
+ ASSERT(js_obj->HasFastObjectElements());
+
+ return js_obj;
+}
+
+
void Heap::InitializeJSObjectFromMap(JSObject* obj,
FixedArray* properties,
Map* map) {
« no previous file with comments | « src/heap.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698