← All issues

DFG ArrayShift intrinsic node

dfe5dc6

DFG bytecode parser는 일반 JS 함수 호출을 직접 설계한 node로 대체할 수 있습니다. 이 node는 backend에서 고도로 최적화된 machine code로 변환됩니다. 새로운 intrinsic을 추가하려면 node를 다루는 모든 phase에 연동해야 합니다. type fixup, clobber analysis, abstract interpretation, GC interaction tracking, 각 backend의 code generator까지, 빠짐없이 대응 대상에 포함됩니다. Array.shift()Array.pop()보다 의미적으로 더 복잡합니다. 배열의 앞쪽 요소를 제거하는 특성상, length가 1보다 클 때는 전체 요소 이동이 필요하기 때문입니다.

이 commit은 ArrayShift를 새로운 DFG intrinsic node로 추가했습니다. 전체 DFG/FTL pipeline(fixup, clobberize, abstract interpreter, B3 lowering)에 걸쳐 연동됩니다. inline fast path는 length가 0 또는 1인 배열만 처리하며, length가 2 이상인 경우에는 runtime에서 operationArrayShift로 넘어갑니다. fast path에서는 storage[0]을 읽고, 해당 슬롯에 empty를 저장한 뒤, publicLength를 감소시킵니다. prototype-chain 처리는 우회됩니다.

storage의 앞쪽을 변경하는, 자주 사용되는 array operation에 JIT 컴파일된 machine code가 추가되었습니다. 기존에는 C++만으로 처리되던 경로가 이제 speculative machine code로 실행되며, 자체적인 GC interaction 및 OSR-exit 경계를 갖게 되었습니다.

🔒

New JIT intrinsic with direct butterfly writes and a narrow fast path — several edge cases in the inline path are worth security investigation.

더 확인하려면 구독해 주세요