OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 __ bind(&fast_double_without_map_check); | 853 __ bind(&fast_double_without_map_check); |
854 // If the value is a number, store it as a double in the FastDoubleElements | 854 // If the value is a number, store it as a double in the FastDoubleElements |
855 // array. | 855 // array. |
856 __ StoreNumberToDoubleElements(eax, ebx, ecx, edx, xmm0, &slow, false); | 856 __ StoreNumberToDoubleElements(eax, ebx, ecx, edx, xmm0, &slow, false); |
857 __ ret(0); | 857 __ ret(0); |
858 } | 858 } |
859 | 859 |
860 | 860 |
861 // The generated code does not accept smi keys. | 861 // The generated code does not accept smi keys. |
862 // The generated code falls through if both probes miss. | 862 // The generated code falls through if both probes miss. |
863 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, | 863 void CallICBase::GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
864 int argc, | 864 int argc, |
865 Code::Kind kind, | 865 Code::Kind kind, |
866 Code::ExtraICState extra_ic_state) { | 866 Code::ExtraICState extra_state) { |
867 // ----------- S t a t e ------------- | 867 // ----------- S t a t e ------------- |
868 // -- ecx : name | 868 // -- ecx : name |
869 // -- edx : receiver | 869 // -- edx : receiver |
870 // ----------------------------------- | 870 // ----------------------------------- |
871 Label number, non_number, non_string, boolean, probe, miss; | 871 Label number, non_number, non_string, boolean, probe, miss; |
872 | 872 |
873 // Probe the stub cache. | 873 // Probe the stub cache. |
874 Code::Flags flags = Code::ComputeFlags(kind, | 874 Code::Flags flags = Code::ComputeFlags(kind, |
875 MONOMORPHIC, | 875 MONOMORPHIC, |
876 extra_ic_state, | 876 extra_state, |
877 NORMAL, | 877 NORMAL, |
878 argc); | 878 argc); |
879 Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, | 879 Isolate* isolate = masm->isolate(); |
880 eax); | 880 isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, eax); |
881 | 881 |
882 // If the stub cache probing failed, the receiver might be a value. | 882 // If the stub cache probing failed, the receiver might be a value. |
883 // For value objects, we use the map of the prototype objects for | 883 // For value objects, we use the map of the prototype objects for |
884 // the corresponding JSValue for the cache and that is what we need | 884 // the corresponding JSValue for the cache and that is what we need |
885 // to probe. | 885 // to probe. |
886 // | 886 // |
887 // Check for number. | 887 // Check for number. |
888 __ JumpIfSmi(edx, &number); | 888 __ JumpIfSmi(edx, &number); |
889 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ebx); | 889 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ebx); |
890 __ j(not_equal, &non_number); | 890 __ j(not_equal, &non_number); |
891 __ bind(&number); | 891 __ bind(&number); |
892 StubCompiler::GenerateLoadGlobalFunctionPrototype( | 892 StubCompiler::GenerateLoadGlobalFunctionPrototype( |
893 masm, Context::NUMBER_FUNCTION_INDEX, edx); | 893 masm, Context::NUMBER_FUNCTION_INDEX, edx); |
894 __ jmp(&probe); | 894 __ jmp(&probe); |
895 | 895 |
896 // Check for string. | 896 // Check for string. |
897 __ bind(&non_number); | 897 __ bind(&non_number); |
898 __ CmpInstanceType(ebx, FIRST_NONSTRING_TYPE); | 898 __ CmpInstanceType(ebx, FIRST_NONSTRING_TYPE); |
899 __ j(above_equal, &non_string); | 899 __ j(above_equal, &non_string); |
900 StubCompiler::GenerateLoadGlobalFunctionPrototype( | 900 StubCompiler::GenerateLoadGlobalFunctionPrototype( |
901 masm, Context::STRING_FUNCTION_INDEX, edx); | 901 masm, Context::STRING_FUNCTION_INDEX, edx); |
902 __ jmp(&probe); | 902 __ jmp(&probe); |
903 | 903 |
904 // Check for boolean. | 904 // Check for boolean. |
905 __ bind(&non_string); | 905 __ bind(&non_string); |
906 __ cmp(edx, FACTORY->true_value()); | 906 __ cmp(edx, isolate->factory()->true_value()); |
907 __ j(equal, &boolean); | 907 __ j(equal, &boolean); |
908 __ cmp(edx, FACTORY->false_value()); | 908 __ cmp(edx, isolate->factory()->false_value()); |
909 __ j(not_equal, &miss); | 909 __ j(not_equal, &miss); |
910 __ bind(&boolean); | 910 __ bind(&boolean); |
911 StubCompiler::GenerateLoadGlobalFunctionPrototype( | 911 StubCompiler::GenerateLoadGlobalFunctionPrototype( |
912 masm, Context::BOOLEAN_FUNCTION_INDEX, edx); | 912 masm, Context::BOOLEAN_FUNCTION_INDEX, edx); |
913 | 913 |
914 // Probe the stub cache for the value object. | 914 // Probe the stub cache for the value object. |
915 __ bind(&probe); | 915 __ bind(&probe); |
916 Isolate::Current()->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, | 916 isolate->stub_cache()->GenerateProbe(masm, flags, edx, ecx, ebx, no_reg); |
917 no_reg); | |
918 __ bind(&miss); | 917 __ bind(&miss); |
919 } | 918 } |
920 | 919 |
921 | 920 |
922 static void GenerateFunctionTailCall(MacroAssembler* masm, | 921 static void GenerateFunctionTailCall(MacroAssembler* masm, |
923 int argc, | 922 int argc, |
924 Label* miss) { | 923 Label* miss) { |
925 // ----------- S t a t e ------------- | 924 // ----------- S t a t e ------------- |
926 // -- ecx : name | 925 // -- ecx : name |
927 // -- edi : function | 926 // -- edi : function |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 __ InvokeFunction(edi, | 1036 __ InvokeFunction(edi, |
1038 actual, | 1037 actual, |
1039 JUMP_FUNCTION, | 1038 JUMP_FUNCTION, |
1040 NullCallWrapper(), | 1039 NullCallWrapper(), |
1041 call_kind); | 1040 call_kind); |
1042 } | 1041 } |
1043 | 1042 |
1044 | 1043 |
1045 void CallIC::GenerateMegamorphic(MacroAssembler* masm, | 1044 void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
1046 int argc, | 1045 int argc, |
1047 Code::ExtraICState extra_ic_state) { | 1046 Code::ExtraICState extra_state) { |
1048 // ----------- S t a t e ------------- | 1047 // ----------- S t a t e ------------- |
1049 // -- ecx : name | 1048 // -- ecx : name |
1050 // -- esp[0] : return address | 1049 // -- esp[0] : return address |
1051 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1050 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
1052 // -- ... | 1051 // -- ... |
1053 // -- esp[(argc + 1) * 4] : receiver | 1052 // -- esp[(argc + 1) * 4] : receiver |
1054 // ----------------------------------- | 1053 // ----------------------------------- |
1055 | 1054 |
1056 // Get the receiver of the function from the stack; 1 ~ return address. | 1055 // Get the receiver of the function from the stack; 1 ~ return address. |
1057 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 1056 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
1058 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); | 1057 CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, |
| 1058 extra_state); |
1059 | 1059 |
1060 GenerateMiss(masm, argc, extra_ic_state); | 1060 GenerateMiss(masm, argc, extra_state); |
1061 } | 1061 } |
1062 | 1062 |
1063 | 1063 |
1064 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 1064 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
1065 // ----------- S t a t e ------------- | 1065 // ----------- S t a t e ------------- |
1066 // -- ecx : name | 1066 // -- ecx : name |
1067 // -- esp[0] : return address | 1067 // -- esp[0] : return address |
1068 // -- esp[(argc - n) * 4] : arg[n] (zero-based) | 1068 // -- esp[(argc - n) * 4] : arg[n] (zero-based) |
1069 // -- ... | 1069 // -- ... |
1070 // -- esp[(argc + 1) * 4] : receiver | 1070 // -- esp[(argc + 1) * 4] : receiver |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1152 isolate->factory()->hash_table_map(), | 1152 isolate->factory()->hash_table_map(), |
1153 &lookup_monomorphic_cache, | 1153 &lookup_monomorphic_cache, |
1154 DONT_DO_SMI_CHECK); | 1154 DONT_DO_SMI_CHECK); |
1155 | 1155 |
1156 GenerateDictionaryLoad(masm, &slow_load, ebx, ecx, eax, edi, edi); | 1156 GenerateDictionaryLoad(masm, &slow_load, ebx, ecx, eax, edi, edi); |
1157 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1); | 1157 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1); |
1158 __ jmp(&do_call); | 1158 __ jmp(&do_call); |
1159 | 1159 |
1160 __ bind(&lookup_monomorphic_cache); | 1160 __ bind(&lookup_monomorphic_cache); |
1161 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); | 1161 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1); |
1162 GenerateMonomorphicCacheProbe(masm, | 1162 CallICBase::GenerateMonomorphicCacheProbe(masm, argc, Code::KEYED_CALL_IC, |
1163 argc, | 1163 Code::kNoExtraICState); |
1164 Code::KEYED_CALL_IC, | |
1165 Code::kNoExtraICState); | |
1166 // Fall through on miss. | 1164 // Fall through on miss. |
1167 | 1165 |
1168 __ bind(&slow_call); | 1166 __ bind(&slow_call); |
1169 // This branch is taken if: | 1167 // This branch is taken if: |
1170 // - the receiver requires boxing or access check, | 1168 // - the receiver requires boxing or access check, |
1171 // - the key is neither smi nor symbol, | 1169 // - the key is neither smi nor symbol, |
1172 // - the value loaded is not a function, | 1170 // - the value loaded is not a function, |
1173 // - there is hope that the runtime will create a monomorphic call stub | 1171 // - there is hope that the runtime will create a monomorphic call stub |
1174 // that will get fetched next time. | 1172 // that will get fetched next time. |
1175 __ IncrementCounter(counters->keyed_call_generic_slow(), 1); | 1173 __ IncrementCounter(counters->keyed_call_generic_slow(), 1); |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 Condition cc = *jmp_address == Assembler::kJncShortOpcode | 1676 Condition cc = *jmp_address == Assembler::kJncShortOpcode |
1679 ? not_zero | 1677 ? not_zero |
1680 : zero; | 1678 : zero; |
1681 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); | 1679 *jmp_address = static_cast<byte>(Assembler::kJccShortPrefix | cc); |
1682 } | 1680 } |
1683 | 1681 |
1684 | 1682 |
1685 } } // namespace v8::internal | 1683 } } // namespace v8::internal |
1686 | 1684 |
1687 #endif // V8_TARGET_ARCH_IA32 | 1685 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |