OLD | NEW |
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_MIPS64 | 5 #if V8_TARGET_ARCH_MIPS64 |
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" |
11 #include "src/runtime/runtime.h" | 11 #include "src/runtime/runtime.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 | |
17 #define __ ACCESS_MASM(masm) | 16 #define __ ACCESS_MASM(masm) |
18 | 17 |
19 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, | 18 void Builtins::Generate_Adaptor(MacroAssembler* masm, CFunctionId id, |
20 ExitFrameType exit_frame_type) { | 19 ExitFrameType exit_frame_type) { |
21 // ----------- S t a t e ------------- | 20 // ----------- S t a t e ------------- |
22 // -- a0 : number of arguments excluding receiver | 21 // -- a0 : number of arguments excluding receiver |
23 // -- a1 : target | 22 // -- a1 : target |
24 // -- a3 : new.target | 23 // -- a3 : new.target |
25 // -- sp[0] : last argument | 24 // -- sp[0] : last argument |
26 // -- ... | 25 // -- ... |
(...skipping 15 matching lines...) Expand all Loading... |
42 | 41 |
43 // Insert extra arguments. | 42 // Insert extra arguments. |
44 __ SmiTag(a0); | 43 __ SmiTag(a0); |
45 __ Push(a0, a1, a3); | 44 __ Push(a0, a1, a3); |
46 __ SmiUntag(a0); | 45 __ SmiUntag(a0); |
47 | 46 |
48 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), PROTECT, | 47 __ JumpToExternalReference(ExternalReference(id, masm->isolate()), PROTECT, |
49 exit_frame_type == BUILTIN_EXIT); | 48 exit_frame_type == BUILTIN_EXIT); |
50 } | 49 } |
51 | 50 |
52 | |
53 // Load the built-in InternalArray function from the current context. | 51 // Load the built-in InternalArray function from the current context. |
54 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, | 52 static void GenerateLoadInternalArrayFunction(MacroAssembler* masm, |
55 Register result) { | 53 Register result) { |
56 // Load the InternalArray function from the native context. | 54 // Load the InternalArray function from the native context. |
57 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 55 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); |
58 } | 56 } |
59 | 57 |
60 | |
61 // Load the built-in Array function from the current context. | 58 // Load the built-in Array function from the current context. |
62 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { | 59 static void GenerateLoadArrayFunction(MacroAssembler* masm, Register result) { |
63 // Load the Array function from the native context. | 60 // Load the Array function from the native context. |
64 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); | 61 __ LoadNativeContextSlot(Context::ARRAY_FUNCTION_INDEX, result); |
65 } | 62 } |
66 | 63 |
67 | |
68 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 64 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
69 // ----------- S t a t e ------------- | 65 // ----------- S t a t e ------------- |
70 // -- a0 : number of arguments | 66 // -- a0 : number of arguments |
71 // -- ra : return address | 67 // -- ra : return address |
72 // -- sp[...]: constructor arguments | 68 // -- sp[...]: constructor arguments |
73 // ----------------------------------- | 69 // ----------------------------------- |
74 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; | 70 Label generic_array_code, one_or_more_arguments, two_or_more_arguments; |
75 | 71 |
76 // Get the InternalArray function. | 72 // Get the InternalArray function. |
77 GenerateLoadInternalArrayFunction(masm, a1); | 73 GenerateLoadInternalArrayFunction(masm, a1); |
78 | 74 |
79 if (FLAG_debug_code) { | 75 if (FLAG_debug_code) { |
80 // Initial map for the builtin InternalArray functions should be maps. | 76 // Initial map for the builtin InternalArray functions should be maps. |
81 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); | 77 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
82 __ SmiTst(a2, a4); | 78 __ SmiTst(a2, a4); |
83 __ Assert(ne, kUnexpectedInitialMapForInternalArrayFunction, | 79 __ Assert(ne, kUnexpectedInitialMapForInternalArrayFunction, a4, |
84 a4, Operand(zero_reg)); | 80 Operand(zero_reg)); |
85 __ GetObjectType(a2, a3, a4); | 81 __ GetObjectType(a2, a3, a4); |
86 __ Assert(eq, kUnexpectedInitialMapForInternalArrayFunction, | 82 __ Assert(eq, kUnexpectedInitialMapForInternalArrayFunction, a4, |
87 a4, Operand(MAP_TYPE)); | 83 Operand(MAP_TYPE)); |
88 } | 84 } |
89 | 85 |
90 // Run the native code for the InternalArray function called as a normal | 86 // Run the native code for the InternalArray function called as a normal |
91 // function. | 87 // function. |
92 // Tail call a stub. | 88 // Tail call a stub. |
93 InternalArrayConstructorStub stub(masm->isolate()); | 89 InternalArrayConstructorStub stub(masm->isolate()); |
94 __ TailCallStub(&stub); | 90 __ TailCallStub(&stub); |
95 } | 91 } |
96 | 92 |
97 | |
98 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { | 93 void Builtins::Generate_ArrayCode(MacroAssembler* masm) { |
99 // ----------- S t a t e ------------- | 94 // ----------- S t a t e ------------- |
100 // -- a0 : number of arguments | 95 // -- a0 : number of arguments |
101 // -- ra : return address | 96 // -- ra : return address |
102 // -- sp[...]: constructor arguments | 97 // -- sp[...]: constructor arguments |
103 // ----------------------------------- | 98 // ----------------------------------- |
104 Label generic_array_code; | 99 Label generic_array_code; |
105 | 100 |
106 // Get the Array function. | 101 // Get the Array function. |
107 GenerateLoadArrayFunction(masm, a1); | 102 GenerateLoadArrayFunction(masm, a1); |
108 | 103 |
109 if (FLAG_debug_code) { | 104 if (FLAG_debug_code) { |
110 // Initial map for the builtin Array functions should be maps. | 105 // Initial map for the builtin Array functions should be maps. |
111 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); | 106 __ ld(a2, FieldMemOperand(a1, JSFunction::kPrototypeOrInitialMapOffset)); |
112 __ SmiTst(a2, a4); | 107 __ SmiTst(a2, a4); |
113 __ Assert(ne, kUnexpectedInitialMapForArrayFunction1, | 108 __ Assert(ne, kUnexpectedInitialMapForArrayFunction1, a4, |
114 a4, Operand(zero_reg)); | 109 Operand(zero_reg)); |
115 __ GetObjectType(a2, a3, a4); | 110 __ GetObjectType(a2, a3, a4); |
116 __ Assert(eq, kUnexpectedInitialMapForArrayFunction2, | 111 __ Assert(eq, kUnexpectedInitialMapForArrayFunction2, a4, |
117 a4, Operand(MAP_TYPE)); | 112 Operand(MAP_TYPE)); |
118 } | 113 } |
119 | 114 |
120 // Run the native code for the Array function called as a normal function. | 115 // Run the native code for the Array function called as a normal function. |
121 // Tail call a stub. | 116 // Tail call a stub. |
122 __ mov(a3, a1); | 117 __ mov(a3, a1); |
123 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 118 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
124 ArrayConstructorStub stub(masm->isolate()); | 119 ArrayConstructorStub stub(masm->isolate()); |
125 __ TailCallStub(&stub); | 120 __ TailCallStub(&stub); |
126 } | 121 } |
127 | 122 |
128 | |
129 // static | 123 // static |
130 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { | 124 void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) { |
131 // ----------- S t a t e ------------- | 125 // ----------- S t a t e ------------- |
132 // -- a0 : number of arguments | 126 // -- a0 : number of arguments |
133 // -- a1 : function | 127 // -- a1 : function |
134 // -- cp : context | 128 // -- cp : context |
135 // -- ra : return address | 129 // -- ra : return address |
136 // -- sp[(argc - n - 1) * 8] : arg[n] (zero-based) | 130 // -- sp[(argc - n - 1) * 8] : arg[n] (zero-based) |
137 // -- sp[argc * 8] : receiver | 131 // -- sp[argc * 8] : receiver |
138 // ----------------------------------- | 132 // ----------------------------------- |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 __ Dlsa(sp, sp, t0, kPointerSizeLog2); | 261 __ Dlsa(sp, sp, t0, kPointerSizeLog2); |
268 __ DropAndRet(1); | 262 __ DropAndRet(1); |
269 } | 263 } |
270 | 264 |
271 // 2b. No arguments, return +0. | 265 // 2b. No arguments, return +0. |
272 __ bind(&no_arguments); | 266 __ bind(&no_arguments); |
273 __ Move(v0, Smi::FromInt(0)); | 267 __ Move(v0, Smi::FromInt(0)); |
274 __ DropAndRet(1); | 268 __ DropAndRet(1); |
275 } | 269 } |
276 | 270 |
277 | |
278 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { | 271 void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) { |
279 // ----------- S t a t e ------------- | 272 // ----------- S t a t e ------------- |
280 // -- a0 : number of arguments | 273 // -- a0 : number of arguments |
281 // -- a1 : constructor function | 274 // -- a1 : constructor function |
282 // -- a3 : new target | 275 // -- a3 : new target |
283 // -- cp : context | 276 // -- cp : context |
284 // -- ra : return address | 277 // -- ra : return address |
285 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 278 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
286 // -- sp[argc * 8] : receiver | 279 // -- sp[argc * 8] : receiver |
287 // ----------------------------------- | 280 // ----------------------------------- |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } | 340 } |
348 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); | 341 __ sd(a0, FieldMemOperand(v0, JSValue::kValueOffset)); |
349 | 342 |
350 __ bind(&drop_frame_and_ret); | 343 __ bind(&drop_frame_and_ret); |
351 { | 344 { |
352 __ Dlsa(sp, sp, t0, kPointerSizeLog2); | 345 __ Dlsa(sp, sp, t0, kPointerSizeLog2); |
353 __ DropAndRet(1); | 346 __ DropAndRet(1); |
354 } | 347 } |
355 } | 348 } |
356 | 349 |
357 | |
358 // static | 350 // static |
359 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { | 351 void Builtins::Generate_StringConstructor(MacroAssembler* masm) { |
360 // ----------- S t a t e ------------- | 352 // ----------- S t a t e ------------- |
361 // -- a0 : number of arguments | 353 // -- a0 : number of arguments |
362 // -- a1 : constructor function | 354 // -- a1 : constructor function |
363 // -- cp : context | 355 // -- cp : context |
364 // -- ra : return address | 356 // -- ra : return address |
365 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 357 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
366 // -- sp[argc * 8] : receiver | 358 // -- sp[argc * 8] : receiver |
367 // ----------------------------------- | 359 // ----------------------------------- |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 __ TailCallRuntime(Runtime::kSymbolDescriptiveString); | 412 __ TailCallRuntime(Runtime::kSymbolDescriptiveString); |
421 } | 413 } |
422 | 414 |
423 __ bind(&drop_frame_and_ret); | 415 __ bind(&drop_frame_and_ret); |
424 { | 416 { |
425 __ Dlsa(sp, sp, t0, kPointerSizeLog2); | 417 __ Dlsa(sp, sp, t0, kPointerSizeLog2); |
426 __ DropAndRet(1); | 418 __ DropAndRet(1); |
427 } | 419 } |
428 } | 420 } |
429 | 421 |
430 | |
431 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 422 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
432 // ----------- S t a t e ------------- | 423 // ----------- S t a t e ------------- |
433 // -- a0 : number of arguments | 424 // -- a0 : number of arguments |
434 // -- a1 : constructor function | 425 // -- a1 : constructor function |
435 // -- a3 : new target | 426 // -- a3 : new target |
436 // -- cp : context | 427 // -- cp : context |
437 // -- ra : return address | 428 // -- ra : return address |
438 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) | 429 // -- sp[(argc - n - 1) * 8] : arg[n] (zero based) |
439 // -- sp[argc * 8] : receiver | 430 // -- sp[argc * 8] : receiver |
440 // ----------------------------------- | 431 // ----------------------------------- |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 __ CallRuntime(function_id, 1); | 525 __ CallRuntime(function_id, 1); |
535 // Restore target function and new target. | 526 // Restore target function and new target. |
536 __ Pop(a0, a1, a3); | 527 __ Pop(a0, a1, a3); |
537 __ SmiUntag(a0); | 528 __ SmiUntag(a0); |
538 } | 529 } |
539 | 530 |
540 __ Daddu(at, v0, Operand(Code::kHeaderSize - kHeapObjectTag)); | 531 __ Daddu(at, v0, Operand(Code::kHeaderSize - kHeapObjectTag)); |
541 __ Jump(at); | 532 __ Jump(at); |
542 } | 533 } |
543 | 534 |
544 | |
545 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { | 535 void Builtins::Generate_InOptimizationQueue(MacroAssembler* masm) { |
546 // Checking whether the queued function is ready for install is optional, | 536 // Checking whether the queued function is ready for install is optional, |
547 // since we come across interrupts and stack checks elsewhere. However, | 537 // since we come across interrupts and stack checks elsewhere. However, |
548 // not checking may delay installing ready functions, and always checking | 538 // not checking may delay installing ready functions, and always checking |
549 // would be quite expensive. A good compromise is to first check against | 539 // would be quite expensive. A good compromise is to first check against |
550 // stack limit as a cue for an interrupt signal. | 540 // stack limit as a cue for an interrupt signal. |
551 Label ok; | 541 Label ok; |
552 __ LoadRoot(a4, Heap::kStackLimitRootIndex); | 542 __ LoadRoot(a4, Heap::kStackLimitRootIndex); |
553 __ Branch(&ok, hs, sp, Operand(a4)); | 543 __ Branch(&ok, hs, sp, Operand(a4)); |
554 | 544 |
555 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); | 545 GenerateTailCallToReturnedCode(masm, Runtime::kTryInstallOptimizedCode); |
556 | 546 |
557 __ bind(&ok); | 547 __ bind(&ok); |
558 GenerateTailCallToSharedCode(masm); | 548 GenerateTailCallToSharedCode(masm); |
559 } | 549 } |
560 | 550 |
561 | |
562 static void Generate_JSConstructStubHelper(MacroAssembler* masm, | 551 static void Generate_JSConstructStubHelper(MacroAssembler* masm, |
563 bool is_api_function, | 552 bool is_api_function, |
564 bool create_implicit_receiver, | 553 bool create_implicit_receiver, |
565 bool check_derived_construct) { | 554 bool check_derived_construct) { |
566 // ----------- S t a t e ------------- | 555 // ----------- S t a t e ------------- |
567 // -- a0 : number of arguments | 556 // -- a0 : number of arguments |
568 // -- a1 : constructor function | 557 // -- a1 : constructor function |
569 // -- a2 : allocation site or undefined | 558 // -- a2 : allocation site or undefined |
570 // -- a3 : new target | 559 // -- a3 : new target |
571 // -- cp : context | 560 // -- cp : context |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 | 688 |
700 __ SmiScale(a4, a1, kPointerSizeLog2); | 689 __ SmiScale(a4, a1, kPointerSizeLog2); |
701 __ Daddu(sp, sp, a4); | 690 __ Daddu(sp, sp, a4); |
702 __ Daddu(sp, sp, kPointerSize); | 691 __ Daddu(sp, sp, kPointerSize); |
703 if (create_implicit_receiver) { | 692 if (create_implicit_receiver) { |
704 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); | 693 __ IncrementCounter(isolate->counters()->constructed_objects(), 1, a1, a2); |
705 } | 694 } |
706 __ Ret(); | 695 __ Ret(); |
707 } | 696 } |
708 | 697 |
709 | |
710 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { | 698 void Builtins::Generate_JSConstructStubGeneric(MacroAssembler* masm) { |
711 Generate_JSConstructStubHelper(masm, false, true, false); | 699 Generate_JSConstructStubHelper(masm, false, true, false); |
712 } | 700 } |
713 | 701 |
714 | |
715 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { | 702 void Builtins::Generate_JSConstructStubApi(MacroAssembler* masm) { |
716 Generate_JSConstructStubHelper(masm, true, false, false); | 703 Generate_JSConstructStubHelper(masm, true, false, false); |
717 } | 704 } |
718 | 705 |
719 | |
720 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 706 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
721 Generate_JSConstructStubHelper(masm, false, false, false); | 707 Generate_JSConstructStubHelper(masm, false, false, false); |
722 } | 708 } |
723 | 709 |
724 | |
725 void Builtins::Generate_JSBuiltinsConstructStubForDerived( | 710 void Builtins::Generate_JSBuiltinsConstructStubForDerived( |
726 MacroAssembler* masm) { | 711 MacroAssembler* masm) { |
727 Generate_JSConstructStubHelper(masm, false, false, true); | 712 Generate_JSConstructStubHelper(masm, false, false, true); |
728 } | 713 } |
729 | 714 |
730 // static | 715 // static |
731 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { | 716 void Builtins::Generate_ResumeGeneratorTrampoline(MacroAssembler* masm) { |
732 // ----------- S t a t e ------------- | 717 // ----------- S t a t e ------------- |
733 // -- v0 : the value to pass to the generator | 718 // -- v0 : the value to pass to the generator |
734 // -- a1 : the JSGeneratorObject to resume | 719 // -- a1 : the JSGeneratorObject to resume |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 Label old_generator; | 786 Label old_generator; |
802 __ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); | 787 __ ld(a3, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); |
803 __ ld(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); | 788 __ ld(a3, FieldMemOperand(a3, SharedFunctionInfo::kFunctionDataOffset)); |
804 __ GetObjectType(a3, a3, a3); | 789 __ GetObjectType(a3, a3, a3); |
805 __ Branch(&old_generator, ne, a3, Operand(BYTECODE_ARRAY_TYPE)); | 790 __ Branch(&old_generator, ne, a3, Operand(BYTECODE_ARRAY_TYPE)); |
806 | 791 |
807 // New-style (ignition/turbofan) generator object. | 792 // New-style (ignition/turbofan) generator object. |
808 { | 793 { |
809 __ ld(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); | 794 __ ld(a0, FieldMemOperand(a4, JSFunction::kSharedFunctionInfoOffset)); |
810 __ lw(a0, | 795 __ lw(a0, |
811 FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); | 796 FieldMemOperand(a0, SharedFunctionInfo::kFormalParameterCountOffset)); |
812 // We abuse new.target both to indicate that this is a resume call and to | 797 // We abuse new.target both to indicate that this is a resume call and to |
813 // pass in the generator object. In ordinary calls, new.target is always | 798 // pass in the generator object. In ordinary calls, new.target is always |
814 // undefined because generator functions are non-constructable. | 799 // undefined because generator functions are non-constructable. |
815 __ Move(a3, a1); | 800 __ Move(a3, a1); |
816 __ Move(a1, a4); | 801 __ Move(a1, a4); |
817 __ ld(a2, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 802 __ ld(a2, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
818 __ Jump(a2); | 803 __ Jump(a2); |
819 } | 804 } |
820 | 805 |
821 // Old-style (full-codegen) generator object | 806 // Old-style (full-codegen) generator object |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 __ Branch(USE_DELAY_SLOT, &stepping_prepared); | 867 __ Branch(USE_DELAY_SLOT, &stepping_prepared); |
883 __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); | 868 __ ld(a4, FieldMemOperand(a1, JSGeneratorObject::kFunctionOffset)); |
884 } | 869 } |
885 | 870 |
886 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 871 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
887 FrameScope scope(masm, StackFrame::INTERNAL); | 872 FrameScope scope(masm, StackFrame::INTERNAL); |
888 __ Push(a1); | 873 __ Push(a1); |
889 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); | 874 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
890 } | 875 } |
891 | 876 |
892 | |
893 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; | 877 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; |
894 | 878 |
895 | |
896 // Clobbers a2; preserves all other registers. | 879 // Clobbers a2; preserves all other registers. |
897 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, | 880 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, |
898 IsTagged argc_is_tagged) { | 881 IsTagged argc_is_tagged) { |
899 // Check the stack for overflow. We are not trying to catch | 882 // Check the stack for overflow. We are not trying to catch |
900 // interruptions (e.g. debug break and preemption) here, so the "real stack | 883 // interruptions (e.g. debug break and preemption) here, so the "real stack |
901 // limit" is checked. | 884 // limit" is checked. |
902 Label okay; | 885 Label okay; |
903 __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); | 886 __ LoadRoot(a2, Heap::kRealStackLimitRootIndex); |
904 // Make a2 the space we have left. The stack might already be overflowed | 887 // Make a2 the space we have left. The stack might already be overflowed |
905 // here which will cause r2 to become negative. | 888 // here which will cause r2 to become negative. |
906 __ dsubu(a2, sp, a2); | 889 __ dsubu(a2, sp, a2); |
907 // Check if the arguments will overflow the stack. | 890 // Check if the arguments will overflow the stack. |
908 if (argc_is_tagged == kArgcIsSmiTagged) { | 891 if (argc_is_tagged == kArgcIsSmiTagged) { |
909 __ SmiScale(a7, v0, kPointerSizeLog2); | 892 __ SmiScale(a7, v0, kPointerSizeLog2); |
910 } else { | 893 } else { |
911 DCHECK(argc_is_tagged == kArgcIsUntaggedInt); | 894 DCHECK(argc_is_tagged == kArgcIsUntaggedInt); |
912 __ dsll(a7, argc, kPointerSizeLog2); | 895 __ dsll(a7, argc, kPointerSizeLog2); |
913 } | 896 } |
914 __ Branch(&okay, gt, a2, Operand(a7)); // Signed comparison. | 897 __ Branch(&okay, gt, a2, Operand(a7)); // Signed comparison. |
915 | 898 |
916 // Out of stack space. | 899 // Out of stack space. |
917 __ CallRuntime(Runtime::kThrowStackOverflow); | 900 __ CallRuntime(Runtime::kThrowStackOverflow); |
918 | 901 |
919 __ bind(&okay); | 902 __ bind(&okay); |
920 } | 903 } |
921 | 904 |
922 | |
923 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 905 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
924 bool is_construct) { | 906 bool is_construct) { |
925 // Called from JSEntryStub::GenerateBody | 907 // Called from JSEntryStub::GenerateBody |
926 | 908 |
927 // ----------- S t a t e ------------- | 909 // ----------- S t a t e ------------- |
928 // -- a0: new.target | 910 // -- a0: new.target |
929 // -- a1: function | 911 // -- a1: function |
930 // -- a2: receiver_pointer | 912 // -- a2: receiver_pointer |
931 // -- a3: argc | 913 // -- a3: argc |
932 // -- s0: argv | 914 // -- s0: argv |
(...skipping 19 matching lines...) Expand all Loading... |
952 | 934 |
953 // Remember new.target. | 935 // Remember new.target. |
954 __ mov(a5, a0); | 936 __ mov(a5, a0); |
955 | 937 |
956 // Copy arguments to the stack in a loop. | 938 // Copy arguments to the stack in a loop. |
957 // a3: argc | 939 // a3: argc |
958 // s0: argv, i.e. points to first arg | 940 // s0: argv, i.e. points to first arg |
959 Label loop, entry; | 941 Label loop, entry; |
960 __ Dlsa(a6, s0, a3, kPointerSizeLog2); | 942 __ Dlsa(a6, s0, a3, kPointerSizeLog2); |
961 __ b(&entry); | 943 __ b(&entry); |
962 __ nop(); // Branch delay slot nop. | 944 __ nop(); // Branch delay slot nop. |
963 // a6 points past last arg. | 945 // a6 points past last arg. |
964 __ bind(&loop); | 946 __ bind(&loop); |
965 __ ld(a4, MemOperand(s0)); // Read next parameter. | 947 __ ld(a4, MemOperand(s0)); // Read next parameter. |
966 __ daddiu(s0, s0, kPointerSize); | 948 __ daddiu(s0, s0, kPointerSize); |
967 __ ld(a4, MemOperand(a4)); // Dereference handle. | 949 __ ld(a4, MemOperand(a4)); // Dereference handle. |
968 __ push(a4); // Push parameter. | 950 __ push(a4); // Push parameter. |
969 __ bind(&entry); | 951 __ bind(&entry); |
970 __ Branch(&loop, ne, s0, Operand(a6)); | 952 __ Branch(&loop, ne, s0, Operand(a6)); |
971 | 953 |
972 // Setup new.target and argc. | 954 // Setup new.target and argc. |
973 __ mov(a0, a3); | 955 __ mov(a0, a3); |
974 __ mov(a3, a5); | 956 __ mov(a3, a5); |
975 | 957 |
976 // Initialize all JavaScript callee-saved registers, since they will be seen | 958 // Initialize all JavaScript callee-saved registers, since they will be seen |
977 // by the garbage collector as part of handlers. | 959 // by the garbage collector as part of handlers. |
978 __ LoadRoot(a4, Heap::kUndefinedValueRootIndex); | 960 __ LoadRoot(a4, Heap::kUndefinedValueRootIndex); |
979 __ mov(s1, a4); | 961 __ mov(s1, a4); |
980 __ mov(s2, a4); | 962 __ mov(s2, a4); |
981 __ mov(s3, a4); | 963 __ mov(s3, a4); |
982 __ mov(s4, a4); | 964 __ mov(s4, a4); |
983 __ mov(s5, a4); | 965 __ mov(s5, a4); |
984 // s6 holds the root address. Do not clobber. | 966 // s6 holds the root address. Do not clobber. |
985 // s7 is cp. Do not init. | 967 // s7 is cp. Do not init. |
986 | 968 |
987 // Invoke the code. | 969 // Invoke the code. |
988 Handle<Code> builtin = is_construct | 970 Handle<Code> builtin = is_construct |
989 ? masm->isolate()->builtins()->Construct() | 971 ? masm->isolate()->builtins()->Construct() |
990 : masm->isolate()->builtins()->Call(); | 972 : masm->isolate()->builtins()->Call(); |
991 __ Call(builtin, RelocInfo::CODE_TARGET); | 973 __ Call(builtin, RelocInfo::CODE_TARGET); |
992 | 974 |
993 // Leave internal frame. | 975 // Leave internal frame. |
994 } | 976 } |
995 __ Jump(ra); | 977 __ Jump(ra); |
996 } | 978 } |
997 | 979 |
998 | |
999 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 980 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
1000 Generate_JSEntryTrampolineHelper(masm, false); | 981 Generate_JSEntryTrampolineHelper(masm, false); |
1001 } | 982 } |
1002 | 983 |
1003 | |
1004 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 984 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
1005 Generate_JSEntryTrampolineHelper(masm, true); | 985 Generate_JSEntryTrampolineHelper(masm, true); |
1006 } | 986 } |
1007 | 987 |
1008 static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { | 988 static void LeaveInterpreterFrame(MacroAssembler* masm, Register scratch) { |
1009 Register args_count = scratch; | 989 Register args_count = scratch; |
1010 | 990 |
1011 // Get the arguments + receiver count. | 991 // Get the arguments + receiver count. |
1012 __ ld(args_count, | 992 __ ld(args_count, |
1013 MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); | 993 MemOperand(fp, InterpreterFrameConstants::kBytecodeArrayFromFp)); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1499 } | 1479 } |
1500 | 1480 |
1501 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { | 1481 static void GenerateMakeCodeYoungAgainCommon(MacroAssembler* masm) { |
1502 // For now, we are relying on the fact that make_code_young doesn't do any | 1482 // For now, we are relying on the fact that make_code_young doesn't do any |
1503 // garbage collection which allows us to save/restore the registers without | 1483 // garbage collection which allows us to save/restore the registers without |
1504 // worrying about which of them contain pointers. We also don't build an | 1484 // worrying about which of them contain pointers. We also don't build an |
1505 // internal frame to make the code faster, since we shouldn't have to do stack | 1485 // internal frame to make the code faster, since we shouldn't have to do stack |
1506 // crawls in MakeCodeYoung. This seems a bit fragile. | 1486 // crawls in MakeCodeYoung. This seems a bit fragile. |
1507 | 1487 |
1508 // Set a0 to point to the head of the PlatformCodeAge sequence. | 1488 // Set a0 to point to the head of the PlatformCodeAge sequence. |
1509 __ Dsubu(a0, a0, | 1489 __ Dsubu(a0, a0, Operand(kNoCodeAgeSequenceLength - Assembler::kInstrSize)); |
1510 Operand(kNoCodeAgeSequenceLength - Assembler::kInstrSize)); | |
1511 | 1490 |
1512 // The following registers must be saved and restored when calling through to | 1491 // The following registers must be saved and restored when calling through to |
1513 // the runtime: | 1492 // the runtime: |
1514 // a0 - contains return address (beginning of patch sequence) | 1493 // a0 - contains return address (beginning of patch sequence) |
1515 // a1 - isolate | 1494 // a1 - isolate |
1516 // a3 - new target | 1495 // a3 - new target |
1517 RegList saved_regs = | 1496 RegList saved_regs = |
1518 (a0.bit() | a1.bit() | a3.bit() | ra.bit() | fp.bit()) & ~sp.bit(); | 1497 (a0.bit() | a1.bit() | a3.bit() | ra.bit() | fp.bit()) & ~sp.bit(); |
1519 FrameScope scope(masm, StackFrame::MANUAL); | 1498 FrameScope scope(masm, StackFrame::MANUAL); |
1520 __ MultiPush(saved_regs); | 1499 __ MultiPush(saved_regs); |
1521 __ PrepareCallCFunction(2, 0, a2); | 1500 __ PrepareCallCFunction(2, 0, a2); |
1522 __ li(a1, Operand(ExternalReference::isolate_address(masm->isolate()))); | 1501 __ li(a1, Operand(ExternalReference::isolate_address(masm->isolate()))); |
1523 __ CallCFunction( | 1502 __ CallCFunction( |
1524 ExternalReference::get_make_code_young_function(masm->isolate()), 2); | 1503 ExternalReference::get_make_code_young_function(masm->isolate()), 2); |
1525 __ MultiPop(saved_regs); | 1504 __ MultiPop(saved_regs); |
1526 __ Jump(a0); | 1505 __ Jump(a0); |
1527 } | 1506 } |
1528 | 1507 |
1529 #define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ | 1508 #define DEFINE_CODE_AGE_BUILTIN_GENERATOR(C) \ |
1530 void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \ | 1509 void Builtins::Generate_Make##C##CodeYoungAgainEvenMarking( \ |
1531 MacroAssembler* masm) { \ | 1510 MacroAssembler* masm) { \ |
1532 GenerateMakeCodeYoungAgainCommon(masm); \ | 1511 GenerateMakeCodeYoungAgainCommon(masm); \ |
1533 } \ | 1512 } \ |
1534 void Builtins::Generate_Make##C##CodeYoungAgainOddMarking( \ | 1513 void Builtins::Generate_Make##C##CodeYoungAgainOddMarking( \ |
1535 MacroAssembler* masm) { \ | 1514 MacroAssembler* masm) { \ |
1536 GenerateMakeCodeYoungAgainCommon(masm); \ | 1515 GenerateMakeCodeYoungAgainCommon(masm); \ |
1537 } | 1516 } |
1538 CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR) | 1517 CODE_AGE_LIST(DEFINE_CODE_AGE_BUILTIN_GENERATOR) |
1539 #undef DEFINE_CODE_AGE_BUILTIN_GENERATOR | 1518 #undef DEFINE_CODE_AGE_BUILTIN_GENERATOR |
1540 | 1519 |
1541 | |
1542 void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) { | 1520 void Builtins::Generate_MarkCodeAsExecutedOnce(MacroAssembler* masm) { |
1543 // For now, as in GenerateMakeCodeYoungAgainCommon, we are relying on the fact | 1521 // For now, as in GenerateMakeCodeYoungAgainCommon, we are relying on the fact |
1544 // that make_code_young doesn't do any garbage collection which allows us to | 1522 // that make_code_young doesn't do any garbage collection which allows us to |
1545 // save/restore the registers without worrying about which of them contain | 1523 // save/restore the registers without worrying about which of them contain |
1546 // pointers. | 1524 // pointers. |
1547 | 1525 |
1548 // Set a0 to point to the head of the PlatformCodeAge sequence. | 1526 // Set a0 to point to the head of the PlatformCodeAge sequence. |
1549 __ Dsubu(a0, a0, | 1527 __ Dsubu(a0, a0, Operand(kNoCodeAgeSequenceLength - Assembler::kInstrSize)); |
1550 Operand(kNoCodeAgeSequenceLength - Assembler::kInstrSize)); | |
1551 | 1528 |
1552 // The following registers must be saved and restored when calling through to | 1529 // The following registers must be saved and restored when calling through to |
1553 // the runtime: | 1530 // the runtime: |
1554 // a0 - contains return address (beginning of patch sequence) | 1531 // a0 - contains return address (beginning of patch sequence) |
1555 // a1 - isolate | 1532 // a1 - isolate |
1556 // a3 - new target | 1533 // a3 - new target |
1557 RegList saved_regs = | 1534 RegList saved_regs = |
1558 (a0.bit() | a1.bit() | a3.bit() | ra.bit() | fp.bit()) & ~sp.bit(); | 1535 (a0.bit() | a1.bit() | a3.bit() | ra.bit() | fp.bit()) & ~sp.bit(); |
1559 FrameScope scope(masm, StackFrame::MANUAL); | 1536 FrameScope scope(masm, StackFrame::MANUAL); |
1560 __ MultiPush(saved_regs); | 1537 __ MultiPush(saved_regs); |
1561 __ PrepareCallCFunction(2, 0, a2); | 1538 __ PrepareCallCFunction(2, 0, a2); |
1562 __ li(a1, Operand(ExternalReference::isolate_address(masm->isolate()))); | 1539 __ li(a1, Operand(ExternalReference::isolate_address(masm->isolate()))); |
1563 __ CallCFunction( | 1540 __ CallCFunction( |
1564 ExternalReference::get_mark_code_as_executed_function(masm->isolate()), | 1541 ExternalReference::get_mark_code_as_executed_function(masm->isolate()), |
1565 2); | 1542 2); |
1566 __ MultiPop(saved_regs); | 1543 __ MultiPop(saved_regs); |
1567 | 1544 |
1568 // Perform prologue operations usually performed by the young code stub. | 1545 // Perform prologue operations usually performed by the young code stub. |
1569 __ PushStandardFrame(a1); | 1546 __ PushStandardFrame(a1); |
1570 | 1547 |
1571 // Jump to point after the code-age stub. | 1548 // Jump to point after the code-age stub. |
1572 __ Daddu(a0, a0, Operand((kNoCodeAgeSequenceLength))); | 1549 __ Daddu(a0, a0, Operand((kNoCodeAgeSequenceLength))); |
1573 __ Jump(a0); | 1550 __ Jump(a0); |
1574 } | 1551 } |
1575 | 1552 |
1576 | |
1577 void Builtins::Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm) { | 1553 void Builtins::Generate_MarkCodeAsExecutedTwice(MacroAssembler* masm) { |
1578 GenerateMakeCodeYoungAgainCommon(masm); | 1554 GenerateMakeCodeYoungAgainCommon(masm); |
1579 } | 1555 } |
1580 | 1556 |
1581 | |
1582 void Builtins::Generate_MarkCodeAsToBeExecutedOnce(MacroAssembler* masm) { | 1557 void Builtins::Generate_MarkCodeAsToBeExecutedOnce(MacroAssembler* masm) { |
1583 Generate_MarkCodeAsExecutedOnce(masm); | 1558 Generate_MarkCodeAsExecutedOnce(masm); |
1584 } | 1559 } |
1585 | 1560 |
1586 | |
1587 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm, | 1561 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm, |
1588 SaveFPRegsMode save_doubles) { | 1562 SaveFPRegsMode save_doubles) { |
1589 { | 1563 { |
1590 FrameScope scope(masm, StackFrame::INTERNAL); | 1564 FrameScope scope(masm, StackFrame::INTERNAL); |
1591 | 1565 |
1592 // Preserve registers across notification, this is important for compiled | 1566 // Preserve registers across notification, this is important for compiled |
1593 // stubs that tail call the runtime on deopts passing their parameters in | 1567 // stubs that tail call the runtime on deopts passing their parameters in |
1594 // registers. | 1568 // registers. |
1595 __ MultiPush(kJSCallerSaved | kCalleeSaved); | 1569 __ MultiPush(kJSCallerSaved | kCalleeSaved); |
1596 // Pass the function and deoptimization type to the runtime system. | 1570 // Pass the function and deoptimization type to the runtime system. |
1597 __ CallRuntime(Runtime::kNotifyStubFailure, save_doubles); | 1571 __ CallRuntime(Runtime::kNotifyStubFailure, save_doubles); |
1598 __ MultiPop(kJSCallerSaved | kCalleeSaved); | 1572 __ MultiPop(kJSCallerSaved | kCalleeSaved); |
1599 } | 1573 } |
1600 | 1574 |
1601 __ Daddu(sp, sp, Operand(kPointerSize)); // Ignore state | 1575 __ Daddu(sp, sp, Operand(kPointerSize)); // Ignore state |
1602 __ Jump(ra); // Jump to miss handler | 1576 __ Jump(ra); // Jump to miss handler |
1603 } | 1577 } |
1604 | 1578 |
1605 | |
1606 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { | 1579 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { |
1607 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); | 1580 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); |
1608 } | 1581 } |
1609 | 1582 |
1610 | |
1611 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { | 1583 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { |
1612 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); | 1584 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); |
1613 } | 1585 } |
1614 | 1586 |
1615 | |
1616 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, | 1587 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, |
1617 Deoptimizer::BailoutType type) { | 1588 Deoptimizer::BailoutType type) { |
1618 { | 1589 { |
1619 FrameScope scope(masm, StackFrame::INTERNAL); | 1590 FrameScope scope(masm, StackFrame::INTERNAL); |
1620 // Pass the function and deoptimization type to the runtime system. | 1591 // Pass the function and deoptimization type to the runtime system. |
1621 __ li(a0, Operand(Smi::FromInt(static_cast<int>(type)))); | 1592 __ li(a0, Operand(Smi::FromInt(static_cast<int>(type)))); |
1622 __ push(a0); | 1593 __ push(a0); |
1623 __ CallRuntime(Runtime::kNotifyDeoptimized); | 1594 __ CallRuntime(Runtime::kNotifyDeoptimized); |
1624 } | 1595 } |
1625 | 1596 |
(...skipping 17 matching lines...) Expand all Loading... |
1643 Operand(static_cast<int64_t>(Deoptimizer::BailoutState::TOS_REGISTER))); | 1614 Operand(static_cast<int64_t>(Deoptimizer::BailoutState::TOS_REGISTER))); |
1644 | 1615 |
1645 __ Ret(USE_DELAY_SLOT); | 1616 __ Ret(USE_DELAY_SLOT); |
1646 // Safe to fill delay slot Addu will emit one instruction. | 1617 // Safe to fill delay slot Addu will emit one instruction. |
1647 __ Daddu(sp, sp, Operand(2 * kPointerSize)); // Remove state. | 1618 __ Daddu(sp, sp, Operand(2 * kPointerSize)); // Remove state. |
1648 | 1619 |
1649 __ bind(&unknown_state); | 1620 __ bind(&unknown_state); |
1650 __ stop("no cases left"); | 1621 __ stop("no cases left"); |
1651 } | 1622 } |
1652 | 1623 |
1653 | |
1654 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { | 1624 void Builtins::Generate_NotifyDeoptimized(MacroAssembler* masm) { |
1655 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); | 1625 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
1656 } | 1626 } |
1657 | 1627 |
1658 | |
1659 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { | 1628 void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { |
1660 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); | 1629 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); |
1661 } | 1630 } |
1662 | 1631 |
1663 | |
1664 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 1632 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
1665 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 1633 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
1666 } | 1634 } |
1667 | 1635 |
1668 | |
1669 // Clobbers {t2, t3, a4, a5}. | 1636 // Clobbers {t2, t3, a4, a5}. |
1670 static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, | 1637 static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, |
1671 Register function_template_info, | 1638 Register function_template_info, |
1672 Label* receiver_check_failed) { | 1639 Label* receiver_check_failed) { |
1673 Register signature = t2; | 1640 Register signature = t2; |
1674 Register map = t3; | 1641 Register map = t3; |
1675 Register constructor = a4; | 1642 Register constructor = a4; |
1676 Register scratch = a5; | 1643 Register scratch = a5; |
1677 | 1644 |
1678 // If there is no signature, return the holder. | 1645 // If there is no signature, return the holder. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1722 __ Branch(receiver_check_failed, eq, scratch, Operand(zero_reg)); | 1689 __ Branch(receiver_check_failed, eq, scratch, Operand(zero_reg)); |
1723 | 1690 |
1724 __ ld(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); | 1691 __ ld(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); |
1725 __ ld(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); | 1692 __ ld(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); |
1726 // Iterate. | 1693 // Iterate. |
1727 __ Branch(&prototype_loop_start); | 1694 __ Branch(&prototype_loop_start); |
1728 | 1695 |
1729 __ bind(&receiver_check_passed); | 1696 __ bind(&receiver_check_passed); |
1730 } | 1697 } |
1731 | 1698 |
1732 | |
1733 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { | 1699 void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { |
1734 // ----------- S t a t e ------------- | 1700 // ----------- S t a t e ------------- |
1735 // -- a0 : number of arguments excluding receiver | 1701 // -- a0 : number of arguments excluding receiver |
1736 // -- a1 : callee | 1702 // -- a1 : callee |
1737 // -- ra : return address | 1703 // -- ra : return address |
1738 // -- sp[0] : last argument | 1704 // -- sp[0] : last argument |
1739 // -- ... | 1705 // -- ... |
1740 // -- sp[8 * (argc - 1)] : first argument | 1706 // -- sp[8 * (argc - 1)] : first argument |
1741 // -- sp[8 * argc] : receiver | 1707 // -- sp[8 * argc] : receiver |
1742 // ----------------------------------- | 1708 // ----------------------------------- |
(...skipping 16 matching lines...) Expand all Loading... |
1759 __ Jump(t2); | 1725 __ Jump(t2); |
1760 | 1726 |
1761 // Compatible receiver check failed: throw an Illegal Invocation exception. | 1727 // Compatible receiver check failed: throw an Illegal Invocation exception. |
1762 __ bind(&receiver_check_failed); | 1728 __ bind(&receiver_check_failed); |
1763 // Drop the arguments (including the receiver); | 1729 // Drop the arguments (including the receiver); |
1764 __ Daddu(t8, t8, Operand(kPointerSize)); | 1730 __ Daddu(t8, t8, Operand(kPointerSize)); |
1765 __ daddu(sp, t8, zero_reg); | 1731 __ daddu(sp, t8, zero_reg); |
1766 __ TailCallRuntime(Runtime::kThrowIllegalInvocation); | 1732 __ TailCallRuntime(Runtime::kThrowIllegalInvocation); |
1767 } | 1733 } |
1768 | 1734 |
1769 | |
1770 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1735 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1771 // Lookup the function in the JavaScript frame. | 1736 // Lookup the function in the JavaScript frame. |
1772 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1737 __ ld(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1773 { | 1738 { |
1774 FrameScope scope(masm, StackFrame::INTERNAL); | 1739 FrameScope scope(masm, StackFrame::INTERNAL); |
1775 // Pass function as argument. | 1740 // Pass function as argument. |
1776 __ push(a0); | 1741 __ push(a0); |
1777 __ CallRuntime(Runtime::kCompileForOnStackReplacement); | 1742 __ CallRuntime(Runtime::kCompileForOnStackReplacement); |
1778 } | 1743 } |
1779 | 1744 |
1780 // If the code object is null, just return to the unoptimized code. | 1745 // If the code object is null, just return to the unoptimized code. |
1781 __ Ret(eq, v0, Operand(Smi::FromInt(0))); | 1746 __ Ret(eq, v0, Operand(Smi::FromInt(0))); |
1782 | 1747 |
1783 // Load deoptimization data from the code object. | 1748 // Load deoptimization data from the code object. |
1784 // <deopt_data> = <code>[#deoptimization_data_offset] | 1749 // <deopt_data> = <code>[#deoptimization_data_offset] |
1785 __ ld(a1, MemOperand(v0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); | 1750 __ ld(a1, MemOperand(v0, Code::kDeoptimizationDataOffset - kHeapObjectTag)); |
1786 | 1751 |
1787 // Load the OSR entrypoint offset from the deoptimization data. | 1752 // Load the OSR entrypoint offset from the deoptimization data. |
1788 // <osr_offset> = <deopt_data>[#header_size + #osr_pc_offset] | 1753 // <osr_offset> = <deopt_data>[#header_size + #osr_pc_offset] |
1789 __ ld(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( | 1754 __ ld(a1, MemOperand(a1, FixedArray::OffsetOfElementAt( |
1790 DeoptimizationInputData::kOsrPcOffsetIndex) - kHeapObjectTag)); | 1755 DeoptimizationInputData::kOsrPcOffsetIndex) - |
| 1756 kHeapObjectTag)); |
1791 __ SmiUntag(a1); | 1757 __ SmiUntag(a1); |
1792 | 1758 |
1793 // Compute the target address = code_obj + header_size + osr_offset | 1759 // Compute the target address = code_obj + header_size + osr_offset |
1794 // <entry_addr> = <code_obj> + #header_size + <osr_offset> | 1760 // <entry_addr> = <code_obj> + #header_size + <osr_offset> |
1795 __ daddu(v0, v0, a1); | 1761 __ daddu(v0, v0, a1); |
1796 __ daddiu(ra, v0, Code::kHeaderSize - kHeapObjectTag); | 1762 __ daddiu(ra, v0, Code::kHeaderSize - kHeapObjectTag); |
1797 | 1763 |
1798 // And "return" to the OSR entry point of the function. | 1764 // And "return" to the OSR entry point of the function. |
1799 __ Ret(); | 1765 __ Ret(); |
1800 } | 1766 } |
1801 | 1767 |
1802 | |
1803 // static | 1768 // static |
1804 void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm, | 1769 void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm, |
1805 int field_index) { | 1770 int field_index) { |
1806 // ----------- S t a t e ------------- | 1771 // ----------- S t a t e ------------- |
1807 // -- a0 : number of arguments | 1772 // -- a0 : number of arguments |
1808 // -- a1 : function | 1773 // -- a1 : function |
1809 // -- cp : context | 1774 // -- cp : context |
1810 // -- sp[0] : receiver | 1775 // -- sp[0] : receiver |
1811 // ----------------------------------- | 1776 // ----------------------------------- |
1812 | 1777 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 } | 1886 } |
1922 | 1887 |
1923 // 4c. The receiver is not callable, throw an appropriate TypeError. | 1888 // 4c. The receiver is not callable, throw an appropriate TypeError. |
1924 __ bind(&receiver_not_callable); | 1889 __ bind(&receiver_not_callable); |
1925 { | 1890 { |
1926 __ sd(a1, MemOperand(sp)); | 1891 __ sd(a1, MemOperand(sp)); |
1927 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | 1892 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); |
1928 } | 1893 } |
1929 } | 1894 } |
1930 | 1895 |
1931 | |
1932 // static | 1896 // static |
1933 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1897 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
1934 // 1. Make sure we have at least one argument. | 1898 // 1. Make sure we have at least one argument. |
1935 // a0: actual number of arguments | 1899 // a0: actual number of arguments |
1936 { | 1900 { |
1937 Label done; | 1901 Label done; |
1938 __ Branch(&done, ne, a0, Operand(zero_reg)); | 1902 __ Branch(&done, ne, a0, Operand(zero_reg)); |
1939 __ PushRoot(Heap::kUndefinedValueRootIndex); | 1903 __ PushRoot(Heap::kUndefinedValueRootIndex); |
1940 __ Daddu(a0, a0, Operand(1)); | 1904 __ Daddu(a0, a0, Operand(1)); |
1941 __ bind(&done); | 1905 __ bind(&done); |
(...skipping 22 matching lines...) Expand all Loading... |
1964 // Adjust the actual number of arguments and remove the top element | 1928 // Adjust the actual number of arguments and remove the top element |
1965 // (which is a copy of the last argument). | 1929 // (which is a copy of the last argument). |
1966 __ Dsubu(a0, a0, Operand(1)); | 1930 __ Dsubu(a0, a0, Operand(1)); |
1967 __ Pop(); | 1931 __ Pop(); |
1968 } | 1932 } |
1969 | 1933 |
1970 // 4. Call the callable. | 1934 // 4. Call the callable. |
1971 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1935 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1972 } | 1936 } |
1973 | 1937 |
1974 | |
1975 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { | 1938 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
1976 // ----------- S t a t e ------------- | 1939 // ----------- S t a t e ------------- |
1977 // -- a0 : argc | 1940 // -- a0 : argc |
1978 // -- sp[0] : argumentsList | 1941 // -- sp[0] : argumentsList |
1979 // -- sp[4] : thisArgument | 1942 // -- sp[4] : thisArgument |
1980 // -- sp[8] : target | 1943 // -- sp[8] : target |
1981 // -- sp[12] : receiver | 1944 // -- sp[12] : receiver |
1982 // ----------------------------------- | 1945 // ----------------------------------- |
1983 | 1946 |
1984 // 1. Load target into a1 (if present), argumentsList into a0 (if present), | 1947 // 1. Load target into a1 (if present), argumentsList into a0 (if present), |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2028 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); | 1991 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
2029 | 1992 |
2030 // 3b. The target is not callable, throw an appropriate TypeError. | 1993 // 3b. The target is not callable, throw an appropriate TypeError. |
2031 __ bind(&target_not_callable); | 1994 __ bind(&target_not_callable); |
2032 { | 1995 { |
2033 __ sd(a1, MemOperand(sp)); | 1996 __ sd(a1, MemOperand(sp)); |
2034 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); | 1997 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); |
2035 } | 1998 } |
2036 } | 1999 } |
2037 | 2000 |
2038 | |
2039 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 2001 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
2040 // ----------- S t a t e ------------- | 2002 // ----------- S t a t e ------------- |
2041 // -- a0 : argc | 2003 // -- a0 : argc |
2042 // -- sp[0] : new.target (optional) | 2004 // -- sp[0] : new.target (optional) |
2043 // -- sp[4] : argumentsList | 2005 // -- sp[4] : argumentsList |
2044 // -- sp[8] : target | 2006 // -- sp[8] : target |
2045 // -- sp[12] : receiver | 2007 // -- sp[12] : receiver |
2046 // ----------------------------------- | 2008 // ----------------------------------- |
2047 | 2009 |
2048 // 1. Load target into a1 (if present), argumentsList into a0 (if present), | 2010 // 1. Load target into a1 (if present), argumentsList into a0 (if present), |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 } | 2069 } |
2108 | 2070 |
2109 // 4c. The new.target is not a constructor, throw an appropriate TypeError. | 2071 // 4c. The new.target is not a constructor, throw an appropriate TypeError. |
2110 __ bind(&new_target_not_constructor); | 2072 __ bind(&new_target_not_constructor); |
2111 { | 2073 { |
2112 __ sd(a3, MemOperand(sp)); | 2074 __ sd(a3, MemOperand(sp)); |
2113 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); | 2075 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); |
2114 } | 2076 } |
2115 } | 2077 } |
2116 | 2078 |
2117 | |
2118 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | 2079 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, |
2119 Label* stack_overflow) { | 2080 Label* stack_overflow) { |
2120 // ----------- S t a t e ------------- | 2081 // ----------- S t a t e ------------- |
2121 // -- a0 : actual number of arguments | 2082 // -- a0 : actual number of arguments |
2122 // -- a1 : function (passed through to callee) | 2083 // -- a1 : function (passed through to callee) |
2123 // -- a2 : expected number of arguments | 2084 // -- a2 : expected number of arguments |
2124 // -- a3 : new target (passed through to callee) | 2085 // -- a3 : new target (passed through to callee) |
2125 // ----------------------------------- | 2086 // ----------------------------------- |
2126 // Check the stack for overflow. We are not trying to catch | 2087 // Check the stack for overflow. We are not trying to catch |
2127 // interruptions (e.g. debug break and preemption) here, so the "real stack | 2088 // interruptions (e.g. debug break and preemption) here, so the "real stack |
2128 // limit" is checked. | 2089 // limit" is checked. |
2129 __ LoadRoot(a5, Heap::kRealStackLimitRootIndex); | 2090 __ LoadRoot(a5, Heap::kRealStackLimitRootIndex); |
2130 // Make a5 the space we have left. The stack might already be overflowed | 2091 // Make a5 the space we have left. The stack might already be overflowed |
2131 // here which will cause a5 to become negative. | 2092 // here which will cause a5 to become negative. |
2132 __ dsubu(a5, sp, a5); | 2093 __ dsubu(a5, sp, a5); |
2133 // Check if the arguments will overflow the stack. | 2094 // Check if the arguments will overflow the stack. |
2134 __ dsll(at, a2, kPointerSizeLog2); | 2095 __ dsll(at, a2, kPointerSizeLog2); |
2135 // Signed comparison. | 2096 // Signed comparison. |
2136 __ Branch(stack_overflow, le, a5, Operand(at)); | 2097 __ Branch(stack_overflow, le, a5, Operand(at)); |
2137 } | 2098 } |
2138 | 2099 |
2139 | |
2140 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 2100 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
2141 // __ sll(a0, a0, kSmiTagSize); | 2101 // __ sll(a0, a0, kSmiTagSize); |
2142 __ dsll32(a0, a0, 0); | 2102 __ dsll32(a0, a0, 0); |
2143 __ li(a4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 2103 __ li(a4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
2144 __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); | 2104 __ MultiPush(a0.bit() | a1.bit() | a4.bit() | fp.bit() | ra.bit()); |
2145 __ Daddu(fp, sp, | 2105 __ Daddu(fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp + |
2146 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); | 2106 kPointerSize)); |
2147 } | 2107 } |
2148 | 2108 |
2149 | |
2150 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { | 2109 static void LeaveArgumentsAdaptorFrame(MacroAssembler* masm) { |
2151 // ----------- S t a t e ------------- | 2110 // ----------- S t a t e ------------- |
2152 // -- v0 : result being passed through | 2111 // -- v0 : result being passed through |
2153 // ----------------------------------- | 2112 // ----------------------------------- |
2154 // Get the number of arguments passed (as a smi), tear down the frame and | 2113 // Get the number of arguments passed (as a smi), tear down the frame and |
2155 // then tear down the parameters. | 2114 // then tear down the parameters. |
2156 __ ld(a1, MemOperand(fp, -(StandardFrameConstants::kFixedFrameSizeFromFp + | 2115 __ ld(a1, MemOperand(fp, -(StandardFrameConstants::kFixedFrameSizeFromFp + |
2157 kPointerSize))); | 2116 kPointerSize))); |
2158 __ mov(sp, fp); | 2117 __ mov(sp, fp); |
2159 __ MultiPop(fp.bit() | ra.bit()); | 2118 __ MultiPop(fp.bit() | ra.bit()); |
2160 __ SmiScale(a4, a1, kPointerSizeLog2); | 2119 __ SmiScale(a4, a1, kPointerSizeLog2); |
2161 __ Daddu(sp, sp, a4); | 2120 __ Daddu(sp, sp, a4); |
2162 // Adjust for the receiver. | 2121 // Adjust for the receiver. |
2163 __ Daddu(sp, sp, Operand(kPointerSize)); | 2122 __ Daddu(sp, sp, Operand(kPointerSize)); |
2164 } | 2123 } |
2165 | 2124 |
2166 | |
2167 // static | 2125 // static |
2168 void Builtins::Generate_Apply(MacroAssembler* masm) { | 2126 void Builtins::Generate_Apply(MacroAssembler* masm) { |
2169 // ----------- S t a t e ------------- | 2127 // ----------- S t a t e ------------- |
2170 // -- a0 : argumentsList | 2128 // -- a0 : argumentsList |
2171 // -- a1 : target | 2129 // -- a1 : target |
2172 // -- a3 : new.target (checked to be constructor or undefined) | 2130 // -- a3 : new.target (checked to be constructor or undefined) |
2173 // -- sp[0] : thisArgument | 2131 // -- sp[0] : thisArgument |
2174 // ----------------------------------- | 2132 // ----------------------------------- |
2175 | 2133 |
2176 // Create the list of arguments from the array-like argumentsList. | 2134 // Create the list of arguments from the array-like argumentsList. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2478 | 2436 |
2479 // The function is a "classConstructor", need to raise an exception. | 2437 // The function is a "classConstructor", need to raise an exception. |
2480 __ bind(&class_constructor); | 2438 __ bind(&class_constructor); |
2481 { | 2439 { |
2482 FrameScope frame(masm, StackFrame::INTERNAL); | 2440 FrameScope frame(masm, StackFrame::INTERNAL); |
2483 __ Push(a1); | 2441 __ Push(a1); |
2484 __ CallRuntime(Runtime::kThrowConstructorNonCallableError); | 2442 __ CallRuntime(Runtime::kThrowConstructorNonCallableError); |
2485 } | 2443 } |
2486 } | 2444 } |
2487 | 2445 |
2488 | |
2489 // static | 2446 // static |
2490 void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm, | 2447 void Builtins::Generate_CallBoundFunctionImpl(MacroAssembler* masm, |
2491 TailCallMode tail_call_mode) { | 2448 TailCallMode tail_call_mode) { |
2492 // ----------- S t a t e ------------- | 2449 // ----------- S t a t e ------------- |
2493 // -- a0 : the number of arguments (not including the receiver) | 2450 // -- a0 : the number of arguments (not including the receiver) |
2494 // -- a1 : the function to call (checked to be a JSBoundFunction) | 2451 // -- a1 : the function to call (checked to be a JSBoundFunction) |
2495 // ----------------------------------- | 2452 // ----------------------------------- |
2496 __ AssertBoundFunction(a1); | 2453 __ AssertBoundFunction(a1); |
2497 | 2454 |
2498 if (tail_call_mode == TailCallMode::kAllow) { | 2455 if (tail_call_mode == TailCallMode::kAllow) { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 | 2530 |
2574 // Call the [[BoundTargetFunction]] via the Call builtin. | 2531 // Call the [[BoundTargetFunction]] via the Call builtin. |
2575 __ ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); | 2532 __ ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); |
2576 __ li(at, Operand(ExternalReference(Builtins::kCall_ReceiverIsAny, | 2533 __ li(at, Operand(ExternalReference(Builtins::kCall_ReceiverIsAny, |
2577 masm->isolate()))); | 2534 masm->isolate()))); |
2578 __ ld(at, MemOperand(at)); | 2535 __ ld(at, MemOperand(at)); |
2579 __ Daddu(at, at, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2536 __ Daddu(at, at, Operand(Code::kHeaderSize - kHeapObjectTag)); |
2580 __ Jump(at); | 2537 __ Jump(at); |
2581 } | 2538 } |
2582 | 2539 |
2583 | |
2584 // static | 2540 // static |
2585 void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode, | 2541 void Builtins::Generate_Call(MacroAssembler* masm, ConvertReceiverMode mode, |
2586 TailCallMode tail_call_mode) { | 2542 TailCallMode tail_call_mode) { |
2587 // ----------- S t a t e ------------- | 2543 // ----------- S t a t e ------------- |
2588 // -- a0 : the number of arguments (not including the receiver) | 2544 // -- a0 : the number of arguments (not including the receiver) |
2589 // -- a1 : the target to call (can be any Object). | 2545 // -- a1 : the target to call (can be any Object). |
2590 // ----------------------------------- | 2546 // ----------------------------------- |
2591 | 2547 |
2592 Label non_callable, non_function, non_smi; | 2548 Label non_callable, non_function, non_smi; |
2593 __ JumpIfSmi(a1, &non_callable); | 2549 __ JumpIfSmi(a1, &non_callable); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2633 | 2589 |
2634 // 3. Call to something that is not callable. | 2590 // 3. Call to something that is not callable. |
2635 __ bind(&non_callable); | 2591 __ bind(&non_callable); |
2636 { | 2592 { |
2637 FrameScope scope(masm, StackFrame::INTERNAL); | 2593 FrameScope scope(masm, StackFrame::INTERNAL); |
2638 __ Push(a1); | 2594 __ Push(a1); |
2639 __ CallRuntime(Runtime::kThrowCalledNonCallable); | 2595 __ CallRuntime(Runtime::kThrowCalledNonCallable); |
2640 } | 2596 } |
2641 } | 2597 } |
2642 | 2598 |
2643 | |
2644 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { | 2599 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
2645 // ----------- S t a t e ------------- | 2600 // ----------- S t a t e ------------- |
2646 // -- a0 : the number of arguments (not including the receiver) | 2601 // -- a0 : the number of arguments (not including the receiver) |
2647 // -- a1 : the constructor to call (checked to be a JSFunction) | 2602 // -- a1 : the constructor to call (checked to be a JSFunction) |
2648 // -- a3 : the new target (checked to be a constructor) | 2603 // -- a3 : the new target (checked to be a constructor) |
2649 // ----------------------------------- | 2604 // ----------------------------------- |
2650 __ AssertFunction(a1); | 2605 __ AssertFunction(a1); |
2651 | 2606 |
2652 // Calling convention for function specific ConstructStubs require | 2607 // Calling convention for function specific ConstructStubs require |
2653 // a2 to contain either an AllocationSite or undefined. | 2608 // a2 to contain either an AllocationSite or undefined. |
2654 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); | 2609 __ LoadRoot(a2, Heap::kUndefinedValueRootIndex); |
2655 | 2610 |
2656 // Tail call to the function-specific construct stub (still in the caller | 2611 // Tail call to the function-specific construct stub (still in the caller |
2657 // context at this point). | 2612 // context at this point). |
2658 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); | 2613 __ ld(a4, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); |
2659 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); | 2614 __ ld(a4, FieldMemOperand(a4, SharedFunctionInfo::kConstructStubOffset)); |
2660 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2615 __ Daddu(at, a4, Operand(Code::kHeaderSize - kHeapObjectTag)); |
2661 __ Jump(at); | 2616 __ Jump(at); |
2662 } | 2617 } |
2663 | 2618 |
2664 | |
2665 // static | 2619 // static |
2666 void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { | 2620 void Builtins::Generate_ConstructBoundFunction(MacroAssembler* masm) { |
2667 // ----------- S t a t e ------------- | 2621 // ----------- S t a t e ------------- |
2668 // -- a0 : the number of arguments (not including the receiver) | 2622 // -- a0 : the number of arguments (not including the receiver) |
2669 // -- a1 : the function to call (checked to be a JSBoundFunction) | 2623 // -- a1 : the function to call (checked to be a JSBoundFunction) |
2670 // -- a3 : the new target (checked to be a constructor) | 2624 // -- a3 : the new target (checked to be a constructor) |
2671 // ----------------------------------- | 2625 // ----------------------------------- |
2672 __ AssertBoundFunction(a1); | 2626 __ AssertBoundFunction(a1); |
2673 | 2627 |
2674 // Load [[BoundArguments]] into a2 and length of that into a4. | 2628 // Load [[BoundArguments]] into a2 and length of that into a4. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2746 } | 2700 } |
2747 | 2701 |
2748 // Construct the [[BoundTargetFunction]] via the Construct builtin. | 2702 // Construct the [[BoundTargetFunction]] via the Construct builtin. |
2749 __ ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); | 2703 __ ld(a1, FieldMemOperand(a1, JSBoundFunction::kBoundTargetFunctionOffset)); |
2750 __ li(at, Operand(ExternalReference(Builtins::kConstruct, masm->isolate()))); | 2704 __ li(at, Operand(ExternalReference(Builtins::kConstruct, masm->isolate()))); |
2751 __ ld(at, MemOperand(at)); | 2705 __ ld(at, MemOperand(at)); |
2752 __ Daddu(at, at, Operand(Code::kHeaderSize - kHeapObjectTag)); | 2706 __ Daddu(at, at, Operand(Code::kHeaderSize - kHeapObjectTag)); |
2753 __ Jump(at); | 2707 __ Jump(at); |
2754 } | 2708 } |
2755 | 2709 |
2756 | |
2757 // static | 2710 // static |
2758 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { | 2711 void Builtins::Generate_ConstructProxy(MacroAssembler* masm) { |
2759 // ----------- S t a t e ------------- | 2712 // ----------- S t a t e ------------- |
2760 // -- a0 : the number of arguments (not including the receiver) | 2713 // -- a0 : the number of arguments (not including the receiver) |
2761 // -- a1 : the constructor to call (checked to be a JSProxy) | 2714 // -- a1 : the constructor to call (checked to be a JSProxy) |
2762 // -- a3 : the new target (either the same as the constructor or | 2715 // -- a3 : the new target (either the same as the constructor or |
2763 // the JSFunction on which new was invoked initially) | 2716 // the JSFunction on which new was invoked initially) |
2764 // ----------------------------------- | 2717 // ----------------------------------- |
2765 | 2718 |
2766 // Call into the Runtime for Proxy [[Construct]]. | 2719 // Call into the Runtime for Proxy [[Construct]]. |
2767 __ Push(a1, a3); | 2720 __ Push(a1, a3); |
2768 // Include the pushed new_target, constructor and the receiver. | 2721 // Include the pushed new_target, constructor and the receiver. |
2769 __ Daddu(a0, a0, Operand(3)); | 2722 __ Daddu(a0, a0, Operand(3)); |
2770 // Tail-call to the runtime. | 2723 // Tail-call to the runtime. |
2771 __ JumpToExternalReference( | 2724 __ JumpToExternalReference( |
2772 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate())); | 2725 ExternalReference(Runtime::kJSProxyConstruct, masm->isolate())); |
2773 } | 2726 } |
2774 | 2727 |
2775 | |
2776 // static | 2728 // static |
2777 void Builtins::Generate_Construct(MacroAssembler* masm) { | 2729 void Builtins::Generate_Construct(MacroAssembler* masm) { |
2778 // ----------- S t a t e ------------- | 2730 // ----------- S t a t e ------------- |
2779 // -- a0 : the number of arguments (not including the receiver) | 2731 // -- a0 : the number of arguments (not including the receiver) |
2780 // -- a1 : the constructor to call (can be any Object) | 2732 // -- a1 : the constructor to call (can be any Object) |
2781 // -- a3 : the new target (either the same as the constructor or | 2733 // -- a3 : the new target (either the same as the constructor or |
2782 // the JSFunction on which new was invoked initially) | 2734 // the JSFunction on which new was invoked initially) |
2783 // ----------------------------------- | 2735 // ----------------------------------- |
2784 | 2736 |
2785 // Check if target is a Smi. | 2737 // Check if target is a Smi. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2931 // ----------- S t a t e ------------- | 2883 // ----------- S t a t e ------------- |
2932 // -- a0: actual arguments count | 2884 // -- a0: actual arguments count |
2933 // -- a1: function (passed through to callee) | 2885 // -- a1: function (passed through to callee) |
2934 // -- a2: expected arguments count | 2886 // -- a2: expected arguments count |
2935 // -- a3: new target (passed through to callee) | 2887 // -- a3: new target (passed through to callee) |
2936 // ----------------------------------- | 2888 // ----------------------------------- |
2937 | 2889 |
2938 Label invoke, dont_adapt_arguments, stack_overflow; | 2890 Label invoke, dont_adapt_arguments, stack_overflow; |
2939 | 2891 |
2940 Label enough, too_few; | 2892 Label enough, too_few; |
2941 __ Branch(&dont_adapt_arguments, eq, | 2893 __ Branch(&dont_adapt_arguments, eq, a2, |
2942 a2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 2894 Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
2943 // We use Uless as the number of argument should always be greater than 0. | 2895 // We use Uless as the number of argument should always be greater than 0. |
2944 __ Branch(&too_few, Uless, a0, Operand(a2)); | 2896 __ Branch(&too_few, Uless, a0, Operand(a2)); |
2945 | 2897 |
2946 { // Enough parameters: actual >= expected. | 2898 { // Enough parameters: actual >= expected. |
2947 // a0: actual number of arguments as a smi | 2899 // a0: actual number of arguments as a smi |
2948 // a1: function | 2900 // a1: function |
2949 // a2: expected number of arguments | 2901 // a2: expected number of arguments |
2950 // a3: new target (passed through to callee) | 2902 // a3: new target (passed through to callee) |
2951 __ bind(&enough); | 2903 __ bind(&enough); |
2952 EnterArgumentsAdaptorFrame(masm); | 2904 EnterArgumentsAdaptorFrame(masm); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 __ ld(a4, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 2988 __ ld(a4, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
3037 __ Call(a4); | 2989 __ Call(a4); |
3038 | 2990 |
3039 // Store offset of return address for deoptimizer. | 2991 // Store offset of return address for deoptimizer. |
3040 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 2992 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
3041 | 2993 |
3042 // Exit frame and return. | 2994 // Exit frame and return. |
3043 LeaveArgumentsAdaptorFrame(masm); | 2995 LeaveArgumentsAdaptorFrame(masm); |
3044 __ Ret(); | 2996 __ Ret(); |
3045 | 2997 |
3046 | |
3047 // ------------------------------------------- | 2998 // ------------------------------------------- |
3048 // Don't adapt arguments. | 2999 // Don't adapt arguments. |
3049 // ------------------------------------------- | 3000 // ------------------------------------------- |
3050 __ bind(&dont_adapt_arguments); | 3001 __ bind(&dont_adapt_arguments); |
3051 __ ld(a4, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); | 3002 __ ld(a4, FieldMemOperand(a1, JSFunction::kCodeEntryOffset)); |
3052 __ Jump(a4); | 3003 __ Jump(a4); |
3053 | 3004 |
3054 __ bind(&stack_overflow); | 3005 __ bind(&stack_overflow); |
3055 { | 3006 { |
3056 FrameScope frame(masm, StackFrame::MANUAL); | 3007 FrameScope frame(masm, StackFrame::MANUAL); |
3057 __ CallRuntime(Runtime::kThrowStackOverflow); | 3008 __ CallRuntime(Runtime::kThrowStackOverflow); |
3058 __ break_(0xCC); | 3009 __ break_(0xCC); |
3059 } | 3010 } |
3060 } | 3011 } |
3061 | 3012 |
3062 | |
3063 #undef __ | 3013 #undef __ |
3064 | 3014 |
3065 } // namespace internal | 3015 } // namespace internal |
3066 } // namespace v8 | 3016 } // namespace v8 |
3067 | 3017 |
3068 #endif // V8_TARGET_ARCH_MIPS64 | 3018 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |