| 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 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 + 1) * 8] : 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, StackOperandForReceiver(argc)); |
| 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); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 933 // rsp[(argc + 1) * 8] : argument 0 = receiver | 933 // rsp[(argc + 1) * 8] : 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 __ movq(rdx, StackOperandForReceiver(argc)); |
| 944 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | |
| 945 | 944 |
| 946 // Enter an internal frame. | 945 // Enter an internal frame. |
| 947 { | 946 { |
| 948 FrameScope scope(masm, StackFrame::INTERNAL); | 947 FrameScope scope(masm, StackFrame::INTERNAL); |
| 949 | 948 |
| 950 // Push the receiver and the name of the function. | 949 // Push the receiver and the name of the function. |
| 951 __ push(rdx); | 950 __ push(rdx); |
| 952 __ push(rcx); | 951 __ push(rcx); |
| 953 | 952 |
| 954 // Call the entry. | 953 // Call the entry. |
| 955 CEntryStub stub(1); | 954 CEntryStub stub(1); |
| 956 __ Set(rax, 2); | 955 __ Set(rax, 2); |
| 957 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate())); | 956 __ LoadAddress(rbx, ExternalReference(IC_Utility(id), masm->isolate())); |
| 958 __ CallStub(&stub); | 957 __ CallStub(&stub); |
| 959 | 958 |
| 960 // Move result to rdi and exit the internal frame. | 959 // Move result to rdi and exit the internal frame. |
| 961 __ movq(rdi, rax); | 960 __ movq(rdi, rax); |
| 962 } | 961 } |
| 963 | 962 |
| 964 // Check if the receiver is a global object of some sort. | 963 // Check if the receiver is a global object of some sort. |
| 965 // This can happen only for regular CallIC but not KeyedCallIC. | 964 // This can happen only for regular CallIC but not KeyedCallIC. |
| 966 if (id == IC::kCallIC_Miss) { | 965 if (id == IC::kCallIC_Miss) { |
| 967 Label invoke, global; | 966 Label invoke, global; |
| 968 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); // receiver | 967 __ movq(rdx, StackOperandForReceiver(argc)); |
| 969 __ JumpIfSmi(rdx, &invoke); | 968 __ JumpIfSmi(rdx, &invoke); |
| 970 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx); | 969 __ CmpObjectType(rdx, JS_GLOBAL_OBJECT_TYPE, rcx); |
| 971 __ j(equal, &global); | 970 __ j(equal, &global); |
| 972 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE); | 971 __ CmpInstanceType(rcx, JS_BUILTINS_OBJECT_TYPE); |
| 973 __ j(not_equal, &invoke); | 972 __ j(not_equal, &invoke); |
| 974 | 973 |
| 975 // Patch the receiver on the stack. | 974 // Patch the receiver on the stack. |
| 976 __ bind(&global); | 975 __ bind(&global); |
| 977 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); | 976 __ movq(rdx, FieldOperand(rdx, GlobalObject::kGlobalReceiverOffset)); |
| 978 __ movq(Operand(rsp, (argc + 1) * kPointerSize), rdx); | 977 __ movq(StackOperandForReceiver(argc), rdx); |
| 979 __ bind(&invoke); | 978 __ bind(&invoke); |
| 980 } | 979 } |
| 981 | 980 |
| 982 // Invoke the function. | 981 // Invoke the function. |
| 983 CallKind call_kind = CallICBase::Contextual::decode(extra_state) | 982 CallKind call_kind = CallICBase::Contextual::decode(extra_state) |
| 984 ? CALL_AS_FUNCTION | 983 ? CALL_AS_FUNCTION |
| 985 : CALL_AS_METHOD; | 984 : CALL_AS_METHOD; |
| 986 ParameterCount actual(argc); | 985 ParameterCount actual(argc); |
| 987 __ InvokeFunction(rdi, | 986 __ InvokeFunction(rdi, |
| 988 actual, | 987 actual, |
| 989 JUMP_FUNCTION, | 988 JUMP_FUNCTION, |
| 990 NullCallWrapper(), | 989 NullCallWrapper(), |
| 991 call_kind); | 990 call_kind); |
| 992 } | 991 } |
| 993 | 992 |
| 994 | 993 |
| 995 void CallIC::GenerateMegamorphic(MacroAssembler* masm, | 994 void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
| 996 int argc, | 995 int argc, |
| 997 Code::ExtraICState extra_ic_state) { | 996 Code::ExtraICState extra_ic_state) { |
| 998 // ----------- S t a t e ------------- | 997 // ----------- S t a t e ------------- |
| 999 // rcx : function name | 998 // rcx : function name |
| 1000 // rsp[0] : return address | 999 // rsp[0] : return address |
| 1001 // rsp[8] : argument argc | 1000 // rsp[8] : argument argc |
| 1002 // rsp[16] : argument argc - 1 | 1001 // rsp[16] : argument argc - 1 |
| 1003 // ... | 1002 // ... |
| 1004 // rsp[argc * 8] : argument 1 | 1003 // rsp[argc * 8] : argument 1 |
| 1005 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1004 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 1006 // ----------------------------------- | 1005 // ----------------------------------- |
| 1007 | 1006 |
| 1008 // Get the receiver of the function from the stack; 1 ~ return address. | 1007 __ movq(rdx, StackOperandForReceiver(argc)); |
| 1009 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | |
| 1010 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); | 1008 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); |
| 1011 GenerateMiss(masm, argc, extra_ic_state); | 1009 GenerateMiss(masm, argc, extra_ic_state); |
| 1012 } | 1010 } |
| 1013 | 1011 |
| 1014 | 1012 |
| 1015 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 1013 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
| 1016 // ----------- S t a t e ------------- | 1014 // ----------- S t a t e ------------- |
| 1017 // rcx : function name | 1015 // rcx : function name |
| 1018 // rsp[0] : return address | 1016 // rsp[0] : return address |
| 1019 // rsp[8] : argument argc | 1017 // rsp[8] : argument argc |
| 1020 // rsp[16] : argument argc - 1 | 1018 // rsp[16] : argument argc - 1 |
| 1021 // ... | 1019 // ... |
| 1022 // rsp[argc * 8] : argument 1 | 1020 // rsp[argc * 8] : argument 1 |
| 1023 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1021 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 1024 // ----------------------------------- | 1022 // ----------------------------------- |
| 1025 | 1023 |
| 1026 // Get the receiver of the function from the stack; 1 ~ return address. | 1024 __ movq(rdx, StackOperandForReceiver(argc)); |
| 1027 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | |
| 1028 | 1025 |
| 1029 Label do_call, slow_call, slow_load; | 1026 Label do_call, slow_call, slow_load; |
| 1030 Label check_number_dictionary, check_name, lookup_monomorphic_cache; | 1027 Label check_number_dictionary, check_name, lookup_monomorphic_cache; |
| 1031 Label index_smi, index_name; | 1028 Label index_smi, index_name; |
| 1032 | 1029 |
| 1033 // Check that the key is a smi. | 1030 // Check that the key is a smi. |
| 1034 __ JumpIfNotSmi(rcx, &check_name); | 1031 __ JumpIfNotSmi(rcx, &check_name); |
| 1035 | 1032 |
| 1036 __ bind(&index_smi); | 1033 __ bind(&index_smi); |
| 1037 // Now the key is known to be a smi. This place is also jumped to from below | 1034 // Now the key is known to be a smi. This place is also jumped to from below |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 // ----------- S t a t e ------------- | 1292 // ----------- S t a t e ------------- |
| 1296 // rcx : function name | 1293 // rcx : function name |
| 1297 // rsp[0] : return address | 1294 // rsp[0] : return address |
| 1298 // rsp[8] : argument argc | 1295 // rsp[8] : argument argc |
| 1299 // rsp[16] : argument argc - 1 | 1296 // rsp[16] : argument argc - 1 |
| 1300 // ... | 1297 // ... |
| 1301 // rsp[argc * 8] : argument 1 | 1298 // rsp[argc * 8] : argument 1 |
| 1302 // rsp[(argc + 1) * 8] : argument 0 = receiver | 1299 // rsp[(argc + 1) * 8] : argument 0 = receiver |
| 1303 // ----------------------------------- | 1300 // ----------------------------------- |
| 1304 Label slow, notin; | 1301 Label slow, notin; |
| 1305 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1302 __ movq(rdx, StackOperandForReceiver(argc)); |
| 1306 Operand mapped_location = GenerateMappedArgumentsLookup( | 1303 Operand mapped_location = GenerateMappedArgumentsLookup( |
| 1307 masm, rdx, rcx, rbx, rax, r8, ¬in, &slow); | 1304 masm, rdx, rcx, rbx, rax, r8, ¬in, &slow); |
| 1308 __ movq(rdi, mapped_location); | 1305 __ movq(rdi, mapped_location); |
| 1309 GenerateFunctionTailCall(masm, argc, &slow); | 1306 GenerateFunctionTailCall(masm, argc, &slow); |
| 1310 __ bind(¬in); | 1307 __ bind(¬in); |
| 1311 // The unmapped lookup expects that the parameter map is in rbx. | 1308 // The unmapped lookup expects that the parameter map is in rbx. |
| 1312 Operand unmapped_location = | 1309 Operand unmapped_location = |
| 1313 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); | 1310 GenerateUnmappedArgumentsLookup(masm, rcx, rbx, rax, &slow); |
| 1314 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); | 1311 __ CompareRoot(unmapped_location, Heap::kTheHoleValueRootIndex); |
| 1315 __ j(equal, &slow); | 1312 __ j(equal, &slow); |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1677 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) | 1674 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
| 1678 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) | 1675 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
| 1679 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); | 1676 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
| 1680 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1677 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
| 1681 } | 1678 } |
| 1682 | 1679 |
| 1683 | 1680 |
| 1684 } } // namespace v8::internal | 1681 } } // namespace v8::internal |
| 1685 | 1682 |
| 1686 #endif // V8_TARGET_ARCH_X64 | 1683 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |