Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(711)

Side by Side Diff: src/ia32/builtins-ia32.cc

Issue 1865833002: [generators] Decouple generator resume from fullcodegen. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 385 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
386 Generate_JSEntryTrampolineHelper(masm, false); 386 Generate_JSEntryTrampolineHelper(masm, false);
387 } 387 }
388 388
389 389
390 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 390 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
391 Generate_JSEntryTrampolineHelper(masm, true); 391 Generate_JSEntryTrampolineHelper(masm, true);
392 } 392 }
393 393
394 // static
395 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
396 // ----------- S t a t e -------------
397 // -- eax : the value to pass to the generator
398 // -- ebx : the JSGeneratorObject to resume
399 // -- edx : the resume mode (tagged)
400 // -- esp[0] : return address
401 // -----------------------------------
402 __ AssertGeneratorObject(ebx);
403
404 // Store input value into generator object.
405 __ mov(FieldOperand(ebx, JSGeneratorObject::kInputOffset), eax);
406 __ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, eax, ecx,
407 kDontSaveFPRegs);
408
409 // Load suspended function and context.
410 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
411 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
412
413 // Flood function if we are stepping.
414 Label skip_flooding;
415 ExternalReference step_in_enabled =
416 ExternalReference::debug_step_in_enabled_address(masm->isolate());
417 __ cmpb(Operand::StaticVariable(step_in_enabled), Immediate(0));
418 __ j(equal, &skip_flooding);
419 {
420 FrameScope scope(masm, StackFrame::INTERNAL);
421 __ Push(ebx);
422 __ Push(edx);
423 __ Push(edi);
424 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
425 __ Pop(edx);
426 __ Pop(ebx);
427 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
428 }
429 __ bind(&skip_flooding);
430
431 // Pop return address.
432 __ PopReturnAddressTo(eax);
433
434 // Push receiver.
435 __ Push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
436
437 // ----------- S t a t e -------------
438 // -- eax : return address
439 // -- ebx : the JSGeneratorObject to resume
440 // -- edx : the resume mode (tagged)
441 // -- edi : generator function
442 // -- esi : generator context
443 // -- esp[0] : generator receiver
444 // -----------------------------------
445
446 // Push holes for arguments to generator function. Since the parser forced
447 // context allocation for any variables in generators, the actual argument
448 // values have already been copied into the context and these dummy values
449 // will never be used.
450 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
451 __ mov(ecx,
452 FieldOperand(ecx, SharedFunctionInfo::kFormalParameterCountOffset));
453 {
454 Label done_loop, loop;
455 __ bind(&loop);
456 __ sub(ecx, Immediate(Smi::FromInt(1)));
457 __ j(carry, &done_loop, Label::kNear);
458 __ PushRoot(Heap::kTheHoleValueRootIndex);
459 __ jmp(&loop);
460 __ bind(&done_loop);
461 }
462
463 // Enter a new JavaScript frame, and initialize its slots as they were when
464 // the generator was suspended.
465 FrameScope scope(masm, StackFrame::MANUAL);
466 __ PushReturnAddressFrom(eax); // Return address.
467 __ Push(ebp); // Caller's frame pointer.
468 __ Move(ebp, esp);
469 __ Push(esi); // Callee's context.
470 __ Push(edi); // Callee's JS Function.
471
472 // Restore the operand stack.
473 __ mov(eax, FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset));
474 {
475 Label done_loop, loop;
476 __ Move(ecx, Smi::FromInt(0));
477 __ bind(&loop);
478 __ cmp(ecx, FieldOperand(eax, FixedArray::kLengthOffset));
479 __ j(equal, &done_loop, Label::kNear);
480 __ Push(FieldOperand(eax, ecx, times_half_pointer_size,
481 FixedArray::kHeaderSize));
482 __ add(ecx, Immediate(Smi::FromInt(1)));
483 __ jmp(&loop);
484 __ bind(&done_loop);
485 }
486
487 // Push resume mode (consumed in continuation).
488 __ Push(edx);
489
490 // Reset operand stack so we don't leak.
491 __ mov(FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset),
492 Immediate(masm->isolate()->factory()->empty_fixed_array()));
493
494 // Restore value.
495 __ mov(eax, FieldOperand(ebx, JSGeneratorObject::kInputOffset));
496
497 // Resume the generator function at the continuation.
498 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
499 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset));
500 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset));
501 __ SmiUntag(ecx);
502 __ lea(edx, FieldOperand(edx, ecx, times_1, Code::kHeaderSize));
503 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
504 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
505 __ jmp(edx);
506 }
394 507
395 // Generate code for entering a JS function with the interpreter. 508 // Generate code for entering a JS function with the interpreter.
396 // On entry to the function the receiver and arguments have been pushed on the 509 // On entry to the function the receiver and arguments have been pushed on the
397 // stack left to right. The actual argument count matches the formal parameter 510 // stack left to right. The actual argument count matches the formal parameter
398 // count expected by the function. 511 // count expected by the function.
399 // 512 //
400 // The live registers are: 513 // The live registers are:
401 // o edi: the JS function object being called 514 // o edi: the JS function object being called
402 // o edx: the new target 515 // o edx: the new target
403 // o esi: our context 516 // o esi: our context
(...skipping 2207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 // And "return" to the OSR entry point of the function. 2724 // And "return" to the OSR entry point of the function.
2612 __ ret(0); 2725 __ ret(0);
2613 } 2726 }
2614 2727
2615 2728
2616 #undef __ 2729 #undef __
2617 } // namespace internal 2730 } // namespace internal
2618 } // namespace v8 2731 } // namespace v8
2619 2732
2620 #endif // V8_TARGET_ARCH_IA32 2733 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698