| Index: src/ia32/full-codegen-ia32.cc
|
| diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc
|
| index 58ddbad74695fb7f49de8693640f7ff51252dbe8..82ef657c2900ebb2a89469c4751790c58509092f 100644
|
| --- a/src/ia32/full-codegen-ia32.cc
|
| +++ b/src/ia32/full-codegen-ia32.cc
|
| @@ -1033,9 +1033,8 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
|
| ForIn loop_statement(this, stmt);
|
| increment_loop_depth();
|
|
|
| - // Get the object to enumerate over. Both SpiderMonkey and JSC
|
| - // ignore null and undefined in contrast to the specification; see
|
| - // ECMA-262 section 12.6.4.
|
| + // Get the object to enumerate over. If the object is null or undefined, skip
|
| + // over the loop. See ECMA-262 version 5, section 12.6.4.
|
| VisitForAccumulatorValue(stmt->enumerable());
|
| __ cmp(eax, isolate()->factory()->undefined_value());
|
| __ j(equal, &exit);
|
| @@ -1198,6 +1197,64 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
|
| }
|
|
|
|
|
| +void FullCodeGenerator::VisitForOfStatement(ForOfStatement* stmt) {
|
| + Comment cmnt(masm_, "[ ForOfStatement");
|
| + SetStatementPosition(stmt);
|
| +
|
| + Iteration loop_statement(this, stmt);
|
| + increment_loop_depth();
|
| +
|
| + // var iterator = iterable[@@iterator]()
|
| + VisitForAccumulatorValue(stmt->assign_iterator());
|
| +
|
| + // As with for-in, skip the loop if the iterator is null or undefined.
|
| + __ CompareRoot(eax, Heap::kUndefinedValueRootIndex);
|
| + __ j(equal, loop_statement.break_label());
|
| + __ CompareRoot(eax, Heap::kNullValueRootIndex);
|
| + __ j(equal, loop_statement.break_label());
|
| +
|
| + // Convert the iterator to a JS object.
|
| + Label convert, done_convert;
|
| + __ JumpIfSmi(eax, &convert);
|
| + __ CmpObjectType(eax, FIRST_SPEC_OBJECT_TYPE, ecx);
|
| + __ j(above_equal, &done_convert);
|
| + __ bind(&convert);
|
| + __ push(eax);
|
| + __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
|
| + __ bind(&done_convert);
|
| +
|
| + // Loop entry.
|
| + __ bind(loop_statement.continue_label());
|
| +
|
| + // result = iterator.next()
|
| + VisitForEffect(stmt->next_result());
|
| +
|
| + // if (result.done) break;
|
| + Label result_not_done;
|
| + VisitForControl(stmt->result_done(),
|
| + loop_statement.break_label(),
|
| + &result_not_done,
|
| + &result_not_done);
|
| + __ bind(&result_not_done);
|
| +
|
| + // each = result.value
|
| + VisitForEffect(stmt->assign_each());
|
| +
|
| + // Generate code for the body of the loop.
|
| + Visit(stmt->body());
|
| +
|
| + // Check stack before looping.
|
| + PrepareForBailoutForId(stmt->BackEdgeId(), NO_REGISTERS);
|
| + EmitBackEdgeBookkeeping(stmt, loop_statement.continue_label());
|
| + __ jmp(loop_statement.continue_label());
|
| +
|
| + // Exit and decrement the loop depth.
|
| + PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
|
| + __ bind(loop_statement.break_label());
|
| + decrement_loop_depth();
|
| +}
|
| +
|
| +
|
| void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
|
| bool pretenure) {
|
| // Use the fast case closure allocation code that allocates in new
|
|
|