OLD | NEW |
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 #ifndef V8_IC_IC_COMPILER_H_ | 5 #ifndef V8_IC_HANDLER_COMPILER_H_ |
6 #define V8_IC_IC_COMPILER_H_ | 6 #define V8_IC_HANDLER_COMPILER_H_ |
7 | 7 |
8 #include "src/code-stubs.h" | |
9 #include "src/ic/access-compiler.h" | 8 #include "src/ic/access-compiler.h" |
10 #include "src/macro-assembler.h" | |
11 #include "src/objects.h" | |
12 | 9 |
13 namespace v8 { | 10 namespace v8 { |
14 namespace internal { | 11 namespace internal { |
15 | 12 |
16 | |
17 class CallOptimization; | 13 class CallOptimization; |
18 | 14 |
19 | |
20 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER }; | 15 enum PrototypeCheckType { CHECK_ALL_MAPS, SKIP_RECEIVER }; |
21 enum IcCheckType { ELEMENT, PROPERTY }; | |
22 | |
23 | |
24 class PropertyICCompiler : public PropertyAccessCompiler { | |
25 public: | |
26 // Finds the Code object stored in the Heap::non_monomorphic_cache(). | |
27 static Code* FindPreMonomorphic(Isolate* isolate, Code::Kind kind, | |
28 ExtraICState extra_ic_state); | |
29 | |
30 // Named | |
31 static Handle<Code> ComputeLoad(Isolate* isolate, InlineCacheState ic_state, | |
32 ExtraICState extra_state); | |
33 static Handle<Code> ComputeStore(Isolate* isolate, InlineCacheState ic_state, | |
34 ExtraICState extra_state); | |
35 | |
36 static Handle<Code> ComputeMonomorphic(Code::Kind kind, Handle<Name> name, | |
37 Handle<HeapType> type, | |
38 Handle<Code> handler, | |
39 ExtraICState extra_ic_state); | |
40 static Handle<Code> ComputePolymorphic(Code::Kind kind, TypeHandleList* types, | |
41 CodeHandleList* handlers, | |
42 int number_of_valid_maps, | |
43 Handle<Name> name, | |
44 ExtraICState extra_ic_state); | |
45 | |
46 // Keyed | |
47 static Handle<Code> ComputeKeyedLoadMonomorphic(Handle<Map> receiver_map); | |
48 | |
49 static Handle<Code> ComputeKeyedStoreMonomorphic( | |
50 Handle<Map> receiver_map, StrictMode strict_mode, | |
51 KeyedAccessStoreMode store_mode); | |
52 static Handle<Code> ComputeKeyedLoadPolymorphic(MapHandleList* receiver_maps); | |
53 static Handle<Code> ComputeKeyedStorePolymorphic( | |
54 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode, | |
55 StrictMode strict_mode); | |
56 | |
57 // Compare nil | |
58 static Handle<Code> ComputeCompareNil(Handle<Map> receiver_map, | |
59 CompareNilICStub* stub); | |
60 | |
61 // Helpers | |
62 // TODO(verwaest): Move all uses of these helpers to the PropertyICCompiler | |
63 // and make the helpers private. | |
64 static void GenerateRuntimeSetProperty(MacroAssembler* masm, | |
65 StrictMode strict_mode); | |
66 | |
67 | |
68 private: | |
69 PropertyICCompiler(Isolate* isolate, Code::Kind kind, | |
70 ExtraICState extra_ic_state = kNoExtraICState, | |
71 CacheHolderFlag cache_holder = kCacheOnReceiver) | |
72 : PropertyAccessCompiler(isolate, kind, cache_holder), | |
73 extra_ic_state_(extra_ic_state) {} | |
74 | |
75 static Handle<Code> Find(Handle<Name> name, Handle<Map> stub_holder_map, | |
76 Code::Kind kind, | |
77 ExtraICState extra_ic_state = kNoExtraICState, | |
78 CacheHolderFlag cache_holder = kCacheOnReceiver); | |
79 | |
80 Handle<Code> CompileLoadInitialize(Code::Flags flags); | |
81 Handle<Code> CompileLoadPreMonomorphic(Code::Flags flags); | |
82 Handle<Code> CompileLoadMegamorphic(Code::Flags flags); | |
83 Handle<Code> CompileStoreInitialize(Code::Flags flags); | |
84 Handle<Code> CompileStorePreMonomorphic(Code::Flags flags); | |
85 Handle<Code> CompileStoreGeneric(Code::Flags flags); | |
86 Handle<Code> CompileStoreMegamorphic(Code::Flags flags); | |
87 | |
88 Handle<Code> CompileMonomorphic(Handle<HeapType> type, Handle<Code> handler, | |
89 Handle<Name> name, IcCheckType check); | |
90 Handle<Code> CompilePolymorphic(TypeHandleList* types, | |
91 CodeHandleList* handlers, Handle<Name> name, | |
92 Code::StubType type, IcCheckType check); | |
93 | |
94 Handle<Code> CompileKeyedStoreMonomorphic(Handle<Map> receiver_map, | |
95 KeyedAccessStoreMode store_mode); | |
96 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps, | |
97 KeyedAccessStoreMode store_mode); | |
98 Handle<Code> CompileKeyedStorePolymorphic(MapHandleList* receiver_maps, | |
99 CodeHandleList* handler_stubs, | |
100 MapHandleList* transitioned_maps); | |
101 | |
102 bool IncludesNumberType(TypeHandleList* types); | |
103 | |
104 Handle<Code> GetCode(Code::Kind kind, Code::StubType type, Handle<Name> name, | |
105 InlineCacheState state = MONOMORPHIC); | |
106 | |
107 Logger::LogEventsAndTags log_kind(Handle<Code> code) { | |
108 if (kind() == Code::LOAD_IC) { | |
109 return code->ic_state() == MONOMORPHIC ? Logger::LOAD_IC_TAG | |
110 : Logger::LOAD_POLYMORPHIC_IC_TAG; | |
111 } else if (kind() == Code::KEYED_LOAD_IC) { | |
112 return code->ic_state() == MONOMORPHIC | |
113 ? Logger::KEYED_LOAD_IC_TAG | |
114 : Logger::KEYED_LOAD_POLYMORPHIC_IC_TAG; | |
115 } else if (kind() == Code::STORE_IC) { | |
116 return code->ic_state() == MONOMORPHIC ? Logger::STORE_IC_TAG | |
117 : Logger::STORE_POLYMORPHIC_IC_TAG; | |
118 } else { | |
119 DCHECK_EQ(Code::KEYED_STORE_IC, kind()); | |
120 return code->ic_state() == MONOMORPHIC | |
121 ? Logger::KEYED_STORE_IC_TAG | |
122 : Logger::KEYED_STORE_POLYMORPHIC_IC_TAG; | |
123 } | |
124 } | |
125 | |
126 const ExtraICState extra_ic_state_; | |
127 }; | |
128 | |
129 | 16 |
130 class PropertyHandlerCompiler : public PropertyAccessCompiler { | 17 class PropertyHandlerCompiler : public PropertyAccessCompiler { |
131 public: | 18 public: |
132 static Handle<Code> Find(Handle<Name> name, Handle<Map> map, Code::Kind kind, | 19 static Handle<Code> Find(Handle<Name> name, Handle<Map> map, Code::Kind kind, |
133 CacheHolderFlag cache_holder, Code::StubType type); | 20 CacheHolderFlag cache_holder, Code::StubType type); |
134 | 21 |
135 protected: | 22 protected: |
136 PropertyHandlerCompiler(Isolate* isolate, Code::Kind kind, | 23 PropertyHandlerCompiler(Isolate* isolate, Code::Kind kind, |
137 Handle<HeapType> type, Handle<JSObject> holder, | 24 Handle<HeapType> type, Handle<JSObject> holder, |
138 CacheHolderFlag cache_holder) | 25 CacheHolderFlag cache_holder) |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 Handle<JSObject>::null(), kCacheOnReceiver) {} | 262 Handle<JSObject>::null(), kCacheOnReceiver) {} |
376 | 263 |
377 virtual ~ElementHandlerCompiler() {} | 264 virtual ~ElementHandlerCompiler() {} |
378 | 265 |
379 void CompileElementHandlers(MapHandleList* receiver_maps, | 266 void CompileElementHandlers(MapHandleList* receiver_maps, |
380 CodeHandleList* handlers); | 267 CodeHandleList* handlers); |
381 | 268 |
382 static void GenerateLoadDictionaryElement(MacroAssembler* masm); | 269 static void GenerateLoadDictionaryElement(MacroAssembler* masm); |
383 static void GenerateStoreDictionaryElement(MacroAssembler* masm); | 270 static void GenerateStoreDictionaryElement(MacroAssembler* masm); |
384 }; | 271 }; |
385 | |
386 | |
387 } | 272 } |
388 } // namespace v8::internal | 273 } // namespace v8::internal |
389 | 274 |
390 #endif // V8_IC_IC_COMPILER_H_ | 275 #endif // V8_IC_HANDLER_COMPILER_H_ |
OLD | NEW |