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

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
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 5292 matching lines...) Expand 10 before | Expand all | Expand 10 after
5303 public: 5303 public:
5304 static const int kVectorIndex = 0; 5304 static const int kVectorIndex = 0;
5305 static const int kFirstLiteralIndex = 1; 5305 static const int kFirstLiteralIndex = 1;
5306 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset; 5306 V8_EXPORT_PRIVATE static const int kFeedbackVectorOffset;
5307 static const int kOffsetToFirstLiteral; 5307 static const int kOffsetToFirstLiteral;
5308 5308
5309 static int OffsetOfLiteralAt(int index) { 5309 static int OffsetOfLiteralAt(int index) {
5310 return OffsetOfElementAt(index + kFirstLiteralIndex); 5310 return OffsetOfElementAt(index + kFirstLiteralIndex);
5311 } 5311 }
5312 5312
5313 // Returns true if the vector isn't yet installed.
5314 inline bool needs_feedback_vector() const;
5313 inline TypeFeedbackVector* feedback_vector() const; 5315 inline TypeFeedbackVector* feedback_vector() const;
5314 inline void set_feedback_vector(TypeFeedbackVector* vector); 5316 inline void set_feedback_vector(TypeFeedbackVector* vector);
5317
5315 inline Object* literal(int literal_index) const; 5318 inline Object* literal(int literal_index) const;
5316 inline void set_literal(int literal_index, Object* literal); 5319 inline void set_literal(int literal_index, Object* literal);
5317 inline void set_literal_undefined(int literal_index); 5320 inline void set_literal_undefined(int literal_index);
5318 inline int literals_count() const; 5321 inline int literals_count() const;
5319 5322
5320 static Handle<LiteralsArray> New(Isolate* isolate, 5323 static Handle<LiteralsArray> New(Isolate* isolate,
5321 Handle<TypeFeedbackVector> vector, 5324 Handle<TypeFeedbackVector> vector,
5322 int number_of_literals, 5325 int number_of_literals,
5323 PretenureFlag pretenure = TENURED); 5326 PretenureFlag pretenure = TENURED);
5324 5327
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
7397 kTypedArrayEntries, 7400 kTypedArrayEntries,
7398 kTypedArrayKeys, 7401 kTypedArrayKeys,
7399 kTypedArrayLength, 7402 kTypedArrayLength,
7400 kTypedArrayValues, 7403 kTypedArrayValues,
7401 kSharedArrayBufferByteLength, 7404 kSharedArrayBufferByteLength,
7402 kStringIterator, 7405 kStringIterator,
7403 kStringIteratorNext, 7406 kStringIteratorNext,
7404 }; 7407 };
7405 7408
7406 7409
7407 // Result of searching in an optimized code map of a SharedFunctionInfo. Note
7408 // that both {code} and {literals} can be NULL to pass search result status.
7409 struct CodeAndLiterals {
7410 Code* code; // Cached optimized code.
7411 LiteralsArray* literals; // Cached literals array.
7412 };
7413
7414
7415 // SharedFunctionInfo describes the JSFunction information that can be 7410 // SharedFunctionInfo describes the JSFunction information that can be
7416 // shared by multiple instances of the function. 7411 // shared by multiple instances of the function.
7417 class SharedFunctionInfo: public HeapObject { 7412 class SharedFunctionInfo: public HeapObject {
7418 public: 7413 public:
7419 // [name]: Function name. 7414 // [name]: Function name.
7420 DECL_ACCESSORS(name, Object) 7415 DECL_ACCESSORS(name, Object)
7421 7416
7422 // [code]: Function code. 7417 // [code]: Function code.
7423 DECL_ACCESSORS(code, Code) 7418 DECL_ACCESSORS(code, Code)
7424 7419
(...skipping 10 matching lines...) Expand all
7435 inline bool IsInterpreted() const; 7430 inline bool IsInterpreted() const;
7436 7431
7437 inline void ReplaceCode(Code* code); 7432 inline void ReplaceCode(Code* code);
7438 inline bool HasBaselineCode() const; 7433 inline bool HasBaselineCode() const;
7439 7434
7440 // [optimized_code_map]: Map from native context to optimized code 7435 // [optimized_code_map]: Map from native context to optimized code
7441 // and a shared literals array. 7436 // and a shared literals array.
7442 DECL_ACCESSORS(optimized_code_map, FixedArray) 7437 DECL_ACCESSORS(optimized_code_map, FixedArray)
7443 7438
7444 // Returns entry from optimized code map for specified context and OSR entry. 7439 // Returns entry from optimized code map for specified context and OSR entry.
7445 // Note that {code == nullptr, literals == nullptr} indicates no matching 7440 Code* SearchOptimizedCodeMap(Context* native_context, BailoutId osr_ast_id);
7446 // entry has been found, whereas {code, literals == nullptr} indicates that
7447 // code is context-independent.
7448 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context,
7449 BailoutId osr_ast_id);
7450 7441
7451 // Clear optimized code map. 7442 // Clear optimized code map.
7452 void ClearOptimizedCodeMap(); 7443 void ClearOptimizedCodeMap();
7453 7444
7454 // Like ClearOptimizedCodeMap, but preserves literals. 7445 // Like ClearOptimizedCodeMap, but preserves literals.
7455 void ClearCodeFromOptimizedCodeMap(); 7446 void ClearCodeFromOptimizedCodeMap();
7456 7447
7457 // We have a special root FixedArray with the right shape and values 7448 // We have a special root FixedArray with the right shape and values
7458 // to represent the cleared optimized code map. This predicate checks 7449 // to represent the cleared optimized code map. This predicate checks
7459 // if that root is installed. 7450 // if that root is installed.
7460 inline bool OptimizedCodeMapIsCleared() const; 7451 inline bool OptimizedCodeMapIsCleared() const;
7461 7452
7462 // Removes a specific optimized code object from the optimized code map. 7453 // Removes a specific optimized code object from the optimized code map.
7463 // In case of non-OSR the code reference is cleared from the cache entry but 7454 // In case of non-OSR the code reference is cleared from the cache entry but
7464 // the entry itself is left in the map in order to proceed sharing literals. 7455 // the entry itself is left in the map in order to proceed sharing literals.
7465 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 7456 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
7466 7457
7467 static Handle<LiteralsArray> FindOrCreateLiterals( 7458 static Handle<LiteralsArray> FindOrCreateLiterals(
7468 Handle<SharedFunctionInfo> shared, Handle<Context> native_context); 7459 Handle<SharedFunctionInfo> shared, Handle<Context> native_context);
7469 7460
7470 // Add or update entry in the optimized code map for context-dependent code. 7461 // Add or update entry in the optimized code map for context-dependent code.
7471 // If {code} is not given, then an existing entry's code won't be overwritten. 7462 // If {code} is not given, then an existing entry's code won't be overwritten.
7472 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 7463 static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
7473 Handle<Context> native_context, 7464 Handle<Context> native_context,
7474 MaybeHandle<Code> code, 7465 MaybeHandle<Code> code,
7475 Handle<LiteralsArray> literals,
7476 BailoutId osr_ast_id); 7466 BailoutId osr_ast_id);
7477 7467
7478 // Set up the link between shared function info and the script. The shared 7468 // Set up the link between shared function info and the script. The shared
7479 // function info is added to the list on the script. 7469 // function info is added to the list on the script.
7480 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared, 7470 V8_EXPORT_PRIVATE static void SetScript(Handle<SharedFunctionInfo> shared,
7481 Handle<Object> script_object); 7471 Handle<Object> script_object);
7482 7472
7483 // Layout description of the optimized code map. 7473 // Layout description of the optimized code map.
7484 static const int kEntriesStart = 0; 7474 static const int kEntriesStart = 0;
7485 static const int kContextOffset = 0; 7475 static const int kContextOffset = 0;
7486 static const int kCachedCodeOffset = 1; 7476 static const int kCachedCodeOffset = 1;
7487 static const int kLiteralsOffset = 2; 7477 static const int kEntryLength = 2;
7488 static const int kEntryLength = 3;
7489 static const int kInitialLength = kEntriesStart + kEntryLength; 7478 static const int kInitialLength = kEntriesStart + kEntryLength;
7490 7479
7491 static const int kNotFound = -1; 7480 static const int kNotFound = -1;
7492 7481
7493 // Helpers for assembly code that does a backwards walk of the optimized code 7482 // Helpers for assembly code that does a backwards walk of the optimized code
7494 // map. 7483 // map.
7495 static const int kOffsetToPreviousContext = 7484 static const int kOffsetToPreviousContext =
7496 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength); 7485 FixedArray::kHeaderSize + kPointerSize * (kContextOffset - kEntryLength);
7497 static const int kOffsetToPreviousCachedCode = 7486 static const int kOffsetToPreviousCachedCode =
7498 FixedArray::kHeaderSize + 7487 FixedArray::kHeaderSize +
7499 kPointerSize * (kCachedCodeOffset - kEntryLength); 7488 kPointerSize * (kCachedCodeOffset - kEntryLength);
7500 static const int kOffsetToPreviousLiterals =
7501 FixedArray::kHeaderSize + kPointerSize * (kLiteralsOffset - kEntryLength);
7502 7489
7503 // [scope_info]: Scope info. 7490 // [scope_info]: Scope info.
7504 DECL_ACCESSORS(scope_info, ScopeInfo) 7491 DECL_ACCESSORS(scope_info, ScopeInfo)
7505 7492
7506 // The outer scope info for the purpose of parsing this function, or the hole 7493 // The outer scope info for the purpose of parsing this function, or the hole
7507 // value if it isn't yet known. 7494 // value if it isn't yet known.
7508 DECL_ACCESSORS(outer_scope_info, HeapObject) 7495 DECL_ACCESSORS(outer_scope_info, HeapObject)
7509 7496
7510 // [construct stub]: Code stub for constructing instances of this function. 7497 // [construct stub]: Code stub for constructing instances of this function.
7511 DECL_ACCESSORS(construct_stub, Code) 7498 DECL_ACCESSORS(construct_stub, Code)
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
8626 static const int kSharedFunctionInfoOffset = 8613 static const int kSharedFunctionInfoOffset =
8627 kPrototypeOrInitialMapOffset + kPointerSize; 8614 kPrototypeOrInitialMapOffset + kPointerSize;
8628 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize; 8615 static const int kContextOffset = kSharedFunctionInfoOffset + kPointerSize;
8629 static const int kLiteralsOffset = kContextOffset + kPointerSize; 8616 static const int kLiteralsOffset = kContextOffset + kPointerSize;
8630 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize; 8617 static const int kNonWeakFieldsEndOffset = kLiteralsOffset + kPointerSize;
8631 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset; 8618 static const int kCodeEntryOffset = kNonWeakFieldsEndOffset;
8632 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize; 8619 static const int kNextFunctionLinkOffset = kCodeEntryOffset + kPointerSize;
8633 static const int kSize = kNextFunctionLinkOffset + kPointerSize; 8620 static const int kSize = kNextFunctionLinkOffset + kPointerSize;
8634 8621
8635 private: 8622 private:
8623 inline bool needs_literals_array() const;
8624
8636 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction); 8625 DISALLOW_IMPLICIT_CONSTRUCTORS(JSFunction);
8637 }; 8626 };
8638 8627
8639 8628
8640 // JSGlobalProxy's prototype must be a JSGlobalObject or null, 8629 // JSGlobalProxy's prototype must be a JSGlobalObject or null,
8641 // and the prototype is hidden. JSGlobalProxy always delegates 8630 // and the prototype is hidden. JSGlobalProxy always delegates
8642 // property accesses to its prototype if the prototype is not null. 8631 // property accesses to its prototype if the prototype is not null.
8643 // 8632 //
8644 // A JSGlobalProxy can be reinitialized which will preserve its identity. 8633 // A JSGlobalProxy can be reinitialized which will preserve its identity.
8645 // 8634 //
(...skipping 3350 matching lines...) Expand 10 before | Expand all | Expand 10 after
11996 } 11985 }
11997 return value; 11986 return value;
11998 } 11987 }
11999 }; 11988 };
12000 11989
12001 11990
12002 } // NOLINT, false-positive due to second-order macros. 11991 } // NOLINT, false-positive due to second-order macros.
12003 } // NOLINT, false-positive due to second-order macros. 11992 } // NOLINT, false-positive due to second-order macros.
12004 11993
12005 #endif // V8_OBJECTS_H_ 11994 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698