Commit c2aa8f38 authored by verwaest's avatar verwaest Committed by Commit bot

[runtime] Speed up allocating instances in the runtime by having a quick-check...

[runtime] Speed up allocating instances in the runtime by having a quick-check for inobject slack tracking.

This speeds up
https://github.com/kpdecker/six-speed/blob/master/tests/object-assign/object-assign.es5
by over 5%.

Review URL: https://codereview.chromium.org/1690923002

Cr-Commit-Position: refs/heads/master@{#33917}
parent 2646b62a
......@@ -3446,7 +3446,6 @@ void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) {
if (start_offset == map->instance_size()) return;
DCHECK_LT(start_offset, map->instance_size());
Object* filler;
// We cannot always fill with one_pointer_filler_map because objects
// created from API functions expect their internal fields to be initialized
// with undefined_value.
......@@ -3456,15 +3455,17 @@ void Heap::InitializeJSObjectBody(JSObject* obj, Map* map, int start_offset) {
// In case of Array subclassing the |map| could already be transitioned
// to different elements kind from the initial map on which we track slack.
Map* initial_map = map->FindRootMap();
if (initial_map->IsInobjectSlackTrackingInProgress()) {
// We might want to shrink the object later.
filler = Heap::one_pointer_filler_map();
bool in_progress = map->IsInobjectSlackTrackingInProgress();
Object* filler;
if (in_progress) {
filler = one_pointer_filler_map();
} else {
filler = Heap::undefined_value();
filler = undefined_value();
}
obj->InitializeBody(map, start_offset, Heap::undefined_value(), filler);
initial_map->InobjectSlackTrackingStep();
if (in_progress) {
map->FindRootMap()->InobjectSlackTrackingStep();
}
}
......
......@@ -9310,8 +9310,6 @@ Handle<Map> Map::RawCopy(Handle<Map> map, int instance_size) {
if (!map->is_dictionary_map()) {
new_bit_field3 = IsUnstable::update(new_bit_field3, false);
}
new_bit_field3 =
ConstructionCounter::update(new_bit_field3, kNoSlackTracking);
result->set_bit_field3(new_bit_field3);
return result;
}
......@@ -9398,6 +9396,7 @@ Handle<Map> Map::CopyNormalized(Handle<Map> map,
result->set_dictionary_map(true);
result->set_migration_target(false);
result->set_construction_counter(kNoSlackTracking);
#ifdef VERIFY_HEAP
if (FLAG_verify_heap) result->DictionaryMapVerify();
......@@ -12713,6 +12712,7 @@ static void ShrinkInstanceSize(Map* map, void* data) {
map->SetInObjectProperties(map->GetInObjectProperties() - slack);
map->set_unused_property_fields(map->unused_property_fields() - slack);
map->set_instance_size(map->instance_size() - slack * kPointerSize);
map->set_construction_counter(Map::kNoSlackTracking);
// Visitor id might depend on the instance size, recalculate it.
map->set_visitor_id(Heap::GetStaticVisitorIdForMap(map));
......@@ -12723,8 +12723,6 @@ void Map::CompleteInobjectSlackTracking() {
// Has to be an initial map.
DCHECK(GetBackPointer()->IsUndefined());
set_construction_counter(kNoSlackTracking);
int slack = unused_property_fields();
TransitionArray::TraverseTransitionTree(this, &GetMinInobjectSlack, &slack);
if (slack != 0) {
......@@ -13316,6 +13314,7 @@ MaybeHandle<Map> JSFunction::GetDerivedMap(Isolate* isolate,
JSFunction::SetInitialMap(function, map, prototype);
map->SetConstructor(*constructor);
map->set_construction_counter(Map::kNoSlackTracking);
map->StartInobjectSlackTracking();
return map;
}
......
......@@ -5584,7 +5584,11 @@ class Map: public HeapObject {
// Builtins::kJSConstructStubGeneric stub.
// This counter is used for in-object slack tracking.
// The in-object slack tracking is considered enabled when the counter is
// non zero.
// non zero. The counter only has a valid count for initial maps. For
// transitioned maps only kNoSlackTracking has a meaning, namely that inobject
// slack tracking already finished for the transition tree. Any other value
// indicates that either inobject slack tracking is still in progress, or that
// the map isn't part of the transition tree anymore.
class ConstructionCounter : public BitField<int, 29, 3> {};
static const int kSlackTrackingCounterStart = 7;
static const int kSlackTrackingCounterEnd = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment