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_FEEDBACK_VECTOR_H_ | 5 #ifndef V8_FEEDBACK_VECTOR_H_ |
6 #define V8_FEEDBACK_VECTOR_H_ | 6 #define V8_FEEDBACK_VECTOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 } | 470 } |
471 FeedbackVector* vector() const { | 471 FeedbackVector* vector() const { |
472 return vector_handle_.is_null() ? vector_ : *vector_handle_; | 472 return vector_handle_.is_null() ? vector_ : *vector_handle_; |
473 } | 473 } |
474 FeedbackSlot slot() const { return slot_; } | 474 FeedbackSlot slot() const { return slot_; } |
475 FeedbackSlotKind kind() const { return vector()->GetKind(slot()); } | 475 FeedbackSlotKind kind() const { return vector()->GetKind(slot()); } |
476 | 476 |
477 InlineCacheState ic_state() const { return StateFromFeedback(); } | 477 InlineCacheState ic_state() const { return StateFromFeedback(); } |
478 bool IsUninitialized() const { return StateFromFeedback() == UNINITIALIZED; } | 478 bool IsUninitialized() const { return StateFromFeedback() == UNINITIALIZED; } |
479 Map* FindFirstMap() const { | 479 Map* FindFirstMap() const { |
480 MapHandleList maps; | 480 MapHandles maps; |
481 ExtractMaps(&maps); | 481 ExtractMaps(&maps); |
482 if (maps.length() > 0) return *maps.at(0); | 482 if (maps.size() > 0) return *maps.at(0); |
483 return NULL; | 483 return NULL; |
484 } | 484 } |
485 | 485 |
486 virtual InlineCacheState StateFromFeedback() const = 0; | 486 virtual InlineCacheState StateFromFeedback() const = 0; |
487 virtual int ExtractMaps(MapHandleList* maps) const; | 487 virtual int ExtractMaps(MapHandles* maps) const; |
488 virtual MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const; | 488 virtual MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const; |
489 virtual bool FindHandlers(List<Handle<Object>>* code_list, | 489 virtual bool FindHandlers(List<Handle<Object>>* code_list, |
490 int length = -1) const; | 490 int length = -1) const; |
491 virtual Name* FindFirstName() const { return NULL; } | 491 virtual Name* FindFirstName() const { return NULL; } |
492 | 492 |
493 bool IsCleared() { | 493 bool IsCleared() { |
494 InlineCacheState state = StateFromFeedback(); | 494 InlineCacheState state = StateFromFeedback(); |
495 return !FLAG_use_ic || state == UNINITIALIZED || state == PREMONOMORPHIC; | 495 return !FLAG_use_ic || state == UNINITIALIZED || state == PREMONOMORPHIC; |
496 } | 496 } |
497 | 497 |
498 virtual void Clear() { ConfigureUninitialized(); } | 498 virtual void Clear() { ConfigureUninitialized(); } |
499 virtual void ConfigureUninitialized(); | 499 virtual void ConfigureUninitialized(); |
500 void ConfigurePremonomorphic(); | 500 void ConfigurePremonomorphic(); |
501 void ConfigureMegamorphic(IcCheckType property_type); | 501 void ConfigureMegamorphic(IcCheckType property_type); |
502 | 502 |
503 inline Object* GetFeedback() const; | 503 inline Object* GetFeedback() const; |
504 inline Object* GetFeedbackExtra() const; | 504 inline Object* GetFeedbackExtra() const; |
505 | 505 |
506 inline Isolate* GetIsolate() const; | 506 inline Isolate* GetIsolate() const; |
507 | 507 |
508 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, | 508 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map, |
509 Handle<Object> handler); | 509 Handle<Object> handler); |
510 | 510 |
511 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 511 void ConfigurePolymorphic(Handle<Name> name, MapHandles const& maps, |
512 List<Handle<Object>>* handlers); | 512 List<Handle<Object>>* handlers); |
513 | 513 |
514 protected: | 514 protected: |
515 inline void SetFeedback(Object* feedback, | 515 inline void SetFeedback(Object* feedback, |
516 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 516 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
517 inline void SetFeedbackExtra(Object* feedback_extra, | 517 inline void SetFeedbackExtra(Object* feedback_extra, |
518 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 518 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
519 | 519 |
520 Handle<FixedArray> EnsureArrayOfSize(int length); | 520 Handle<FixedArray> EnsureArrayOfSize(int length); |
521 Handle<FixedArray> EnsureExtraArrayOfSize(int length); | 521 Handle<FixedArray> EnsureExtraArrayOfSize(int length); |
(...skipping 16 matching lines...) Expand all Loading... |
538 } | 538 } |
539 CallICNexus(FeedbackVector* vector, FeedbackSlot slot) | 539 CallICNexus(FeedbackVector* vector, FeedbackSlot slot) |
540 : FeedbackNexus(vector, slot) { | 540 : FeedbackNexus(vector, slot) { |
541 DCHECK(vector->IsCallIC(slot)); | 541 DCHECK(vector->IsCallIC(slot)); |
542 } | 542 } |
543 | 543 |
544 void ConfigureUninitialized() final; | 544 void ConfigureUninitialized() final; |
545 | 545 |
546 InlineCacheState StateFromFeedback() const final; | 546 InlineCacheState StateFromFeedback() const final; |
547 | 547 |
548 int ExtractMaps(MapHandleList* maps) const final { | 548 int ExtractMaps(MapHandles* maps) const final { |
549 // CallICs don't record map feedback. | 549 // CallICs don't record map feedback. |
550 return 0; | 550 return 0; |
551 } | 551 } |
552 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { | 552 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
553 return MaybeHandle<Code>(); | 553 return MaybeHandle<Code>(); |
554 } | 554 } |
555 bool FindHandlers(List<Handle<Object>>* code_list, | 555 bool FindHandlers(List<Handle<Object>>* code_list, |
556 int length = -1) const final { | 556 int length = -1) const final { |
557 return length == 0; | 557 return length == 0; |
558 } | 558 } |
(...skipping 25 matching lines...) Expand all Loading... |
584 public: | 584 public: |
585 LoadGlobalICNexus(Handle<FeedbackVector> vector, FeedbackSlot slot) | 585 LoadGlobalICNexus(Handle<FeedbackVector> vector, FeedbackSlot slot) |
586 : FeedbackNexus(vector, slot) { | 586 : FeedbackNexus(vector, slot) { |
587 DCHECK(vector->IsLoadGlobalIC(slot)); | 587 DCHECK(vector->IsLoadGlobalIC(slot)); |
588 } | 588 } |
589 LoadGlobalICNexus(FeedbackVector* vector, FeedbackSlot slot) | 589 LoadGlobalICNexus(FeedbackVector* vector, FeedbackSlot slot) |
590 : FeedbackNexus(vector, slot) { | 590 : FeedbackNexus(vector, slot) { |
591 DCHECK(vector->IsLoadGlobalIC(slot)); | 591 DCHECK(vector->IsLoadGlobalIC(slot)); |
592 } | 592 } |
593 | 593 |
594 int ExtractMaps(MapHandleList* maps) const final { | 594 int ExtractMaps(MapHandles* maps) const final { |
595 // LoadGlobalICs don't record map feedback. | 595 // LoadGlobalICs don't record map feedback. |
596 return 0; | 596 return 0; |
597 } | 597 } |
598 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { | 598 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
599 return MaybeHandle<Code>(); | 599 return MaybeHandle<Code>(); |
600 } | 600 } |
601 bool FindHandlers(List<Handle<Object>>* code_list, | 601 bool FindHandlers(List<Handle<Object>>* code_list, |
602 int length = -1) const final { | 602 int length = -1) const final { |
603 return length == 0; | 603 return length == 0; |
604 } | 604 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, vector->GetKind(slot)); | 677 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, vector->GetKind(slot)); |
678 } | 678 } |
679 BinaryOpICNexus(FeedbackVector* vector, FeedbackSlot slot) | 679 BinaryOpICNexus(FeedbackVector* vector, FeedbackSlot slot) |
680 : FeedbackNexus(vector, slot) { | 680 : FeedbackNexus(vector, slot) { |
681 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, vector->GetKind(slot)); | 681 DCHECK_EQ(FeedbackSlotKind::kBinaryOp, vector->GetKind(slot)); |
682 } | 682 } |
683 | 683 |
684 InlineCacheState StateFromFeedback() const final; | 684 InlineCacheState StateFromFeedback() const final; |
685 BinaryOperationHint GetBinaryOperationFeedback() const; | 685 BinaryOperationHint GetBinaryOperationFeedback() const; |
686 | 686 |
687 int ExtractMaps(MapHandleList* maps) const final { | 687 int ExtractMaps(MapHandles* maps) const final { |
688 // BinaryOpICs don't record map feedback. | 688 // BinaryOpICs don't record map feedback. |
689 return 0; | 689 return 0; |
690 } | 690 } |
691 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { | 691 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
692 return MaybeHandle<Code>(); | 692 return MaybeHandle<Code>(); |
693 } | 693 } |
694 bool FindHandlers(List<Handle<Object>>* code_list, | 694 bool FindHandlers(List<Handle<Object>>* code_list, |
695 int length = -1) const final { | 695 int length = -1) const final { |
696 return length == 0; | 696 return length == 0; |
697 } | 697 } |
698 }; | 698 }; |
699 | 699 |
700 class CompareICNexus final : public FeedbackNexus { | 700 class CompareICNexus final : public FeedbackNexus { |
701 public: | 701 public: |
702 CompareICNexus(Handle<FeedbackVector> vector, FeedbackSlot slot) | 702 CompareICNexus(Handle<FeedbackVector> vector, FeedbackSlot slot) |
703 : FeedbackNexus(vector, slot) { | 703 : FeedbackNexus(vector, slot) { |
704 DCHECK_EQ(FeedbackSlotKind::kCompareOp, vector->GetKind(slot)); | 704 DCHECK_EQ(FeedbackSlotKind::kCompareOp, vector->GetKind(slot)); |
705 } | 705 } |
706 CompareICNexus(FeedbackVector* vector, FeedbackSlot slot) | 706 CompareICNexus(FeedbackVector* vector, FeedbackSlot slot) |
707 : FeedbackNexus(vector, slot) { | 707 : FeedbackNexus(vector, slot) { |
708 DCHECK_EQ(FeedbackSlotKind::kCompareOp, vector->GetKind(slot)); | 708 DCHECK_EQ(FeedbackSlotKind::kCompareOp, vector->GetKind(slot)); |
709 } | 709 } |
710 | 710 |
711 InlineCacheState StateFromFeedback() const final; | 711 InlineCacheState StateFromFeedback() const final; |
712 CompareOperationHint GetCompareOperationFeedback() const; | 712 CompareOperationHint GetCompareOperationFeedback() const; |
713 | 713 |
714 int ExtractMaps(MapHandleList* maps) const final { | 714 int ExtractMaps(MapHandles* maps) const final { |
715 // BinaryOpICs don't record map feedback. | 715 // BinaryOpICs don't record map feedback. |
716 return 0; | 716 return 0; |
717 } | 717 } |
718 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { | 718 MaybeHandle<Object> FindHandlerForMap(Handle<Map> map) const final { |
719 return MaybeHandle<Code>(); | 719 return MaybeHandle<Code>(); |
720 } | 720 } |
721 bool FindHandlers(List<Handle<Object>>* code_list, | 721 bool FindHandlers(List<Handle<Object>>* code_list, |
722 int length = -1) const final { | 722 int length = -1) const final { |
723 return length == 0; | 723 return length == 0; |
724 } | 724 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 InlineCacheState StateFromFeedback() const override; | 763 InlineCacheState StateFromFeedback() const override; |
764 }; | 764 }; |
765 | 765 |
766 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); | 766 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); |
767 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); | 767 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); |
768 | 768 |
769 } // namespace internal | 769 } // namespace internal |
770 } // namespace v8 | 770 } // namespace v8 |
771 | 771 |
772 #endif // V8_FEEDBACK_VECTOR_H_ | 772 #endif // V8_FEEDBACK_VECTOR_H_ |
OLD | NEW |