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

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

Issue 1998153002: X87: [Interpreter] Support compiling for baseline on return from interpreted function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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 | « no previous file | no next file » | 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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset)); 514 __ mov(ecx, FieldOperand(ebx, JSGeneratorObject::kContinuationOffset));
515 __ SmiUntag(ecx); 515 __ SmiUntag(ecx);
516 __ lea(edx, FieldOperand(edx, ecx, times_1, Code::kHeaderSize)); 516 __ lea(edx, FieldOperand(edx, ecx, times_1, Code::kHeaderSize));
517 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset), 517 __ mov(FieldOperand(ebx, JSGeneratorObject::kContinuationOffset),
518 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting))); 518 Immediate(Smi::FromInt(JSGeneratorObject::kGeneratorExecuting)));
519 __ mov(eax, ebx); // Continuation expects generator object in eax. 519 __ mov(eax, ebx); // Continuation expects generator object in eax.
520 __ jmp(edx); 520 __ jmp(edx);
521 } 521 }
522 } 522 }
523 523
524 static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch1,
525 Register scratch2) {
526 Register args_count = scratch1;
527 Register return_pc = scratch2;
528
529 // Get the arguments + reciever count.
530 __ mov(args_count,
531 Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp));
532 __ mov(args_count,
533 FieldOperand(args_count, BytecodeArray::kParameterSizeOffset));
534
535 // Leave the frame (also dropping the register file).
536 __ leave();
537
538 // Drop receiver + arguments.
539 __ pop(return_pc);
540 __ add(esp, args_count);
541 __ push(return_pc);
542 }
543
524 // Generate code for entering a JS function with the interpreter. 544 // Generate code for entering a JS function with the interpreter.
525 // On entry to the function the receiver and arguments have been pushed on the 545 // On entry to the function the receiver and arguments have been pushed on the
526 // stack left to right. The actual argument count matches the formal parameter 546 // stack left to right. The actual argument count matches the formal parameter
527 // count expected by the function. 547 // count expected by the function.
528 // 548 //
529 // The live registers are: 549 // The live registers are:
530 // o edi: the JS function object being called 550 // o edi: the JS function object being called
531 // o edx: the new target 551 // o edx: the new target
532 // o esi: our context 552 // o esi: our context
533 // o ebp: the caller's frame pointer 553 // o ebp: the caller's frame pointer
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 637
618 // Dispatch to the first bytecode handler for the function. 638 // Dispatch to the first bytecode handler for the function.
619 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister, 639 __ movzx_b(ebx, Operand(kInterpreterBytecodeArrayRegister,
620 kInterpreterBytecodeOffsetRegister, times_1, 0)); 640 kInterpreterBytecodeOffsetRegister, times_1, 0));
621 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx, 641 __ mov(ebx, Operand(kInterpreterDispatchTableRegister, ebx,
622 times_pointer_size, 0)); 642 times_pointer_size, 0));
623 __ call(ebx); 643 __ call(ebx);
624 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset()); 644 masm->isolate()->heap()->SetInterpreterEntryReturnPCOffset(masm->pc_offset());
625 645
626 // The return value is in eax. 646 // The return value is in eax.
627 647 LeaveInterpreterFrame(masm, ebx, ecx);
628 // Get the arguments + reciever count.
629 __ mov(ebx, Operand(ebp, InterpreterFrameConstants::kBytecodeArrayFromFp));
630 __ mov(ebx, FieldOperand(ebx, BytecodeArray::kParameterSizeOffset));
631
632 // Leave the frame (also dropping the register file).
633 __ leave();
634
635 // Drop receiver + arguments and return.
636 __ pop(ecx);
637 __ add(esp, ebx);
638 __ push(ecx);
639 __ ret(0); 648 __ ret(0);
640 649
641 // Load debug copy of the bytecode array. 650 // Load debug copy of the bytecode array.
642 __ bind(&load_debug_bytecode_array); 651 __ bind(&load_debug_bytecode_array);
643 Register debug_info = kInterpreterBytecodeArrayRegister; 652 Register debug_info = kInterpreterBytecodeArrayRegister;
644 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset)); 653 __ mov(debug_info, FieldOperand(eax, SharedFunctionInfo::kDebugInfoOffset));
645 __ mov(kInterpreterBytecodeArrayRegister, 654 __ mov(kInterpreterBytecodeArrayRegister,
646 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex)); 655 FieldOperand(debug_info, DebugInfo::kAbstractCodeIndex));
647 __ jmp(&bytecode_array_loaded); 656 __ jmp(&bytecode_array_loaded);
648 657
649 // If the bytecode array is no longer present, then the underlying function 658 // If the bytecode array is no longer present, then the underlying function
650 // has been switched to a different kind of code and we heal the closure by 659 // has been switched to a different kind of code and we heal the closure by
651 // switching the code entry field over to the new code object as well. 660 // switching the code entry field over to the new code object as well.
652 __ bind(&bytecode_array_not_present); 661 __ bind(&bytecode_array_not_present);
653 __ pop(edx); // Callee's new target. 662 __ pop(edx); // Callee's new target.
654 __ pop(edi); // Callee's JS function. 663 __ pop(edi); // Callee's JS function.
655 __ pop(esi); // Callee's context. 664 __ pop(esi); // Callee's context.
656 __ leave(); // Leave the frame so we can tail call. 665 __ leave(); // Leave the frame so we can tail call.
657 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); 666 __ mov(ecx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset));
658 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kCodeOffset)); 667 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kCodeOffset));
659 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize)); 668 __ lea(ecx, FieldOperand(ecx, Code::kHeaderSize));
660 __ mov(FieldOperand(edi, JSFunction::kCodeEntryOffset), ecx); 669 __ mov(FieldOperand(edi, JSFunction::kCodeEntryOffset), ecx);
661 __ RecordWriteCodeEntryField(edi, ecx, ebx); 670 __ RecordWriteCodeEntryField(edi, ecx, ebx);
662 __ jmp(ecx); 671 __ jmp(ecx);
663 } 672 }
664 673
674 void Builtins::Generate_InterpreterMarkBaselineOnReturn(MacroAssembler* masm) {
675 // Save the function and context for call to CompileBaseline.
676 __ mov(edi, Operand(ebp, StandardFrameConstants::kFunctionOffset));
677 __ mov(kContextRegister,
678 Operand(ebp, StandardFrameConstants::kContextOffset));
679
680 // Leave the frame before recompiling for baseline so that we don't count as
681 // an activation on the stack.
682 LeaveInterpreterFrame(masm, ebx, ecx);
683
684 {
685 FrameScope frame_scope(masm, StackFrame::INTERNAL);
686 // Push return value.
687 __ push(eax);
688
689 // Push function as argument and compile for baseline.
690 __ push(edi);
691 __ CallRuntime(Runtime::kCompileBaseline);
692
693 // Restore return value.
694 __ pop(eax);
695 }
696 __ ret(0);
697 }
698
665 static void Generate_InterpreterPushArgs(MacroAssembler* masm, 699 static void Generate_InterpreterPushArgs(MacroAssembler* masm,
666 Register array_limit) { 700 Register array_limit) {
667 // ----------- S t a t e ------------- 701 // ----------- S t a t e -------------
668 // -- ebx : Pointer to the last argument in the args array. 702 // -- ebx : Pointer to the last argument in the args array.
669 // -- array_limit : Pointer to one before the first argument in the 703 // -- array_limit : Pointer to one before the first argument in the
670 // args array. 704 // args array.
671 // ----------------------------------- 705 // -----------------------------------
672 Label loop_header, loop_check; 706 Label loop_header, loop_check;
673 __ jmp(&loop_check); 707 __ jmp(&loop_check);
674 __ bind(&loop_header); 708 __ bind(&loop_header);
(...skipping 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 // And "return" to the OSR entry point of the function. 2887 // And "return" to the OSR entry point of the function.
2854 __ ret(0); 2888 __ ret(0);
2855 } 2889 }
2856 2890
2857 2891
2858 #undef __ 2892 #undef __
2859 } // namespace internal 2893 } // namespace internal
2860 } // namespace v8 2894 } // namespace v8
2861 2895
2862 #endif // V8_TARGET_ARCH_X87 2896 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698