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 {
int length() const { return list_.length(); }
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) {
if (at(i).is_identical_to(map)) return;
}
......
......@@ -2861,7 +2861,7 @@ Handle<Map> Map::GeneralizeAllFieldRepresentations(
// static
MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
MaybeHandle<Map> Map::TryUpdate(Handle<Map> map) {
Handle<Map> proto_map(map);
while (proto_map->prototype()->IsJSObject()) {
Handle<JSObject> holder(JSObject::cast(proto_map->prototype()));
......@@ -2870,12 +2870,20 @@ MaybeHandle<Map> Map::CurrentMapForDeprecated(Handle<Map> map) {
proto_map = Handle<Map>(holder->map());
}
}
return CurrentMapForDeprecatedInternal(map);
return TryUpdateInternal(map);
}
// 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;
DisallowDeoptimization no_deoptimization(old_map->GetIsolate());
......@@ -3940,17 +3948,12 @@ void JSObject::AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map) {
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());
GeneralizeFieldRepresentation(
object, 0, Representation::None(),
HeapType::None(object->GetIsolate()),
ALLOW_AS_CONSTANT);
object->map()->set_migration_target(true);
Handle<Map> map = Map::Update(original_map);
map->set_migration_target(true);
MigrateToMap(object, map);
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) {
DisallowDeoptimization no_deoptimization(isolate);
Handle<Map> original_map(object->map(), isolate);
Handle<Map> new_map;
if (!Map::CurrentMapForDeprecatedInternal(original_map).ToHandle(&new_map)) {
if (!Map::TryUpdate(original_map).ToHandle(&new_map)) {
return false;
}
JSObject::MigrateToMap(object, new_map);
......@@ -7326,11 +7329,7 @@ Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
if (map->is_dictionary_map()) return map;
// Migrate to the newest map before storing the property.
if (map->is_deprecated()) {
map = GeneralizeRepresentation(map, 0, Representation::None(),
HeapType::None(map->GetIsolate()),
ALLOW_AS_CONSTANT);
}
if (map->is_deprecated()) map = Update(map);
Handle<DescriptorArray> descriptors(map->instance_descriptors());
......@@ -7353,11 +7352,7 @@ Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
if (map->is_dictionary_map()) return map;
// Migrate to the newest map before transitioning to the new property.
if (map->is_deprecated()) {
map = GeneralizeRepresentation(map, 0, Representation::None(),
HeapType::None(map->GetIsolate()),
ALLOW_AS_CONSTANT);
}
if (map->is_deprecated()) map = Update(map);
int index = map->SearchTransition(*name);
if (index != TransitionArray::kNotFound) {
......
......@@ -6451,12 +6451,16 @@ class Map: public HeapObject {
// 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.
// This method also applies any pending migrations along the prototype chain.
static MaybeHandle<Map> CurrentMapForDeprecated(Handle<Map> map)
V8_WARN_UNUSED_RESULT;
static MaybeHandle<Map> TryUpdate(Handle<Map> map) V8_WARN_UNUSED_RESULT;
// 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;
// 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> CopyInsertDescriptor(Handle<Map> map,
Descriptor* descriptor,
......
......@@ -200,7 +200,7 @@ void TypeFeedbackOracle::CompareType(TypeFeedbackId id,
Handle<Map> map;
Map* raw_map = code->FindFirstMap();
if (raw_map != NULL) {
if (Map::CurrentMapForDeprecated(handle(raw_map)).ToHandle(&map) &&
if (Map::TryUpdate(handle(raw_map)).ToHandle(&map) &&
CanRetainOtherContext(*map, *native_context_)) {
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