Commit bddc6aa5 authored by Takuto Ikuta's avatar Takuto Ikuta Committed by Commit Bot

Reland "Reland "Extract JSObject class from objects.cc""

This is a reland of 83908b86

Fix: check V8_INTL_SUPPORT macro in js-objects.cc

Original change's description:
> Reland "Extract JSObject class from objects.cc"
>
> This is a reland of b8c821f4
>
> Fix: include src/string-stream.h for compile failure
> https://ci.chromium.org/p/v8/builders/luci.v8.ci/V8%20Linux%20-%20builder/39320
>
> Original change's description:
> > 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}
>
> Bug: v8:7629
> Bug: v8:8562
> Change-Id: Iac2227c5f0c5a4072d16814ecae481fb4720e4f5
> Reviewed-on: https://chromium-review.googlesource.com/c/1449951
> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
> Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#59318}

Bug: v8:7629, v8:8562
Change-Id: If8870bd579d8597d08981a83492f60595e081a65
Reviewed-on: https://chromium-review.googlesource.com/c/1452097Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Takuto Ikuta <tikuta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59329}
parent ac73e1d5
......@@ -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",
......@@ -2246,6 +2247,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",
......
This diff is collapsed.
......@@ -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
......
This diff is collapsed.
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