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

Side by Side Diff: src/objects.h

Issue 2620753003: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: Comments, TODOs. 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.
5012 inline bool needs_feedback_vector() const;
Michael Starzinger 2017/01/11 12:07:27 suggestion: Could we negate this predicate and cal
mvstanton 2017/01/11 13:14:52 Good idea, done.
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. 7208 // If {code} is not given, then an existing entry's code won't be overwritten.
7218 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 7209 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
7219 Handle<Context> native_context, 7210 Handle<Context> native_context,
7220 MaybeHandle<Code> code, 7211 MaybeHandle<Code> code,
Michael Starzinger 2017/01/11 12:07:27 Is there still a call-site left that does not pass
mvstanton 2017/01/11 13:14:52 Good idea, done!
7221 Handle<LiteralsArray> literals,
7222 BailoutId osr_ast_id); 7212 BailoutId osr_ast_id);
7223 7213
7224 // Set up the link between shared function info and the script. The shared 7214 // Set up the link between shared function info and the script. The shared
7225 // function info is added to the list on the script. 7215 // function info is added to the list on the script.
7226 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, 7216 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared,
7227 Handle<Object> script_object); 7217 Handle<Object> script_object);
7228 7218
7229 // Layout description of the optimized code map. 7219 // Layout description of the optimized code map.
7230 static const int kEntriesStart = 0; 7220 static const int kEntriesStart = 0;
7231 static const int kContextOffset = 0; 7221 static const int kContextOffset = 0;
7232 static const int kCachedCodeOffset = 1; 7222 static const int kCachedCodeOffset = 1;
7233 static const int kLiteralsOffset = 2; 7223 static const int kEntryLength = 2;
7234 static const int kEntryLength = 3;
7235 static const int kInitialLength = kEntriesStart + kEntryLength; 7224 static const int kInitialLength = kEntriesStart + kEntryLength;
7236 7225
7237 static const int kNotFound = -1; 7226 static const int kNotFound = -1;
7238 7227
7239 // Helpers for assembly code that does a backwards walk of the optimized code 7228 // Helpers for assembly code that does a backwards walk of the optimized code
7240 // map. 7229 // map.
7241 static const int kOffsetToPreviousContext = 7230 static const int kOffsetToPreviousContext =
7242 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); 7231 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength);
7243 static const int kOffsetToPreviousCachedCode = 7232 static const int kOffsetToPreviousCachedCode =
7244 FixedArray::kHeaderSize + 7233 FixedArray::kHeaderSize +
7245 kPointerSize * (kCachedCodeOffset - kEntryLength); 7234 kPointerSize * (kCachedCodeOffset - kEntryLength);
7246 static const int kOffsetToPreviousLiterals =
7247 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength);
7248 7235
7249 // [scope_info]: Scope info. 7236 // [scope_info]: Scope info.
7250 DECL_ACCESSORS(scope_info, ScopeInfo) 7237 DECL_ACCESSORS(scope_info, ScopeInfo)
7251 7238
7252 // The outer scope info for the purpose of parsing this function, or the hole 7239 // The outer scope info for the purpose of parsing this function, or the hole
7253 // value if it isn't yet known. 7240 // value if it isn't yet known.
7254 DECL_ACCESSORS(outer_scope_info, HeapObject) 7241 DECL_ACCESSORS(outer_scope_info, HeapObject)
7255 7242
7256 // [construct stub]: Code stub for constructing instances of this function. 7243 // [construct stub]: Code stub for constructing instances of this function.
7257 DECL_ACCESSORS(construct_stub, Code) 7244 DECL_ACCESSORS(construct_stub, Code)
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
8376 static const int kSharedFunctionInfoOffset = 8363 static const int kSharedFunctionInfoOffset =
8377 kPrototypeOrInitialMapOffset + kPointerSize; 8364 kPrototypeOrInitialMapOffset + kPointerSize;
8378 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; 8365 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
8379 static const int kLiteralsOffset = kContextOffset + kPointerSize; 8366 static const int kLiteralsOffset = kContextOffset + kPointerSize;
8380 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; 8367 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
8381 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset; 8368 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset;
8382 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize; 8369 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize;
8383 static const int kSize = kNextFunctionLinkOffset + kPointerSize; 8370 static const int kSize = kNextFunctionLinkOffset + kPointerSize;
8384 8371
8385 private: 8372 private:
8373 inline bool needs_literals_array() const;
Michael Starzinger 2017/01/11 12:07:27 suggestion: Likewise, I propose changing to "has_l
mvstanton 2017/01/11 13:14:52 Done.
8374
8386 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); 8375 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
8387 }; 8376 };
8388 8377
8389 8378
8390 // JSGlobalProxy's prototype must be a JSGlobalObject or null, 8379 // JSGlobalProxy's prototype must be a JSGlobalObject or null,
8391 // and the prototype is hidden. JSGlobalProxy always delegates 8380 // and the prototype is hidden. JSGlobalProxy always delegates
8392 // property accesses to its prototype if the prototype is not null. 8381 // property accesses to its prototype if the prototype is not null.
8393 // 8382 //
8394 // A JSGlobalProxy can be reinitialized which will preserve its identity. 8383 // A JSGlobalProxy can be reinitialized which will preserve its identity.
8395 // 8384 //
(...skipping 3360 matching lines...) Expand 10 before | Expand all | Expand 10 after
11756 } 11745 }
11757 }; 11746 };
11758 11747
11759 11748
11760 } // NOLINT, false-positive due to second-order macros. 11749 } // NOLINT, false-positive due to second-order macros.
11761 } // NOLINT, false-positive due to second-order macros. 11750 } // NOLINT, false-positive due to second-order macros.
11762 11751
11763 #include "src/objects/object-macros-undef.h" 11752 #include "src/objects/object-macros-undef.h"
11764 11753
11765 #endif // V8_OBJECTS_H_ 11754 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap/object-stats.cc ('k') | src/objects.cc » ('j') | src/objects-printer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698