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

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

Issue 1553703002: [runtime] TailCallRuntime and CallRuntime should use default argument counts (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@2015-12-29_TailCallRuntime_default_result_size_1_1550923002
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_IA32 5 #if V8_TARGET_ARCH_IA32
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/codegen.h" 8 #include "src/codegen.h"
9 #include "src/deoptimizer.h" 9 #include "src/deoptimizer.h"
10 #include "src/full-codegen/full-codegen.h" 10 #include "src/full-codegen/full-codegen.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 __ InitializeFieldsWithFiller(ecx, edi, edx); 234 __ InitializeFieldsWithFiller(ecx, edi, edx);
235 235
236 __ pop(esi); // Restore allocation count value before decreasing. 236 __ pop(esi); // Restore allocation count value before decreasing.
237 __ cmp(esi, Map::kSlackTrackingCounterEnd); 237 __ cmp(esi, Map::kSlackTrackingCounterEnd);
238 __ j(not_equal, &allocated); 238 __ j(not_equal, &allocated);
239 239
240 // Push the object to the stack, and then the initial map as 240 // Push the object to the stack, and then the initial map as
241 // an argument to the runtime call. 241 // an argument to the runtime call.
242 __ push(ebx); 242 __ push(ebx);
243 __ push(eax); // initial map 243 __ push(eax); // initial map
244 __ CallRuntime(Runtime::kFinalizeInstanceSize, 1); 244 __ CallRuntime(Runtime::kFinalizeInstanceSize);
245 __ pop(ebx); 245 __ pop(ebx);
246 246
247 // Continue with JSObject being successfully allocated 247 // Continue with JSObject being successfully allocated
248 // ebx: JSObject (tagged) 248 // ebx: JSObject (tagged)
249 __ jmp(&allocated); 249 __ jmp(&allocated);
250 250
251 __ bind(&no_inobject_slack_tracking); 251 __ bind(&no_inobject_slack_tracking);
252 } 252 }
253 253
254 __ InitializeFieldsWithFiller(ecx, edi, edx); 254 __ InitializeFieldsWithFiller(ecx, edi, edx);
255 255
256 // Continue with JSObject being successfully allocated 256 // Continue with JSObject being successfully allocated
257 // ebx: JSObject (tagged) 257 // ebx: JSObject (tagged)
258 __ jmp(&allocated); 258 __ jmp(&allocated);
259 } 259 }
260 260
261 // Allocate the new receiver object using the runtime call. 261 // Allocate the new receiver object using the runtime call.
262 // edx: new target 262 // edx: new target
263 __ bind(&rt_call); 263 __ bind(&rt_call);
264 int offset = kPointerSize; 264 int offset = kPointerSize;
265 265
266 // Must restore esi (context) and edi (constructor) before calling 266 // Must restore esi (context) and edi (constructor) before calling
267 // runtime. 267 // runtime.
268 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 268 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
269 __ mov(edi, Operand(esp, offset)); 269 __ mov(edi, Operand(esp, offset));
270 __ push(edi); // constructor function 270 __ push(edi); // constructor function
271 __ push(edx); // new target 271 __ push(edx); // new target
272 __ CallRuntime(Runtime::kNewObject, 2); 272 __ CallRuntime(Runtime::kNewObject);
273 __ mov(ebx, eax); // store result in ebx 273 __ mov(ebx, eax); // store result in ebx
274 274
275 // New object allocated. 275 // New object allocated.
276 // ebx: newly allocated object 276 // ebx: newly allocated object
277 __ bind(&allocated); 277 __ bind(&allocated);
278 278
279 // Restore the parameters. 279 // Restore the parameters.
280 __ pop(edx); // new.target 280 __ pop(edx); // new.target
281 __ pop(edi); // Constructor function. 281 __ pop(edi); // Constructor function.
282 282
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 382
383 383
384 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) { 384 void Builtins::Generate_JSBuiltinsConstructStub(MacroAssembler* masm) {
385 Generate_JSConstructStubHelper(masm, false, false); 385 Generate_JSConstructStubHelper(masm, false, false);
386 } 386 }
387 387
388 388
389 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) { 389 void Builtins::Generate_ConstructedNonConstructable(MacroAssembler* masm) {
390 FrameScope scope(masm, StackFrame::INTERNAL); 390 FrameScope scope(masm, StackFrame::INTERNAL);
391 __ push(edi); 391 __ push(edi);
392 __ CallRuntime(Runtime::kThrowConstructedNonConstructable, 1); 392 __ CallRuntime(Runtime::kThrowConstructedNonConstructable);
393 } 393 }
394 394
395 395
396 enum IsTagged { kEaxIsSmiTagged, kEaxIsUntaggedInt }; 396 enum IsTagged { kEaxIsSmiTagged, kEaxIsUntaggedInt };
397 397
398 398
399 // Clobbers ecx, edx, edi; preserves all other registers. 399 // Clobbers ecx, edx, edi; preserves all other registers.
400 static void Generate_CheckStackOverflow(MacroAssembler* masm, 400 static void Generate_CheckStackOverflow(MacroAssembler* masm,
401 IsTagged eax_is_tagged) { 401 IsTagged eax_is_tagged) {
402 // eax : the number of items to be pushed to the stack 402 // eax : the number of items to be pushed to the stack
(...skipping 12 matching lines...) Expand all
415 // Make edx the space we need for the array when it is unrolled onto the 415 // Make edx the space we need for the array when it is unrolled onto the
416 // stack. 416 // stack.
417 __ mov(edx, eax); 417 __ mov(edx, eax);
418 int smi_tag = eax_is_tagged == kEaxIsSmiTagged ? kSmiTagSize : 0; 418 int smi_tag = eax_is_tagged == kEaxIsSmiTagged ? kSmiTagSize : 0;
419 __ shl(edx, kPointerSizeLog2 - smi_tag); 419 __ shl(edx, kPointerSizeLog2 - smi_tag);
420 // Check if the arguments will overflow the stack. 420 // Check if the arguments will overflow the stack.
421 __ cmp(ecx, edx); 421 __ cmp(ecx, edx);
422 __ j(greater, &okay); // Signed comparison. 422 __ j(greater, &okay); // Signed comparison.
423 423
424 // Out of stack space. 424 // Out of stack space.
425 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 425 __ CallRuntime(Runtime::kThrowStackOverflow);
426 426
427 __ bind(&okay); 427 __ bind(&okay);
428 } 428 }
429 429
430 430
431 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm, 431 static void Generate_JSEntryTrampolineHelper(MacroAssembler* masm,
432 bool is_construct) { 432 bool is_construct) {
433 ProfileEntryHookStub::MaybeCallEntryHook(masm); 433 ProfileEntryHookStub::MaybeCallEntryHook(masm);
434 434
435 // Clear the context before we push it when entering the internal frame. 435 // Clear the context before we push it when entering the internal frame.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 BytecodeArray::kFrameSizeOffset)); 552 BytecodeArray::kFrameSizeOffset));
553 553
554 // Do a stack check to ensure we don't go over the limit. 554 // Do a stack check to ensure we don't go over the limit.
555 Label ok; 555 Label ok;
556 __ mov(ecx, esp); 556 __ mov(ecx, esp);
557 __ sub(ecx, ebx); 557 __ sub(ecx, ebx);
558 ExternalReference stack_limit = 558 ExternalReference stack_limit =
559 ExternalReference::address_of_real_stack_limit(masm->isolate()); 559 ExternalReference::address_of_real_stack_limit(masm->isolate());
560 __ cmp(ecx, Operand::StaticVariable(stack_limit)); 560 __ cmp(ecx, Operand::StaticVariable(stack_limit));
561 __ j(above_equal, &ok); 561 __ j(above_equal, &ok);
562 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 562 __ CallRuntime(Runtime::kThrowStackOverflow);
563 __ bind(&ok); 563 __ bind(&ok);
564 564
565 // If ok, push undefined as the initial value for all register file entries. 565 // If ok, push undefined as the initial value for all register file entries.
566 Label loop_header; 566 Label loop_header;
567 Label loop_check; 567 Label loop_check;
568 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value())); 568 __ mov(eax, Immediate(masm->isolate()->factory()->undefined_value()));
569 __ jmp(&loop_check); 569 __ jmp(&loop_check);
570 __ bind(&loop_header); 570 __ bind(&loop_header);
571 // TODO(rmcilroy): Consider doing more than one push per loop iteration. 571 // TODO(rmcilroy): Consider doing more than one push per loop iteration.
572 __ push(eax); 572 __ push(eax);
(...skipping 11 matching lines...) Expand all
584 // - Code aging of the BytecodeArray object. 584 // - Code aging of the BytecodeArray object.
585 585
586 // Perform stack guard check. 586 // Perform stack guard check.
587 { 587 {
588 Label ok; 588 Label ok;
589 ExternalReference stack_limit = 589 ExternalReference stack_limit =
590 ExternalReference::address_of_stack_limit(masm->isolate()); 590 ExternalReference::address_of_stack_limit(masm->isolate());
591 __ cmp(esp, Operand::StaticVariable(stack_limit)); 591 __ cmp(esp, Operand::StaticVariable(stack_limit));
592 __ j(above_equal, &ok); 592 __ j(above_equal, &ok);
593 __ push(kInterpreterBytecodeArrayRegister); 593 __ push(kInterpreterBytecodeArrayRegister);
594 __ CallRuntime(Runtime::kStackGuard, 0); 594 __ CallRuntime(Runtime::kStackGuard);
595 __ pop(kInterpreterBytecodeArrayRegister); 595 __ pop(kInterpreterBytecodeArrayRegister);
596 __ bind(&ok); 596 __ bind(&ok);
597 } 597 }
598 598
599 // Load accumulator, register file, bytecode offset, dispatch table into 599 // Load accumulator, register file, bytecode offset, dispatch table into
600 // registers. 600 // registers.
601 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex); 601 __ LoadRoot(kInterpreterAccumulatorRegister, Heap::kUndefinedValueRootIndex);
602 __ mov(kInterpreterRegisterFileRegister, ebp); 602 __ mov(kInterpreterRegisterFileRegister, ebp);
603 __ add(kInterpreterRegisterFileRegister, 603 __ add(kInterpreterRegisterFileRegister,
604 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); 604 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 static void Generate_InterpreterNotifyDeoptimizedHelper( 742 static void Generate_InterpreterNotifyDeoptimizedHelper(
743 MacroAssembler* masm, Deoptimizer::BailoutType type) { 743 MacroAssembler* masm, Deoptimizer::BailoutType type) {
744 // Enter an internal frame. 744 // Enter an internal frame.
745 { 745 {
746 FrameScope scope(masm, StackFrame::INTERNAL); 746 FrameScope scope(masm, StackFrame::INTERNAL);
747 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register. 747 __ Push(kInterpreterAccumulatorRegister); // Save accumulator register.
748 748
749 // Pass the deoptimization type to the runtime system. 749 // Pass the deoptimization type to the runtime system.
750 __ Push(Smi::FromInt(static_cast<int>(type))); 750 __ Push(Smi::FromInt(static_cast<int>(type)));
751 751
752 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); 752 __ CallRuntime(Runtime::kNotifyDeoptimized);
753 753
754 __ Pop(kInterpreterAccumulatorRegister); // Restore accumulator register. 754 __ Pop(kInterpreterAccumulatorRegister); // Restore accumulator register.
755 // Tear down internal frame. 755 // Tear down internal frame.
756 } 756 }
757 757
758 // Initialize register file register. 758 // Initialize register file register.
759 __ mov(kInterpreterRegisterFileRegister, ebp); 759 __ mov(kInterpreterRegisterFileRegister, ebp);
760 __ add(kInterpreterRegisterFileRegister, 760 __ add(kInterpreterRegisterFileRegister,
761 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp)); 761 Immediate(InterpreterFrameConstants::kRegisterFilePointerFromFp));
762 762
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm, 925 static void Generate_NotifyStubFailureHelper(MacroAssembler* masm,
926 SaveFPRegsMode save_doubles) { 926 SaveFPRegsMode save_doubles) {
927 // Enter an internal frame. 927 // Enter an internal frame.
928 { 928 {
929 FrameScope scope(masm, StackFrame::INTERNAL); 929 FrameScope scope(masm, StackFrame::INTERNAL);
930 930
931 // Preserve registers across notification, this is important for compiled 931 // Preserve registers across notification, this is important for compiled
932 // stubs that tail call the runtime on deopts passing their parameters in 932 // stubs that tail call the runtime on deopts passing their parameters in
933 // registers. 933 // registers.
934 __ pushad(); 934 __ pushad();
935 __ CallRuntime(Runtime::kNotifyStubFailure, 0, save_doubles); 935 __ CallRuntime(Runtime::kNotifyStubFailure, save_doubles);
936 __ popad(); 936 __ popad();
937 // Tear down internal frame. 937 // Tear down internal frame.
938 } 938 }
939 939
940 __ pop(MemOperand(esp, 0)); // Ignore state offset 940 __ pop(MemOperand(esp, 0)); // Ignore state offset
941 __ ret(0); // Return to IC Miss stub, continuation still on stack. 941 __ ret(0); // Return to IC Miss stub, continuation still on stack.
942 } 942 }
943 943
944 944
945 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { 945 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) {
946 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); 946 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs);
947 } 947 }
948 948
949 949
950 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { 950 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) {
951 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); 951 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs);
952 } 952 }
953 953
954 954
955 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, 955 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm,
956 Deoptimizer::BailoutType type) { 956 Deoptimizer::BailoutType type) {
957 { 957 {
958 FrameScope scope(masm, StackFrame::INTERNAL); 958 FrameScope scope(masm, StackFrame::INTERNAL);
959 959
960 // Pass deoptimization type to the runtime system. 960 // Pass deoptimization type to the runtime system.
961 __ push(Immediate(Smi::FromInt(static_cast<int>(type)))); 961 __ push(Immediate(Smi::FromInt(static_cast<int>(type))));
962 __ CallRuntime(Runtime::kNotifyDeoptimized, 1); 962 __ CallRuntime(Runtime::kNotifyDeoptimized);
963 963
964 // Tear down internal frame. 964 // Tear down internal frame.
965 } 965 }
966 966
967 // Get the full codegen state from the stack and untag it. 967 // Get the full codegen state from the stack and untag it.
968 __ mov(ecx, Operand(esp, 1 * kPointerSize)); 968 __ mov(ecx, Operand(esp, 1 * kPointerSize));
969 __ SmiUntag(ecx); 969 __ SmiUntag(ecx);
970 970
971 // Switch on the state. 971 // Switch on the state.
972 Label not_no_registers, not_tos_eax; 972 Label not_no_registers, not_tos_eax;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1065 __ bind(&no_arguments); 1065 __ bind(&no_arguments);
1066 { 1066 {
1067 __ Set(eax, 0); 1067 __ Set(eax, 0);
1068 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); 1068 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET);
1069 } 1069 }
1070 1070
1071 // 4c. The receiver is not callable, throw an appropriate TypeError. 1071 // 4c. The receiver is not callable, throw an appropriate TypeError.
1072 __ bind(&receiver_not_callable); 1072 __ bind(&receiver_not_callable);
1073 { 1073 {
1074 __ mov(Operand(esp, kPointerSize), edi); 1074 __ mov(Operand(esp, kPointerSize), edi);
1075 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1); 1075 __ TailCallRuntime(Runtime::kThrowApplyNonFunction);
1076 } 1076 }
1077 } 1077 }
1078 1078
1079 1079
1080 // static 1080 // static
1081 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { 1081 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) {
1082 // Stack Layout: 1082 // Stack Layout:
1083 // esp[0] : Return address 1083 // esp[0] : Return address
1084 // esp[8] : Argument n 1084 // esp[8] : Argument n
1085 // esp[16] : Argument n-1 1085 // esp[16] : Argument n-1
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 1174
1175 // 3a. Apply the target to the given argumentsList (passing undefined for 1175 // 3a. Apply the target to the given argumentsList (passing undefined for
1176 // new.target). 1176 // new.target).
1177 __ LoadRoot(edx, Heap::kUndefinedValueRootIndex); 1177 __ LoadRoot(edx, Heap::kUndefinedValueRootIndex);
1178 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); 1178 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
1179 1179
1180 // 3b. The target is not callable, throw an appropriate TypeError. 1180 // 3b. The target is not callable, throw an appropriate TypeError.
1181 __ bind(&target_not_callable); 1181 __ bind(&target_not_callable);
1182 { 1182 {
1183 __ mov(Operand(esp, kPointerSize), edi); 1183 __ mov(Operand(esp, kPointerSize), edi);
1184 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1); 1184 __ TailCallRuntime(Runtime::kThrowApplyNonFunction);
1185 } 1185 }
1186 } 1186 }
1187 1187
1188 1188
1189 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) { 1189 void Builtins::Generate_ReflectConstruct(MacroAssembler* masm) {
1190 // ----------- S t a t e ------------- 1190 // ----------- S t a t e -------------
1191 // -- eax : argc 1191 // -- eax : argc
1192 // -- esp[0] : return address 1192 // -- esp[0] : return address
1193 // -- esp[4] : new.target (optional) 1193 // -- esp[4] : new.target (optional)
1194 // -- esp[8] : argumentsList 1194 // -- esp[8] : argumentsList
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor); 1244 __ test_b(FieldOperand(ecx, Map::kBitFieldOffset), 1 << Map::kIsConstructor);
1245 __ j(zero, &new_target_not_constructor, Label::kNear); 1245 __ j(zero, &new_target_not_constructor, Label::kNear);
1246 1246
1247 // 4a. Construct the target with the given new.target and argumentsList. 1247 // 4a. Construct the target with the given new.target and argumentsList.
1248 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET); 1248 __ Jump(masm->isolate()->builtins()->Apply(), RelocInfo::CODE_TARGET);
1249 1249
1250 // 4b. The target is not a constructor, throw an appropriate TypeError. 1250 // 4b. The target is not a constructor, throw an appropriate TypeError.
1251 __ bind(&target_not_constructor); 1251 __ bind(&target_not_constructor);
1252 { 1252 {
1253 __ mov(Operand(esp, kPointerSize), edi); 1253 __ mov(Operand(esp, kPointerSize), edi);
1254 __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1); 1254 __ TailCallRuntime(Runtime::kThrowCalledNonCallable);
1255 } 1255 }
1256 1256
1257 // 4c. The new.target is not a constructor, throw an appropriate TypeError. 1257 // 4c. The new.target is not a constructor, throw an appropriate TypeError.
1258 __ bind(&new_target_not_constructor); 1258 __ bind(&new_target_not_constructor);
1259 { 1259 {
1260 __ mov(Operand(esp, kPointerSize), edx); 1260 __ mov(Operand(esp, kPointerSize), edx);
1261 __ TailCallRuntime(Runtime::kThrowCalledNonCallable, 1); 1261 __ TailCallRuntime(Runtime::kThrowCalledNonCallable);
1262 } 1262 }
1263 } 1263 }
1264 1264
1265 1265
1266 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { 1266 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) {
1267 // ----------- S t a t e ------------- 1267 // ----------- S t a t e -------------
1268 // -- eax : argc 1268 // -- eax : argc
1269 // -- esp[0] : return address 1269 // -- esp[0] : return address
1270 // -- esp[4] : last argument 1270 // -- esp[4] : last argument
1271 // ----------------------------------- 1271 // -----------------------------------
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 ToStringStub stub(masm->isolate()); 1370 ToStringStub stub(masm->isolate());
1371 __ TailCallStub(&stub); 1371 __ TailCallStub(&stub);
1372 } 1372 }
1373 1373
1374 // 3b. Convert symbol in eax to a string. 1374 // 3b. Convert symbol in eax to a string.
1375 __ bind(&symbol_descriptive_string); 1375 __ bind(&symbol_descriptive_string);
1376 { 1376 {
1377 __ PopReturnAddressTo(ecx); 1377 __ PopReturnAddressTo(ecx);
1378 __ Push(eax); 1378 __ Push(eax);
1379 __ PushReturnAddressFrom(ecx); 1379 __ PushReturnAddressFrom(ecx);
1380 __ TailCallRuntime(Runtime::kSymbolDescriptiveString, 1); 1380 __ TailCallRuntime(Runtime::kSymbolDescriptiveString);
1381 } 1381 }
1382 } 1382 }
1383 1383
1384 1384
1385 // static 1385 // static
1386 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { 1386 void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) {
1387 // ----------- S t a t e ------------- 1387 // ----------- S t a t e -------------
1388 // -- eax : number of arguments 1388 // -- eax : number of arguments
1389 // -- edi : constructor function 1389 // -- edi : constructor function
1390 // -- edx : new target 1390 // -- edx : new target
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 __ Ret(); 1456 __ Ret();
1457 } 1457 }
1458 1458
1459 // 5. Fallback to the runtime to create new object. 1459 // 5. Fallback to the runtime to create new object.
1460 __ bind(&new_object); 1460 __ bind(&new_object);
1461 { 1461 {
1462 FrameScope scope(masm, StackFrame::INTERNAL); 1462 FrameScope scope(masm, StackFrame::INTERNAL);
1463 __ Push(ebx); // the first argument 1463 __ Push(ebx); // the first argument
1464 __ Push(edi); // constructor function 1464 __ Push(edi); // constructor function
1465 __ Push(edx); // new target 1465 __ Push(edx); // new target
1466 __ CallRuntime(Runtime::kNewObject, 2); 1466 __ CallRuntime(Runtime::kNewObject);
1467 __ Pop(FieldOperand(eax, JSValue::kValueOffset)); 1467 __ Pop(FieldOperand(eax, JSValue::kValueOffset));
1468 } 1468 }
1469 __ Ret(); 1469 __ Ret();
1470 } 1470 }
1471 1471
1472 1472
1473 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, 1473 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm,
1474 Label* stack_overflow) { 1474 Label* stack_overflow) {
1475 // ----------- S t a t e ------------- 1475 // ----------- S t a t e -------------
1476 // -- eax : actual number of arguments 1476 // -- eax : actual number of arguments
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 __ CmpInstanceType(ecx, JS_ARRAY_TYPE); 1562 __ CmpInstanceType(ecx, JS_ARRAY_TYPE);
1563 __ j(equal, &create_array); 1563 __ j(equal, &create_array);
1564 1564
1565 // Ask the runtime to create the list (actually a FixedArray). 1565 // Ask the runtime to create the list (actually a FixedArray).
1566 __ bind(&create_runtime); 1566 __ bind(&create_runtime);
1567 { 1567 {
1568 FrameScope scope(masm, StackFrame::INTERNAL); 1568 FrameScope scope(masm, StackFrame::INTERNAL);
1569 __ Push(edi); 1569 __ Push(edi);
1570 __ Push(edx); 1570 __ Push(edx);
1571 __ Push(eax); 1571 __ Push(eax);
1572 __ CallRuntime(Runtime::kCreateListFromArrayLike, 1); 1572 __ CallRuntime(Runtime::kCreateListFromArrayLike);
1573 __ Pop(edx); 1573 __ Pop(edx);
1574 __ Pop(edi); 1574 __ Pop(edi);
1575 __ mov(ebx, FieldOperand(eax, FixedArray::kLengthOffset)); 1575 __ mov(ebx, FieldOperand(eax, FixedArray::kLengthOffset));
1576 __ SmiUntag(ebx); 1576 __ SmiUntag(ebx);
1577 } 1577 }
1578 __ jmp(&done_create); 1578 __ jmp(&done_create);
1579 1579
1580 // Try to create the list from an arguments object. 1580 // Try to create the list from an arguments object.
1581 __ bind(&create_arguments); 1581 __ bind(&create_arguments);
1582 __ mov(ebx, 1582 __ mov(ebx,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 ExternalReference::address_of_real_stack_limit(masm->isolate()); 1616 ExternalReference::address_of_real_stack_limit(masm->isolate());
1617 __ mov(ecx, Operand::StaticVariable(real_stack_limit)); 1617 __ mov(ecx, Operand::StaticVariable(real_stack_limit));
1618 // Make ecx the space we have left. The stack might already be overflowed 1618 // Make ecx the space we have left. The stack might already be overflowed
1619 // here which will cause ecx to become negative. 1619 // here which will cause ecx to become negative.
1620 __ neg(ecx); 1620 __ neg(ecx);
1621 __ add(ecx, esp); 1621 __ add(ecx, esp);
1622 __ sar(ecx, kPointerSizeLog2); 1622 __ sar(ecx, kPointerSizeLog2);
1623 // Check if the arguments will overflow the stack. 1623 // Check if the arguments will overflow the stack.
1624 __ cmp(ecx, ebx); 1624 __ cmp(ecx, ebx);
1625 __ j(greater, &done, Label::kNear); // Signed comparison. 1625 __ j(greater, &done, Label::kNear); // Signed comparison.
1626 __ TailCallRuntime(Runtime::kThrowStackOverflow, 1); 1626 __ TailCallRuntime(Runtime::kThrowStackOverflow);
1627 __ bind(&done); 1627 __ bind(&done);
1628 } 1628 }
1629 1629
1630 // ----------- S t a t e ------------- 1630 // ----------- S t a t e -------------
1631 // -- edi : target 1631 // -- edi : target
1632 // -- eax : args (a FixedArray built from argumentsList) 1632 // -- eax : args (a FixedArray built from argumentsList)
1633 // -- ebx : len (number of elements to push from args) 1633 // -- ebx : len (number of elements to push from args)
1634 // -- edx : new.target (checked to be constructor or undefined) 1634 // -- edx : new.target (checked to be constructor or undefined)
1635 // -- esp[0] : return address. 1635 // -- esp[0] : return address.
1636 // -- esp[4] : thisArgument 1636 // -- esp[4] : thisArgument
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1760 __ SmiUntag(ebx); 1760 __ SmiUntag(ebx);
1761 ParameterCount actual(eax); 1761 ParameterCount actual(eax);
1762 ParameterCount expected(ebx); 1762 ParameterCount expected(ebx);
1763 __ InvokeFunctionCode(edi, no_reg, expected, actual, JUMP_FUNCTION, 1763 __ InvokeFunctionCode(edi, no_reg, expected, actual, JUMP_FUNCTION,
1764 CheckDebugStepCallWrapper()); 1764 CheckDebugStepCallWrapper());
1765 // The function is a "classConstructor", need to raise an exception. 1765 // The function is a "classConstructor", need to raise an exception.
1766 __ bind(&class_constructor); 1766 __ bind(&class_constructor);
1767 { 1767 {
1768 FrameScope frame(masm, StackFrame::INTERNAL); 1768 FrameScope frame(masm, StackFrame::INTERNAL);
1769 __ push(edi); 1769 __ push(edi);
1770 __ CallRuntime(Runtime::kThrowConstructorNonCallableError, 1); 1770 __ CallRuntime(Runtime::kThrowConstructorNonCallableError);
1771 } 1771 }
1772 } 1772 }
1773 1773
1774 1774
1775 namespace { 1775 namespace {
1776 1776
1777 void Generate_PushBoundArguments(MacroAssembler* masm) { 1777 void Generate_PushBoundArguments(MacroAssembler* masm) {
1778 // ----------- S t a t e ------------- 1778 // ----------- S t a t e -------------
1779 // -- eax : the number of arguments (not including the receiver) 1779 // -- eax : the number of arguments (not including the receiver)
1780 // -- edx : new.target (only in case of [[Construct]]) 1780 // -- edx : new.target (only in case of [[Construct]])
(...skipping 24 matching lines...) Expand all
1805 // Check the stack for overflow. We are not trying to catch interruptions 1805 // Check the stack for overflow. We are not trying to catch interruptions
1806 // (i.e. debug break and preemption) here, so check the "real stack 1806 // (i.e. debug break and preemption) here, so check the "real stack
1807 // limit". 1807 // limit".
1808 __ CompareRoot(esp, ecx, Heap::kRealStackLimitRootIndex); 1808 __ CompareRoot(esp, ecx, Heap::kRealStackLimitRootIndex);
1809 __ j(greater, &done, Label::kNear); // Signed comparison. 1809 __ j(greater, &done, Label::kNear); // Signed comparison.
1810 // Restore the stack pointer. 1810 // Restore the stack pointer.
1811 __ lea(esp, Operand(esp, ebx, times_pointer_size, 0)); 1811 __ lea(esp, Operand(esp, ebx, times_pointer_size, 0));
1812 { 1812 {
1813 FrameScope scope(masm, StackFrame::MANUAL); 1813 FrameScope scope(masm, StackFrame::MANUAL);
1814 __ EnterFrame(StackFrame::INTERNAL); 1814 __ EnterFrame(StackFrame::INTERNAL);
1815 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 1815 __ CallRuntime(Runtime::kThrowStackOverflow);
1816 } 1816 }
1817 __ bind(&done); 1817 __ bind(&done);
1818 } 1818 }
1819 1819
1820 // Adjust effective number of arguments to include return address. 1820 // Adjust effective number of arguments to include return address.
1821 __ inc(eax); 1821 __ inc(eax);
1822 1822
1823 // Relocate arguments and return address down the stack. 1823 // Relocate arguments and return address down the stack.
1824 { 1824 {
1825 Label loop; 1825 Label loop;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, edi); 1925 __ LoadGlobalFunction(Context::CALL_AS_FUNCTION_DELEGATE_INDEX, edi);
1926 __ Jump(masm->isolate()->builtins()->CallFunction( 1926 __ Jump(masm->isolate()->builtins()->CallFunction(
1927 ConvertReceiverMode::kNotNullOrUndefined), 1927 ConvertReceiverMode::kNotNullOrUndefined),
1928 RelocInfo::CODE_TARGET); 1928 RelocInfo::CODE_TARGET);
1929 1929
1930 // 3. Call to something that is not callable. 1930 // 3. Call to something that is not callable.
1931 __ bind(&non_callable); 1931 __ bind(&non_callable);
1932 { 1932 {
1933 FrameScope scope(masm, StackFrame::INTERNAL); 1933 FrameScope scope(masm, StackFrame::INTERNAL);
1934 __ Push(edi); 1934 __ Push(edi);
1935 __ CallRuntime(Runtime::kThrowCalledNonCallable, 1); 1935 __ CallRuntime(Runtime::kThrowCalledNonCallable);
1936 } 1936 }
1937 } 1937 }
1938 1938
1939 1939
1940 // static 1940 // static
1941 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) { 1941 void Builtins::Generate_ConstructFunction(MacroAssembler* masm) {
1942 // ----------- S t a t e ------------- 1942 // ----------- S t a t e -------------
1943 // -- eax : the number of arguments (not including the receiver) 1943 // -- eax : the number of arguments (not including the receiver)
1944 // -- edx : the new target (checked to be a constructor) 1944 // -- edx : the new target (checked to be a constructor)
1945 // -- edi : the constructor to call (checked to be a JSFunction) 1945 // -- edi : the constructor to call (checked to be a JSFunction)
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2112 2112
2113 // What we really care about is the required number of arguments. 2113 // What we really care about is the required number of arguments.
2114 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kLengthOffset)); 2114 __ mov(ecx, FieldOperand(ecx, SharedFunctionInfo::kLengthOffset));
2115 __ SmiUntag(ecx); 2115 __ SmiUntag(ecx);
2116 __ cmp(eax, ecx); 2116 __ cmp(eax, ecx);
2117 __ j(greater_equal, &no_strong_error, Label::kNear); 2117 __ j(greater_equal, &no_strong_error, Label::kNear);
2118 2118
2119 { 2119 {
2120 FrameScope frame(masm, StackFrame::MANUAL); 2120 FrameScope frame(masm, StackFrame::MANUAL);
2121 EnterArgumentsAdaptorFrame(masm); 2121 EnterArgumentsAdaptorFrame(masm);
2122 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments, 0); 2122 __ CallRuntime(Runtime::kThrowStrongModeTooFewArguments);
2123 } 2123 }
2124 2124
2125 __ bind(&no_strong_error); 2125 __ bind(&no_strong_error);
2126 EnterArgumentsAdaptorFrame(masm); 2126 EnterArgumentsAdaptorFrame(masm);
2127 ArgumentsAdaptorStackCheck(masm, &stack_overflow); 2127 ArgumentsAdaptorStackCheck(masm, &stack_overflow);
2128 2128
2129 // Remember expected arguments in ecx. 2129 // Remember expected arguments in ecx.
2130 __ mov(ecx, ebx); 2130 __ mov(ecx, ebx);
2131 2131
2132 // Copy receiver and all actual arguments. 2132 // Copy receiver and all actual arguments.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2178 // ------------------------------------------- 2178 // -------------------------------------------
2179 // Dont adapt arguments. 2179 // Dont adapt arguments.
2180 // ------------------------------------------- 2180 // -------------------------------------------
2181 __ bind(&dont_adapt_arguments); 2181 __ bind(&dont_adapt_arguments);
2182 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset)); 2182 __ mov(ecx, FieldOperand(edi, JSFunction::kCodeEntryOffset));
2183 __ jmp(ecx); 2183 __ jmp(ecx);
2184 2184
2185 __ bind(&stack_overflow); 2185 __ bind(&stack_overflow);
2186 { 2186 {
2187 FrameScope frame(masm, StackFrame::MANUAL); 2187 FrameScope frame(masm, StackFrame::MANUAL);
2188 __ CallRuntime(Runtime::kThrowStackOverflow, 0); 2188 __ CallRuntime(Runtime::kThrowStackOverflow);
2189 __ int3(); 2189 __ int3();
2190 } 2190 }
2191 } 2191 }
2192 2192
2193 2193
2194 static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, 2194 static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver,
2195 Register function_template_info, 2195 Register function_template_info,
2196 Register scratch0, Register scratch1, 2196 Register scratch0, Register scratch1,
2197 Label* receiver_check_failed) { 2197 Label* receiver_check_failed) {
2198 // If receiver is not an object, jump to receiver_check_failed. 2198 // If receiver is not an object, jump to receiver_check_failed.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 // Compatible receiver check failed: pop return address, arguments and 2307 // Compatible receiver check failed: pop return address, arguments and
2308 // receiver and throw an Illegal Invocation exception. 2308 // receiver and throw an Illegal Invocation exception.
2309 __ bind(&receiver_check_failed); 2309 __ bind(&receiver_check_failed);
2310 __ Pop(eax); 2310 __ Pop(eax);
2311 __ PopReturnAddressTo(ebx); 2311 __ PopReturnAddressTo(ebx);
2312 __ lea(eax, Operand(eax, times_pointer_size, 1 * kPointerSize)); 2312 __ lea(eax, Operand(eax, times_pointer_size, 1 * kPointerSize));
2313 __ add(esp, eax); 2313 __ add(esp, eax);
2314 __ PushReturnAddressFrom(ebx); 2314 __ PushReturnAddressFrom(ebx);
2315 { 2315 {
2316 FrameScope scope(masm, StackFrame::INTERNAL); 2316 FrameScope scope(masm, StackFrame::INTERNAL);
2317 __ TailCallRuntime(Runtime::kThrowIllegalInvocation, 0); 2317 __ TailCallRuntime(Runtime::kThrowIllegalInvocation);
2318 } 2318 }
2319 } 2319 }
2320 2320
2321 2321
2322 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { 2322 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
2323 // Lookup the function in the JavaScript frame. 2323 // Lookup the function in the JavaScript frame.
2324 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); 2324 __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
2325 { 2325 {
2326 FrameScope scope(masm, StackFrame::INTERNAL); 2326 FrameScope scope(masm, StackFrame::INTERNAL);
2327 // Pass function as argument. 2327 // Pass function as argument.
2328 __ push(eax); 2328 __ push(eax);
2329 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); 2329 __ CallRuntime(Runtime::kCompileForOnStackReplacement);
2330 } 2330 }
2331 2331
2332 Label skip; 2332 Label skip;
2333 // If the code object is null, just return to the unoptimized code. 2333 // If the code object is null, just return to the unoptimized code.
2334 __ cmp(eax, Immediate(0)); 2334 __ cmp(eax, Immediate(0));
2335 __ j(not_equal, &skip, Label::kNear); 2335 __ j(not_equal, &skip, Label::kNear);
2336 __ ret(0); 2336 __ ret(0);
2337 2337
2338 __ bind(&skip); 2338 __ bind(&skip);
2339 2339
(...skipping 18 matching lines...) Expand all
2358 2358
2359 void Builtins::Generate_OsrAfterStackCheck(MacroAssembler* masm) { 2359 void Builtins::Generate_OsrAfterStackCheck(MacroAssembler* masm) {
2360 // We check the stack limit as indicator that recompilation might be done. 2360 // We check the stack limit as indicator that recompilation might be done.
2361 Label ok; 2361 Label ok;
2362 ExternalReference stack_limit = 2362 ExternalReference stack_limit =
2363 ExternalReference::address_of_stack_limit(masm->isolate()); 2363 ExternalReference::address_of_stack_limit(masm->isolate());
2364 __ cmp(esp, Operand::StaticVariable(stack_limit)); 2364 __ cmp(esp, Operand::StaticVariable(stack_limit));
2365 __ j(above_equal, &ok, Label::kNear); 2365 __ j(above_equal, &ok, Label::kNear);
2366 { 2366 {
2367 FrameScope scope(masm, StackFrame::INTERNAL); 2367 FrameScope scope(masm, StackFrame::INTERNAL);
2368 __ CallRuntime(Runtime::kStackGuard, 0); 2368 __ CallRuntime(Runtime::kStackGuard);
2369 } 2369 }
2370 __ jmp(masm->isolate()->builtins()->OnStackReplacement(), 2370 __ jmp(masm->isolate()->builtins()->OnStackReplacement(),
2371 RelocInfo::CODE_TARGET); 2371 RelocInfo::CODE_TARGET);
2372 2372
2373 __ bind(&ok); 2373 __ bind(&ok);
2374 __ ret(0); 2374 __ ret(0);
2375 } 2375 }
2376 2376
2377 #undef __ 2377 #undef __
2378 } // namespace internal 2378 } // namespace internal
2379 } // namespace v8 2379 } // namespace v8
2380 2380
2381 #endif // V8_TARGET_ARCH_IA32 2381 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698