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

Unified Diff: src/objects.cc

Issue 346743005: Making MigrateToMap() a single bottleneck for all migrations except slow-to-fast case. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 6 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') | no next file » | 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 408e35ab421e97a22d19533dbfb020c695e05e22..dd4341b45558a94a9d6be3f69fff34839a9bf2ac 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2119,7 +2119,26 @@ Handle<TransitionArray> Map::SetElementsTransitionMap(
}
-// To migrate an instance to a map:
+void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
+ if (object->map() == *new_map) return;
+ if (object->HasFastProperties()) {
+ if (!new_map->is_dictionary_map()) {
+ MigrateFastToFast(object, new_map);
+ } else {
+ MigrateFastToSlow(object, new_map, 0);
+ }
+ } else {
+ // For slow-to-fast migrations JSObject::TransformToFastProperties()
+ // must be used instead.
+ CHECK(new_map->is_dictionary_map());
+
+ // Slow-to-slow migration is trivial.
+ object->set_map(*new_map);
+ }
+}
+
+
+// To migrate an fast instance to a fast map:
Toon Verwaest 2014/06/24 13:17:33 a fast
// - First check whether the instance needs to be rewritten. If not, simply
// change the map.
// - Otherwise, allocate a fixed array large enough to hold all fields, in
@@ -2134,7 +2153,7 @@ Handle<TransitionArray> Map::SetElementsTransitionMap(
// to temporarily store the inobject properties.
// * If there are properties left in the backing store, install the backing
// store.
-void JSObject::MigrateToMap(Handle<JSObject> object, Handle<Map> new_map) {
+void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
Isolate* isolate = object->GetIsolate();
Handle<Map> old_map(object->map());
int number_of_fields = new_map->NumberOfFields();
@@ -2276,8 +2295,7 @@ void JSObject::GeneralizeFieldRepresentation(Handle<JSObject> object,
Handle<Map> new_map = Map::GeneralizeRepresentation(
handle(object->map()), modify_index, new_representation,
new_field_type, store_mode);
- if (object->map() == *new_map) return;
- return MigrateToMap(object, new_map);
+ MigrateToMap(object, new_map);
}
@@ -4570,6 +4588,16 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
int expected_additional_properties) {
if (!object->HasFastProperties()) return;
+ Handle<Map> map(object->map());
+ Handle<Map> new_map = Map::Normalize(map, mode);
+
+ MigrateFastToSlow(object, new_map, expected_additional_properties);
+}
+
+
+void JSObject::MigrateFastToSlow(Handle<JSObject> object,
+ Handle<Map> new_map,
+ int expected_additional_properties) {
// The global object is always normalized.
ASSERT(!object->IsGlobalObject());
// JSGlobalProxy must never be normalized
@@ -4578,7 +4606,6 @@ void JSObject::NormalizeProperties(Handle<JSObject> object,
Isolate* isolate = object->GetIsolate();
HandleScope scope(isolate);
Handle<Map> map(object->map());
- Handle<Map> new_map = Map::Normalize(map, mode);
// Allocate new content.
int real_size = map->NumberOfOwnDescriptors();
« no previous file with comments | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698