| 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 4998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5009 public: | 5009 public: |
| 5010 static const int kVectorIndex = 0; | 5010 static const int kVectorIndex = 0; |
| 5011 static const int kFirstLiteralIndex = 1; | 5011 static const int kFirstLiteralIndex = 1; |
| 5012 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; | 5012 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; |
| 5013 static const int kOffsetToFirstLiteral; | 5013 static const int kOffsetToFirstLiteral; |
| 5014 | 5014 |
| 5015 static int OffsetOfLiteralAt(int index) { | 5015 static int OffsetOfLiteralAt(int index) { |
| 5016 return OffsetOfElementAt(index + kFirstLiteralIndex); | 5016 return OffsetOfElementAt(index + kFirstLiteralIndex); |
| 5017 } | 5017 } |
| 5018 | 5018 |
| 5019 inline bool has_feedback_vector() const; |
| 5019 inline TypeFeedbackVector* feedback_vector() const; | 5020 inline TypeFeedbackVector* feedback_vector() const; |
| 5020 inline void set_feedback_vector(TypeFeedbackVector* vector); | 5021 inline void set_feedback_vector(TypeFeedbackVector* vector); |
| 5022 |
| 5021 inline Object* literal(int literal_index) const; | 5023 inline Object* literal(int literal_index) const; |
| 5022 inline void set_literal(int literal_index, Object* literal); | 5024 inline void set_literal(int literal_index, Object* literal); |
| 5023 inline void set_literal_undefined(int literal_index); | 5025 inline void set_literal_undefined(int literal_index); |
| 5024 inline int literals_count() const; | 5026 inline int literals_count() const; |
| 5025 | 5027 |
| 5026 static Handle<LiteralsArray> New(Isolate* isolate, | 5028 static Handle<LiteralsArray> New(Isolate* isolate, |
| 5027 Handle<TypeFeedbackVector> vector, | 5029 Handle<TypeFeedbackVector> vector, |
| 5028 int number_of_literals, | 5030 int number_of_literals, |
| 5029 PretenureFlag pretenure = TENURED); | 5031 PretenureFlag pretenure = TENURED); |
| 5030 | 5032 |
| (...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7150 kTypedArrayEntries, | 7152 kTypedArrayEntries, |
| 7151 kTypedArrayKeys, | 7153 kTypedArrayKeys, |
| 7152 kTypedArrayLength, | 7154 kTypedArrayLength, |
| 7153 kTypedArrayValues, | 7155 kTypedArrayValues, |
| 7154 kSharedArrayBufferByteLength, | 7156 kSharedArrayBufferByteLength, |
| 7155 kStringIterator, | 7157 kStringIterator, |
| 7156 kStringIteratorNext, | 7158 kStringIteratorNext, |
| 7157 }; | 7159 }; |
| 7158 | 7160 |
| 7159 | 7161 |
| 7160 // Result of searching in an optimized code map of a SharedFunctionInfo. Note | |
| 7161 // that both {code} and {literals} can be NULL to pass search result status. | |
| 7162 struct CodeAndLiterals { | |
| 7163 Code* code; // Cached optimized code. | |
| 7164 LiteralsArray* literals; // Cached literals array. | |
| 7165 }; | |
| 7166 | |
| 7167 | |
| 7168 // SharedFunctionInfo describes the JSFunction information that can be | 7162 // SharedFunctionInfo describes the JSFunction information that can be |
| 7169 // shared by multiple instances of the function. | 7163 // shared by multiple instances of the function. |
| 7170 class SharedFunctionInfo: public HeapObject { | 7164 class SharedFunctionInfo: public HeapObject { |
| 7171 public: | 7165 public: |
| 7172 // [name]: Function name. | 7166 // [name]: Function name. |
| 7173 DECL_ACCESSORS(name, Object) | 7167 DECL_ACCESSORS(name, Object) |
| 7174 | 7168 |
| 7175 // [code]: Function code. | 7169 // [code]: Function code. |
| 7176 DECL_ACCESSORS(code, Code) | 7170 DECL_ACCESSORS(code, Code) |
| 7177 | 7171 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 7188 inline bool IsInterpreted() const; | 7182 inline bool IsInterpreted() const; |
| 7189 | 7183 |
| 7190 inline void ReplaceCode(Code* code); | 7184 inline void ReplaceCode(Code* code); |
| 7191 inline bool HasBaselineCode() const; | 7185 inline bool HasBaselineCode() const; |
| 7192 | 7186 |
| 7193 // [optimized_code_map]: Map from native context to optimized code | 7187 // [optimized_code_map]: Map from native context to optimized code |
| 7194 // and a shared literals array. | 7188 // and a shared literals array. |
| 7195 DECL_ACCESSORS(optimized_code_map, FixedArray) | 7189 DECL_ACCESSORS(optimized_code_map, FixedArray) |
| 7196 | 7190 |
| 7197 // Returns entry from optimized code map for specified context and OSR entry. | 7191 // Returns entry from optimized code map for specified context and OSR entry. |
| 7198 // Note that {code == nullptr, literals == nullptr} indicates no matching | 7192 Code* SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id); |
| 7199 // entry has been found, whereas {code, literals == nullptr} indicates that | |
| 7200 // code is context-independent. | |
| 7201 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, | |
| 7202 BailoutId osr_ast_id); | |
| 7203 | 7193 |
| 7204 // Clear optimized code map. | 7194 // Clear optimized code map. |
| 7205 void ClearOptimizedCodeMap(); | 7195 void ClearOptimizedCodeMap(); |
| 7206 | 7196 |
| 7207 // Like ClearOptimizedCodeMap, but preserves literals. | 7197 // Like ClearOptimizedCodeMap, but preserves literals. |
| 7208 void ClearCodeFromOptimizedCodeMap(); | 7198 void ClearCodeFromOptimizedCodeMap(); |
| 7209 | 7199 |
| 7210 // We have a special root FixedArray with the right shape and values | 7200 // We have a special root FixedArray with the right shape and values |
| 7211 // to represent the cleared optimized code map. This predicate checks | 7201 // to represent the cleared optimized code map. This predicate checks |
| 7212 // if that root is installed. | 7202 // if that root is installed. |
| 7213 inline bool OptimizedCodeMapIsCleared() const; | 7203 inline bool OptimizedCodeMapIsCleared() const; |
| 7214 | 7204 |
| 7215 // Removes a specific optimized code object from the optimized code map. | 7205 // Removes a specific optimized code object from the optimized code map. |
| 7216 // In case of non-OSR the code reference is cleared from the cache entry but | 7206 // In case of non-OSR the code reference is cleared from the cache entry but |
| 7217 // the entry itself is left in the map in order to proceed sharing literals. | 7207 // the entry itself is left in the map in order to proceed sharing literals. |
| 7218 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); | 7208 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); |
| 7219 | 7209 |
| 7220 static Handle<LiteralsArray> FindOrCreateLiterals( | 7210 static Handle<LiteralsArray> FindOrCreateLiterals( |
| 7221 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); | 7211 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); |
| 7222 | 7212 |
| 7223 // Add or update entry in the optimized code map for context-dependent code. | 7213 // Add or update entry in the optimized code map for context-dependent code. |
| 7224 // If {code} is not given, then an existing entry's code won't be overwritten. | |
| 7225 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, | 7214 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, |
| 7226 Handle<Context> native_context, | 7215 Handle<Context> native_context, |
| 7227 MaybeHandle<Code> code, | 7216 Handle<Code> code, BailoutId osr_ast_id); |
| 7228 Handle<LiteralsArray> literals, | |
| 7229 BailoutId osr_ast_id); | |
| 7230 | 7217 |
| 7231 // Set up the link between shared function info and the script. The shared | 7218 // Set up the link between shared function info and the script. The shared |
| 7232 // function info is added to the list on the script. | 7219 // function info is added to the list on the script. |
| 7233 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, | 7220 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, |
| 7234 Handle<Object> script_object); | 7221 Handle<Object> script_object); |
| 7235 | 7222 |
| 7236 // Layout description of the optimized code map. | 7223 // Layout description of the optimized code map. |
| 7237 static const int kEntriesStart = 0; | 7224 static const int kEntriesStart = 0; |
| 7238 static const int kContextOffset = 0; | 7225 static const int kContextOffset = 0; |
| 7239 static const int kCachedCodeOffset = 1; | 7226 static const int kCachedCodeOffset = 1; |
| 7240 static const int kLiteralsOffset = 2; | 7227 static const int kEntryLength = 2; |
| 7241 static const int kEntryLength = 3; | |
| 7242 static const int kInitialLength = kEntriesStart + kEntryLength; | 7228 static const int kInitialLength = kEntriesStart + kEntryLength; |
| 7243 | 7229 |
| 7244 static const int kNotFound = -1; | 7230 static const int kNotFound = -1; |
| 7245 | 7231 |
| 7246 // Helpers for assembly code that does a backwards walk of the optimized code | 7232 // Helpers for assembly code that does a backwards walk of the optimized code |
| 7247 // map. | 7233 // map. |
| 7248 static const int kOffsetToPreviousContext = | 7234 static const int kOffsetToPreviousContext = |
| 7249 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); | 7235 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); |
| 7250 static const int kOffsetToPreviousCachedCode = | 7236 static const int kOffsetToPreviousCachedCode = |
| 7251 FixedArray::kHeaderSize + | 7237 FixedArray::kHeaderSize + |
| 7252 kPointerSize * (kCachedCodeOffset - kEntryLength); | 7238 kPointerSize * (kCachedCodeOffset - kEntryLength); |
| 7253 static const int kOffsetToPreviousLiterals = | |
| 7254 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength); | |
| 7255 | 7239 |
| 7256 // [scope_info]: Scope info. | 7240 // [scope_info]: Scope info. |
| 7257 DECL_ACCESSORS(scope_info, ScopeInfo) | 7241 DECL_ACCESSORS(scope_info, ScopeInfo) |
| 7258 | 7242 |
| 7259 // The outer scope info for the purpose of parsing this function, or the hole | 7243 // The outer scope info for the purpose of parsing this function, or the hole |
| 7260 // value if it isn't yet known. | 7244 // value if it isn't yet known. |
| 7261 DECL_ACCESSORS(outer_scope_info, HeapObject) | 7245 DECL_ACCESSORS(outer_scope_info, HeapObject) |
| 7262 | 7246 |
| 7263 // [construct stub]: Code stub for constructing instances of this function. | 7247 // [construct stub]: Code stub for constructing instances of this function. |
| 7264 DECL_ACCESSORS(construct_stub, Code) | 7248 DECL_ACCESSORS(construct_stub, Code) |
| (...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8213 // | 8197 // |
| 8214 // If the function contains object, regexp or array literals, the | 8198 // If the function contains object, regexp or array literals, the |
| 8215 // literals array prefix contains the object, regexp, and array | 8199 // literals array prefix contains the object, regexp, and array |
| 8216 // function to be used when creating these literals. This is | 8200 // function to be used when creating these literals. This is |
| 8217 // necessary so that we do not dynamically lookup the object, regexp | 8201 // necessary so that we do not dynamically lookup the object, regexp |
| 8218 // or array functions. Performing a dynamic lookup, we might end up | 8202 // or array functions. Performing a dynamic lookup, we might end up |
| 8219 // using the functions from a new context that we should not have | 8203 // using the functions from a new context that we should not have |
| 8220 // access to. For API objects we store the boilerplate in the literal array. | 8204 // access to. For API objects we store the boilerplate in the literal array. |
| 8221 DECL_ACCESSORS(literals, LiteralsArray) | 8205 DECL_ACCESSORS(literals, LiteralsArray) |
| 8222 | 8206 |
| 8207 inline bool has_literals_array() const; |
| 8223 static void EnsureLiterals(Handle<JSFunction> function); | 8208 static void EnsureLiterals(Handle<JSFunction> function); |
| 8224 inline TypeFeedbackVector* feedback_vector(); | 8209 inline TypeFeedbackVector* feedback_vector(); |
| 8225 | 8210 |
| 8226 // Unconditionally clear the type feedback vector (including vector ICs). | 8211 // Unconditionally clear the type feedback vector (including vector ICs). |
| 8227 void ClearTypeFeedbackInfo(); | 8212 void ClearTypeFeedbackInfo(); |
| 8228 | 8213 |
| 8229 // Clear the type feedback vector with a more subtle policy at GC time. | 8214 // Clear the type feedback vector with a more subtle policy at GC time. |
| 8230 void ClearTypeFeedbackInfoAtGCTime(); | 8215 void ClearTypeFeedbackInfoAtGCTime(); |
| 8231 | 8216 |
| 8232 // The initial map for an object created by this constructor. | 8217 // The initial map for an object created by this constructor. |
| (...skipping 3515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11748 } | 11733 } |
| 11749 }; | 11734 }; |
| 11750 | 11735 |
| 11751 | 11736 |
| 11752 } // NOLINT, false-positive due to second-order macros. | 11737 } // NOLINT, false-positive due to second-order macros. |
| 11753 } // NOLINT, false-positive due to second-order macros. | 11738 } // NOLINT, false-positive due to second-order macros. |
| 11754 | 11739 |
| 11755 #include "src/objects/object-macros-undef.h" | 11740 #include "src/objects/object-macros-undef.h" |
| 11756 | 11741 |
| 11757 #endif // V8_OBJECTS_H_ | 11742 #endif // V8_OBJECTS_H_ |
| OLD | NEW |