| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 no_reg); | 863 no_reg); |
| 864 | 864 |
| 865 __ bind(&miss); | 865 __ bind(&miss); |
| 866 } | 866 } |
| 867 | 867 |
| 868 | 868 |
| 869 static void GenerateFunctionTailCall(MacroAssembler* masm, | 869 static void GenerateFunctionTailCall(MacroAssembler* masm, |
| 870 int argc, | 870 int argc, |
| 871 Label* miss) { | 871 Label* miss) { |
| 872 // ----------- S t a t e ------------- | 872 // ----------- S t a t e ------------- |
| 873 // rcx : function name | 873 // rcx : function name |
| 874 // rdi : function | 874 // rdi : function |
| 875 // rsp[0] : return address | 875 // rsp[0] : return address |
| 876 // rsp[8] : argument argc | 876 // rsp[8] : argument argc |
| 877 // rsp[16] : argument argc - 1 | 877 // rsp[16] : argument argc - 1 |
| 878 // ... | 878 // ... |
| 879 // rsp[argc * 8] : argument 1 | 879 // rsp[argc * 8] : argument 1 |
| 880 // rsp[(argc + 1) * 8] : argument 0 = receiver | 880 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 881 // ----------------------------------- | 881 // ----------------------------------- |
| 882 __ JumpIfSmi(rdi, miss); | 882 __ JumpIfSmi(rdi, miss); |
| 883 // Check that the value is a JavaScript function. | 883 // Check that the value is a JavaScript function. |
| 884 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rdx); | 884 __ CmpObjectType(rdi, JS_FUNCTION_TYPE, rdx); |
| 885 __ j(not_equal, miss); | 885 __ j(not_equal, miss); |
| 886 | 886 |
| 887 // Invoke the function. | 887 // Invoke the function. |
| 888 ParameterCount actual(argc); | 888 ParameterCount actual(argc); |
| 889 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, | 889 __ InvokeFunction(rdi, actual, JUMP_FUNCTION, |
| 890 NullCallWrapper(), CALL_AS_METHOD); | 890 NullCallWrapper(), CALL_AS_METHOD); |
| 891 } | 891 } |
| 892 | 892 |
| 893 | 893 |
| 894 // The generated code falls through if the call should be handled by runtime. | 894 // The generated code falls through if the call should be handled by runtime. |
| 895 void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) { | 895 void CallICBase::GenerateNormal(MacroAssembler* masm, int argc) { |
| 896 // ----------- S t a t e ------------- | 896 // ----------- S t a t e ------------- |
| 897 // rcx : function name | 897 // rcx : function name |
| 898 // rsp[0] : return address | 898 // rsp[0] : return address |
| 899 // rsp[8] : argument argc | 899 // rsp[8] : argument argc |
| 900 // rsp[16] : argument argc - 1 | 900 // rsp[16] : argument argc - 1 |
| 901 // ... | 901 // ... |
| 902 // rsp[argc * 8] : argument 1 | 902 // rsp[argc * 8] : argument 1 |
| 903 // rsp[(argc + 1) * 8] : argument 0 = receiver | 903 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 904 // ----------------------------------- | 904 // ----------------------------------- |
| 905 Label miss; | 905 Label miss; |
| 906 | 906 |
| 907 // Get the receiver of the function from the stack. | 907 // Get the receiver of the function from the stack. |
| 908 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 908 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 909 | 909 |
| 910 GenerateNameDictionaryReceiverCheck(masm, rdx, rax, rbx, &miss); | 910 GenerateNameDictionaryReceiverCheck(masm, rdx, rax, rbx, &miss); |
| 911 | 911 |
| 912 // rax: elements | 912 // rax: elements |
| 913 // Search the dictionary placing the result in rdi. | 913 // Search the dictionary placing the result in rdi. |
| 914 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi); | 914 GenerateDictionaryLoad(masm, &miss, rax, rcx, rbx, rdi, rdi); |
| 915 | 915 |
| 916 GenerateFunctionTailCall(masm, argc, &miss); | 916 GenerateFunctionTailCall(masm, argc, &miss); |
| 917 | 917 |
| 918 __ bind(&miss); | 918 __ bind(&miss); |
| 919 } | 919 } |
| 920 | 920 |
| 921 | 921 |
| 922 void CallICBase::GenerateMiss(MacroAssembler* masm, | 922 void CallICBase::GenerateMiss(MacroAssembler* masm, |
| 923 int argc, | 923 int argc, |
| 924 IC::UtilityId id, | 924 IC::UtilityId id, |
| 925 Code::ExtraICState extra_state) { | 925 Code::ExtraICState extra_state) { |
| 926 // ----------- S t a t e ------------- | 926 // ----------- S t a t e ------------- |
| 927 // rcx : function name | 927 // rcx : function name |
| 928 // rsp[0] : return address | 928 // rsp[0] : return address |
| 929 // rsp[8] : argument argc | 929 // rsp[8] : argument argc |
| 930 // rsp[16] : argument argc - 1 | 930 // rsp[16] : argument argc - 1 |
| 931 // ... | 931 // ... |
| 932 // rsp[argc * 8] : argument 1 | 932 // rsp[argc * 8] : argument 1 |
| 933 // rsp[(argc + 1) * 8] : argument 0 = receiver | 933 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 934 // ----------------------------------- | 934 // ----------------------------------- |
| 935 | 935 |
| 936 Counters* counters = masm->isolate()->counters(); | 936 Counters* counters = masm->isolate()->counters(); |
| 937 if (id == IC::kCallIC_Miss) { | 937 if (id == IC::kCallIC_Miss) { |
| 938 __ IncrementCounter(counters->call_miss(), 1); | 938 __ IncrementCounter(counters->call_miss(), 1); |
| 939 } else { | 939 } else { |
| 940 __ IncrementCounter(counters->keyed_call_miss(), 1); | 940 __ IncrementCounter(counters->keyed_call_miss(), 1); |
| 941 } | 941 } |
| 942 | 942 |
| 943 // Get the receiver of the function from the stack; 1 ~ return address. | 943 // Get the receiver of the function from the stack; 1 ~ return address. |
| 944 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 944 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 945 | 945 |
| 946 // Enter an internal frame. | 946 // Enter an internal frame. |
| 947 { | 947 { |
| 948 FrameScope scope(masm, StackFrame::INTERNAL); | 948 FrameScope scope(masm, StackFrame::INTERNAL); |
| 949 | 949 |
| 950 // Push the receiver and the name of the function. | 950 // Push the receiver and the name of the function. |
| 951 __ push(rdx); | 951 __ push(rdx); |
| 952 __ push(rcx); | 952 __ push(rcx); |
| 953 | 953 |
| 954 // Call the entry. | 954 // Call the entry. |
| 955 CEntryStub stub(1); | 955 CEntryStub stub(1); |
| 956 __ Set(rax, 2); | 956 __ Set(rax, 2); |
| 957 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate())); | 957 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate())); |
| 958 __ CallStub(&stub); | 958 __ CallStub(&stub); |
| 959 | 959 |
| 960 // Move result to rdi and exit the internal frame. | 960 // Move result to rdi and exit the internal frame. |
| 961 __ movq(rdi, rax); | 961 __ movq(rdi, rax); |
| 962 } | 962 } |
| 963 | 963 |
| 964 // Check if the receiver is a global object of some sort. | 964 // Check if the receiver is a global object of some sort. |
| 965 // This can happen only for regular CallIC but not KeyedCallIC. | 965 // This can happen only for regular CallIC but not KeyedCallIC. |
| 966 if (id == IC::kCallIC_Miss) { | 966 if (id == IC::kCallIC_Miss) { |
| 967 Label invoke, global; | 967 Label invoke, global; |
| 968 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); // receiver | 968 // receiver |
| 969 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 969 __ JumpIfSmi(rdx, &invoke); | 970 __ JumpIfSmi(rdx, &invoke); |
| 970 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx); | 971 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx); |
| 971 __ j(equal, &global); | 972 __ j(equal, &global); |
| 972 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE); | 973 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE); |
| 973 __ j(not_equal, &invoke); | 974 __ j(not_equal, &invoke); |
| 974 | 975 |
| 975 // Patch the receiver on the stack. | 976 // Patch the receiver on the stack. |
| 976 __ bind(&global); | 977 __ bind(&global); |
| 977 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); | 978 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 978 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); | 979 __ movq(Operand(rsp, kPCOnStackSize + argc * kPointerSize), rdx); |
| 979 __ bind(&invoke); | 980 __ bind(&invoke); |
| 980 } | 981 } |
| 981 | 982 |
| 982 // Invoke the function. | 983 // Invoke the function. |
| 983 CallKind call_kind = CallICBase::Contextual::decode(extra_state) | 984 CallKind call_kind = CallICBase::Contextual::decode(extra_state) |
| 984 ? CALL_AS_FUNCTION | 985 ? CALL_AS_FUNCTION |
| 985 : CALL_AS_METHOD; | 986 : CALL_AS_METHOD; |
| 986 ParameterCount actual(argc); | 987 ParameterCount actual(argc); |
| 987 __ InvokeFunction(rdi, | 988 __ InvokeFunction(rdi, |
| 988 actual, | 989 actual, |
| 989 JUMP_FUNCTION, | 990 JUMP_FUNCTION, |
| 990 NullCallWrapper(), | 991 NullCallWrapper(), |
| 991 call_kind); | 992 call_kind); |
| 992 } | 993 } |
| 993 | 994 |
| 994 | 995 |
| 995 void CallIC::GenerateMegamorphic(MacroAssembler* masm, | 996 void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
| 996 int argc, | 997 int argc, |
| 997 Code::ExtraICState extra_ic_state) { | 998 Code::ExtraICState extra_ic_state) { |
| 998 // ----------- S t a t e ------------- | 999 // ----------- S t a t e ------------- |
| 999 // rcx : function name | 1000 // rcx : function name |
| 1000 // rsp[0] : return address | 1001 // rsp[0] : return address |
| 1001 // rsp[8] : argument argc | 1002 // rsp[8] : argument argc |
| 1002 // rsp[16] : argument argc - 1 | 1003 // rsp[16] : argument argc - 1 |
| 1003 // ... | 1004 // ... |
| 1004 // rsp[argc * 8] : argument 1 | 1005 // rsp[argc * 8] : argument 1 |
| 1005 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1006 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 1006 // ----------------------------------- | 1007 // ----------------------------------- |
| 1007 | 1008 |
| 1008 // Get the receiver of the function from the stack; 1 ~ return address. | 1009 // Get the receiver of the function from the stack; 1 ~ return address. |
| 1009 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1010 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 1010 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); | 1011 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); |
| 1011 GenerateMiss(masm, argc, extra_ic_state); | 1012 GenerateMiss(masm, argc, extra_ic_state); |
| 1012 } | 1013 } |
| 1013 | 1014 |
| 1014 | 1015 |
| 1015 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 1016 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
| 1016 // ----------- S t a t e ------------- | 1017 // ----------- S t a t e ------------- |
| 1017 // rcx : function name | 1018 // rcx : function name |
| 1018 // rsp[0] : return address | 1019 // rsp[0] : return address |
| 1019 // rsp[8] : argument argc | 1020 // rsp[8] : argument argc |
| 1020 // rsp[16] : argument argc - 1 | 1021 // rsp[16] : argument argc - 1 |
| 1021 // ... | 1022 // ... |
| 1022 // rsp[argc * 8] : argument 1 | 1023 // rsp[argc * 8] : argument 1 |
| 1023 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1024 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 1024 // ----------------------------------- | 1025 // ----------------------------------- |
| 1025 | 1026 |
| 1026 // Get the receiver of the function from the stack; 1 ~ return address. | 1027 // Get the receiver of the function from the stack; 1 ~ return address. |
| 1027 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1028 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 1028 | 1029 |
| 1029 Label do_call, slow_call, slow_load; | 1030 Label do_call, slow_call, slow_load; |
| 1030 Label check_number_dictionary, check_name, lookup_monomorphic_cache; | 1031 Label check_number_dictionary, check_name, lookup_monomorphic_cache; |
| 1031 Label index_smi, index_name; | 1032 Label index_smi, index_name; |
| 1032 | 1033 |
| 1033 // Check that the key is a smi. | 1034 // Check that the key is a smi. |
| 1034 __ JumpIfNotSmi(rcx, &check_name); | 1035 __ JumpIfNotSmi(rcx, &check_name); |
| 1035 | 1036 |
| 1036 __ bind(&index_smi); | 1037 __ bind(&index_smi); |
| 1037 // Now the key is known to be a smi. This place is also jumped to from below | 1038 // Now the key is known to be a smi. This place is also jumped to from below |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1118 | 1119 |
| 1119 __ bind(&index_name); | 1120 __ bind(&index_name); |
| 1120 __ IndexFromHash(rbx, rcx); | 1121 __ IndexFromHash(rbx, rcx); |
| 1121 // Now jump to the place where smi keys are handled. | 1122 // Now jump to the place where smi keys are handled. |
| 1122 __ jmp(&index_smi); | 1123 __ jmp(&index_smi); |
| 1123 } | 1124 } |
| 1124 | 1125 |
| 1125 | 1126 |
| 1126 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) { | 1127 void KeyedCallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
| 1127 // ----------- S t a t e ------------- | 1128 // ----------- S t a t e ------------- |
| 1128 // rcx : function name | 1129 // rcx : function name |
| 1129 // rsp[0] : return address | 1130 // rsp[0] : return address |
| 1130 // rsp[8] : argument argc | 1131 // rsp[8] : argument argc |
| 1131 // rsp[16] : argument argc - 1 | 1132 // rsp[16] : argument argc - 1 |
| 1132 // ... | 1133 // ... |
| 1133 // rsp[argc * 8] : argument 1 | 1134 // rsp[argc * 8] : argument 1 |
| 1134 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1135 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 1135 // ----------------------------------- | 1136 // ----------------------------------- |
| 1136 | 1137 |
| 1137 // Check if the name is really a name. | 1138 // Check if the name is really a name. |
| 1138 Label miss; | 1139 Label miss; |
| 1139 __ JumpIfSmi(rcx, &miss); | 1140 __ JumpIfSmi(rcx, &miss); |
| 1140 Condition cond = masm->IsObjectNameType(rcx, rax, rax); | 1141 Condition cond = masm->IsObjectNameType(rcx, rax, rax); |
| 1141 __ j(NegateCondition(cond), &miss); | 1142 __ j(NegateCondition(cond), &miss); |
| 1142 CallICBase::GenerateNormal(masm, argc); | 1143 CallICBase::GenerateNormal(masm, argc); |
| 1143 __ bind(&miss); | 1144 __ bind(&miss); |
| 1144 GenerateMiss(masm, argc); | 1145 GenerateMiss(masm, argc); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 INLINE_SMI_CHECK); | 1287 INLINE_SMI_CHECK); |
| 1287 __ Ret(); | 1288 __ Ret(); |
| 1288 __ bind(&slow); | 1289 __ bind(&slow); |
| 1289 GenerateMiss(masm, MISS); | 1290 GenerateMiss(masm, MISS); |
| 1290 } | 1291 } |
| 1291 | 1292 |
| 1292 | 1293 |
| 1293 void KeyedCallIC::GenerateNonStrictArguments(MacroAssembler* masm, | 1294 void KeyedCallIC::GenerateNonStrictArguments(MacroAssembler* masm, |
| 1294 int argc) { | 1295 int argc) { |
| 1295 // ----------- S t a t e ------------- | 1296 // ----------- S t a t e ------------- |
| 1296 // rcx : function name | 1297 // rcx : function name |
| 1297 // rsp[0] : return address | 1298 // rsp[0] : return address |
| 1298 // rsp[8] : argument argc | 1299 // rsp[8] : argument argc |
| 1299 // rsp[16] : argument argc - 1 | 1300 // rsp[16] : argument argc - 1 |
| 1300 // ... | 1301 // ... |
| 1301 // rsp[argc * 8] : argument 1 | 1302 // rsp[argc * 8] : argument 1 |
| 1302 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1303 // rsp[argc * 8 + kPCOnStackSize] : argument 0 = receiver |
| 1303 // ----------------------------------- | 1304 // ----------------------------------- |
| 1304 Label slow, notin; | 1305 Label slow, notin; |
| 1305 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1306 __ movq(rdx, Operand(rsp, kPCOnStackSize + argc * kPointerSize)); |
| 1306 Operand mapped_location = GenerateMappedArgumentsLookup( | 1307 Operand mapped_location = GenerateMappedArgumentsLookup( |
| 1307 masm, rdx, rcx, rbx, rax, r8, ¬in, &slow); | 1308 masm, rdx, rcx, rbx, rax, r8, ¬in, &slow); |
| 1308 __ movq(rdi, mapped_location); | 1309 __ movq(rdi, mapped_location); |
| 1309 GenerateFunctionTailCall(masm, argc, &slow); | 1310 GenerateFunctionTailCall(masm, argc, &slow); |
| 1310 __ bind(¬in); | 1311 __ bind(¬in); |
| 1311 // The unmapped lookup expects that the parameter map is in rbx. | 1312 // The unmapped lookup expects that the parameter map is in rbx. |
| 1312 Operand unmapped_location = | 1313 Operand unmapped_location = |
| 1313 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); | 1314 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); |
| 1314 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); | 1315 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); |
| 1315 __ j(equal, &slow); | 1316 __ j(equal, &slow); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) | 1727 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
| 1727 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) | 1728 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
| 1728 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); | 1729 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
| 1729 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1730 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
| 1730 } | 1731 } |
| 1731 | 1732 |
| 1732 | 1733 |
| 1733 } } // namespace v8::internal | 1734 } } // namespace v8::internal |
| 1734 | 1735 |
| 1735 #endif // V8_TARGET_ARCH_X64 | 1736 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |