Revision: 24094
Author: [email protected]
Date: Fri Sep 19 14:59:14 2014 UTC
Log: Make Map::Create always use the Object function, and remove the
unused inobject properties
BUG=
[email protected]
Review URL: https://codereview.chromium.org/584943002
https://code.google.com/p/v8/source/detail?r=24094
Modified:
/branches/bleeding_edge/src/bootstrapper.cc
/branches/bleeding_edge/src/factory.cc
/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 Fri Sep 19 14:03:34 2014 UTC
+++ /branches/bleeding_edge/src/bootstrapper.cc Fri Sep 19 14:59:14 2014 UTC
@@ -1156,7 +1156,11 @@
STATIC_ASSERT(JSGeneratorObject::kResultPropertyCount == 2);
Handle<JSFunction>
object_function(native_context()->object_function());
Handle<Map> iterator_result_map =
- Map::Create(object_function,
JSGeneratorObject::kResultPropertyCount);
+ Map::Create(isolate, JSGeneratorObject::kResultPropertyCount);
+ DCHECK_EQ(JSGeneratorObject::kResultSize,
+ iterator_result_map->instance_size());
+ DCHECK_EQ(JSGeneratorObject::kResultPropertyCount,
+ iterator_result_map->inobject_properties());
Map::EnsureDescriptorSlack(iterator_result_map,
JSGeneratorObject::kResultPropertyCount);
@@ -1170,14 +1174,9 @@
NONE, Representation::Tagged());
iterator_result_map->AppendDescriptor(&done_descr);
- iterator_result_map->set_instance_size(JSGeneratorObject::kResultSize);
iterator_result_map->set_unused_property_fields(0);
- iterator_result_map->set_inobject_properties(
- JSGeneratorObject::kResultPropertyCount);
iterator_result_map->set_pre_allocated_property_fields(
JSGeneratorObject::kResultPropertyCount);
- iterator_result_map->set_visitor_id(
- StaticVisitorBase::GetVisitorId(*iterator_result_map));
DCHECK_EQ(JSGeneratorObject::kResultSize,
iterator_result_map->instance_size());
native_context()->set_iterator_result_map(*iterator_result_map);
@@ -1929,8 +1928,7 @@
*strict_generator_function_map);
Handle<JSFunction>
object_function(native_context()->object_function());
- Handle<Map> generator_object_prototype_map =
- Map::Create(object_function, 0);
+ Handle<Map> generator_object_prototype_map = Map::Create(isolate(), 0);
generator_object_prototype_map->set_prototype(*generator_object_prototype);
native_context()->set_generator_object_prototype_map(
*generator_object_prototype_map);
=======================================
--- /branches/bleeding_edge/src/factory.cc Fri Sep 19 13:40:38 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc Fri Sep 19 14:59:14 2014 UTC
@@ -2331,9 +2331,9 @@
int length = keys->length();
// Create a new map and add it to the cache. Reuse the initial map of the
// Object function if the literal has no predeclared properties.
- Handle<Map> map =
- length == 0 ? handle(context->object_function()->initial_map())
- : Map::Create(handle(context->object_function()),
length);
+ Handle<Map> map = length == 0
+ ? handle(context->object_function()->initial_map())
+ : Map::Create(isolate(), length);
AddToMapCache(context, keys, map);
return map;
}
=======================================
--- /branches/bleeding_edge/src/objects.cc Fri Sep 19 13:39:55 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc Fri Sep 19 14:59:14 2014 UTC
@@ -6660,30 +6660,26 @@
}
-Handle<Map> Map::Create(Handle<JSFunction> constructor,
- int extra_inobject_properties) {
- Handle<Map> copy = Copy(handle(constructor->initial_map()));
+Handle<Map> Map::Create(Isolate* isolate, int inobject_properties) {
+ Handle<Map> copy =
Copy(handle(isolate->object_function()->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;
+ // Check that we do not overflow the instance size when adding the extra
+ // inobject properties. If the instance size overflows, we allocate as
many
+ // properties as we can as inobject properties.
+ int max_extra_properties =
+ (JSObject::kMaxInstanceSize - JSObject::kHeaderSize) >>
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;
+ if (inobject_properties > max_extra_properties) {
+ inobject_properties = max_extra_properties;
}
+
+ int new_instance_size =
+ JSObject::kHeaderSize + kPointerSize * inobject_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_instance_size(new_instance_size);
copy->set_visitor_id(StaticVisitorBase::GetVisitorId(*copy));
return copy;
}
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Sep 19 12:50:50 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Fri Sep 19 14:59:14 2014 UTC
@@ -6379,8 +6379,7 @@
// 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);
+ static Handle<Map> Create(Isolate* isolate, int inobject_properties);
// Returns the next free property index (only valid for FAST MODE).
int NextFreePropertyIndex();
=======================================
--- /branches/bleeding_edge/src/runtime.cc Fri Sep 19 12:50:50 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc Fri Sep 19 14:59:14 2014 UTC
@@ -207,7 +207,7 @@
return isolate->factory()->ObjectLiteralMapFromCache(context, keys);
}
*is_result_from_cache = false;
- return Map::Create(handle(context->object_function()),
number_of_properties);
+ return Map::Create(isolate, number_of_properties);
}
=======================================
--- /branches/bleeding_edge/test/cctest/test-heap.cc Fri Sep 19 14:19:26
2014 UTC
+++ /branches/bleeding_edge/test/cctest/test-heap.cc Fri Sep 19 14:59:14
2014 UTC
@@ -992,11 +992,8 @@
// that region dirty marks are updated correctly.
// Step 1: prepare a map for the object. We add 1 inobject property to
it.
- Handle<JSFunction> object_ctor(
- CcTest::i_isolate()->native_context()->object_function());
- CHECK(object_ctor->has_initial_map());
// Create a map with single inobject property.
- Handle<Map> my_map = Map::Create(object_ctor, 1);
+ Handle<Map> my_map = Map::Create(CcTest::i_isolate(), 1);
int n_properties = my_map->inobject_properties();
CHECK_GT(n_properties, 0);
@@ -4461,7 +4458,7 @@
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
- Handle<Map> map1 = Map::Create(isolate->object_function(), 1);
+ Handle<Map> map1 = Map::Create(isolate, 1);
Handle<Map> map2 =
Map::CopyWithField(map1, factory->NewStringFromStaticChars("foo"),
HeapType::Any(isolate), NONE,
Representation::Tagged(),
--
--
v8-dev mailing list
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/d/optout.