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