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

Unified Diff: src/objects.cc

Issue 104793003: Fix polymorphic inlined calls with migrating prototypes (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fixed inefficient recursion Created 7 years 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/type-info.h » ('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 43a047e78c0cd80c179a3c476c919f6251475362..bfe1f5577833c9902afa27efeab45953436bb53c 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2803,31 +2803,44 @@ Handle<Map> Map::GeneralizeAllFieldRepresentations(
}
-Map* Map::CurrentMapForDeprecated() {
- DisallowHeapAllocation no_allocation;
- if (!is_deprecated()) return this;
+Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
+ Handle<Map> proto_map(map);
+ while (proto_map->prototype()->IsJSObject()) {
+ Handle<JSObject> holder(JSObject::cast(proto_map->prototype()));
+ if (holder->map()->is_deprecated()) {
+ JSObject::TryMigrateInstance(holder);
+ }
+ proto_map = Handle<Map>(holder->map());
+ }
+ return CurrentMapForDeprecatedInternal(map);
+}
- DescriptorArray* old_descriptors = instance_descriptors();
- int descriptors = NumberOfOwnDescriptors();
- Map* root_map = FindRootMap();
+Handle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) {
+ if (!map->is_deprecated()) return map;
+
+ DisallowHeapAllocation no_allocation;
+ DescriptorArray* old_descriptors = map->instance_descriptors();
+
+ int descriptors = map->NumberOfOwnDescriptors();
+ Map* root_map = map->FindRootMap();
// Check the state of the root map.
- if (!EquivalentToForTransition(root_map)) return NULL;
+ if (!map->EquivalentToForTransition(root_map)) return Handle<Map>();
int verbatim = root_map->NumberOfOwnDescriptors();
Map* updated = root_map->FindUpdatedMap(
verbatim, descriptors, old_descriptors);
- if (updated == NULL) return NULL;
+ if (updated == NULL) return Handle<Map>();
DescriptorArray* updated_descriptors = updated->instance_descriptors();
int valid = updated->NumberOfOwnDescriptors();
if (!updated_descriptors->IsMoreGeneralThan(
verbatim, valid, descriptors, old_descriptors)) {
- return NULL;
+ return Handle<Map>();
}
- return updated;
+ return handle(updated);
}
@@ -3879,10 +3892,10 @@ void JSObject::MigrateInstance(Handle<JSObject> object) {
Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) {
- Map* new_map = object->map()->CurrentMapForDeprecated();
- if (new_map == NULL) return Handle<Object>();
Handle<Map> original_map(object->map());
- JSObject::MigrateToMap(object, handle(new_map));
+ Handle<Map> new_map = Map::CurrentMapForDeprecatedInternal(original_map);
+ if (new_map.is_null()) return Handle<Object>();
+ JSObject::MigrateToMap(object, new_map);
if (FLAG_trace_migration) {
object->PrintInstanceMigration(stdout, *original_map, object->map());
}
« no previous file with comments | « src/objects.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698