| Index: src/arm/full-codegen-arm.cc
|
| diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc
|
| index 8a500e203545c40954fe3e44c358e70c8da34bc7..b787f69c50cb3a79bda22b3cd27de0dcb8c5ff03 100644
|
| --- a/src/arm/full-codegen-arm.cc
|
| +++ b/src/arm/full-codegen-arm.cc
|
| @@ -149,9 +149,6 @@ void FullCodeGenerator::Generate() {
|
| // object).
|
| if (info->is_classic_mode() && !info->is_native()) {
|
| Label ok;
|
| - __ cmp(r5, Operand::Zero());
|
| - __ b(eq, &ok);
|
| -
|
| int receiver_offset = info->scope()->num_parameters() * kPointerSize;
|
| __ ldr(r2, MemOperand(sp, receiver_offset));
|
| __ CompareRoot(r2, Heap::kUndefinedValueRootIndex);
|
| @@ -2121,19 +2118,21 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| Expression *value,
|
| JSGeneratorObject::ResumeMode resume_mode) {
|
| // The value stays in r0, and is ultimately read by the resumed generator, as
|
| - // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. r1
|
| - // will hold the generator object until the activation has been resumed.
|
| + // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. Or it
|
| + // is read to throw the value when the resumed generator is already closed.
|
| + // r1 will hold the generator object until the activation has been resumed.
|
| VisitForStackValue(generator);
|
| VisitForAccumulatorValue(value);
|
| __ pop(r1);
|
|
|
| // Check generator state.
|
| - Label wrong_state, done;
|
| + Label wrong_state, closed_state, done;
|
| __ ldr(r3, FieldMemOperand(r1, JSGeneratorObject::kContinuationOffset));
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0);
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0);
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
|
| __ cmp(r3, Operand(Smi::FromInt(0)));
|
| - __ b(le, &wrong_state);
|
| + __ b(eq, &closed_state);
|
| + __ b(lt, &wrong_state);
|
|
|
| // Load suspended function and context.
|
| __ ldr(cp, FieldMemOperand(r1, JSGeneratorObject::kContextOffset));
|
| @@ -2208,6 +2207,21 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| // Not reached: the runtime call returns elsewhere.
|
| __ stop("not-reached");
|
|
|
| + // Reach here when generator is closed.
|
| + __ bind(&closed_state);
|
| + if (resume_mode == JSGeneratorObject::NEXT) {
|
| + // Return completed iterator result when generator is closed.
|
| + __ LoadRoot(r2, Heap::kUndefinedValueRootIndex);
|
| + __ push(r2);
|
| + // Pop value from top-of-stack slot; box result into result register.
|
| + EmitCreateIteratorResult(true);
|
| + } else {
|
| + // Throw the provided value.
|
| + __ push(r0);
|
| + __ CallRuntime(Runtime::kThrow, 1);
|
| + }
|
| + __ jmp(&done);
|
| +
|
| // Throw error if we attempt to operate on a running generator.
|
| __ bind(&wrong_state);
|
| __ push(r1);
|
| @@ -2600,8 +2614,7 @@ void FullCodeGenerator::EmitCallWithIC(Call* expr,
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| // Call the IC initialization code.
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
|
| + Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
|
| TypeFeedbackId ast_id = mode == CONTEXTUAL
|
| ? TypeFeedbackId::None()
|
| : expr->CallFeedbackId();
|
| @@ -2646,7 +2659,7 @@ void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
|
| }
|
|
|
|
|
| -void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) {
|
| +void FullCodeGenerator::EmitCallWithStub(Call* expr) {
|
| // Code common for calls using the call stub.
|
| ZoneList<Expression*>* args = expr->arguments();
|
| int arg_count = args->length();
|
| @@ -2658,15 +2671,14 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) {
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
|
|
| - // Record call targets in unoptimized code.
|
| - flags = static_cast<CallFunctionFlags>(flags | RECORD_CALL_TARGET);
|
| Handle<Object> uninitialized =
|
| TypeFeedbackCells::UninitializedSentinel(isolate());
|
| Handle<Cell> cell = isolate()->factory()->NewCell(uninitialized);
|
| RecordTypeFeedbackCell(expr->CallFeedbackId(), cell);
|
| __ mov(r2, Operand(cell));
|
|
|
| - CallFunctionStub stub(arg_count, flags);
|
| + // Record call targets in unoptimized code.
|
| + CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
|
| __ ldr(r1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub, expr->CallFeedbackId());
|
| RecordJSReturnSite(expr);
|
| @@ -2793,7 +2805,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
|
|
| // The receiver is either the global receiver or an object found
|
| // by LoadContextSlot.
|
| - EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
| + EmitCallWithStub(expr);
|
| } else if (property != NULL) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(property->obj());
|
| @@ -2813,7 +2825,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ LoadRoot(r1, Heap::kUndefinedValueRootIndex);
|
| __ push(r1);
|
| // Emit function call.
|
| - EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
| + EmitCallWithStub(expr);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -3729,8 +3741,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| // InvokeFunction requires the function in r1. Move it in there.
|
| __ mov(r1, result_register());
|
| ParameterCount count(arg_count);
|
| - __ InvokeFunction(r1, count, CALL_FUNCTION,
|
| - NullCallWrapper(), CALL_AS_FUNCTION);
|
| + __ InvokeFunction(r1, count, CALL_FUNCTION, NullCallWrapper());
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
|
|
| @@ -4142,10 +4153,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
|
| if (expr->is_jsruntime()) {
|
| // Call the JS runtime function.
|
| __ mov(r2, Operand(expr->name()));
|
| - ContextualMode mode = NOT_CONTEXTUAL;
|
| - Handle<Code> ic =
|
| - isolate()->stub_cache()->ComputeCallInitialize(arg_count, mode);
|
| - CallIC(ic, mode, expr->CallRuntimeFeedbackId());
|
| + Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(arg_count);
|
| + CallIC(ic, NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId());
|
| // Restore context register.
|
| __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| } else {
|
|
|