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

Side by Side Diff: src/objects.h

Issue 1488023002: Fix inobject slack tracking for both subclassing and non-subclassing cases. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moved and updated comments about slack tracking Created 5 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
« no previous file with comments | « src/mips64/builtins-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 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 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 // Define this so that we can put assertions on discrete checks. 770 // Define this so that we can put assertions on discrete checks.
771 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2 771 NUM_OF_CALLABLE_SPEC_OBJECT_TYPES = 2
772 }; 772 };
773 773
774 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType); 774 STATIC_ASSERT(JS_OBJECT_TYPE == Internals::kJSObjectType);
775 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType); 775 STATIC_ASSERT(FIRST_NONSTRING_TYPE == Internals::kFirstNonstringType);
776 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType); 776 STATIC_ASSERT(ODDBALL_TYPE == Internals::kOddballType);
777 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType); 777 STATIC_ASSERT(FOREIGN_TYPE == Internals::kForeignType);
778 778
779 779
780 std::ostream& operator<<(std::ostream& os, InstanceType instance_type);
781
782
780 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \ 783 #define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V) \
781 V(FAST_ELEMENTS_SUB_TYPE) \ 784 V(FAST_ELEMENTS_SUB_TYPE) \
782 V(DICTIONARY_ELEMENTS_SUB_TYPE) \ 785 V(DICTIONARY_ELEMENTS_SUB_TYPE) \
783 V(FAST_PROPERTIES_SUB_TYPE) \ 786 V(FAST_PROPERTIES_SUB_TYPE) \
784 V(DICTIONARY_PROPERTIES_SUB_TYPE) \ 787 V(DICTIONARY_PROPERTIES_SUB_TYPE) \
785 V(MAP_CODE_CACHE_SUB_TYPE) \ 788 V(MAP_CODE_CACHE_SUB_TYPE) \
786 V(SCOPE_INFO_SUB_TYPE) \ 789 V(SCOPE_INFO_SUB_TYPE) \
787 V(STRING_TABLE_SUB_TYPE) \ 790 V(STRING_TABLE_SUB_TYPE) \
788 V(DESCRIPTOR_ARRAY_SUB_TYPE) \ 791 V(DESCRIPTOR_ARRAY_SUB_TYPE) \
789 V(TRANSITION_ARRAY_SUB_TYPE) 792 V(TRANSITION_ARRAY_SUB_TYPE)
(...skipping 4708 matching lines...) Expand 10 before | Expand all | Expand 10 after
5498 // Builtins::kJSConstructStubGeneric stub. 5501 // Builtins::kJSConstructStubGeneric stub.
5499 // This counter is used for in-object slack tracking and for map aging. 5502 // This counter is used for in-object slack tracking and for map aging.
5500 // The in-object slack tracking is considered enabled when the counter is 5503 // The in-object slack tracking is considered enabled when the counter is
5501 // in the range [kSlackTrackingCounterStart, kSlackTrackingCounterEnd]. 5504 // in the range [kSlackTrackingCounterStart, kSlackTrackingCounterEnd].
5502 class Counter : public BitField<int, 28, 4> {}; 5505 class Counter : public BitField<int, 28, 4> {};
5503 static const int kSlackTrackingCounterStart = 14; 5506 static const int kSlackTrackingCounterStart = 14;
5504 static const int kSlackTrackingCounterEnd = 8; 5507 static const int kSlackTrackingCounterEnd = 8;
5505 static const int kRetainingCounterStart = kSlackTrackingCounterEnd - 1; 5508 static const int kRetainingCounterStart = kSlackTrackingCounterEnd - 1;
5506 static const int kRetainingCounterEnd = 0; 5509 static const int kRetainingCounterEnd = 0;
5507 5510
5511
5512 // Inobject slack tracking is the way to reclaim unused inobject space.
5513 //
5514 // The instance size is initially determined by adding some slack to
5515 // expected_nof_properties (to allow for a few extra properties added
5516 // after the constructor). There is no guarantee that the extra space
5517 // will not be wasted.
5518 //
5519 // Here is the algorithm to reclaim the unused inobject space:
5520 // - Detect the first constructor call for this JSFunction.
5521 // When it happens enter the "in progress" state: initialize construction
5522 // counter in the initial_map.
5523 // - While the tracking is in progress initialize unused properties of a new
5524 // object with one_pointer_filler_map instead of undefined_value (the "used"
5525 // part is initialized with undefined_value as usual). This way they can
5526 // be resized quickly and safely.
5527 // - Once enough objects have been created compute the 'slack'
5528 // (traverse the map transition tree starting from the
5529 // initial_map and find the lowest value of unused_property_fields).
5530 // - Traverse the transition tree again and decrease the instance size
5531 // of every map. Existing objects will resize automatically (they are
5532 // filled with one_pointer_filler_map). All further allocations will
5533 // use the adjusted instance size.
5534 // - SharedFunctionInfo's expected_nof_properties left unmodified since
5535 // allocations made using different closures could actually create different
5536 // kind of objects (see prototype inheritance pattern).
5537 //
5538 // Important: inobject slack tracking is not attempted during the snapshot
5539 // creation.
5540
5541 static const int kGenerousAllocationCount =
5542 kSlackTrackingCounterStart - kSlackTrackingCounterEnd + 1;
5543
5544 // Starts the tracking by initializing object constructions countdown counter.
5545 void StartInobjectSlackTracking();
5546
5547 // True if the object constructions countdown counter is a range
5548 // [kSlackTrackingCounterEnd, kSlackTrackingCounterStart].
5549 inline bool IsInobjectSlackTrackingInProgress();
5550
5551 // Does the tracking step.
5552 inline void InobjectSlackTrackingStep();
5553
5508 // Completes inobject slack tracking for the transition tree starting at this 5554 // Completes inobject slack tracking for the transition tree starting at this
5509 // initial map. 5555 // initial map.
5510 void CompleteInobjectSlackTracking(); 5556 void CompleteInobjectSlackTracking();
5511 5557
5512 // Tells whether the object in the prototype property will be used 5558 // Tells whether the object in the prototype property will be used
5513 // for instances created from this function. If the prototype 5559 // for instances created from this function. If the prototype
5514 // property is set to a value that is not a JSObject, the prototype 5560 // property is set to a value that is not a JSObject, the prototype
5515 // property will not be used to create instances of the function. 5561 // property will not be used to create instances of the function.
5516 // See ECMA-262, 13.2.2. 5562 // See ECMA-262, 13.2.2.
5517 inline void set_non_instance_prototype(bool value); 5563 inline void set_non_instance_prototype(bool value);
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
7216 void AttemptConcurrentOptimization(); 7262 void AttemptConcurrentOptimization();
7217 7263
7218 // Tells whether or not the function is already marked for lazy 7264 // Tells whether or not the function is already marked for lazy
7219 // recompilation. 7265 // recompilation.
7220 inline bool IsMarkedForOptimization(); 7266 inline bool IsMarkedForOptimization();
7221 inline bool IsMarkedForConcurrentOptimization(); 7267 inline bool IsMarkedForConcurrentOptimization();
7222 7268
7223 // Tells whether or not the function is on the concurrent recompilation queue. 7269 // Tells whether or not the function is on the concurrent recompilation queue.
7224 inline bool IsInOptimizationQueue(); 7270 inline bool IsInOptimizationQueue();
7225 7271
7226 // Inobject slack tracking is the way to reclaim unused inobject space. 7272 // Completes inobject slack tracking on initial map if it is active.
7227 // 7273 inline void CompleteInobjectSlackTrackingIfActive();
7228 // The instance size is initially determined by adding some slack to
7229 // expected_nof_properties (to allow for a few extra properties added
7230 // after the constructor). There is no guarantee that the extra space
7231 // will not be wasted.
7232 //
7233 // Here is the algorithm to reclaim the unused inobject space:
7234 // - Detect the first constructor call for this JSFunction.
7235 // When it happens enter the "in progress" state: initialize construction
7236 // counter in the initial_map.
7237 // - While the tracking is in progress create objects filled with
7238 // one_pointer_filler_map instead of undefined_value. This way they can be
7239 // resized quickly and safely.
7240 // - Once enough objects have been created compute the 'slack'
7241 // (traverse the map transition tree starting from the
7242 // initial_map and find the lowest value of unused_property_fields).
7243 // - Traverse the transition tree again and decrease the instance size
7244 // of every map. Existing objects will resize automatically (they are
7245 // filled with one_pointer_filler_map). All further allocations will
7246 // use the adjusted instance size.
7247 // - SharedFunctionInfo's expected_nof_properties left unmodified since
7248 // allocations made using different closures could actually create different
7249 // kind of objects (see prototype inheritance pattern).
7250 //
7251 // Important: inobject slack tracking is not attempted during the snapshot
7252 // creation.
7253
7254 // True if the initial_map is set and the object constructions countdown
7255 // counter is not zero.
7256 static const int kGenerousAllocationCount =
7257 Map::kSlackTrackingCounterStart - Map::kSlackTrackingCounterEnd + 1;
7258 inline bool IsInobjectSlackTrackingInProgress();
7259
7260 // Starts the tracking.
7261 // Initializes object constructions countdown counter in the initial map.
7262 void StartInobjectSlackTracking();
7263
7264 // Completes the tracking.
7265 void CompleteInobjectSlackTracking();
7266 7274
7267 // [literals_or_bindings]: Fixed array holding either 7275 // [literals_or_bindings]: Fixed array holding either
7268 // the materialized literals or the bindings of a bound function. 7276 // the materialized literals or the bindings of a bound function.
7269 // 7277 //
7270 // If the function contains object, regexp or array literals, the 7278 // If the function contains object, regexp or array literals, the
7271 // literals array prefix contains the object, regexp, and array 7279 // literals array prefix contains the object, regexp, and array
7272 // function to be used when creating these literals. This is 7280 // function to be used when creating these literals. This is
7273 // necessary so that we do not dynamically lookup the object, regexp 7281 // necessary so that we do not dynamically lookup the object, regexp
7274 // or array functions. Performing a dynamic lookup, we might end up 7282 // or array functions. Performing a dynamic lookup, we might end up
7275 // using the functions from a new context that we should not have 7283 // using the functions from a new context that we should not have
(...skipping 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after
10710 } 10718 }
10711 return value; 10719 return value;
10712 } 10720 }
10713 }; 10721 };
10714 10722
10715 10723
10716 } // NOLINT, false-positive due to second-order macros. 10724 } // NOLINT, false-positive due to second-order macros.
10717 } // NOLINT, false-positive due to second-order macros. 10725 } // NOLINT, false-positive due to second-order macros.
10718 10726
10719 #endif // V8_OBJECTS_H_ 10727 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips64/builtins-mips64.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698