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

Unified Diff: src/bootstrapper.cc

Issue 358363003: 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, 6 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/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index 72ca6bfdc53303bf860b7a2c060eda4a8e74bc0b..735d0992d7eeab142a438eb1eec93c58220edf41 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -1133,80 +1133,59 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> global_object,
InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
isolate->initial_object_prototype(), Builtins::kIllegal);
- { // --- arguments_boilerplate_
+ { // --- sloppy arguments map
// Make sure we can recognize argument objects at runtime.
// This is done by introducing an anonymous function with
// class_name equals 'Arguments'.
Handle<String> arguments_string = factory->InternalizeOneByteString(
STATIC_ASCII_VECTOR("Arguments"));
Handle<Code> code(isolate->builtins()->builtin(Builtins::kIllegal));
-
Handle<JSFunction> function = factory->NewFunctionWithoutPrototype(
arguments_string, code);
- ASSERT(!function->has_initial_map());
function->shared()->set_instance_class_name(*arguments_string);
- function->shared()->set_expected_nof_properties(2);
- function->set_prototype_or_initial_map(
- native_context()->object_function()->prototype());
- Handle<JSObject> result = factory->NewJSObject(function);
-
- native_context()->set_sloppy_arguments_boilerplate(*result);
- // Note: length must be added as the first property and
- // callee must be added as the second property.
- JSObject::AddProperty(
- result, factory->length_string(),
- factory->undefined_value(), DONT_ENUM,
- Object::FORCE_TAGGED, FORCE_FIELD);
- JSObject::AddProperty(
- result, factory->callee_string(),
- factory->undefined_value(), DONT_ENUM,
- Object::FORCE_TAGGED, FORCE_FIELD);
+
+ Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
+ Heap::kSloppyArgumentsObjectSize);
+ // Create the descriptor array for the arguments object.
+ Map::EnsureDescriptorSlack(map, 2);
+
+ { // length
+ FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
+ DONT_ENUM, Representation::Tagged());
+ map->AppendDescriptor(&d);
+ }
+ { // callee
+ FieldDescriptor d(factory->callee_string(), Heap::kArgumentsCalleeIndex,
+ DONT_ENUM, Representation::Tagged());
+ map->AppendDescriptor(&d);
+ }
+
+ map->set_function_with_prototype(true);
+ map->set_prototype(native_context()->object_function()->prototype());
+ map->set_pre_allocated_property_fields(2);
+ map->set_inobject_properties(2);
+ native_context()->set_sloppy_arguments_map(*map);
+
+ ASSERT(!function->has_initial_map());
+ function->set_initial_map(*map);
+ map->set_constructor(*function);
#ifdef DEBUG
Igor Sheludko 2014/07/02 14:17:14 Probably we don't need #ifdef DEBUG anymore
- LookupResult lookup(isolate);
- result->LookupOwn(factory->callee_string(), &lookup);
- ASSERT(lookup.IsField());
- ASSERT(lookup.GetFieldIndex().property_index() ==
- Heap::kArgumentsCalleeIndex);
-
- result->LookupOwn(factory->length_string(), &lookup);
- ASSERT(lookup.IsField());
- ASSERT(lookup.GetFieldIndex().property_index() ==
- Heap::kArgumentsLengthIndex);
-
- ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
- ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
-
- // Check the state of the object.
- ASSERT(result->HasFastProperties());
- ASSERT(result->HasFastObjectElements());
+ ASSERT(map->inobject_properties() > Heap::kArgumentsCalleeIndex);
+ ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex);
+ ASSERT(!map->is_dictionary_map());
+ ASSERT(IsFastObjectElementsKind(map->elements_kind()));
#endif
}
- { // --- aliased_arguments_boilerplate_
- // Set up a well-formed parameter map to make assertions happy.
- Handle<FixedArray> elements = factory->NewFixedArray(2);
- elements->set_map(heap->sloppy_arguments_elements_map());
- Handle<FixedArray> array;
- array = factory->NewFixedArray(0);
- elements->set(0, *array);
- array = factory->NewFixedArray(0);
- elements->set(1, *array);
-
- Handle<Map> old_map(
- native_context()->sloppy_arguments_boilerplate()->map());
- Handle<Map> new_map = Map::Copy(old_map);
- new_map->set_pre_allocated_property_fields(2);
- Handle<JSObject> result = factory->NewJSObjectFromMap(new_map);
- // Set elements kind after allocating the object because
- // NewJSObjectFromMap assumes a fast elements map.
- new_map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
- result->set_elements(*elements);
- ASSERT(result->HasSloppyArgumentsElements());
- native_context()->set_aliased_arguments_boilerplate(*result);
- }
-
- { // --- strict mode arguments boilerplate
+ { // --- aliased arguments map
+ Handle<Map> map = Map::Copy(isolate->sloppy_arguments_map());
+ map->set_elements_kind(SLOPPY_ARGUMENTS_ELEMENTS);
+ ASSERT_EQ(2, map->pre_allocated_property_fields());
+ native_context()->set_aliased_arguments_map(*map);
+ }
+
+ { // --- strict mode arguments map
const PropertyAttributes attributes =
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
@@ -1229,20 +1208,16 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> global_object,
Map::EnsureDescriptorSlack(map, 3);
{ // length
- FieldDescriptor d(
- factory->length_string(), 0, DONT_ENUM, Representation::Tagged());
+ FieldDescriptor d(factory->length_string(), Heap::kArgumentsLengthIndex,
+ DONT_ENUM, Representation::Tagged());
map->AppendDescriptor(&d);
}
{ // callee
- CallbacksDescriptor d(factory->callee_string(),
- callee,
- attributes);
+ CallbacksDescriptor d(factory->callee_string(), callee, attributes);
map->AppendDescriptor(&d);
}
{ // caller
- CallbacksDescriptor d(factory->caller_string(),
- caller,
- attributes);
+ CallbacksDescriptor d(factory->caller_string(), caller, attributes);
map->AppendDescriptor(&d);
}
@@ -1253,28 +1228,14 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> global_object,
// Copy constructor from the sloppy arguments boilerplate.
map->set_constructor(
- native_context()->sloppy_arguments_boilerplate()->map()->constructor());
+ native_context()->sloppy_arguments_map()->constructor());
- // Allocate the arguments boilerplate object.
- Handle<JSObject> result = factory->NewJSObjectFromMap(map);
- native_context()->set_strict_arguments_boilerplate(*result);
+ native_context()->set_strict_arguments_map(*map);
#ifdef DEBUG
Igor Sheludko 2014/07/02 14:17:14 Same here.
- LookupResult lookup(isolate);
- result->LookupOwn(factory->length_string(), &lookup);
- ASSERT(lookup.IsField());
- ASSERT(lookup.GetFieldIndex().property_index() ==
- Heap::kArgumentsLengthIndex);
-
- Handle<Object> length_value = Object::GetProperty(
- result, factory->length_string()).ToHandleChecked();
- ASSERT_EQ(heap->undefined_value(), *length_value);
-
- ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
-
- // Check the state of the object.
- ASSERT(result->HasFastProperties());
- ASSERT(result->HasFastObjectElements());
+ ASSERT(map->inobject_properties() > Heap::kArgumentsLengthIndex);
+ ASSERT(!map->is_dictionary_map());
+ ASSERT(IsFastObjectElementsKind(map->elements_kind()));
#endif
}

Powered by Google App Engine
This is Rietveld 408576698