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

Side by Side Diff: src/objects.h

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