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

Side by Side Diff: src/objects.h

Issue 11575007: Make embedded maps in optimized code weak. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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
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 4421 matching lines...) Expand 10 before | Expand all | Expand 10 after
4432 4432
4433 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in. 4433 // [to_boolean_foo]: For kind TO_BOOLEAN_IC tells what state the stub is in.
4434 inline byte to_boolean_state(); 4434 inline byte to_boolean_state();
4435 inline void set_to_boolean_state(byte value); 4435 inline void set_to_boolean_state(byte value);
4436 4436
4437 // [has_function_cache]: For kind STUB tells whether there is a function 4437 // [has_function_cache]: For kind STUB tells whether there is a function
4438 // cache is passed to the stub. 4438 // cache is passed to the stub.
4439 inline bool has_function_cache(); 4439 inline bool has_function_cache();
4440 inline void set_has_function_cache(bool flag); 4440 inline void set_has_function_cache(bool flag);
4441 4441
4442
4443 // [marked_for_deoptimization]: For kind OPTIMIZED_FUNCTION tells whether
4444 // the code is going to be deoptimized because of dead embedded maps.
4445 inline bool marked_for_deoptimization();
4446 inline void set_marked_for_deoptimization(bool flag);
4447
4442 bool allowed_in_shared_map_code_cache(); 4448 bool allowed_in_shared_map_code_cache();
4443 4449
4444 // Get the safepoint entry for the given pc. 4450 // Get the safepoint entry for the given pc.
4445 SafepointEntry GetSafepointEntry(Address pc); 4451 SafepointEntry GetSafepointEntry(Address pc);
4446 4452
4447 // Mark this code object as not having a stack check table. Assumes kind 4453 // Mark this code object as not having a stack check table. Assumes kind
4448 // is FUNCTION. 4454 // is FUNCTION.
4449 void SetNoStackCheckTable(); 4455 void SetNoStackCheckTable();
4450 4456
4451 // Find the first map in an IC stub. 4457 // Find the first map in an IC stub.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
4639 static const int kStackSlotsBitCount = 24; 4645 static const int kStackSlotsBitCount = 24;
4640 static const int kUnaryOpTypeFirstBit = 4646 static const int kUnaryOpTypeFirstBit =
4641 kStackSlotsFirstBit + kStackSlotsBitCount; 4647 kStackSlotsFirstBit + kStackSlotsBitCount;
4642 static const int kUnaryOpTypeBitCount = 3; 4648 static const int kUnaryOpTypeBitCount = 3;
4643 static const int kToBooleanStateFirstBit = 4649 static const int kToBooleanStateFirstBit =
4644 kStackSlotsFirstBit + kStackSlotsBitCount; 4650 kStackSlotsFirstBit + kStackSlotsBitCount;
4645 static const int kToBooleanStateBitCount = 8; 4651 static const int kToBooleanStateBitCount = 8;
4646 static const int kHasFunctionCacheFirstBit = 4652 static const int kHasFunctionCacheFirstBit =
4647 kStackSlotsFirstBit + kStackSlotsBitCount; 4653 kStackSlotsFirstBit + kStackSlotsBitCount;
4648 static const int kHasFunctionCacheBitCount = 1; 4654 static const int kHasFunctionCacheBitCount = 1;
4655 static const int kMarkedForDeoptimizationFirstBit =
4656 kStackSlotsFirstBit + kStackSlotsBitCount + 1;
4657 static const int kMarkedForDeoptimizationBitCount = 1;
4649 4658
4650 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32); 4659 STATIC_ASSERT(kStackSlotsFirstBit + kStackSlotsBitCount <= 32);
4651 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32); 4660 STATIC_ASSERT(kUnaryOpTypeFirstBit + kUnaryOpTypeBitCount <= 32);
4652 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32); 4661 STATIC_ASSERT(kToBooleanStateFirstBit + kToBooleanStateBitCount <= 32);
4653 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32); 4662 STATIC_ASSERT(kHasFunctionCacheFirstBit + kHasFunctionCacheBitCount <= 32);
4663 STATIC_ASSERT(kMarkedForDeoptimizationBitCount +
4664 kMarkedForDeoptimizationBitCount <= 32);
4654 4665
4655 class StackSlotsField: public BitField<int, 4666 class StackSlotsField: public BitField<int,
4656 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT 4667 kStackSlotsFirstBit, kStackSlotsBitCount> {}; // NOLINT
4657 class UnaryOpTypeField: public BitField<int, 4668 class UnaryOpTypeField: public BitField<int,
4658 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT 4669 kUnaryOpTypeFirstBit, kUnaryOpTypeBitCount> {}; // NOLINT
4659 class ToBooleanStateField: public BitField<int, 4670 class ToBooleanStateField: public BitField<int,
4660 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT 4671 kToBooleanStateFirstBit, kToBooleanStateBitCount> {}; // NOLINT
4661 class HasFunctionCacheField: public BitField<bool, 4672 class HasFunctionCacheField: public BitField<bool,
4662 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT 4673 kHasFunctionCacheFirstBit, kHasFunctionCacheBitCount> {}; // NOLINT
4674 class MarkedForDeoptimizationField: public BitField<bool,
4675 kMarkedForDeoptimizationFirstBit,
4676 kMarkedForDeoptimizationBitCount> {}; // NOLINT
4663 4677
4664 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION) 4678 // KindSpecificFlags2 layout (STUB and OPTIMIZED_FUNCTION)
4665 static const int kStubMajorKeyFirstBit = 0; 4679 static const int kStubMajorKeyFirstBit = 0;
4666 static const int kSafepointTableOffsetFirstBit = 4680 static const int kSafepointTableOffsetFirstBit =
4667 kStubMajorKeyFirstBit + kStubMajorKeyBits; 4681 kStubMajorKeyFirstBit + kStubMajorKeyBits;
4668 static const int kSafepointTableOffsetBitCount = 26; 4682 static const int kSafepointTableOffsetBitCount = 26;
4669 4683
4670 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32); 4684 STATIC_ASSERT(kStubMajorKeyFirstBit + kStubMajorKeyBits <= 32);
4671 STATIC_ASSERT(kSafepointTableOffsetFirstBit + 4685 STATIC_ASSERT(kSafepointTableOffsetFirstBit +
4672 kSafepointTableOffsetBitCount <= 32); 4686 kSafepointTableOffsetBitCount <= 32);
(...skipping 27 matching lines...) Expand all
4700 static Code* GetCodeAgeStub(Age age, MarkingParity parity); 4714 static Code* GetCodeAgeStub(Age age, MarkingParity parity);
4701 4715
4702 // Code aging -- platform-specific 4716 // Code aging -- platform-specific
4703 static void PatchPlatformCodeAge(byte* sequence, Age age, 4717 static void PatchPlatformCodeAge(byte* sequence, Age age,
4704 MarkingParity parity); 4718 MarkingParity parity);
4705 4719
4706 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); 4720 DISALLOW_IMPLICIT_CONSTRUCTORS(Code);
4707 }; 4721 };
4708 4722
4709 4723
4724 // These helper functions abstract the layout of dependent codes array of a
4725 // map. The first element contains the number of codes as a Smi.
4726 // The subsequent elements contain code objects. The suffix of the array can
4727 // be filled with Smi(0) if the number of codes is less than the length of the
4728 // array.
4729 class DependentCodes {
ulan 2012/12/13 14:37:25 I could make this a proper object that derives fro
Michael Starzinger 2012/12/14 14:15:26 I think it should derive from FixedArray. One exam
ulan 2013/01/17 09:35:10 Done.
4730 public:
4731 static inline int number_of_codes(FixedArray* codes);
4732 static inline void set_number_of_codes(FixedArray* codes, int value);
4733 static inline Code* code(FixedArray* codes, int i);
4734 static inline void set_code(FixedArray* codes, int i, Code* value);
4735 static inline Object** code_slot(FixedArray* codes, int i);
4736 static inline void clear_code(FixedArray* codes, int i);
4737 static Handle<FixedArray> Append(Handle<FixedArray> codes,
4738 Handle<Code> value);
4739 private:
4740 static const int kNumberOfCodesOffset = 0;
4741 static const int kCodesOffset = 1;
4742 };
4743
4744
4710 // All heap objects have a Map that describes their structure. 4745 // All heap objects have a Map that describes their structure.
4711 // A Map contains information about: 4746 // A Map contains information about:
4712 // - Size information about the object 4747 // - Size information about the object
4713 // - How to iterate over an object (for garbage collection) 4748 // - How to iterate over an object (for garbage collection)
4714 class Map: public HeapObject { 4749 class Map: public HeapObject {
4715 public: 4750 public:
4716 // Instance size. 4751 // Instance size.
4717 // Size in bytes or kVariableSizeSentinel if instances do not have 4752 // Size in bytes or kVariableSizeSentinel if instances do not have
4718 // a fixed size. 4753 // a fixed size.
4719 inline int instance_size(); 4754 inline int instance_size();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
4921 4956
4922 inline JSFunction* unchecked_constructor(); 4957 inline JSFunction* unchecked_constructor();
4923 4958
4924 // [instance descriptors]: describes the object. 4959 // [instance descriptors]: describes the object.
4925 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 4960 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
4926 inline void InitializeDescriptors(DescriptorArray* descriptors); 4961 inline void InitializeDescriptors(DescriptorArray* descriptors);
4927 4962
4928 // [stub cache]: contains stubs compiled for this map. 4963 // [stub cache]: contains stubs compiled for this map.
4929 DECL_ACCESSORS(code_cache, Object) 4964 DECL_ACCESSORS(code_cache, Object)
4930 4965
4966 // [dependent codes]: list of optimized codes that have this map embedded.
4967 DECL_ACCESSORS(dependent_codes, FixedArray)
4968
4931 // [back pointer]: points back to the parent map from which a transition 4969 // [back pointer]: points back to the parent map from which a transition
4932 // leads to this map. The field overlaps with prototype transitions and the 4970 // leads to this map. The field overlaps with prototype transitions and the
4933 // back pointer will be moved into the prototype transitions array if 4971 // back pointer will be moved into the prototype transitions array if
4934 // required. 4972 // required.
4935 inline Object* GetBackPointer(); 4973 inline Object* GetBackPointer();
4936 inline void SetBackPointer(Object* value, 4974 inline void SetBackPointer(Object* value,
4937 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 4975 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
4938 inline void init_back_pointer(Object* undefined); 4976 inline void init_back_pointer(Object* undefined);
4939 4977
4940 // [prototype transitions]: cache of prototype transitions. 4978 // [prototype transitions]: cache of prototype transitions.
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
5130 5168
5131 // Zaps the contents of backing data structures. Note that the 5169 // Zaps the contents of backing data structures. Note that the
5132 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects 5170 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
5133 // holding weak references when incremental marking is used, because it also 5171 // holding weak references when incremental marking is used, because it also
5134 // iterates over objects that are otherwise unreachable. 5172 // iterates over objects that are otherwise unreachable.
5135 // In general we only want to call these functions in release mode when 5173 // In general we only want to call these functions in release mode when
5136 // heap verification is turned on. 5174 // heap verification is turned on.
5137 void ZapPrototypeTransitions(); 5175 void ZapPrototypeTransitions();
5138 void ZapTransitions(); 5176 void ZapTransitions();
5139 5177
5178 bool CanTransition() {
5179 // Only JSObject and subtypes have map transitions and back pointers.
5180 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE);
5181 return instance_type() >= FIRST_JS_OBJECT_TYPE;
5182 }
5183
5184 inline void AddDependentCode(Handle<Code> code);
5185
5140 // Dispatched behavior. 5186 // Dispatched behavior.
5141 #ifdef OBJECT_PRINT 5187 #ifdef OBJECT_PRINT
5142 inline void MapPrint() { 5188 inline void MapPrint() {
5143 MapPrint(stdout); 5189 MapPrint(stdout);
5144 } 5190 }
5145 void MapPrint(FILE* out); 5191 void MapPrint(FILE* out);
5146 #endif 5192 #endif
5147 DECLARE_VERIFIER(Map) 5193 DECLARE_VERIFIER(Map)
5148 5194
5149 #ifdef VERIFY_HEAP 5195 #ifdef VERIFY_HEAP
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
5183 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 5229 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
5184 // Storage for the transition array is overloaded to directly contain a back 5230 // Storage for the transition array is overloaded to directly contain a back
5185 // pointer if unused. When the map has transitions, the back pointer is 5231 // pointer if unused. When the map has transitions, the back pointer is
5186 // transferred to the transition array and accessed through an extra 5232 // transferred to the transition array and accessed through an extra
5187 // indirection. 5233 // indirection.
5188 static const int kTransitionsOrBackPointerOffset = 5234 static const int kTransitionsOrBackPointerOffset =
5189 kConstructorOffset + kPointerSize; 5235 kConstructorOffset + kPointerSize;
5190 static const int kDescriptorsOffset = 5236 static const int kDescriptorsOffset =
5191 kTransitionsOrBackPointerOffset + kPointerSize; 5237 kTransitionsOrBackPointerOffset + kPointerSize;
5192 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize; 5238 static const int kCodeCacheOffset = kDescriptorsOffset + kPointerSize;
5193 static const int kBitField3Offset = kCodeCacheOffset + kPointerSize; 5239 static const int kDependentCodesOffset = kCodeCacheOffset + kPointerSize;
5240 static const int kBitField3Offset = kDependentCodesOffset + kPointerSize;
5194 static const int kSize = kBitField3Offset + kPointerSize; 5241 static const int kSize = kBitField3Offset + kPointerSize;
5195 5242
5196 // Layout of pointer fields. Heap iteration code relies on them 5243 // Layout of pointer fields. Heap iteration code relies on them
5197 // being continuously allocated. 5244 // being continuously allocated.
5198 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; 5245 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset;
5199 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize; 5246 static const int kPointerFieldsEndOffset = kBitField3Offset + kPointerSize;
5200 5247
5201 // Byte offsets within kInstanceSizesOffset. 5248 // Byte offsets within kInstanceSizesOffset.
5202 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 5249 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
5203 static const int kInObjectPropertiesByte = 1; 5250 static const int kInObjectPropertiesByte = 1;
(...skipping 3895 matching lines...) Expand 10 before | Expand all | Expand 10 after
9099 } else { 9146 } else {
9100 value &= ~(1 << bit_position); 9147 value &= ~(1 << bit_position);
9101 } 9148 }
9102 return value; 9149 return value;
9103 } 9150 }
9104 }; 9151 };
9105 9152
9106 } } // namespace v8::internal 9153 } } // namespace v8::internal
9107 9154
9108 #endif // V8_OBJECTS_H_ 9155 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mark-compact.cc ('k') | src/objects.cc » ('j') | src/objects-visiting-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698