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, StackOperandForArgument((argc + 1) * 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); |
(...skipping 15 matching lines...) Expand all Loading... | |
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, StackOperandForArgument((argc + 1) * 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 // Get the receiver of the function from the stack; 1 ~ return address. |
danno
2013/07/31 07:48:37
I don't understand the comment, what do you mean b
| |
969 __ movq(rdx, StackOperandForArgument((argc + 1) * 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(StackOperandForArgument((argc + 1) * 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, |
(...skipping 10 matching lines...) Expand all Loading... | |
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 + 1) * 8] : 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, StackOperandForArgument((argc + 1) * 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 + 1) * 8] : 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, StackOperandForArgument((argc + 1) * 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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 + 1) * 8] : argument 0 = receiver |
1303 // ----------------------------------- | 1304 // ----------------------------------- |
1304 Label slow, notin; | 1305 Label slow, notin; |
1305 __ movq(rdx, Operand(rsp, (argc + 1) * kPointerSize)); | 1306 __ movq(rdx, StackOperandForArgument((argc + 1) * kPointerSize)); |
danno
2013/07/31 07:48:37
Just to make it even prettier/more readible, how a
| |
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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1677 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) | 1678 Condition cc = (check == ENABLE_INLINED_SMI_CHECK) |
1678 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) | 1679 ? (*jmp_address == Assembler::kJncShortOpcode ? not_zero : zero) |
1679 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); | 1680 : (*jmp_address == Assembler::kJnzShortOpcode ? not_carry : carry); |
1680 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1681 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1681 } | 1682 } |
1682 | 1683 |
1683 | 1684 |
1684 } } // namespace v8::internal | 1685 } } // namespace v8::internal |
1685 | 1686 |
1686 #endif // V8_TARGET_ARCH_X64 | 1687 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |