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

Unified Diff: src/objects.cc

Issue 251683003: Fix CurrentMapForDeprecated() to return MaybeHandle instead of a null handle. (Closed) Base URL: git@github.com:v8/v8.git@master
Patch Set: Mark functions that return MaybeHandle with V8_WARN_UNUSED_RESULT. Created 6 years, 8 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 30329e8f2dd7b438b310569e0f82df39933de1fa..a6534b3baf1c1d9d59cecaed05020fb8f0ae9355 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -2764,20 +2764,22 @@ Handle<Map> Map::GeneralizeAllFieldRepresentations(
}
-Handle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
+// static
+MaybeHandle<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());
+ if (proto_map->is_deprecated() && JSObject::TryMigrateInstance(holder)) {
+ proto_map = Handle<Map>(holder->map());
+ }
}
return CurrentMapForDeprecatedInternal(map);
}
-Handle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) {
+// static
+MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) {
if (!map->is_deprecated()) return map;
DisallowHeapAllocation no_allocation;
@@ -2787,18 +2789,18 @@ Handle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> map) {
Map* root_map = map->FindRootMap();
// Check the state of the root map.
- if (!map->EquivalentToForTransition(root_map)) return Handle<Map>();
+ if (!map->EquivalentToForTransition(root_map)) return MaybeHandle<Map>();
int verbatim = root_map->NumberOfOwnDescriptors();
Map* updated = root_map->FindUpdatedMap(
verbatim, descriptors, old_descriptors);
- if (updated == NULL) return Handle<Map>();
+ if (updated == NULL) return MaybeHandle<Map>();
DescriptorArray* updated_descriptors = updated->instance_descriptors();
int valid = updated->NumberOfOwnDescriptors();
if (!updated_descriptors->IsMoreGeneralThan(
verbatim, valid, descriptors, old_descriptors)) {
- return Handle<Map>();
+ return MaybeHandle<Map>();
}
return handle(updated);
@@ -3903,15 +3905,18 @@ void JSObject::MigrateInstance(Handle<JSObject> object) {
}
-Handle<Object> JSObject::TryMigrateInstance(Handle<JSObject> object) {
+// static
+bool JSObject::TryMigrateInstance(Handle<JSObject> object) {
Handle<Map> original_map(object->map());
- Handle<Map> new_map = Map::CurrentMapForDeprecatedInternal(original_map);
- if (new_map.is_null()) return Handle<Object>();
+ Handle<Map> new_map;
+ if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) {
+ return false;
+ }
JSObject::MigrateToMap(object, new_map);
if (FLAG_trace_migration) {
object->PrintInstanceMigration(stdout, *original_map, object->map());
}
- return object;
+ return true;
}
« 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