Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(689)

Side by Side Diff: src/code-stubs.cc

Issue 544123002: Do not cache CodeStubInterfaceDescriptor on the isolate. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/bootstrapper.h" 7 #include "src/bootstrapper.h"
8 #include "src/code-stubs.h" 8 #include "src/code-stubs.h"
9 #include "src/cpu-profiler.h" 9 #include "src/cpu-profiler.h"
10 #include "src/factory.h" 10 #include "src/factory.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return Handle<Code>(code, isolate()); 170 return Handle<Code>(code, isolate());
171 } 171 }
172 172
173 173
174 const char* CodeStub::MajorName(CodeStub::Major major_key, 174 const char* CodeStub::MajorName(CodeStub::Major major_key,
175 bool allow_unknown_keys) { 175 bool allow_unknown_keys) {
176 switch (major_key) { 176 switch (major_key) {
177 #define DEF_CASE(name) case name: return #name "Stub"; 177 #define DEF_CASE(name) case name: return #name "Stub";
178 CODE_STUB_LIST(DEF_CASE) 178 CODE_STUB_LIST(DEF_CASE)
179 #undef DEF_CASE 179 #undef DEF_CASE
180 case UninitializedMajorKey: return "<UninitializedMajorKey>Stub";
181 case NoCache: 180 case NoCache:
182 return "<NoCache>Stub"; 181 return "<NoCache>Stub";
183 default: 182 case NUMBER_OF_IDS:
184 if (!allow_unknown_keys) { 183 UNREACHABLE();
185 UNREACHABLE();
186 }
187 return NULL; 184 return NULL;
188 } 185 }
186 return NULL;
189 } 187 }
190 188
191 189
192 void CodeStub::PrintBaseName(OStream& os) const { // NOLINT 190 void CodeStub::PrintBaseName(OStream& os) const { // NOLINT
193 os << MajorName(MajorKey(), false); 191 os << MajorName(MajorKey(), false);
194 } 192 }
195 193
196 194
197 void CodeStub::PrintName(OStream& os) const { // NOLINT 195 void CodeStub::PrintName(OStream& os) const { // NOLINT
198 PrintBaseName(os); 196 PrintBaseName(os);
199 PrintState(os); 197 PrintState(os);
200 } 198 }
201 199
202 200
201 void CodeStub::Dispatch(Isolate* isolate, uint32_t key, void** value_out,
mvstanton 2014/09/05 13:38:43 As we discussed, this is a better solution than ma
202 DispatchedCall call) {
203 switch (MajorKeyFromKey(key)) {
204 #define DEF_CASE(NAME) \
205 case NAME: { \
206 NAME##Stub stub(key, isolate); \
207 CodeStub* pstub = &stub; \
208 call(pstub, value_out); \
209 break; \
210 }
211 CODE_STUB_LIST(DEF_CASE)
212 #undef DEF_CASE
213 case NUMBER_OF_IDS:
214 UNREACHABLE();
215 case NoCache:
216 *value_out = NULL;
217 break;
218 }
219 }
220
221
222 static void GetInterfaceDescriptorDispatchedCall(CodeStub* stub,
223 void** value_out) {
224 CodeStubInterfaceDescriptor* descriptor_out =
225 reinterpret_cast<CodeStubInterfaceDescriptor*>(value_out);
226 stub->InitializeInterfaceDescriptor(descriptor_out);
227 }
228
229
230 void CodeStub::InitializeInterfaceDescriptor(
231 Isolate* isolate, uint32_t key, CodeStubInterfaceDescriptor* desc) {
232 void** value_out = reinterpret_cast<void**>(desc);
233 Dispatch(isolate, key, value_out, &GetInterfaceDescriptorDispatchedCall);
234 }
235
236
203 // static 237 // static
204 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) { 238 void BinaryOpICStub::GenerateAheadOfTime(Isolate* isolate) {
205 // Generate the uninitialized versions of the stub. 239 // Generate the uninitialized versions of the stub.
206 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) { 240 for (int op = Token::BIT_OR; op <= Token::MOD; ++op) {
207 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) { 241 for (int mode = NO_OVERWRITE; mode <= OVERWRITE_RIGHT; ++mode) {
208 BinaryOpICStub stub(isolate, 242 BinaryOpICStub stub(isolate,
209 static_cast<Token::Value>(op), 243 static_cast<Token::Value>(op),
210 static_cast<OverwriteMode>(mode)); 244 static_cast<OverwriteMode>(mode));
211 stub.GetCode(); 245 stub.GetCode();
212 } 246 }
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 955
922 void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function, 956 void ProfileEntryHookStub::EntryHookTrampoline(intptr_t function,
923 intptr_t stack_pointer, 957 intptr_t stack_pointer,
924 Isolate* isolate) { 958 Isolate* isolate) {
925 FunctionEntryHook entry_hook = isolate->function_entry_hook(); 959 FunctionEntryHook entry_hook = isolate->function_entry_hook();
926 DCHECK(entry_hook != NULL); 960 DCHECK(entry_hook != NULL);
927 entry_hook(function, stack_pointer); 961 entry_hook(function, stack_pointer);
928 } 962 }
929 963
930 964
931 static void InstallDescriptor(Isolate* isolate, HydrogenCodeStub* stub) {
932 int major_key = stub->MajorKey();
933 CodeStubInterfaceDescriptor* descriptor =
934 isolate->code_stub_interface_descriptor(major_key);
935 if (!descriptor->IsInitialized()) {
936 stub->InitializeInterfaceDescriptor(descriptor);
937 }
938 }
939
940
941 void ArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
942 ArrayNoArgumentConstructorStub stub1(isolate, GetInitialFastElementsKind());
943 InstallDescriptor(isolate, &stub1);
944 ArraySingleArgumentConstructorStub stub2(isolate,
945 GetInitialFastElementsKind());
946 InstallDescriptor(isolate, &stub2);
947 ArrayNArgumentsConstructorStub stub3(isolate, GetInitialFastElementsKind());
948 InstallDescriptor(isolate, &stub3);
949 }
950
951
952 void NumberToStringStub::InstallDescriptors(Isolate* isolate) {
953 NumberToStringStub stub(isolate);
954 InstallDescriptor(isolate, &stub);
955 }
956
957
958 void FastNewClosureStub::InstallDescriptors(Isolate* isolate) {
959 FastNewClosureStub stub(isolate, STRICT, false);
960 InstallDescriptor(isolate, &stub);
961 }
962
963
964 void FastNewContextStub::InstallDescriptors(Isolate* isolate) {
965 FastNewContextStub stub(isolate, FastNewContextStub::kMaximumSlots);
966 InstallDescriptor(isolate, &stub);
967 }
968
969
970 // static
971 void FastCloneShallowArrayStub::InstallDescriptors(Isolate* isolate) {
972 FastCloneShallowArrayStub stub(isolate, DONT_TRACK_ALLOCATION_SITE);
973 InstallDescriptor(isolate, &stub);
974 }
975
976
977 // static
978 void BinaryOpICStub::InstallDescriptors(Isolate* isolate) {
979 BinaryOpICStub stub(isolate, Token::ADD, NO_OVERWRITE);
980 InstallDescriptor(isolate, &stub);
981 }
982
983
984 // static
985 void BinaryOpWithAllocationSiteStub::InstallDescriptors(Isolate* isolate) {
986 BinaryOpWithAllocationSiteStub stub(isolate, Token::ADD, NO_OVERWRITE);
987 InstallDescriptor(isolate, &stub);
988 }
989
990
991 // static
992 void StringAddStub::InstallDescriptors(Isolate* isolate) {
993 StringAddStub stub(isolate, STRING_ADD_CHECK_NONE, NOT_TENURED);
994 InstallDescriptor(isolate, &stub);
995 }
996
997
998 // static
999 void RegExpConstructResultStub::InstallDescriptors(Isolate* isolate) {
1000 RegExpConstructResultStub stub(isolate);
1001 InstallDescriptor(isolate, &stub);
1002 }
1003
1004
1005 // static
1006 void KeyedLoadGenericStub::InstallDescriptors(Isolate* isolate) {
1007 KeyedLoadGenericStub stub(isolate);
1008 InstallDescriptor(isolate, &stub);
1009 }
1010
1011
1012 // static
1013 void StoreFieldStub::InstallDescriptors(Isolate* isolate) {
1014 StoreFieldStub stub(isolate, FieldIndex::ForInObjectOffset(0),
1015 Representation::None());
1016 InstallDescriptor(isolate, &stub);
1017 }
1018
1019
1020 // static
1021 void LoadFastElementStub::InstallDescriptors(Isolate* isolate) {
1022 LoadFastElementStub stub(isolate, true, FAST_ELEMENTS);
1023 InstallDescriptor(isolate, &stub);
1024 }
1025
1026
1027 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate) 965 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate)
1028 : PlatformCodeStub(isolate) { 966 : PlatformCodeStub(isolate) {
1029 minor_key_ = ArgumentCountBits::encode(ANY); 967 minor_key_ = ArgumentCountBits::encode(ANY);
1030 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 968 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
1031 } 969 }
1032 970
1033 971
1034 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate, 972 ArrayConstructorStub::ArrayConstructorStub(Isolate* isolate,
1035 int argument_count) 973 int argument_count)
1036 : PlatformCodeStub(isolate) { 974 : PlatformCodeStub(isolate) {
1037 if (argument_count == 0) { 975 if (argument_count == 0) {
1038 minor_key_ = ArgumentCountBits::encode(NONE); 976 minor_key_ = ArgumentCountBits::encode(NONE);
1039 } else if (argument_count == 1) { 977 } else if (argument_count == 1) {
1040 minor_key_ = ArgumentCountBits::encode(ONE); 978 minor_key_ = ArgumentCountBits::encode(ONE);
1041 } else if (argument_count >= 2) { 979 } else if (argument_count >= 2) {
1042 minor_key_ = ArgumentCountBits::encode(MORE_THAN_ONE); 980 minor_key_ = ArgumentCountBits::encode(MORE_THAN_ONE);
1043 } else { 981 } else {
1044 UNREACHABLE(); 982 UNREACHABLE();
1045 } 983 }
1046 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 984 ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
1047 } 985 }
1048 986
1049 987
1050 void InternalArrayConstructorStubBase::InstallDescriptors(Isolate* isolate) {
1051 InternalArrayNoArgumentConstructorStub stub1(isolate, FAST_ELEMENTS);
1052 InstallDescriptor(isolate, &stub1);
1053 InternalArraySingleArgumentConstructorStub stub2(isolate, FAST_ELEMENTS);
1054 InstallDescriptor(isolate, &stub2);
1055 InternalArrayNArgumentsConstructorStub stub3(isolate, FAST_ELEMENTS);
1056 InstallDescriptor(isolate, &stub3);
1057 }
1058
1059 InternalArrayConstructorStub::InternalArrayConstructorStub( 988 InternalArrayConstructorStub::InternalArrayConstructorStub(
1060 Isolate* isolate) : PlatformCodeStub(isolate) { 989 Isolate* isolate) : PlatformCodeStub(isolate) {
1061 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate); 990 InternalArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
1062 } 991 }
1063 992
1064 993
1065 } } // namespace v8::internal 994 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698