| 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_HANDLER_COMPILER_H_ | 5 #ifndef V8_IC_HANDLER_COMPILER_H_ |
| 6 #define V8_IC_HANDLER_COMPILER_H_ | 6 #define V8_IC_HANDLER_COMPILER_H_ |
| 7 | 7 |
| 8 #include "src/ic/access-compiler.h" | 8 #include "src/ic/access-compiler.h" |
| 9 #include "src/ic/ic-state.h" | 9 #include "src/ic/ic-state.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 Label* miss, ReturnHolder return_what) { | 33 Label* miss, ReturnHolder return_what) { |
| 34 UNREACHABLE(); | 34 UNREACHABLE(); |
| 35 return receiver(); | 35 return receiver(); |
| 36 } | 36 } |
| 37 | 37 |
| 38 virtual void FrontendFooter(Handle<Name> name, Label* miss) { UNREACHABLE(); } | 38 virtual void FrontendFooter(Handle<Name> name, Label* miss) { UNREACHABLE(); } |
| 39 | 39 |
| 40 // Frontend loads from receiver(), returns holder register which may be | 40 // Frontend loads from receiver(), returns holder register which may be |
| 41 // different. | 41 // different. |
| 42 Register Frontend(Handle<Name> name); | 42 Register Frontend(Handle<Name> name); |
| 43 void NonexistentFrontendHeader(Handle<Name> name, Label* miss, | |
| 44 Register scratch1, Register scratch2); | |
| 45 | 43 |
| 46 // When FLAG_vector_ics is true, handlers that have the possibility of missing | 44 // When FLAG_vector_ics is true, handlers that have the possibility of missing |
| 47 // will need to save and pass these to miss handlers. | 45 // will need to save and pass these to miss handlers. |
| 48 void PushVectorAndSlot() { PushVectorAndSlot(vector(), slot()); } | 46 void PushVectorAndSlot() { PushVectorAndSlot(vector(), slot()); } |
| 49 void PushVectorAndSlot(Register vector, Register slot); | 47 void PushVectorAndSlot(Register vector, Register slot); |
| 50 void PopVectorAndSlot() { PopVectorAndSlot(vector(), slot()); } | 48 void PopVectorAndSlot() { PopVectorAndSlot(vector(), slot()); } |
| 51 void PopVectorAndSlot(Register vector, Register slot); | 49 void PopVectorAndSlot(Register vector, Register slot); |
| 52 | 50 |
| 53 void DiscardVectorAndSlot(); | 51 void DiscardVectorAndSlot(); |
| 54 | 52 |
| 55 void PushReturnAddress(Register tmp); | |
| 56 void PopReturnAddress(Register tmp); | |
| 57 | |
| 58 // TODO(verwaest): Make non-static. | 53 // TODO(verwaest): Make non-static. |
| 59 static void GenerateApiAccessorCall(MacroAssembler* masm, | 54 static void GenerateApiAccessorCall(MacroAssembler* masm, |
| 60 const CallOptimization& optimization, | 55 const CallOptimization& optimization, |
| 61 Handle<Map> receiver_map, | 56 Handle<Map> receiver_map, |
| 62 Register receiver, Register scratch, | 57 Register receiver, Register scratch, |
| 63 bool is_store, Register store_parameter, | 58 bool is_store, Register store_parameter, |
| 64 Register accessor_holder, | 59 Register accessor_holder, |
| 65 int accessor_index); | 60 int accessor_index); |
| 66 | 61 |
| 67 // Helper function used to check that the dictionary doesn't contain | 62 // Helper function used to check that the dictionary doesn't contain |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 // the iterator points to a LookupIterator::PROPERTY, its access will be | 141 // the iterator points to a LookupIterator::PROPERTY, its access will be |
| 147 // inlined. | 142 // inlined. |
| 148 Handle<Code> CompileLoadInterceptor(LookupIterator* it); | 143 Handle<Code> CompileLoadInterceptor(LookupIterator* it); |
| 149 | 144 |
| 150 Handle<Code> CompileLoadViaGetter(Handle<Name> name, int accessor_index, | 145 Handle<Code> CompileLoadViaGetter(Handle<Name> name, int accessor_index, |
| 151 int expected_arguments); | 146 int expected_arguments); |
| 152 | 147 |
| 153 Handle<Code> CompileLoadGlobal(Handle<PropertyCell> cell, Handle<Name> name, | 148 Handle<Code> CompileLoadGlobal(Handle<PropertyCell> cell, Handle<Name> name, |
| 154 bool is_configurable); | 149 bool is_configurable); |
| 155 | 150 |
| 156 // Static interface | |
| 157 static Handle<Code> ComputeLoadNonexistent(Handle<Name> name, | |
| 158 Handle<Map> map); | |
| 159 | |
| 160 static void GenerateLoadViaGetter(MacroAssembler* masm, Handle<Map> map, | 151 static void GenerateLoadViaGetter(MacroAssembler* masm, Handle<Map> map, |
| 161 Register receiver, Register holder, | 152 Register receiver, Register holder, |
| 162 int accessor_index, int expected_arguments, | 153 int accessor_index, int expected_arguments, |
| 163 Register scratch); | 154 Register scratch); |
| 164 | 155 |
| 165 static void GenerateLoadViaGetterForDeopt(MacroAssembler* masm) { | 156 static void GenerateLoadViaGetterForDeopt(MacroAssembler* masm) { |
| 166 GenerateLoadViaGetter(masm, Handle<Map>::null(), no_reg, no_reg, -1, -1, | 157 GenerateLoadViaGetter(masm, Handle<Map>::null(), no_reg, no_reg, -1, -1, |
| 167 no_reg); | 158 no_reg); |
| 168 } | 159 } |
| 169 | 160 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 182 static const int kInterceptorArgsHolderIndex = 2; | 173 static const int kInterceptorArgsHolderIndex = 2; |
| 183 static const int kInterceptorArgsLength = 3; | 174 static const int kInterceptorArgsLength = 3; |
| 184 | 175 |
| 185 protected: | 176 protected: |
| 186 virtual Register FrontendHeader(Register object_reg, Handle<Name> name, | 177 virtual Register FrontendHeader(Register object_reg, Handle<Name> name, |
| 187 Label* miss, ReturnHolder return_what); | 178 Label* miss, ReturnHolder return_what); |
| 188 | 179 |
| 189 virtual void FrontendFooter(Handle<Name> name, Label* miss); | 180 virtual void FrontendFooter(Handle<Name> name, Label* miss); |
| 190 | 181 |
| 191 private: | 182 private: |
| 192 Handle<Code> CompileLoadNonexistent(Handle<Name> name); | |
| 193 void GenerateLoadConstant(Handle<Object> value); | |
| 194 void GenerateLoadCallback(Register reg, Handle<AccessorInfo> callback); | 183 void GenerateLoadCallback(Register reg, Handle<AccessorInfo> callback); |
| 195 void GenerateLoadCallback(const CallOptimization& call_optimization, | |
| 196 Handle<Map> receiver_map); | |
| 197 | 184 |
| 198 // Helper emits no code if vector-ics are disabled. | 185 // Helper emits no code if vector-ics are disabled. |
| 199 void InterceptorVectorSlotPush(Register holder_reg); | 186 void InterceptorVectorSlotPush(Register holder_reg); |
| 200 enum PopMode { POP, DISCARD }; | 187 enum PopMode { POP, DISCARD }; |
| 201 void InterceptorVectorSlotPop(Register holder_reg, PopMode mode = POP); | 188 void InterceptorVectorSlotPop(Register holder_reg, PopMode mode = POP); |
| 202 | 189 |
| 203 void GenerateLoadInterceptor(Register holder_reg); | 190 void GenerateLoadInterceptor(Register holder_reg); |
| 204 void GenerateLoadInterceptorWithFollowup(LookupIterator* it, | 191 void GenerateLoadInterceptorWithFollowup(LookupIterator* it, |
| 205 Register holder_reg); | 192 Register holder_reg); |
| 206 void GenerateLoadPostInterceptor(LookupIterator* it, Register reg); | 193 void GenerateLoadPostInterceptor(LookupIterator* it, Register reg); |
| 207 | 194 |
| 208 // Generates prototype loading code that uses the objects from the | |
| 209 // context we were in when this function was called. If the context | |
| 210 // has changed, a jump to miss is performed. This ties the generated | |
| 211 // code to a particular context and so must not be used in cases | |
| 212 // where the generated code is not allowed to have references to | |
| 213 // objects from a context. | |
| 214 static void GenerateDirectLoadGlobalFunctionPrototype(MacroAssembler* masm, | |
| 215 int index, | |
| 216 Register prototype, | |
| 217 Label* miss); | |
| 218 | |
| 219 Register scratch3() { return registers_[4]; } | 195 Register scratch3() { return registers_[4]; } |
| 220 }; | 196 }; |
| 221 | 197 |
| 222 | 198 |
| 223 class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { | 199 class NamedStoreHandlerCompiler : public PropertyHandlerCompiler { |
| 224 public: | 200 public: |
| 225 // All store handlers use StoreWithVectorDescriptor calling convention. | 201 // All store handlers use StoreWithVectorDescriptor calling convention. |
| 226 typedef StoreWithVectorDescriptor Descriptor; | 202 typedef StoreWithVectorDescriptor Descriptor; |
| 227 | 203 |
| 228 explicit NamedStoreHandlerCompiler(Isolate* isolate, Handle<Map> map, | 204 explicit NamedStoreHandlerCompiler(Isolate* isolate, Handle<Map> map, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 237 } |
| 262 | 238 |
| 263 protected: | 239 protected: |
| 264 virtual Register FrontendHeader(Register object_reg, Handle<Name> name, | 240 virtual Register FrontendHeader(Register object_reg, Handle<Name> name, |
| 265 Label* miss, ReturnHolder return_what); | 241 Label* miss, ReturnHolder return_what); |
| 266 | 242 |
| 267 virtual void FrontendFooter(Handle<Name> name, Label* miss); | 243 virtual void FrontendFooter(Handle<Name> name, Label* miss); |
| 268 void GenerateRestoreName(Label* label, Handle<Name> name); | 244 void GenerateRestoreName(Label* label, Handle<Name> name); |
| 269 | 245 |
| 270 private: | 246 private: |
| 271 void GenerateRestoreName(Handle<Name> name); | |
| 272 void GenerateRestoreMap(Handle<Map> transition, Register map_reg, | |
| 273 Register scratch, Label* miss); | |
| 274 | |
| 275 void GenerateConstantCheck(Register map_reg, int descriptor, | |
| 276 Register value_reg, Register scratch, | |
| 277 Label* miss_label); | |
| 278 | |
| 279 bool RequiresFieldTypeChecks(FieldType* field_type) const; | |
| 280 void GenerateFieldTypeChecks(FieldType* field_type, Register value_reg, | |
| 281 Label* miss_label); | |
| 282 | |
| 283 static Register value(); | 247 static Register value(); |
| 284 }; | 248 }; |
| 285 | 249 |
| 286 | 250 |
| 287 class ElementHandlerCompiler : public PropertyHandlerCompiler { | 251 class ElementHandlerCompiler : public PropertyHandlerCompiler { |
| 288 public: | 252 public: |
| 289 explicit ElementHandlerCompiler(Isolate* isolate) | 253 explicit ElementHandlerCompiler(Isolate* isolate) |
| 290 : PropertyHandlerCompiler(isolate, Code::KEYED_LOAD_IC, | 254 : PropertyHandlerCompiler(isolate, Code::KEYED_LOAD_IC, |
| 291 Handle<Map>::null(), Handle<JSObject>::null(), | 255 Handle<Map>::null(), Handle<JSObject>::null(), |
| 292 kCacheOnReceiver) {} | 256 kCacheOnReceiver) {} |
| 293 | 257 |
| 294 virtual ~ElementHandlerCompiler() {} | 258 virtual ~ElementHandlerCompiler() {} |
| 295 | 259 |
| 296 static Handle<Object> GetKeyedLoadHandler(Handle<Map> receiver_map, | 260 static Handle<Object> GetKeyedLoadHandler(Handle<Map> receiver_map, |
| 297 Isolate* isolate); | 261 Isolate* isolate); |
| 298 void CompileElementHandlers(MapHandleList* receiver_maps, | 262 void CompileElementHandlers(MapHandleList* receiver_maps, |
| 299 List<Handle<Object>>* handlers); | 263 List<Handle<Object>>* handlers); |
| 300 }; | 264 }; |
| 301 } // namespace internal | 265 } // namespace internal |
| 302 } // namespace v8 | 266 } // namespace v8 |
| 303 | 267 |
| 304 #endif // V8_IC_HANDLER_COMPILER_H_ | 268 #endif // V8_IC_HANDLER_COMPILER_H_ |
| OLD | NEW |