| OLD | NEW |
| 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 | 9 |
| 10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 class LookupIterator; | 849 class LookupIterator; |
| 850 class FieldType; | 850 class FieldType; |
| 851 class ObjectHashTable; | 851 class ObjectHashTable; |
| 852 class ObjectVisitor; | 852 class ObjectVisitor; |
| 853 class PropertyCell; | 853 class PropertyCell; |
| 854 class PropertyDescriptor; | 854 class PropertyDescriptor; |
| 855 class SafepointEntry; | 855 class SafepointEntry; |
| 856 class SharedFunctionInfo; | 856 class SharedFunctionInfo; |
| 857 class StringStream; | 857 class StringStream; |
| 858 class TypeFeedbackInfo; | 858 class TypeFeedbackInfo; |
| 859 class TypeFeedbackMetadata; |
| 859 class TypeFeedbackVector; | 860 class TypeFeedbackVector; |
| 860 class WeakCell; | 861 class WeakCell; |
| 861 class TransitionArray; | 862 class TransitionArray; |
| 862 | 863 |
| 863 | 864 |
| 864 // A template-ized version of the IsXXX functions. | 865 // A template-ized version of the IsXXX functions. |
| 865 template <class C> inline bool Is(Object* obj); | 866 template <class C> inline bool Is(Object* obj); |
| 866 | 867 |
| 867 #ifdef VERIFY_HEAP | 868 #ifdef VERIFY_HEAP |
| 868 #define DECLARE_VERIFIER(Name) void Name##Verify(); | 869 #define DECLARE_VERIFIER(Name) void Name##Verify(); |
| (...skipping 3863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4732 #endif | 4733 #endif |
| 4733 }; | 4734 }; |
| 4734 | 4735 |
| 4735 | 4736 |
| 4736 // A literals array contains the literals for a JSFunction. It also holds | 4737 // A literals array contains the literals for a JSFunction. It also holds |
| 4737 // the type feedback vector. | 4738 // the type feedback vector. |
| 4738 class LiteralsArray : public FixedArray { | 4739 class LiteralsArray : public FixedArray { |
| 4739 public: | 4740 public: |
| 4740 static const int kVectorIndex = 0; | 4741 static const int kVectorIndex = 0; |
| 4741 static const int kFirstLiteralIndex = 1; | 4742 static const int kFirstLiteralIndex = 1; |
| 4742 static const int kOffsetToFirstLiteral = | 4743 static const int kFeedbackVectorOffset; |
| 4743 FixedArray::kHeaderSize + kPointerSize; | 4744 static const int kOffsetToFirstLiteral; |
| 4744 | 4745 |
| 4745 static int OffsetOfLiteralAt(int index) { | 4746 static int OffsetOfLiteralAt(int index) { |
| 4746 return SizeFor(index + kFirstLiteralIndex); | 4747 return OffsetOfElementAt(index + kFirstLiteralIndex); |
| 4747 } | 4748 } |
| 4748 | 4749 |
| 4749 inline TypeFeedbackVector* feedback_vector() const; | 4750 inline TypeFeedbackVector* feedback_vector() const; |
| 4750 inline void set_feedback_vector(TypeFeedbackVector* vector); | 4751 inline void set_feedback_vector(TypeFeedbackVector* vector); |
| 4751 inline Object* literal(int literal_index) const; | 4752 inline Object* literal(int literal_index) const; |
| 4752 inline void set_literal(int literal_index, Object* literal); | 4753 inline void set_literal(int literal_index, Object* literal); |
| 4754 inline void set_literal_undefined(int literal_index); |
| 4753 inline int literals_count() const; | 4755 inline int literals_count() const; |
| 4754 | 4756 |
| 4755 static Handle<LiteralsArray> New(Isolate* isolate, | 4757 static Handle<LiteralsArray> New(Isolate* isolate, |
| 4756 Handle<TypeFeedbackVector> vector, | 4758 Handle<TypeFeedbackVector> vector, |
| 4757 int number_of_literals, | 4759 int number_of_literals, |
| 4758 PretenureFlag pretenure); | 4760 PretenureFlag pretenure); |
| 4759 | 4761 |
| 4760 DECLARE_CAST(LiteralsArray) | 4762 DECLARE_CAST(LiteralsArray) |
| 4761 | 4763 |
| 4762 private: | 4764 private: |
| (...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6611 // Returns entry from optimized code map for specified context and OSR entry. | 6613 // Returns entry from optimized code map for specified context and OSR entry. |
| 6612 // Note that {code == nullptr, literals == nullptr} indicates no matching | 6614 // Note that {code == nullptr, literals == nullptr} indicates no matching |
| 6613 // entry has been found, whereas {code, literals == nullptr} indicates that | 6615 // entry has been found, whereas {code, literals == nullptr} indicates that |
| 6614 // code is context-independent. | 6616 // code is context-independent. |
| 6615 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, | 6617 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, |
| 6616 BailoutId osr_ast_id); | 6618 BailoutId osr_ast_id); |
| 6617 | 6619 |
| 6618 // Clear optimized code map. | 6620 // Clear optimized code map. |
| 6619 void ClearOptimizedCodeMap(); | 6621 void ClearOptimizedCodeMap(); |
| 6620 | 6622 |
| 6623 // Like ClearOptimizedCodeMap, but preserves literals. |
| 6624 void ClearCodeFromOptimizedCodeMap(); |
| 6625 |
| 6621 // We have a special root FixedArray with the right shape and values | 6626 // We have a special root FixedArray with the right shape and values |
| 6622 // to represent the cleared optimized code map. This predicate checks | 6627 // to represent the cleared optimized code map. This predicate checks |
| 6623 // if that root is installed. | 6628 // if that root is installed. |
| 6624 inline bool OptimizedCodeMapIsCleared() const; | 6629 inline bool OptimizedCodeMapIsCleared() const; |
| 6625 | 6630 |
| 6626 // Removes a specific optimized code object from the optimized code map. | 6631 // Removes a specific optimized code object from the optimized code map. |
| 6627 // In case of non-OSR the code reference is cleared from the cache entry but | 6632 // In case of non-OSR the code reference is cleared from the cache entry but |
| 6628 // the entry itself is left in the map in order to proceed sharing literals. | 6633 // the entry itself is left in the map in order to proceed sharing literals. |
| 6629 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); | 6634 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); |
| 6630 | 6635 |
| 6631 // Trims the optimized code map after entries have been removed. | 6636 // Trims the optimized code map after entries have been removed. |
| 6632 void TrimOptimizedCodeMap(int shrink_by); | 6637 void TrimOptimizedCodeMap(int shrink_by); |
| 6633 | 6638 |
| 6639 static Handle<LiteralsArray> FindOrCreateLiterals( |
| 6640 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); |
| 6641 |
| 6634 // Add or update entry in the optimized code map for context-independent code. | 6642 // Add or update entry in the optimized code map for context-independent code. |
| 6635 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6643 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
| 6636 Handle<Code> code); | 6644 Handle<Code> code); |
| 6637 | 6645 |
| 6638 // Add or update entry in the optimized code map for context-dependent code. | 6646 // Add or update entry in the optimized code map for context-dependent code. |
| 6639 // If {code} is not given, then an existing entry's code won't be overwritten. | 6647 // If {code} is not given, then an existing entry's code won't be overwritten. |
| 6640 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6648 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
| 6641 Handle<Context> native_context, | 6649 Handle<Context> native_context, |
| 6642 MaybeHandle<Code> code, | 6650 MaybeHandle<Code> code, |
| 6643 Handle<LiteralsArray> literals, | 6651 Handle<LiteralsArray> literals, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6693 inline void set_internal_formal_parameter_count(int value); | 6701 inline void set_internal_formal_parameter_count(int value); |
| 6694 | 6702 |
| 6695 // Set the formal parameter count so the function code will be | 6703 // Set the formal parameter count so the function code will be |
| 6696 // called without using argument adaptor frames. | 6704 // called without using argument adaptor frames. |
| 6697 inline void DontAdaptArguments(); | 6705 inline void DontAdaptArguments(); |
| 6698 | 6706 |
| 6699 // [expected_nof_properties]: Expected number of properties for the function. | 6707 // [expected_nof_properties]: Expected number of properties for the function. |
| 6700 inline int expected_nof_properties() const; | 6708 inline int expected_nof_properties() const; |
| 6701 inline void set_expected_nof_properties(int value); | 6709 inline void set_expected_nof_properties(int value); |
| 6702 | 6710 |
| 6703 // [feedback_vector] - accumulates ast node feedback from full-codegen and | 6711 // [feedback_metadata] - describes ast node feedback from full-codegen and |
| 6704 // (increasingly) from crankshafted code where sufficient feedback isn't | 6712 // (increasingly) from crankshafted code where sufficient feedback isn't |
| 6705 // available. | 6713 // available. |
| 6706 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector) | 6714 DECL_ACCESSORS(feedback_metadata, TypeFeedbackMetadata) |
| 6707 | |
| 6708 // Unconditionally clear the type feedback vector (including vector ICs). | |
| 6709 void ClearTypeFeedbackInfo(); | |
| 6710 | |
| 6711 // Clear the type feedback vector with a more subtle policy at GC time. | |
| 6712 void ClearTypeFeedbackInfoAtGCTime(); | |
| 6713 | 6715 |
| 6714 #if TRACE_MAPS | 6716 #if TRACE_MAPS |
| 6715 // [unique_id] - For --trace-maps purposes, an identifier that's persistent | 6717 // [unique_id] - For --trace-maps purposes, an identifier that's persistent |
| 6716 // even if the GC moves this SharedFunctionInfo. | 6718 // even if the GC moves this SharedFunctionInfo. |
| 6717 inline int unique_id() const; | 6719 inline int unique_id() const; |
| 6718 inline void set_unique_id(int value); | 6720 inline void set_unique_id(int value); |
| 6719 #endif | 6721 #endif |
| 6720 | 6722 |
| 6721 // [instance class name]: class name for instances. | 6723 // [instance class name]: class name for instances. |
| 6722 DECL_ACCESSORS(instance_class_name, Object) | 6724 DECL_ACCESSORS(instance_class_name, Object) |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7021 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; | 7023 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; |
| 7022 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; | 7024 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; |
| 7023 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; | 7025 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; |
| 7024 static const int kInstanceClassNameOffset = | 7026 static const int kInstanceClassNameOffset = |
| 7025 kConstructStubOffset + kPointerSize; | 7027 kConstructStubOffset + kPointerSize; |
| 7026 static const int kFunctionDataOffset = | 7028 static const int kFunctionDataOffset = |
| 7027 kInstanceClassNameOffset + kPointerSize; | 7029 kInstanceClassNameOffset + kPointerSize; |
| 7028 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 7030 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
| 7029 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 7031 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
| 7030 static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize; | 7032 static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize; |
| 7031 static const int kFeedbackVectorOffset = | 7033 static const int kFeedbackMetadataOffset = |
| 7032 kFunctionIdentifierOffset + kPointerSize; | 7034 kFunctionIdentifierOffset + kPointerSize; |
| 7033 #if TRACE_MAPS | 7035 #if TRACE_MAPS |
| 7034 static const int kUniqueIdOffset = kFeedbackVectorOffset + kPointerSize; | 7036 static const int kUniqueIdOffset = kFeedbackMetadataOffset + kPointerSize; |
| 7035 static const int kLastPointerFieldOffset = kUniqueIdOffset; | 7037 static const int kLastPointerFieldOffset = kUniqueIdOffset; |
| 7036 #else | 7038 #else |
| 7037 // Just to not break the postmortrem support with conditional offsets | 7039 // Just to not break the postmortrem support with conditional offsets |
| 7038 static const int kUniqueIdOffset = kFeedbackVectorOffset; | 7040 static const int kUniqueIdOffset = kFeedbackMetadataOffset; |
| 7039 static const int kLastPointerFieldOffset = kFeedbackVectorOffset; | 7041 static const int kLastPointerFieldOffset = kFeedbackMetadataOffset; |
| 7040 #endif | 7042 #endif |
| 7041 | 7043 |
| 7042 #if V8_HOST_ARCH_32_BIT | 7044 #if V8_HOST_ARCH_32_BIT |
| 7043 // Smi fields. | 7045 // Smi fields. |
| 7044 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; | 7046 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; |
| 7045 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 7047 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; |
| 7046 static const int kExpectedNofPropertiesOffset = | 7048 static const int kExpectedNofPropertiesOffset = |
| 7047 kFormalParameterCountOffset + kPointerSize; | 7049 kFormalParameterCountOffset + kPointerSize; |
| 7048 static const int kNumLiteralsOffset = | 7050 static const int kNumLiteralsOffset = |
| 7049 kExpectedNofPropertiesOffset + kPointerSize; | 7051 kExpectedNofPropertiesOffset + kPointerSize; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7479 // | 7481 // |
| 7480 // If the function contains object, regexp or array literals, the | 7482 // If the function contains object, regexp or array literals, the |
| 7481 // literals array prefix contains the object, regexp, and array | 7483 // literals array prefix contains the object, regexp, and array |
| 7482 // function to be used when creating these literals. This is | 7484 // function to be used when creating these literals. This is |
| 7483 // necessary so that we do not dynamically lookup the object, regexp | 7485 // necessary so that we do not dynamically lookup the object, regexp |
| 7484 // or array functions. Performing a dynamic lookup, we might end up | 7486 // or array functions. Performing a dynamic lookup, we might end up |
| 7485 // using the functions from a new context that we should not have | 7487 // using the functions from a new context that we should not have |
| 7486 // access to. | 7488 // access to. |
| 7487 DECL_ACCESSORS(literals, LiteralsArray) | 7489 DECL_ACCESSORS(literals, LiteralsArray) |
| 7488 | 7490 |
| 7491 static void EnsureLiterals(Handle<JSFunction> function); |
| 7492 inline TypeFeedbackVector* feedback_vector(); |
| 7493 |
| 7494 // Unconditionally clear the type feedback vector (including vector ICs). |
| 7495 void ClearTypeFeedbackInfo(); |
| 7496 |
| 7497 // Clear the type feedback vector with a more subtle policy at GC time. |
| 7498 void ClearTypeFeedbackInfoAtGCTime(); |
| 7499 |
| 7489 // The initial map for an object created by this constructor. | 7500 // The initial map for an object created by this constructor. |
| 7490 inline Map* initial_map(); | 7501 inline Map* initial_map(); |
| 7491 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, | 7502 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, |
| 7492 Handle<Object> prototype); | 7503 Handle<Object> prototype); |
| 7493 inline bool has_initial_map(); | 7504 inline bool has_initial_map(); |
| 7494 static void EnsureHasInitialMap(Handle<JSFunction> function); | 7505 static void EnsureHasInitialMap(Handle<JSFunction> function); |
| 7495 | 7506 |
| 7496 // Creates a map that matches the constructor's initial map, but with | 7507 // Creates a map that matches the constructor's initial map, but with |
| 7497 // [[prototype]] being new.target.prototype. Because new.target can be a | 7508 // [[prototype]] being new.target.prototype. Because new.target can be a |
| 7498 // JSProxy, this can call back into JavaScript. | 7509 // JSProxy, this can call back into JavaScript. |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10767 } | 10778 } |
| 10768 return value; | 10779 return value; |
| 10769 } | 10780 } |
| 10770 }; | 10781 }; |
| 10771 | 10782 |
| 10772 | 10783 |
| 10773 } // NOLINT, false-positive due to second-order macros. | 10784 } // NOLINT, false-positive due to second-order macros. |
| 10774 } // NOLINT, false-positive due to second-order macros. | 10785 } // NOLINT, false-positive due to second-order macros. |
| 10775 | 10786 |
| 10776 #endif // V8_OBJECTS_H_ | 10787 #endif // V8_OBJECTS_H_ |
| OLD | NEW |