Commit 7e08f81e authored by verwaest@chromium.org's avatar verwaest@chromium.org

Also eliminate map checks with transitions.

R=ulan@chromium.org

Review URL: https://chromiumcodereview.appspot.com/19888006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15821 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 558c4237
......@@ -2791,6 +2791,39 @@ HCheckMaps* HCheckMaps::New(HValue* value,
}
HCheckMaps* HCheckMaps::NewWithTransitions(HValue* value,
Handle<Map> map,
Zone* zone,
CompilationInfo* info) {
HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, value);
check_map->map_set_.Add(map, zone);
// Since transitioned elements maps of the initial map don't fail the map
// check, the CheckMaps instruction doesn't need to depend on ElementsKinds.
check_map->ClearGVNFlag(kDependsOnElementsKind);
ElementsKind kind = map->elements_kind();
bool packed = IsFastPackedElementsKind(kind);
while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
kind = GetNextMoreGeneralFastElementsKind(kind, packed);
Map* transitioned_map =
map->LookupElementsTransitionMap(kind);
if (transitioned_map) {
check_map->map_set_.Add(Handle<Map>(transitioned_map), zone);
}
};
if (map->CanOmitMapChecks() &&
value->IsConstant() &&
HConstant::cast(value)->InstanceOf(map)) {
check_map->omit(info);
}
check_map->map_set_.Sort();
return check_map;
}
void HCheckMaps::FinalizeUniqueValueId() {
if (!map_unique_ids_.is_empty()) return;
Zone* zone = block()->zone();
......
......@@ -2750,27 +2750,7 @@ class HCheckMaps: public HTemplateInstruction<2> {
}
static HCheckMaps* NewWithTransitions(HValue* value, Handle<Map> map,
Zone* zone) {
HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, value);
check_map->map_set_.Add(map, zone);
// Since transitioned elements maps of the initial map don't fail the map
// check, the CheckMaps instruction doesn't need to depend on ElementsKinds.
check_map->ClearGVNFlag(kDependsOnElementsKind);
ElementsKind kind = map->elements_kind();
bool packed = IsFastPackedElementsKind(kind);
while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
kind = GetNextMoreGeneralFastElementsKind(kind, packed);
Map* transitioned_map =
map->LookupElementsTransitionMap(kind);
if (transitioned_map) {
check_map->map_set_.Add(Handle<Map>(transitioned_map), zone);
}
};
check_map->map_set_.Sort();
return check_map;
}
Zone* zone, CompilationInfo* info);
bool CanOmitMapChecks() { return omit_; }
......
......@@ -4549,7 +4549,8 @@ void HOptimizedGraphBuilder::AddCheckMap(HValue* object, Handle<Map> map) {
void HOptimizedGraphBuilder::AddCheckMapsWithTransitions(HValue* object,
Handle<Map> map) {
BuildCheckHeapObject(object);
AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone()));
AddInstruction(HCheckMaps::NewWithTransitions(
object, map, zone(), top_info()));
}
......
......@@ -53,3 +53,18 @@ assertEquals(2, load2());
g2.b = 10;
g2.a = 5;
assertEquals(5, load2());
var g3 = { a:2, b:9, c:1 }
function store(v) {
g3.a = v;
return g3.a;
}
assertEquals(5, store(5));
assertEquals(8, store(8));
%OptimizeFunctionOnNextCall(store);
assertEquals(10, store(10));
delete g3.c;
store(7);
assertEquals({a:7, b:9}, g3);
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