릴리스 노트는 영어로 작성되어 있습니다.
Generators that actually suspend: function*/yield on the resumable VM
Generators were faking it. Calling a `function*` used to run the whole body to completion right then and there, collecting every `yield` into a hidden array and handing back an iterator over that finished list. That is fine for the simplest finite case and wrong for everything else: an infinite generator hung the tab, `const x = yield` could never receive the value passed to `.next(v)`, and all of a generator's side effects fired up front in the wrong order. They are real now, built on the SAME resumable interpreter that fixed async/await: calling a `function*` returns a generator object and runs NOTHING; each `.next()` runs the body to the next `yield`, which suspends it - reifying its stack, environment and try/finally state onto the heap - and resumes it synchronously on the next call. So an infinite `while(true) yield i++` is fine as long as you pull finitely many values, `.next(v)` delivers `v` to the waiting `yield`, `.return()` runs a spanning `finally`, `.throw()` is catchable inside, and `yield*` delegates to any iterable. for-of, spread, destructuring, `Array.from`, `new Map(gen)` and a class whose `[Symbol.iterator]` is a `*method` all drive them through the real iterator protocol. JavaScript language moves 78 to 80; overall holds at 50, because a language feature - however flagship - is not one of the named infrastructure floors (GPU, video, HTTP/2, multi-process) that gate the climb past halfway. 24 behaviour tests, gate 6375/6375.
바뀐 점
변경 3개- JavaScript와 JITfunction*/yield are real lazy generators now, not the old eager stub. Calling a generator runs none of the body; each .next() runs to the next yield and suspends there, reifying the frame (operand stack, environment, and its try/finally/staged-completion state) onto the heap exactly as async/await does, then resumes synchronously on the next call. Proven by laziness, infinity and two-way tests the eager model could never pass: side effects interleave with consumer code, `function* nats(){ while(true) yield i++ }` yields its first values without hanging, and `.next(v)` is the value of the resumed yield.
- 렌더링Two-way communication and early termination: `const x = yield e` evaluates to whatever `.next(v)` passes, `.throw(e)` throws at the yield point so a try/catch spanning it can handle it, and `.return(v)` performs a return there, running any finally that spans the yield. A generator that creates and drives another generator mid-body keeps its own suspended slot with no aliasing.
- JavaScript와 JITThe iterator protocol is wired through the VM: for-of, spread `[...g()]`, array destructuring, `Array.from`, `Object.groupBy`, and `new Map`/`new Set`/`new WeakMap`/`new WeakSet` all drive a generator or user iterator by calling its `.next()`, and `yield* iterable` delegates to arrays, strings and other generators (pulled lazily) and evaluates to the inner iterators return value. A class whose `[Symbol.iterator]` is a `*method` is now iterable - the everyday way to make an object iterable. Research note: docs/generators-resumable-vm.md.