OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5658 class NumberOfOwnDescriptorsBits: public BitField<int, | 5658 class NumberOfOwnDescriptorsBits: public BitField<int, |
5659 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT | 5659 kDescriptorIndexBitCount, kDescriptorIndexBitCount> {}; // NOLINT |
5660 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); | 5660 STATIC_ASSERT(kDescriptorIndexBitCount + kDescriptorIndexBitCount == 20); |
5661 class DictionaryMap : public BitField<bool, 20, 1> {}; | 5661 class DictionaryMap : public BitField<bool, 20, 1> {}; |
5662 class OwnsDescriptors : public BitField<bool, 21, 1> {}; | 5662 class OwnsDescriptors : public BitField<bool, 21, 1> {}; |
5663 class HasInstanceCallHandler : public BitField<bool, 22, 1> {}; | 5663 class HasInstanceCallHandler : public BitField<bool, 22, 1> {}; |
5664 class Deprecated : public BitField<bool, 23, 1> {}; | 5664 class Deprecated : public BitField<bool, 23, 1> {}; |
5665 class IsFrozen : public BitField<bool, 24, 1> {}; | 5665 class IsFrozen : public BitField<bool, 24, 1> {}; |
5666 class IsUnstable : public BitField<bool, 25, 1> {}; | 5666 class IsUnstable : public BitField<bool, 25, 1> {}; |
5667 class IsMigrationTarget : public BitField<bool, 26, 1> {}; | 5667 class IsMigrationTarget : public BitField<bool, 26, 1> {}; |
5668 class DoneInobjectSlackTracking : public BitField<bool, 27, 1> {}; | 5668 // Bit 27 is free. |
5669 // Bit 28 is free. | |
5670 | 5669 |
5671 // Keep this bit field at the very end for better code in | 5670 // Keep this bit field at the very end for better code in |
5672 // Builtins::kJSConstructStubGeneric stub. | 5671 // Builtins::kJSConstructStubGeneric stub. |
5673 class ConstructionCount: public BitField<int, 29, 3> {}; | 5672 // This counter is used for in-object slack tracking and for map aging. |
| 5673 // The in-object slack tracking is considered enabled when the counter is |
| 5674 // in the range [kSlackTrackingCounterStart, kSlackTrackingCounterEnd]. |
| 5675 class Counter : public BitField<bool, 28, 4> {}; |
| 5676 static const int kSlackTrackingCounterStart = 14; |
| 5677 static const int kSlackTrackingCounterEnd = 8; |
| 5678 static const int kRetainingCounterStart = kSlackTrackingCounterEnd - 1; |
| 5679 static const int kRetainingCounterEnd = 0; |
5674 | 5680 |
5675 // Tells whether the object in the prototype property will be used | 5681 // Tells whether the object in the prototype property will be used |
5676 // for instances created from this function. If the prototype | 5682 // for instances created from this function. If the prototype |
5677 // property is set to a value that is not a JSObject, the prototype | 5683 // property is set to a value that is not a JSObject, the prototype |
5678 // property will not be used to create instances of the function. | 5684 // property will not be used to create instances of the function. |
5679 // See ECMA-262, 13.2.2. | 5685 // See ECMA-262, 13.2.2. |
5680 inline void set_non_instance_prototype(bool value); | 5686 inline void set_non_instance_prototype(bool value); |
5681 inline bool has_non_instance_prototype(); | 5687 inline bool has_non_instance_prototype(); |
5682 | 5688 |
5683 // Tells whether function has special prototype property. If not, prototype | 5689 // Tells whether function has special prototype property. If not, prototype |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6005 inline bool owns_descriptors(); | 6011 inline bool owns_descriptors(); |
6006 inline void set_owns_descriptors(bool owns_descriptors); | 6012 inline void set_owns_descriptors(bool owns_descriptors); |
6007 inline bool has_instance_call_handler(); | 6013 inline bool has_instance_call_handler(); |
6008 inline void set_has_instance_call_handler(); | 6014 inline void set_has_instance_call_handler(); |
6009 inline void freeze(); | 6015 inline void freeze(); |
6010 inline bool is_frozen(); | 6016 inline bool is_frozen(); |
6011 inline void mark_unstable(); | 6017 inline void mark_unstable(); |
6012 inline bool is_stable(); | 6018 inline bool is_stable(); |
6013 inline void set_migration_target(bool value); | 6019 inline void set_migration_target(bool value); |
6014 inline bool is_migration_target(); | 6020 inline bool is_migration_target(); |
6015 inline void set_done_inobject_slack_tracking(bool value); | 6021 inline void set_counter(int value); |
6016 inline bool done_inobject_slack_tracking(); | 6022 inline int counter(); |
6017 inline void set_construction_count(int value); | |
6018 inline int construction_count(); | |
6019 inline void deprecate(); | 6023 inline void deprecate(); |
6020 inline bool is_deprecated(); | 6024 inline bool is_deprecated(); |
6021 inline bool CanBeDeprecated(); | 6025 inline bool CanBeDeprecated(); |
6022 // Returns a non-deprecated version of the input. If the input was not | 6026 // Returns a non-deprecated version of the input. If the input was not |
6023 // deprecated, it is directly returned. Otherwise, the non-deprecated version | 6027 // deprecated, it is directly returned. Otherwise, the non-deprecated version |
6024 // is found by re-transitioning from the root of the transition tree using the | 6028 // is found by re-transitioning from the root of the transition tree using the |
6025 // descriptor array of the map. Returns NULL if no updated map is found. | 6029 // descriptor array of the map. Returns NULL if no updated map is found. |
6026 // This method also applies any pending migrations along the prototype chain. | 6030 // This method also applies any pending migrations along the prototype chain. |
6027 static MaybeHandle<Map> TryUpdate(Handle<Map> map) WARN_UNUSED_RESULT; | 6031 static MaybeHandle<Map> TryUpdate(Handle<Map> map) WARN_UNUSED_RESULT; |
6028 // Same as above, but does not touch the prototype chain. | 6032 // Same as above, but does not touch the prototype chain. |
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7359 // Inobject slack tracking is the way to reclaim unused inobject space. | 7363 // Inobject slack tracking is the way to reclaim unused inobject space. |
7360 // | 7364 // |
7361 // The instance size is initially determined by adding some slack to | 7365 // The instance size is initially determined by adding some slack to |
7362 // expected_nof_properties (to allow for a few extra properties added | 7366 // expected_nof_properties (to allow for a few extra properties added |
7363 // after the constructor). There is no guarantee that the extra space | 7367 // after the constructor). There is no guarantee that the extra space |
7364 // will not be wasted. | 7368 // will not be wasted. |
7365 // | 7369 // |
7366 // Here is the algorithm to reclaim the unused inobject space: | 7370 // Here is the algorithm to reclaim the unused inobject space: |
7367 // - Detect the first constructor call for this JSFunction. | 7371 // - Detect the first constructor call for this JSFunction. |
7368 // When it happens enter the "in progress" state: initialize construction | 7372 // When it happens enter the "in progress" state: initialize construction |
7369 // counter in the initial_map and set the |done_inobject_slack_tracking| | 7373 // counter in the initial_map. |
7370 // flag. | |
7371 // - While the tracking is in progress create objects filled with | 7374 // - While the tracking is in progress create objects filled with |
7372 // one_pointer_filler_map instead of undefined_value. This way they can be | 7375 // one_pointer_filler_map instead of undefined_value. This way they can be |
7373 // resized quickly and safely. | 7376 // resized quickly and safely. |
7374 // - Once enough (kGenerousAllocationCount) objects have been created | 7377 // - Once enough objects have been created compute the 'slack' |
7375 // compute the 'slack' (traverse the map transition tree starting from the | 7378 // (traverse the map transition tree starting from the |
7376 // initial_map and find the lowest value of unused_property_fields). | 7379 // initial_map and find the lowest value of unused_property_fields). |
7377 // - Traverse the transition tree again and decrease the instance size | 7380 // - Traverse the transition tree again and decrease the instance size |
7378 // of every map. Existing objects will resize automatically (they are | 7381 // of every map. Existing objects will resize automatically (they are |
7379 // filled with one_pointer_filler_map). All further allocations will | 7382 // filled with one_pointer_filler_map). All further allocations will |
7380 // use the adjusted instance size. | 7383 // use the adjusted instance size. |
7381 // - SharedFunctionInfo's expected_nof_properties left unmodified since | 7384 // - SharedFunctionInfo's expected_nof_properties left unmodified since |
7382 // allocations made using different closures could actually create different | 7385 // allocations made using different closures could actually create different |
7383 // kind of objects (see prototype inheritance pattern). | 7386 // kind of objects (see prototype inheritance pattern). |
7384 // | 7387 // |
7385 // Important: inobject slack tracking is not attempted during the snapshot | 7388 // Important: inobject slack tracking is not attempted during the snapshot |
7386 // creation. | 7389 // creation. |
7387 | 7390 |
7388 static const int kGenerousAllocationCount = Map::ConstructionCount::kMax; | |
7389 static const int kFinishSlackTracking = 1; | |
7390 static const int kNoSlackTracking = 0; | |
7391 | |
7392 // True if the initial_map is set and the object constructions countdown | 7391 // True if the initial_map is set and the object constructions countdown |
7393 // counter is not zero. | 7392 // counter is not zero. |
| 7393 static const int kGenerousAllocationCount = |
| 7394 Map::kSlackTrackingCounterStart - Map::kSlackTrackingCounterEnd + 1; |
7394 inline bool IsInobjectSlackTrackingInProgress(); | 7395 inline bool IsInobjectSlackTrackingInProgress(); |
7395 | 7396 |
7396 // Starts the tracking. | 7397 // Starts the tracking. |
7397 // Initializes object constructions countdown counter in the initial map. | 7398 // Initializes object constructions countdown counter in the initial map. |
7398 // IsInobjectSlackTrackingInProgress is normally true after this call, | |
7399 // except when tracking have not been started (e.g. the map has no unused | |
7400 // properties or the snapshot is being built). | |
7401 void StartInobjectSlackTracking(); | 7399 void StartInobjectSlackTracking(); |
7402 | 7400 |
7403 // Completes the tracking. | 7401 // Completes the tracking. |
7404 // IsInobjectSlackTrackingInProgress is false after this call. | |
7405 void CompleteInobjectSlackTracking(); | 7402 void CompleteInobjectSlackTracking(); |
7406 | 7403 |
7407 // [literals_or_bindings]: Fixed array holding either | 7404 // [literals_or_bindings]: Fixed array holding either |
7408 // the materialized literals or the bindings of a bound function. | 7405 // the materialized literals or the bindings of a bound function. |
7409 // | 7406 // |
7410 // If the function contains object, regexp or array literals, the | 7407 // If the function contains object, regexp or array literals, the |
7411 // literals array prefix contains the object, regexp, and array | 7408 // literals array prefix contains the object, regexp, and array |
7412 // function to be used when creating these literals. This is | 7409 // function to be used when creating these literals. This is |
7413 // necessary so that we do not dynamically lookup the object, regexp | 7410 // necessary so that we do not dynamically lookup the object, regexp |
7414 // or array functions. Performing a dynamic lookup, we might end up | 7411 // or array functions. Performing a dynamic lookup, we might end up |
(...skipping 3590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11005 } else { | 11002 } else { |
11006 value &= ~(1 << bit_position); | 11003 value &= ~(1 << bit_position); |
11007 } | 11004 } |
11008 return value; | 11005 return value; |
11009 } | 11006 } |
11010 }; | 11007 }; |
11011 | 11008 |
11012 } } // namespace v8::internal | 11009 } } // namespace v8::internal |
11013 | 11010 |
11014 #endif // V8_OBJECTS_H_ | 11011 #endif // V8_OBJECTS_H_ |
OLD | NEW |