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

Unified Diff: src/objects.cc

Issue 584943002: Make Map::Create always use the Object function, and remove the unused inobject properties (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index d645b4efc009e018c28a7ba98ab8f9ed9358da1a..cc685577ce37cb029d57c98fb058bcd919fcc3bc 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6660,30 +6660,26 @@ Handle<Map> Map::Copy(Handle<Map> map) {
}
-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;
}
« no previous file with comments | « src/objects.h ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698