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 3844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4713 #endif | 4714 #endif |
4714 }; | 4715 }; |
4715 | 4716 |
4716 | 4717 |
4717 // A literals array contains the literals for a JSFunction. It also holds | 4718 // A literals array contains the literals for a JSFunction. It also holds |
4718 // the type feedback vector. | 4719 // the type feedback vector. |
4719 class LiteralsArray : public FixedArray { | 4720 class LiteralsArray : public FixedArray { |
4720 public: | 4721 public: |
4721 static const int kVectorIndex = 0; | 4722 static const int kVectorIndex = 0; |
4722 static const int kFirstLiteralIndex = 1; | 4723 static const int kFirstLiteralIndex = 1; |
4723 static const int kOffsetToFirstLiteral = | 4724 static const int kFeedbackVectorOffset = FixedArray::kHeaderSize; |
Michael Starzinger
2016/05/10 13:47:20
nit: It is possible to use OffsetOfElementAt(kVect
mvstanton
2016/05/24 16:31:50
Done.
| |
4724 FixedArray::kHeaderSize + kPointerSize; | 4725 static const int kOffsetToFirstLiteral = kFeedbackVectorOffset + kPointerSize; |
Michael Starzinger
2016/05/10 13:47:20
nit: Likewise.
mvstanton
2016/05/24 16:31:50
Done.
| |
4725 | 4726 |
4726 static int OffsetOfLiteralAt(int index) { | 4727 static int OffsetOfLiteralAt(int index) { |
4727 return SizeFor(index + kFirstLiteralIndex); | 4728 return SizeFor(index + kFirstLiteralIndex); |
4728 } | 4729 } |
4729 | 4730 |
4730 inline TypeFeedbackVector* feedback_vector() const; | 4731 inline TypeFeedbackVector* feedback_vector() const; |
4731 inline void set_feedback_vector(TypeFeedbackVector* vector); | 4732 inline void set_feedback_vector(TypeFeedbackVector* vector); |
4732 inline Object* literal(int literal_index) const; | 4733 inline Object* literal(int literal_index) const; |
4733 inline void set_literal(int literal_index, Object* literal); | 4734 inline void set_literal(int literal_index, Object* literal); |
4735 inline void set_literal_undefined(int literal_index); | |
4734 inline int literals_count() const; | 4736 inline int literals_count() const; |
4735 | 4737 |
4736 static Handle<LiteralsArray> New(Isolate* isolate, | 4738 static Handle<LiteralsArray> New(Isolate* isolate, |
4737 Handle<TypeFeedbackVector> vector, | 4739 Handle<TypeFeedbackVector> vector, |
4738 int number_of_literals, | 4740 int number_of_literals, |
4739 PretenureFlag pretenure); | 4741 PretenureFlag pretenure); |
4740 | 4742 |
4741 DECLARE_CAST(LiteralsArray) | 4743 DECLARE_CAST(LiteralsArray) |
4742 | 4744 |
4743 private: | 4745 private: |
(...skipping 1831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6575 // Returns entry from optimized code map for specified context and OSR entry. | 6577 // Returns entry from optimized code map for specified context and OSR entry. |
6576 // Note that {code == nullptr, literals == nullptr} indicates no matching | 6578 // Note that {code == nullptr, literals == nullptr} indicates no matching |
6577 // entry has been found, whereas {code, literals == nullptr} indicates that | 6579 // entry has been found, whereas {code, literals == nullptr} indicates that |
6578 // code is context-independent. | 6580 // code is context-independent. |
6579 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, | 6581 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, |
6580 BailoutId osr_ast_id); | 6582 BailoutId osr_ast_id); |
6581 | 6583 |
6582 // Clear optimized code map. | 6584 // Clear optimized code map. |
6583 void ClearOptimizedCodeMap(); | 6585 void ClearOptimizedCodeMap(); |
6584 | 6586 |
6587 // Like ClearOptimizedCodeMap, but preserves literals. | |
6588 void ClearCodeFromOptimizedCodeMap(); | |
6589 | |
6585 // We have a special root FixedArray with the right shape and values | 6590 // We have a special root FixedArray with the right shape and values |
6586 // to represent the cleared optimized code map. This predicate checks | 6591 // to represent the cleared optimized code map. This predicate checks |
6587 // if that root is installed. | 6592 // if that root is installed. |
6588 inline bool OptimizedCodeMapIsCleared() const; | 6593 inline bool OptimizedCodeMapIsCleared() const; |
6589 | 6594 |
6590 // Removes a specific optimized code object from the optimized code map. | 6595 // Removes a specific optimized code object from the optimized code map. |
6591 // In case of non-OSR the code reference is cleared from the cache entry but | 6596 // In case of non-OSR the code reference is cleared from the cache entry but |
6592 // the entry itself is left in the map in order to proceed sharing literals. | 6597 // the entry itself is left in the map in order to proceed sharing literals. |
6593 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); | 6598 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); |
6594 | 6599 |
6595 // Trims the optimized code map after entries have been removed. | 6600 // Trims the optimized code map after entries have been removed. |
6596 void TrimOptimizedCodeMap(int shrink_by); | 6601 void TrimOptimizedCodeMap(int shrink_by); |
6597 | 6602 |
6603 static Handle<LiteralsArray> FindOrCreateLiterals( | |
6604 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); | |
6605 | |
6598 // Add or update entry in the optimized code map for context-independent code. | 6606 // Add or update entry in the optimized code map for context-independent code. |
6599 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6607 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6600 Handle<Code> code); | 6608 Handle<Code> code); |
6601 | 6609 |
6602 // Add or update entry in the optimized code map for context-dependent code. | 6610 // Add or update entry in the optimized code map for context-dependent code. |
6603 // If {code} is not given, then an existing entry's code won't be overwritten. | 6611 // If {code} is not given, then an existing entry's code won't be overwritten. |
6604 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 6612 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
6605 Handle<Context> native_context, | 6613 Handle<Context> native_context, |
6606 MaybeHandle<Code> code, | 6614 MaybeHandle<Code> code, |
6607 Handle<LiteralsArray> literals, | 6615 Handle<LiteralsArray> literals, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6657 inline void set_internal_formal_parameter_count(int value); | 6665 inline void set_internal_formal_parameter_count(int value); |
6658 | 6666 |
6659 // Set the formal parameter count so the function code will be | 6667 // Set the formal parameter count so the function code will be |
6660 // called without using argument adaptor frames. | 6668 // called without using argument adaptor frames. |
6661 inline void DontAdaptArguments(); | 6669 inline void DontAdaptArguments(); |
6662 | 6670 |
6663 // [expected_nof_properties]: Expected number of properties for the function. | 6671 // [expected_nof_properties]: Expected number of properties for the function. |
6664 inline int expected_nof_properties() const; | 6672 inline int expected_nof_properties() const; |
6665 inline void set_expected_nof_properties(int value); | 6673 inline void set_expected_nof_properties(int value); |
6666 | 6674 |
6667 // [feedback_vector] - accumulates ast node feedback from full-codegen and | 6675 // [feedback_metadata] - describes ast node feedback from full-codegen and |
6668 // (increasingly) from crankshafted code where sufficient feedback isn't | 6676 // (increasingly) from crankshafted code where sufficient feedback isn't |
6669 // available. | 6677 // available. |
6670 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector) | 6678 DECL_ACCESSORS(feedback_metadata, TypeFeedbackMetadata) |
6671 | |
6672 // Unconditionally clear the type feedback vector (including vector ICs). | |
6673 void ClearTypeFeedbackInfo(); | |
6674 | |
6675 // Clear the type feedback vector with a more subtle policy at GC time. | |
6676 void ClearTypeFeedbackInfoAtGCTime(); | |
6677 | 6679 |
6678 #if TRACE_MAPS | 6680 #if TRACE_MAPS |
6679 // [unique_id] - For --trace-maps purposes, an identifier that's persistent | 6681 // [unique_id] - For --trace-maps purposes, an identifier that's persistent |
6680 // even if the GC moves this SharedFunctionInfo. | 6682 // even if the GC moves this SharedFunctionInfo. |
6681 inline int unique_id() const; | 6683 inline int unique_id() const; |
6682 inline void set_unique_id(int value); | 6684 inline void set_unique_id(int value); |
6683 #endif | 6685 #endif |
6684 | 6686 |
6685 // [instance class name]: class name for instances. | 6687 // [instance class name]: class name for instances. |
6686 DECL_ACCESSORS(instance_class_name, Object) | 6688 DECL_ACCESSORS(instance_class_name, Object) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6978 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; | 6980 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; |
6979 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; | 6981 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; |
6980 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; | 6982 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; |
6981 static const int kInstanceClassNameOffset = | 6983 static const int kInstanceClassNameOffset = |
6982 kConstructStubOffset + kPointerSize; | 6984 kConstructStubOffset + kPointerSize; |
6983 static const int kFunctionDataOffset = | 6985 static const int kFunctionDataOffset = |
6984 kInstanceClassNameOffset + kPointerSize; | 6986 kInstanceClassNameOffset + kPointerSize; |
6985 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; | 6987 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; |
6986 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 6988 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
6987 static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize; | 6989 static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize; |
6988 static const int kFeedbackVectorOffset = | 6990 static const int kFeedbackMetadataOffset = |
6989 kFunctionIdentifierOffset + kPointerSize; | 6991 kFunctionIdentifierOffset + kPointerSize; |
6990 #if TRACE_MAPS | 6992 #if TRACE_MAPS |
6991 static const int kUniqueIdOffset = kFeedbackVectorOffset + kPointerSize; | 6993 static const int kUniqueIdOffset = kFeedbackMetadataOffset + kPointerSize; |
6992 static const int kLastPointerFieldOffset = kUniqueIdOffset; | 6994 static const int kLastPointerFieldOffset = kUniqueIdOffset; |
6993 #else | 6995 #else |
6994 // Just to not break the postmortrem support with conditional offsets | 6996 // Just to not break the postmortrem support with conditional offsets |
6995 static const int kUniqueIdOffset = kFeedbackVectorOffset; | 6997 static const int kUniqueIdOffset = kFeedbackMetadataOffset; |
6996 static const int kLastPointerFieldOffset = kFeedbackVectorOffset; | 6998 static const int kLastPointerFieldOffset = kFeedbackMetadataOffset; |
6997 #endif | 6999 #endif |
6998 | 7000 |
6999 #if V8_HOST_ARCH_32_BIT | 7001 #if V8_HOST_ARCH_32_BIT |
7000 // Smi fields. | 7002 // Smi fields. |
7001 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; | 7003 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; |
7002 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; | 7004 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; |
7003 static const int kExpectedNofPropertiesOffset = | 7005 static const int kExpectedNofPropertiesOffset = |
7004 kFormalParameterCountOffset + kPointerSize; | 7006 kFormalParameterCountOffset + kPointerSize; |
7005 static const int kNumLiteralsOffset = | 7007 static const int kNumLiteralsOffset = |
7006 kExpectedNofPropertiesOffset + kPointerSize; | 7008 kExpectedNofPropertiesOffset + kPointerSize; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7397 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function); | 7399 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function); |
7398 | 7400 |
7399 // [code]: The generated code object for this function. Executed | 7401 // [code]: The generated code object for this function. Executed |
7400 // when the function is invoked, e.g. foo() or new foo(). See | 7402 // when the function is invoked, e.g. foo() or new foo(). See |
7401 // [[Call]] and [[Construct]] description in ECMA-262, section | 7403 // [[Call]] and [[Construct]] description in ECMA-262, section |
7402 // 8.6.2, page 27. | 7404 // 8.6.2, page 27. |
7403 inline Code* code(); | 7405 inline Code* code(); |
7404 inline void set_code(Code* code); | 7406 inline void set_code(Code* code); |
7405 inline void set_code_no_write_barrier(Code* code); | 7407 inline void set_code_no_write_barrier(Code* code); |
7406 inline void ReplaceCode(Code* code); | 7408 inline void ReplaceCode(Code* code); |
7409 static void EnsureLiterals(Handle<JSFunction> function); | |
Michael Starzinger
2016/05/10 13:47:20
nit: Please move this down to the "[literals]" sec
mvstanton
2016/05/24 16:31:50
Done.
| |
7407 | 7410 |
7408 // Get the abstract code associated with the function, which will either be | 7411 // Get the abstract code associated with the function, which will either be |
7409 // a Code object or a BytecodeArray. | 7412 // a Code object or a BytecodeArray. |
7410 inline AbstractCode* abstract_code(); | 7413 inline AbstractCode* abstract_code(); |
7411 | 7414 |
7412 // Tells whether this function inlines the given shared function info. | 7415 // Tells whether this function inlines the given shared function info. |
7413 bool Inlines(SharedFunctionInfo* candidate); | 7416 bool Inlines(SharedFunctionInfo* candidate); |
7414 | 7417 |
7415 // Tells whether or not this function has been optimized. | 7418 // Tells whether or not this function has been optimized. |
7416 inline bool IsOptimized(); | 7419 inline bool IsOptimized(); |
7417 | 7420 |
7418 // Mark this function for lazy recompilation. The function will be recompiled | 7421 // Mark this function for lazy recompilation. The function will be recompiled |
7419 // the next time it is executed. | 7422 // the next time it is executed. |
7420 void MarkForBaseline(); | 7423 void MarkForBaseline(); |
7421 void MarkForOptimization(); | 7424 void MarkForOptimization(); |
7422 void AttemptConcurrentOptimization(); | 7425 void AttemptConcurrentOptimization(); |
7423 | 7426 |
7424 // Tells whether or not the function is already marked for lazy recompilation. | 7427 // Tells whether or not the function is already marked for lazy recompilation. |
7425 inline bool IsMarkedForBaseline(); | 7428 inline bool IsMarkedForBaseline(); |
7426 inline bool IsMarkedForOptimization(); | 7429 inline bool IsMarkedForOptimization(); |
7427 inline bool IsMarkedForConcurrentOptimization(); | 7430 inline bool IsMarkedForConcurrentOptimization(); |
7428 | 7431 |
7429 // Tells whether or not the function is on the concurrent recompilation queue. | 7432 // Tells whether or not the function is on the concurrent recompilation queue. |
7430 inline bool IsInOptimizationQueue(); | 7433 inline bool IsInOptimizationQueue(); |
7431 | 7434 |
7435 // Unconditionally clear the type feedback vector (including vector ICs). | |
7436 void ClearTypeFeedbackInfo(); | |
Michael Starzinger
2016/05/10 13:47:20
nit: Likewise, please move this down to after the
mvstanton
2016/05/24 16:31:50
Done.
| |
7437 | |
7438 // Clear the type feedback vector with a more subtle policy at GC time. | |
7439 void ClearTypeFeedbackInfoAtGCTime(); | |
7440 | |
7432 // Completes inobject slack tracking on initial map if it is active. | 7441 // Completes inobject slack tracking on initial map if it is active. |
7433 inline void CompleteInobjectSlackTrackingIfActive(); | 7442 inline void CompleteInobjectSlackTrackingIfActive(); |
7434 | 7443 |
7435 // [literals]: Fixed array holding the materialized literals. | 7444 // [literals]: Fixed array holding the materialized literals. |
7436 // | 7445 // |
7437 // If the function contains object, regexp or array literals, the | 7446 // If the function contains object, regexp or array literals, the |
7438 // literals array prefix contains the object, regexp, and array | 7447 // literals array prefix contains the object, regexp, and array |
7439 // function to be used when creating these literals. This is | 7448 // function to be used when creating these literals. This is |
7440 // necessary so that we do not dynamically lookup the object, regexp | 7449 // necessary so that we do not dynamically lookup the object, regexp |
7441 // or array functions. Performing a dynamic lookup, we might end up | 7450 // or array functions. Performing a dynamic lookup, we might end up |
7442 // using the functions from a new context that we should not have | 7451 // using the functions from a new context that we should not have |
7443 // access to. | 7452 // access to. |
7444 DECL_ACCESSORS(literals, LiteralsArray) | 7453 DECL_ACCESSORS(literals, LiteralsArray) |
7445 | 7454 |
7455 inline TypeFeedbackVector* feedback_vector(); | |
7456 | |
7446 // The initial map for an object created by this constructor. | 7457 // The initial map for an object created by this constructor. |
7447 inline Map* initial_map(); | 7458 inline Map* initial_map(); |
7448 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, | 7459 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, |
7449 Handle<Object> prototype); | 7460 Handle<Object> prototype); |
7450 inline bool has_initial_map(); | 7461 inline bool has_initial_map(); |
7451 static void EnsureHasInitialMap(Handle<JSFunction> function); | 7462 static void EnsureHasInitialMap(Handle<JSFunction> function); |
7452 | 7463 |
7453 // Creates a map that matches the constructor's initial map, but with | 7464 // Creates a map that matches the constructor's initial map, but with |
7454 // [[prototype]] being new.target.prototype. Because new.target can be a | 7465 // [[prototype]] being new.target.prototype. Because new.target can be a |
7455 // JSProxy, this can call back into JavaScript. | 7466 // JSProxy, this can call back into JavaScript. |
(...skipping 3267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10723 } | 10734 } |
10724 return value; | 10735 return value; |
10725 } | 10736 } |
10726 }; | 10737 }; |
10727 | 10738 |
10728 | 10739 |
10729 } // NOLINT, false-positive due to second-order macros. | 10740 } // NOLINT, false-positive due to second-order macros. |
10730 } // NOLINT, false-positive due to second-order macros. | 10741 } // NOLINT, false-positive due to second-order macros. |
10731 | 10742 |
10732 #endif // V8_OBJECTS_H_ | 10743 #endif // V8_OBJECTS_H_ |
OLD | NEW |