Files
v8/test/mjsunit/array-destructuring-setter-order.js
Leszek Swirski 636546215e [interpreter] Add experimental ArrayDestructure bytecode
Implement an experimental bytecode `ArrayDestructure <outputs> <count>`
guarded by the `--array-destructure-bytecode` flag to optimize
destructuring patterns of the form `let [x, y, ...] = iterable;`.

Key highlights across execution tiers:
- Builtin: Adds `Builtin::kArrayDestructure` builtin which returns N
  iterated elements out of an iterator in a FixedArray, with a fast
  path for JSArray iteration.
- Ignition: Adds `ArrayDestructure` bytecode handler which calls the
  `Builtin::kArrayDestructure` and copies the result to a RegList. The
  values from that RegList are then written out into the target bytecode
  registers as needed, handling destructuring holes and default values.
- Sparkplug: Calls the `Builtin::kArrayDestructure` builtin and emits
  direct FixedArray reads for the multi-register output.
- Maglev: Adds IR node `JSArrayDestructure` and graph builder
  reduction (`VisitArrayDestructure`), which for now also calls the
  `Builtin::kArrayDestructure` builtin with direct inline FixedArray
  loads that populate the abstract interpreter state. Since the builtin
  can lazy deopt the Maglev code, we have a lazy deopt continuation that
  populates the RegList (`kArrayDestructureLazyDeoptContinuation`).
- TurboFan: Adds operator `JSArrayDestructure` in `JSOperatorBuilder`
  which has N outputs that are read through Projections, and generic
  lowering in `JSGenericLowering::LowerJSArrayDestructure` which for now
  does effectively the same thing as Maglev, turning the Projections
  into FixedArray reads and adding the lazy deopt continuation.

TAG=agy
Conversation-Id: 7fc7c031-68c6-4ddc-bdff-6ce4e63adc59

Change-Id: I1bbe22f3cab2c147a4d6519cb88052ca8176c4cd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7994076
Commit-Queue: Darius Mercadier <dmercadier@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Darius Mercadier <dmercadier@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/main@{#108353}
2026-07-01 02:39:45 -07:00

27 lines
481 B
JavaScript

// Copyright 2026 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --array-destructure-bytecode
let log = [];
function* gen() {
log.push("gen 1");
yield 1;
log.push("gen 2");
yield 2;
}
let obj = {
set foo(val) {
log.push("set foo: " + val);
}
};
let y;
[obj.foo, y] = gen();
assertEquals(["gen 1", "set foo: 1", "gen 2"], log);
assertEquals(2, y);