Extract JSObject class from objects.cc
I extracted following class member functions to js-objects.cc * JSReceiver * JSObject * JSBoundFunction * JSFunction * JSGlobalObject * JSDate * JSMessageObject Declaration of all above class are in js-objects.h. I also moved AllocationSite::DigestTransitionFeedback used in JSObject::UpdateAllocationSite and ShouldConvertToSlowElements used in JSObject and JSArray This patch makes compile time of objects.cc from 17.6s to 14.1s on Z840 Linux. And js-objects.cc takes 8.69s for compile. Bug: v8:7629 Change-Id: I989f22363667445dd28d7f8c06c81ff79d6ed45f Reviewed-on: https://chromium-review.googlesource.com/c/1447916 Commit-Queue: Takuto Ikuta <tikuta@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Marja Hölttä <marja@chromium.org> Cr-Commit-Position: refs/heads/master@{#59288}
This commit is contained in:
parent
f0d69fc913
commit
b8c821f4e2
2
BUILD.gn
2
BUILD.gn
@ -834,6 +834,7 @@ action("postmortem-metadata") {
|
||||
"src/objects/map.h",
|
||||
"src/objects/map.cc",
|
||||
"src/objects/map-inl.h",
|
||||
"src/objects/js-objects.cc",
|
||||
"src/objects/name.h",
|
||||
"src/objects/name-inl.h",
|
||||
"src/objects/oddball-inl.h",
|
||||
@ -2245,6 +2246,7 @@ v8_source_set("v8_base") {
|
||||
"src/objects/js-number-format.cc",
|
||||
"src/objects/js-number-format.h",
|
||||
"src/objects/js-objects-inl.h",
|
||||
"src/objects/js-objects.cc",
|
||||
"src/objects/js-objects.h",
|
||||
"src/objects/js-plural-rules-inl.h",
|
||||
"src/objects/js-plural-rules.cc",
|
||||
|
5845
src/objects.cc
5845
src/objects.cc
File diff suppressed because it is too large
Load Diff
@ -194,6 +194,64 @@ Address AllocationMemento::GetAllocationSiteUnchecked() const {
|
||||
return allocation_site()->ptr();
|
||||
}
|
||||
|
||||
template <AllocationSiteUpdateMode update_or_check>
|
||||
bool AllocationSite::DigestTransitionFeedback(Handle<AllocationSite> site,
|
||||
ElementsKind to_kind) {
|
||||
Isolate* isolate = site->GetIsolate();
|
||||
bool result = false;
|
||||
|
||||
if (site->PointsToLiteral() && site->boilerplate()->IsJSArray()) {
|
||||
Handle<JSArray> boilerplate(JSArray::cast(site->boilerplate()), isolate);
|
||||
ElementsKind kind = boilerplate->GetElementsKind();
|
||||
// if kind is holey ensure that to_kind is as well.
|
||||
if (IsHoleyElementsKind(kind)) {
|
||||
to_kind = GetHoleyElementsKind(to_kind);
|
||||
}
|
||||
if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
|
||||
// If the array is huge, it's not likely to be defined in a local
|
||||
// function, so we shouldn't make new instances of it very often.
|
||||
uint32_t length = 0;
|
||||
CHECK(boilerplate->length()->ToArrayLength(&length));
|
||||
if (length <= kMaximumArrayBytesToPretransition) {
|
||||
if (update_or_check == AllocationSiteUpdateMode::kCheckOnly) {
|
||||
return true;
|
||||
}
|
||||
if (FLAG_trace_track_allocation_sites) {
|
||||
bool is_nested = site->IsNested();
|
||||
PrintF("AllocationSite: JSArray %p boilerplate %supdated %s->%s\n",
|
||||
reinterpret_cast<void*>(site->ptr()),
|
||||
is_nested ? "(nested)" : " ", ElementsKindToString(kind),
|
||||
ElementsKindToString(to_kind));
|
||||
}
|
||||
JSObject::TransitionElementsKind(boilerplate, to_kind);
|
||||
site->dependent_code()->DeoptimizeDependentCodeGroup(
|
||||
isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// The AllocationSite is for a constructed Array.
|
||||
ElementsKind kind = site->GetElementsKind();
|
||||
// if kind is holey ensure that to_kind is as well.
|
||||
if (IsHoleyElementsKind(kind)) {
|
||||
to_kind = GetHoleyElementsKind(to_kind);
|
||||
}
|
||||
if (IsMoreGeneralElementsKindTransition(kind, to_kind)) {
|
||||
if (update_or_check == AllocationSiteUpdateMode::kCheckOnly) return true;
|
||||
if (FLAG_trace_track_allocation_sites) {
|
||||
PrintF("AllocationSite: JSArray %p site updated %s->%s\n",
|
||||
reinterpret_cast<void*>(site->ptr()), ElementsKindToString(kind),
|
||||
ElementsKindToString(to_kind));
|
||||
}
|
||||
site->SetElementsKind(to_kind);
|
||||
site->dependent_code()->DeoptimizeDependentCodeGroup(
|
||||
isolate, DependentCode::kAllocationSiteTransitionChangedGroup);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "src/lookup-inl.h"
|
||||
#include "src/objects/embedder-data-slot-inl.h"
|
||||
#include "src/objects/feedback-cell-inl.h"
|
||||
#include "src/objects/hash-table-inl.h"
|
||||
#include "src/objects/heap-number-inl.h"
|
||||
#include "src/objects/property-array-inl.h"
|
||||
#include "src/objects/shared-function-info.h"
|
||||
@ -976,6 +977,34 @@ ACCESSORS(JSAsyncFromSyncIterator, next, Object, kNextOffset)
|
||||
ACCESSORS(JSStringIterator, string, String, kStringOffset)
|
||||
SMI_ACCESSORS(JSStringIterator, index, kNextIndexOffset)
|
||||
|
||||
static inline bool ShouldConvertToSlowElements(JSObject object,
|
||||
uint32_t capacity,
|
||||
uint32_t index,
|
||||
uint32_t* new_capacity) {
|
||||
STATIC_ASSERT(JSObject::kMaxUncheckedOldFastElementsLength <=
|
||||
JSObject::kMaxUncheckedFastElementsLength);
|
||||
if (index < capacity) {
|
||||
*new_capacity = capacity;
|
||||
return false;
|
||||
}
|
||||
if (index - capacity >= JSObject::kMaxGap) return true;
|
||||
*new_capacity = JSObject::NewElementsCapacity(index + 1);
|
||||
DCHECK_LT(index, *new_capacity);
|
||||
// TODO(ulan): Check if it works with young large objects.
|
||||
if (*new_capacity <= JSObject::kMaxUncheckedOldFastElementsLength ||
|
||||
(*new_capacity <= JSObject::kMaxUncheckedFastElementsLength &&
|
||||
Heap::InYoungGeneration(object))) {
|
||||
return false;
|
||||
}
|
||||
// If the fast-case backing storage takes up much more memory than a
|
||||
// dictionary backing storage would, the object should have slow elements.
|
||||
int used_elements = object->GetFastElementsUsage();
|
||||
uint32_t size_threshold = NumberDictionary::kPreferFastElementsSizeFactor *
|
||||
NumberDictionary::ComputeCapacity(used_elements) *
|
||||
NumberDictionary::kEntrySize;
|
||||
return size_threshold <= *new_capacity;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
|
5768
src/objects/js-objects.cc
Normal file
5768
src/objects/js-objects.cc
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user