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

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

Issue 1889083002: X87: [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
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_X87 5 #if V8_TARGET_ARCH_X87
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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 385
386 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { 386 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) {
387 Generate_JSEntryTrampolineHelper(masm, false); 387 Generate_JSEntryTrampolineHelper(masm, false);
388 } 388 }
389 389
390 390
391 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { 391 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) {
392 Generate_JSEntryTrampolineHelper(masm, true); 392 Generate_JSEntryTrampolineHelper(masm, true);
393 } 393 }
394 394
395 // static
396 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) {
397 // ----------- S t a t e -------------
398 // -- eax : the value to pass to the generator
399 // -- ebx : the JSGeneratorObject to resume
400 // -- edx : the resume mode (tagged)
401 // -- esp[0] : return address
402 // -----------------------------------
403 __ AssertGeneratorObject(ebx);
404
405 // Store input value into generator object.
406 __ mov(FieldOperand(ebx, JSGeneratorObject::kInputOffset), eax);
407 __ RecordWriteField(ebx, JSGeneratorObject::kInputOffset, eax, ecx,
408 kDontSaveFPRegs);
409
410 // Load suspended function and context.
411 __ mov(esi, FieldOperand(ebx, JSGeneratorObject::kContextOffset));
412 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
413
414 // Flood function if we are stepping.
415 Label skip_flooding;
416 ExternalReference step_in_enabled =
417 ExternalReference::debug_step_in_enabled_address(masm->isolate());
418 __ cmpb(Operand::StaticVariable(step_in_enabled), Immediate(0));
419 __ j(equal, &skip_flooding);
420 {
421 FrameScope scope(masm, StackFrame::INTERNAL);
422 __ Push(ebx);
423 __ Push(edx);
424 __ Push(edi);
425 __ CallRuntime(Runtime::kDebugPrepareStepInIfStepping);
426 __ Pop(edx);
427 __ Pop(ebx);
428 __ mov(edi, FieldOperand(ebx, JSGeneratorObject::kFunctionOffset));
429 }
430 __ bind(&skip_flooding);
431
432 // Pop return address.
433 __ PopReturnAddressTo(eax);
434
435 // Push receiver.
436 __ Push(FieldOperand(ebx, JSGeneratorObject::kReceiverOffset));
437
438 // ----------- S t a t e -------------
439 // -- eax : return address
440 // -- ebx : the JSGeneratorObject to resume
441 // -- edx : the resume mode (tagged)
442 // -- edi : generator function
443 // -- esi : generator context
444 // -- esp[0] : generator receiver
445 // -----------------------------------
446
447 // Push holes for arguments to generator function. Since the parser forced
448 // context allocation for any variables in generators, the actual argument
449 // values have already been copied into the context and these dummy values
450 // will never be used.
451 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
452 __ mov(ecx,
453 FieldOperand(ecx, SharedFunctionInfo::kFormalParameterCountOffset));
454 {
455 Label done_loop, loop;
456 __ bind(&loop);
457 __ sub(ecx, Immediate(Smi::FromInt(1)));
458 __ j(carry, &done_loop, Label::kNear);
459 __ PushRoot(Heap::kTheHoleValueRootIndex);
460 __ jmp(&loop);
461 __ bind(&done_loop);
462 }
463
464 // Enter a new JavaScript frame, and initialize its slots as they were when
465 // the generator was suspended.
466 FrameScope scope(masm, StackFrame::MANUAL);
467 __ PushReturnAddressFrom(eax); // Return address.
468 __ Push(ebp); // Caller's frame pointer.
469 __ Move(ebp, esp);
470 __ Push(esi); // Callee's context.
471 __ Push(edi); // Callee's JS Function.
472
473 // Restore the operand stack.
474 __ mov(eax, FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset));
475 {
476 Label done_loop, loop;
477 __ Move(ecx, Smi::FromInt(0));
478 __ bind(&loop);
479 __ cmp(ecx, FieldOperand(eax, FixedArray::kLengthOffset));
480 __ j(equal, &done_loop, Label::kNear);
481 __ Push(FieldOperand(eax, ecx, times_half_pointer_size,
482 FixedArray::kHeaderSize));
483 __ add(ecx, Immediate(Smi::FromInt(1)));
484 __ jmp(&loop);
485 __ bind(&done_loop);
486 }
487
488 // Push resume mode (consumed in continuation).
489 __ Push(edx);
490
491 // Reset operand stack so we don't leak.
492 __ mov(FieldOperand(ebx, JSGeneratorObject::kOperandStackOffset),
493 Immediate(masm->isolate()->factory()->empty_fixed_array()));
494
495 // Restore value.
496 __ mov(eax, FieldOperand(ebx, JSGeneratorObject::kInputOffset));
497
498 // Resume the generator function at the continuation.
499 __ mov(edx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
500 __ mov(edx, FieldOperand(edx, SharedFunctionInfo::kCodeOffset));
501 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset));
502 __ SmiUntag(ecx);
503 __ lea(edx, FieldOperand(edx, ecx, times_1, Code::kHeaderSize));
504 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
505 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
506 __ jmp(edx);
507 }
395 508
396 // Generate code for entering a JS function with the interpreter. 509 // Generate code for entering a JS function with the interpreter.
397 // On entry to the function the receiver and arguments have been pushed on the 510 // On entry to the function the receiver and arguments have been pushed on the
398 // stack left to right. The actual argument count matches the formal parameter 511 // stack left to right. The actual argument count matches the formal parameter
399 // count expected by the function. 512 // count expected by the function.
400 // 513 //
401 // The live registers are: 514 // The live registers are:
402 // o edi: the JS function object being called 515 // o edi: the JS function object being called
403 // o edx: the new target 516 // o edx: the new target
404 // o esi: our context 517 // o esi: our context
(...skipping 2233 matching lines...) Expand 10 before | Expand all | Expand 10 after
2638 // And "return" to the OSR entry point of the function. 2751 // And "return" to the OSR entry point of the function.
2639 __ ret(0); 2752 __ ret(0);
2640 } 2753 }
2641 2754
2642 2755
2643 #undef __ 2756 #undef __
2644 } // namespace internal 2757 } // namespace internal
2645 } // namespace v8 2758 } // namespace v8
2646 2759
2647 #endif // V8_TARGET_ARCH_X87 2760 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/full-codegen/x87/full-codegen-x87.cc ('k') | src/x87/interface-descriptors-x87.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698