[crankshaft] Remove for-in slow mode deopt loop.

When a slow mode for-in loop is compiled with Crankshaft we
unconditionally deoptimize when we hit an object with a usable
enum-cache (which is currently hidden by another CL), and obviously
we don't learn anything from that.

R=jarin@chromium.org
BUG=v8:3650
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#33427}
This commit is contained in:
bmeurer 2016-01-21 00:55:49 -08:00 committed by Commit bot
parent f48bf12f5e
commit 1c6a818efb

View File

@ -5311,19 +5311,19 @@ void HOptimizedGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt, void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt,
Variable* each_var, Variable* each_var,
HValue* enumerable) { HValue* enumerable) {
HInstruction* map; HValue* map;
HInstruction* array; HValue* array;
HInstruction* enum_length; HValue* enum_length;
Handle<Map> meta_map = isolate()->factory()->meta_map();
bool fast = stmt->for_in_type() == ForInStatement::FAST_FOR_IN;
BuildCheckHeapObject(enumerable); BuildCheckHeapObject(enumerable);
Add<HCheckInstanceType>(enumerable, HCheckInstanceType::IS_JS_RECEIVER); Add<HCheckInstanceType>(enumerable, HCheckInstanceType::IS_JS_RECEIVER);
Add<HSimulate>(stmt->ToObjectId()); Add<HSimulate>(stmt->ToObjectId());
bool fast = stmt->for_in_type() == ForInStatement::FAST_FOR_IN;
if (fast) { if (fast) {
map = Add<HForInPrepareMap>(enumerable); map = Add<HForInPrepareMap>(enumerable);
Push(map); Push(map);
Add<HSimulate>(stmt->EnumId()); Add<HSimulate>(stmt->EnumId());
Drop(1); Drop(1);
Handle<Map> meta_map = isolate()->factory()->meta_map();
Add<HCheckMaps>(map, meta_map); Add<HCheckMaps>(map, meta_map);
array = Add<HForInCacheArray>(enumerable, map, array = Add<HForInCacheArray>(enumerable, map,
@ -5335,16 +5335,37 @@ void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt,
HForInCacheArray::cast(array) HForInCacheArray::cast(array)
->set_index_cache(HForInCacheArray::cast(index_cache)); ->set_index_cache(HForInCacheArray::cast(index_cache));
} else { } else {
map = graph()->GetConstant1();
Runtime::FunctionId function_id = Runtime::kGetPropertyNamesFast; Runtime::FunctionId function_id = Runtime::kGetPropertyNamesFast;
Add<HPushArguments>(enumerable); Add<HPushArguments>(enumerable);
array = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 1); array = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 1);
Push(array); Push(array);
Add<HSimulate>(stmt->EnumId()); Add<HSimulate>(stmt->EnumId());
Drop(1); Drop(1);
Handle<Map> array_map = isolate()->factory()->fixed_array_map(); {
HValue* check = Add<HCheckMaps>(array, array_map); NoObservableSideEffectsScope scope(this);
enum_length = AddLoadFixedArrayLength(array, check); IfBuilder if_fast(this);
if_fast.If<HCompareMap>(array, meta_map);
if_fast.Then();
{
HValue* cache_map = array;
HForInCacheArray* cache = Add<HForInCacheArray>(
enumerable, cache_map, DescriptorArray::kEnumCacheBridgeCacheIndex);
enum_length = Add<HMapEnumLength>(cache_map);
Push(cache_map);
Push(cache);
Push(enum_length);
}
if_fast.Else();
{
Push(graph()->GetConstant1());
Push(array);
Push(AddLoadFixedArrayLength(array));
}
if_fast.End();
enum_length = Pop();
array = Pop();
map = Pop();
}
} }
HInstruction* start_index = Add<HConstant>(0); HInstruction* start_index = Add<HConstant>(0);