Revision: 20437
Author: verwa...@chromium.org
Date: Wed Apr 2 13:30:36 2014 UTC
Log: Replace CopyMap(constructor->initial_map()) by
Map::Create(constructor)
BUG=
R=u...@chromium.org
Review URL: https://codereview.chromium.org/218633014
http://code.google.com/p/v8/source/detail?r=20437
Modified:
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/objects.cc
/branches/bleeding_edge/src/objects.h
/branches/bleeding_edge/src/runtime.cc
/branches/bleeding_edge/test/cctest/test-heap.cc
=======================================
--- /branches/bleeding_edge/src/bootstrapper.cc Tue Apr 1 17:43:20 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Wed Apr 2 13:30:36 2014 UTC
@@ -1372,19 +1372,19 @@
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);
=======================================
--- /branches/bleeding_edge/src/factory.cc Tue Apr 1 17:43:20 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Wed Apr 2 13:30:36 2014 UTC
@@ -811,38 +811,6 @@
return prototype;
}
-
-
-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) {
@@ -1911,11 +1879,10 @@
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;
}
=======================================
--- /branches/bleeding_edge/src/factory.h Tue Apr 1 17:43:20 2014 UTC
+++ /branches/bleeding_edge/src/factory.h Wed Apr 2 13:30:36 2014 UTC
@@ -256,12 +256,6 @@
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
=======================================
--- /branches/bleeding_edge/src/objects.cc Wed Apr 2 07:59:54 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Wed Apr 2 13:30:36 2014 UTC
@@ -7007,18 +7007,15 @@
}
-MaybeObject* Map::CopyWithPreallocatedFieldDescriptors() {
- if (pre_allocated_property_fields() == 0) return CopyDropDescriptors();
+Handle<Map> Map::Copy(Handle<Map> map) {
+ CALL_HEAP_FUNCTION(map->GetIsolate(), map->Copy(), Map);
+}
- // 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();
+MaybeObject* Map::Copy() {
+ DescriptorArray* descriptors = instance_descriptors();
DescriptorArray* new_descriptors;
+ int number_of_own_descriptors = NumberOfOwnDescriptors();
MaybeObject* maybe_descriptors =
descriptors->CopyUpTo(number_of_own_descriptors);
if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
@@ -7027,20 +7024,32 @@
}
-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;
-MaybeObject* Map::Copy() {
- DescriptorArray* descriptors = instance_descriptors();
- DescriptorArray* new_descriptors;
- int number_of_own_descriptors = NumberOfOwnDescriptors();
- MaybeObject* maybe_descriptors =
- descriptors->CopyUpTo(number_of_own_descriptors);
- if (!maybe_descriptors->To(&new_descriptors)) return maybe_descriptors;
+ // 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;
+ }
- return CopyReplaceDescriptors(new_descriptors, OMIT_TRANSITION);
+ // 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;
}
=======================================
--- /branches/bleeding_edge/src/objects.h Wed Apr 2 07:59:54 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Wed Apr 2 13:30:36 2014 UTC
@@ -6223,7 +6223,6 @@
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,
@@ -6270,6 +6269,8 @@
// 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).
=======================================
--- /branches/bleeding_edge/src/runtime.cc Wed Apr 2 12:38:01 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Wed Apr 2 13:30:36 2014 UTC
@@ -209,9 +209,7 @@
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);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Mon Mar 31 14:14:54
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Wed Apr 2 13:30:36
2014 UTC
@@ -972,7 +972,6 @@
// 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.
@@ -988,9 +987,8 @@
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);
--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.