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

[cleanup] Remove unused TrySimpleSlice array runtime function

This CL also removes the ElementsAccessor "slice" implementation, as
the runtime function is the last use site.

R=verwaest@chromium.org

Bug: v8:9183
Change-Id: If268e20120e7c7bb4a58d9560482b35896b0992f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1617662Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarYang Guo <yangguo@chromium.org>
Commit-Queue: Simon Zünd <szuend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61635}
parent d1d61ea8
......@@ -266,7 +266,6 @@ bool IntrinsicHasNoSideEffect(Runtime::FunctionId id) {
V(NewArray) \
V(NormalizeElements) \
V(PrepareElementsForSort) \
V(TrySliceSimpleNonFastElements) \
V(TypedArrayGetBuffer) \
/* Errors */ \
V(NewTypeError) \
......
......@@ -732,16 +732,6 @@ class ElementsAccessorBase : public InternalElementsAccessor {
UNREACHABLE();
}
Handle<JSObject> Slice(Handle<JSObject> receiver, uint32_t start,
uint32_t end) final {
return Subclass::SliceImpl(receiver, start, end);
}
static Handle<JSObject> SliceImpl(Handle<JSObject> receiver, uint32_t start,
uint32_t end) {
UNREACHABLE();
}
Handle<Object> Pop(Handle<JSArray> receiver) final {
return Subclass::PopImpl(receiver);
}
......@@ -1497,38 +1487,6 @@ class DictionaryElementsAccessor
UNREACHABLE();
}
static Handle<JSObject> SliceImpl(Handle<JSObject> receiver, uint32_t start,
uint32_t end) {
Isolate* isolate = receiver->GetIsolate();
uint32_t result_length = end < start ? 0u : end - start;
// Result must also be a dictionary.
Handle<JSArray> result_array =
isolate->factory()->NewJSArray(0, HOLEY_ELEMENTS);
JSObject::NormalizeElements(result_array);
result_array->set_length(Smi::FromInt(result_length));
Handle<NumberDictionary> source_dict(
NumberDictionary::cast(receiver->elements()), isolate);
int entry_count = source_dict->Capacity();
ReadOnlyRoots roots(isolate);
for (int i = 0; i < entry_count; i++) {
Object key = source_dict->KeyAt(i);
if (!source_dict->ToKey(roots, i, &key)) continue;
uint64_t key_value = NumberToInt64(key);
if (key_value >= start && key_value < end) {
Handle<NumberDictionary> dest_dict(
NumberDictionary::cast(result_array->elements()), isolate);
Handle<Object> value(source_dict->ValueAt(i), isolate);
PropertyDetails details = source_dict->DetailsAt(i);
PropertyAttributes attr = details.attributes();
AddImpl(result_array, static_cast<uint32_t>(key_value) - start, value,
attr, 0);
}
}
return result_array;
}
static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) {
Handle<NumberDictionary> dict(NumberDictionary::cast(obj->elements()),
obj->GetIsolate());
......@@ -2218,21 +2176,6 @@ class FastElementsAccessor : public ElementsAccessorBase<Subclass, KindTraits> {
AT_START);
}
static Handle<JSObject> SliceImpl(Handle<JSObject> receiver, uint32_t start,
uint32_t end) {
Isolate* isolate = receiver->GetIsolate();
Handle<FixedArrayBase> backing_store(receiver->elements(), isolate);
int result_len = end < start ? 0u : end - start;
Handle<JSArray> result_array = isolate->factory()->NewJSArray(
KindTraits::Kind, result_len, result_len);
DisallowHeapAllocation no_gc;
Subclass::CopyElementsImpl(isolate, *backing_store, start,
result_array->elements(), KindTraits::Kind, 0,
kPackedSizeNotKnown, result_len);
Subclass::TryTransitionResultArrayToPacked(result_array);
return result_array;
}
static void MoveElements(Isolate* isolate, Handle<JSArray> receiver,
Handle<FixedArrayBase> backing_store, int dst_index,
int src_index, int len, int hole_start,
......@@ -4092,29 +4035,6 @@ class SloppyArgumentsElementsAccessor
}
return Just<int64_t>(-1);
}
static Handle<JSObject> SliceImpl(Handle<JSObject> receiver, uint32_t start,
uint32_t end) {
Isolate* isolate = receiver->GetIsolate();
uint32_t result_len = end < start ? 0u : end - start;
Handle<JSArray> result_array =
isolate->factory()->NewJSArray(HOLEY_ELEMENTS, result_len, result_len);
DisallowHeapAllocation no_gc;
FixedArray elements = FixedArray::cast(result_array->elements());
FixedArray parameters = FixedArray::cast(receiver->elements());
uint32_t insertion_index = 0;
for (uint32_t i = start; i < end; i++) {
uint32_t entry = GetEntryForIndexImpl(isolate, *receiver, parameters, i,
ALL_PROPERTIES);
if (entry != kMaxUInt32 && HasEntryImpl(isolate, parameters, entry)) {
elements->set(insertion_index, *GetImpl(isolate, parameters, entry));
} else {
elements->set_the_hole(isolate, insertion_index);
}
insertion_index++;
}
return result_array;
}
};
......
......@@ -132,9 +132,6 @@ class ElementsAccessor {
virtual uint32_t Unshift(Handle<JSArray> receiver, Arguments* args,
uint32_t unshift_size) = 0;
virtual Handle<JSObject> Slice(Handle<JSObject> receiver, uint32_t start,
uint32_t end) = 0;
virtual Handle<Object> Pop(Handle<JSArray> receiver) = 0;
virtual Handle<Object> Shift(Handle<JSArray> receiver) = 0;
......
......@@ -422,44 +422,6 @@ RUNTIME_FUNCTION(Runtime_PrepareElementsForSort) {
return RemoveArrayHoles(isolate, object, length);
}
RUNTIME_FUNCTION(Runtime_TrySliceSimpleNonFastElements) {
HandleScope scope(isolate);
DCHECK_EQ(3, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
CONVERT_SMI_ARG_CHECKED(first, 1);
CONVERT_SMI_ARG_CHECKED(count, 2);
uint32_t length = first + count;
// Only handle elements kinds that have a ElementsAccessor Slice
// implementation.
if (receiver->IsJSArray()) {
// This "fastish" path must make sure the destination array is a JSArray.
if (!isolate->IsArraySpeciesLookupChainIntact() ||
!JSArray::cast(*receiver)->HasArrayPrototype(isolate)) {
return Smi::FromInt(0);
}
} else {
int len;
if (!receiver->IsJSObject() ||
!JSSloppyArgumentsObject::GetSloppyArgumentsLength(
isolate, Handle<JSObject>::cast(receiver), &len) ||
(length > static_cast<uint32_t>(len))) {
return Smi::FromInt(0);
}
}
// This "fastish" path must also ensure that elements are simple (no
// geters/setters), no elements on prototype chain.
Handle<JSObject> object(Handle<JSObject>::cast(receiver));
if (!JSObject::PrototypeHasNoElements(isolate, *object) ||
object->HasComplexElements()) {
return Smi::FromInt(0);
}
ElementsAccessor* accessor = object->GetElementsAccessor();
return *accessor->Slice(object, first, length);
}
RUNTIME_FUNCTION(Runtime_NewArray) {
HandleScope scope(isolate);
DCHECK_LE(3, args.length());
......
......@@ -50,7 +50,6 @@ namespace internal {
F(PrepareElementsForSort, 2, 1) \
F(TransitionElementsKind, 2, 1) \
F(TransitionElementsKindWithKind, 2, 1) \
F(TrySliceSimpleNonFastElements, 3, 1)
#define FOR_EACH_INTRINSIC_ATOMICS(F, I) \
F(AtomicsLoad64, 2, 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