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

Side by Side Diff: src/objects.h

Issue 2504153002: [TypeFeedbackVector] Root literal arrays in function literals slots (Closed)
Patch Set: REBASE. Created 4 years 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
« no previous file with comments | « src/mips64/interface-descriptors-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4979 matching lines...) Expand 10 before | Expand all | Expand 10 after
4990 public: 4990 public:
4991 static const int kVectorIndex = 0; 4991 static const int kVectorIndex = 0;
4992 static const int kFirstLiteralIndex = 1; 4992 static const int kFirstLiteralIndex = 1;
4993 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; 4993 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset;
4994 static const int kOffsetToFirstLiteral; 4994 static const int kOffsetToFirstLiteral;
4995 4995
4996 static int OffsetOfLiteralAt(int index) { 4996 static int OffsetOfLiteralAt(int index) {
4997 return OffsetOfElementAt(index + kFirstLiteralIndex); 4997 return OffsetOfElementAt(index + kFirstLiteralIndex);
4998 } 4998 }
4999 4999
5000 // Returns true if the vector isn't yet installed.
5001 inline bool needs_feedback_vector() const;
5000 inline TypeFeedbackVector* feedback_vector() const; 5002 inline TypeFeedbackVector* feedback_vector() const;
5001 inline void set_feedback_vector(TypeFeedbackVector* vector); 5003 inline void set_feedback_vector(TypeFeedbackVector* vector);
5004
5002 inline Object* literal(int literal_index) const; 5005 inline Object* literal(int literal_index) const;
5003 inline void set_literal(int literal_index, Object* literal); 5006 inline void set_literal(int literal_index, Object* literal);
5004 inline void set_literal_undefined(int literal_index); 5007 inline void set_literal_undefined(int literal_index);
5005 inline int literals_count() const; 5008 inline int literals_count() const;
5006 5009
5007 static Handle<LiteralsArray> New(Isolate* isolate, 5010 static Handle<LiteralsArray> New(Isolate* isolate,
5008 Handle<TypeFeedbackVector> vector, 5011 Handle<TypeFeedbackVector> vector,
5009 int number_of_literals, 5012 int number_of_literals,
5010 PretenureFlag pretenure = TENURED); 5013 PretenureFlag pretenure = TENURED);
5011 5014
(...skipping 2106 matching lines...) Expand 10 before | Expand all | Expand 10 after
7118 kTypedArrayEntries, 7121 kTypedArrayEntries,
7119 kTypedArrayKeys, 7122 kTypedArrayKeys,
7120 kTypedArrayLength, 7123 kTypedArrayLength,
7121 kTypedArrayValues, 7124 kTypedArrayValues,
7122 kSharedArrayBufferByteLength, 7125 kSharedArrayBufferByteLength,
7123 kStringIterator, 7126 kStringIterator,
7124 kStringIteratorNext, 7127 kStringIteratorNext,
7125 }; 7128 };
7126 7129
7127 7130
7128 // Result of searching in an optimized code map of a SharedFunctionInfo. Note
7129 // that both {code} and {literals} can be NULL to pass search result status.
7130 struct CodeAndLiterals {
7131 Code* code; // Cached optimized code.
7132 LiteralsArray* literals; // Cached literals array.
7133 };
7134
7135
7136 // SharedFunctionInfo describes the JSFunction information that can be 7131 // SharedFunctionInfo describes the JSFunction information that can be
7137 // shared by multiple instances of the function. 7132 // shared by multiple instances of the function.
7138 class SharedFunctionInfo: public HeapObject { 7133 class SharedFunctionInfo: public HeapObject {
7139 public: 7134 public:
7140 // [name]: Function name. 7135 // [name]: Function name.
7141 DECL_ACCESSORS(name, Object) 7136 DECL_ACCESSORS(name, Object)
7142 7137
7143 // [code]: Function code. 7138 // [code]: Function code.
7144 DECL_ACCESSORS(code, Code) 7139 DECL_ACCESSORS(code, Code)
7145 7140
(...skipping 10 matching lines...) Expand all
7156 inline bool IsInterpreted() const; 7151 inline bool IsInterpreted() const;
7157 7152
7158 inline void ReplaceCode(Code* code); 7153 inline void ReplaceCode(Code* code);
7159 inline bool HasBaselineCode() const; 7154 inline bool HasBaselineCode() const;
7160 7155
7161 // [optimized_code_map]: Map from native context to optimized code 7156 // [optimized_code_map]: Map from native context to optimized code
7162 // and a shared literals array. 7157 // and a shared literals array.
7163 DECL_ACCESSORS(optimized_code_map, FixedArray) 7158 DECL_ACCESSORS(optimized_code_map, FixedArray)
7164 7159
7165 // Returns entry from optimized code map for specified context and OSR entry. 7160 // Returns entry from optimized code map for specified context and OSR entry.
7166 // Note that {code == nullptr, literals == nullptr} indicates no matching 7161 Code* SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id);
7167 // entry has been found, whereas {code, literals == nullptr} indicates that
7168 // code is context-independent.
7169 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context,
7170 BailoutId osr_ast_id);
7171 7162
7172 // Clear optimized code map. 7163 // Clear optimized code map.
7173 void ClearOptimizedCodeMap(); 7164 void ClearOptimizedCodeMap();
7174 7165
7175 // Like ClearOptimizedCodeMap, but preserves literals. 7166 // Like ClearOptimizedCodeMap, but preserves literals.
7176 void ClearCodeFromOptimizedCodeMap(); 7167 void ClearCodeFromOptimizedCodeMap();
7177 7168
7178 // We have a special root FixedArray with the right shape and values 7169 // We have a special root FixedArray with the right shape and values
7179 // to represent the cleared optimized code map. This predicate checks 7170 // to represent the cleared optimized code map. This predicate checks
7180 // if that root is installed. 7171 // if that root is installed.
7181 inline bool OptimizedCodeMapIsCleared() const; 7172 inline bool OptimizedCodeMapIsCleared() const;
7182 7173
7183 // Removes a specific optimized code object from the optimized code map. 7174 // Removes a specific optimized code object from the optimized code map.
7184 // In case of non-OSR the code reference is cleared from the cache entry but 7175 // In case of non-OSR the code reference is cleared from the cache entry but
7185 // the entry itself is left in the map in order to proceed sharing literals. 7176 // the entry itself is left in the map in order to proceed sharing literals.
7186 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 7177 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
7187 7178
7188 static Handle<LiteralsArray> FindOrCreateLiterals( 7179 static Handle<LiteralsArray> FindOrCreateLiterals(
7189 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); 7180 Handle<SharedFunctionInfo> shared, Handle<Context> native_context);
7190 7181
7191 // Add or update entry in the optimized code map for context-dependent code. 7182 // Add or update entry in the optimized code map for context-dependent code.
7192 // If {code} is not given, then an existing entry's code won't be overwritten. 7183 // If {code} is not given, then an existing entry's code won't be overwritten.
7193 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 7184 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
7194 Handle<Context> native_context, 7185 Handle<Context> native_context,
7195 MaybeHandle<Code> code, 7186 MaybeHandle<Code> code,
7196 Handle<LiteralsArray> literals,
7197 BailoutId osr_ast_id); 7187 BailoutId osr_ast_id);
7198 7188
7199 // Set up the link between shared function info and the script. The shared 7189 // Set up the link between shared function info and the script. The shared
7200 // function info is added to the list on the script. 7190 // function info is added to the list on the script.
7201 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, 7191 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared,
7202 Handle<Object> script_object); 7192 Handle<Object> script_object);
7203 7193
7204 // Layout description of the optimized code map. 7194 // Layout description of the optimized code map.
7205 static const int kEntriesStart = 0; 7195 static const int kEntriesStart = 0;
7206 static const int kContextOffset = 0; 7196 static const int kContextOffset = 0;
7207 static const int kCachedCodeOffset = 1; 7197 static const int kCachedCodeOffset = 1;
7208 static const int kLiteralsOffset = 2; 7198 static const int kEntryLength = 2;
7209 static const int kEntryLength = 3;
7210 static const int kInitialLength = kEntriesStart + kEntryLength; 7199 static const int kInitialLength = kEntriesStart + kEntryLength;
7211 7200
7212 static const int kNotFound = -1; 7201 static const int kNotFound = -1;
7213 7202
7214 // Helpers for assembly code that does a backwards walk of the optimized code 7203 // Helpers for assembly code that does a backwards walk of the optimized code
7215 // map. 7204 // map.
7216 static const int kOffsetToPreviousContext = 7205 static const int kOffsetToPreviousContext =
7217 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); 7206 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength);
7218 static const int kOffsetToPreviousCachedCode = 7207 static const int kOffsetToPreviousCachedCode =
7219 FixedArray::kHeaderSize + 7208 FixedArray::kHeaderSize +
7220 kPointerSize * (kCachedCodeOffset - kEntryLength); 7209 kPointerSize * (kCachedCodeOffset - kEntryLength);
7221 static const int kOffsetToPreviousLiterals =
7222 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength);
7223 7210
7224 // [scope_info]: Scope info. 7211 // [scope_info]: Scope info.
7225 DECL_ACCESSORS(scope_info, ScopeInfo) 7212 DECL_ACCESSORS(scope_info, ScopeInfo)
7226 7213
7227 // The outer scope info for the purpose of parsing this function, or the hole 7214 // The outer scope info for the purpose of parsing this function, or the hole
7228 // value if it isn't yet known. 7215 // value if it isn't yet known.
7229 DECL_ACCESSORS(outer_scope_info, HeapObject) 7216 DECL_ACCESSORS(outer_scope_info, HeapObject)
7230 7217
7231 // [construct stub]: Code stub for constructing instances of this function. 7218 // [construct stub]: Code stub for constructing instances of this function.
7232 DECL_ACCESSORS(construct_stub, Code) 7219 DECL_ACCESSORS(construct_stub, Code)
(...skipping 1126 matching lines...) Expand 10 before | Expand all | Expand 10 after
8359 static const int kSharedFunctionInfoOffset = 8346 static const int kSharedFunctionInfoOffset =
8360 kPrototypeOrInitialMapOffset + kPointerSize; 8347 kPrototypeOrInitialMapOffset + kPointerSize;
8361 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; 8348 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
8362 static const int kLiteralsOffset = kContextOffset + kPointerSize; 8349 static const int kLiteralsOffset = kContextOffset + kPointerSize;
8363 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; 8350 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
8364 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset; 8351 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset;
8365 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize; 8352 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize;
8366 static const int kSize = kNextFunctionLinkOffset + kPointerSize; 8353 static const int kSize = kNextFunctionLinkOffset + kPointerSize;
8367 8354
8368 private: 8355 private:
8356 inline bool needs_literals_array() const;
8357
8369 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); 8358 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
8370 }; 8359 };
8371 8360
8372 8361
8373 // JSGlobalProxy's prototype must be a JSGlobalObject or null, 8362 // JSGlobalProxy's prototype must be a JSGlobalObject or null,
8374 // and the prototype is hidden. JSGlobalProxy always delegates 8363 // and the prototype is hidden. JSGlobalProxy always delegates
8375 // property accesses to its prototype if the prototype is not null. 8364 // property accesses to its prototype if the prototype is not null.
8376 // 8365 //
8377 // A JSGlobalProxy can be reinitialized which will preserve its identity. 8366 // A JSGlobalProxy can be reinitialized which will preserve its identity.
8378 // 8367 //
(...skipping 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after
11706 } 11695 }
11707 }; 11696 };
11708 11697
11709 11698
11710 } // NOLINT, false-positive due to second-order macros. 11699 } // NOLINT, false-positive due to second-order macros.
11711 } // NOLINT, false-positive due to second-order macros. 11700 } // NOLINT, false-positive due to second-order macros.
11712 11701
11713 #include "src/objects/object-macros-undef.h" 11702 #include "src/objects/object-macros-undef.h"
11714 11703
11715 #endif // V8_OBJECTS_H_ 11704 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/interface-descriptors-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698