Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 93 | 93 |
| 94 | 94 |
| 95 Object* StubCache::ComputeLoadField(String* name, | 95 Object* StubCache::ComputeLoadField(String* name, |
| 96 JSObject* receiver, | 96 JSObject* receiver, |
| 97 JSObject* holder, | 97 JSObject* holder, |
| 98 int field_index) { | 98 int field_index) { |
| 99 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); | 99 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, FIELD); |
| 100 Object* code = receiver->map()->FindInCodeCache(name, flags); | 100 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 101 if (code->IsUndefined()) { | 101 if (code->IsUndefined()) { |
| 102 LoadStubCompiler compiler; | 102 LoadStubCompiler compiler; |
| 103 code = compiler.CompileLoadField(receiver, holder, field_index); | 103 code = compiler.CompileLoadField(receiver, holder, field_index, name); |
| 104 if (code->IsFailure()) return code; | 104 if (code->IsFailure()) return code; |
| 105 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); | 105 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); |
| 106 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); | 106 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
| 107 if (result->IsFailure()) return code; | 107 if (result->IsFailure()) return code; |
| 108 } | 108 } |
| 109 return Set(name, receiver->map(), Code::cast(code)); | 109 return Set(name, receiver->map(), Code::cast(code)); |
| 110 } | 110 } |
| 111 | 111 |
| 112 | 112 |
| 113 Object* StubCache::ComputeLoadCallback(String* name, | 113 Object* StubCache::ComputeLoadCallback(String* name, |
| 114 JSObject* receiver, | 114 JSObject* receiver, |
| 115 JSObject* holder, | 115 JSObject* holder, |
| 116 AccessorInfo* callback) { | 116 AccessorInfo* callback) { |
| 117 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); | 117 ASSERT(v8::ToCData<Address>(callback->getter()) != 0); |
| 118 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); | 118 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::LOAD_IC, CALLBACKS); |
| 119 Object* code = receiver->map()->FindInCodeCache(name, flags); | 119 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 120 if (code->IsUndefined()) { | 120 if (code->IsUndefined()) { |
| 121 LoadStubCompiler compiler; | 121 LoadStubCompiler compiler; |
| 122 code = compiler.CompileLoadCallback(receiver, holder, callback); | 122 code = compiler.CompileLoadCallback(receiver, holder, callback, name); |
| 123 if (code->IsFailure()) return code; | 123 if (code->IsFailure()) return code; |
| 124 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); | 124 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); |
| 125 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); | 125 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
| 126 if (result->IsFailure()) return code; | 126 if (result->IsFailure()) return code; |
| 127 } | 127 } |
| 128 return Set(name, receiver->map(), Code::cast(code)); | 128 return Set(name, receiver->map(), Code::cast(code)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 | 131 |
| 132 Object* StubCache::ComputeLoadConstant(String* name, | 132 Object* StubCache::ComputeLoadConstant(String* name, |
| 133 JSObject* receiver, | 133 JSObject* receiver, |
| 134 JSObject* holder, | 134 JSObject* holder, |
| 135 Object* value) { | 135 Object* value) { |
| 136 Code::Flags flags = | 136 Code::Flags flags = |
| 137 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); | 137 Code::ComputeMonomorphicFlags(Code::LOAD_IC, CONSTANT_FUNCTION); |
| 138 Object* code = receiver->map()->FindInCodeCache(name, flags); | 138 Object* code = receiver->map()->FindInCodeCache(name, flags); |
| 139 if (code->IsUndefined()) { | 139 if (code->IsUndefined()) { |
| 140 LoadStubCompiler compiler; | 140 LoadStubCompiler compiler; |
| 141 code = compiler.CompileLoadConstant(receiver, holder, value); | 141 code = compiler.CompileLoadConstant(receiver, holder, value, name); |
| 142 if (code->IsFailure()) return code; | 142 if (code->IsFailure()) return code; |
| 143 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); | 143 LOG(CodeCreateEvent("LoadIC", Code::cast(code), name)); |
| 144 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); | 144 Object* result = receiver->map()->UpdateCodeCache(name, Code::cast(code)); |
| 145 if (result->IsFailure()) return code; | 145 if (result->IsFailure()) return code; |
| 146 } | 146 } |
| 147 return Set(name, receiver->map(), Code::cast(code)); | 147 return Set(name, receiver->map(), Code::cast(code)); |
| 148 } | 148 } |
| 149 | 149 |
| 150 | 150 |
| 151 Object* StubCache::ComputeLoadInterceptor(String* name, | 151 Object* StubCache::ComputeLoadInterceptor(String* name, |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 // because they may be represented as immediates without a | 427 // because they may be represented as immediates without a |
| 428 // map. Instead, we check against the map in the holder. | 428 // map. Instead, we check against the map in the holder. |
| 429 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { | 429 if (object->IsNumber() || object->IsBoolean() || object->IsString()) { |
| 430 object = holder; | 430 object = holder; |
| 431 } | 431 } |
| 432 | 432 |
| 433 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, FIELD, argc); | 433 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, FIELD, argc); |
| 434 Object* code = map->FindInCodeCache(name, flags); | 434 Object* code = map->FindInCodeCache(name, flags); |
| 435 if (code->IsUndefined()) { | 435 if (code->IsUndefined()) { |
| 436 CallStubCompiler compiler(argc); | 436 CallStubCompiler compiler(argc); |
| 437 code = compiler.CompileCallField(object, holder, index); | 437 code = compiler.CompileCallField(object, holder, index, name); |
| 438 if (code->IsFailure()) return code; | 438 if (code->IsFailure()) return code; |
| 439 LOG(CodeCreateEvent("CallIC", Code::cast(code), name)); | 439 LOG(CodeCreateEvent("CallIC", Code::cast(code), name)); |
| 440 Object* result = map->UpdateCodeCache(name, Code::cast(code)); | 440 Object* result = map->UpdateCodeCache(name, Code::cast(code)); |
| 441 if (result->IsFailure()) return result; | 441 if (result->IsFailure()) return result; |
| 442 } | 442 } |
| 443 return Set(name, map, Code::cast(code)); | 443 return Set(name, map, Code::cast(code)); |
| 444 } | 444 } |
| 445 | 445 |
| 446 | 446 |
| 447 Object* StubCache::ComputeCallInterceptor(int argc, | 447 Object* StubCache::ComputeCallInterceptor(int argc, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 781 return Failure::Exception(); | 781 return Failure::Exception(); |
| 782 } | 782 } |
| 783 return *result; | 783 return *result; |
| 784 } | 784 } |
| 785 | 785 |
| 786 | 786 |
| 787 Object* StubCompiler::CompileCallInitialize(Code::Flags flags) { | 787 Object* StubCompiler::CompileCallInitialize(Code::Flags flags) { |
| 788 HandleScope scope; | 788 HandleScope scope; |
| 789 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 789 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 790 CallIC::GenerateInitialize(masm(), argc); | 790 CallIC::GenerateInitialize(masm(), argc); |
| 791 Object* result = GetCodeWithFlags(flags); | 791 Object* result = GetCodeWithFlags(flags, "CompileCallInitialize"); |
| 792 if (!result->IsFailure()) { | 792 if (!result->IsFailure()) { |
| 793 Counters::call_initialize_stubs.Increment(); | 793 Counters::call_initialize_stubs.Increment(); |
| 794 Code* code = Code::cast(result); | 794 Code* code = Code::cast(result); |
| 795 USE(code); | 795 USE(code); |
| 796 LOG(CodeCreateEvent("CallInitialize", code, code->arguments_count())); | 796 LOG(CodeCreateEvent("CallInitialize", code, code->arguments_count())); |
| 797 } | 797 } |
| 798 return result; | 798 return result; |
| 799 } | 799 } |
| 800 | 800 |
| 801 | 801 |
| 802 Object* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { | 802 Object* StubCompiler::CompileCallPreMonomorphic(Code::Flags flags) { |
| 803 HandleScope scope; | 803 HandleScope scope; |
| 804 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 804 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 805 CallIC::GenerateInitialize(masm(), argc); | 805 CallIC::GenerateInitialize(masm(), argc); |
| 806 Object* result = GetCodeWithFlags(flags); | 806 Object* result = GetCodeWithFlags(flags, "CompileCallPreMonomorphic"); |
| 807 if (!result->IsFailure()) { | 807 if (!result->IsFailure()) { |
| 808 Counters::call_premonomorphic_stubs.Increment(); | 808 Counters::call_premonomorphic_stubs.Increment(); |
| 809 Code* code = Code::cast(result); | 809 Code* code = Code::cast(result); |
| 810 USE(code); | 810 USE(code); |
| 811 LOG(CodeCreateEvent("CallPreMonomorphic", code, code->arguments_count())); | 811 LOG(CodeCreateEvent("CallPreMonomorphic", code, code->arguments_count())); |
| 812 } | 812 } |
| 813 return result; | 813 return result; |
| 814 } | 814 } |
| 815 | 815 |
| 816 | 816 |
| 817 Object* StubCompiler::CompileCallNormal(Code::Flags flags) { | 817 Object* StubCompiler::CompileCallNormal(Code::Flags flags) { |
| 818 HandleScope scope; | 818 HandleScope scope; |
| 819 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 819 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 820 CallIC::GenerateNormal(masm(), argc); | 820 CallIC::GenerateNormal(masm(), argc); |
| 821 Object* result = GetCodeWithFlags(flags); | 821 Object* result = GetCodeWithFlags(flags, "CompileCallNormal"); |
| 822 if (!result->IsFailure()) { | 822 if (!result->IsFailure()) { |
| 823 Counters::call_normal_stubs.Increment(); | 823 Counters::call_normal_stubs.Increment(); |
| 824 Code* code = Code::cast(result); | 824 Code* code = Code::cast(result); |
| 825 USE(code); | 825 USE(code); |
| 826 LOG(CodeCreateEvent("CallNormal", code, code->arguments_count())); | 826 LOG(CodeCreateEvent("CallNormal", code, code->arguments_count())); |
| 827 } | 827 } |
| 828 return result; | 828 return result; |
| 829 } | 829 } |
| 830 | 830 |
| 831 | 831 |
| 832 Object* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { | 832 Object* StubCompiler::CompileCallMegamorphic(Code::Flags flags) { |
| 833 HandleScope scope; | 833 HandleScope scope; |
| 834 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 834 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 835 CallIC::GenerateMegamorphic(masm(), argc); | 835 CallIC::GenerateMegamorphic(masm(), argc); |
| 836 Object* result = GetCodeWithFlags(flags); | 836 Object* result = GetCodeWithFlags(flags, "CompileCallMegamorphic"); |
| 837 if (!result->IsFailure()) { | 837 if (!result->IsFailure()) { |
| 838 Counters::call_megamorphic_stubs.Increment(); | 838 Counters::call_megamorphic_stubs.Increment(); |
| 839 Code* code = Code::cast(result); | 839 Code* code = Code::cast(result); |
| 840 USE(code); | 840 USE(code); |
| 841 LOG(CodeCreateEvent("CallMegamorphic", code, code->arguments_count())); | 841 LOG(CodeCreateEvent("CallMegamorphic", code, code->arguments_count())); |
| 842 } | 842 } |
| 843 return result; | 843 return result; |
| 844 } | 844 } |
| 845 | 845 |
| 846 | 846 |
| 847 Object* StubCompiler::CompileCallMiss(Code::Flags flags) { | 847 Object* StubCompiler::CompileCallMiss(Code::Flags flags) { |
| 848 HandleScope scope; | 848 HandleScope scope; |
| 849 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 849 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 850 CallIC::GenerateMiss(masm(), argc); | 850 CallIC::GenerateMiss(masm(), argc); |
| 851 Object* result = GetCodeWithFlags(flags); | 851 Object* result = GetCodeWithFlags(flags, "CompileCallMiss"); |
| 852 if (!result->IsFailure()) { | 852 if (!result->IsFailure()) { |
| 853 Counters::call_megamorphic_stubs.Increment(); | 853 Counters::call_megamorphic_stubs.Increment(); |
| 854 Code* code = Code::cast(result); | 854 Code* code = Code::cast(result); |
| 855 USE(code); | 855 USE(code); |
| 856 LOG(CodeCreateEvent("CallMiss", code, code->arguments_count())); | 856 LOG(CodeCreateEvent("CallMiss", code, code->arguments_count())); |
| 857 } | 857 } |
| 858 return result; | 858 return result; |
| 859 } | 859 } |
| 860 | 860 |
| 861 | 861 |
| 862 Object* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { | 862 Object* StubCompiler::CompileCallDebugBreak(Code::Flags flags) { |
| 863 HandleScope scope; | 863 HandleScope scope; |
| 864 Debug::GenerateCallICDebugBreak(masm()); | 864 Debug::GenerateCallICDebugBreak(masm()); |
| 865 Object* result = GetCodeWithFlags(flags); | 865 Object* result = GetCodeWithFlags(flags, "CompileCallDebugBreak"); |
| 866 if (!result->IsFailure()) { | 866 if (!result->IsFailure()) { |
| 867 Code* code = Code::cast(result); | 867 Code* code = Code::cast(result); |
| 868 USE(code); | 868 USE(code); |
| 869 LOG(CodeCreateEvent("CallDebugBreak", code, code->arguments_count())); | 869 LOG(CodeCreateEvent("CallDebugBreak", code, code->arguments_count())); |
| 870 } | 870 } |
| 871 return result; | 871 return result; |
| 872 } | 872 } |
| 873 | 873 |
| 874 | 874 |
| 875 Object* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { | 875 Object* StubCompiler::CompileCallDebugPrepareStepIn(Code::Flags flags) { |
| 876 HandleScope scope; | 876 HandleScope scope; |
| 877 // Use the same code for the the step in preparations as we do for | 877 // Use the same code for the the step in preparations as we do for |
| 878 // the miss case. | 878 // the miss case. |
| 879 int argc = Code::ExtractArgumentsCountFromFlags(flags); | 879 int argc = Code::ExtractArgumentsCountFromFlags(flags); |
| 880 CallIC::GenerateMiss(masm(), argc); | 880 CallIC::GenerateMiss(masm(), argc); |
| 881 Object* result = GetCodeWithFlags(flags); | 881 Object* result = GetCodeWithFlags(flags, "CompileCallDebugPrepareStepIn"); |
| 882 if (!result->IsFailure()) { | 882 if (!result->IsFailure()) { |
| 883 Code* code = Code::cast(result); | 883 Code* code = Code::cast(result); |
| 884 USE(code); | 884 USE(code); |
| 885 LOG(CodeCreateEvent("CallDebugPrepareStepIn", code, | 885 LOG(CodeCreateEvent("CallDebugPrepareStepIn", code, |
| 886 code->arguments_count())); | 886 code->arguments_count())); |
| 887 } | 887 } |
| 888 return result; | 888 return result; |
| 889 } | 889 } |
| 890 | 890 |
| 891 | 891 |
| 892 Object* StubCompiler::GetCodeWithFlags(Code::Flags flags) { | 892 Object* StubCompiler::GetCodeWithFlags(Code::Flags flags, char* name) { |
| 893 CodeDesc desc; | 893 CodeDesc desc; |
| 894 masm_.GetCode(&desc); | 894 masm_.GetCode(&desc); |
| 895 Object* result = Heap::CreateCode(desc, NULL, flags, masm_.CodeObject()); | 895 Object* result = Heap::CreateCode(desc, NULL, flags, masm_.CodeObject()); |
| 896 #ifdef DEBUG | 896 #ifdef ENABLE_DISASSEMBLER |
| 897 if (FLAG_print_code_stubs && !result->IsFailure()) { | 897 if (FLAG_print_code_stubs && !result->IsFailure()) { |
| 898 Code::cast(result)->Print(); | 898 Code::cast(result)->Disassemble(name); |
| 899 } | 899 } |
| 900 #endif | 900 #endif |
| 901 return result; | 901 return result; |
| 902 } | 902 } |
| 903 | 903 |
| 904 | 904 |
| 905 Object* LoadStubCompiler::GetCode(PropertyType type) { | 905 Object* StubCompiler::GetCodeWithFlags(Code::Flags flags, String* name) { |
| 906 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::LOAD_IC, type)); | 906 if (FLAG_print_code_stubs && (name != NULL)) { |
| 907 return GetCodeWithFlags(flags, *name->ToCString()); | |
| 908 } | |
| 909 return GetCodeWithFlags(flags, reinterpret_cast<char*>(NULL)); | |
| 907 } | 910 } |
| 908 | 911 |
| 909 | 912 |
| 910 Object* KeyedLoadStubCompiler::GetCode(PropertyType type) { | 913 Object* LoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 911 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, | 914 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::LOAD_IC, type), |
|
Kasper Lund
2009/03/03 15:42:30
Maybe this would look better if you precomputed th
iposva
2009/03/03 16:21:19
Done.
| |
| 912 type)); | 915 name); |
| 913 } | 916 } |
| 914 | 917 |
| 915 | 918 |
| 916 Object* StoreStubCompiler::GetCode(PropertyType type) { | 919 Object* KeyedLoadStubCompiler::GetCode(PropertyType type, String* name) { |
| 917 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::STORE_IC, type)); | 920 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_LOAD_IC, |
| 921 type), | |
| 922 name); | |
| 918 } | 923 } |
| 919 | 924 |
| 920 | 925 |
| 921 Object* KeyedStoreStubCompiler::GetCode(PropertyType type) { | 926 Object* StoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 922 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, | 927 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::STORE_IC, type), |
| 923 type)); | 928 name); |
| 924 } | 929 } |
| 925 | 930 |
| 926 | 931 |
| 927 Object* CallStubCompiler::GetCode(PropertyType type) { | 932 Object* KeyedStoreStubCompiler::GetCode(PropertyType type, String* name) { |
| 928 int argc = arguments_.immediate(); | 933 return GetCodeWithFlags(Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, |
| 929 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, type, argc); | 934 type), |
| 930 return GetCodeWithFlags(flags); | 935 name); |
| 931 } | 936 } |
| 932 | 937 |
| 933 | 938 |
| 939 Object* CallStubCompiler::GetCode(PropertyType type, String* name) { | |
| 940 int argc = arguments_.immediate(); | |
| 941 Code::Flags flags = Code::ComputeMonomorphicFlags(Code::CALL_IC, type, argc); | |
|
Kasper Lund
2009/03/03 15:42:30
Yes. Like this.
iposva
2009/03/03 16:21:19
Done.
| |
| 942 return GetCodeWithFlags(flags, name); | |
| 943 } | |
| 944 | |
| 945 | |
| 934 } } // namespace v8::internal | 946 } } // namespace v8::internal |
| OLD | NEW |