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

Side by Side Diff: src/x64/code-stubs-x64.cc

Issue 1550923002: Remove uses of result size in TailCallRuntime and friends (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: change spaces 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
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_X64 5 #if V8_TARGET_ARCH_X64
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/codegen.h" 9 #include "src/codegen.h"
10 #include "src/ic/handler-compiler.h" 10 #include "src/ic/handler-compiler.h"
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 // and may not have contained the exponent value in the first place when the 484 // and may not have contained the exponent value in the first place when the
485 // input was a smi. We reset it with exponent value before bailing out. 485 // input was a smi. We reset it with exponent value before bailing out.
486 __ j(not_equal, &done); 486 __ j(not_equal, &done);
487 __ Cvtlsi2sd(double_exponent, exponent); 487 __ Cvtlsi2sd(double_exponent, exponent);
488 488
489 // Returning or bailing out. 489 // Returning or bailing out.
490 Counters* counters = isolate()->counters(); 490 Counters* counters = isolate()->counters();
491 if (exponent_type() == ON_STACK) { 491 if (exponent_type() == ON_STACK) {
492 // The arguments are still on the stack. 492 // The arguments are still on the stack.
493 __ bind(&call_runtime); 493 __ bind(&call_runtime);
494 __ TailCallRuntime(Runtime::kMathPowRT, 2, 1); 494 __ TailCallRuntime(Runtime::kMathPowRT, 2);
495 495
496 // The stub is called from non-optimized code, which expects the result 496 // The stub is called from non-optimized code, which expects the result
497 // as heap number in rax. 497 // as heap number in rax.
498 __ bind(&done); 498 __ bind(&done);
499 __ AllocateHeapNumber(rax, rcx, &call_runtime); 499 __ AllocateHeapNumber(rax, rcx, &call_runtime);
500 __ Movsd(FieldOperand(rax, HeapNumber::kValueOffset), double_result); 500 __ Movsd(FieldOperand(rax, HeapNumber::kValueOffset), double_result);
501 __ IncrementCounter(counters->math_pow(), 1); 501 __ IncrementCounter(counters->math_pow(), 1);
502 __ ret(2 * kPointerSize); 502 __ ret(2 * kPointerSize);
503 } else { 503 } else {
504 __ bind(&call_runtime); 504 __ bind(&call_runtime);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 ARGUMENTS_DONT_CONTAIN_RECEIVER); 584 ARGUMENTS_DONT_CONTAIN_RECEIVER);
585 __ movp(rax, adaptor_args.GetArgumentOperand(0)); 585 __ movp(rax, adaptor_args.GetArgumentOperand(0));
586 __ Ret(); 586 __ Ret();
587 587
588 // Slow-case: Handle non-smi or out-of-bounds access to arguments 588 // Slow-case: Handle non-smi or out-of-bounds access to arguments
589 // by calling the runtime system. 589 // by calling the runtime system.
590 __ bind(&slow); 590 __ bind(&slow);
591 __ PopReturnAddressTo(rbx); 591 __ PopReturnAddressTo(rbx);
592 __ Push(rdx); 592 __ Push(rdx);
593 __ PushReturnAddressFrom(rbx); 593 __ PushReturnAddressFrom(rbx);
594 __ TailCallRuntime(Runtime::kArguments, 1, 1); 594 __ TailCallRuntime(Runtime::kArguments, 1);
595 } 595 }
596 596
597 597
598 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) { 598 void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) {
599 // rcx : number of parameters (tagged) 599 // rcx : number of parameters (tagged)
600 // rdx : parameters pointer 600 // rdx : parameters pointer
601 // rdi : function 601 // rdi : function
602 // rsp[0] : return address 602 // rsp[0] : return address
603 // Registers used over the whole function: 603 // Registers used over the whole function:
604 // rbx: the mapped parameter count (untagged) 604 // rbx: the mapped parameter count (untagged)
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 796
797 // Do the runtime call to allocate the arguments object. 797 // Do the runtime call to allocate the arguments object.
798 // r11 = argument count (untagged) 798 // r11 = argument count (untagged)
799 __ bind(&runtime); 799 __ bind(&runtime);
800 __ Integer32ToSmi(r11, r11); 800 __ Integer32ToSmi(r11, r11);
801 __ PopReturnAddressTo(rax); 801 __ PopReturnAddressTo(rax);
802 __ Push(rdi); // Push function. 802 __ Push(rdi); // Push function.
803 __ Push(rdx); // Push parameters pointer. 803 __ Push(rdx); // Push parameters pointer.
804 __ Push(r11); // Push parameter count. 804 __ Push(r11); // Push parameter count.
805 __ PushReturnAddressFrom(rax); 805 __ PushReturnAddressFrom(rax);
806 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); 806 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3);
807 } 807 }
808 808
809 809
810 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) { 810 void ArgumentsAccessStub::GenerateNewSloppySlow(MacroAssembler* masm) {
811 // rcx : number of parameters (tagged) 811 // rcx : number of parameters (tagged)
812 // rdx : parameters pointer 812 // rdx : parameters pointer
813 // rdi : function 813 // rdi : function
814 // rsp[0] : return address 814 // rsp[0] : return address
815 815
816 DCHECK(rdi.is(ArgumentsAccessNewDescriptor::function())); 816 DCHECK(rdi.is(ArgumentsAccessNewDescriptor::function()));
(...skipping 13 matching lines...) Expand all
830 __ SmiToInteger64(rax, rcx); 830 __ SmiToInteger64(rax, rcx);
831 __ leap(rdx, Operand(rbx, rax, times_pointer_size, 831 __ leap(rdx, Operand(rbx, rax, times_pointer_size,
832 StandardFrameConstants::kCallerSPOffset)); 832 StandardFrameConstants::kCallerSPOffset));
833 833
834 __ bind(&runtime); 834 __ bind(&runtime);
835 __ PopReturnAddressTo(rax); 835 __ PopReturnAddressTo(rax);
836 __ Push(rdi); // Push function. 836 __ Push(rdi); // Push function.
837 __ Push(rdx); // Push parameters pointer. 837 __ Push(rdx); // Push parameters pointer.
838 __ Push(rcx); // Push parameter count. 838 __ Push(rcx); // Push parameter count.
839 __ PushReturnAddressFrom(rax); 839 __ PushReturnAddressFrom(rax);
840 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3, 1); 840 __ TailCallRuntime(Runtime::kNewSloppyArguments, 3);
841 } 841 }
842 842
843 843
844 void RestParamAccessStub::GenerateNew(MacroAssembler* masm) { 844 void RestParamAccessStub::GenerateNew(MacroAssembler* masm) {
845 // rsp[0] : return address 845 // rsp[0] : return address
846 // rsp[8] : language mode 846 // rsp[8] : language mode
847 // rsp[16] : index of rest parameter 847 // rsp[16] : index of rest parameter
848 // rsp[24] : number of parameters 848 // rsp[24] : number of parameters
849 // rsp[32] : receiver displacement 849 // rsp[32] : receiver displacement
850 850
851 // Check if the calling frame is an arguments adaptor frame. 851 // Check if the calling frame is an arguments adaptor frame.
852 Label runtime; 852 Label runtime;
853 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset)); 853 __ movp(rdx, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
854 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset)); 854 __ movp(rcx, Operand(rdx, StandardFrameConstants::kContextOffset));
855 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); 855 __ Cmp(rcx, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
856 __ j(not_equal, &runtime); 856 __ j(not_equal, &runtime);
857 857
858 // Patch the arguments.length and the parameters pointer. 858 // Patch the arguments.length and the parameters pointer.
859 StackArgumentsAccessor args(rsp, 4, ARGUMENTS_DONT_CONTAIN_RECEIVER); 859 StackArgumentsAccessor args(rsp, 4, ARGUMENTS_DONT_CONTAIN_RECEIVER);
860 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset)); 860 __ movp(rcx, Operand(rdx, ArgumentsAdaptorFrameConstants::kLengthOffset));
861 __ movp(args.GetArgumentOperand(1), rcx); 861 __ movp(args.GetArgumentOperand(1), rcx);
862 __ SmiToInteger64(rcx, rcx); 862 __ SmiToInteger64(rcx, rcx);
863 __ leap(rdx, Operand(rdx, rcx, times_pointer_size, 863 __ leap(rdx, Operand(rdx, rcx, times_pointer_size,
864 StandardFrameConstants::kCallerSPOffset)); 864 StandardFrameConstants::kCallerSPOffset));
865 __ movp(args.GetArgumentOperand(0), rdx); 865 __ movp(args.GetArgumentOperand(0), rdx);
866 866
867 __ bind(&runtime); 867 __ bind(&runtime);
868 __ TailCallRuntime(Runtime::kNewRestParam, 4, 1); 868 __ TailCallRuntime(Runtime::kNewRestParam, 4);
869 } 869 }
870 870
871 871
872 void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) { 872 void LoadIndexedInterceptorStub::Generate(MacroAssembler* masm) {
873 // Return address is on the stack. 873 // Return address is on the stack.
874 Label slow; 874 Label slow;
875 875
876 Register receiver = LoadDescriptor::ReceiverRegister(); 876 Register receiver = LoadDescriptor::ReceiverRegister();
877 Register key = LoadDescriptor::NameRegister(); 877 Register key = LoadDescriptor::NameRegister();
878 Register scratch = rax; 878 Register scratch = rax;
879 DCHECK(!scratch.is(receiver) && !scratch.is(key)); 879 DCHECK(!scratch.is(receiver) && !scratch.is(key));
880 880
881 // Check that the key is an array index, that is Uint32. 881 // Check that the key is an array index, that is Uint32.
882 STATIC_ASSERT(kSmiValueSize <= 32); 882 STATIC_ASSERT(kSmiValueSize <= 32);
883 __ JumpUnlessNonNegativeSmi(key, &slow); 883 __ JumpUnlessNonNegativeSmi(key, &slow);
884 884
885 // Everything is fine, call runtime. 885 // Everything is fine, call runtime.
886 __ PopReturnAddressTo(scratch); 886 __ PopReturnAddressTo(scratch);
887 __ Push(receiver); // receiver 887 __ Push(receiver); // receiver
888 __ Push(key); // key 888 __ Push(key); // key
889 __ PushReturnAddressFrom(scratch); 889 __ PushReturnAddressFrom(scratch);
890 890
891 // Perform tail call to the entry. 891 // Perform tail call to the entry.
892 __ TailCallRuntime(Runtime::kLoadElementWithInterceptor, 2, 1); 892 __ TailCallRuntime(Runtime::kLoadElementWithInterceptor, 2);
893 893
894 __ bind(&slow); 894 __ bind(&slow);
895 PropertyAccessCompiler::TailCallBuiltin( 895 PropertyAccessCompiler::TailCallBuiltin(
896 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC)); 896 masm, PropertyAccessCompiler::MissBuiltin(Code::KEYED_LOAD_IC));
897 } 897 }
898 898
899 899
900 void LoadIndexedStringStub::Generate(MacroAssembler* masm) { 900 void LoadIndexedStringStub::Generate(MacroAssembler* masm) {
901 // Return address is on the stack. 901 // Return address is on the stack.
902 Label miss; 902 Label miss;
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 __ bind(&done); 1016 __ bind(&done);
1017 __ ret(0); 1017 __ ret(0);
1018 1018
1019 // Do the runtime call to allocate the arguments object. 1019 // Do the runtime call to allocate the arguments object.
1020 __ bind(&runtime); 1020 __ bind(&runtime);
1021 __ PopReturnAddressTo(rax); 1021 __ PopReturnAddressTo(rax);
1022 __ Push(rdi); // Push function. 1022 __ Push(rdi); // Push function.
1023 __ Push(rdx); // Push parameters pointer. 1023 __ Push(rdx); // Push parameters pointer.
1024 __ Push(rcx); // Push parameter count. 1024 __ Push(rcx); // Push parameter count.
1025 __ PushReturnAddressFrom(rax); 1025 __ PushReturnAddressFrom(rax);
1026 __ TailCallRuntime(Runtime::kNewStrictArguments, 3, 1); 1026 __ TailCallRuntime(Runtime::kNewStrictArguments, 3);
1027 } 1027 }
1028 1028
1029 1029
1030 void RegExpExecStub::Generate(MacroAssembler* masm) { 1030 void RegExpExecStub::Generate(MacroAssembler* masm) {
1031 // Just jump directly to runtime if native RegExp is not selected at compile 1031 // Just jump directly to runtime if native RegExp is not selected at compile
1032 // time or if regexp entry in generated code is turned off runtime switch or 1032 // time or if regexp entry in generated code is turned off runtime switch or
1033 // at compilation. 1033 // at compilation.
1034 #ifdef V8_INTERPRETED_REGEXP 1034 #ifdef V8_INTERPRETED_REGEXP
1035 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 1035 __ TailCallRuntime(Runtime::kRegExpExec, 4);
1036 #else // V8_INTERPRETED_REGEXP 1036 #else // V8_INTERPRETED_REGEXP
1037 1037
1038 // Stack frame on entry. 1038 // Stack frame on entry.
1039 // rsp[0] : return address 1039 // rsp[0] : return address
1040 // rsp[8] : last_match_info (expected JSArray) 1040 // rsp[8] : last_match_info (expected JSArray)
1041 // rsp[16] : previous index 1041 // rsp[16] : previous index
1042 // rsp[24] : subject string 1042 // rsp[24] : subject string
1043 // rsp[32] : JSRegExp object 1043 // rsp[32] : JSRegExp object
1044 1044
1045 enum RegExpExecStubArgumentIndices { 1045 enum RegExpExecStubArgumentIndices {
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 ExternalReference pending_exception_address( 1408 ExternalReference pending_exception_address(
1409 Isolate::kPendingExceptionAddress, isolate()); 1409 Isolate::kPendingExceptionAddress, isolate());
1410 Operand pending_exception_operand = 1410 Operand pending_exception_operand =
1411 masm->ExternalOperand(pending_exception_address, rbx); 1411 masm->ExternalOperand(pending_exception_address, rbx);
1412 __ movp(rax, pending_exception_operand); 1412 __ movp(rax, pending_exception_operand);
1413 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex); 1413 __ LoadRoot(rdx, Heap::kTheHoleValueRootIndex);
1414 __ cmpp(rax, rdx); 1414 __ cmpp(rax, rdx);
1415 __ j(equal, &runtime); 1415 __ j(equal, &runtime);
1416 1416
1417 // For exception, throw the exception again. 1417 // For exception, throw the exception again.
1418 __ TailCallRuntime(Runtime::kRegExpExecReThrow, 4, 1); 1418 __ TailCallRuntime(Runtime::kRegExpExecReThrow, 4);
1419 1419
1420 // Do the runtime call to execute the regexp. 1420 // Do the runtime call to execute the regexp.
1421 __ bind(&runtime); 1421 __ bind(&runtime);
1422 __ TailCallRuntime(Runtime::kRegExpExec, 4, 1); 1422 __ TailCallRuntime(Runtime::kRegExpExec, 4);
1423 1423
1424 // Deferred code for string handling. 1424 // Deferred code for string handling.
1425 // (7) Not a long external string? If yes, go to (10). 1425 // (7) Not a long external string? If yes, go to (10).
1426 __ bind(&not_seq_nor_cons); 1426 __ bind(&not_seq_nor_cons);
1427 // Compare flags are still set from (3). 1427 // Compare flags are still set from (3).
1428 __ j(greater, &not_long_external, Label::kNear); // Go to (10). 1428 __ j(greater, &not_long_external, Label::kNear); // Go to (10).
1429 1429
1430 // (8) External string. Short external strings have been ruled out. 1430 // (8) External string. Short external strings have been ruled out.
1431 __ bind(&external_string); 1431 __ bind(&external_string);
1432 __ movp(rbx, FieldOperand(rdi, HeapObject::kMapOffset)); 1432 __ movp(rbx, FieldOperand(rdi, HeapObject::kMapOffset));
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 __ bind(&runtime_call); 1756 __ bind(&runtime_call);
1757 1757
1758 // Push arguments below the return address to prepare jump to builtin. 1758 // Push arguments below the return address to prepare jump to builtin.
1759 __ PopReturnAddressTo(rcx); 1759 __ PopReturnAddressTo(rcx);
1760 __ Push(rdx); 1760 __ Push(rdx);
1761 __ Push(rax); 1761 __ Push(rax);
1762 1762
1763 // Figure out which native to call and setup the arguments. 1763 // Figure out which native to call and setup the arguments.
1764 if (cc == equal) { 1764 if (cc == equal) {
1765 __ PushReturnAddressFrom(rcx); 1765 __ PushReturnAddressFrom(rcx);
1766 __ TailCallRuntime(strict() ? Runtime::kStrictEquals : Runtime::kEquals, 2, 1766 __ TailCallRuntime(strict() ? Runtime::kStrictEquals : Runtime::kEquals, 2);
1767 1);
1768 } else { 1767 } else {
1769 __ Push(Smi::FromInt(NegativeComparisonResult(cc))); 1768 __ Push(Smi::FromInt(NegativeComparisonResult(cc)));
1770 __ PushReturnAddressFrom(rcx); 1769 __ PushReturnAddressFrom(rcx);
1771 __ TailCallRuntime( 1770 __ TailCallRuntime(
1772 is_strong(strength()) ? Runtime::kCompare_Strong : Runtime::kCompare, 3, 1771 is_strong(strength()) ? Runtime::kCompare_Strong : Runtime::kCompare,
1773 1); 1772 3);
1774 } 1773 }
1775 1774
1776 __ bind(&miss); 1775 __ bind(&miss);
1777 GenerateMiss(masm); 1776 GenerateMiss(masm);
1778 } 1777 }
1779 1778
1780 1779
1781 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) { 1780 static void CallStubInRecordCallTarget(MacroAssembler* masm, CodeStub* stub) {
1782 // rax : number of arguments to the construct function 1781 // rax : number of arguments to the construct function
1783 // rbx : feedback vector 1782 // rbx : feedback vector
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after
2559 2558
2560 // Found Proxy or access check needed: Call the runtime. 2559 // Found Proxy or access check needed: Call the runtime.
2561 __ bind(&fast_runtime_fallback); 2560 __ bind(&fast_runtime_fallback);
2562 __ PopReturnAddressTo(kScratchRegister); 2561 __ PopReturnAddressTo(kScratchRegister);
2563 __ Push(object); 2562 __ Push(object);
2564 __ Push(function_prototype); 2563 __ Push(function_prototype);
2565 __ PushReturnAddressFrom(kScratchRegister); 2564 __ PushReturnAddressFrom(kScratchRegister);
2566 // Invalidate the instanceof cache. 2565 // Invalidate the instanceof cache.
2567 __ Move(rax, Smi::FromInt(0)); 2566 __ Move(rax, Smi::FromInt(0));
2568 __ StoreRoot(rax, Heap::kInstanceofCacheFunctionRootIndex); 2567 __ StoreRoot(rax, Heap::kInstanceofCacheFunctionRootIndex);
2569 __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1); 2568 __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2);
2570 2569
2571 // Slow-case: Call the %InstanceOf runtime function. 2570 // Slow-case: Call the %InstanceOf runtime function.
2572 __ bind(&slow_case); 2571 __ bind(&slow_case);
2573 __ PopReturnAddressTo(kScratchRegister); 2572 __ PopReturnAddressTo(kScratchRegister);
2574 __ Push(object); 2573 __ Push(object);
2575 __ Push(function); 2574 __ Push(function);
2576 __ PushReturnAddressFrom(kScratchRegister); 2575 __ PushReturnAddressFrom(kScratchRegister);
2577 __ TailCallRuntime(Runtime::kInstanceOf, 2, 1); 2576 __ TailCallRuntime(Runtime::kInstanceOf, 2);
2578 } 2577 }
2579 2578
2580 2579
2581 // ------------------------------------------------------------------------- 2580 // -------------------------------------------------------------------------
2582 // StringCharCodeAtGenerator 2581 // StringCharCodeAtGenerator
2583 2582
2584 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) { 2583 void StringCharCodeAtGenerator::GenerateFast(MacroAssembler* masm) {
2585 // If the receiver is a smi trigger the non-string case. 2584 // If the receiver is a smi trigger the non-string case.
2586 if (check_mode_ == RECEIVER_IS_UNKNOWN) { 2585 if (check_mode_ == RECEIVER_IS_UNKNOWN) {
2587 __ JumpIfSmi(object_, receiver_not_string_); 2586 __ JumpIfSmi(object_, receiver_not_string_);
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
2944 // rcx: result length 2943 // rcx: result length
2945 // rdi: first character of result 2944 // rdi: first character of result
2946 // r14: character of sub string start 2945 // r14: character of sub string start
2947 StringHelper::GenerateCopyCharacters( 2946 StringHelper::GenerateCopyCharacters(
2948 masm, rdi, r14, rcx, String::TWO_BYTE_ENCODING); 2947 masm, rdi, r14, rcx, String::TWO_BYTE_ENCODING);
2949 __ IncrementCounter(counters->sub_string_native(), 1); 2948 __ IncrementCounter(counters->sub_string_native(), 1);
2950 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize); 2949 __ ret(SUB_STRING_ARGUMENT_COUNT * kPointerSize);
2951 2950
2952 // Just jump to runtime to create the sub string. 2951 // Just jump to runtime to create the sub string.
2953 __ bind(&runtime); 2952 __ bind(&runtime);
2954 __ TailCallRuntime(Runtime::kSubString, 3, 1); 2953 __ TailCallRuntime(Runtime::kSubString, 3);
2955 2954
2956 __ bind(&single_char); 2955 __ bind(&single_char);
2957 // rax: string 2956 // rax: string
2958 // rbx: instance type 2957 // rbx: instance type
2959 // rcx: sub string length (smi) 2958 // rcx: sub string length (smi)
2960 // rdx: from index (smi) 2959 // rdx: from index (smi)
2961 StringCharAtGenerator generator(rax, rdx, rcx, rax, &runtime, &runtime, 2960 StringCharAtGenerator generator(rax, rdx, rcx, rax, &runtime, &runtime,
2962 &runtime, STRING_INDEX_IS_NUMBER, 2961 &runtime, STRING_INDEX_IS_NUMBER,
2963 RECEIVER_IS_STRING); 2962 RECEIVER_IS_STRING);
2964 generator.GenerateFast(masm); 2963 generator.GenerateFast(masm);
(...skipping 25 matching lines...) Expand all
2990 __ testl(FieldOperand(rax, String::kHashFieldOffset), 2989 __ testl(FieldOperand(rax, String::kHashFieldOffset),
2991 Immediate(String::kContainsCachedArrayIndexMask)); 2990 Immediate(String::kContainsCachedArrayIndexMask));
2992 __ j(not_zero, &slow_string, Label::kNear); 2991 __ j(not_zero, &slow_string, Label::kNear);
2993 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); 2992 __ movl(rax, FieldOperand(rax, String::kHashFieldOffset));
2994 __ IndexFromHash(rax, rax); 2993 __ IndexFromHash(rax, rax);
2995 __ Ret(); 2994 __ Ret();
2996 __ bind(&slow_string); 2995 __ bind(&slow_string);
2997 __ PopReturnAddressTo(rcx); // Pop return address. 2996 __ PopReturnAddressTo(rcx); // Pop return address.
2998 __ Push(rax); // Push argument. 2997 __ Push(rax); // Push argument.
2999 __ PushReturnAddressFrom(rcx); // Push return address. 2998 __ PushReturnAddressFrom(rcx); // Push return address.
3000 __ TailCallRuntime(Runtime::kStringToNumber, 1, 1); 2999 __ TailCallRuntime(Runtime::kStringToNumber, 1);
3001 __ bind(&not_string); 3000 __ bind(&not_string);
3002 3001
3003 Label not_oddball; 3002 Label not_oddball;
3004 __ CmpInstanceType(rdi, ODDBALL_TYPE); 3003 __ CmpInstanceType(rdi, ODDBALL_TYPE);
3005 __ j(not_equal, &not_oddball, Label::kNear); 3004 __ j(not_equal, &not_oddball, Label::kNear);
3006 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); 3005 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
3007 __ Ret(); 3006 __ Ret();
3008 __ bind(&not_oddball); 3007 __ bind(&not_oddball);
3009 3008
3010 __ PopReturnAddressTo(rcx); // Pop return address. 3009 __ PopReturnAddressTo(rcx); // Pop return address.
3011 __ Push(rax); // Push argument. 3010 __ Push(rax); // Push argument.
3012 __ PushReturnAddressFrom(rcx); // Push return address. 3011 __ PushReturnAddressFrom(rcx); // Push return address.
3013 __ TailCallRuntime(Runtime::kToNumber, 1, 1); 3012 __ TailCallRuntime(Runtime::kToNumber, 1);
3014 } 3013 }
3015 3014
3016 3015
3017 void ToLengthStub::Generate(MacroAssembler* masm) { 3016 void ToLengthStub::Generate(MacroAssembler* masm) {
3018 // The ToLength stub takes on argument in rax. 3017 // The ToLength stub takes on argument in rax.
3019 Label not_smi, positive_smi; 3018 Label not_smi, positive_smi;
3020 __ JumpIfNotSmi(rax, &not_smi, Label::kNear); 3019 __ JumpIfNotSmi(rax, &not_smi, Label::kNear);
3021 STATIC_ASSERT(kSmiTag == 0); 3020 STATIC_ASSERT(kSmiTag == 0);
3022 __ testp(rax, rax); 3021 __ testp(rax, rax);
3023 __ j(greater_equal, &positive_smi, Label::kNear); 3022 __ j(greater_equal, &positive_smi, Label::kNear);
3024 __ xorl(rax, rax); 3023 __ xorl(rax, rax);
3025 __ bind(&positive_smi); 3024 __ bind(&positive_smi);
3026 __ Ret(); 3025 __ Ret();
3027 __ bind(&not_smi); 3026 __ bind(&not_smi);
3028 3027
3029 __ PopReturnAddressTo(rcx); // Pop return address. 3028 __ PopReturnAddressTo(rcx); // Pop return address.
3030 __ Push(rax); // Push argument. 3029 __ Push(rax); // Push argument.
3031 __ PushReturnAddressFrom(rcx); // Push return address. 3030 __ PushReturnAddressFrom(rcx); // Push return address.
3032 __ TailCallRuntime(Runtime::kToLength, 1, 1); 3031 __ TailCallRuntime(Runtime::kToLength, 1);
3033 } 3032 }
3034 3033
3035 3034
3036 void ToStringStub::Generate(MacroAssembler* masm) { 3035 void ToStringStub::Generate(MacroAssembler* masm) {
3037 // The ToString stub takes one argument in rax. 3036 // The ToString stub takes one argument in rax.
3038 Label is_number; 3037 Label is_number;
3039 __ JumpIfSmi(rax, &is_number, Label::kNear); 3038 __ JumpIfSmi(rax, &is_number, Label::kNear);
3040 3039
3041 Label not_string; 3040 Label not_string;
3042 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); 3041 __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi);
(...skipping 14 matching lines...) Expand all
3057 Label not_oddball; 3056 Label not_oddball;
3058 __ CmpInstanceType(rdi, ODDBALL_TYPE); 3057 __ CmpInstanceType(rdi, ODDBALL_TYPE);
3059 __ j(not_equal, &not_oddball, Label::kNear); 3058 __ j(not_equal, &not_oddball, Label::kNear);
3060 __ movp(rax, FieldOperand(rax, Oddball::kToStringOffset)); 3059 __ movp(rax, FieldOperand(rax, Oddball::kToStringOffset));
3061 __ Ret(); 3060 __ Ret();
3062 __ bind(&not_oddball); 3061 __ bind(&not_oddball);
3063 3062
3064 __ PopReturnAddressTo(rcx); // Pop return address. 3063 __ PopReturnAddressTo(rcx); // Pop return address.
3065 __ Push(rax); // Push argument. 3064 __ Push(rax); // Push argument.
3066 __ PushReturnAddressFrom(rcx); // Push return address. 3065 __ PushReturnAddressFrom(rcx); // Push return address.
3067 __ TailCallRuntime(Runtime::kToString, 1, 1); 3066 __ TailCallRuntime(Runtime::kToString, 1);
3068 } 3067 }
3069 3068
3070 3069
3071 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, 3070 void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
3072 Register left, 3071 Register left,
3073 Register right, 3072 Register right,
3074 Register scratch1, 3073 Register scratch1,
3075 Register scratch2) { 3074 Register scratch2) {
3076 Register length = scratch1; 3075 Register length = scratch1;
3077 3076
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
3232 StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx, rdi, 3231 StringHelper::GenerateCompareFlatOneByteStrings(masm, rdx, rax, rcx, rbx, rdi,
3233 r8); 3232 r8);
3234 3233
3235 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) 3234 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater)
3236 // tagged as a small integer. 3235 // tagged as a small integer.
3237 __ bind(&runtime); 3236 __ bind(&runtime);
3238 __ PopReturnAddressTo(rcx); 3237 __ PopReturnAddressTo(rcx);
3239 __ Push(rdx); 3238 __ Push(rdx);
3240 __ Push(rax); 3239 __ Push(rax);
3241 __ PushReturnAddressFrom(rcx); 3240 __ PushReturnAddressFrom(rcx);
3242 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3241 __ TailCallRuntime(Runtime::kStringCompare, 2);
3243 } 3242 }
3244 3243
3245 3244
3246 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) { 3245 void BinaryOpICWithAllocationSiteStub::Generate(MacroAssembler* masm) {
3247 // ----------- S t a t e ------------- 3246 // ----------- S t a t e -------------
3248 // -- rdx : left 3247 // -- rdx : left
3249 // -- rax : right 3248 // -- rax : right
3250 // -- rsp[0] : return address 3249 // -- rsp[0] : return address
3251 // ----------------------------------- 3250 // -----------------------------------
3252 3251
(...skipping 24 matching lines...) Expand all
3277 Label::Distance const miss_distance = 3276 Label::Distance const miss_distance =
3278 masm->emit_debug_code() ? Label::kFar : Label::kNear; 3277 masm->emit_debug_code() ? Label::kFar : Label::kNear;
3279 3278
3280 __ JumpIfSmi(rdx, &miss, miss_distance); 3279 __ JumpIfSmi(rdx, &miss, miss_distance);
3281 __ movp(rcx, FieldOperand(rdx, HeapObject::kMapOffset)); 3280 __ movp(rcx, FieldOperand(rdx, HeapObject::kMapOffset));
3282 __ JumpIfSmi(rax, &miss, miss_distance); 3281 __ JumpIfSmi(rax, &miss, miss_distance);
3283 __ movp(rbx, FieldOperand(rax, HeapObject::kMapOffset)); 3282 __ movp(rbx, FieldOperand(rax, HeapObject::kMapOffset));
3284 __ JumpIfNotRoot(rcx, Heap::kBooleanMapRootIndex, &miss, miss_distance); 3283 __ JumpIfNotRoot(rcx, Heap::kBooleanMapRootIndex, &miss, miss_distance);
3285 __ JumpIfNotRoot(rbx, Heap::kBooleanMapRootIndex, &miss, miss_distance); 3284 __ JumpIfNotRoot(rbx, Heap::kBooleanMapRootIndex, &miss, miss_distance);
3286 if (op() != Token::EQ_STRICT && is_strong(strength())) { 3285 if (op() != Token::EQ_STRICT && is_strong(strength())) {
3287 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion, 0, 1); 3286 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion, 0);
3288 } else { 3287 } else {
3289 if (!Token::IsEqualityOp(op())) { 3288 if (!Token::IsEqualityOp(op())) {
3290 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset)); 3289 __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
3291 __ AssertSmi(rax); 3290 __ AssertSmi(rax);
3292 __ movp(rdx, FieldOperand(rdx, Oddball::kToNumberOffset)); 3291 __ movp(rdx, FieldOperand(rdx, Oddball::kToNumberOffset));
3293 __ AssertSmi(rdx); 3292 __ AssertSmi(rdx);
3294 __ xchgp(rax, rdx); 3293 __ xchgp(rax, rdx);
3295 } 3294 }
3296 __ subp(rax, rdx); 3295 __ subp(rax, rdx);
3297 __ Ret(); 3296 __ Ret();
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
3559 masm, left, right, tmp1, tmp2, tmp3, kScratchRegister); 3558 masm, left, right, tmp1, tmp2, tmp3, kScratchRegister);
3560 } 3559 }
3561 3560
3562 // Handle more complex cases in runtime. 3561 // Handle more complex cases in runtime.
3563 __ bind(&runtime); 3562 __ bind(&runtime);
3564 __ PopReturnAddressTo(tmp1); 3563 __ PopReturnAddressTo(tmp1);
3565 __ Push(left); 3564 __ Push(left);
3566 __ Push(right); 3565 __ Push(right);
3567 __ PushReturnAddressFrom(tmp1); 3566 __ PushReturnAddressFrom(tmp1);
3568 if (equality) { 3567 if (equality) {
3569 __ TailCallRuntime(Runtime::kStringEquals, 2, 1); 3568 __ TailCallRuntime(Runtime::kStringEquals, 2);
3570 } else { 3569 } else {
3571 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); 3570 __ TailCallRuntime(Runtime::kStringCompare, 2);
3572 } 3571 }
3573 3572
3574 __ bind(&miss); 3573 __ bind(&miss);
3575 GenerateMiss(masm); 3574 GenerateMiss(masm);
3576 } 3575 }
3577 3576
3578 3577
3579 void CompareICStub::GenerateReceivers(MacroAssembler* masm) { 3578 void CompareICStub::GenerateReceivers(MacroAssembler* masm) {
3580 DCHECK_EQ(CompareICState::RECEIVER, state()); 3579 DCHECK_EQ(CompareICState::RECEIVER, state());
3581 Label miss; 3580 Label miss;
(...skipping 24 matching lines...) Expand all
3606 __ GetWeakValue(rdi, cell); 3605 __ GetWeakValue(rdi, cell);
3607 __ cmpp(FieldOperand(rdx, HeapObject::kMapOffset), rdi); 3606 __ cmpp(FieldOperand(rdx, HeapObject::kMapOffset), rdi);
3608 __ j(not_equal, &miss, Label::kNear); 3607 __ j(not_equal, &miss, Label::kNear);
3609 __ cmpp(FieldOperand(rax, HeapObject::kMapOffset), rdi); 3608 __ cmpp(FieldOperand(rax, HeapObject::kMapOffset), rdi);
3610 __ j(not_equal, &miss, Label::kNear); 3609 __ j(not_equal, &miss, Label::kNear);
3611 3610
3612 if (Token::IsEqualityOp(op())) { 3611 if (Token::IsEqualityOp(op())) {
3613 __ subp(rax, rdx); 3612 __ subp(rax, rdx);
3614 __ ret(0); 3613 __ ret(0);
3615 } else if (is_strong(strength())) { 3614 } else if (is_strong(strength())) {
3616 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion, 0, 1); 3615 __ TailCallRuntime(Runtime::kThrowStrongModeImplicitConversion, 0);
3617 } else { 3616 } else {
3618 __ PopReturnAddressTo(rcx); 3617 __ PopReturnAddressTo(rcx);
3619 __ Push(rdx); 3618 __ Push(rdx);
3620 __ Push(rax); 3619 __ Push(rax);
3621 __ Push(Smi::FromInt(NegativeComparisonResult(GetCondition()))); 3620 __ Push(Smi::FromInt(NegativeComparisonResult(GetCondition())));
3622 __ PushReturnAddressFrom(rcx); 3621 __ PushReturnAddressFrom(rcx);
3623 __ TailCallRuntime(Runtime::kCompare, 3, 1); 3622 __ TailCallRuntime(Runtime::kCompare, 3);
3624 } 3623 }
3625 3624
3626 __ bind(&miss); 3625 __ bind(&miss);
3627 GenerateMiss(masm); 3626 GenerateMiss(masm);
3628 } 3627 }
3629 3628
3630 3629
3631 void CompareICStub::GenerateMiss(MacroAssembler* masm) { 3630 void CompareICStub::GenerateMiss(MacroAssembler* masm) {
3632 { 3631 {
3633 // Call the runtime system in a fresh internal frame. 3632 // Call the runtime system in a fresh internal frame.
(...skipping 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
4766 StackArgumentsAccessor args(rsp, 1); 4765 StackArgumentsAccessor args(rsp, 1);
4767 __ movp(args.GetReceiverOperand(), rdi); 4766 __ movp(args.GetReceiverOperand(), rdi);
4768 __ Set(rax, 4); 4767 __ Set(rax, 4);
4769 break; 4768 break;
4770 } 4769 }
4771 } 4770 }
4772 __ PopReturnAddressTo(rcx); 4771 __ PopReturnAddressTo(rcx);
4773 __ Push(rdx); 4772 __ Push(rdx);
4774 __ Push(rbx); 4773 __ Push(rbx);
4775 __ PushReturnAddressFrom(rcx); 4774 __ PushReturnAddressFrom(rcx);
4776 __ JumpToExternalReference(ExternalReference(Runtime::kNewArray, isolate()), 4775 __ JumpToExternalReference(ExternalReference(Runtime::kNewArray, isolate()));
4777 1);
4778 } 4776 }
4779 4777
4780 4778
4781 void InternalArrayConstructorStub::GenerateCase( 4779 void InternalArrayConstructorStub::GenerateCase(
4782 MacroAssembler* masm, ElementsKind kind) { 4780 MacroAssembler* masm, ElementsKind kind) {
4783 Label not_zero_case, not_one_case; 4781 Label not_zero_case, not_one_case;
4784 Label normal_sequence; 4782 Label normal_sequence;
4785 4783
4786 __ testp(rax, rax); 4784 __ testp(rax, rax);
4787 __ j(not_zero, &not_zero_case); 4785 __ j(not_zero, &not_zero_case);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
4886 __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex); 4884 __ CompareRoot(result_reg, Heap::kTheHoleValueRootIndex);
4887 __ j(equal, &slow_case, Label::kNear); 4885 __ j(equal, &slow_case, Label::kNear);
4888 __ Ret(); 4886 __ Ret();
4889 4887
4890 // Fallback to the runtime. 4888 // Fallback to the runtime.
4891 __ bind(&slow_case); 4889 __ bind(&slow_case);
4892 __ Integer32ToSmi(slot_reg, slot_reg); 4890 __ Integer32ToSmi(slot_reg, slot_reg);
4893 __ PopReturnAddressTo(kScratchRegister); 4891 __ PopReturnAddressTo(kScratchRegister);
4894 __ Push(slot_reg); 4892 __ Push(slot_reg);
4895 __ Push(kScratchRegister); 4893 __ Push(kScratchRegister);
4896 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1, 1); 4894 __ TailCallRuntime(Runtime::kLoadGlobalViaContext, 1);
4897 } 4895 }
4898 4896
4899 4897
4900 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) { 4898 void StoreGlobalViaContextStub::Generate(MacroAssembler* masm) {
4901 Register context_reg = rsi; 4899 Register context_reg = rsi;
4902 Register slot_reg = rbx; 4900 Register slot_reg = rbx;
4903 Register value_reg = rax; 4901 Register value_reg = rax;
4904 Register cell_reg = r8; 4902 Register cell_reg = r8;
4905 Register cell_details_reg = rdx; 4903 Register cell_details_reg = rdx;
4906 Register cell_value_reg = r9; 4904 Register cell_value_reg = r9;
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
5010 // Fallback to the runtime. 5008 // Fallback to the runtime.
5011 __ bind(&slow_case); 5009 __ bind(&slow_case);
5012 __ Integer32ToSmi(slot_reg, slot_reg); 5010 __ Integer32ToSmi(slot_reg, slot_reg);
5013 __ PopReturnAddressTo(kScratchRegister); 5011 __ PopReturnAddressTo(kScratchRegister);
5014 __ Push(slot_reg); 5012 __ Push(slot_reg);
5015 __ Push(value_reg); 5013 __ Push(value_reg);
5016 __ Push(kScratchRegister); 5014 __ Push(kScratchRegister);
5017 __ TailCallRuntime(is_strict(language_mode()) 5015 __ TailCallRuntime(is_strict(language_mode())
5018 ? Runtime::kStoreGlobalViaContext_Strict 5016 ? Runtime::kStoreGlobalViaContext_Strict
5019 : Runtime::kStoreGlobalViaContext_Sloppy, 5017 : Runtime::kStoreGlobalViaContext_Sloppy,
5020 2, 1); 5018 2);
5021 } 5019 }
5022 5020
5023 5021
5024 static int Offset(ExternalReference ref0, ExternalReference ref1) { 5022 static int Offset(ExternalReference ref0, ExternalReference ref1) {
5025 int64_t offset = (ref0.address() - ref1.address()); 5023 int64_t offset = (ref0.address() - ref1.address());
5026 // Check that fits into int. 5024 // Check that fits into int.
5027 DCHECK(static_cast<int>(offset) == offset); 5025 DCHECK(static_cast<int>(offset) == offset);
5028 return static_cast<int>(offset); 5026 return static_cast<int>(offset);
5029 } 5027 }
5030 5028
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
5184 DCHECK_EQ(stack_space, 0); 5182 DCHECK_EQ(stack_space, 0);
5185 __ PopReturnAddressTo(rcx); 5183 __ PopReturnAddressTo(rcx);
5186 __ addq(rsp, rbx); 5184 __ addq(rsp, rbx);
5187 __ jmp(rcx); 5185 __ jmp(rcx);
5188 } else { 5186 } else {
5189 __ ret(stack_space * kPointerSize); 5187 __ ret(stack_space * kPointerSize);
5190 } 5188 }
5191 5189
5192 // Re-throw by promoting a scheduled exception. 5190 // Re-throw by promoting a scheduled exception.
5193 __ bind(&promote_scheduled_exception); 5191 __ bind(&promote_scheduled_exception);
5194 __ TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); 5192 __ TailCallRuntime(Runtime::kPromoteScheduledException, 0);
5195 5193
5196 // HandleScope limit has changed. Delete allocated extensions. 5194 // HandleScope limit has changed. Delete allocated extensions.
5197 __ bind(&delete_allocated_handles); 5195 __ bind(&delete_allocated_handles);
5198 __ movp(Operand(base_reg, kLimitOffset), prev_limit_reg); 5196 __ movp(Operand(base_reg, kLimitOffset), prev_limit_reg);
5199 __ movp(prev_limit_reg, rax); 5197 __ movp(prev_limit_reg, rax);
5200 __ LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate)); 5198 __ LoadAddress(arg_reg_1, ExternalReference::isolate_address(isolate));
5201 __ LoadAddress(rax, 5199 __ LoadAddress(rax,
5202 ExternalReference::delete_handle_scope_extensions(isolate)); 5200 ExternalReference::delete_handle_scope_extensions(isolate));
5203 __ call(rax); 5201 __ call(rax);
5204 __ movp(rax, prev_limit_reg); 5202 __ movp(rax, prev_limit_reg);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
5416 kStackSpace, nullptr, return_value_operand, NULL); 5414 kStackSpace, nullptr, return_value_operand, NULL);
5417 } 5415 }
5418 5416
5419 5417
5420 #undef __ 5418 #undef __
5421 5419
5422 } // namespace internal 5420 } // namespace internal
5423 } // namespace v8 5421 } // namespace v8
5424 5422
5425 #endif // V8_TARGET_ARCH_X64 5423 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/builtins-x64.cc ('k') | src/x64/macro-assembler-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698