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

Side by Side Diff: src/ic/ic-compiler.cc

Issue 1864703003: Turn StoreIC::Megamorphic into a builtin, get rid of the non-monomorphic-cache (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/ic/ic-compiler.h ('k') | src/ic/mips/ic-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ic/ic-compiler.h" 5 #include "src/ic/ic-compiler.h"
6 6
7 #include "src/ic/handler-compiler.h" 7 #include "src/ic/handler-compiler.h"
8 #include "src/ic/ic-inl.h" 8 #include "src/ic/ic-inl.h"
9 #include "src/profiler/cpu-profiler.h" 9 #include "src/profiler/cpu-profiler.h"
10 10
(...skipping 25 matching lines...) Expand all
36 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, 36 stub = LoadFastElementStub(isolate, is_js_array, elements_kind,
37 convert_hole_to_undefined).GetCode(); 37 convert_hole_to_undefined).GetCode();
38 } else { 38 } else {
39 DCHECK(receiver_map->has_dictionary_elements()); 39 DCHECK(receiver_map->has_dictionary_elements());
40 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) 40 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state))
41 .GetCode(); 41 .GetCode();
42 } 42 }
43 return stub; 43 return stub;
44 } 44 }
45 45
46
47 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler( 46 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
48 Handle<Map> receiver_map, LanguageMode language_mode, 47 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
49 KeyedAccessStoreMode store_mode) {
50 Isolate* isolate = receiver_map->GetIsolate(); 48 Isolate* isolate = receiver_map->GetIsolate();
51 ExtraICState extra_state =
52 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
53 49
54 DCHECK(store_mode == STANDARD_STORE || 50 DCHECK(store_mode == STANDARD_STORE ||
55 store_mode == STORE_AND_GROW_NO_TRANSITION || 51 store_mode == STORE_AND_GROW_NO_TRANSITION ||
56 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || 52 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
57 store_mode == STORE_NO_TRANSITION_HANDLE_COW); 53 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
58 54
59 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); 55 PropertyICCompiler compiler(isolate);
60 Handle<Code> code = 56 Handle<Code> code =
61 compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode); 57 compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode);
62 return code; 58 return code;
63 } 59 }
64 60
65
66 static void FillCache(Isolate* isolate, Handle<Code> code) {
67 Handle<UnseededNumberDictionary> dictionary = UnseededNumberDictionary::Set(
68 isolate->factory()->non_monomorphic_cache(), code->flags(), code);
69 isolate->heap()->SetRootNonMonomorphicCache(*dictionary);
70 }
71
72
73 Handle<Code> PropertyICCompiler::ComputeStore(Isolate* isolate,
74 InlineCacheState ic_state,
75 ExtraICState extra_state) {
76 DCHECK_EQ(MEGAMORPHIC, ic_state);
77 Code::Flags flags = Code::ComputeFlags(Code::STORE_IC, ic_state, extra_state);
78 Handle<UnseededNumberDictionary> cache =
79 isolate->factory()->non_monomorphic_cache();
80 int entry = cache->FindEntry(isolate, flags);
81 if (entry != -1) return Handle<Code>(Code::cast(cache->ValueAt(entry)));
82
83 PropertyICCompiler compiler(isolate, Code::STORE_IC);
84 Handle<Code> code = compiler.CompileStoreMegamorphic(flags);
85
86 FillCache(isolate, code);
87 return code;
88 }
89
90
91 void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers( 61 void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers(
92 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, 62 MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
93 CodeHandleList* handlers, KeyedAccessStoreMode store_mode, 63 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) {
94 LanguageMode language_mode) {
95 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); 64 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
96 DCHECK(store_mode == STANDARD_STORE || 65 DCHECK(store_mode == STANDARD_STORE ||
97 store_mode == STORE_AND_GROW_NO_TRANSITION || 66 store_mode == STORE_AND_GROW_NO_TRANSITION ||
98 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || 67 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
99 store_mode == STORE_NO_TRANSITION_HANDLE_COW); 68 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
100 ExtraICState extra_state = 69 PropertyICCompiler compiler(isolate);
101 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
102 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
103 compiler.CompileKeyedStorePolymorphicHandlers( 70 compiler.CompileKeyedStorePolymorphicHandlers(
104 receiver_maps, transitioned_maps, handlers, store_mode); 71 receiver_maps, transitioned_maps, handlers, store_mode);
105 } 72 }
106 73
107 74
108 Handle<Code> PropertyICCompiler::CompileStoreMegamorphic(Code::Flags flags) {
109 StoreIC::GenerateMegamorphic(masm());
110 Handle<Code> code = GetCodeWithFlags(flags, "CompileStoreMegamorphic");
111 PROFILE(isolate(), CodeCreateEvent(Logger::STORE_MEGAMORPHIC_TAG,
112 AbstractCode::cast(*code), 0));
113 return code;
114 }
115
116 Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Handle<Name> name,
117 InlineCacheState state) {
118 Code::Flags flags =
119 Code::ComputeFlags(kind, state, extra_ic_state_, cache_holder());
120 Handle<Code> code = GetCodeWithFlags(flags, name);
121 PROFILE(isolate(),
122 CodeCreateEvent(log_kind(code), AbstractCode::cast(*code), *name));
123 #ifdef DEBUG
124 code->VerifyEmbeddedObjects();
125 #endif
126 return code;
127 }
128
129
130 void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers( 75 void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers(
131 MapHandleList* receiver_maps, MapHandleList* transitioned_maps, 76 MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
132 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) { 77 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) {
133 for (int i = 0; i < receiver_maps->length(); ++i) { 78 for (int i = 0; i < receiver_maps->length(); ++i) {
134 Handle<Map> receiver_map(receiver_maps->at(i)); 79 Handle<Map> receiver_map(receiver_maps->at(i));
135 Handle<Code> cached_stub; 80 Handle<Code> cached_stub;
136 Handle<Map> transitioned_map = 81 Handle<Map> transitioned_map =
137 Map::FindTransitionedMap(receiver_map, receiver_maps); 82 Map::FindTransitionedMap(receiver_map, receiver_maps);
138 83
139 // TODO(mvstanton): The code below is doing pessimistic elements 84 // TODO(mvstanton): The code below is doing pessimistic elements
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 } else { 134 } else {
190 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); 135 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode();
191 } 136 }
192 return stub; 137 return stub;
193 } 138 }
194 139
195 140
196 #undef __ 141 #undef __
197 } // namespace internal 142 } // namespace internal
198 } // namespace v8 143 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic-compiler.h ('k') | src/ic/mips/ic-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698