| 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 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 4969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4980 public: | 4980 public: |
| 4981 static const int kVectorIndex = 0; | 4981 static const int kVectorIndex = 0; |
| 4982 static const int kFirstLiteralIndex = 1; | 4982 static const int kFirstLiteralIndex = 1; |
| 4983 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; | 4983 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; |
| 4984 static const int kOffsetToFirstLiteral; | 4984 static const int kOffsetToFirstLiteral; |
| 4985 | 4985 |
| 4986 static int OffsetOfLiteralAt(int index) { | 4986 static int OffsetOfLiteralAt(int index) { |
| 4987 return OffsetOfElementAt(index + kFirstLiteralIndex); | 4987 return OffsetOfElementAt(index + kFirstLiteralIndex); |
| 4988 } | 4988 } |
| 4989 | 4989 |
| 4990 inline bool has_feedback_vector() const; |
| 4990 inline TypeFeedbackVector* feedback_vector() const; | 4991 inline TypeFeedbackVector* feedback_vector() const; |
| 4991 inline void set_feedback_vector(TypeFeedbackVector* vector); | 4992 inline void set_feedback_vector(TypeFeedbackVector* vector); |
| 4993 |
| 4992 inline Object* literal(int literal_index) const; | 4994 inline Object* literal(int literal_index) const; |
| 4993 inline void set_literal(int literal_index, Object* literal); | 4995 inline void set_literal(int literal_index, Object* literal); |
| 4994 inline void set_literal_undefined(int literal_index); | 4996 inline void set_literal_undefined(int literal_index); |
| 4995 inline int literals_count() const; | 4997 inline int literals_count() const; |
| 4996 | 4998 |
| 4997 static Handle<LiteralsArray> New(Isolate* isolate, | 4999 static Handle<LiteralsArray> New(Isolate* isolate, |
| 4998 Handle<TypeFeedbackVector> vector, | 5000 Handle<TypeFeedbackVector> vector, |
| 4999 int number_of_literals, | 5001 int number_of_literals, |
| 5000 PretenureFlag pretenure = TENURED); | 5002 PretenureFlag pretenure = TENURED); |
| 5001 | 5003 |
| (...skipping 2116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7118 kTypedArrayByteOffset, | 7120 kTypedArrayByteOffset, |
| 7119 kTypedArrayEntries, | 7121 kTypedArrayEntries, |
| 7120 kTypedArrayKeys, | 7122 kTypedArrayKeys, |
| 7121 kTypedArrayLength, | 7123 kTypedArrayLength, |
| 7122 kTypedArrayValues, | 7124 kTypedArrayValues, |
| 7123 kSharedArrayBufferByteLength, | 7125 kSharedArrayBufferByteLength, |
| 7124 kStringIterator, | 7126 kStringIterator, |
| 7125 kStringIteratorNext, | 7127 kStringIteratorNext, |
| 7126 }; | 7128 }; |
| 7127 | 7129 |
| 7128 // Result of searching in an optimized code map of a SharedFunctionInfo. Note | |
| 7129 // that both {code} and {literals} can be NULL to pass search result status. | |
| 7130 struct CodeAndLiterals { | |
| 7131 Code* code; // Cached optimized code. | |
| 7132 LiteralsArray* literals; // Cached literals array. | |
| 7133 }; | |
| 7134 | 7130 |
| 7135 // SharedFunctionInfo describes the JSFunction information that can be | 7131 // SharedFunctionInfo describes the JSFunction information that can be |
| 7136 // shared by multiple instances of the function. | 7132 // shared by multiple instances of the function. |
| 7137 class SharedFunctionInfo: public HeapObject { | 7133 class SharedFunctionInfo: public HeapObject { |
| 7138 public: | 7134 public: |
| 7139 // [name]: Function name. | 7135 // [name]: Function name. |
| 7140 DECL_ACCESSORS(name, Object) | 7136 DECL_ACCESSORS(name, Object) |
| 7141 | 7137 |
| 7142 // [code]: Function code. | 7138 // [code]: Function code. |
| 7143 DECL_ACCESSORS(code, Code) | 7139 DECL_ACCESSORS(code, Code) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 7155 inline bool IsInterpreted() const; | 7151 inline bool IsInterpreted() const; |
| 7156 | 7152 |
| 7157 inline void ReplaceCode(Code* code); | 7153 inline void ReplaceCode(Code* code); |
| 7158 inline bool HasBaselineCode() const; | 7154 inline bool HasBaselineCode() const; |
| 7159 | 7155 |
| 7160 // [optimized_code_map]: Map from native context to optimized code | 7156 // [optimized_code_map]: Map from native context to optimized code |
| 7161 // and a shared literals array. | 7157 // and a shared literals array. |
| 7162 DECL_ACCESSORS(optimized_code_map, FixedArray) | 7158 DECL_ACCESSORS(optimized_code_map, FixedArray) |
| 7163 | 7159 |
| 7164 // Returns entry from optimized code map for specified context and OSR entry. | 7160 // Returns entry from optimized code map for specified context and OSR entry. |
| 7165 // Note that {code == nullptr, literals == nullptr} indicates no matching | 7161 Code* SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id); |
| 7166 // entry has been found, whereas {code, literals == nullptr} indicates that | |
| 7167 // code is context-independent. | |
| 7168 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, | |
| 7169 BailoutId osr_ast_id); | |
| 7170 | 7162 |
| 7171 // Clear optimized code map. | 7163 // Clear optimized code map. |
| 7172 void ClearOptimizedCodeMap(); | 7164 void ClearOptimizedCodeMap(); |
| 7173 | 7165 |
| 7174 // Like ClearOptimizedCodeMap, but preserves literals. | 7166 // Like ClearOptimizedCodeMap, but preserves literals. |
| 7175 void ClearCodeFromOptimizedCodeMap(); | 7167 void ClearCodeFromOptimizedCodeMap(); |
| 7176 | 7168 |
| 7177 // We have a special root FixedArray with the right shape and values | 7169 // We have a special root FixedArray with the right shape and values |
| 7178 // to represent the cleared optimized code map. This predicate checks | 7170 // to represent the cleared optimized code map. This predicate checks |
| 7179 // if that root is installed. | 7171 // if that root is installed. |
| 7180 inline bool OptimizedCodeMapIsCleared() const; | 7172 inline bool OptimizedCodeMapIsCleared() const; |
| 7181 | 7173 |
| 7182 // Removes a specific optimized code object from the optimized code map. | 7174 // Removes a specific optimized code object from the optimized code map. |
| 7183 // In case of non-OSR the code reference is cleared from the cache entry but | 7175 // In case of non-OSR the code reference is cleared from the cache entry but |
| 7184 // the entry itself is left in the map in order to proceed sharing literals. | 7176 // the entry itself is left in the map in order to proceed sharing literals. |
| 7185 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); | 7177 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); |
| 7186 | 7178 |
| 7187 static Handle<LiteralsArray> FindOrCreateLiterals( | 7179 static Handle<LiteralsArray> FindOrCreateLiterals( |
| 7188 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); | 7180 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); |
| 7189 | 7181 |
| 7190 // Add or update entry in the optimized code map for context-dependent code. | 7182 // Add or update entry in the optimized code map for context-dependent code. |
| 7191 // If {code} is not given, then an existing entry's code won't be overwritten. | |
| 7192 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 7183 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
| 7193 Handle<Context> native_context, | 7184 Handle<Context> native_context, |
| 7194 MaybeHandle<Code> code, | 7185 Handle<Code> code, BailoutId osr_ast_id); |
| 7195 Handle<LiteralsArray> literals, | |
| 7196 BailoutId osr_ast_id); | |
| 7197 | 7186 |
| 7198 // Set up the link between shared function info and the script. The shared | 7187 // Set up the link between shared function info and the script. The shared |
| 7199 // function info is added to the list on the script. | 7188 // function info is added to the list on the script. |
| 7200 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, | 7189 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, |
| 7201 Handle<Object> script_object); | 7190 Handle<Object> script_object); |
| 7202 | 7191 |
| 7203 // Layout description of the optimized code map. | 7192 // Layout description of the optimized code map. |
| 7204 static const int kEntriesStart = 0; | 7193 static const int kEntriesStart = 0; |
| 7205 static const int kContextOffset = 0; | 7194 static const int kContextOffset = 0; |
| 7206 static const int kCachedCodeOffset = 1; | 7195 static const int kCachedCodeOffset = 1; |
| 7207 static const int kLiteralsOffset = 2; | 7196 static const int kEntryLength = 2; |
| 7208 static const int kEntryLength = 3; | |
| 7209 static const int kInitialLength = kEntriesStart + kEntryLength; | 7197 static const int kInitialLength = kEntriesStart + kEntryLength; |
| 7210 | 7198 |
| 7211 static const int kNotFound = -1; | 7199 static const int kNotFound = -1; |
| 7212 | 7200 |
| 7213 // Helpers for assembly code that does a backwards walk of the optimized code | 7201 // Helpers for assembly code that does a backwards walk of the optimized code |
| 7214 // map. | 7202 // map. |
| 7215 static const int kOffsetToPreviousContext = | 7203 static const int kOffsetToPreviousContext = |
| 7216 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); | 7204 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); |
| 7217 static const int kOffsetToPreviousCachedCode = | 7205 static const int kOffsetToPreviousCachedCode = |
| 7218 FixedArray::kHeaderSize + | 7206 FixedArray::kHeaderSize + |
| 7219 kPointerSize * (kCachedCodeOffset - kEntryLength); | 7207 kPointerSize * (kCachedCodeOffset - kEntryLength); |
| 7220 static const int kOffsetToPreviousLiterals = | |
| 7221 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength); | |
| 7222 | 7208 |
| 7223 // [scope_info]: Scope info. | 7209 // [scope_info]: Scope info. |
| 7224 DECL_ACCESSORS(scope_info, ScopeInfo) | 7210 DECL_ACCESSORS(scope_info, ScopeInfo) |
| 7225 | 7211 |
| 7226 // The outer scope info for the purpose of parsing this function, or the hole | 7212 // The outer scope info for the purpose of parsing this function, or the hole |
| 7227 // value if it isn't yet known. | 7213 // value if it isn't yet known. |
| 7228 DECL_ACCESSORS(outer_scope_info, HeapObject) | 7214 DECL_ACCESSORS(outer_scope_info, HeapObject) |
| 7229 | 7215 |
| 7230 // [construct stub]: Code stub for constructing instances of this function. | 7216 // [construct stub]: Code stub for constructing instances of this function. |
| 7231 DECL_ACCESSORS(construct_stub, Code) | 7217 DECL_ACCESSORS(construct_stub, Code) |
| (...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8161 // | 8147 // |
| 8162 // If the function contains object, regexp or array literals, the | 8148 // If the function contains object, regexp or array literals, the |
| 8163 // literals array prefix contains the object, regexp, and array | 8149 // literals array prefix contains the object, regexp, and array |
| 8164 // function to be used when creating these literals. This is | 8150 // function to be used when creating these literals. This is |
| 8165 // necessary so that we do not dynamically lookup the object, regexp | 8151 // necessary so that we do not dynamically lookup the object, regexp |
| 8166 // or array functions. Performing a dynamic lookup, we might end up | 8152 // or array functions. Performing a dynamic lookup, we might end up |
| 8167 // using the functions from a new context that we should not have | 8153 // using the functions from a new context that we should not have |
| 8168 // access to. For API objects we store the boilerplate in the literal array. | 8154 // access to. For API objects we store the boilerplate in the literal array. |
| 8169 DECL_ACCESSORS(literals, LiteralsArray) | 8155 DECL_ACCESSORS(literals, LiteralsArray) |
| 8170 | 8156 |
| 8157 inline bool has_literals_array() const; |
| 8171 static void EnsureLiterals(Handle<JSFunction> function); | 8158 static void EnsureLiterals(Handle<JSFunction> function); |
| 8172 inline TypeFeedbackVector* feedback_vector(); | 8159 inline TypeFeedbackVector* feedback_vector(); |
| 8173 | 8160 |
| 8174 // Unconditionally clear the type feedback vector (including vector ICs). | 8161 // Unconditionally clear the type feedback vector (including vector ICs). |
| 8175 void ClearTypeFeedbackInfo(); | 8162 void ClearTypeFeedbackInfo(); |
| 8176 | 8163 |
| 8177 // Clear the type feedback vector with a more subtle policy at GC time. | 8164 // Clear the type feedback vector with a more subtle policy at GC time. |
| 8178 void ClearTypeFeedbackInfoAtGCTime(); | 8165 void ClearTypeFeedbackInfoAtGCTime(); |
| 8179 | 8166 |
| 8180 // The initial map for an object created by this constructor. | 8167 // The initial map for an object created by this constructor. |
| (...skipping 3480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11661 } | 11648 } |
| 11662 }; | 11649 }; |
| 11663 | 11650 |
| 11664 | 11651 |
| 11665 } // NOLINT, false-positive due to second-order macros. | 11652 } // NOLINT, false-positive due to second-order macros. |
| 11666 } // NOLINT, false-positive due to second-order macros. | 11653 } // NOLINT, false-positive due to second-order macros. |
| 11667 | 11654 |
| 11668 #include "src/objects/object-macros-undef.h" | 11655 #include "src/objects/object-macros-undef.h" |
| 11669 | 11656 |
| 11670 #endif // V8_OBJECTS_H_ | 11657 #endif // V8_OBJECTS_H_ |
| OLD | NEW |