5 #ifndef V8_IC_ACCESSOR_ASSEMBLER_H_ 6 #define V8_IC_ACCESSOR_ASSEMBLER_H_ 8 #include "src/code-stub-assembler.h" 14 class CodeAssemblerState;
30 void GenerateLoadIC();
31 void GenerateLoadIC_Megamorphic();
32 void GenerateLoadIC_Noninlined();
33 void GenerateLoadIC_Uninitialized();
34 void GenerateLoadICTrampoline();
35 void GenerateLoadICTrampoline_Megamorphic();
36 void GenerateKeyedLoadIC();
37 void GenerateKeyedLoadIC_Megamorphic();
38 void GenerateKeyedLoadIC_PolymorphicName();
39 void GenerateKeyedLoadICTrampoline();
40 void GenerateKeyedLoadICTrampoline_Megamorphic();
41 void GenerateStoreIC();
42 void GenerateStoreICTrampoline();
43 void GenerateStoreGlobalIC();
44 void GenerateStoreGlobalICTrampoline();
45 void GenerateCloneObjectIC();
46 void GenerateCloneObjectIC_Slow();
48 void GenerateLoadGlobalIC(TypeofMode typeof_mode);
49 void GenerateLoadGlobalICTrampoline(TypeofMode typeof_mode);
51 void GenerateKeyedStoreIC();
52 void GenerateKeyedStoreICTrampoline();
54 void GenerateStoreInArrayLiteralIC();
60 Node* StubCachePrimaryOffsetForTesting(
Node* name,
Node* map) {
61 return StubCachePrimaryOffset(name, map);
63 Node* StubCacheSecondaryOffsetForTesting(
Node* name,
Node* map) {
64 return StubCacheSecondaryOffset(name, map);
69 Node* vector,
Node* holder =
nullptr)
75 holder(holder ? holder : receiver) {}
86 const LazyNode<Context>& lazy_context,
87 const LazyNode<Name>& lazy_name, TypeofMode typeof_mode,
89 ParameterMode slot_mode = SMI_PARAMETERS);
108 enum class ICMode { kNonGlobalIC, kGlobalIC };
109 enum ElementSupport { kOnlyProperties, kSupportElements };
110 void HandleStoreICHandlerCase(
111 const StoreICParameters* p, TNode<MaybeObject> handler, Label* miss,
112 ICMode ic_mode, ElementSupport support_elements = kOnlyProperties);
113 enum StoreTransitionMapFlags {
114 kCheckPrototypeValidity = 1 << 0,
115 kValidateTransitionHandler = 1 << 1,
116 kStoreTransitionMapFlagsMask =
117 kCheckPrototypeValidity | kValidateTransitionHandler,
119 void HandleStoreICTransitionMapHandlerCase(
const StoreICParameters* p,
120 TNode<Map> transition_map,
122 StoreTransitionMapFlags flags);
124 void JumpIfDataProperty(Node* details, Label* writable, Label* readonly);
126 void BranchIfStrictMode(Node* vector, Node* slot, Label* if_strict);
128 void InvalidateValidityCellIfPrototype(Node* map, Node* bitfield2 =
nullptr);
130 void OverwriteExistingFastDataProperty(Node*
object, Node* object_map,
132 Node* descriptor_name_index,
133 Node* details, Node* value,
135 bool do_transitioning_store);
137 void CheckFieldType(TNode<DescriptorArray> descriptors, Node* name_index,
138 Node* representation, Node* value, Label* bailout);
145 void LoadIC(
const LoadICParameters* p);
146 void LoadIC_Noninlined(
const LoadICParameters* p, Node* receiver_map,
147 TNode<HeapObject> feedback,
148 TVariable<MaybeObject>* var_handler, Label* if_handler,
149 Label* miss, ExitPoint* exit_point);
151 TNode<Object> LoadDescriptorValue(TNode<Map> map,
152 TNode<IntPtrT> descriptor_entry);
153 TNode<MaybeObject> LoadDescriptorValueOrFieldType(
154 TNode<Map> map, TNode<IntPtrT> descriptor_entry);
156 void LoadIC_Uninitialized(
const LoadICParameters* p);
158 void KeyedLoadIC(
const LoadICParameters* p);
159 void KeyedLoadICGeneric(
const LoadICParameters* p);
160 void KeyedLoadICPolymorphicName(
const LoadICParameters* p);
161 void StoreIC(
const StoreICParameters* p);
162 void StoreGlobalIC(
const StoreICParameters* p);
163 void StoreGlobalIC_PropertyCellCase(Node* property_cell, Node* value,
164 ExitPoint* exit_point, Label* miss);
165 void KeyedStoreIC(
const StoreICParameters* p);
166 void StoreInArrayLiteralIC(
const StoreICParameters* p);
171 TNode<MaybeObject> TryMonomorphicCase(Node* slot, Node* vector,
172 Node* receiver_map, Label* if_handler,
173 TVariable<MaybeObject>* var_handler,
175 void HandlePolymorphicCase(Node* receiver_map, TNode<WeakFixedArray> feedback,
177 TVariable<MaybeObject>* var_handler,
178 Label* if_miss,
int min_feedback_capacity);
181 void HandleLoadICHandlerCase(
182 const LoadICParameters* p, TNode<Object> handler, Label* miss,
183 ExitPoint* exit_point, ICMode ic_mode = ICMode::kNonGlobalIC,
184 OnNonExistent on_nonexistent = OnNonExistent::kReturnUndefined,
185 ElementSupport support_elements = kOnlyProperties);
187 void HandleLoadICSmiHandlerCase(
const LoadICParameters* p, Node* holder,
188 SloppyTNode<Smi> smi_handler,
189 SloppyTNode<Object> handler, Label* miss,
190 ExitPoint* exit_point,
191 OnNonExistent on_nonexistent,
192 ElementSupport support_elements);
194 void HandleLoadICProtoHandler(
const LoadICParameters* p, Node* handler,
195 Variable* var_holder, Variable* var_smi_handler,
196 Label* if_smi_handler, Label* miss,
197 ExitPoint* exit_point, ICMode ic_mode);
199 void HandleLoadCallbackProperty(
const LoadICParameters* p,
200 TNode<JSObject> holder,
201 TNode<WordT> handler_word,
202 ExitPoint* exit_point);
204 void HandleLoadAccessor(
const LoadICParameters* p,
205 TNode<CallHandlerInfo> call_handler_info,
206 TNode<WordT> handler_word, TNode<DataHandler> handler,
207 TNode<IntPtrT> handler_kind, ExitPoint* exit_point);
209 void HandleLoadField(Node* holder, Node* handler_word,
210 Variable* var_double_value, Label* rebox_double,
211 ExitPoint* exit_point);
213 void EmitAccessCheck(Node* expected_native_context, Node* context,
214 Node* receiver, Label* can_access, Label* miss);
218 void LoadGlobalIC_TryPropertyCellCase(
219 TNode<FeedbackVector> vector, Node* slot,
220 const LazyNode<Context>& lazy_context, ExitPoint* exit_point,
221 Label* try_handler, Label* miss,
222 ParameterMode slot_mode = SMI_PARAMETERS);
224 void LoadGlobalIC_TryHandlerCase(TNode<FeedbackVector> vector, Node* slot,
225 const LazyNode<Context>& lazy_context,
226 const LazyNode<Name>& lazy_name,
227 TypeofMode typeof_mode,
228 ExitPoint* exit_point, Label* miss,
229 ParameterMode slot_mode);
233 void HandleStoreICProtoHandler(
const StoreICParameters* p,
234 TNode<StoreHandler> handler, Label* miss,
236 ElementSupport support_elements);
237 void HandleStoreICSmiHandlerCase(Node* handler_word, Node* holder,
238 Node* value, Label* miss);
239 void HandleStoreFieldAndReturn(Node* handler_word, Node* holder,
240 Representation representation, Node* value,
243 void CheckPrototypeValidityCell(Node* maybe_validity_cell, Label* miss);
244 void HandleStoreICNativeDataProperty(
const StoreICParameters* p, Node* holder,
247 void HandleStoreToProxy(
const StoreICParameters* p, Node* proxy, Label* miss,
248 ElementSupport support_elements);
250 void HandleStoreAccessor(
const StoreICParameters* p, Node* holder,
255 void GenericElementLoad(Node* receiver, Node* receiver_map,
256 SloppyTNode<Int32T> instance_type, Node* index,
259 enum UseStubCache { kUseStubCache, kDontUseStubCache };
260 void GenericPropertyLoad(Node* receiver, Node* receiver_map,
261 SloppyTNode<Int32T> instance_type,
262 const LoadICParameters* p, Label* slow,
263 UseStubCache use_stub_cache = kUseStubCache);
267 typedef std::function<void(Node* code_handler)> OnCodeHandler;
268 typedef std::function<void(Node* properties, Node* name_index)>
271 template <
typename ICHandler,
typename ICParameters>
272 Node* HandleProtoHandler(
const ICParameters* p, Node* handler,
273 const OnCodeHandler& on_code_handler,
274 const OnFoundOnReceiver& on_found_on_receiver,
275 Label* miss, ICMode ic_mode);
277 Node* GetLanguageMode(Node* vector, Node* slot);
279 Node* PrepareValueForStore(Node* handler_word, Node* holder,
280 Representation representation, Node* value,
285 Node* ExtendPropertiesBackingStore(Node*
object, Node* index);
287 void StoreNamedField(Node* handler_word, Node*
object,
bool is_inobject,
288 Representation representation, Node* value,
291 void EmitFastElementsBoundsCheck(Node*
object, Node* elements,
293 Node* is_jsarray_condition, Label* miss);
294 void EmitElementLoad(Node*
object, Node* elements, Node* elements_kind,
295 SloppyTNode<IntPtrT> key, Node* is_jsarray_condition,
296 Label* if_hole, Label* rebox_double,
297 Variable* var_double_value,
298 Label* unimplemented_elements_kind, Label* out_of_bounds,
299 Label* miss, ExitPoint* exit_point);
300 void NameDictionaryNegativeLookup(Node*
object, SloppyTNode<Name> name,
307 enum StubCacheTable :
int;
309 Node* StubCachePrimaryOffset(Node* name, Node* map);
310 Node* StubCacheSecondaryOffset(Node* name, Node* seed);
312 void TryProbeStubCacheTable(StubCache* stub_cache, StubCacheTable table_id,
313 Node* entry_offset, Node* name, Node* map,
315 TVariable<MaybeObject>* var_handler,
329 typedef std::function<void(Node* result)> IndirectReturnHandler;
335 const IndirectReturnHandler& indirect_return_handler)
336 : asm_(assembler), indirect_return_handler_(indirect_return_handler) {}
341 var_result->Bind(result);
342 assembler->Goto(out);
344 DCHECK_EQ(out !=
nullptr, var_result !=
nullptr);
347 template <
class... TArgs>
348 void ReturnCallRuntime(Runtime::FunctionId
function,
Node* context,
351 asm_->TailCallRuntime(
function, context, args...);
353 indirect_return_handler_(asm_->CallRuntime(
function, context, args...));
357 template <
class... TArgs>
358 void ReturnCallStub(
Callable const& callable,
Node* context, TArgs... args) {
360 asm_->TailCallStub(callable, context, args...);
362 indirect_return_handler_(asm_->CallStub(callable, context, args...));
366 template <
class... TArgs>
368 Node* context, TArgs... args) {
370 asm_->TailCallStub(descriptor, target, context, args...);
372 indirect_return_handler_(
373 asm_->CallStub(descriptor, target, context, args...));
377 void Return(
Node*
const result) {
379 asm_->Return(result);
381 indirect_return_handler_(result);
385 bool IsDirect()
const {
return !indirect_return_handler_; }
389 IndirectReturnHandler indirect_return_handler_;
395 #endif // V8_IC_ACCESSOR_ASSEMBLER_H_