Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: src/objects.h

Issue 2170743003: [api] Introduce fast instantiations cache (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fixing uint issue under windows Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/object-stats.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 760
761 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); 761 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType);
762 STATIC_ASSERT(JS_API_OBJECT_TYPE == Internals::kJSApiObjectType); 762 STATIC_ASSERT(JS_API_OBJECT_TYPE == Internals::kJSApiObjectType);
763 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); 763 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
764 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); 764 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType);
765 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); 765 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType);
766 766
767 767
768 std::ostream& operator<<(std::ostream& os, InstanceType instance_type); 768 std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
769 769
770 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ 770 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \
771 V(CODE_STUBS_TABLE_SUB_TYPE) \ 771 V(CODE_STUBS_TABLE_SUB_TYPE) \
772 V(CONTEXT_SUB_TYPE) \ 772 V(CONTEXT_SUB_TYPE) \
773 V(COPY_ON_WRITE_SUB_TYPE) \ 773 V(COPY_ON_WRITE_SUB_TYPE) \
774 V(DEOPTIMIZATION_DATA_SUB_TYPE) \ 774 V(DEOPTIMIZATION_DATA_SUB_TYPE) \
775 V(DESCRIPTOR_ARRAY_SUB_TYPE) \ 775 V(DESCRIPTOR_ARRAY_SUB_TYPE) \
776 V(EMBEDDED_OBJECT_SUB_TYPE) \ 776 V(EMBEDDED_OBJECT_SUB_TYPE) \
777 V(ENUM_CACHE_SUB_TYPE) \ 777 V(ENUM_CACHE_SUB_TYPE) \
778 V(ENUM_INDICES_CACHE_SUB_TYPE) \ 778 V(ENUM_INDICES_CACHE_SUB_TYPE) \
779 V(DEPENDENT_CODE_SUB_TYPE) \ 779 V(DEPENDENT_CODE_SUB_TYPE) \
780 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ 780 V(DICTIONARY_ELEMENTS_SUB_TYPE) \
781 V(DICTIONARY_PROPERTIES_SUB_TYPE) \ 781 V(DICTIONARY_PROPERTIES_SUB_TYPE) \
782 V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \ 782 V(EMPTY_PROPERTIES_DICTIONARY_SUB_TYPE) \
783 V(FAST_ELEMENTS_SUB_TYPE) \ 783 V(FAST_ELEMENTS_SUB_TYPE) \
784 V(FAST_PROPERTIES_SUB_TYPE) \ 784 V(FAST_PROPERTIES_SUB_TYPE) \
785 V(HANDLER_TABLE_SUB_TYPE) \ 785 V(FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
786 V(INTRINSIC_FUNCTION_NAMES_SUB_TYPE) \ 786 V(HANDLER_TABLE_SUB_TYPE) \
787 V(JS_COLLECTION_SUB_TYPE) \ 787 V(INTRINSIC_FUNCTION_NAMES_SUB_TYPE) \
788 V(JS_WEAK_COLLECTION_SUB_TYPE) \ 788 V(JS_COLLECTION_SUB_TYPE) \
789 V(LITERALS_ARRAY_SUB_TYPE) \ 789 V(JS_WEAK_COLLECTION_SUB_TYPE) \
790 V(MAP_CODE_CACHE_SUB_TYPE) \ 790 V(LITERALS_ARRAY_SUB_TYPE) \
791 V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \ 791 V(MAP_CODE_CACHE_SUB_TYPE) \
792 V(NUMBER_STRING_CACHE_SUB_TYPE) \ 792 V(NOSCRIPT_SHARED_FUNCTION_INFOS_SUB_TYPE) \
793 V(OBJECT_TO_CODE_SUB_TYPE) \ 793 V(NUMBER_STRING_CACHE_SUB_TYPE) \
794 V(OPTIMIZED_CODE_MAP_SUB_TYPE) \ 794 V(OBJECT_TO_CODE_SUB_TYPE) \
795 V(PROTOTYPE_USERS_SUB_TYPE) \ 795 V(OPTIMIZED_CODE_MAP_SUB_TYPE) \
796 V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \ 796 V(PROTOTYPE_USERS_SUB_TYPE) \
797 V(RETAINED_MAPS_SUB_TYPE) \ 797 V(REGEXP_MULTIPLE_CACHE_SUB_TYPE) \
798 V(SCOPE_INFO_SUB_TYPE) \ 798 V(RETAINED_MAPS_SUB_TYPE) \
799 V(SCRIPT_LIST_SUB_TYPE) \ 799 V(SCOPE_INFO_SUB_TYPE) \
800 V(SERIALIZED_TEMPLATES_SUB_TYPE) \ 800 V(SCRIPT_LIST_SUB_TYPE) \
801 V(SHARED_FUNCTION_INFOS_SUB_TYPE) \ 801 V(SERIALIZED_TEMPLATES_SUB_TYPE) \
802 V(SINGLE_CHARACTER_STRING_CACHE_SUB_TYPE) \ 802 V(SHARED_FUNCTION_INFOS_SUB_TYPE) \
803 V(STRING_SPLIT_CACHE_SUB_TYPE) \ 803 V(SINGLE_CHARACTER_STRING_CACHE_SUB_TYPE) \
804 V(STRING_TABLE_SUB_TYPE) \ 804 V(SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \
805 V(TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE) \ 805 V(STRING_SPLIT_CACHE_SUB_TYPE) \
806 V(TYPE_FEEDBACK_VECTOR_SUB_TYPE) \ 806 V(STRING_TABLE_SUB_TYPE) \
807 V(TYPE_FEEDBACK_METADATA_SUB_TYPE) \ 807 V(TYPE_FEEDBACK_VECTOR_SUB_TYPE) \
808 V(TYPE_FEEDBACK_METADATA_SUB_TYPE) \
808 V(WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE) 809 V(WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE)
809 810
810 enum FixedArraySubInstanceType { 811 enum FixedArraySubInstanceType {
811 #define DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE(name) name, 812 #define DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE(name) name,
812 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE) 813 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE)
813 #undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE 814 #undef DEFINE_FIXED_ARRAY_SUB_INSTANCE_TYPE
814 LAST_FIXED_ARRAY_SUB_TYPE = WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE 815 LAST_FIXED_ARRAY_SUB_TYPE = WEAK_NEW_SPACE_OBJECT_TO_CODE_SUB_TYPE
815 }; 816 };
816 817
817 818
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after
2664 2665
2665 2666
2666 // FixedArray describes fixed-sized arrays with element type Object*. 2667 // FixedArray describes fixed-sized arrays with element type Object*.
2667 class FixedArray: public FixedArrayBase { 2668 class FixedArray: public FixedArrayBase {
2668 public: 2669 public:
2669 // Setter and getter for elements. 2670 // Setter and getter for elements.
2670 inline Object* get(int index) const; 2671 inline Object* get(int index) const;
2671 static inline Handle<Object> get(FixedArray* array, int index, 2672 static inline Handle<Object> get(FixedArray* array, int index,
2672 Isolate* isolate); 2673 Isolate* isolate);
2673 template <class T> 2674 template <class T>
2674 MaybeHandle<T> GetValue(int index) const; 2675 MaybeHandle<T> GetValue(Isolate* isolate, int index) const;
2675 2676
2676 template <class T> 2677 template <class T>
2677 Handle<T> GetValueChecked(int index) const; 2678 Handle<T> GetValueChecked(Isolate* isolate, int index) const;
Mircea Trofin 2016/08/01 23:40:02 Why was it necessary to pass the isolate explicitl
Camillo Bruni 2016/08/02 07:27:54 The calls to GetValueChecked happen in loops and d
2679
2680 // Return a grown copy if the index is bigger than the array's length.
2681 static Handle<FixedArray> SetAndGrow(Handle<FixedArray> array, int index,
2682 Handle<Object> value);
2678 2683
2679 // Setter that uses write barrier. 2684 // Setter that uses write barrier.
2680 inline void set(int index, Object* value); 2685 inline void set(int index, Object* value);
2681 inline bool is_the_hole(int index); 2686 inline bool is_the_hole(int index);
2682 2687
2683 // Setter that doesn't need write barrier. 2688 // Setter that doesn't need write barrier.
2684 inline void set(int index, Smi* value); 2689 inline void set(int index, Smi* value);
2685 // Setter with explicit barrier mode. 2690 // Setter with explicit barrier mode.
2686 inline void set(int index, Object* value, WriteBarrierMode mode); 2691 inline void set(int index, Object* value, WriteBarrierMode mode);
2687 2692
(...skipping 2164 matching lines...) Expand 10 before | Expand all | Expand 10 after
4852 inline TypeFeedbackVector* feedback_vector() const; 4857 inline TypeFeedbackVector* feedback_vector() const;
4853 inline void set_feedback_vector(TypeFeedbackVector* vector); 4858 inline void set_feedback_vector(TypeFeedbackVector* vector);
4854 inline Object* literal(int literal_index) const; 4859 inline Object* literal(int literal_index) const;
4855 inline void set_literal(int literal_index, Object* literal); 4860 inline void set_literal(int literal_index, Object* literal);
4856 inline void set_literal_undefined(int literal_index); 4861 inline void set_literal_undefined(int literal_index);
4857 inline int literals_count() const; 4862 inline int literals_count() const;
4858 4863
4859 static Handle<LiteralsArray> New(Isolate* isolate, 4864 static Handle<LiteralsArray> New(Isolate* isolate,
4860 Handle<TypeFeedbackVector> vector, 4865 Handle<TypeFeedbackVector> vector,
4861 int number_of_literals, 4866 int number_of_literals,
4862 PretenureFlag pretenure); 4867 PretenureFlag pretenure = TENURED);
4863 4868
4864 DECLARE_CAST(LiteralsArray) 4869 DECLARE_CAST(LiteralsArray)
4865 4870
4866 private: 4871 private:
4867 inline Object* get(int index) const; 4872 inline Object* get(int index) const;
4868 inline void set(int index, Object* value); 4873 inline void set(int index, Object* value);
4869 inline void set(int index, Smi* value); 4874 inline void set(int index, Smi* value);
4870 inline void set(int index, Object* value, WriteBarrierMode mode); 4875 inline void set(int index, Object* value, WriteBarrierMode mode);
4871 }; 4876 };
4872 4877
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after
7728 inline void CompleteInobjectSlackTrackingIfActive(); 7733 inline void CompleteInobjectSlackTrackingIfActive();
7729 7734
7730 // [literals]: Fixed array holding the materialized literals. 7735 // [literals]: Fixed array holding the materialized literals.
7731 // 7736 //
7732 // If the function contains object, regexp or array literals, the 7737 // If the function contains object, regexp or array literals, the
7733 // literals array prefix contains the object, regexp, and array 7738 // literals array prefix contains the object, regexp, and array
7734 // function to be used when creating these literals. This is 7739 // function to be used when creating these literals. This is
7735 // necessary so that we do not dynamically lookup the object, regexp 7740 // necessary so that we do not dynamically lookup the object, regexp
7736 // or array functions. Performing a dynamic lookup, we might end up 7741 // or array functions. Performing a dynamic lookup, we might end up
7737 // using the functions from a new context that we should not have 7742 // using the functions from a new context that we should not have
7738 // access to. 7743 // access to. For API objects we store the boilerplate in the literal array.
7739 DECL_ACCESSORS(literals, LiteralsArray) 7744 DECL_ACCESSORS(literals, LiteralsArray)
7740 7745
7741 static void EnsureLiterals(Handle<JSFunction> function); 7746 static void EnsureLiterals(Handle<JSFunction> function);
7742 inline TypeFeedbackVector* feedback_vector(); 7747 inline TypeFeedbackVector* feedback_vector();
7743 7748
7744 // Unconditionally clear the type feedback vector (including vector ICs). 7749 // Unconditionally clear the type feedback vector (including vector ICs).
7745 void ClearTypeFeedbackInfo(); 7750 void ClearTypeFeedbackInfo();
7746 7751
7747 // Clear the type feedback vector with a more subtle policy at GC time. 7752 // Clear the type feedback vector with a more subtle policy at GC time.
7748 void ClearTypeFeedbackInfoAtGCTime(); 7753 void ClearTypeFeedbackInfoAtGCTime();
(...skipping 2935 matching lines...) Expand 10 before | Expand all | Expand 10 after
10684 static const int kTagOffset = HeapObject::kHeaderSize; 10689 static const int kTagOffset = HeapObject::kHeaderSize;
10685 static const int kSerialNumberOffset = kTagOffset + kPointerSize; 10690 static const int kSerialNumberOffset = kTagOffset + kPointerSize;
10686 static const int kNumberOfProperties = kSerialNumberOffset + kPointerSize; 10691 static const int kNumberOfProperties = kSerialNumberOffset + kPointerSize;
10687 static const int kPropertyListOffset = kNumberOfProperties + kPointerSize; 10692 static const int kPropertyListOffset = kNumberOfProperties + kPointerSize;
10688 static const int kPropertyAccessorsOffset = 10693 static const int kPropertyAccessorsOffset =
10689 kPropertyListOffset + kPointerSize; 10694 kPropertyListOffset + kPointerSize;
10690 static const int kPropertyIntrinsicsOffset = 10695 static const int kPropertyIntrinsicsOffset =
10691 kPropertyAccessorsOffset + kPointerSize; 10696 kPropertyAccessorsOffset + kPointerSize;
10692 static const int kHeaderSize = kPropertyIntrinsicsOffset + kPointerSize; 10697 static const int kHeaderSize = kPropertyIntrinsicsOffset + kPointerSize;
10693 10698
10699 static const int kFastTemplateInstantiationsCacheSize = 1 * KB;
10700
10694 private: 10701 private:
10695 DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo); 10702 DISALLOW_IMPLICIT_CONSTRUCTORS(TemplateInfo);
10696 }; 10703 };
10697 10704
10698 10705
10699 class FunctionTemplateInfo: public TemplateInfo { 10706 class FunctionTemplateInfo: public TemplateInfo {
10700 public: 10707 public:
10701 DECL_ACCESSORS(call_code, Object) 10708 DECL_ACCESSORS(call_code, Object)
10702 DECL_ACCESSORS(prototype_template, Object) 10709 DECL_ACCESSORS(prototype_template, Object)
10703 DECL_ACCESSORS(parent_template, Object) 10710 DECL_ACCESSORS(parent_template, Object)
10704 DECL_ACCESSORS(named_property_handler, Object) 10711 DECL_ACCESSORS(named_property_handler, Object)
10705 DECL_ACCESSORS(indexed_property_handler, Object) 10712 DECL_ACCESSORS(indexed_property_handler, Object)
10706 DECL_ACCESSORS(instance_template, Object) 10713 DECL_ACCESSORS(instance_template, Object)
10707 DECL_ACCESSORS(class_name, Object) 10714 DECL_ACCESSORS(class_name, Object)
10708 DECL_ACCESSORS(signature, Object) 10715 DECL_ACCESSORS(signature, Object)
10709 DECL_ACCESSORS(instance_call_handler, Object) 10716 DECL_ACCESSORS(instance_call_handler, Object)
10710 DECL_ACCESSORS(access_check_info, Object) 10717 DECL_ACCESSORS(access_check_info, Object)
10711 DECL_ACCESSORS(shared_function_info, Object) 10718 DECL_ACCESSORS(shared_function_info, Object)
10719 DECL_ACCESSORS(js_function, Object)
10712 DECL_INT_ACCESSORS(flag) 10720 DECL_INT_ACCESSORS(flag)
10713 10721
10714 inline int length() const; 10722 inline int length() const;
10715 inline void set_length(int value); 10723 inline void set_length(int value);
10716 10724
10717 // Following properties use flag bits. 10725 // Following properties use flag bits.
10718 DECL_BOOLEAN_ACCESSORS(hidden_prototype) 10726 DECL_BOOLEAN_ACCESSORS(hidden_prototype)
10719 DECL_BOOLEAN_ACCESSORS(undetectable) 10727 DECL_BOOLEAN_ACCESSORS(undetectable)
10720 // If the bit is set, object instances created by this function 10728 // If the bit is set, object instances created by this function
10721 // requires access check. 10729 // requires access check.
(...skipping 26 matching lines...) Expand all
10748 static const int kAccessCheckInfoOffset = 10756 static const int kAccessCheckInfoOffset =
10749 kInstanceCallHandlerOffset + kPointerSize; 10757 kInstanceCallHandlerOffset + kPointerSize;
10750 static const int kSharedFunctionInfoOffset = 10758 static const int kSharedFunctionInfoOffset =
10751 kAccessCheckInfoOffset + kPointerSize; 10759 kAccessCheckInfoOffset + kPointerSize;
10752 static const int kFlagOffset = kSharedFunctionInfoOffset + kPointerSize; 10760 static const int kFlagOffset = kSharedFunctionInfoOffset + kPointerSize;
10753 static const int kLengthOffset = kFlagOffset + kPointerSize; 10761 static const int kLengthOffset = kFlagOffset + kPointerSize;
10754 static const int kSize = kLengthOffset + kPointerSize; 10762 static const int kSize = kLengthOffset + kPointerSize;
10755 10763
10756 static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo( 10764 static Handle<SharedFunctionInfo> GetOrCreateSharedFunctionInfo(
10757 Isolate* isolate, Handle<FunctionTemplateInfo> info); 10765 Isolate* isolate, Handle<FunctionTemplateInfo> info);
10766 // Returns parent function template or null.
10767 inline FunctionTemplateInfo* GetParent(Isolate* isolate);
10758 // Returns true if |object| is an instance of this function template. 10768 // Returns true if |object| is an instance of this function template.
10759 inline bool IsTemplateFor(JSObject* object); 10769 inline bool IsTemplateFor(JSObject* object);
10760 bool IsTemplateFor(Map* map); 10770 bool IsTemplateFor(Map* map);
10761 inline bool instantiated(); 10771 inline bool instantiated();
10762 10772
10763 private: 10773 private:
10764 // Bit position in the flag, from least significant bit position. 10774 // Bit position in the flag, from least significant bit position.
10765 static const int kHiddenPrototypeBit = 0; 10775 static const int kHiddenPrototypeBit = 0;
10766 static const int kUndetectableBit = 1; 10776 static const int kUndetectableBit = 1;
10767 static const int kNeedsAccessCheckBit = 2; 10777 static const int kNeedsAccessCheckBit = 2;
(...skipping 17 matching lines...) Expand all
10785 10795
10786 // Dispatched behavior. 10796 // Dispatched behavior.
10787 DECLARE_PRINTER(ObjectTemplateInfo) 10797 DECLARE_PRINTER(ObjectTemplateInfo)
10788 DECLARE_VERIFIER(ObjectTemplateInfo) 10798 DECLARE_VERIFIER(ObjectTemplateInfo)
10789 10799
10790 static const int kConstructorOffset = TemplateInfo::kHeaderSize; 10800 static const int kConstructorOffset = TemplateInfo::kHeaderSize;
10791 // LSB is for immutable_proto, higher bits for internal_field_count 10801 // LSB is for immutable_proto, higher bits for internal_field_count
10792 static const int kDataOffset = kConstructorOffset + kPointerSize; 10802 static const int kDataOffset = kConstructorOffset + kPointerSize;
10793 static const int kSize = kDataOffset + kPointerSize; 10803 static const int kSize = kDataOffset + kPointerSize;
10794 10804
10805 // Starting from given object template's constructor walk up the inheritance
10806 // chain till a function template that has an instance template is found.
10807 inline ObjectTemplateInfo* GetParent(Isolate* isolate);
10808
10795 private: 10809 private:
10796 class IsImmutablePrototype : public BitField<bool, 0, 1> {}; 10810 class IsImmutablePrototype : public BitField<bool, 0, 1> {};
10797 class InternalFieldCount 10811 class InternalFieldCount
10798 : public BitField<int, IsImmutablePrototype::kNext, 29> {}; 10812 : public BitField<int, IsImmutablePrototype::kNext, 29> {};
10799 }; 10813 };
10800 10814
10801 10815
10802 // The DebugInfo class holds additional information for a function being 10816 // The DebugInfo class holds additional information for a function being
10803 // debugged. 10817 // debugged.
10804 class DebugInfo: public Struct { 10818 class DebugInfo: public Struct {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
11021 } 11035 }
11022 return value; 11036 return value;
11023 } 11037 }
11024 }; 11038 };
11025 11039
11026 11040
11027 } // NOLINT, false-positive due to second-order macros. 11041 } // NOLINT, false-positive due to second-order macros.
11028 } // NOLINT, false-positive due to second-order macros. 11042 } // NOLINT, false-positive due to second-order macros.
11029 11043
11030 #endif // V8_OBJECTS_H_ 11044 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/object-stats.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698