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

Side by Side Diff: src/objects.h

Issue 188783003: Make maps in monomorphic IC stubs weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase, address comments Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 3207 matching lines...) Expand 10 before | Expand all | Expand 10 after
3218 // [1]: Field holding the first index which is a heap pointer entry 3218 // [1]: Field holding the first index which is a heap pointer entry
3219 // [2]: Field holding the first index which is a int32 entry 3219 // [2]: Field holding the first index which is a int32 entry
3220 // [3] ... [first_code_ptr_index() - 1] : 64 bit entries 3220 // [3] ... [first_code_ptr_index() - 1] : 64 bit entries
3221 // [first_code_ptr_index()] ... [first_heap_ptr_index() - 1] : code pointers 3221 // [first_code_ptr_index()] ... [first_heap_ptr_index() - 1] : code pointers
3222 // [first_heap_ptr_index()] ... [first_int32_index() - 1] : heap pointers 3222 // [first_heap_ptr_index()] ... [first_int32_index() - 1] : heap pointers
3223 // [first_int32_index()] ... [length - 1] : 32 bit entries 3223 // [first_int32_index()] ... [length - 1] : 32 bit entries
3224 class ConstantPoolArray: public FixedArrayBase { 3224 class ConstantPoolArray: public FixedArrayBase {
3225 public: 3225 public:
3226 enum WeakObjectState { 3226 enum WeakObjectState {
3227 NO_WEAK_OBJECTS, 3227 NO_WEAK_OBJECTS,
3228 WEAK_OBJECTS_IN_OPTIMIZED_CODE 3228 WEAK_OBJECTS_IN_OPTIMIZED_CODE,
3229 WEAK_OBJECTS_IN_IC
3229 }; 3230 };
3230 3231
3231 // Getters for the field storing the first index for different type entries. 3232 // Getters for the field storing the first index for different type entries.
3232 inline int first_code_ptr_index(); 3233 inline int first_code_ptr_index();
3233 inline int first_heap_ptr_index(); 3234 inline int first_heap_ptr_index();
3234 inline int first_int64_index(); 3235 inline int first_int64_index();
3235 inline int first_int32_index(); 3236 inline int first_int32_index();
3236 3237
3237 // Getters for counts of different type entries. 3238 // Getters for counts of different type entries.
3238 inline int count_of_code_ptr_entries(); 3239 inline int count_of_code_ptr_entries();
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
5487 inline bool is_load_stub() { return kind() == LOAD_IC; } 5488 inline bool is_load_stub() { return kind() == LOAD_IC; }
5488 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; } 5489 inline bool is_keyed_load_stub() { return kind() == KEYED_LOAD_IC; }
5489 inline bool is_store_stub() { return kind() == STORE_IC; } 5490 inline bool is_store_stub() { return kind() == STORE_IC; }
5490 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; } 5491 inline bool is_keyed_store_stub() { return kind() == KEYED_STORE_IC; }
5491 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; } 5492 inline bool is_binary_op_stub() { return kind() == BINARY_OP_IC; }
5492 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; } 5493 inline bool is_compare_ic_stub() { return kind() == COMPARE_IC; }
5493 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; } 5494 inline bool is_compare_nil_ic_stub() { return kind() == COMPARE_NIL_IC; }
5494 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; } 5495 inline bool is_to_boolean_ic_stub() { return kind() == TO_BOOLEAN_IC; }
5495 inline bool is_keyed_stub(); 5496 inline bool is_keyed_stub();
5496 inline bool is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; } 5497 inline bool is_optimized_code() { return kind() == OPTIMIZED_FUNCTION; }
5498 inline bool is_weak_stub();
5499 inline void mark_as_weak_stub();
5500 inline bool is_invalidated_weak_stub();
5501 inline void mark_as_invalidated_weak_stub();
5502
5503 inline bool CanBeWeakStub() {
5504 Kind k = kind();
5505 return (k == LOAD_IC || k == STORE_IC || k == KEYED_LOAD_IC ||
5506 k == KEYED_STORE_IC || k == COMPARE_NIL_IC) &&
5507 ic_state() == MONOMORPHIC;
5508 }
5497 5509
5498 inline void set_raw_kind_specific_flags1(int value); 5510 inline void set_raw_kind_specific_flags1(int value);
5499 inline void set_raw_kind_specific_flags2(int value); 5511 inline void set_raw_kind_specific_flags2(int value);
5500 5512
5501 // [major_key]: For kind STUB or BINARY_OP_IC, the major key. 5513 // [major_key]: For kind STUB or BINARY_OP_IC, the major key.
5502 inline int major_key(); 5514 inline int major_key();
5503 inline void set_major_key(int value); 5515 inline void set_major_key(int value);
5504 inline bool has_major_key(); 5516 inline bool has_major_key();
5505 5517
5506 // For kind STUB or ICs, tells whether or not a code object was generated by 5518 // For kind STUB or ICs, tells whether or not a code object was generated by
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
5744 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY); 5756 return GetCodeAgeStub(isolate, kNotExecutedCodeAge, NO_MARKING_PARITY);
5745 } 5757 }
5746 5758
5747 void PrintDeoptLocation(FILE* out, int bailout_id); 5759 void PrintDeoptLocation(FILE* out, int bailout_id);
5748 bool CanDeoptAt(Address pc); 5760 bool CanDeoptAt(Address pc);
5749 5761
5750 #ifdef VERIFY_HEAP 5762 #ifdef VERIFY_HEAP
5751 void VerifyEmbeddedObjectsDependency(); 5763 void VerifyEmbeddedObjectsDependency();
5752 #endif 5764 #endif
5753 5765
5766 inline bool CanContainWeakObjects() {
5767 return is_optimized_code() || is_weak_stub();
5768 }
5769
5754 inline bool IsWeakObject(Object* object) { 5770 inline bool IsWeakObject(Object* object) {
5755 return is_optimized_code() && IsWeakObjectInOptimizedCode(object); 5771 return (is_optimized_code() && IsWeakObjectInOptimizedCode(object)) ||
5772 (is_weak_stub() && IsWeakObjectInIC(object));
5756 } 5773 }
5757 5774
5758 static inline bool IsWeakObjectInOptimizedCode(Object* object); 5775 static inline bool IsWeakObjectInOptimizedCode(Object* object);
5776 static inline bool IsWeakObjectInIC(Object* object);
5759 5777
5760 // Max loop nesting marker used to postpose OSR. We don't take loop 5778 // Max loop nesting marker used to postpose OSR. We don't take loop
5761 // nesting that is deeper than 5 levels into account. 5779 // nesting that is deeper than 5 levels into account.
5762 static const int kMaxLoopNestingMarker = 6; 5780 static const int kMaxLoopNestingMarker = 6;
5763 5781
5764 // Layout description. 5782 // Layout description.
5765 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; 5783 static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
5766 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize; 5784 static const int kRelocationInfoOffset = kInstructionSizeOffset + kIntSize;
5767 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize; 5785 static const int kHandlerTableOffset = kRelocationInfoOffset + kPointerSize;
5768 static const int kDeoptimizationDataOffset = 5786 static const int kDeoptimizationDataOffset =
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
5811 5829
5812 // KindSpecificFlags1 layout (STUB and OPTIMIZED_FUNCTION) 5830 // KindSpecificFlags1 layout (STUB and OPTIMIZED_FUNCTION)
5813 static const int kStackSlotsFirstBit = 0; 5831 static const int kStackSlotsFirstBit = 0;
5814 static const int kStackSlotsBitCount = 24; 5832 static const int kStackSlotsBitCount = 24;
5815 static const int kHasFunctionCacheFirstBit = 5833 static const int kHasFunctionCacheFirstBit =
5816 kStackSlotsFirstBit + kStackSlotsBitCount; 5834 kStackSlotsFirstBit + kStackSlotsBitCount;
5817 static const int kHasFunctionCacheBitCount = 1; 5835 static const int kHasFunctionCacheBitCount = 1;
5818 static const int kMarkedForDeoptimizationFirstBit = 5836 static const int kMarkedForDeoptimizationFirstBit =
5819 kStackSlotsFirstBit + kStackSlotsBitCount + 1; 5837 kStackSlotsFirstBit + kStackSlotsBitCount + 1;
5820 static const int kMarkedForDeoptimizationBitCount = 1; 5838 static const int kMarkedForDeoptimizationBitCount = 1;
5839 static const int kWeakStubFirstBit =
5840 kMarkedForDeoptimizationFirstBit + kMarkedForDeoptimizationBitCount;
5841 static const int kWeakStubBitCount = 1;
5842 static const int kInvalidatedWeakStubFirstBit =
5843 kWeakStubFirstBit + kWeakStubBitCount;
5844 static const int kInvalidatedWeakStubBitCount = 1;
5821 5845
5822 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); 5846 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32);
5823 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); 5847 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32);
5824 STATIC_ASSERT(kMarkedForDeoptimizationFirstBit + 5848 STATIC_ASSERT(kInvalidatedWeakStubFirstBit +
5825 kMarkedForDeoptimizationBitCount <= 32); 5849 kInvalidatedWeakStubBitCount <= 32);
5826 5850
5827 class StackSlotsField: public BitField<int, 5851 class StackSlotsField: public BitField<int,
5828 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT 5852 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT
5829 class HasFunctionCacheField: public BitField<bool, 5853 class HasFunctionCacheField: public BitField<bool,
5830 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT 5854 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT
5831 class MarkedForDeoptimizationField: public BitField<bool, 5855 class MarkedForDeoptimizationField: public BitField<bool,
5832 kMarkedForDeoptimizationFirstBit, 5856 kMarkedForDeoptimizationFirstBit,
5833 kMarkedForDeoptimizationBitCount> {}; // NOLINT 5857 kMarkedForDeoptimizationBitCount> {}; // NOLINT
5858 class WeakStubField: public BitField<bool,
5859 kWeakStubFirstBit,
5860 kWeakStubBitCount> {}; // NOLINT
5861 class InvalidatedWeakStubField: public BitField<bool,
5862 kInvalidatedWeakStubFirstBit,
5863 kInvalidatedWeakStubBitCount> {}; // NOLINT
5834 5864
5835 // KindSpecificFlags2 layout (ALL) 5865 // KindSpecificFlags2 layout (ALL)
5836 static const int kIsCrankshaftedBit = 0; 5866 static const int kIsCrankshaftedBit = 0;
5837 class IsCrankshaftedField: public BitField<bool, 5867 class IsCrankshaftedField: public BitField<bool,
5838 kIsCrankshaftedBit, 1> {}; // NOLINT 5868 kIsCrankshaftedBit, 1> {}; // NOLINT
5839 5869
5840 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) 5870 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION)
5841 static const int kStubMajorKeyFirstBit = kIsCrankshaftedBit + 1; 5871 static const int kStubMajorKeyFirstBit = kIsCrankshaftedBit + 1;
5842 static const int kSafepointTableOffsetFirstBit = 5872 static const int kSafepointTableOffsetFirstBit =
5843 kStubMajorKeyFirstBit + kStubMajorKeyBits; 5873 kStubMajorKeyFirstBit + kStubMajorKeyBits;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
5908 // the number of codes is less than the length of the array. The order of the 5938 // the number of codes is less than the length of the array. The order of the
5909 // code objects within a group is not preserved. 5939 // code objects within a group is not preserved.
5910 // 5940 //
5911 // All code indexes used in the class are counted starting from the first 5941 // All code indexes used in the class are counted starting from the first
5912 // code object of the first group. In other words, code index 0 corresponds 5942 // code object of the first group. In other words, code index 0 corresponds
5913 // to array index n = kCodesStartIndex. 5943 // to array index n = kCodesStartIndex.
5914 5944
5915 class DependentCode: public FixedArray { 5945 class DependentCode: public FixedArray {
5916 public: 5946 public:
5917 enum DependencyGroup { 5947 enum DependencyGroup {
5948 // Group of IC stubs that weakly embed this map and depend on being
5949 // invalidated when the map is garbage collected. Dependent IC stubs form
5950 // a linked list. This group stores only the head of the list. This means
5951 // that the number_of_entries(kWeakICGroup) is 0 or 1.
5952 kWeakICGroup,
5918 // Group of code that weakly embed this map and depend on being 5953 // Group of code that weakly embed this map and depend on being
5919 // deoptimized when the map is garbage collected. 5954 // deoptimized when the map is garbage collected.
5920 kWeaklyEmbeddedGroup, 5955 kWeakCodeGroup,
5921 // Group of code that embed a transition to this map, and depend on being 5956 // Group of code that embed a transition to this map, and depend on being
5922 // deoptimized when the transition is replaced by a new version. 5957 // deoptimized when the transition is replaced by a new version.
5923 kTransitionGroup, 5958 kTransitionGroup,
5924 // Group of code that omit run-time prototype checks for prototypes 5959 // Group of code that omit run-time prototype checks for prototypes
5925 // described by this map. The group is deoptimized whenever an object 5960 // described by this map. The group is deoptimized whenever an object
5926 // described by this map changes shape (and transitions to a new map), 5961 // described by this map changes shape (and transitions to a new map),
5927 // possibly invalidating the assumptions embedded in the code. 5962 // possibly invalidating the assumptions embedded in the code.
5928 kPrototypeCheckGroup, 5963 kPrototypeCheckGroup,
5929 // Group of code that depends on elements not being added to objects with 5964 // Group of code that depends on elements not being added to objects with
5930 // this map. 5965 // this map.
(...skipping 30 matching lines...) Expand all
5961 CompilationInfo* info, 5996 CompilationInfo* info,
5962 Code* code); 5997 Code* code);
5963 void RemoveCompilationInfo(DependentCode::DependencyGroup group, 5998 void RemoveCompilationInfo(DependentCode::DependencyGroup group,
5964 CompilationInfo* info); 5999 CompilationInfo* info);
5965 6000
5966 void DeoptimizeDependentCodeGroup(Isolate* isolate, 6001 void DeoptimizeDependentCodeGroup(Isolate* isolate,
5967 DependentCode::DependencyGroup group); 6002 DependentCode::DependencyGroup group);
5968 6003
5969 bool MarkCodeForDeoptimization(Isolate* isolate, 6004 bool MarkCodeForDeoptimization(Isolate* isolate,
5970 DependentCode::DependencyGroup group); 6005 DependentCode::DependencyGroup group);
6006 void AddToDependentICList(Handle<Code> stub);
5971 6007
5972 // The following low-level accessors should only be used by this class 6008 // The following low-level accessors should only be used by this class
5973 // and the mark compact collector. 6009 // and the mark compact collector.
5974 inline int number_of_entries(DependencyGroup group); 6010 inline int number_of_entries(DependencyGroup group);
5975 inline void set_number_of_entries(DependencyGroup group, int value); 6011 inline void set_number_of_entries(DependencyGroup group, int value);
5976 inline bool is_code_at(int i); 6012 inline bool is_code_at(int i);
5977 inline Code* code_at(int i); 6013 inline Code* code_at(int i);
5978 inline CompilationInfo* compilation_info_at(int i); 6014 inline CompilationInfo* compilation_info_at(int i);
5979 inline void set_object_at(int i, Object* object); 6015 inline void set_object_at(int i, Object* object);
5980 inline Object** slot_at(int i); 6016 inline Object** slot_at(int i);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
6271 // [constructor]: points back to the function responsible for this map. 6307 // [constructor]: points back to the function responsible for this map.
6272 DECL_ACCESSORS(constructor, Object) 6308 DECL_ACCESSORS(constructor, Object)
6273 6309
6274 // [instance descriptors]: describes the object. 6310 // [instance descriptors]: describes the object.
6275 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 6311 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
6276 inline void InitializeDescriptors(DescriptorArray* descriptors); 6312 inline void InitializeDescriptors(DescriptorArray* descriptors);
6277 6313
6278 // [stub cache]: contains stubs compiled for this map. 6314 // [stub cache]: contains stubs compiled for this map.
6279 DECL_ACCESSORS(code_cache, Object) 6315 DECL_ACCESSORS(code_cache, Object)
6280 6316
6281 // [dependent code]: list of optimized codes that have this map embedded. 6317 // [dependent code]: list of optimized codes that weakly embed this map.
6282 DECL_ACCESSORS(dependent_code, DependentCode) 6318 DECL_ACCESSORS(dependent_code, DependentCode)
6283 6319
6284 // [back pointer]: points back to the parent map from which a transition 6320 // [back pointer]: points back to the parent map from which a transition
6285 // leads to this map. The field overlaps with prototype transitions and the 6321 // leads to this map. The field overlaps with prototype transitions and the
6286 // back pointer will be moved into the prototype transitions array if 6322 // back pointer will be moved into the prototype transitions array if
6287 // required. 6323 // required.
6288 inline Object* GetBackPointer(); 6324 inline Object* GetBackPointer();
6289 inline void SetBackPointer(Object* value, 6325 inline void SetBackPointer(Object* value,
6290 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 6326 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
6291 inline void init_back_pointer(Object* undefined); 6327 inline void init_back_pointer(Object* undefined);
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
6556 // the descriptor array. 6592 // the descriptor array.
6557 inline void NotifyLeafMapLayoutChange(); 6593 inline void NotifyLeafMapLayoutChange();
6558 6594
6559 inline bool CanOmitMapChecks(); 6595 inline bool CanOmitMapChecks();
6560 6596
6561 void AddDependentCompilationInfo(DependentCode::DependencyGroup group, 6597 void AddDependentCompilationInfo(DependentCode::DependencyGroup group,
6562 CompilationInfo* info); 6598 CompilationInfo* info);
6563 6599
6564 void AddDependentCode(DependentCode::DependencyGroup group, 6600 void AddDependentCode(DependentCode::DependencyGroup group,
6565 Handle<Code> code); 6601 Handle<Code> code);
6602 void AddDependentIC(Handle<Code> stub);
6566 6603
6567 bool IsMapInArrayPrototypeChain(); 6604 bool IsMapInArrayPrototypeChain();
6568 6605
6569 // Dispatched behavior. 6606 // Dispatched behavior.
6570 DECLARE_PRINTER(Map) 6607 DECLARE_PRINTER(Map)
6571 DECLARE_VERIFIER(Map) 6608 DECLARE_VERIFIER(Map)
6572 6609
6573 #ifdef VERIFY_HEAP 6610 #ifdef VERIFY_HEAP
6574 void SharedMapVerify(); 6611 void SharedMapVerify();
6575 void VerifyOmittedMapChecks(); 6612 void VerifyOmittedMapChecks();
(...skipping 4434 matching lines...) Expand 10 before | Expand all | Expand 10 after
11010 } else { 11047 } else {
11011 value &= ~(1 << bit_position); 11048 value &= ~(1 << bit_position);
11012 } 11049 }
11013 return value; 11050 return value;
11014 } 11051 }
11015 }; 11052 };
11016 11053
11017 } } // namespace v8::internal 11054 } } // namespace v8::internal
11018 11055
11019 #endif // V8_OBJECTS_H_ 11056 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698