OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_PPC | 5 #if V8_TARGET_ARCH_PPC |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/debug/debug.h" | 8 #include "src/debug/debug.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 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 525 |
526 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 526 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
527 bool is_api_function, | 527 bool is_api_function, |
528 bool create_implicit_receiver, | 528 bool create_implicit_receiver, |
529 bool check_derived_construct) { | 529 bool check_derived_construct) { |
530 // ----------- S t a t e ------------- | 530 // ----------- S t a t e ------------- |
531 // -- r3 : number of arguments | 531 // -- r3 : number of arguments |
532 // -- r4 : constructor function | 532 // -- r4 : constructor function |
533 // -- r5 : allocation site or undefined | 533 // -- r5 : allocation site or undefined |
534 // -- r6 : new target | 534 // -- r6 : new target |
| 535 // -- cp : context |
535 // -- lr : return address | 536 // -- lr : return address |
536 // -- sp[...]: constructor arguments | 537 // -- sp[...]: constructor arguments |
537 // ----------------------------------- | 538 // ----------------------------------- |
538 | 539 |
539 Isolate* isolate = masm->isolate(); | 540 Isolate* isolate = masm->isolate(); |
540 | 541 |
541 // Enter a construct frame. | 542 // Enter a construct frame. |
542 { | 543 { |
543 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); | 544 FrameAndConstantPoolScope scope(masm, StackFrame::CONSTRUCT); |
544 | 545 |
545 // Preserve the incoming parameters on the stack. | 546 // Preserve the incoming parameters on the stack. |
546 __ AssertUndefinedOrAllocationSite(r5, r7); | 547 __ AssertUndefinedOrAllocationSite(r5, r7); |
547 | 548 |
548 if (!create_implicit_receiver) { | 549 if (!create_implicit_receiver) { |
549 __ SmiTag(r7, r3, SetRC); | 550 __ SmiTag(r7, r3, SetRC); |
550 __ Push(r5, r7); | 551 __ Push(cp, r5, r7); |
551 __ PushRoot(Heap::kTheHoleValueRootIndex); | 552 __ PushRoot(Heap::kTheHoleValueRootIndex); |
552 } else { | 553 } else { |
553 __ SmiTag(r3); | 554 __ SmiTag(r3); |
554 __ Push(r5, r3); | 555 __ Push(cp, r5, r3); |
555 | 556 |
556 // Allocate the new receiver object. | 557 // Allocate the new receiver object. |
557 __ Push(r4, r6); | 558 __ Push(r4, r6); |
558 FastNewObjectStub stub(masm->isolate()); | 559 FastNewObjectStub stub(masm->isolate()); |
559 __ CallStub(&stub); | 560 __ CallStub(&stub); |
560 __ mr(r7, r3); | 561 __ mr(r7, r3); |
561 __ Pop(r4, r6); | 562 __ Pop(r4, r6); |
562 | 563 |
563 // ----------- S t a t e ------------- | 564 // ----------- S t a t e ------------- |
564 // -- r4: constructor function | 565 // -- r4: constructor function |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 617 |
617 // Store offset of return address for deoptimizer. | 618 // Store offset of return address for deoptimizer. |
618 if (create_implicit_receiver && !is_api_function) { | 619 if (create_implicit_receiver && !is_api_function) { |
619 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 620 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
620 } | 621 } |
621 | 622 |
622 // Restore context from the frame. | 623 // Restore context from the frame. |
623 // r3: result | 624 // r3: result |
624 // sp[0]: receiver | 625 // sp[0]: receiver |
625 // sp[1]: number of arguments (smi-tagged) | 626 // sp[1]: number of arguments (smi-tagged) |
626 __ LoadP(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 627 __ LoadP(cp, MemOperand(fp, ConstructFrameConstants::kContextOffset)); |
627 | 628 |
628 if (create_implicit_receiver) { | 629 if (create_implicit_receiver) { |
629 // If the result is an object (in the ECMA sense), we should get rid | 630 // If the result is an object (in the ECMA sense), we should get rid |
630 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 | 631 // of the receiver and use the result; see ECMA-262 section 13.2.2-7 |
631 // on page 74. | 632 // on page 74. |
632 Label use_receiver, exit; | 633 Label use_receiver, exit; |
633 | 634 |
634 // If the result is a smi, it is *not* an object in the ECMA sense. | 635 // If the result is a smi, it is *not* an object in the ECMA sense. |
635 // r3: result | 636 // r3: result |
636 // sp[0]: receiver | 637 // sp[0]: receiver |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 bool is_construct) { | 748 bool is_construct) { |
748 // Called from Generate_JS_Entry | 749 // Called from Generate_JS_Entry |
749 // r3: new.target | 750 // r3: new.target |
750 // r4: function | 751 // r4: function |
751 // r5: receiver | 752 // r5: receiver |
752 // r6: argc | 753 // r6: argc |
753 // r7: argv | 754 // r7: argv |
754 // r0,r8-r9, cp may be clobbered | 755 // r0,r8-r9, cp may be clobbered |
755 ProfileEntryHookStub::MaybeCallEntryHook(masm); | 756 ProfileEntryHookStub::MaybeCallEntryHook(masm); |
756 | 757 |
757 // Clear the context before we push it when entering the internal frame. | |
758 __ li(cp, Operand::Zero()); | |
759 | |
760 // Enter an internal frame. | 758 // Enter an internal frame. |
761 { | 759 { |
762 FrameScope scope(masm, StackFrame::INTERNAL); | 760 FrameScope scope(masm, StackFrame::INTERNAL); |
763 | 761 |
764 // Setup the context (we need to use the caller context from the isolate). | 762 // Setup the context (we need to use the caller context from the isolate). |
765 ExternalReference context_address(Isolate::kContextAddress, | 763 ExternalReference context_address(Isolate::kContextAddress, |
766 masm->isolate()); | 764 masm->isolate()); |
767 __ mov(cp, Operand(context_address)); | 765 __ mov(cp, Operand(context_address)); |
768 __ LoadP(cp, MemOperand(cp)); | 766 __ LoadP(cp, MemOperand(cp)); |
769 | 767 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
846 // o sp: stack pointer | 844 // o sp: stack pointer |
847 // o lr: return address | 845 // o lr: return address |
848 // | 846 // |
849 // The function builds an interpreter frame. See InterpreterFrameConstants in | 847 // The function builds an interpreter frame. See InterpreterFrameConstants in |
850 // frames.h for its layout. | 848 // frames.h for its layout. |
851 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { | 849 void Builtins::Generate_InterpreterEntryTrampoline(MacroAssembler* masm) { |
852 // Open a frame scope to indicate that there is a frame on the stack. The | 850 // Open a frame scope to indicate that there is a frame on the stack. The |
853 // MANUAL indicates that the scope shouldn't actually generate code to set up | 851 // MANUAL indicates that the scope shouldn't actually generate code to set up |
854 // the frame (that is done below). | 852 // the frame (that is done below). |
855 FrameScope frame_scope(masm, StackFrame::MANUAL); | 853 FrameScope frame_scope(masm, StackFrame::MANUAL); |
856 __ PushFixedFrame(r4); | 854 __ PushStandardFrame(r4); |
857 __ addi(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | |
858 | 855 |
859 // Get the bytecode array from the function object and load the pointer to the | 856 // Get the bytecode array from the function object and load the pointer to the |
860 // first entry into kInterpreterBytecodeRegister. | 857 // first entry into kInterpreterBytecodeRegister. |
861 __ LoadP(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); | 858 __ LoadP(r3, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); |
862 Label array_done; | 859 Label array_done; |
863 Register debug_info = r5; | 860 Register debug_info = r5; |
864 DCHECK(!debug_info.is(r3)); | 861 DCHECK(!debug_info.is(r3)); |
865 __ LoadP(debug_info, | 862 __ LoadP(debug_info, |
866 FieldMemOperand(r3, SharedFunctionInfo::kDebugInfoOffset)); | 863 FieldMemOperand(r3, SharedFunctionInfo::kDebugInfoOffset)); |
867 // Load original bytecode array or the debug copy. | 864 // Load original bytecode array or the debug copy. |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 __ PrepareCallCFunction(2, 0, r5); | 1198 __ PrepareCallCFunction(2, 0, r5); |
1202 __ mov(r4, Operand(ExternalReference::isolate_address(masm->isolate()))); | 1199 __ mov(r4, Operand(ExternalReference::isolate_address(masm->isolate()))); |
1203 __ CallCFunction( | 1200 __ CallCFunction( |
1204 ExternalReference::get_mark_code_as_executed_function(masm->isolate()), | 1201 ExternalReference::get_mark_code_as_executed_function(masm->isolate()), |
1205 2); | 1202 2); |
1206 __ MultiPop(r0.bit() | r3.bit() | r4.bit() | r6.bit() | fp.bit()); | 1203 __ MultiPop(r0.bit() | r3.bit() | r4.bit() | r6.bit() | fp.bit()); |
1207 __ mtlr(r0); | 1204 __ mtlr(r0); |
1208 __ mr(ip, r3); | 1205 __ mr(ip, r3); |
1209 | 1206 |
1210 // Perform prologue operations usually performed by the young code stub. | 1207 // Perform prologue operations usually performed by the young code stub. |
1211 __ PushFixedFrame(r4); | 1208 __ PushStandardFrame(r4); |
1212 __ addi(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); | |
1213 | 1209 |
1214 // Jump to point after the code-age stub. | 1210 // Jump to point after the code-age stub. |
1215 __ addi(r3, ip, Operand(kNoCodeAgeSequenceLength)); | 1211 __ addi(r3, ip, Operand(kNoCodeAgeSequenceLength)); |
1216 __ Jump(r3); | 1212 __ Jump(r3); |
1217 } | 1213 } |
1218 | 1214 |
1219 | 1215 |
1220 void Builtins::Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm) { | 1216 void Builtins::Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm) { |
1221 GenerateMakeCodeYoungAgainCommon(masm); | 1217 GenerateMakeCodeYoungAgainCommon(masm); |
1222 } | 1218 } |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1975 ExternalReference debug_is_active = | 1971 ExternalReference debug_is_active = |
1976 ExternalReference::debug_is_active_address(masm->isolate()); | 1972 ExternalReference::debug_is_active_address(masm->isolate()); |
1977 __ mov(scratch1, Operand(debug_is_active)); | 1973 __ mov(scratch1, Operand(debug_is_active)); |
1978 __ lbz(scratch1, MemOperand(scratch1)); | 1974 __ lbz(scratch1, MemOperand(scratch1)); |
1979 __ cmpi(scratch1, Operand::Zero()); | 1975 __ cmpi(scratch1, Operand::Zero()); |
1980 __ bne(&done); | 1976 __ bne(&done); |
1981 | 1977 |
1982 // Drop possible interpreter handler/stub frame. | 1978 // Drop possible interpreter handler/stub frame. |
1983 { | 1979 { |
1984 Label no_interpreter_frame; | 1980 Label no_interpreter_frame; |
1985 __ LoadP(scratch3, MemOperand(fp, StandardFrameConstants::kMarkerOffset)); | 1981 __ LoadP(scratch3, |
| 1982 MemOperand(fp, CommonFrameConstants::kContextOrFrameTypeOffset)); |
1986 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0); | 1983 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::STUB), r0); |
1987 __ bne(&no_interpreter_frame); | 1984 __ bne(&no_interpreter_frame); |
1988 __ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1985 __ LoadP(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1989 __ bind(&no_interpreter_frame); | 1986 __ bind(&no_interpreter_frame); |
1990 } | 1987 } |
1991 | 1988 |
1992 // Check if next frame is an arguments adaptor frame. | 1989 // Check if next frame is an arguments adaptor frame. |
1993 Register caller_args_count_reg = scratch1; | 1990 Register caller_args_count_reg = scratch1; |
1994 Label no_arguments_adaptor, formal_parameter_count_loaded; | 1991 Label no_arguments_adaptor, formal_parameter_count_loaded; |
1995 __ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); | 1992 __ LoadP(scratch2, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
1996 __ LoadP(scratch3, | 1993 __ LoadP( |
1997 MemOperand(scratch2, StandardFrameConstants::kContextOffset)); | 1994 scratch3, |
| 1995 MemOperand(scratch2, CommonFrameConstants::kContextOrFrameTypeOffset)); |
1998 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); | 1996 __ CmpSmiLiteral(scratch3, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR), r0); |
1999 __ bne(&no_arguments_adaptor); | 1997 __ bne(&no_arguments_adaptor); |
2000 | 1998 |
2001 // Drop current frame and load arguments count from arguments adaptor frame. | 1999 // Drop current frame and load arguments count from arguments adaptor frame. |
2002 __ mr(fp, scratch2); | 2000 __ mr(fp, scratch2); |
2003 __ LoadP(caller_args_count_reg, | 2001 __ LoadP(caller_args_count_reg, |
2004 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); | 2002 MemOperand(fp, ArgumentsAdaptorFrameConstants::kLengthOffset)); |
2005 __ SmiUntag(caller_args_count_reg); | 2003 __ SmiUntag(caller_args_count_reg); |
2006 __ b(&formal_parameter_count_loaded); | 2004 __ b(&formal_parameter_count_loaded); |
2007 | 2005 |
2008 __ bind(&no_arguments_adaptor); | 2006 __ bind(&no_arguments_adaptor); |
2009 // Load caller's formal parameter count | 2007 // Load caller's formal parameter count |
2010 __ LoadP(scratch1, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 2008 __ LoadP(scratch1, |
| 2009 MemOperand(fp, ArgumentsAdaptorFrameConstants::kFunctionOffset)); |
2011 __ LoadP(scratch1, | 2010 __ LoadP(scratch1, |
2012 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); | 2011 FieldMemOperand(scratch1, JSFunction::kSharedFunctionInfoOffset)); |
2013 __ LoadWordArith( | 2012 __ LoadWordArith( |
2014 caller_args_count_reg, | 2013 caller_args_count_reg, |
2015 FieldMemOperand(scratch1, | 2014 FieldMemOperand(scratch1, |
2016 SharedFunctionInfo::kFormalParameterCountOffset)); | 2015 SharedFunctionInfo::kFormalParameterCountOffset)); |
2017 #if !V8_TARGET_ARCH_PPC64 | 2016 #if !V8_TARGET_ARCH_PPC64 |
2018 __ SmiUntag(caller_args_count_reg); | 2017 __ SmiUntag(caller_args_count_reg); |
2019 #endif | 2018 #endif |
2020 | 2019 |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2597 __ bkpt(0); | 2596 __ bkpt(0); |
2598 } | 2597 } |
2599 } | 2598 } |
2600 | 2599 |
2601 | 2600 |
2602 #undef __ | 2601 #undef __ |
2603 } // namespace internal | 2602 } // namespace internal |
2604 } // namespace v8 | 2603 } // namespace v8 |
2605 | 2604 |
2606 #endif // V8_TARGET_ARCH_PPC | 2605 #endif // V8_TARGET_ARCH_PPC |
OLD | NEW |