Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LCodeGen::DoArrayForEach(LArrayForEach* instr) {
- Register receiver = ToRegister(instr->receiver());
- Register function = ToRegister(instr->function());
- Register index = ToRegister(instr->index());
- Register length = ToRegister(instr->length());
- Register scratch = ToRegister(instr->temp());
- Label loop, done, body, footer;
- ASSERT(function.is(edi)); // Required by InvokeFunction.
- __ RecordComment(";;; check JSFunction");
- __ test(function, Immediate(kSmiTagMask));
- DeoptimizeIf(zero, instr->environment());
- __ CmpObjectType(function, JS_FUNCTION_TYPE, scratch);
- DeoptimizeIf(not_equal, instr->environment());
- LPointerMap* pointers = instr->pointer_map();
- RecordPosition(pointers->position());
- SafepointGenerator safepoint_generator(
- this, pointers, Safepoint::kLazyDeopt);
- ParameterCount actual(3);
- __ mov(length, FieldOperand(receiver, JSArray::kLengthOffset));
- __ mov(scratch, receiver);
- __ mov(receiver, FieldOperand(receiver, JSObject::kElementsOffset));
- __ xor_(index, index);
- __ bind(&loop);
- __ cmp(index, length);
- __ j(above_equal, &done, Label::kNear);
- //How to add stack-check here
- __ mov(edx, Operand(receiver, index, times_half_pointer_size,
- FixedArray::kHeaderSize - 1));
- __ test(edx, Immediate(kSmiTagMask));
- __ j(zero, &body, Label::kNear);
- __ cmp(FieldOperand(edx, HeapObject::kMapOffset),
- factory()->the_hole_value());
- __ j(equal, &footer, Label::kNear);
- __ bind(&body);
- //(item, index, array)
- __ push(edx);
- __ push(index);
- __ push(scratch);
- __ InvokeFunction(function, actual, CALL_FUNCTION,
- safepoint_generator, CALL_AS_FUNCTION);
- //todo check that array map didn't change
- __ bind(&footer);
- __ add(index, Immediate(2));
- __ jmp(&loop);
- __ bind(&done);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement