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

Side by Side Diff: src/objects.h

Issue 1668103002: Type Feedback Vector lives in the closure (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. 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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 class LookupIterator; 843 class LookupIterator;
844 class FieldType; 844 class FieldType;
845 class ObjectHashTable; 845 class ObjectHashTable;
846 class ObjectVisitor; 846 class ObjectVisitor;
847 class PropertyCell; 847 class PropertyCell;
848 class PropertyDescriptor; 848 class PropertyDescriptor;
849 class SafepointEntry; 849 class SafepointEntry;
850 class SharedFunctionInfo; 850 class SharedFunctionInfo;
851 class StringStream; 851 class StringStream;
852 class TypeFeedbackInfo; 852 class TypeFeedbackInfo;
853 class TypeFeedbackMetadata;
853 class TypeFeedbackVector; 854 class TypeFeedbackVector;
854 class WeakCell; 855 class WeakCell;
855 class TransitionArray; 856 class TransitionArray;
856 857
857 858
858 // A template-ized version of the IsXXX functions. 859 // A template-ized version of the IsXXX functions.
859 template <class C> inline bool Is(Object* obj); 860 template <class C> inline bool Is(Object* obj);
860 861
861 #ifdef VERIFY_HEAP 862 #ifdef VERIFY_HEAP
862 #define DECLARE_VERIFIER(Name) void Name##Verify(); 863 #define DECLARE_VERIFIER(Name) void Name##Verify();
(...skipping 3845 matching lines...) Expand 10 before | Expand all | Expand 10 after
4708 #endif 4709 #endif
4709 }; 4710 };
4710 4711
4711 4712
4712 // A literals array contains the literals for a JSFunction. It also holds 4713 // A literals array contains the literals for a JSFunction. It also holds
4713 // the type feedback vector. 4714 // the type feedback vector.
4714 class LiteralsArray : public FixedArray { 4715 class LiteralsArray : public FixedArray {
4715 public: 4716 public:
4716 static const int kVectorIndex = 0; 4717 static const int kVectorIndex = 0;
4717 static const int kFirstLiteralIndex = 1; 4718 static const int kFirstLiteralIndex = 1;
4718 static const int kOffsetToFirstLiteral = 4719 static const int kFeedbackVectorOffset = FixedArray::kHeaderSize;
4719 FixedArray::kHeaderSize + kPointerSize; 4720 static const int kOffsetToFirstLiteral = kFeedbackVectorOffset + kPointerSize;
4720 4721
4721 static int OffsetOfLiteralAt(int index) { 4722 static int OffsetOfLiteralAt(int index) {
4722 return SizeFor(index + kFirstLiteralIndex); 4723 return SizeFor(index + kFirstLiteralIndex);
4723 } 4724 }
4724 4725
4725 inline TypeFeedbackVector* feedback_vector() const; 4726 inline TypeFeedbackVector* feedback_vector() const;
4726 inline void set_feedback_vector(TypeFeedbackVector* vector); 4727 inline void set_feedback_vector(TypeFeedbackVector* vector);
4727 inline Object* literal(int literal_index) const; 4728 inline Object* literal(int literal_index) const;
4728 inline void set_literal(int literal_index, Object* literal); 4729 inline void set_literal(int literal_index, Object* literal);
4730 inline void set_literal_undefined(int literal_index);
4729 inline int literals_count() const; 4731 inline int literals_count() const;
4730 4732
4731 static Handle<LiteralsArray> New(Isolate* isolate, 4733 static Handle<LiteralsArray> New(Isolate* isolate,
4732 Handle<TypeFeedbackVector> vector, 4734 Handle<TypeFeedbackVector> vector,
4733 int number_of_literals, 4735 int number_of_literals,
4734 PretenureFlag pretenure); 4736 PretenureFlag pretenure);
4735 4737
4736 DECLARE_CAST(LiteralsArray) 4738 DECLARE_CAST(LiteralsArray)
4737 4739
4738 private: 4740 private:
(...skipping 1818 matching lines...) Expand 10 before | Expand all | Expand 10 after
6557 // Returns entry from optimized code map for specified context and OSR entry. 6559 // Returns entry from optimized code map for specified context and OSR entry.
6558 // Note that {code == nullptr, literals == nullptr} indicates no matching 6560 // Note that {code == nullptr, literals == nullptr} indicates no matching
6559 // entry has been found, whereas {code, literals == nullptr} indicates that 6561 // entry has been found, whereas {code, literals == nullptr} indicates that
6560 // code is context-independent. 6562 // code is context-independent.
6561 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context, 6563 CodeAndLiterals SearchOptimizedCodeMap(Context* native_context,
6562 BailoutId osr_ast_id); 6564 BailoutId osr_ast_id);
6563 6565
6564 // Clear optimized code map. 6566 // Clear optimized code map.
6565 void ClearOptimizedCodeMap(); 6567 void ClearOptimizedCodeMap();
6566 6568
6569 // Like ClearOptimizedCodeMap, but preserves literals.
6570 void ClearCodeFromOptimizedCodeMap();
6571
6567 // We have a special root FixedArray with the right shape and values 6572 // We have a special root FixedArray with the right shape and values
6568 // to represent the cleared optimized code map. This predicate checks 6573 // to represent the cleared optimized code map. This predicate checks
6569 // if that root is installed. 6574 // if that root is installed.
6570 inline bool OptimizedCodeMapIsCleared() const; 6575 inline bool OptimizedCodeMapIsCleared() const;
6571 6576
6572 // Removes a specific optimized code object from the optimized code map. 6577 // Removes a specific optimized code object from the optimized code map.
6573 // In case of non-OSR the code reference is cleared from the cache entry but 6578 // In case of non-OSR the code reference is cleared from the cache entry but
6574 // the entry itself is left in the map in order to proceed sharing literals. 6579 // the entry itself is left in the map in order to proceed sharing literals.
6575 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason); 6580 void EvictFromOptimizedCodeMap(Code* optimized_code, const char* reason);
6576 6581
6577 // Trims the optimized code map after entries have been removed. 6582 // Trims the optimized code map after entries have been removed.
6578 void TrimOptimizedCodeMap(int shrink_by); 6583 void TrimOptimizedCodeMap(int shrink_by);
6579 6584
6585 static Handle<LiteralsArray> FindOrCreateLiterals(
6586 Handle<SharedFunctionInfo> shared, Handle<Context> native_context);
6587
6580 // Add a new entry to the optimized code map for context-independent code. 6588 // Add a new entry to the optimized code map for context-independent code.
6581 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6589 static void AddSharedCodeToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6582 Handle<Code> code); 6590 Handle<Code> code);
6583 6591
6584 // Add a new entry to the optimized code map for context-dependent code. 6592 // Add a new entry to the optimized code map for context-dependent code.
6585 inline static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared, 6593 inline static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
6586 Handle<Context> native_context, 6594 Handle<Context> native_context,
6587 Handle<Code> code, 6595 Handle<Code> code,
6588 Handle<LiteralsArray> literals, 6596 Handle<LiteralsArray> literals,
6589 BailoutId osr_ast_id); 6597 BailoutId osr_ast_id);
(...skipping 14 matching lines...) Expand all
6604 static const int kEntriesStart = 1; 6612 static const int kEntriesStart = 1;
6605 static const int kContextOffset = 0; 6613 static const int kContextOffset = 0;
6606 static const int kCachedCodeOffset = 1; 6614 static const int kCachedCodeOffset = 1;
6607 static const int kLiteralsOffset = 2; 6615 static const int kLiteralsOffset = 2;
6608 static const int kOsrAstIdOffset = 3; 6616 static const int kOsrAstIdOffset = 3;
6609 static const int kEntryLength = 4; 6617 static const int kEntryLength = 4;
6610 static const int kInitialLength = kEntriesStart + kEntryLength; 6618 static const int kInitialLength = kEntriesStart + kEntryLength;
6611 6619
6612 static const int kNotFound = -1; 6620 static const int kNotFound = -1;
6613 6621
6622 // Helpers for assembly code that does a backwards walk of the optimized code
6623 // map.
6624 static inline int OffsetToPreviousContext();
6625 static inline int OffsetToPreviousCachedCode();
6626 static inline int OffsetToPreviousLiterals();
6627 static inline int OffsetToPreviousOsrAstId();
6628
6614 // [scope_info]: Scope info. 6629 // [scope_info]: Scope info.
6615 DECL_ACCESSORS(scope_info, ScopeInfo) 6630 DECL_ACCESSORS(scope_info, ScopeInfo)
6616 6631
6617 // [construct stub]: Code stub for constructing instances of this function. 6632 // [construct stub]: Code stub for constructing instances of this function.
6618 DECL_ACCESSORS(construct_stub, Code) 6633 DECL_ACCESSORS(construct_stub, Code)
6619 6634
6620 // Returns if this function has been compiled to native code yet. 6635 // Returns if this function has been compiled to native code yet.
6621 inline bool is_compiled(); 6636 inline bool is_compiled();
6622 6637
6623 // [length]: The function length - usually the number of declared parameters. 6638 // [length]: The function length - usually the number of declared parameters.
6624 // Use up to 2^30 parameters. 6639 // Use up to 2^30 parameters.
6625 inline int length() const; 6640 inline int length() const;
6626 inline void set_length(int value); 6641 inline void set_length(int value);
6627 6642
6628 // [internal formal parameter count]: The declared number of parameters. 6643 // [internal formal parameter count]: The declared number of parameters.
6629 // For subclass constructors, also includes new.target. 6644 // For subclass constructors, also includes new.target.
6630 // The size of function's frame is internal_formal_parameter_count + 1. 6645 // The size of function's frame is internal_formal_parameter_count + 1.
6631 inline int internal_formal_parameter_count() const; 6646 inline int internal_formal_parameter_count() const;
6632 inline void set_internal_formal_parameter_count(int value); 6647 inline void set_internal_formal_parameter_count(int value);
6633 6648
6634 // Set the formal parameter count so the function code will be 6649 // Set the formal parameter count so the function code will be
6635 // called without using argument adaptor frames. 6650 // called without using argument adaptor frames.
6636 inline void DontAdaptArguments(); 6651 inline void DontAdaptArguments();
6637 6652
6638 // [expected_nof_properties]: Expected number of properties for the function. 6653 // [expected_nof_properties]: Expected number of properties for the function.
6639 inline int expected_nof_properties() const; 6654 inline int expected_nof_properties() const;
6640 inline void set_expected_nof_properties(int value); 6655 inline void set_expected_nof_properties(int value);
6641 6656
6642 // [feedback_vector] - accumulates ast node feedback from full-codegen and 6657 // [feedback_metadata] - describes ast node feedback from full-codegen and
6643 // (increasingly) from crankshafted code where sufficient feedback isn't 6658 // (increasingly) from crankshafted code where sufficient feedback isn't
6644 // available. 6659 // available.
6645 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector) 6660 DECL_ACCESSORS(feedback_metadata, TypeFeedbackMetadata)
6646
6647 // Unconditionally clear the type feedback vector (including vector ICs).
6648 void ClearTypeFeedbackInfo();
6649
6650 // Clear the type feedback vector with a more subtle policy at GC time.
6651 void ClearTypeFeedbackInfoAtGCTime();
6652 6661
6653 #if TRACE_MAPS 6662 #if TRACE_MAPS
6654 // [unique_id] - For --trace-maps purposes, an identifier that's persistent 6663 // [unique_id] - For --trace-maps purposes, an identifier that's persistent
6655 // even if the GC moves this SharedFunctionInfo. 6664 // even if the GC moves this SharedFunctionInfo.
6656 inline int unique_id() const; 6665 inline int unique_id() const;
6657 inline void set_unique_id(int value); 6666 inline void set_unique_id(int value);
6658 #endif 6667 #endif
6659 6668
6660 // [instance class name]: class name for instances. 6669 // [instance class name]: class name for instances.
6661 DECL_ACCESSORS(instance_class_name, Object) 6670 DECL_ACCESSORS(instance_class_name, Object)
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
6935 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize; 6944 static const int kOptimizedCodeMapOffset = kCodeOffset + kPointerSize;
6936 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize; 6945 static const int kScopeInfoOffset = kOptimizedCodeMapOffset + kPointerSize;
6937 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize; 6946 static const int kConstructStubOffset = kScopeInfoOffset + kPointerSize;
6938 static const int kInstanceClassNameOffset = 6947 static const int kInstanceClassNameOffset =
6939 kConstructStubOffset + kPointerSize; 6948 kConstructStubOffset + kPointerSize;
6940 static const int kFunctionDataOffset = 6949 static const int kFunctionDataOffset =
6941 kInstanceClassNameOffset + kPointerSize; 6950 kInstanceClassNameOffset + kPointerSize;
6942 static const int kScriptOffset = kFunctionDataOffset + kPointerSize; 6951 static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
6943 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; 6952 static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
6944 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; 6953 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
6945 static const int kFeedbackVectorOffset = 6954 static const int kFeedbackMetadataOffset = kInferredNameOffset + kPointerSize;
6946 kInferredNameOffset + kPointerSize;
6947 #if TRACE_MAPS 6955 #if TRACE_MAPS
6948 static const int kUniqueIdOffset = kFeedbackVectorOffset + kPointerSize; 6956 static const int kUniqueIdOffset = kFeedbackMetadataOffset + kPointerSize;
6949 static const int kLastPointerFieldOffset = kUniqueIdOffset; 6957 static const int kLastPointerFieldOffset = kUniqueIdOffset;
6950 #else 6958 #else
6951 // Just to not break the postmortrem support with conditional offsets 6959 // Just to not break the postmortrem support with conditional offsets
6952 static const int kUniqueIdOffset = kFeedbackVectorOffset; 6960 static const int kUniqueIdOffset = kFeedbackMetadataOffset;
6953 static const int kLastPointerFieldOffset = kFeedbackVectorOffset; 6961 static const int kLastPointerFieldOffset = kFeedbackMetadataOffset;
6954 #endif 6962 #endif
6955 6963
6956 #if V8_HOST_ARCH_32_BIT 6964 #if V8_HOST_ARCH_32_BIT
6957 // Smi fields. 6965 // Smi fields.
6958 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize; 6966 static const int kLengthOffset = kLastPointerFieldOffset + kPointerSize;
6959 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize; 6967 static const int kFormalParameterCountOffset = kLengthOffset + kPointerSize;
6960 static const int kExpectedNofPropertiesOffset = 6968 static const int kExpectedNofPropertiesOffset =
6961 kFormalParameterCountOffset + kPointerSize; 6969 kFormalParameterCountOffset + kPointerSize;
6962 static const int kNumLiteralsOffset = 6970 static const int kNumLiteralsOffset =
6963 kExpectedNofPropertiesOffset + kPointerSize; 6971 kExpectedNofPropertiesOffset + kPointerSize;
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
7364 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function); 7372 static Handle<Context> GetFunctionRealm(Handle<JSFunction> function);
7365 7373
7366 // [code]: The generated code object for this function. Executed 7374 // [code]: The generated code object for this function. Executed
7367 // when the function is invoked, e.g. foo() or new foo(). See 7375 // when the function is invoked, e.g. foo() or new foo(). See
7368 // [[Call]] and [[Construct]] description in ECMA-262, section 7376 // [[Call]] and [[Construct]] description in ECMA-262, section
7369 // 8.6.2, page 27. 7377 // 8.6.2, page 27.
7370 inline Code* code(); 7378 inline Code* code();
7371 inline void set_code(Code* code); 7379 inline void set_code(Code* code);
7372 inline void set_code_no_write_barrier(Code* code); 7380 inline void set_code_no_write_barrier(Code* code);
7373 inline void ReplaceCode(Code* code); 7381 inline void ReplaceCode(Code* code);
7382 static void EnsureLiterals(Handle<JSFunction> function);
7374 7383
7375 // Tells whether this function inlines the given shared function info. 7384 // Tells whether this function inlines the given shared function info.
7376 bool Inlines(SharedFunctionInfo* candidate); 7385 bool Inlines(SharedFunctionInfo* candidate);
7377 7386
7378 // Tells whether or not this function has been optimized. 7387 // Tells whether or not this function has been optimized.
7379 inline bool IsOptimized(); 7388 inline bool IsOptimized();
7380 7389
7381 // Mark this function for lazy recompilation. The function will be 7390 // Mark this function for lazy recompilation. The function will be
7382 // recompiled the next time it is executed. 7391 // recompiled the next time it is executed.
7383 void MarkForOptimization(); 7392 void MarkForOptimization();
7384 void AttemptConcurrentOptimization(); 7393 void AttemptConcurrentOptimization();
7385 7394
7386 // Tells whether or not the function is already marked for lazy 7395 // Tells whether or not the function is already marked for lazy
7387 // recompilation. 7396 // recompilation.
7388 inline bool IsMarkedForOptimization(); 7397 inline bool IsMarkedForOptimization();
7389 inline bool IsMarkedForConcurrentOptimization(); 7398 inline bool IsMarkedForConcurrentOptimization();
7390 7399
7391 // Tells whether or not the function is on the concurrent recompilation queue. 7400 // Tells whether or not the function is on the concurrent recompilation queue.
7392 inline bool IsInOptimizationQueue(); 7401 inline bool IsInOptimizationQueue();
7393 7402
7403 // Unconditionally clear the type feedback vector (including vector ICs).
7404 void ClearTypeFeedbackInfo();
7405
7406 // Clear the type feedback vector with a more subtle policy at GC time.
7407 void ClearTypeFeedbackInfoAtGCTime();
7408
7394 // Completes inobject slack tracking on initial map if it is active. 7409 // Completes inobject slack tracking on initial map if it is active.
7395 inline void CompleteInobjectSlackTrackingIfActive(); 7410 inline void CompleteInobjectSlackTrackingIfActive();
7396 7411
7397 // [literals]: Fixed array holding the materialized literals. 7412 // [literals]: Fixed array holding the materialized literals.
7398 // 7413 //
7399 // If the function contains object, regexp or array literals, the 7414 // If the function contains object, regexp or array literals, the
7400 // literals array prefix contains the object, regexp, and array 7415 // literals array prefix contains the object, regexp, and array
7401 // function to be used when creating these literals. This is 7416 // function to be used when creating these literals. This is
7402 // necessary so that we do not dynamically lookup the object, regexp 7417 // necessary so that we do not dynamically lookup the object, regexp
7403 // or array functions. Performing a dynamic lookup, we might end up 7418 // or array functions. Performing a dynamic lookup, we might end up
7404 // using the functions from a new context that we should not have 7419 // using the functions from a new context that we should not have
7405 // access to. 7420 // access to.
7406 DECL_ACCESSORS(literals, LiteralsArray) 7421 DECL_ACCESSORS(literals, LiteralsArray)
7407 7422
7423 inline TypeFeedbackVector* feedback_vector();
7424
7408 // The initial map for an object created by this constructor. 7425 // The initial map for an object created by this constructor.
7409 inline Map* initial_map(); 7426 inline Map* initial_map();
7410 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map, 7427 static void SetInitialMap(Handle<JSFunction> function, Handle<Map> map,
7411 Handle<Object> prototype); 7428 Handle<Object> prototype);
7412 inline bool has_initial_map(); 7429 inline bool has_initial_map();
7413 static void EnsureHasInitialMap(Handle<JSFunction> function); 7430 static void EnsureHasInitialMap(Handle<JSFunction> function);
7414 7431
7415 // Creates a map that matches the constructor's initial map, but with 7432 // Creates a map that matches the constructor's initial map, but with
7416 // [[prototype]] being new.target.prototype. Because new.target can be a 7433 // [[prototype]] being new.target.prototype. Because new.target can be a
7417 // JSProxy, this can call back into JavaScript. 7434 // JSProxy, this can call back into JavaScript.
(...skipping 3387 matching lines...) Expand 10 before | Expand all | Expand 10 after
10805 } 10822 }
10806 return value; 10823 return value;
10807 } 10824 }
10808 }; 10825 };
10809 10826
10810 10827
10811 } // NOLINT, false-positive due to second-order macros. 10828 } // NOLINT, false-positive due to second-order macros.
10812 } // NOLINT, false-positive due to second-order macros. 10829 } // NOLINT, false-positive due to second-order macros.
10813 10830
10814 #endif // V8_OBJECTS_H_ 10831 #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