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_ARM | 5 #if V8_TARGET_ARCH_ARM |
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 __ bind(&to_string); | 179 __ bind(&to_string); |
180 { | 180 { |
181 ToStringStub stub(masm->isolate()); | 181 ToStringStub stub(masm->isolate()); |
182 __ TailCallStub(&stub); | 182 __ TailCallStub(&stub); |
183 } | 183 } |
184 | 184 |
185 // 3b. Convert symbol in r0 to a string. | 185 // 3b. Convert symbol in r0 to a string. |
186 __ bind(&symbol_descriptive_string); | 186 __ bind(&symbol_descriptive_string); |
187 { | 187 { |
188 __ Push(r0); | 188 __ Push(r0); |
189 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1); | 189 __ TailCallRuntime(Runtime::kSymbolDescriptiveString); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 | 193 |
194 // static | 194 // static |
195 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { | 195 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { |
196 // ----------- S t a t e ------------- | 196 // ----------- S t a t e ------------- |
197 // -- r0 : number of arguments | 197 // -- r0 : number of arguments |
198 // -- r1 : constructor function | 198 // -- r1 : constructor function |
199 // -- r3 : new target | 199 // -- r3 : new target |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset)); | 260 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset)); |
261 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); | 261 STATIC_ASSERT(JSValue::kSize == 4 * kPointerSize); |
262 __ Ret(); | 262 __ Ret(); |
263 } | 263 } |
264 | 264 |
265 // 5. Fallback to the runtime to create new object. | 265 // 5. Fallback to the runtime to create new object. |
266 __ bind(&new_object); | 266 __ bind(&new_object); |
267 { | 267 { |
268 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 268 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
269 __ Push(r2, r1, r3); // first argument, constructor, new target | 269 __ Push(r2, r1, r3); // first argument, constructor, new target |
270 __ CallRuntime(Runtime::kNewObject, 2); | 270 __ CallRuntime(Runtime::kNewObject); |
271 __ Pop(r2); | 271 __ Pop(r2); |
272 } | 272 } |
273 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset)); | 273 __ str(r2, FieldMemOperand(r0, JSValue::kValueOffset)); |
274 __ Ret(); | 274 __ Ret(); |
275 } | 275 } |
276 | 276 |
277 | 277 |
278 static void CallRuntimePassFunction( | 278 static void CallRuntimePassFunction( |
279 MacroAssembler* masm, Runtime::FunctionId function_id) { | 279 MacroAssembler* masm, Runtime::FunctionId function_id) { |
280 // ----------- S t a t e ------------- | 280 // ----------- S t a t e ------------- |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); | 452 __ LoadRoot(r6, Heap::kOnePointerFillerMapRootIndex); |
453 __ InitializeFieldsWithFiller(r5, r9, r6); | 453 __ InitializeFieldsWithFiller(r5, r9, r6); |
454 | 454 |
455 __ pop(r0); // Restore allocation count value before decreasing. | 455 __ pop(r0); // Restore allocation count value before decreasing. |
456 __ cmp(r0, Operand(Map::kSlackTrackingCounterEnd)); | 456 __ cmp(r0, Operand(Map::kSlackTrackingCounterEnd)); |
457 __ b(ne, &allocated); | 457 __ b(ne, &allocated); |
458 | 458 |
459 // Push the constructor, new_target and the object to the stack, | 459 // Push the constructor, new_target and the object to the stack, |
460 // and then the initial map as an argument to the runtime call. | 460 // and then the initial map as an argument to the runtime call. |
461 __ Push(r1, r3, r4, r2); | 461 __ Push(r1, r3, r4, r2); |
462 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); | 462 __ CallRuntime(Runtime::kFinalizeInstanceSize); |
463 __ Pop(r1, r3, r4); | 463 __ Pop(r1, r3, r4); |
464 | 464 |
465 // Continue with JSObject being successfully allocated | 465 // Continue with JSObject being successfully allocated |
466 // r1: constructor function | 466 // r1: constructor function |
467 // r3: new target | 467 // r3: new target |
468 // r4: JSObject | 468 // r4: JSObject |
469 __ jmp(&allocated); | 469 __ jmp(&allocated); |
470 | 470 |
471 __ bind(&no_inobject_slack_tracking); | 471 __ bind(&no_inobject_slack_tracking); |
472 } | 472 } |
473 | 473 |
474 __ InitializeFieldsWithFiller(r5, r9, r6); | 474 __ InitializeFieldsWithFiller(r5, r9, r6); |
475 | 475 |
476 // Continue with JSObject being successfully allocated | 476 // Continue with JSObject being successfully allocated |
477 // r1: constructor function | 477 // r1: constructor function |
478 // r3: new target | 478 // r3: new target |
479 // r4: JSObject | 479 // r4: JSObject |
480 __ jmp(&allocated); | 480 __ jmp(&allocated); |
481 } | 481 } |
482 | 482 |
483 // Allocate the new receiver object using the runtime call. | 483 // Allocate the new receiver object using the runtime call. |
484 // r1: constructor function | 484 // r1: constructor function |
485 // r3: new target | 485 // r3: new target |
486 __ bind(&rt_call); | 486 __ bind(&rt_call); |
487 | 487 |
488 // Push the constructor and new_target twice, second pair as arguments | 488 // Push the constructor and new_target twice, second pair as arguments |
489 // to the runtime call. | 489 // to the runtime call. |
490 __ Push(r1, r3); | 490 __ Push(r1, r3); |
491 __ Push(r1, r3); // constructor function, new target | 491 __ Push(r1, r3); // constructor function, new target |
492 __ CallRuntime(Runtime::kNewObject, 2); | 492 __ CallRuntime(Runtime::kNewObject); |
493 __ mov(r4, r0); | 493 __ mov(r4, r0); |
494 __ Pop(r1, r3); | 494 __ Pop(r1, r3); |
495 | 495 |
496 // Receiver for constructor call allocated. | 496 // Receiver for constructor call allocated. |
497 // r1: constructor function | 497 // r1: constructor function |
498 // r3: new target | 498 // r3: new target |
499 // r4: JSObject | 499 // r4: JSObject |
500 __ bind(&allocated); | 500 __ bind(&allocated); |
501 | 501 |
502 // Retrieve smi-tagged arguments count from the stack. | 502 // Retrieve smi-tagged arguments count from the stack. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 | 619 |
620 | 620 |
621 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { | 621 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { |
622 Generate_JSConstructStubHelper(masm, false, false); | 622 Generate_JSConstructStubHelper(masm, false, false); |
623 } | 623 } |
624 | 624 |
625 | 625 |
626 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { | 626 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { |
627 FrameScope scope(masm, StackFrame::INTERNAL); | 627 FrameScope scope(masm, StackFrame::INTERNAL); |
628 __ push(r1); | 628 __ push(r1); |
629 __ CallRuntime(Runtime::kThrowConstructedNonConstructable, 1); | 629 __ CallRuntime(Runtime::kThrowConstructedNonConstructable); |
630 } | 630 } |
631 | 631 |
632 | 632 |
633 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; | 633 enum IsTagged { kArgcIsSmiTagged, kArgcIsUntaggedInt }; |
634 | 634 |
635 | 635 |
636 // Clobbers r2; preserves all other registers. | 636 // Clobbers r2; preserves all other registers. |
637 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, | 637 static void Generate_CheckStackOverflow(MacroAssembler* masm, Register argc, |
638 IsTagged argc_is_tagged) { | 638 IsTagged argc_is_tagged) { |
639 // Check the stack for overflow. We are not trying to catch | 639 // Check the stack for overflow. We are not trying to catch |
640 // interruptions (e.g. debug break and preemption) here, so the "real stack | 640 // interruptions (e.g. debug break and preemption) here, so the "real stack |
641 // limit" is checked. | 641 // limit" is checked. |
642 Label okay; | 642 Label okay; |
643 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); | 643 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); |
644 // Make r2 the space we have left. The stack might already be overflowed | 644 // Make r2 the space we have left. The stack might already be overflowed |
645 // here which will cause r2 to become negative. | 645 // here which will cause r2 to become negative. |
646 __ sub(r2, sp, r2); | 646 __ sub(r2, sp, r2); |
647 // Check if the arguments will overflow the stack. | 647 // Check if the arguments will overflow the stack. |
648 if (argc_is_tagged == kArgcIsSmiTagged) { | 648 if (argc_is_tagged == kArgcIsSmiTagged) { |
649 __ cmp(r2, Operand::PointerOffsetFromSmiKey(argc)); | 649 __ cmp(r2, Operand::PointerOffsetFromSmiKey(argc)); |
650 } else { | 650 } else { |
651 DCHECK(argc_is_tagged == kArgcIsUntaggedInt); | 651 DCHECK(argc_is_tagged == kArgcIsUntaggedInt); |
652 __ cmp(r2, Operand(argc, LSL, kPointerSizeLog2)); | 652 __ cmp(r2, Operand(argc, LSL, kPointerSizeLog2)); |
653 } | 653 } |
654 __ b(gt, &okay); // Signed comparison. | 654 __ b(gt, &okay); // Signed comparison. |
655 | 655 |
656 // Out of stack space. | 656 // Out of stack space. |
657 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 657 __ CallRuntime(Runtime::kThrowStackOverflow); |
658 | 658 |
659 __ bind(&okay); | 659 __ bind(&okay); |
660 } | 660 } |
661 | 661 |
662 | 662 |
663 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, | 663 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, |
664 bool is_construct) { | 664 bool is_construct) { |
665 // Called from Generate_JS_Entry | 665 // Called from Generate_JS_Entry |
666 // r0: new.target | 666 // r0: new.target |
667 // r1: function | 667 // r1: function |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 // Load frame size from the BytecodeArray object. | 805 // Load frame size from the BytecodeArray object. |
806 __ ldr(r4, FieldMemOperand(kInterpreterBytecodeArrayRegister, | 806 __ ldr(r4, FieldMemOperand(kInterpreterBytecodeArrayRegister, |
807 BytecodeArray::kFrameSizeOffset)); | 807 BytecodeArray::kFrameSizeOffset)); |
808 | 808 |
809 // Do a stack check to ensure we don't go over the limit. | 809 // Do a stack check to ensure we don't go over the limit. |
810 Label ok; | 810 Label ok; |
811 __ sub(r9, sp, Operand(r4)); | 811 __ sub(r9, sp, Operand(r4)); |
812 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); | 812 __ LoadRoot(r2, Heap::kRealStackLimitRootIndex); |
813 __ cmp(r9, Operand(r2)); | 813 __ cmp(r9, Operand(r2)); |
814 __ b(hs, &ok); | 814 __ b(hs, &ok); |
815 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 815 __ CallRuntime(Runtime::kThrowStackOverflow); |
816 __ bind(&ok); | 816 __ bind(&ok); |
817 | 817 |
818 // If ok, push undefined as the initial value for all register file entries. | 818 // If ok, push undefined as the initial value for all register file entries. |
819 Label loop_header; | 819 Label loop_header; |
820 Label loop_check; | 820 Label loop_check; |
821 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); | 821 __ LoadRoot(r9, Heap::kUndefinedValueRootIndex); |
822 __ b(&loop_check, al); | 822 __ b(&loop_check, al); |
823 __ bind(&loop_header); | 823 __ bind(&loop_header); |
824 // TODO(rmcilroy): Consider doing more than one push per loop iteration. | 824 // TODO(rmcilroy): Consider doing more than one push per loop iteration. |
825 __ push(r9); | 825 __ push(r9); |
(...skipping 10 matching lines...) Expand all Loading... |
836 // - Allow simulator stop operations if FLAG_stop_at is set. | 836 // - Allow simulator stop operations if FLAG_stop_at is set. |
837 // - Code aging of the BytecodeArray object. | 837 // - Code aging of the BytecodeArray object. |
838 | 838 |
839 // Perform stack guard check. | 839 // Perform stack guard check. |
840 { | 840 { |
841 Label ok; | 841 Label ok; |
842 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 842 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
843 __ cmp(sp, Operand(ip)); | 843 __ cmp(sp, Operand(ip)); |
844 __ b(hs, &ok); | 844 __ b(hs, &ok); |
845 __ push(kInterpreterBytecodeArrayRegister); | 845 __ push(kInterpreterBytecodeArrayRegister); |
846 __ CallRuntime(Runtime::kStackGuard, 0); | 846 __ CallRuntime(Runtime::kStackGuard); |
847 __ pop(kInterpreterBytecodeArrayRegister); | 847 __ pop(kInterpreterBytecodeArrayRegister); |
848 __ bind(&ok); | 848 __ bind(&ok); |
849 } | 849 } |
850 | 850 |
851 // Load accumulator, register file, bytecode offset, dispatch table into | 851 // Load accumulator, register file, bytecode offset, dispatch table into |
852 // registers. | 852 // registers. |
853 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); | 853 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); |
854 __ add(kInterpreterRegisterFileRegister, fp, | 854 __ add(kInterpreterRegisterFileRegister, fp, |
855 Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp)); | 855 Operand(InterpreterFrameConstants::kRegisterFilePointerFromFp)); |
856 __ mov(kInterpreterBytecodeOffsetRegister, | 856 __ mov(kInterpreterBytecodeOffsetRegister, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 static void Generate_InterpreterNotifyDeoptimizedHelper( | 955 static void Generate_InterpreterNotifyDeoptimizedHelper( |
956 MacroAssembler* masm, Deoptimizer::BailoutType type) { | 956 MacroAssembler* masm, Deoptimizer::BailoutType type) { |
957 // Enter an internal frame. | 957 // Enter an internal frame. |
958 { | 958 { |
959 FrameScope scope(masm, StackFrame::INTERNAL); | 959 FrameScope scope(masm, StackFrame::INTERNAL); |
960 __ push(kInterpreterAccumulatorRegister); // Save accumulator register. | 960 __ push(kInterpreterAccumulatorRegister); // Save accumulator register. |
961 | 961 |
962 // Pass the deoptimization type to the runtime system. | 962 // Pass the deoptimization type to the runtime system. |
963 __ mov(r1, Operand(Smi::FromInt(static_cast<int>(type)))); | 963 __ mov(r1, Operand(Smi::FromInt(static_cast<int>(type)))); |
964 __ push(r1); | 964 __ push(r1); |
965 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); | 965 __ CallRuntime(Runtime::kNotifyDeoptimized); |
966 | 966 |
967 __ pop(kInterpreterAccumulatorRegister); // Restore accumulator register. | 967 __ pop(kInterpreterAccumulatorRegister); // Restore accumulator register. |
968 // Tear down internal frame. | 968 // Tear down internal frame. |
969 } | 969 } |
970 | 970 |
971 // Drop state (we don't use these for interpreter deopts) and push PC at top | 971 // Drop state (we don't use these for interpreter deopts) and push PC at top |
972 // of stack (to simulate initial call to bytecode handler in interpreter entry | 972 // of stack (to simulate initial call to bytecode handler in interpreter entry |
973 // trampoline). | 973 // trampoline). |
974 __ pop(r1); | 974 __ pop(r1); |
975 __ Drop(1); | 975 __ Drop(1); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm, | 1134 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm, |
1135 SaveFPRegsMode save_doubles) { | 1135 SaveFPRegsMode save_doubles) { |
1136 { | 1136 { |
1137 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1137 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1138 | 1138 |
1139 // Preserve registers across notification, this is important for compiled | 1139 // Preserve registers across notification, this is important for compiled |
1140 // stubs that tail call the runtime on deopts passing their parameters in | 1140 // stubs that tail call the runtime on deopts passing their parameters in |
1141 // registers. | 1141 // registers. |
1142 __ stm(db_w, sp, kJSCallerSaved | kCalleeSaved); | 1142 __ stm(db_w, sp, kJSCallerSaved | kCalleeSaved); |
1143 // Pass the function and deoptimization type to the runtime system. | 1143 // Pass the function and deoptimization type to the runtime system. |
1144 __ CallRuntime(Runtime::kNotifyStubFailure, 0, save_doubles); | 1144 __ CallRuntime(Runtime::kNotifyStubFailure, save_doubles); |
1145 __ ldm(ia_w, sp, kJSCallerSaved | kCalleeSaved); | 1145 __ ldm(ia_w, sp, kJSCallerSaved | kCalleeSaved); |
1146 } | 1146 } |
1147 | 1147 |
1148 __ add(sp, sp, Operand(kPointerSize)); // Ignore state | 1148 __ add(sp, sp, Operand(kPointerSize)); // Ignore state |
1149 __ mov(pc, lr); // Jump to miss handler | 1149 __ mov(pc, lr); // Jump to miss handler |
1150 } | 1150 } |
1151 | 1151 |
1152 | 1152 |
1153 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { | 1153 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { |
1154 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); | 1154 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); |
1155 } | 1155 } |
1156 | 1156 |
1157 | 1157 |
1158 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { | 1158 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { |
1159 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); | 1159 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); |
1160 } | 1160 } |
1161 | 1161 |
1162 | 1162 |
1163 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, | 1163 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, |
1164 Deoptimizer::BailoutType type) { | 1164 Deoptimizer::BailoutType type) { |
1165 { | 1165 { |
1166 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1166 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1167 // Pass the function and deoptimization type to the runtime system. | 1167 // Pass the function and deoptimization type to the runtime system. |
1168 __ mov(r0, Operand(Smi::FromInt(static_cast<int>(type)))); | 1168 __ mov(r0, Operand(Smi::FromInt(static_cast<int>(type)))); |
1169 __ push(r0); | 1169 __ push(r0); |
1170 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); | 1170 __ CallRuntime(Runtime::kNotifyDeoptimized); |
1171 } | 1171 } |
1172 | 1172 |
1173 // Get the full codegen state from the stack and untag it -> r6. | 1173 // Get the full codegen state from the stack and untag it -> r6. |
1174 __ ldr(r6, MemOperand(sp, 0 * kPointerSize)); | 1174 __ ldr(r6, MemOperand(sp, 0 * kPointerSize)); |
1175 __ SmiUntag(r6); | 1175 __ SmiUntag(r6); |
1176 // Switch on the state. | 1176 // Switch on the state. |
1177 Label with_tos_register, unknown_state; | 1177 Label with_tos_register, unknown_state; |
1178 __ cmp(r6, Operand(FullCodeGenerator::NO_REGISTERS)); | 1178 __ cmp(r6, Operand(FullCodeGenerator::NO_REGISTERS)); |
1179 __ b(ne, &with_tos_register); | 1179 __ b(ne, &with_tos_register); |
1180 __ add(sp, sp, Operand(1 * kPointerSize)); // Remove state. | 1180 __ add(sp, sp, Operand(1 * kPointerSize)); // Remove state. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 __ bind(&set_global_proxy); | 1315 __ bind(&set_global_proxy); |
1316 __ LoadGlobalProxy(r2); | 1316 __ LoadGlobalProxy(r2); |
1317 __ str(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); | 1317 __ str(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); |
1318 __ b(&valid_receiver); | 1318 __ b(&valid_receiver); |
1319 | 1319 |
1320 // Compatible receiver check failed: throw an Illegal Invocation exception. | 1320 // Compatible receiver check failed: throw an Illegal Invocation exception. |
1321 __ bind(&receiver_check_failed); | 1321 __ bind(&receiver_check_failed); |
1322 // Drop the arguments (including the receiver) | 1322 // Drop the arguments (including the receiver) |
1323 __ add(r0, r0, Operand(1)); | 1323 __ add(r0, r0, Operand(1)); |
1324 __ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); | 1324 __ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); |
1325 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0); | 1325 __ TailCallRuntime(Runtime::kThrowIllegalInvocation); |
1326 } | 1326 } |
1327 | 1327 |
1328 | 1328 |
1329 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1329 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1330 // Lookup the function in the JavaScript frame. | 1330 // Lookup the function in the JavaScript frame. |
1331 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1331 __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1332 { | 1332 { |
1333 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1333 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1334 // Pass function as argument. | 1334 // Pass function as argument. |
1335 __ push(r0); | 1335 __ push(r0); |
1336 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | 1336 __ CallRuntime(Runtime::kCompileForOnStackReplacement); |
1337 } | 1337 } |
1338 | 1338 |
1339 // If the code object is null, just return to the unoptimized code. | 1339 // If the code object is null, just return to the unoptimized code. |
1340 Label skip; | 1340 Label skip; |
1341 __ cmp(r0, Operand(Smi::FromInt(0))); | 1341 __ cmp(r0, Operand(Smi::FromInt(0))); |
1342 __ b(ne, &skip); | 1342 __ b(ne, &skip); |
1343 __ Ret(); | 1343 __ Ret(); |
1344 | 1344 |
1345 __ bind(&skip); | 1345 __ bind(&skip); |
1346 | 1346 |
(...skipping 23 matching lines...) Expand all Loading... |
1370 | 1370 |
1371 | 1371 |
1372 void Builtins::Generate_OsrAfterStackCheck(MacroAssembler* masm) { | 1372 void Builtins::Generate_OsrAfterStackCheck(MacroAssembler* masm) { |
1373 // We check the stack limit as indicator that recompilation might be done. | 1373 // We check the stack limit as indicator that recompilation might be done. |
1374 Label ok; | 1374 Label ok; |
1375 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 1375 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
1376 __ cmp(sp, Operand(ip)); | 1376 __ cmp(sp, Operand(ip)); |
1377 __ b(hs, &ok); | 1377 __ b(hs, &ok); |
1378 { | 1378 { |
1379 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1379 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1380 __ CallRuntime(Runtime::kStackGuard, 0); | 1380 __ CallRuntime(Runtime::kStackGuard); |
1381 } | 1381 } |
1382 __ Jump(masm->isolate()->builtins()->OnStackReplacement(), | 1382 __ Jump(masm->isolate()->builtins()->OnStackReplacement(), |
1383 RelocInfo::CODE_TARGET); | 1383 RelocInfo::CODE_TARGET); |
1384 | 1384 |
1385 __ bind(&ok); | 1385 __ bind(&ok); |
1386 __ Ret(); | 1386 __ Ret(); |
1387 } | 1387 } |
1388 | 1388 |
1389 | 1389 |
1390 // static | 1390 // static |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 __ bind(&no_arguments); | 1441 __ bind(&no_arguments); |
1442 { | 1442 { |
1443 __ mov(r0, Operand(0)); | 1443 __ mov(r0, Operand(0)); |
1444 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | 1444 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
1445 } | 1445 } |
1446 | 1446 |
1447 // 4c. The receiver is not callable, throw an appropriate TypeError. | 1447 // 4c. The receiver is not callable, throw an appropriate TypeError. |
1448 __ bind(&receiver_not_callable); | 1448 __ bind(&receiver_not_callable); |
1449 { | 1449 { |
1450 __ str(r1, MemOperand(sp, 0)); | 1450 __ str(r1, MemOperand(sp, 0)); |
1451 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1); | 1451 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); |
1452 } | 1452 } |
1453 } | 1453 } |
1454 | 1454 |
1455 | 1455 |
1456 // static | 1456 // static |
1457 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { | 1457 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
1458 // 1. Make sure we have at least one argument. | 1458 // 1. Make sure we have at least one argument. |
1459 // r0: actual number of arguments | 1459 // r0: actual number of arguments |
1460 { | 1460 { |
1461 Label done; | 1461 Label done; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 | 1540 |
1541 // 3a. Apply the target to the given argumentsList (passing undefined for | 1541 // 3a. Apply the target to the given argumentsList (passing undefined for |
1542 // new.target). | 1542 // new.target). |
1543 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); | 1543 __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); |
1544 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); | 1544 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
1545 | 1545 |
1546 // 3b. The target is not callable, throw an appropriate TypeError. | 1546 // 3b. The target is not callable, throw an appropriate TypeError. |
1547 __ bind(&target_not_callable); | 1547 __ bind(&target_not_callable); |
1548 { | 1548 { |
1549 __ str(r1, MemOperand(sp, 0)); | 1549 __ str(r1, MemOperand(sp, 0)); |
1550 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1); | 1550 __ TailCallRuntime(Runtime::kThrowApplyNonFunction); |
1551 } | 1551 } |
1552 } | 1552 } |
1553 | 1553 |
1554 | 1554 |
1555 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { | 1555 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { |
1556 // ----------- S t a t e ------------- | 1556 // ----------- S t a t e ------------- |
1557 // -- r0 : argc | 1557 // -- r0 : argc |
1558 // -- sp[0] : new.target (optional) | 1558 // -- sp[0] : new.target (optional) |
1559 // -- sp[4] : argumentsList | 1559 // -- sp[4] : argumentsList |
1560 // -- sp[8] : target | 1560 // -- sp[8] : target |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1603 __ tst(r4, Operand(1 << Map::kIsConstructor)); | 1603 __ tst(r4, Operand(1 << Map::kIsConstructor)); |
1604 __ b(eq, &new_target_not_constructor); | 1604 __ b(eq, &new_target_not_constructor); |
1605 | 1605 |
1606 // 4a. Construct the target with the given new.target and argumentsList. | 1606 // 4a. Construct the target with the given new.target and argumentsList. |
1607 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); | 1607 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); |
1608 | 1608 |
1609 // 4b. The target is not a constructor, throw an appropriate TypeError. | 1609 // 4b. The target is not a constructor, throw an appropriate TypeError. |
1610 __ bind(&target_not_constructor); | 1610 __ bind(&target_not_constructor); |
1611 { | 1611 { |
1612 __ str(r1, MemOperand(sp, 0)); | 1612 __ str(r1, MemOperand(sp, 0)); |
1613 __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1613 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); |
1614 } | 1614 } |
1615 | 1615 |
1616 // 4c. The new.target is not a constructor, throw an appropriate TypeError. | 1616 // 4c. The new.target is not a constructor, throw an appropriate TypeError. |
1617 __ bind(&new_target_not_constructor); | 1617 __ bind(&new_target_not_constructor); |
1618 { | 1618 { |
1619 __ str(r3, MemOperand(sp, 0)); | 1619 __ str(r3, MemOperand(sp, 0)); |
1620 __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1); | 1620 __ TailCallRuntime(Runtime::kThrowCalledNonCallable); |
1621 } | 1621 } |
1622 } | 1622 } |
1623 | 1623 |
1624 | 1624 |
1625 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | 1625 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, |
1626 Label* stack_overflow) { | 1626 Label* stack_overflow) { |
1627 // ----------- S t a t e ------------- | 1627 // ----------- S t a t e ------------- |
1628 // -- r0 : actual number of arguments | 1628 // -- r0 : actual number of arguments |
1629 // -- r1 : function (passed through to callee) | 1629 // -- r1 : function (passed through to callee) |
1630 // -- r2 : expected number of arguments | 1630 // -- r2 : expected number of arguments |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1699 | 1699 |
1700 // Check if argumentsList is a fast JSArray. | 1700 // Check if argumentsList is a fast JSArray. |
1701 __ CompareInstanceType(r2, ip, JS_ARRAY_TYPE); | 1701 __ CompareInstanceType(r2, ip, JS_ARRAY_TYPE); |
1702 __ b(eq, &create_array); | 1702 __ b(eq, &create_array); |
1703 | 1703 |
1704 // Ask the runtime to create the list (actually a FixedArray). | 1704 // Ask the runtime to create the list (actually a FixedArray). |
1705 __ bind(&create_runtime); | 1705 __ bind(&create_runtime); |
1706 { | 1706 { |
1707 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 1707 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
1708 __ Push(r1, r3, r0); | 1708 __ Push(r1, r3, r0); |
1709 __ CallRuntime(Runtime::kCreateListFromArrayLike, 1); | 1709 __ CallRuntime(Runtime::kCreateListFromArrayLike); |
1710 __ Pop(r1, r3); | 1710 __ Pop(r1, r3); |
1711 __ ldr(r2, FieldMemOperand(r0, FixedArray::kLengthOffset)); | 1711 __ ldr(r2, FieldMemOperand(r0, FixedArray::kLengthOffset)); |
1712 __ SmiUntag(r2); | 1712 __ SmiUntag(r2); |
1713 } | 1713 } |
1714 __ jmp(&done_create); | 1714 __ jmp(&done_create); |
1715 | 1715 |
1716 // Try to create the list from an arguments object. | 1716 // Try to create the list from an arguments object. |
1717 __ bind(&create_arguments); | 1717 __ bind(&create_arguments); |
1718 __ ldr(r2, | 1718 __ ldr(r2, |
1719 FieldMemOperand(r0, JSObject::kHeaderSize + | 1719 FieldMemOperand(r0, JSObject::kHeaderSize + |
(...skipping 29 matching lines...) Expand all Loading... |
1749 // Check the stack for overflow. We are not trying to catch interruptions | 1749 // Check the stack for overflow. We are not trying to catch interruptions |
1750 // (i.e. debug break and preemption) here, so check the "real stack limit". | 1750 // (i.e. debug break and preemption) here, so check the "real stack limit". |
1751 Label done; | 1751 Label done; |
1752 __ LoadRoot(ip, Heap::kRealStackLimitRootIndex); | 1752 __ LoadRoot(ip, Heap::kRealStackLimitRootIndex); |
1753 // Make ip the space we have left. The stack might already be overflowed | 1753 // Make ip the space we have left. The stack might already be overflowed |
1754 // here which will cause ip to become negative. | 1754 // here which will cause ip to become negative. |
1755 __ sub(ip, sp, ip); | 1755 __ sub(ip, sp, ip); |
1756 // Check if the arguments will overflow the stack. | 1756 // Check if the arguments will overflow the stack. |
1757 __ cmp(ip, Operand(r2, LSL, kPointerSizeLog2)); | 1757 __ cmp(ip, Operand(r2, LSL, kPointerSizeLog2)); |
1758 __ b(gt, &done); // Signed comparison. | 1758 __ b(gt, &done); // Signed comparison. |
1759 __ TailCallRuntime(Runtime::kThrowStackOverflow, 1); | 1759 __ TailCallRuntime(Runtime::kThrowStackOverflow); |
1760 __ bind(&done); | 1760 __ bind(&done); |
1761 } | 1761 } |
1762 | 1762 |
1763 // ----------- S t a t e ------------- | 1763 // ----------- S t a t e ------------- |
1764 // -- r1 : target | 1764 // -- r1 : target |
1765 // -- r0 : args (a FixedArray built from argumentsList) | 1765 // -- r0 : args (a FixedArray built from argumentsList) |
1766 // -- r2 : len (number of elements to push from args) | 1766 // -- r2 : len (number of elements to push from args) |
1767 // -- r3 : new.target (checked to be constructor or undefined) | 1767 // -- r3 : new.target (checked to be constructor or undefined) |
1768 // -- sp[0] : thisArgument | 1768 // -- sp[0] : thisArgument |
1769 // ----------------------------------- | 1769 // ----------------------------------- |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1887 ParameterCount actual(r0); | 1887 ParameterCount actual(r0); |
1888 ParameterCount expected(r2); | 1888 ParameterCount expected(r2); |
1889 __ InvokeFunctionCode(r1, no_reg, expected, actual, JUMP_FUNCTION, | 1889 __ InvokeFunctionCode(r1, no_reg, expected, actual, JUMP_FUNCTION, |
1890 CheckDebugStepCallWrapper()); | 1890 CheckDebugStepCallWrapper()); |
1891 | 1891 |
1892 // The function is a "classConstructor", need to raise an exception. | 1892 // The function is a "classConstructor", need to raise an exception. |
1893 __ bind(&class_constructor); | 1893 __ bind(&class_constructor); |
1894 { | 1894 { |
1895 FrameScope frame(masm, StackFrame::INTERNAL); | 1895 FrameScope frame(masm, StackFrame::INTERNAL); |
1896 __ push(r1); | 1896 __ push(r1); |
1897 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 1); | 1897 __ CallRuntime(Runtime::kThrowConstructorNonCallableError); |
1898 } | 1898 } |
1899 } | 1899 } |
1900 | 1900 |
1901 | 1901 |
1902 namespace { | 1902 namespace { |
1903 | 1903 |
1904 void Generate_PushBoundArguments(MacroAssembler* masm) { | 1904 void Generate_PushBoundArguments(MacroAssembler* masm) { |
1905 // ----------- S t a t e ------------- | 1905 // ----------- S t a t e ------------- |
1906 // -- r0 : the number of arguments (not including the receiver) | 1906 // -- r0 : the number of arguments (not including the receiver) |
1907 // -- r1 : target (checked to be a JSBoundFunction) | 1907 // -- r1 : target (checked to be a JSBoundFunction) |
(...skipping 23 matching lines...) Expand all Loading... |
1931 // Check the stack for overflow. We are not trying to catch interruptions | 1931 // Check the stack for overflow. We are not trying to catch interruptions |
1932 // (i.e. debug break and preemption) here, so check the "real stack | 1932 // (i.e. debug break and preemption) here, so check the "real stack |
1933 // limit". | 1933 // limit". |
1934 __ CompareRoot(sp, Heap::kRealStackLimitRootIndex); | 1934 __ CompareRoot(sp, Heap::kRealStackLimitRootIndex); |
1935 __ b(gt, &done); // Signed comparison. | 1935 __ b(gt, &done); // Signed comparison. |
1936 // Restore the stack pointer. | 1936 // Restore the stack pointer. |
1937 __ add(sp, sp, Operand(r4, LSL, kPointerSizeLog2)); | 1937 __ add(sp, sp, Operand(r4, LSL, kPointerSizeLog2)); |
1938 { | 1938 { |
1939 FrameScope scope(masm, StackFrame::MANUAL); | 1939 FrameScope scope(masm, StackFrame::MANUAL); |
1940 __ EnterFrame(StackFrame::INTERNAL); | 1940 __ EnterFrame(StackFrame::INTERNAL); |
1941 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 1941 __ CallRuntime(Runtime::kThrowStackOverflow); |
1942 } | 1942 } |
1943 __ bind(&done); | 1943 __ bind(&done); |
1944 } | 1944 } |
1945 | 1945 |
1946 // Relocate arguments down the stack. | 1946 // Relocate arguments down the stack. |
1947 { | 1947 { |
1948 Label loop, done_loop; | 1948 Label loop, done_loop; |
1949 __ mov(r5, Operand(0)); | 1949 __ mov(r5, Operand(0)); |
1950 __ bind(&loop); | 1950 __ bind(&loop); |
1951 __ cmp(r5, r0); | 1951 __ cmp(r5, r0); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, r1); | 2043 __ LoadNativeContextSlot(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, r1); |
2044 __ Jump(masm->isolate()->builtins()->CallFunction( | 2044 __ Jump(masm->isolate()->builtins()->CallFunction( |
2045 ConvertReceiverMode::kNotNullOrUndefined), | 2045 ConvertReceiverMode::kNotNullOrUndefined), |
2046 RelocInfo::CODE_TARGET); | 2046 RelocInfo::CODE_TARGET); |
2047 | 2047 |
2048 // 3. Call to something that is not callable. | 2048 // 3. Call to something that is not callable. |
2049 __ bind(&non_callable); | 2049 __ bind(&non_callable); |
2050 { | 2050 { |
2051 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); | 2051 FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
2052 __ Push(r1); | 2052 __ Push(r1); |
2053 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); | 2053 __ CallRuntime(Runtime::kThrowCalledNonCallable); |
2054 } | 2054 } |
2055 } | 2055 } |
2056 | 2056 |
2057 | 2057 |
2058 // static | 2058 // static |
2059 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { | 2059 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { |
2060 // ----------- S t a t e ------------- | 2060 // ----------- S t a t e ------------- |
2061 // -- r0 : the number of arguments (not including the receiver) | 2061 // -- r0 : the number of arguments (not including the receiver) |
2062 // -- r1 : the constructor to call (checked to be a JSFunction) | 2062 // -- r1 : the constructor to call (checked to be a JSFunction) |
2063 // -- r3 : the new target (checked to be a constructor) | 2063 // -- r3 : the new target (checked to be a constructor) |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2234 __ b(eq, &no_strong_error); | 2234 __ b(eq, &no_strong_error); |
2235 | 2235 |
2236 // What we really care about is the required number of arguments. | 2236 // What we really care about is the required number of arguments. |
2237 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kLengthOffset)); | 2237 __ ldr(r4, FieldMemOperand(r4, SharedFunctionInfo::kLengthOffset)); |
2238 __ cmp(r0, Operand::SmiUntag(r4)); | 2238 __ cmp(r0, Operand::SmiUntag(r4)); |
2239 __ b(ge, &no_strong_error); | 2239 __ b(ge, &no_strong_error); |
2240 | 2240 |
2241 { | 2241 { |
2242 FrameScope frame(masm, StackFrame::MANUAL); | 2242 FrameScope frame(masm, StackFrame::MANUAL); |
2243 EnterArgumentsAdaptorFrame(masm); | 2243 EnterArgumentsAdaptorFrame(masm); |
2244 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); | 2244 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments); |
2245 } | 2245 } |
2246 | 2246 |
2247 __ bind(&no_strong_error); | 2247 __ bind(&no_strong_error); |
2248 EnterArgumentsAdaptorFrame(masm); | 2248 EnterArgumentsAdaptorFrame(masm); |
2249 ArgumentAdaptorStackCheck(masm, &stack_overflow); | 2249 ArgumentAdaptorStackCheck(masm, &stack_overflow); |
2250 | 2250 |
2251 // Calculate copy start address into r0 and copy end address is fp. | 2251 // Calculate copy start address into r0 and copy end address is fp. |
2252 // r0: actual number of arguments as a smi | 2252 // r0: actual number of arguments as a smi |
2253 // r1: function | 2253 // r1: function |
2254 // r2: expected number of arguments | 2254 // r2: expected number of arguments |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2306 // ------------------------------------------- | 2306 // ------------------------------------------- |
2307 // Dont adapt arguments. | 2307 // Dont adapt arguments. |
2308 // ------------------------------------------- | 2308 // ------------------------------------------- |
2309 __ bind(&dont_adapt_arguments); | 2309 __ bind(&dont_adapt_arguments); |
2310 __ ldr(r4, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 2310 __ ldr(r4, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
2311 __ Jump(r4); | 2311 __ Jump(r4); |
2312 | 2312 |
2313 __ bind(&stack_overflow); | 2313 __ bind(&stack_overflow); |
2314 { | 2314 { |
2315 FrameScope frame(masm, StackFrame::MANUAL); | 2315 FrameScope frame(masm, StackFrame::MANUAL); |
2316 __ CallRuntime(Runtime::kThrowStackOverflow, 0); | 2316 __ CallRuntime(Runtime::kThrowStackOverflow); |
2317 __ bkpt(0); | 2317 __ bkpt(0); |
2318 } | 2318 } |
2319 } | 2319 } |
2320 | 2320 |
2321 | 2321 |
2322 #undef __ | 2322 #undef __ |
2323 | 2323 |
2324 } // namespace internal | 2324 } // namespace internal |
2325 } // namespace v8 | 2325 } // namespace v8 |
2326 | 2326 |
2327 #endif // V8_TARGET_ARCH_ARM | 2327 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |