OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_H_ | 5 #ifndef V8_IC_H_ |
6 #define V8_IC_H_ | 6 #define V8_IC_H_ |
7 | 7 |
8 #include "src/ic/ic-state.h" | 8 #include "src/ic/ic-state.h" |
9 #include "src/macro-assembler.h" | 9 #include "src/macro-assembler.h" |
10 | 10 |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // If the stub contains weak maps then this function adds the stub to | 77 // If the stub contains weak maps then this function adds the stub to |
78 // the dependent code array of each weak map. | 78 // the dependent code array of each weak map. |
79 static void RegisterWeakMapDependency(Handle<Code> stub); | 79 static void RegisterWeakMapDependency(Handle<Code> stub); |
80 | 80 |
81 // This function is called when a weak map in the stub is dying, | 81 // This function is called when a weak map in the stub is dying, |
82 // invalidates the stub by setting maps in it to undefined. | 82 // invalidates the stub by setting maps in it to undefined. |
83 static void InvalidateMaps(Code* stub); | 83 static void InvalidateMaps(Code* stub); |
84 | 84 |
85 // Clear the inline cache to initial state. | 85 // Clear the inline cache to initial state. |
86 static void Clear(Isolate* isolate, Address address, | 86 static void Clear(Isolate* isolate, Address address, |
| 87 TypeFeedbackVector* vector, FeedbackVectorICSlot slot, |
87 ConstantPoolArray* constant_pool); | 88 ConstantPoolArray* constant_pool); |
88 | 89 |
89 #ifdef DEBUG | 90 #ifdef DEBUG |
90 bool IsLoadStub() const { | 91 bool IsLoadStub() const { |
91 return target()->is_load_stub() || target()->is_keyed_load_stub(); | 92 return target()->is_load_stub() || target()->is_keyed_load_stub(); |
92 } | 93 } |
93 | 94 |
94 bool IsStoreStub() const { | 95 bool IsStoreStub() const { |
95 return target()->is_store_stub() || target()->is_keyed_store_stub(); | 96 return target()->is_store_stub() || target()->is_keyed_store_stub(); |
96 } | 97 } |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 Address address_; | 288 Address address_; |
288 IC::UtilityId id_; | 289 IC::UtilityId id_; |
289 }; | 290 }; |
290 | 291 |
291 | 292 |
292 class CallIC : public IC { | 293 class CallIC : public IC { |
293 public: | 294 public: |
294 explicit CallIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} | 295 explicit CallIC(Isolate* isolate) : IC(EXTRA_CALL_FRAME, isolate) {} |
295 | 296 |
296 void PatchMegamorphic(Handle<Object> function, | 297 void PatchMegamorphic(Handle<Object> function, |
297 Handle<TypeFeedbackVector> vector, Handle<Smi> slot); | 298 Handle<TypeFeedbackVector> vector, |
| 299 FeedbackVectorICSlot slot); |
298 | 300 |
299 void HandleMiss(Handle<Object> receiver, Handle<Object> function, | 301 void HandleMiss(Handle<Object> receiver, Handle<Object> function, |
300 Handle<TypeFeedbackVector> vector, Handle<Smi> slot); | 302 Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot); |
301 | 303 |
302 // Returns true if a custom handler was installed. | 304 // Returns true if a custom handler was installed. |
303 bool DoCustomHandler(Handle<Object> receiver, Handle<Object> function, | 305 bool DoCustomHandler(Handle<Object> receiver, Handle<Object> function, |
304 Handle<TypeFeedbackVector> vector, Handle<Smi> slot, | 306 Handle<TypeFeedbackVector> vector, |
305 const CallICState& state); | 307 FeedbackVectorICSlot slot, const CallICState& state); |
306 | 308 |
307 // Code generator routines. | 309 // Code generator routines. |
308 static Handle<Code> initialize_stub(Isolate* isolate, int argc, | 310 static Handle<Code> initialize_stub(Isolate* isolate, int argc, |
309 CallICState::CallType call_type); | 311 CallICState::CallType call_type); |
310 | 312 |
311 static void Clear(Isolate* isolate, Address address, Code* target, | 313 static void Clear(Isolate* isolate, Address address, Code* target, |
| 314 TypeFeedbackVector* vector, FeedbackVectorICSlot slot, |
312 ConstantPoolArray* constant_pool); | 315 ConstantPoolArray* constant_pool); |
313 | 316 |
314 private: | 317 private: |
| 318 static inline IC::State FeedbackToState(Isolate* isolate, |
| 319 TypeFeedbackVector* vector, |
| 320 FeedbackVectorICSlot slot); |
| 321 |
315 inline IC::State FeedbackToState(Handle<TypeFeedbackVector> vector, | 322 inline IC::State FeedbackToState(Handle<TypeFeedbackVector> vector, |
316 Handle<Smi> slot) const; | 323 FeedbackVectorICSlot slot) const; |
| 324 |
| 325 // As a vector-based IC, type feedback must be updated differently. |
| 326 static void OnTypeFeedbackChanged(Isolate* isolate, Address address, |
| 327 TypeFeedbackVector* vector, State old_state, |
| 328 State new_state); |
| 329 inline void OnTypeFeedbackChanged(Handle<TypeFeedbackVector> vector, |
| 330 State old_state, State new_state); |
317 }; | 331 }; |
318 | 332 |
319 | 333 |
320 class LoadIC : public IC { | 334 class LoadIC : public IC { |
321 public: | 335 public: |
322 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { | 336 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { |
323 return LoadICState(contextual_mode).GetExtraICState(); | 337 return LoadICState(contextual_mode).GetExtraICState(); |
324 } | 338 } |
325 | 339 |
326 ContextualMode contextual_mode() const { | 340 ContextualMode contextual_mode() const { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 CacheHolderFlag cache_holder); | 396 CacheHolderFlag cache_holder); |
383 | 397 |
384 private: | 398 private: |
385 virtual Handle<Code> pre_monomorphic_stub() const; | 399 virtual Handle<Code> pre_monomorphic_stub() const; |
386 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, | 400 static Handle<Code> pre_monomorphic_stub(Isolate* isolate, |
387 ExtraICState extra_state); | 401 ExtraICState extra_state); |
388 | 402 |
389 Handle<Code> SimpleFieldLoad(FieldIndex index); | 403 Handle<Code> SimpleFieldLoad(FieldIndex index); |
390 | 404 |
391 static void Clear(Isolate* isolate, Address address, Code* target, | 405 static void Clear(Isolate* isolate, Address address, Code* target, |
| 406 TypeFeedbackVector* vector, FeedbackVectorICSlot slot, |
392 ConstantPoolArray* constant_pool); | 407 ConstantPoolArray* constant_pool); |
393 | 408 |
394 friend class IC; | 409 friend class IC; |
395 }; | 410 }; |
396 | 411 |
397 | 412 |
398 class KeyedLoadIC : public LoadIC { | 413 class KeyedLoadIC : public LoadIC { |
399 public: | 414 public: |
400 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) | 415 explicit KeyedLoadIC(FrameDepth depth, Isolate* isolate) |
401 : LoadIC(depth, isolate) { | 416 : LoadIC(depth, isolate) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 return pre_monomorphic_stub(isolate()); | 448 return pre_monomorphic_stub(isolate()); |
434 } | 449 } |
435 | 450 |
436 private: | 451 private: |
437 Handle<Code> generic_stub() const { return generic_stub(isolate()); } | 452 Handle<Code> generic_stub() const { return generic_stub(isolate()); } |
438 Handle<Code> string_stub() { | 453 Handle<Code> string_stub() { |
439 return isolate()->builtins()->KeyedLoadIC_String(); | 454 return isolate()->builtins()->KeyedLoadIC_String(); |
440 } | 455 } |
441 | 456 |
442 static void Clear(Isolate* isolate, Address address, Code* target, | 457 static void Clear(Isolate* isolate, Address address, Code* target, |
| 458 TypeFeedbackVector* vector, FeedbackVectorICSlot slot, |
443 ConstantPoolArray* constant_pool); | 459 ConstantPoolArray* constant_pool); |
444 | 460 |
445 friend class IC; | 461 friend class IC; |
446 }; | 462 }; |
447 | 463 |
448 | 464 |
449 class StoreIC : public IC { | 465 class StoreIC : public IC { |
450 public: | 466 public: |
451 class StrictModeState : public BitField<StrictMode, 1, 1> {}; | 467 class StrictModeState : public BitField<StrictMode, 1, 1> {}; |
452 static ExtraICState ComputeExtraICState(StrictMode flag) { | 468 static ExtraICState ComputeExtraICState(StrictMode flag) { |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 714 |
699 // Support functions for interceptor handlers. | 715 // Support functions for interceptor handlers. |
700 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | 716 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); |
701 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | 717 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); |
702 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | 718 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); |
703 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | 719 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); |
704 } | 720 } |
705 } // namespace v8::internal | 721 } // namespace v8::internal |
706 | 722 |
707 #endif // V8_IC_H_ | 723 #endif // V8_IC_H_ |
OLD | NEW |