| Index: src/mips/full-codegen-mips.cc
|
| diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc
|
| index 519a48370667da340df180ae1bb58df965e9a19d..1303fba5385530dc80fbea18f3ce96653cc1565b 100644
|
| --- a/src/mips/full-codegen-mips.cc
|
| +++ b/src/mips/full-codegen-mips.cc
|
| @@ -152,16 +152,21 @@ void FullCodeGenerator::Generate() {
|
| }
|
| #endif
|
|
|
| - // Strict mode functions and builtins need to replace the receiver
|
| - // with undefined when called as functions (without an explicit
|
| - // receiver object). t1 is zero for method calls and non-zero for
|
| - // function calls.
|
| - if (!info->is_classic_mode() || info->is_native()) {
|
| + // Classic mode functions and builtins need to replace the receiver with the
|
| + // global proxy when called as functions (without an explicit receiver
|
| + // object).
|
| + if (info->is_classic_mode() && !info->is_native()) {
|
| Label ok;
|
| - __ Branch(&ok, eq, t1, Operand(zero_reg));
|
| int receiver_offset = info->scope()->num_parameters() * kPointerSize;
|
| + __ lw(at, MemOperand(sp, receiver_offset));
|
| __ LoadRoot(a2, Heap::kUndefinedValueRootIndex);
|
| + __ Branch(&ok, ne, a2, Operand(at));
|
| +
|
| + __ lw(a2, GlobalObjectOperand());
|
| + __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset));
|
| +
|
| __ sw(a2, MemOperand(sp, receiver_offset));
|
| +
|
| __ bind(&ok);
|
| }
|
|
|
| @@ -2133,18 +2138,20 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| Expression *value,
|
| JSGeneratorObject::ResumeMode resume_mode) {
|
| // The value stays in a0, and is ultimately read by the resumed generator, as
|
| - // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. a1
|
| - // 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.
|
| + // a1 will hold the generator object until the activation has been resumed.
|
| VisitForStackValue(generator);
|
| VisitForAccumulatorValue(value);
|
| __ pop(a1);
|
|
|
| // Check generator state.
|
| - Label wrong_state, done;
|
| + Label wrong_state, closed_state, done;
|
| __ lw(a3, FieldMemOperand(a1, JSGeneratorObject::kContinuationOffset));
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0);
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0);
|
| - __ Branch(&wrong_state, le, a3, Operand(zero_reg));
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
|
| + __ Branch(&closed_state, eq, a3, Operand(zero_reg));
|
| + __ Branch(&wrong_state, lt, a3, Operand(zero_reg));
|
|
|
| // Load suspended function and context.
|
| __ lw(cp, FieldMemOperand(a1, JSGeneratorObject::kContextOffset));
|
| @@ -2217,6 +2224,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(a2, Heap::kUndefinedValueRootIndex);
|
| + __ push(a2);
|
| + // Pop value from top-of-stack slot; box result into result register.
|
| + EmitCreateIteratorResult(true);
|
| + } else {
|
| + // Throw the provided value.
|
| + __ push(a0);
|
| + __ CallRuntime(Runtime::kThrow, 1);
|
| + }
|
| + __ jmp(&done);
|
| +
|
| // Throw error if we attempt to operate on a running generator.
|
| __ bind(&wrong_state);
|
| __ push(a1);
|
| @@ -2626,8 +2648,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();
|
| @@ -2672,7 +2693,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();
|
| @@ -2684,15 +2705,14 @@ void FullCodeGenerator::EmitCallWithStub(Call* expr, CallFunctionFlags flags) {
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
|
|
| - // Record call targets.
|
| - 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);
|
| __ li(a2, Operand(cell));
|
|
|
| - CallFunctionStub stub(arg_count, flags);
|
| + // Record call targets in unoptimized code.
|
| + CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
|
| __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub, expr->CallFeedbackId());
|
| RecordJSReturnSite(expr);
|
| @@ -2769,7 +2789,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| // Record source position for debugger.
|
| SetSourcePosition(expr->position());
|
| - CallFunctionStub stub(arg_count, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + CallFunctionStub stub(arg_count, NO_CALL_FUNCTION_FLAGS);
|
| __ lw(a1, MemOperand(sp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub);
|
| RecordJSReturnSite(expr);
|
| @@ -2811,15 +2831,14 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| __ push(v0);
|
| // The receiver is implicitly the global receiver. Indicate this
|
| // by passing the hole to the call function stub.
|
| - __ LoadRoot(a1, Heap::kTheHoleValueRootIndex);
|
| + __ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
|
| __ push(a1);
|
| __ bind(&call);
|
| }
|
|
|
| // The receiver is either the global receiver or an object found
|
| - // by LoadContextSlot. That object could be the hole if the
|
| - // receiver is implicitly the global object.
|
| - EmitCallWithStub(expr, RECEIVER_MIGHT_BE_IMPLICIT);
|
| + // by LoadContextSlot.
|
| + EmitCallWithStub(expr);
|
| } else if (property != NULL) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(property->obj());
|
| @@ -2836,12 +2855,10 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| { PreservePositionScope scope(masm()->positions_recorder());
|
| VisitForStackValue(callee);
|
| }
|
| - // Push the hole as receiver.
|
| - // It will be correctly replaced in the call stub.
|
| - __ LoadRoot(a1, Heap::kTheHoleValueRootIndex);
|
| + __ LoadRoot(a1, Heap::kUndefinedValueRootIndex);
|
| __ push(a1);
|
| // Emit function call.
|
| - EmitCallWithStub(expr, RECEIVER_IS_IMPLICIT);
|
| + EmitCallWithStub(expr);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -3781,8 +3798,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| // InvokeFunction requires the function in a1. Move it in there.
|
| __ mov(a1, result_register());
|
| ParameterCount count(arg_count);
|
| - __ InvokeFunction(a1, count, CALL_FUNCTION,
|
| - NullCallWrapper(), CALL_AS_METHOD);
|
| + __ InvokeFunction(a1, count, CALL_FUNCTION, NullCallWrapper());
|
| __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
|
|
| @@ -4198,10 +4214,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
|
| if (expr->is_jsruntime()) {
|
| // Call the JS runtime function.
|
| __ li(a2, 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.
|
| __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset));
|
| } else {
|
|
|