Skip to main content

torque

Provides expert guidance for navigating, implementing, and verifying V8 Torque (.tq) builtins. Use when modifying or debugging Torque files. Do not use for C++ macro builtins.

소스 정보

저장소
nodejs/node
최근 소스 활동
2026년 10월 4일 21:04
감지된 SKILL.md 언어
영어
스타
122,576
포크
39,930

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
torque
description
Provides expert guidance for navigating, implementing, and verifying V8 Torque (.tq) builtins. Use when modifying or debugging Torque files. Do not use for C++ macro builtins.
# V8 Torque Torque is an Ahead-of-Time (AOT) generator that transforms `.tq` DSL into highly-optimized C++ CodeStubAssembler (CSA) code, which is then compiled into the `mksnapshot` binary. ## Execution Pipeline To debug failures, you must understand its multi-stage build: 1. **Generation**: The Torque compiler reads `.tq` files and generates C++ CodeStubAssembler files (`.cc`, `.h`, `.inc`) in `out/<config>/gen/torque-generated/`. 2. **Compilation**: `mksnapshot` (or the `d8` build) compiles the generated C++ files. 3. **Snapshotting**: `mksnapshot` executes the generated C++ code (via TurboFan or Maglev) to emit highly-optimized raw machine code. 4. **Linking**: The machine code is serialized into a snapshot and linked into V8, meaning Torque builtins run with zero translation overhead at runtime. ## Implementation Patterns Common Torque syntax, keywords, and linkage definitions: ```cpp // 1. Type Casting & Checks const array = Cast<JSArray>(object) otherwise GotoLabel; if (Is<JSArray>(object)) { ... } // 2. Control Flow try { const smi = Cast<Smi>(input) otherwise IsNotSmi; } label IsNotSmi deferred { return runtime::DoSomething(context, input); } // 3. Signatures & Keywords // 'macro': Inlined functions for reusable logic. transitioning macro Name(implicit context: Context)(arg: JSAny): JSAny // 'builtin': Non-inlined functions, callable from other builtins or JavaScript. transitioning builtin Name(implicit context: Context)(arg: JSAny): JSAny // 'javascript': Marks a builtin as directly callable from JavaScript, with JS linkage. transitioning javascript builtin Name(js-implicit context: NativeContext, receiver: JSAny)(arg: JSAny): JSAny // 'transitioning': Indicates a function can cause an object's map to change (e.g. adding properties). // 'extern': Used to call C++ defined CSA functions from Torque. extern transitioning macro NameInCpp(Context, JSAny): JSAny; ``` ## Mandatory verification workflow The task is **incomplete** until you successfully execute this sequence: ### 1. Build Run the `gm.py` wrapper to trigger the Torque generator and C++ compilation. ```bash tools/dev/gm.py quiet {arch}.{type} ``` (e.g., `x64.optdebug` or `arm64.release`). Use `optdebug` for logic/debugging, `release` for performance/benchmarking. ### 2. Verify with Tests Run the relevant test suite (usually `mjsunit` for JavaScript-exposed builtins) to ensure correctness. Match the `{arch}.{type}` to your build. ```bash tools/run-tests.py --progress dots --outdir=out/{arch}.{type} mjsunit/<test_name> ``` ### 3. Debug (If Necessary) If the build fails during "Generation", inspect the `.tq` syntax. If it fails during "Compilation", check the generated C++ in `out/<config>/gen/torque-generated/`.
GitHub에서 보기