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" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 | 15 |
16 // IC_UTIL_LIST defines all utility functions called from generated | 16 // IC_UTIL_LIST defines all utility functions called from generated |
17 // inline caching code. The argument for the macro, ICU, is the function name. | 17 // inline caching code. The argument for the macro, ICU, is the function name. |
18 #define IC_UTIL_LIST(ICU) \ | 18 #define IC_UTIL_LIST(ICU) \ |
19 ICU(LoadIC_Miss) \ | 19 ICU(LoadIC_Miss) \ |
20 ICU(KeyedLoadIC_Miss) \ | 20 ICU(KeyedLoadIC_Miss) \ |
21 ICU(LoadIC_Slow) \ | |
22 ICU(KeyedLoadIC_Slow) \ | |
23 ICU(CallIC_Miss) \ | 21 ICU(CallIC_Miss) \ |
24 ICU(CallIC_Customization_Miss) \ | 22 ICU(CallIC_Customization_Miss) \ |
25 ICU(StoreIC_Miss) \ | 23 ICU(StoreIC_Miss) \ |
26 ICU(StoreIC_Slow) \ | 24 ICU(StoreIC_Slow) \ |
27 ICU(KeyedStoreIC_Miss) \ | 25 ICU(KeyedStoreIC_Miss) \ |
28 ICU(KeyedStoreIC_Slow) \ | 26 ICU(KeyedStoreIC_Slow) \ |
29 /* Utilities for IC stubs. */ \ | 27 /* Utilities for IC stubs. */ \ |
30 ICU(StoreCallbackProperty) \ | 28 ICU(StoreCallbackProperty) \ |
31 ICU(LoadPropertyWithInterceptorOnly) \ | 29 ICU(LoadPropertyWithInterceptorOnly) \ |
32 ICU(LoadPropertyWithInterceptor) \ | 30 ICU(LoadPropertyWithInterceptor) \ |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 CallICState::CallType call_type); | 345 CallICState::CallType call_type); |
348 static Handle<Code> initialize_stub_in_optimized_code( | 346 static Handle<Code> initialize_stub_in_optimized_code( |
349 Isolate* isolate, int argc, CallICState::CallType call_type); | 347 Isolate* isolate, int argc, CallICState::CallType call_type); |
350 | 348 |
351 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus); | 349 static void Clear(Isolate* isolate, Code* host, CallICNexus* nexus); |
352 }; | 350 }; |
353 | 351 |
354 | 352 |
355 class LoadIC : public IC { | 353 class LoadIC : public IC { |
356 public: | 354 public: |
357 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, | 355 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode) { |
358 LanguageMode language_mode) { | 356 return LoadICState(contextual_mode).GetExtraICState(); |
359 return LoadICState(contextual_mode, language_mode).GetExtraICState(); | |
360 } | 357 } |
361 | 358 |
362 ContextualMode contextual_mode() const { | 359 ContextualMode contextual_mode() const { |
363 return LoadICState::GetContextualMode(extra_ic_state()); | 360 return LoadICState::GetContextualMode(extra_ic_state()); |
364 } | 361 } |
365 | 362 |
366 LanguageMode language_mode() const { | |
367 return LoadICState::GetLanguageMode(extra_ic_state()); | |
368 } | |
369 | |
370 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) | 363 LoadIC(FrameDepth depth, Isolate* isolate, FeedbackNexus* nexus = NULL) |
371 : IC(depth, isolate, nexus) { | 364 : IC(depth, isolate, nexus) { |
372 DCHECK(nexus != NULL); | 365 DCHECK(nexus != NULL); |
373 DCHECK(IsLoadStub()); | 366 DCHECK(IsLoadStub()); |
374 } | 367 } |
375 | 368 |
376 // TODO(mvstanton): The for_queries_only is because we have a case where we | 369 // TODO(mvstanton): The for_queries_only is because we have a case where we |
377 // construct an IC only to gather the contextual mode, and we don't have | 370 // construct an IC only to gather the contextual mode, and we don't have |
378 // vector/slot information. for_queries_only is a temporary hack to enable the | 371 // vector/slot information. for_queries_only is a temporary hack to enable the |
379 // strong DCHECK protection around vector/slot. | 372 // strong DCHECK protection around vector/slot. |
(...skipping 10 matching lines...) Expand all Loading... |
390 } else { | 383 } else { |
391 DCHECK(contextual_mode() != CONTEXTUAL); | 384 DCHECK(contextual_mode() != CONTEXTUAL); |
392 return false; | 385 return false; |
393 } | 386 } |
394 } | 387 } |
395 | 388 |
396 // Code generator routines. | 389 // Code generator routines. |
397 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 390 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
398 static void GenerateMiss(MacroAssembler* masm); | 391 static void GenerateMiss(MacroAssembler* masm); |
399 static void GenerateNormal(MacroAssembler* masm); | 392 static void GenerateNormal(MacroAssembler* masm); |
400 static void GenerateSlow(MacroAssembler* masm); | 393 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
401 | 394 |
402 static Handle<Code> initialize_stub(Isolate* isolate, | 395 static Handle<Code> initialize_stub(Isolate* isolate, |
403 ExtraICState extra_state); | 396 ExtraICState extra_state); |
404 static Handle<Code> initialize_stub_in_optimized_code( | 397 static Handle<Code> initialize_stub_in_optimized_code( |
405 Isolate* isolate, ExtraICState extra_state, State initialization_state); | 398 Isolate* isolate, ExtraICState extra_state, State initialization_state); |
406 | 399 |
407 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 400 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
408 Handle<Name> name); | 401 Handle<Name> name); |
409 | 402 |
410 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); | 403 static void Clear(Isolate* isolate, Code* host, LoadICNexus* nexus); |
(...skipping 26 matching lines...) Expand all Loading... |
437 static void Clear(Isolate* isolate, Address address, Code* target, | 430 static void Clear(Isolate* isolate, Address address, Code* target, |
438 Address constant_pool); | 431 Address constant_pool); |
439 | 432 |
440 friend class IC; | 433 friend class IC; |
441 }; | 434 }; |
442 | 435 |
443 | 436 |
444 class KeyedLoadIC : public LoadIC { | 437 class KeyedLoadIC : public LoadIC { |
445 public: | 438 public: |
446 // ExtraICState bits (building on IC) | 439 // ExtraICState bits (building on IC) |
447 class IcCheckTypeField | 440 class IcCheckTypeField : public BitField<IcCheckType, 1, 1> {}; |
448 : public BitField<IcCheckType, LoadICState::kNextBitFieldOffset, 1> {}; | |
449 | 441 |
450 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, | 442 static ExtraICState ComputeExtraICState(ContextualMode contextual_mode, |
451 LanguageMode language_mode, | |
452 IcCheckType key_type) { | 443 IcCheckType key_type) { |
453 return LoadICState(contextual_mode, language_mode).GetExtraICState() | | 444 return LoadICState(contextual_mode).GetExtraICState() | |
454 IcCheckTypeField::encode(key_type); | 445 IcCheckTypeField::encode(key_type); |
455 } | 446 } |
456 | 447 |
457 static IcCheckType GetKeyType(ExtraICState extra_state) { | 448 static IcCheckType GetKeyType(ExtraICState extra_state) { |
458 return IcCheckTypeField::decode(extra_state); | 449 return IcCheckTypeField::decode(extra_state); |
459 } | 450 } |
460 | 451 |
461 KeyedLoadIC(FrameDepth depth, Isolate* isolate, | 452 KeyedLoadIC(FrameDepth depth, Isolate* isolate, |
462 KeyedLoadICNexus* nexus = NULL) | 453 KeyedLoadICNexus* nexus = NULL) |
463 : LoadIC(depth, isolate, nexus) { | 454 : LoadIC(depth, isolate, nexus) { |
464 DCHECK(nexus != NULL); | 455 DCHECK(nexus != NULL); |
465 DCHECK(target()->is_keyed_load_stub()); | 456 DCHECK(target()->is_keyed_load_stub()); |
466 } | 457 } |
467 | 458 |
468 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, | 459 MUST_USE_RESULT MaybeHandle<Object> Load(Handle<Object> object, |
469 Handle<Object> key); | 460 Handle<Object> key); |
470 | 461 |
471 // Code generator routines. | 462 // Code generator routines. |
472 static void GenerateMiss(MacroAssembler* masm); | 463 static void GenerateMiss(MacroAssembler* masm); |
473 static void GenerateSlow(MacroAssembler* masm); | 464 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
474 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 465 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
475 static void GenerateMegamorphic(MacroAssembler* masm, | 466 static void GenerateMegamorphic(MacroAssembler* masm); |
476 LanguageMode languageMode); | |
477 | 467 |
478 // Bit mask to be tested against bit field for the cases when | 468 // Bit mask to be tested against bit field for the cases when |
479 // generic stub should go into slow case. | 469 // generic stub should go into slow case. |
480 // Access check is necessary explicitly since generic stub does not perform | 470 // Access check is necessary explicitly since generic stub does not perform |
481 // map checks. | 471 // map checks. |
482 static const int kSlowCaseBitFieldMask = | 472 static const int kSlowCaseBitFieldMask = |
483 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 473 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
484 | 474 |
485 static Handle<Code> initialize_stub(Isolate* isolate, | 475 static Handle<Code> initialize_stub(Isolate* isolate); |
486 ExtraICState extra_state); | |
487 static Handle<Code> initialize_stub_in_optimized_code( | 476 static Handle<Code> initialize_stub_in_optimized_code( |
488 Isolate* isolate, State initialization_state, ExtraICState extra_state); | 477 Isolate* isolate, State initialization_state); |
489 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate, | 478 static Handle<Code> ChooseMegamorphicStub(Isolate* isolate); |
490 ExtraICState extra_state); | |
491 | 479 |
492 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus); | 480 static void Clear(Isolate* isolate, Code* host, KeyedLoadICNexus* nexus); |
493 | 481 |
494 protected: | 482 protected: |
495 // receiver is HeapObject because it could be a String or a JSObject | 483 // receiver is HeapObject because it could be a String or a JSObject |
496 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); | 484 Handle<Code> LoadElementStub(Handle<HeapObject> receiver); |
497 | 485 |
498 private: | 486 private: |
499 static void Clear(Isolate* isolate, Address address, Code* target, | 487 static void Clear(Isolate* isolate, Address address, Code* target, |
500 Address constant_pool); | 488 Address constant_pool); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
748 | 736 |
749 // Support functions for interceptor handlers. | 737 // Support functions for interceptor handlers. |
750 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); | 738 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly); |
751 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); | 739 DECLARE_RUNTIME_FUNCTION(LoadPropertyWithInterceptor); |
752 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); | 740 DECLARE_RUNTIME_FUNCTION(LoadElementWithInterceptor); |
753 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); | 741 DECLARE_RUNTIME_FUNCTION(StorePropertyWithInterceptor); |
754 } | 742 } |
755 } // namespace v8::internal | 743 } // namespace v8::internal |
756 | 744 |
757 #endif // V8_IC_H_ | 745 #endif // V8_IC_H_ |
OLD | NEW |