Revision: 17482
Author: [email protected]
Date: Tue Nov 5 12:32:03 2013 UTC
Log: Handlify Heap::AllocateInitialMap method.
[email protected]
BUG=v8:2877
Review URL: https://codereview.chromium.org/32003006
http://code.google.com/p/v8/source/detail?r=17482
Modified:
/branches/bleeding_edge/src/factory.cc
/branches/bleeding_edge/src/factory.h
/branches/bleeding_edge/src/heap.cc
/branches/bleeding_edge/src/heap.h
/branches/bleeding_edge/src/objects.cc
=======================================
--- /branches/bleeding_edge/src/factory.cc Tue Nov 5 12:11:27 2013 UTC
+++ /branches/bleeding_edge/src/factory.cc Tue Nov 5 12:32:03 2013 UTC
@@ -581,12 +581,6 @@
isolate()->heap()->AllocateFunctionPrototype(*function),
JSObject);
}
-
-
-Handle<Map> Factory::NewInitialMap(Handle<JSFunction> function) {
- CALL_HEAP_FUNCTION(
- isolate(), isolate()->heap()->AllocateInitialMap(*function), Map);
-}
Handle<Map> Factory::CopyWithPreallocatedFieldDescriptors(Handle<Map> src)
{
=======================================
--- /branches/bleeding_edge/src/factory.h Tue Nov 5 12:11:27 2013 UTC
+++ /branches/bleeding_edge/src/factory.h Tue Nov 5 12:32:03 2013 UTC
@@ -263,8 +263,6 @@
Handle<JSObject> NewFunctionPrototype(Handle<JSFunction> function);
- Handle<Map> NewInitialMap(Handle<JSFunction> function);
-
Handle<Map> CopyWithPreallocatedFieldDescriptors(Handle<Map> map);
// Copy the map adding more inobject properties if possible without
=======================================
--- /branches/bleeding_edge/src/heap.cc Tue Nov 5 12:11:27 2013 UTC
+++ /branches/bleeding_edge/src/heap.cc Tue Nov 5 12:32:03 2013 UTC
@@ -4490,48 +4490,6 @@
return result;
}
-
-
-MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) {
- ASSERT(!fun->has_initial_map());
-
- // First create a new map with the size and number of in-object
properties
- // suggested by the function.
- InstanceType instance_type;
- int instance_size;
- int in_object_properties;
- if (fun->shared()->is_generator()) {
- instance_type = JS_GENERATOR_OBJECT_TYPE;
- instance_size = JSGeneratorObject::kSize;
- in_object_properties = 0;
- } else {
- instance_type = JS_OBJECT_TYPE;
- instance_size = fun->shared()->CalculateInstanceSize();
- in_object_properties = fun->shared()->CalculateInObjectProperties();
- }
- Map* map;
- MaybeObject* maybe_map = AllocateMap(instance_type, instance_size);
- if (!maybe_map->To(&map)) return maybe_map;
-
- // Fetch or allocate prototype.
- Object* prototype;
- if (fun->has_instance_prototype()) {
- prototype = fun->instance_prototype();
- } else {
- MaybeObject* maybe_prototype = AllocateFunctionPrototype(fun);
- if (!maybe_prototype->To(&prototype)) return maybe_prototype;
- }
- map->set_inobject_properties(in_object_properties);
- map->set_unused_property_fields(in_object_properties);
- map->set_prototype(prototype);
- ASSERT(map->has_fast_object_elements());
-
- if (!fun->shared()->is_generator()) {
- fun->shared()->StartInobjectSlackTracking(map);
- }
-
- return map;
-}
void Heap::InitializeJSObjectFromMap(JSObject* obj,
=======================================
--- /branches/bleeding_edge/src/heap.h Tue Nov 5 12:11:27 2013 UTC
+++ /branches/bleeding_edge/src/heap.h Tue Nov 5 12:32:03 2013 UTC
@@ -744,9 +744,6 @@
MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType
instance_type,
int instance_size);
- // Allocate a map for the specified function
- MUST_USE_RESULT MaybeObject* AllocateInitialMap(JSFunction* fun);
-
// Allocates an empty code cache.
MUST_USE_RESULT MaybeObject* AllocateCodeCache();
=======================================
--- /branches/bleeding_edge/src/objects.cc Tue Nov 5 12:25:32 2013 UTC
+++ /branches/bleeding_edge/src/objects.cc Tue Nov 5 12:32:03 2013 UTC
@@ -9899,9 +9899,42 @@
void JSFunction::EnsureHasInitialMap(Handle<JSFunction> function) {
if (function->has_initial_map()) return;
Isolate* isolate = function->GetIsolate();
- Handle<Map> initial_map = isolate->factory()->NewInitialMap(function);
- function->set_initial_map(*initial_map);
- initial_map->set_constructor(*function);
+
+ // First create a new map with the size and number of in-object
properties
+ // suggested by the function.
+ InstanceType instance_type;
+ int instance_size;
+ int in_object_properties;
+ if (function->shared()->is_generator()) {
+ instance_type = JS_GENERATOR_OBJECT_TYPE;
+ instance_size = JSGeneratorObject::kSize;
+ in_object_properties = 0;
+ } else {
+ instance_type = JS_OBJECT_TYPE;
+ instance_size = function->shared()->CalculateInstanceSize();
+ in_object_properties =
function->shared()->CalculateInObjectProperties();
+ }
+ Handle<Map> map = isolate->factory()->NewMap(instance_type,
instance_size);
+
+ // Fetch or allocate prototype.
+ Handle<Object> prototype;
+ if (function->has_instance_prototype()) {
+ prototype = handle(function->instance_prototype(), isolate);
+ } else {
+ prototype = isolate->factory()->NewFunctionPrototype(function);
+ }
+ map->set_inobject_properties(in_object_properties);
+ map->set_unused_property_fields(in_object_properties);
+ map->set_prototype(*prototype);
+ ASSERT(map->has_fast_object_elements());
+
+ if (!function->shared()->is_generator()) {
+ function->shared()->StartInobjectSlackTracking(*map);
+ }
+
+ // Finally link initial map and constructor function.
+ function->set_initial_map(*map);
+ map->set_constructor(*function);
}
--
--
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/groups/opt_out.