Commit ee46c631 authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[cleanup] Remove unused EstimateNumberOfElements runtime function

R=jgruber@chromium.org

Bug: v8:9183
Change-Id: I773af2e44bbfb780a3cf375e6412274fe917d397
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1617250
Commit-Queue: Simon Zünd <szuend@chromium.org>
Auto-Submit: Simon Zünd <szuend@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61616}
parent 32cfe260
......@@ -262,7 +262,6 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(GetProperty) \
/* Arrays */ \
V(ArraySpeciesConstructor) \
V(EstimateNumberOfElements) \
V(HasComplexElements) \
V(HasFastPackedElements) \
V(NewArray) \
......
......@@ -422,44 +422,6 @@ RUNTIME_FUNCTION(Runtime_PrepareElementsForSort) {
return RemoveArrayHoles(isolate, object, length);
}
// How many elements does this object/array have?
RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) {
DisallowHeapAllocation no_gc;
HandleScope scope(isolate);
DCHECK_EQ(1, args.length());
CONVERT_ARG_CHECKED(JSArray, array, 0);
FixedArrayBase elements = array->elements();
SealHandleScope shs(isolate);
if (elements->IsNumberDictionary()) {
int result = NumberDictionary::cast(elements)->NumberOfElements();
return Smi::FromInt(result);
} else {
DCHECK(array->length()->IsSmi());
// For packed elements, we know the exact number of elements
int length = elements->length();
ElementsKind kind = array->GetElementsKind();
if (IsFastPackedElementsKind(kind)) {
return Smi::FromInt(length);
}
// For holey elements, take samples from the buffer checking for holes
// to generate the estimate.
const int kNumberOfHoleCheckSamples = 97;
int increment = (length < kNumberOfHoleCheckSamples)
? 1
: static_cast<int>(length / kNumberOfHoleCheckSamples);
ElementsAccessor* accessor = array->GetElementsAccessor();
int holes = 0;
for (int i = 0; i < length; i += increment) {
if (!accessor->HasElement(array, i, elements)) {
++holes;
}
}
int estimate = static_cast<int>((kNumberOfHoleCheckSamples - holes) /
kNumberOfHoleCheckSamples * length);
return Smi::FromInt(estimate);
}
}
RUNTIME_FUNCTION(Runtime_TrySliceSimpleNonFastElements) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
......
......@@ -42,7 +42,6 @@ namespace internal {
F(ArrayIndexOf, 3, 1) \
F(ArrayIsArray, 1, 1) \
F(ArraySpeciesConstructor, 1, 1) \
F(EstimateNumberOfElements, 1, 1) \
F(GrowArrayElements, 2, 1) \
F(HasComplexElements, 1, 1) \
I(IsArray, 1, 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