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

Side by Side Diff: src/objects.h

Issue 1642613002: Reland of Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: %SetCode failed to install literals in cache. Created 4 years, 10 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
« no previous file with comments | « src/mips64/macro-assembler-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 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after
842 class LookupIterator; 842 class LookupIterator;
843 class FieldType; 843 class FieldType;
844 class ObjectHashTable; 844 class ObjectHashTable;
845 class ObjectVisitor; 845 class ObjectVisitor;
846 class PropertyCell; 846 class PropertyCell;
847 class PropertyDescriptor; 847 class PropertyDescriptor;
848 class SafepointEntry; 848 class SafepointEntry;
849 class SharedFunctionInfo; 849 class SharedFunctionInfo;
850 class StringStream; 850 class StringStream;
851 class TypeFeedbackInfo; 851 class TypeFeedbackInfo;
852 class TypeFeedbackMetadata;
852 class TypeFeedbackVector; 853 class TypeFeedbackVector;
853 class WeakCell; 854 class WeakCell;
854 class TransitionArray; 855 class TransitionArray;
855 856
856 857
857 // A template-ized version of the IsXXX functions. 858 // A template-ized version of the IsXXX functions.
858 template <class C> inline bool Is(Object* obj); 859 template <class C> inline bool Is(Object* obj);
859 860
860 #ifdef VERIFY_HEAP 861 #ifdef VERIFY_HEAP
861 #define DECLARE_VERIFIER(Name) void Name##Verify(); 862 #define DECLARE_VERIFIER(Name) void Name##Verify();
(...skipping 3842 matching lines...) Expand 10 before | Expand all | Expand 10 after
4704 #endif 4705 #endif
4705 }; 4706 };
4706 4707
4707 4708
4708 // A literals array contains the literals for a JSFunction. It also holds 4709 // A literals array contains the literals for a JSFunction. It also holds
4709 // the type feedback vector. 4710 // the type feedback vector.
4710 class LiteralsArray : public FixedArray { 4711 class LiteralsArray : public FixedArray {
4711 public: 4712 public:
4712 static const int kVectorIndex = 0; 4713 static const int kVectorIndex = 0;
4713 static const int kFirstLiteralIndex = 1; 4714 static const int kFirstLiteralIndex = 1;
4714 static const int kOffsetToFirstLiteral = 4715 static const int kFeedbackVectorOffset = FixedArray::kHeaderSize;
4715 FixedArray::kHeaderSize + kPointerSize; 4716 static const int kOffsetToFirstLiteral = kFeedbackVectorOffset + kPointerSize;
4716 4717
4717 static int OffsetOfLiteralAt(int index) { 4718 static int OffsetOfLiteralAt(int index) {
4718 return SizeFor(index + kFirstLiteralIndex); 4719 return SizeFor(index + kFirstLiteralIndex);
4719 } 4720 }
4720 4721
4721 inline TypeFeedbackVector* feedback_vector() const; 4722 inline TypeFeedbackVector* feedback_vector() const;
4722 inline void set_feedback_vector(TypeFeedbackVector* vector); 4723 inline void set_feedback_vector(TypeFeedbackVector* vector);
4723 inline Object* literal(int literal_index) const; 4724 inline Object* literal(int literal_index) const;
4724 inline void set_literal(int literal_index, Object* literal); 4725 inline void set_literal(int literal_index, Object* literal);
4726 inline void set_literal_undefined(int literal_index);
4725 inline int literals_count() const; 4727 inline int literals_count() const;
4726 4728
4727 static Handle<LiteralsArray> New(Isolate* isolate, 4729 static Handle<LiteralsArray> New(Isolate* isolate,
4728 Handle<TypeFeedbackVector> vector, 4730 Handle<TypeFeedbackVector> vector,
4729 int number_of_literals, 4731 int number_of_literals,
4730 PretenureFlag pretenure); 4732 PretenureFlag pretenure);
4731 4733
4732 DECLARE_CAST(LiteralsArray) 4734 DECLARE_CAST(LiteralsArray)
4733 4735
4734 private: 4736 private:
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after
6534 // Returns entry from optimized code map for specified context and OSR entry. 6536 // Returns entry from optimized code map for specified context and OSR entry.
6535 // Note that {code == nullptr, literals == nullptr} indicates no matching 6537 // Note that {code == nullptr, literals == nullptr} indicates no matching
6536 // entry has been found, whereas {code, literals == nullptr} indicates that 6538 // entry has been found, whereas {code, literals == nullptr} indicates that
6537 // code is context-independent. 6539 // code is context-independent.
6538 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, 6540 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context,
6539 BailoutId osr_ast_id); 6541 BailoutId osr_ast_id);
6540 6542
6541 // Clear optimized code map. 6543 // Clear optimized code map.
6542 void ClearOptimizedCodeMap(); 6544 void ClearOptimizedCodeMap();
6543 6545
6546 // Like ClearOptimizedCodeMap, but preserves literals.
6547 void ClearCodeFromOptimizedCodeMap();
6548
6544 // We have a special root FixedArray with the right shape and values 6549 // We have a special root FixedArray with the right shape and values
6545 // to represent the cleared optimized code map. This predicate checks 6550 // to represent the cleared optimized code map. This predicate checks
6546 // if that root is installed. 6551 // if that root is installed.
6547 inline bool OptimizedCodeMapIsCleared() const; 6552 inline bool OptimizedCodeMapIsCleared() const;
6548 6553
6549 // Removes a specific optimized code object from the optimized code map. 6554 // Removes a specific optimized code object from the optimized code map.
6550 // In case of non-OSR the code reference is cleared from the cache entry but 6555 // In case of non-OSR the code reference is cleared from the cache entry but
6551 // the entry itself is left in the map in order to proceed sharing literals. 6556 // the entry itself is left in the map in order to proceed sharing literals.
6552 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 6557 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
6553 6558
6554 // Trims the optimized code map after entries have been removed. 6559 // Trims the optimized code map after entries have been removed.
6555 void TrimOptimizedCodeMap(int shrink_by); 6560 void TrimOptimizedCodeMap(int shrink_by);
6556 6561
6562 static Handle<LiteralsArray> FindOrCreateLiterals(
6563 Handle<SharedFunctionInfo> shared, Handle<Context> native_context);
6564
6557 // Add a new entry to the optimized code map for context-independent code. 6565 // Add a new entry to the optimized code map for context-independent code.
6558 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6566 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6559 Handle<Code> code); 6567 Handle<Code> code);
6560 6568
6561 // Add a new entry to the optimized code map for context-dependent code. 6569 // Add a new entry to the optimized code map for context-dependent code.
6562 inline static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6570 inline static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6563 Handle<Context> native_context, 6571 Handle<Context> native_context,
6564 Handle<Code> code, 6572 Handle<Code> code,
6565 Handle<LiteralsArray> literals, 6573 Handle<LiteralsArray> literals,
6566 BailoutId osr_ast_id); 6574 BailoutId osr_ast_id);
(...skipping 14 matching lines...) Expand all
6581 static const int kEntriesStart = 1; 6589 static const int kEntriesStart = 1;
6582 static const int kContextOffset = 0; 6590 static const int kContextOffset = 0;
6583 static const int kCachedCodeOffset = 1; 6591 static const int kCachedCodeOffset = 1;
6584 static const int kLiteralsOffset = 2; 6592 static const int kLiteralsOffset = 2;
6585 static const int kOsrAstIdOffset = 3; 6593 static const int kOsrAstIdOffset = 3;
6586 static const int kEntryLength = 4; 6594 static const int kEntryLength = 4;
6587 static const int kInitialLength = kEntriesStart + kEntryLength; 6595 static const int kInitialLength = kEntriesStart + kEntryLength;
6588 6596
6589 static const int kNotFound = -1; 6597 static const int kNotFound = -1;
6590 6598
6599 // Helpers for assembly code that does a backwards walk of the optimized code
6600 // map.
6601 static inline int OffsetToPreviousContext();
6602 static inline int OffsetToPreviousCachedCode();
6603 static inline int OffsetToPreviousLiterals();
6604 static inline int OffsetToPreviousOsrAstId();
6605
6591 // [scope_info]: Scope info. 6606 // [scope_info]: Scope info.
6592 DECL_ACCESSORS(scope_info, ScopeInfo) 6607 DECL_ACCESSORS(scope_info, ScopeInfo)
6593 6608
6594 // [construct stub]: Code stub for constructing instances of this function. 6609 // [construct stub]: Code stub for constructing instances of this function.
6595 DECL_ACCESSORS(construct_stub, Code) 6610 DECL_ACCESSORS(construct_stub, Code)
6596 6611
6597 // Returns if this function has been compiled to native code yet. 6612 // Returns if this function has been compiled to native code yet.
6598 inline bool is_compiled(); 6613 inline bool is_compiled();
6599 6614
6600 // [length]: The function length - usually the number of declared parameters. 6615 // [length]: The function length - usually the number of declared parameters.
6601 // Use up to 2^30 parameters. 6616 // Use up to 2^30 parameters.
6602 inline int length() const; 6617 inline int length() const;
6603 inline void set_length(int value); 6618 inline void set_length(int value);
6604 6619
6605 // [internal formal parameter count]: The declared number of parameters. 6620 // [internal formal parameter count]: The declared number of parameters.
6606 // For subclass constructors, also includes new.target. 6621 // For subclass constructors, also includes new.target.
6607 // The size of function's frame is internal_formal_parameter_count + 1. 6622 // The size of function's frame is internal_formal_parameter_count + 1.
6608 inline int internal_formal_parameter_count() const; 6623 inline int internal_formal_parameter_count() const;
6609 inline void set_internal_formal_parameter_count(int value); 6624 inline void set_internal_formal_parameter_count(int value);
6610 6625
6611 // Set the formal parameter count so the function code will be 6626 // Set the formal parameter count so the function code will be
6612 // called without using argument adaptor frames. 6627 // called without using argument adaptor frames.
6613 inline void DontAdaptArguments(); 6628 inline void DontAdaptArguments();
6614 6629
6615 // [expected_nof_properties]: Expected number of properties for the function. 6630 // [expected_nof_properties]: Expected number of properties for the function.
6616 inline int expected_nof_properties() const; 6631 inline int expected_nof_properties() const;
6617 inline void set_expected_nof_properties(int value); 6632 inline void set_expected_nof_properties(int value);
6618 6633
6619 // [feedback_vector] - accumulates ast node feedback from full-codegen and 6634 // [feedback_metadata] - describes ast node feedback from full-codegen and
6620 // (increasingly) from crankshafted code where sufficient feedback isn't 6635 // (increasingly) from crankshafted code where sufficient feedback isn't
6621 // available. 6636 // available.
6622 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector) 6637 DECL_ACCESSORS(feedback_metadata, TypeFeedbackMetadata)
6623
6624 // Unconditionally clear the type feedback vector (including vector ICs).
6625 void ClearTypeFeedbackInfo();
6626
6627 // Clear the type feedback vector with a more subtle policy at GC time.
6628 void ClearTypeFeedbackInfoAtGCTime();
6629 6638
6630 #if TRACE_MAPS 6639 #if TRACE_MAPS
6631 // [unique_id] - For --trace-maps purposes, an identifier that's persistent 6640 // [unique_id] - For --trace-maps purposes, an identifier that's persistent
6632 // even if the GC moves this SharedFunctionInfo. 6641 // even if the GC moves this SharedFunctionInfo.
6633 inline int unique_id() const; 6642 inline int unique_id() const;
6634 inline void set_unique_id(int value); 6643 inline void set_unique_id(int value);
6635 #endif 6644 #endif
6636 6645
6637 // [instance class name]: class name for instances. 6646 // [instance class name]: class name for instances.
6638 DECL_ACCESSORS(instance_class_name, Object) 6647 DECL_ACCESSORS(instance_class_name, Object)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6912 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; 6921 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize;
6913 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; 6922 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize;
6914 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; 6923 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize;
6915 static const int kInstanceClassNameOffset = 6924 static const int kInstanceClassNameOffset =
6916 kConstructStubOffset + kPointerSize; 6925 kConstructStubOffset + kPointerSize;
6917 static const int kFunctionDataOffset = 6926 static const int kFunctionDataOffset =
6918 kInstanceClassNameOffset + kPointerSize; 6927 kInstanceClassNameOffset + kPointerSize;
6919 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; 6928 static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
6920 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; 6929 static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
6921 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; 6930 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
6922 static const int kFeedbackVectorOffset = 6931 static const int kFeedbackMetadataOffset = kInferredNameOffset + kPointerSize;
6923 kInferredNameOffset + kPointerSize;
6924 #if TRACE_MAPS 6932 #if TRACE_MAPS
6925 static const int kUniqueIdOffset = kFeedbackVectorOffset + kPointerSize; 6933 static const int kUniqueIdOffset = kFeedbackMetadataOffset + kPointerSize;
6926 static const int kLastPointerFieldOffset = kUniqueIdOffset; 6934 static const int kLastPointerFieldOffset = kUniqueIdOffset;
6927 #else 6935 #else
6928 // Just to not break the postmortrem support with conditional offsets 6936 // Just to not break the postmortrem support with conditional offsets
6929 static const int kUniqueIdOffset = kFeedbackVectorOffset; 6937 static const int kUniqueIdOffset = kFeedbackMetadataOffset;
6930 static const int kLastPointerFieldOffset = kFeedbackVectorOffset; 6938 static const int kLastPointerFieldOffset = kFeedbackMetadataOffset;
6931 #endif 6939 #endif
6932 6940
6933 #if V8_HOST_ARCH_32_BIT 6941 #if V8_HOST_ARCH_32_BIT
6934 // Smi fields. 6942 // Smi fields.
6935 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; 6943 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize;
6936 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; 6944 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize;
6937 static const int kExpectedNofPropertiesOffset = 6945 static const int kExpectedNofPropertiesOffset =
6938 kFormalParameterCountOffset + kPointerSize; 6946 kFormalParameterCountOffset + kPointerSize;
6939 static const int kNumLiteralsOffset = 6947 static const int kNumLiteralsOffset =
6940 kExpectedNofPropertiesOffset + kPointerSize; 6948 kExpectedNofPropertiesOffset + kPointerSize;
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
7337 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function); 7345 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function);
7338 7346
7339 // [code]: The generated code object for this function. Executed 7347 // [code]: The generated code object for this function. Executed
7340 // when the function is invoked, e.g. foo() or new foo(). See 7348 // when the function is invoked, e.g. foo() or new foo(). See
7341 // [[Call]] and [[Construct]] description in ECMA-262, section 7349 // [[Call]] and [[Construct]] description in ECMA-262, section
7342 // 8.6.2, page 27. 7350 // 8.6.2, page 27.
7343 inline Code* code(); 7351 inline Code* code();
7344 inline void set_code(Code* code); 7352 inline void set_code(Code* code);
7345 inline void set_code_no_write_barrier(Code* code); 7353 inline void set_code_no_write_barrier(Code* code);
7346 inline void ReplaceCode(Code* code); 7354 inline void ReplaceCode(Code* code);
7355 static void EnsureLiterals(Handle<JSFunction> function);
7347 7356
7348 // Tells whether this function inlines the given shared function info. 7357 // Tells whether this function inlines the given shared function info.
7349 bool Inlines(SharedFunctionInfo* candidate); 7358 bool Inlines(SharedFunctionInfo* candidate);
7350 7359
7351 // Tells whether or not this function has been optimized. 7360 // Tells whether or not this function has been optimized.
7352 inline bool IsOptimized(); 7361 inline bool IsOptimized();
7353 7362
7354 // Mark this function for lazy recompilation. The function will be 7363 // Mark this function for lazy recompilation. The function will be
7355 // recompiled the next time it is executed. 7364 // recompiled the next time it is executed.
7356 void MarkForOptimization(); 7365 void MarkForOptimization();
7357 void AttemptConcurrentOptimization(); 7366 void AttemptConcurrentOptimization();
7358 7367
7359 // Tells whether or not the function is already marked for lazy 7368 // Tells whether or not the function is already marked for lazy
7360 // recompilation. 7369 // recompilation.
7361 inline bool IsMarkedForOptimization(); 7370 inline bool IsMarkedForOptimization();
7362 inline bool IsMarkedForConcurrentOptimization(); 7371 inline bool IsMarkedForConcurrentOptimization();
7363 7372
7364 // Tells whether or not the function is on the concurrent recompilation queue. 7373 // Tells whether or not the function is on the concurrent recompilation queue.
7365 inline bool IsInOptimizationQueue(); 7374 inline bool IsInOptimizationQueue();
7366 7375
7376 // Unconditionally clear the type feedback vector (including vector ICs).
7377 void ClearTypeFeedbackInfo();
7378
7379 // Clear the type feedback vector with a more subtle policy at GC time.
7380 void ClearTypeFeedbackInfoAtGCTime();
7381
7367 // Completes inobject slack tracking on initial map if it is active. 7382 // Completes inobject slack tracking on initial map if it is active.
7368 inline void CompleteInobjectSlackTrackingIfActive(); 7383 inline void CompleteInobjectSlackTrackingIfActive();
7369 7384
7370 // [literals]: Fixed array holding the materialized literals. 7385 // [literals]: Fixed array holding the materialized literals.
7371 // 7386 //
7372 // If the function contains object, regexp or array literals, the 7387 // If the function contains object, regexp or array literals, the
7373 // literals array prefix contains the object, regexp, and array 7388 // literals array prefix contains the object, regexp, and array
7374 // function to be used when creating these literals. This is 7389 // function to be used when creating these literals. This is
7375 // necessary so that we do not dynamically lookup the object, regexp 7390 // necessary so that we do not dynamically lookup the object, regexp
7376 // or array functions. Performing a dynamic lookup, we might end up 7391 // or array functions. Performing a dynamic lookup, we might end up
7377 // using the functions from a new context that we should not have 7392 // using the functions from a new context that we should not have
7378 // access to. 7393 // access to.
7379 DECL_ACCESSORS(literals, LiteralsArray) 7394 DECL_ACCESSORS(literals, LiteralsArray)
7380 7395
7396 inline TypeFeedbackVector* feedback_vector();
7397
7381 // The initial map for an object created by this constructor. 7398 // The initial map for an object created by this constructor.
7382 inline Map* initial_map(); 7399 inline Map* initial_map();
7383 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, 7400 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
7384 Handle<Object> prototype); 7401 Handle<Object> prototype);
7385 inline bool has_initial_map(); 7402 inline bool has_initial_map();
7386 static void EnsureHasInitialMap(Handle<JSFunction> function); 7403 static void EnsureHasInitialMap(Handle<JSFunction> function);
7387 7404
7388 // Creates a map that matches the constructor's initial map, but with 7405 // Creates a map that matches the constructor's initial map, but with
7389 // [[prototype]] being new.target.prototype. Because new.target can be a 7406 // [[prototype]] being new.target.prototype. Because new.target can be a
7390 // JSProxy, this can call back into JavaScript. 7407 // JSProxy, this can call back into JavaScript.
(...skipping 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after
10778 } 10795 }
10779 return value; 10796 return value;
10780 } 10797 }
10781 }; 10798 };
10782 10799
10783 10800
10784 } // NOLINT, false-positive due to second-order macros. 10801 } // NOLINT, false-positive due to second-order macros.
10785 } // NOLINT, false-positive due to second-order macros. 10802 } // NOLINT, false-positive due to second-order macros.
10786 10803
10787 #endif // V8_OBJECTS_H_ 10804 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/macro-assembler-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698