Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(856)

Side by Side Diff: src/objects.h

Issue 2620753003: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: Code comments. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 4990 matching lines...) Expand 10 before | Expand all | Expand 10 after
5001 public: 5001 public:
5002 static const int kVectorIndex = 0; 5002 static const int kVectorIndex = 0;
5003 static const int kFirstLiteralIndex = 1; 5003 static const int kFirstLiteralIndex = 1;
5004 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; 5004 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset;
5005 static const int kOffsetToFirstLiteral; 5005 static const int kOffsetToFirstLiteral;
5006 5006
5007 static int OffsetOfLiteralAt(int index) { 5007 static int OffsetOfLiteralAt(int index) {
5008 return OffsetOfElementAt(index + kFirstLiteralIndex); 5008 return OffsetOfElementAt(index + kFirstLiteralIndex);
5009 } 5009 }
5010 5010
5011 // Returns true if the vector isn't yet installed.
Michael Starzinger 2017/01/11 13:22:44 nit: Comment no longer applies (I would be fine wi
mvstanton 2017/01/11 14:52:06 Done.
5012 inline bool has_feedback_vector() const;
5011 inline TypeFeedbackVector* feedback_vector() const; 5013 inline TypeFeedbackVector* feedback_vector() const;
5012 inline void set_feedback_vector(TypeFeedbackVector* vector); 5014 inline void set_feedback_vector(TypeFeedbackVector* vector);
5015
5013 inline Object* literal(int literal_index) const; 5016 inline Object* literal(int literal_index) const;
5014 inline void set_literal(int literal_index, Object* literal); 5017 inline void set_literal(int literal_index, Object* literal);
5015 inline void set_literal_undefined(int literal_index); 5018 inline void set_literal_undefined(int literal_index);
5016 inline int literals_count() const; 5019 inline int literals_count() const;
5017 5020
5018 static Handle<LiteralsArray> New(Isolate* isolate, 5021 static Handle<LiteralsArray> New(Isolate* isolate,
5019 Handle<TypeFeedbackVector> vector, 5022 Handle<TypeFeedbackVector> vector,
5020 int number_of_literals, 5023 int number_of_literals,
5021 PretenureFlag pretenure = TENURED); 5024 PretenureFlag pretenure = TENURED);
5022 5025
(...skipping 2120 matching lines...) Expand 10 before | Expand all | Expand 10 after
7143 kTypedArrayEntries, 7146 kTypedArrayEntries,
7144 kTypedArrayKeys, 7147 kTypedArrayKeys,
7145 kTypedArrayLength, 7148 kTypedArrayLength,
7146 kTypedArrayValues, 7149 kTypedArrayValues,
7147 kSharedArrayBufferByteLength, 7150 kSharedArrayBufferByteLength,
7148 kStringIterator, 7151 kStringIterator,
7149 kStringIteratorNext, 7152 kStringIteratorNext,
7150 }; 7153 };
7151 7154
7152 7155
7153 // Result of searching in an optimized code map of a SharedFunctionInfo. Note
7154 // that both {code} and {literals} can be NULL to pass search result status.
7155 struct CodeAndLiterals {
7156 Code* code; // Cached optimized code.
7157 LiteralsArray* literals; // Cached literals array.
7158 };
7159
7160
7161 // SharedFunctionInfo describes the JSFunction information that can be 7156 // SharedFunctionInfo describes the JSFunction information that can be
7162 // shared by multiple instances of the function. 7157 // shared by multiple instances of the function.
7163 class SharedFunctionInfo: public HeapObject { 7158 class SharedFunctionInfo: public HeapObject {
7164 public: 7159 public:
7165 // [name]: Function name. 7160 // [name]: Function name.
7166 DECL_ACCESSORS(name, Object) 7161 DECL_ACCESSORS(name, Object)
7167 7162
7168 // [code]: Function code. 7163 // [code]: Function code.
7169 DECL_ACCESSORS(code, Code) 7164 DECL_ACCESSORS(code, Code)
7170 7165
(...skipping 10 matching lines...) Expand all
7181 inline bool IsInterpreted() const; 7176 inline bool IsInterpreted() const;
7182 7177
7183 inline void ReplaceCode(Code* code); 7178 inline void ReplaceCode(Code* code);
7184 inline bool HasBaselineCode() const; 7179 inline bool HasBaselineCode() const;
7185 7180
7186 // [optimized_code_map]: Map from native context to optimized code 7181 // [optimized_code_map]: Map from native context to optimized code
7187 // and a shared literals array. 7182 // and a shared literals array.
7188 DECL_ACCESSORS(optimized_code_map, FixedArray) 7183 DECL_ACCESSORS(optimized_code_map, FixedArray)
7189 7184
7190 // Returns entry from optimized code map for specified context and OSR entry. 7185 // Returns entry from optimized code map for specified context and OSR entry.
7191 // Note that {code == nullptr, literals == nullptr} indicates no matching 7186 Code* SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id);
7192 // entry has been found, whereas {code, literals == nullptr} indicates that
7193 // code is context-independent.
7194 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context,
7195 BailoutId osr_ast_id);
7196 7187
7197 // Clear optimized code map. 7188 // Clear optimized code map.
7198 void ClearOptimizedCodeMap(); 7189 void ClearOptimizedCodeMap();
7199 7190
7200 // Like ClearOptimizedCodeMap, but preserves literals. 7191 // Like ClearOptimizedCodeMap, but preserves literals.
7201 void ClearCodeFromOptimizedCodeMap(); 7192 void ClearCodeFromOptimizedCodeMap();
7202 7193
7203 // We have a special root FixedArray with the right shape and values 7194 // We have a special root FixedArray with the right shape and values
7204 // to represent the cleared optimized code map. This predicate checks 7195 // to represent the cleared optimized code map. This predicate checks
7205 // if that root is installed. 7196 // if that root is installed.
7206 inline bool OptimizedCodeMapIsCleared() const; 7197 inline bool OptimizedCodeMapIsCleared() const;
7207 7198
7208 // Removes a specific optimized code object from the optimized code map. 7199 // Removes a specific optimized code object from the optimized code map.
7209 // In case of non-OSR the code reference is cleared from the cache entry but 7200 // In case of non-OSR the code reference is cleared from the cache entry but
7210 // the entry itself is left in the map in order to proceed sharing literals. 7201 // the entry itself is left in the map in order to proceed sharing literals.
7211 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 7202 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
7212 7203
7213 static Handle<LiteralsArray> FindOrCreateLiterals( 7204 static Handle<LiteralsArray> FindOrCreateLiterals(
7214 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); 7205 Handle<SharedFunctionInfo> shared, Handle<Context> native_context);
7215 7206
7216 // Add or update entry in the optimized code map for context-dependent code. 7207 // Add or update entry in the optimized code map for context-dependent code.
7217 // If {code} is not given, then an existing entry's code won't be overwritten.
7218 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 7208 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
7219 Handle<Context> native_context, 7209 Handle<Context> native_context,
7220 MaybeHandle<Code> code, 7210 Handle<Code> code, BailoutId osr_ast_id);
7221 Handle<LiteralsArray> literals,
7222 BailoutId osr_ast_id);
7223 7211
7224 // Set up the link between shared function info and the script. The shared 7212 // Set up the link between shared function info and the script. The shared
7225 // function info is added to the list on the script. 7213 // function info is added to the list on the script.
7226 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, 7214 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared,
7227 Handle<Object> script_object); 7215 Handle<Object> script_object);
7228 7216
7229 // Layout description of the optimized code map. 7217 // Layout description of the optimized code map.
7230 static const int kEntriesStart = 0; 7218 static const int kEntriesStart = 0;
7231 static const int kContextOffset = 0; 7219 static const int kContextOffset = 0;
7232 static const int kCachedCodeOffset = 1; 7220 static const int kCachedCodeOffset = 1;
7233 static const int kLiteralsOffset = 2; 7221 static const int kEntryLength = 2;
7234 static const int kEntryLength = 3;
7235 static const int kInitialLength = kEntriesStart + kEntryLength; 7222 static const int kInitialLength = kEntriesStart + kEntryLength;
7236 7223
7237 static const int kNotFound = -1; 7224 static const int kNotFound = -1;
7238 7225
7239 // Helpers for assembly code that does a backwards walk of the optimized code 7226 // Helpers for assembly code that does a backwards walk of the optimized code
7240 // map. 7227 // map.
7241 static const int kOffsetToPreviousContext = 7228 static const int kOffsetToPreviousContext =
7242 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); 7229 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength);
7243 static const int kOffsetToPreviousCachedCode = 7230 static const int kOffsetToPreviousCachedCode =
7244 FixedArray::kHeaderSize + 7231 FixedArray::kHeaderSize +
7245 kPointerSize * (kCachedCodeOffset - kEntryLength); 7232 kPointerSize * (kCachedCodeOffset - kEntryLength);
7246 static const int kOffsetToPreviousLiterals =
7247 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength);
7248 7233
7249 // [scope_info]: Scope info. 7234 // [scope_info]: Scope info.
7250 DECL_ACCESSORS(scope_info, ScopeInfo) 7235 DECL_ACCESSORS(scope_info, ScopeInfo)
7251 7236
7252 // The outer scope info for the purpose of parsing this function, or the hole 7237 // The outer scope info for the purpose of parsing this function, or the hole
7253 // value if it isn't yet known. 7238 // value if it isn't yet known.
7254 DECL_ACCESSORS(outer_scope_info, HeapObject) 7239 DECL_ACCESSORS(outer_scope_info, HeapObject)
7255 7240
7256 // [construct stub]: Code stub for constructing instances of this function. 7241 // [construct stub]: Code stub for constructing instances of this function.
7257 DECL_ACCESSORS(construct_stub, Code) 7242 DECL_ACCESSORS(construct_stub, Code)
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after
8252 // 8237 //
8253 // If the function contains object, regexp or array literals, the 8238 // If the function contains object, regexp or array literals, the
8254 // literals array prefix contains the object, regexp, and array 8239 // literals array prefix contains the object, regexp, and array
8255 // function to be used when creating these literals. This is 8240 // function to be used when creating these literals. This is
8256 // necessary so that we do not dynamically lookup the object, regexp 8241 // necessary so that we do not dynamically lookup the object, regexp
8257 // or array functions. Performing a dynamic lookup, we might end up 8242 // or array functions. Performing a dynamic lookup, we might end up
8258 // using the functions from a new context that we should not have 8243 // using the functions from a new context that we should not have
8259 // access to. For API objects we store the boilerplate in the literal array. 8244 // access to. For API objects we store the boilerplate in the literal array.
8260 DECL_ACCESSORS(literals, LiteralsArray) 8245 DECL_ACCESSORS(literals, LiteralsArray)
8261 8246
8247 inline bool has_literals_array() const;
8262 static void EnsureLiterals(Handle<JSFunction> function); 8248 static void EnsureLiterals(Handle<JSFunction> function);
8263 inline TypeFeedbackVector* feedback_vector(); 8249 inline TypeFeedbackVector* feedback_vector();
8264 8250
8265 // Unconditionally clear the type feedback vector (including vector ICs). 8251 // Unconditionally clear the type feedback vector (including vector ICs).
8266 void ClearTypeFeedbackInfo(); 8252 void ClearTypeFeedbackInfo();
8267 8253
8268 // Clear the type feedback vector with a more subtle policy at GC time. 8254 // Clear the type feedback vector with a more subtle policy at GC time.
8269 void ClearTypeFeedbackInfoAtGCTime(); 8255 void ClearTypeFeedbackInfoAtGCTime();
8270 8256
8271 // The initial map for an object created by this constructor. 8257 // The initial map for an object created by this constructor.
(...skipping 3484 matching lines...) Expand 10 before | Expand all | Expand 10 after
11756 } 11742 }
11757 }; 11743 };
11758 11744
11759 11745
11760 } // NOLINT, false-positive due to second-order macros. 11746 } // NOLINT, false-positive due to second-order macros.
11761 } // NOLINT, false-positive due to second-order macros. 11747 } // NOLINT, false-positive due to second-order macros.
11762 11748
11763 #include "src/objects/object-macros-undef.h" 11749 #include "src/objects/object-macros-undef.h"
11764 11750
11765 #endif // V8_OBJECTS_H_ 11751 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/object-stats.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698