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