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

Side by Side Diff: src/objects.h

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

Powered by Google App Engine
This is Rietveld 408576698