Index: src/interpreter/bytecode-generator.cc |
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc |
index 22972537abcbccb0e72a702ba07e9e4eb12a011a..c57ce9ef13f0b3736eff4d927f425aff81a0796a 100644 |
--- a/src/interpreter/bytecode-generator.cc |
+++ b/src/interpreter/bytecode-generator.cc |
@@ -851,7 +851,6 @@ void BytecodeGenerator::VisitForInAssignment(Expression* expr, |
void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
EffectResultScope statement_result_scope(this); |
- |
if (stmt->subject()->IsNullLiteral() || |
stmt->subject()->IsUndefinedLiteral(isolate())) { |
// ForIn generates lots of code, skip if it wouldn't produce any effects. |
@@ -865,34 +864,26 @@ void BytecodeGenerator::VisitForInStatement(ForInStatement* stmt) { |
VisitForAccumulatorValue(stmt->subject()); |
loop_builder.BreakIfUndefined(); |
loop_builder.BreakIfNull(); |
- |
Register receiver = execution_result()->NewRegister(); |
- builder()->CastAccumulatorToJSObject(); |
- builder()->StoreAccumulatorInRegister(receiver); |
- builder()->CallRuntime(Runtime::kGetPropertyNamesFast, receiver, 1); |
- builder()->ForInPrepare(receiver); |
- loop_builder.BreakIfUndefined(); |
- |
- Register for_in_state = execution_result()->NewRegister(); |
- builder()->StoreAccumulatorInRegister(for_in_state); |
+ Register cache_type = execution_result()->NewRegister(); |
+ Register cache_array = execution_result()->NewRegister(); |
+ Register cache_length = execution_result()->NewRegister(); |
+ builder()->ForInPrepare(receiver, cache_type, cache_array, cache_length); |
// Check loop termination (accumulator holds index). |
- Register index = receiver; // Re-using register as receiver no longer used. |
+ Register index = execution_result()->NewRegister(); |
builder()->LoadLiteral(Smi::FromInt(0)); |
+ builder()->StoreAccumulatorInRegister(index); |
loop_builder.LoopHeader(); |
loop_builder.Condition(); |
- builder()->StoreAccumulatorInRegister(index).ForInDone(for_in_state); |
+ builder()->ForInDone(index, cache_length); |
loop_builder.BreakIfTrue(); |
- builder()->ForInNext(for_in_state, index); |
+ builder()->ForInNext(receiver, cache_type, cache_array, index); |
loop_builder.ContinueIfUndefined(); |
- |
VisitForInAssignment(stmt->each(), stmt->EachFeedbackSlot()); |
Visit(stmt->body()); |
- |
- // TODO(oth): replace CountOperation here with ForInStep. |
loop_builder.Next(); |
- builder()->LoadAccumulatorWithRegister(index).CountOperation( |
- Token::Value::ADD, language_mode_strength()); |
+ builder()->ForInStep(index); |
loop_builder.JumpToHeader(); |
loop_builder.LoopEnd(); |
} |