native_context()->set_strict_generator_function_map(
*strict_mode_generator_function_map);
- Handle<Map> object_map(native_context()->object_function()->initial_map());
- Handle<Map> generator_object_prototype_map = factory()->CopyMap(
- object_map, 0);
+ Handle<JSFunction> object_function(native_context()->object_function());
+ Handle<Map> generator_object_prototype_map = Map::Create(
+ object_function, 0);
generator_object_prototype_map->set_prototype(
*generator_object_prototype);
native_context()->set_generator_object_prototype_map(
*generator_object_prototype_map);
// Create a map for generator result objects.
- ASSERT(object_map->inobject_properties() == 0);
+ ASSERT(object_function->initial_map()->inobject_properties() == 0);
STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
- Handle<Map> generator_result_map = factory()->CopyMap(object_map,
- JSGeneratorObject::kResultPropertyCount);
+ Handle<Map> generator_result_map = Map::Create(
+ object_function, JSGeneratorObject::kResultPropertyCount);
ASSERT(generator_result_map->inobject_properties() ==
JSGeneratorObject::kResultPropertyCount);
}
-Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src) {
- CALL_HEAP_FUNCTION(
- isolate(), src->CopyWithPreallocatedFieldDescriptors(), Map);
-}
-
-
-Handle<Map> Factory::CopyMap(Handle<Map> src,
- int extra_inobject_properties) {
- Handle<Map> copy = CopyWithPreallocatedFieldDescriptors(src);
- // Check that we do not overflow the instance size when adding the
- // extra inobject properties.
- int instance_size_delta = extra_inobject_properties * kPointerSize;
- int max_instance_size_delta =
- JSObject::kMaxInstanceSize - copy->instance_size();
- int max_extra_properties = max_instance_size_delta >> kPointerSizeLog2;
- if (extra_inobject_properties > max_extra_properties) {
- // If the instance size overflows, we allocate as many properties
- // as we can as inobject properties.
- instance_size_delta = max_instance_size_delta;
- extra_inobject_properties = max_extra_properties;
- }
- // Adjust the map with the extra inobject properties.
- int inobject_properties =
- copy->inobject_properties() + extra_inobject_properties;
- copy->set_inobject_properties(inobject_properties);
- copy->set_unused_property_fields(inobject_properties);
- copy->set_instance_size(copy->instance_size() + instance_size_delta);
- copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
- return copy;
-}
-
-
Handle<FixedArray> Factory::CopyFixedArray(Handle<FixedArray> array) {
CALL_HEAP_FUNCTION(isolate(), array->Copy(), FixedArray);
}
Handle<Object> result = Handle<Object>(cache->Lookup(*keys), isolate());
if (result->IsMap()) return Handle<Map>::cast(result);
// Create a new map and add it to the cache.
- Handle<Map> map =
- CopyMap(Handle<Map>(context->object_function()->initial_map()),
- keys->length());
+ Handle<Map> map = Map::Create(
+ handle(context->object_function()), keys->length());
AddToMapCache(context, keys, map);
- return Handle<Map>(map);
+ return map;
}
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
- Handle<Map> CopyWithPreallocatedFieldDescriptors(Handle<Map> map);
-
- // Copy the map adding more inobject properties if possible without
- // overflowing the instance size.
- Handle<Map> CopyMap(Handle<Map> map, int extra_inobject_props);
-
Handle<FixedArray> CopyFixedArray(Handle<FixedArray> array);
// This method expects a COW array in new space, and creates a copy
}
-MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() {
- if (pre_allocated_property_fields() == 0) return CopyDropDescriptors();
-
- // If the map has pre-allocated properties always start out with a descriptor
- // array describing these properties.
- ASSERT(constructor()->IsJSFunction());
- JSFunction* ctor = JSFunction::cast(constructor());
- Map* map = ctor->initial_map();
- DescriptorArray* descriptors = map->instance_descriptors();
-
- int number_of_own_descriptors = map->NumberOfOwnDescriptors();
- DescriptorArray* new_descriptors;
- MaybeObject* maybe_descriptors =
- descriptors->CopyUpTo(number_of_own_descriptors);
- if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
-
- return CopyReplaceDescriptors(new_descriptors, OMIT_TRANSITION);
-}
-
-
Handle<Map> Map::Copy(Handle<Map> map) {
CALL_HEAP_FUNCTION(map->GetIsolate(), map->Copy(), Map);
}
}
+Handle<Map> Map::Create(Handle<JSFunction> constructor,
+ int extra_inobject_properties) {
+ Handle<Map> copy = Copy(handle(constructor->initial_map()));
+
+ // Check that we do not overflow the instance size when adding the
+ // extra inobject properties.
+ int instance_size_delta = extra_inobject_properties * kPointerSize;
+ int max_instance_size_delta =
+ JSObject::kMaxInstanceSize - copy->instance_size();
+ int max_extra_properties = max_instance_size_delta >> kPointerSizeLog2;
+
+ // If the instance size overflows, we allocate as many properties as we can as
+ // inobject properties.
+ if (extra_inobject_properties > max_extra_properties) {
+ instance_size_delta = max_instance_size_delta;
+ extra_inobject_properties = max_extra_properties;
+ }
+
+ // Adjust the map with the extra inobject properties.
+ int inobject_properties =
+ copy->inobject_properties() + extra_inobject_properties;
+ copy->set_inobject_properties(inobject_properties);
+ copy->set_unused_property_fields(inobject_properties);
+ copy->set_instance_size(copy->instance_size() + instance_size_delta);
+ copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
+ return copy;
+}
+
+
MaybeObject* Map::CopyAddDescriptor(Descriptor* descriptor,
TransitionFlag flag) {
DescriptorArray* descriptors = instance_descriptors();
static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
- MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
static Handle<Map> CopyDropDescriptors(Handle<Map> map);
MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
static Handle<Map> CopyReplaceDescriptors(Handle<Map> map,
// Returns a copy of the map, with all transitions dropped from the
// instance descriptors.
static Handle<Map> Copy(Handle<Map> map);
+ static Handle<Map> Create(Handle<JSFunction> constructor,
+ int extra_inobject_properties);
MUST_USE_RESULT MaybeObject* Copy();
// Returns the next free property index (only valid for FAST MODE).
return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
}
*is_result_from_cache = false;
- return isolate->factory()->CopyMap(
- Handle<Map>(context->object_function()->initial_map()),
- number_of_properties);
+ return Map::Create(handle(context->object_function()), number_of_properties);
}
// Test case for crbug.com/39128.
CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate();
- Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
// Increase the chance of 'bump-the-pointer' allocation in old space.
Handle<JSFunction> object_ctor(
CcTest::i_isolate()->native_context()->object_function());
CHECK(object_ctor->has_initial_map());
- Handle<Map> object_map(object_ctor->initial_map());
// Create a map with single inobject property.
- Handle<Map> my_map = factory->CopyMap(object_map, 1);
+ Handle<Map> my_map = Map::Create(object_ctor, 1);
int n_properties = my_map->inobject_properties();
CHECK_GT(n_properties, 0);