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

Side by Side Diff: src/objects.h

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