Commit cc7c7528 authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[js-perf-test] Properly create packed arrays in Array tests

Drive-by: Change the macro magic around elements kind runtime predicates
to make the function names grep-able.

Fixed: v8:10105
Change-Id: Id5046bd0e60f40611c6c264613729fb9c6b73853
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3420306Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Auto-Submit: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/main@{#79005}
parent f0ca45b5
......@@ -1223,23 +1223,23 @@ RUNTIME_FUNCTION(Runtime_RegexpIsUnmodified) {
RegExp::IsUnmodifiedRegExp(isolate, regexp));
}
#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
RUNTIME_FUNCTION(Runtime_Has##Name) { \
CONVERT_ARG_CHECKED(JSObject, obj, 0); \
return isolate->heap()->ToBoolean(obj.Has##Name()); \
}
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SmiElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(ObjectElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SmiOrObjectElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DoubleElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HoleyElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(DictionaryElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(PackedElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(SloppyArgumentsElements)
#define ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(Name) \
RUNTIME_FUNCTION(Runtime_##Name) { \
CONVERT_ARG_CHECKED(JSObject, obj, 0); \
return isolate->heap()->ToBoolean(obj.Name()); \
}
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasFastElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasSmiElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasObjectElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasSmiOrObjectElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasDoubleElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasHoleyElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasDictionaryElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasPackedElements)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasSloppyArgumentsElements)
// Properties test sitting with elements tests - not fooling anyone.
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(FastProperties)
ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION(HasFastProperties)
#undef ELEMENTS_KIND_CHECK_RUNTIME_FUNCTION
......
......@@ -34,34 +34,46 @@ function MakeHoley(array) {
}
function SmiSetup() {
array = Array.from({ length: array_size }, (_, i) => i);
array = [];
for (let i = 0; i < array_size; i++) array.push(i);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasSmiElements(array));
}
function HoleySmiSetup() {
SmiSetup();
array = [];
for (let i = 0; i < array_size; i++) array.push(i);
MakeHoley(array);
assert(%HasSmiElements(array));
}
function DoubleSetup() {
array = Array.from({ length: array_size }, (_, i) => i + 0.5);
array = [];
for (let i = 0; i < array_size; i++) array.push(i + 0.5);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasDoubleElements(array));
}
function HoleyDoubleSetup() {
DoubleSetup();
array = [];
for (let i = 0; i < array_size; i++) array.push(i + 0.5);
MakeHoley(array);
assert(%HasDoubleElements(array));
}
function FastSetup() {
array = Array.from({ length: array_size }, (_, i) => `value ${i}`);
array = [];
for (let i = 0; i < array_size; i++) array.push(`value ${i}`);
// TODO(v8:10105): May still create holey arrays (allocation sites?).
// assert(%HasFastPackedElements(array));
assert(%HasObjectElements(array));
}
function HoleyFastSetup() {
FastSetup();
array = [];
for (let i = 0; i < array_size; i++) array.push(`value ${i}`);
MakeHoley(array);
assert(%HasObjectElements(array));
}
......
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