summaryrefslogtreecommitdiff
path: root/deps/v8/src/builtins/array-of.tq
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/builtins/array-of.tq')
-rw-r--r--deps/v8/src/builtins/array-of.tq23
1 files changed, 15 insertions, 8 deletions
diff --git a/deps/v8/src/builtins/array-of.tq b/deps/v8/src/builtins/array-of.tq
index 44c2cdca27..b469ec5f5c 100644
--- a/deps/v8/src/builtins/array-of.tq
+++ b/deps/v8/src/builtins/array-of.tq
@@ -19,14 +19,21 @@ ArrayOf(
let a: JSReceiver;
// 4. If IsConstructor(C) is true, then
- typeswitch (c) {
- case (c: Constructor): {
- // a. Let A be ? Construct(C, « len »).
- a = Construct(c, len);
- }
- case (JSAny): {
- // a. Let A be ? ArrayCreate(len).
- a = ArrayCreate(len);
+ try {
+ // Allocate an array with PACKED elements kind for fast-path rather than
+ // calling the constructor which creates an array with HOLEY kind.
+ if (c != GetArrayFunction()) goto CreateWithConstructor;
+ a = NewJSArrayFilledWithZero(SmiUntag(len)) otherwise CreateWithConstructor;
+ } label CreateWithConstructor {
+ typeswitch (c) {
+ case (c: Constructor): {
+ // a. Let A be ? Construct(C, « len »).
+ a = Construct(c, len);
+ }
+ case (JSAny): {
+ // a. Let A be ? ArrayCreate(len).
+ a = ArrayCreate(len);
+ }
}
}