| Index: src/x64/full-codegen-x64.cc
|
| diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc
|
| index c9581479cd07ecac02b783886f27acbd24f94325..3b4c07c89c9f9a22a720463119c82834db915352 100644
|
| --- a/src/x64/full-codegen-x64.cc
|
| +++ b/src/x64/full-codegen-x64.cc
|
| @@ -137,9 +137,6 @@ void FullCodeGenerator::Generate() {
|
| // object).
|
| if (info->is_classic_mode() && !info->is_native()) {
|
| Label ok;
|
| - __ testq(rcx, rcx);
|
| - __ j(zero, &ok, Label::kNear);
|
| -
|
| // +1 for return address.
|
| StackArgumentsAccessor args(rsp, info->scope()->num_parameters());
|
| __ movq(rcx, args.GetReceiverOperand());
|
| @@ -2101,19 +2098,21 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| Expression *value,
|
| JSGeneratorObject::ResumeMode resume_mode) {
|
| // The value stays in rax, and is ultimately read by the resumed generator, as
|
| - // if the CallRuntime(Runtime::kSuspendJSGeneratorObject) returned it. rbx
|
| - // 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.
|
| + // rbx will hold the generator object until the activation has been resumed.
|
| VisitForStackValue(generator);
|
| VisitForAccumulatorValue(value);
|
| __ pop(rbx);
|
|
|
| // Check generator state.
|
| - Label wrong_state, done;
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting <= 0);
|
| - STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed <= 0);
|
| + Label wrong_state, closed_state, done;
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorExecuting < 0);
|
| + STATIC_ASSERT(JSGeneratorObject::kGeneratorClosed == 0);
|
| __ SmiCompare(FieldOperand(rbx, JSGeneratorObject::kContinuationOffset),
|
| Smi::FromInt(0));
|
| - __ j(less_equal, &wrong_state);
|
| + __ j(equal, &closed_state);
|
| + __ j(less, &wrong_state);
|
|
|
| // Load suspended function and context.
|
| __ movq(rsi, FieldOperand(rbx, JSGeneratorObject::kContextOffset));
|
| @@ -2184,6 +2183,20 @@ void FullCodeGenerator::EmitGeneratorResume(Expression *generator,
|
| // Not reached: the runtime call returns elsewhere.
|
| __ Abort(kGeneratorFailedToResume);
|
|
|
| + // Reach here when generator is closed.
|
| + __ bind(&closed_state);
|
| + if (resume_mode == JSGeneratorObject::NEXT) {
|
| + // Return completed iterator result when generator is closed.
|
| + __ PushRoot(Heap::kUndefinedValueRootIndex);
|
| + // Pop value from top-of-stack slot; box result into result register.
|
| + EmitCreateIteratorResult(true);
|
| + } else {
|
| + // Throw the provided value.
|
| + __ push(rax);
|
| + __ CallRuntime(Runtime::kThrow, 1);
|
| + }
|
| + __ jmp(&done);
|
| +
|
| // Throw error if we attempt to operate on a running generator.
|
| __ bind(&wrong_state);
|
| __ push(rbx);
|
| @@ -2538,8 +2551,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();
|
| @@ -2584,7 +2596,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();
|
| @@ -2596,15 +2608,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);
|
| __ Move(rbx, cell);
|
|
|
| - CallFunctionStub stub(arg_count, flags);
|
| + // Record call targets in unoptimized code.
|
| + CallFunctionStub stub(arg_count, RECORD_CALL_TARGET);
|
| __ movq(rdi, Operand(rsp, (arg_count + 1) * kPointerSize));
|
| __ CallStub(&stub, expr->CallFeedbackId());
|
| RecordJSReturnSite(expr);
|
| @@ -2723,7 +2734,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());
|
| @@ -2742,7 +2753,7 @@ void FullCodeGenerator::VisitCall(Call* expr) {
|
| }
|
| __ PushRoot(Heap::kUndefinedValueRootIndex);
|
| // Emit function call.
|
| - EmitCallWithStub(expr, NO_CALL_FUNCTION_FLAGS);
|
| + EmitCallWithStub(expr);
|
| }
|
|
|
| #ifdef DEBUG
|
| @@ -3667,8 +3678,7 @@ void FullCodeGenerator::EmitCallFunction(CallRuntime* expr) {
|
| // InvokeFunction requires the function in rdi. Move it in there.
|
| __ movq(rdi, result_register());
|
| ParameterCount count(arg_count);
|
| - __ InvokeFunction(rdi, count, CALL_FUNCTION,
|
| - NullCallWrapper(), CALL_AS_FUNCTION);
|
| + __ InvokeFunction(rdi, count, CALL_FUNCTION, NullCallWrapper());
|
| __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| __ jmp(&done);
|
|
|
| @@ -4138,10 +4148,8 @@ void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
|
| if (expr->is_jsruntime()) {
|
| // Call the JS runtime function using a call IC.
|
| __ Move(rcx, 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.
|
| __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
|
| } else {
|
|
|