Commit f9d631b4 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Rename CurrentMapForDeprecated to TryUpdate, and introduce Map::Update which potentially deprecates

BUG=
R=ishell@chromium.org

Review URL: https://codereview.chromium.org/401243003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22510 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8968425c
...@@ -265,7 +265,7 @@ class SmallMapList V8_FINAL { ...@@ -265,7 +265,7 @@ class SmallMapList V8_FINAL {
int length() const { return list_.length(); } int length() const { return list_.length(); }
void AddMapIfMissing(Handle<Map> map, Zone* zone) { void AddMapIfMissing(Handle<Map> map, Zone* zone) {
if (!Map::CurrentMapForDeprecated(map).ToHandle(&map)) return; if (!Map::TryUpdate(map).ToHandle(&map)) return;
for (int i = 0; i < length(); ++i) { for (int i = 0; i < length(); ++i) {
if (at(i).is_identical_to(map)) return; if (at(i).is_identical_to(map)) return;
} }
......
...@@ -2861,7 +2861,7 @@ Handle<Map> Map::GeneralizeAllFieldRepresentations( ...@@ -2861,7 +2861,7 @@ Handle<Map> Map::GeneralizeAllFieldRepresentations(
// static // static
MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { MaybeHandle<Map> Map::TryUpdate(Handle<Map> map) {
Handle<Map> proto_map(map); Handle<Map> proto_map(map);
while (proto_map->prototype()->IsJSObject()) { while (proto_map->prototype()->IsJSObject()) {
Handle<JSObject> holder(JSObject::cast(proto_map->prototype())); Handle<JSObject> holder(JSObject::cast(proto_map->prototype()));
...@@ -2870,12 +2870,20 @@ MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) { ...@@ -2870,12 +2870,20 @@ MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
proto_map = Handle<Map>(holder->map()); proto_map = Handle<Map>(holder->map());
} }
} }
return CurrentMapForDeprecatedInternal(map); return TryUpdateInternal(map);
} }
// static // static
MaybeHandle<Map> Map::CurrentMapForDeprecatedInternal(Handle<Map> old_map) { Handle<Map> Map::Update(Handle<Map> map) {
return GeneralizeRepresentation(map, 0, Representation::None(),
HeapType::None(map->GetIsolate()),
ALLOW_AS_CONSTANT);
}
// static
MaybeHandle<Map> Map::TryUpdateInternal(Handle<Map> old_map) {
DisallowHeapAllocation no_allocation; DisallowHeapAllocation no_allocation;
DisallowDeoptimization no_deoptimization(old_map->GetIsolate()); DisallowDeoptimization no_deoptimization(old_map->GetIsolate());
...@@ -3940,17 +3948,12 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) { ...@@ -3940,17 +3948,12 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
void JSObject::MigrateInstance(Handle<JSObject> object) { void JSObject::MigrateInstance(Handle<JSObject> object) {
// Converting any field to the most specific type will cause the
// GeneralizeFieldRepresentation algorithm to create the most general existing
// transition that matches the object. This achieves what is needed.
Handle<Map> original_map(object->map()); Handle<Map> original_map(object->map());
GeneralizeFieldRepresentation( Handle<Map> map = Map::Update(original_map);
object, 0, Representation::None(), map->set_migration_target(true);
HeapType::None(object->GetIsolate()), MigrateToMap(object, map);
ALLOW_AS_CONSTANT);
object->map()->set_migration_target(true);
if (FLAG_trace_migration) { if (FLAG_trace_migration) {
object->PrintInstanceMigration(stdout, *original_map, object->map()); object->PrintInstanceMigration(stdout, *original_map, *map);
} }
} }
...@@ -3961,7 +3964,7 @@ bool JSObject::TryMigrateInstance(Handle<JSObject> object) { ...@@ -3961,7 +3964,7 @@ bool JSObject::TryMigrateInstance(Handle<JSObject> object) {
DisallowDeoptimization no_deoptimization(isolate); DisallowDeoptimization no_deoptimization(isolate);
Handle<Map> original_map(object->map(), isolate); Handle<Map> original_map(object->map(), isolate);
Handle<Map> new_map; Handle<Map> new_map;
if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) { if (!Map::TryUpdate(original_map).ToHandle(&new_map)) {
return false; return false;
} }
JSObject::MigrateToMap(object, new_map); JSObject::MigrateToMap(object, new_map);
...@@ -7326,11 +7329,7 @@ Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor, ...@@ -7326,11 +7329,7 @@ Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
if (map->is_dictionary_map()) return map; if (map->is_dictionary_map()) return map;
// Migrate to the newest map before storing the property. // Migrate to the newest map before storing the property.
if (map->is_deprecated()) { if (map->is_deprecated()) map = Update(map);
map = GeneralizeRepresentation(map, 0, Representation::None(),
HeapType::None(map->GetIsolate()),
ALLOW_AS_CONSTANT);
}
Handle<DescriptorArray> descriptors(map->instance_descriptors()); Handle<DescriptorArray> descriptors(map->instance_descriptors());
...@@ -7353,11 +7352,7 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, ...@@ -7353,11 +7352,7 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
if (map->is_dictionary_map()) return map; if (map->is_dictionary_map()) return map;
// Migrate to the newest map before transitioning to the new property. // Migrate to the newest map before transitioning to the new property.
if (map->is_deprecated()) { if (map->is_deprecated()) map = Update(map);
map = GeneralizeRepresentation(map, 0, Representation::None(),
HeapType::None(map->GetIsolate()),
ALLOW_AS_CONSTANT);
}
int index = map->SearchTransition(*name); int index = map->SearchTransition(*name);
if (index != TransitionArray::kNotFound) { if (index != TransitionArray::kNotFound) {
......
...@@ -6451,12 +6451,16 @@ class Map: public HeapObject { ...@@ -6451,12 +6451,16 @@ class Map: public HeapObject {
// is found by re-transitioning from the root of the transition tree using the // is found by re-transitioning from the root of the transition tree using the
// descriptor array of the map. Returns NULL if no updated map is found. // descriptor array of the map. Returns NULL if no updated map is found.
// This method also applies any pending migrations along the prototype chain. // This method also applies any pending migrations along the prototype chain.
static MaybeHandle<Map> CurrentMapForDeprecated(Handle<Map> map) static MaybeHandle<Map> TryUpdate(Handle<Map> map) V8_WARN_UNUSED_RESULT;
V8_WARN_UNUSED_RESULT;
// Same as above, but does not touch the prototype chain. // Same as above, but does not touch the prototype chain.
static MaybeHandle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map) static MaybeHandle<Map> TryUpdateInternal(Handle<Map> map)
V8_WARN_UNUSED_RESULT; V8_WARN_UNUSED_RESULT;
// Returns a non-deprecated version of the input. This method may deprecate
// existing maps along the way if encodings conflict. Not for use while
// gathering type feedback. Use TryUpdate in those cases instead.
static Handle<Map> Update(Handle<Map> map);
static Handle<Map> CopyDropDescriptors(Handle<Map> map); static Handle<Map> CopyDropDescriptors(Handle<Map> map);
static Handle<Map> CopyInsertDescriptor(Handle<Map> map, static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
Descriptor* descriptor, Descriptor* descriptor,
......
...@@ -200,7 +200,7 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id, ...@@ -200,7 +200,7 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
Handle<Map> map; Handle<Map> map;
Map* raw_map = code->FindFirstMap(); Map* raw_map = code->FindFirstMap();
if (raw_map != NULL) { if (raw_map != NULL) {
if (Map::CurrentMapForDeprecated(handle(raw_map)).ToHandle(&map) && if (Map::TryUpdate(handle(raw_map)).ToHandle(&map) &&
CanRetainOtherContext(*map, *native_context_)) { CanRetainOtherContext(*map, *native_context_)) {
map = Handle<Map>::null(); map = Handle<Map>::null();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment