| 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 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 DCHECK(RecomputeHandlerForName(name)); | 40 DCHECK(RecomputeHandlerForName(name)); |
| 41 old_state_ = state_; | 41 old_state_ = state_; |
| 42 state_ = RECOMPUTE_HANDLER; | 42 state_ = RECOMPUTE_HANDLER; |
| 43 } | 43 } |
| 44 | 44 |
| 45 // Clear the inline cache to initial state. | 45 // Clear the inline cache to initial state. |
| 46 static void Clear(Isolate* isolate, Address address, Address constant_pool); | 46 static void Clear(Isolate* isolate, Address address, Address constant_pool); |
| 47 | 47 |
| 48 #ifdef DEBUG | 48 #ifdef DEBUG |
| 49 bool IsLoadStub() const { | 49 bool IsLoadStub() const { |
| 50 return kind_ == Code::LOAD_IC || kind_ == Code::KEYED_LOAD_IC; | 50 return kind_ == Code::LOAD_IC || kind_ == Code::LOAD_GLOBAL_IC || |
| 51 kind_ == Code::KEYED_LOAD_IC; |
| 51 } | 52 } |
| 52 bool IsStoreStub() const { | 53 bool IsStoreStub() const { |
| 53 return kind_ == Code::STORE_IC || kind_ == Code::KEYED_STORE_IC; | 54 return kind_ == Code::STORE_IC || kind_ == Code::KEYED_STORE_IC; |
| 54 } | 55 } |
| 55 bool IsCallStub() const { return kind_ == Code::CALL_IC; } | 56 bool IsCallStub() const { return kind_ == Code::CALL_IC; } |
| 56 #endif | 57 #endif |
| 57 | 58 |
| 58 static inline Handle<Map> GetHandlerCacheHolder(Handle<Map> receiver_map, | 59 static inline Handle<Map> GetHandlerCacheHolder(Handle<Map> receiver_map, |
| 59 bool receiver_is_holder, | 60 bool receiver_is_holder, |
| 60 Isolate* isolate, | 61 Isolate* isolate, |
| 61 CacheHolderFlag* flag); | 62 CacheHolderFlag* flag); |
| 62 static inline Handle<Map> GetICCacheHolder(Handle<Map> receiver_map, | 63 static inline Handle<Map> GetICCacheHolder(Handle<Map> receiver_map, |
| 63 Isolate* isolate, | 64 Isolate* isolate, |
| 64 CacheHolderFlag* flag); | 65 CacheHolderFlag* flag); |
| 65 | 66 |
| 66 static bool IsCleared(FeedbackNexus* nexus) { | 67 static bool IsCleared(FeedbackNexus* nexus) { |
| 67 InlineCacheState state = nexus->StateFromFeedback(); | 68 InlineCacheState state = nexus->StateFromFeedback(); |
| 68 return !FLAG_use_ic || state == UNINITIALIZED || state == PREMONOMORPHIC; | 69 return !FLAG_use_ic || state == UNINITIALIZED || state == PREMONOMORPHIC; |
| 69 } | 70 } |
| 70 | 71 |
| 71 static bool ICUseVector(Code::Kind kind) { | 72 static bool ICUseVector(Code::Kind kind) { |
| 72 return kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC || | 73 return kind == Code::LOAD_IC || kind == Code::LOAD_GLOBAL_IC || |
| 73 kind == Code::CALL_IC || kind == Code::STORE_IC || | 74 kind == Code::KEYED_LOAD_IC || kind == Code::CALL_IC || |
| 74 kind == Code::KEYED_STORE_IC; | 75 kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC; |
| 75 } | 76 } |
| 76 | 77 |
| 77 static InlineCacheState StateFromCode(Code* code); | 78 static InlineCacheState StateFromCode(Code* code); |
| 78 | 79 |
| 79 protected: | 80 protected: |
| 80 Address fp() const { return fp_; } | 81 Address fp() const { return fp_; } |
| 81 Address pc() const { return *pc_address_; } | 82 Address pc() const { return *pc_address_; } |
| 82 Isolate* isolate() const { return isolate_; } | 83 Isolate* isolate() const { return isolate_; } |
| 83 | 84 |
| 84 // Get the shared function info of the caller. | 85 // Get the shared function info of the caller. |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 TypeofMode typeof_mode() const { | 272 TypeofMode typeof_mode() const { |
| 272 return LoadICState::GetTypeofMode(extra_ic_state()); | 273 return LoadICState::GetTypeofMode(extra_ic_state()); |
| 273 } | 274 } |
| 274 | 275 |
| 275 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) | 276 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) |
| 276 : IC(depth, isolate, nexus) { | 277 : IC(depth, isolate, nexus) { |
| 277 DCHECK(nexus != NULL); | 278 DCHECK(nexus != NULL); |
| 278 DCHECK(IsLoadStub()); | 279 DCHECK(IsLoadStub()); |
| 279 } | 280 } |
| 280 | 281 |
| 281 bool ShouldThrowReferenceError(Handle<Object> receiver) { | 282 bool ShouldThrowReferenceError() const { |
| 282 return receiver->IsJSGlobalObject() && typeof_mode() == NOT_INSIDE_TYPEOF; | 283 return kind() == Code::LOAD_GLOBAL_IC && typeof_mode() == NOT_INSIDE_TYPEOF; |
| 283 } | 284 } |
| 284 | 285 |
| 285 // Code generator routines. | 286 // Code generator routines. |
| 286 | 287 |
| 287 static void GenerateMiss(MacroAssembler* masm); | 288 static void GenerateMiss(MacroAssembler* masm); |
| 288 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 289 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 289 static void GenerateNormal(MacroAssembler* masm); | 290 static void GenerateNormal(MacroAssembler* masm); |
| 290 | 291 |
| 291 static Handle<Code> initialize_stub_in_optimized_code( | 292 static Handle<Code> initialize_stub_in_optimized_code( |
| 292 Isolate* isolate, ExtraICState extra_state); | 293 Isolate* isolate, ExtraICState extra_state); |
| 293 | 294 |
| 294 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 295 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
| 295 Handle<Name> name); | 296 Handle<Name> name); |
| 296 | 297 |
| 297 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); | 298 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); |
| 298 | 299 |
| 299 protected: | 300 protected: |
| 300 Handle<Code> slow_stub() const { | 301 virtual Handle<Code> slow_stub() const { |
| 301 return isolate()->builtins()->LoadIC_Slow(); | 302 return isolate()->builtins()->LoadIC_Slow(); |
| 302 } | 303 } |
| 303 | 304 |
| 304 // Update the inline cache and the global stub cache based on the | 305 // Update the inline cache and the global stub cache based on the |
| 305 // lookup result. | 306 // lookup result. |
| 306 void UpdateCaches(LookupIterator* lookup); | 307 void UpdateCaches(LookupIterator* lookup); |
| 307 | 308 |
| 308 Handle<Code> GetMapIndependentHandler(LookupIterator* lookup) override; | 309 Handle<Code> GetMapIndependentHandler(LookupIterator* lookup) override; |
| 309 | 310 |
| 310 Handle<Code> CompileHandler(LookupIterator* lookup, Handle<Object> unused, | 311 Handle<Code> CompileHandler(LookupIterator* lookup, Handle<Object> unused, |
| 311 CacheHolderFlag cache_holder) override; | 312 CacheHolderFlag cache_holder) override; |
| 312 | 313 |
| 313 private: | 314 private: |
| 314 Handle<Code> SimpleFieldLoad(FieldIndex index); | 315 Handle<Code> SimpleFieldLoad(FieldIndex index); |
| 315 | 316 |
| 316 friend class IC; | 317 friend class IC; |
| 317 }; | 318 }; |
| 318 | 319 |
| 320 class LoadGlobalIC : public LoadIC { |
| 321 public: |
| 322 LoadGlobalIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) |
| 323 : LoadIC(depth, isolate, nexus) {} |
| 324 |
| 325 static Handle<Code> initialize_stub_in_optimized_code( |
| 326 Isolate* isolate, ExtraICState extra_state); |
| 327 |
| 328 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Name> name); |
| 329 |
| 330 static void Clear(Isolate* isolate, Code* host, LoadGlobalICNexus* nexus); |
| 331 |
| 332 protected: |
| 333 Handle<Code> slow_stub() const override { |
| 334 return isolate()->builtins()->LoadGlobalIC_Slow(); |
| 335 } |
| 336 }; |
| 319 | 337 |
| 320 class KeyedLoadIC : public LoadIC { | 338 class KeyedLoadIC : public LoadIC { |
| 321 public: | 339 public: |
| 322 KeyedLoadIC(FrameDepth depth, Isolate* isolate, | 340 KeyedLoadIC(FrameDepth depth, Isolate* isolate, |
| 323 KeyedLoadICNexus* nexus = NULL) | 341 KeyedLoadICNexus* nexus = NULL) |
| 324 : LoadIC(depth, isolate, nexus) { | 342 : LoadIC(depth, isolate, nexus) { |
| 325 DCHECK(nexus != NULL); | 343 DCHECK(nexus != NULL); |
| 326 } | 344 } |
| 327 | 345 |
| 328 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 346 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 | 513 |
| 496 // Helper for BinaryOpIC and CompareIC. | 514 // Helper for BinaryOpIC and CompareIC. |
| 497 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 515 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
| 498 void PatchInlinedSmiCode(Isolate* isolate, Address address, | 516 void PatchInlinedSmiCode(Isolate* isolate, Address address, |
| 499 InlinedSmiCheck check); | 517 InlinedSmiCheck check); |
| 500 | 518 |
| 501 } // namespace internal | 519 } // namespace internal |
| 502 } // namespace v8 | 520 } // namespace v8 |
| 503 | 521 |
| 504 #endif // V8_IC_H_ | 522 #endif // V8_IC_H_ |
| OLD | NEW |