Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_SRC_IC_ACCESSOR_ASSEMBLER_H_ | 5 #ifndef V8_SRC_IC_ACCESSOR_ASSEMBLER_H_ |
| 6 #define V8_SRC_IC_ACCESSOR_ASSEMBLER_H_ | 6 #define V8_SRC_IC_ACCESSOR_ASSEMBLER_H_ |
| 7 | 7 |
| 8 #include "src/globals.h" | 8 #include "src/code-stub-assembler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 class CodeAssemblerState; | 14 class CodeAssemblerState; |
| 15 } | 15 } |
| 16 | 16 |
| 17 class AccessorAssembler { | 17 using compiler::Node; |
| 18 | |
| 19 class AccessorAssembler : public CodeStubAssembler { | |
|
Jakob Kummerow
2017/01/18 18:45:30
All this is just moved over from accessor-assemble
| |
| 18 public: | 20 public: |
| 19 static void GenerateLoadIC(compiler::CodeAssemblerState* state); | 21 explicit AccessorAssembler(compiler::CodeAssemblerState* state) |
| 20 static void GenerateLoadICTrampoline(compiler::CodeAssemblerState* state); | 22 : CodeStubAssembler(state) {} |
| 21 static void GenerateLoadICProtoArray( | 23 |
| 22 compiler::CodeAssemblerState* state, | 24 void GenerateLoadIC(); |
| 23 bool throw_reference_error_if_nonexistent); | 25 void GenerateLoadField(); |
| 24 static void GenerateLoadGlobalIC(compiler::CodeAssemblerState* state, | 26 void GenerateLoadICTrampoline(); |
| 25 TypeofMode typeof_mode); | 27 void GenerateKeyedLoadIC(); |
| 26 static void GenerateLoadGlobalICTrampoline( | 28 void GenerateKeyedLoadICTrampoline(); |
| 27 compiler::CodeAssemblerState* state, TypeofMode typeof_mode); | 29 void GenerateKeyedLoadIC_Megamorphic(); |
| 28 static void GenerateKeyedLoadICTF(compiler::CodeAssemblerState* state); | 30 void GenerateStoreIC(); |
| 29 static void GenerateKeyedLoadICTrampolineTF( | 31 void GenerateStoreICTrampoline(); |
| 30 compiler::CodeAssemblerState* state); | 32 |
| 31 static void GenerateKeyedLoadICMegamorphic( | 33 void GenerateLoadICProtoArray(bool throw_reference_error_if_nonexistent); |
| 32 compiler::CodeAssemblerState* state); | 34 |
| 33 static void GenerateLoadField(compiler::CodeAssemblerState* state); | 35 void GenerateLoadGlobalIC(TypeofMode typeof_mode); |
| 34 static void GenerateStoreIC(compiler::CodeAssemblerState* state); | 36 void GenerateLoadGlobalICTrampoline(TypeofMode typeof_mode); |
| 35 static void GenerateStoreICTrampoline(compiler::CodeAssemblerState* state); | 37 |
| 36 static void GenerateKeyedStoreICTF(compiler::CodeAssemblerState* state, | 38 void GenerateKeyedStoreIC(LanguageMode language_mode); |
| 37 LanguageMode language_mode); | 39 void GenerateKeyedStoreICTrampoline(LanguageMode language_mode); |
| 38 static void GenerateKeyedStoreICTrampolineTF( | 40 |
| 39 compiler::CodeAssemblerState* state, LanguageMode language_mode); | 41 void TryProbeStubCache(StubCache* stub_cache, Node* receiver, Node* name, |
| 42 Label* if_handler, Variable* var_handler, | |
| 43 Label* if_miss); | |
| 44 | |
| 45 Node* StubCachePrimaryOffsetForTesting(Node* name, Node* map) { | |
| 46 return StubCachePrimaryOffset(name, map); | |
| 47 } | |
| 48 Node* StubCacheSecondaryOffsetForTesting(Node* name, Node* map) { | |
| 49 return StubCacheSecondaryOffset(name, map); | |
| 50 } | |
| 51 | |
| 52 protected: | |
| 53 struct LoadICParameters { | |
| 54 LoadICParameters(Node* context, Node* receiver, Node* name, Node* slot, | |
| 55 Node* vector) | |
| 56 : context(context), | |
| 57 receiver(receiver), | |
| 58 name(name), | |
| 59 slot(slot), | |
| 60 vector(vector) {} | |
| 61 | |
| 62 Node* context; | |
| 63 Node* receiver; | |
| 64 Node* name; | |
| 65 Node* slot; | |
| 66 Node* vector; | |
| 67 }; | |
| 68 | |
| 69 struct StoreICParameters : public LoadICParameters { | |
| 70 StoreICParameters(Node* context, Node* receiver, Node* name, Node* value, | |
| 71 Node* slot, Node* vector) | |
| 72 : LoadICParameters(context, receiver, name, slot, vector), | |
| 73 value(value) {} | |
| 74 Node* value; | |
| 75 }; | |
| 76 | |
| 77 enum ElementSupport { kOnlyProperties, kSupportElements }; | |
| 78 void HandleStoreICHandlerCase( | |
| 79 const StoreICParameters* p, Node* handler, Label* miss, | |
| 80 ElementSupport support_elements = kOnlyProperties); | |
| 81 | |
| 82 private: | |
| 83 // Stub generation entry points. | |
| 84 | |
| 85 void LoadIC(const LoadICParameters* p); | |
| 86 void LoadICProtoArray(const LoadICParameters* p, Node* handler, | |
| 87 bool throw_reference_error_if_nonexistent); | |
| 88 void LoadGlobalIC(const LoadICParameters* p, TypeofMode typeof_mode); | |
| 89 void KeyedLoadIC(const LoadICParameters* p); | |
| 90 void KeyedLoadICGeneric(const LoadICParameters* p); | |
| 91 void StoreIC(const StoreICParameters* p); | |
| 92 void KeyedStoreIC(const StoreICParameters* p, LanguageMode language_mode); | |
| 93 | |
| 94 // IC dispatcher behavior. | |
| 95 | |
| 96 // Checks monomorphic case. Returns {feedback} entry of the vector. | |
| 97 Node* TryMonomorphicCase(Node* slot, Node* vector, Node* receiver_map, | |
| 98 Label* if_handler, Variable* var_handler, | |
| 99 Label* if_miss); | |
| 100 void HandlePolymorphicCase(Node* receiver_map, Node* feedback, | |
| 101 Label* if_handler, Variable* var_handler, | |
| 102 Label* if_miss, int unroll_count); | |
| 103 void HandleKeyedStorePolymorphicCase(Node* receiver_map, Node* feedback, | |
| 104 Label* if_handler, Variable* var_handler, | |
| 105 Label* if_transition_handler, | |
| 106 Variable* var_transition_map_cell, | |
| 107 Label* if_miss); | |
| 108 | |
| 109 // LoadIC implementation. | |
| 110 | |
| 111 void HandleLoadICHandlerCase( | |
| 112 const LoadICParameters* p, Node* handler, Label* miss, | |
| 113 ElementSupport support_elements = kOnlyProperties); | |
| 114 | |
| 115 void HandleLoadICSmiHandlerCase(const LoadICParameters* p, Node* holder, | |
| 116 Node* smi_handler, Label* miss, | |
| 117 ElementSupport support_elements); | |
| 118 | |
| 119 void HandleLoadICProtoHandlerCase(const LoadICParameters* p, Node* handler, | |
| 120 Variable* var_holder, | |
| 121 Variable* var_smi_handler, | |
| 122 Label* if_smi_handler, Label* miss, | |
| 123 bool throw_reference_error_if_nonexistent); | |
| 124 | |
| 125 Node* EmitLoadICProtoArrayCheck(const LoadICParameters* p, Node* handler, | |
| 126 Node* handler_length, Node* handler_flags, | |
| 127 Label* miss, | |
| 128 bool throw_reference_error_if_nonexistent); | |
| 129 | |
| 130 // LoadGlobalIC implementation. | |
| 131 | |
| 132 void HandleLoadGlobalICHandlerCase(const LoadICParameters* p, Node* handler, | |
| 133 Label* miss, | |
| 134 bool throw_reference_error_if_nonexistent); | |
| 135 | |
| 136 // StoreIC implementation. | |
| 137 | |
| 138 void HandleStoreICElementHandlerCase(const StoreICParameters* p, | |
| 139 Node* handler, Label* miss); | |
| 140 | |
| 141 void HandleStoreICProtoHandler(const StoreICParameters* p, Node* handler, | |
| 142 Label* miss); | |
| 143 // If |transition| is nullptr then the normal field store is generated or | |
| 144 // transitioning store otherwise. | |
| 145 void HandleStoreICSmiHandlerCase(Node* handler_word, Node* holder, | |
| 146 Node* value, Node* transition, Label* miss); | |
| 147 // If |transition| is nullptr then the normal field store is generated or | |
| 148 // transitioning store otherwise. | |
| 149 void HandleStoreFieldAndReturn(Node* handler_word, Node* holder, | |
| 150 Representation representation, Node* value, | |
| 151 Node* transition, Label* miss); | |
| 152 | |
| 153 // Low-level helpers. | |
| 154 | |
| 155 Node* PrepareValueForStore(Node* handler_word, Node* holder, | |
| 156 Representation representation, Node* transition, | |
| 157 Node* value, Label* bailout); | |
| 158 | |
| 159 // Extends properties backing store by JSObject::kFieldsAdded elements. | |
| 160 void ExtendPropertiesBackingStore(Node* object); | |
| 161 | |
| 162 void StoreNamedField(Node* handler_word, Node* object, bool is_inobject, | |
| 163 Representation representation, Node* value, | |
| 164 bool transition_to_field); | |
| 165 | |
| 166 void EmitFastElementsBoundsCheck(Node* object, Node* elements, | |
| 167 Node* intptr_index, | |
| 168 Node* is_jsarray_condition, Label* miss); | |
| 169 void EmitElementLoad(Node* object, Node* elements, Node* elements_kind, | |
| 170 Node* key, Node* is_jsarray_condition, Label* if_hole, | |
| 171 Label* rebox_double, Variable* var_double_value, | |
| 172 Label* unimplemented_elements_kind, Label* out_of_bounds, | |
| 173 Label* miss); | |
| 174 void CheckPrototype(Node* prototype_cell, Node* name, Label* miss); | |
| 175 void NameDictionaryNegativeLookup(Node* object, Node* name, Label* miss); | |
| 176 | |
| 177 // Stub cache access helpers. | |
| 178 | |
| 179 // This enum is used here as a replacement for StubCache::Table to avoid | |
| 180 // including stub cache header. | |
| 181 enum StubCacheTable : int; | |
| 182 | |
| 183 Node* StubCachePrimaryOffset(Node* name, Node* map); | |
| 184 Node* StubCacheSecondaryOffset(Node* name, Node* seed); | |
| 185 | |
| 186 void TryProbeStubCacheTable(StubCache* stub_cache, StubCacheTable table_id, | |
| 187 Node* entry_offset, Node* name, Node* map, | |
| 188 Label* if_handler, Variable* var_handler, | |
| 189 Label* if_miss); | |
| 40 }; | 190 }; |
| 41 | 191 |
| 42 } // namespace internal | 192 } // namespace internal |
| 43 } // namespace v8 | 193 } // namespace v8 |
| 44 | 194 |
| 45 #endif // V8_SRC_IC_ACCESSOR_ASSEMBLER_H_ | 195 #endif // V8_SRC_IC_ACCESSOR_ASSEMBLER_H_ |
| OLD | NEW |