Repository navigation
feat(napi): consolidate managed Edge V8 and metered WebAssembly #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
53b61ef
feat(napi): isolate and meter V8 work per WASIX instance
theduke 65e0a7f
fix(napi): disable asm.js validation by default
theduke 3a50937
feat(napi): embedder-controlled WebAssembly policy
theduke abebf26
feat(napi): meter page-allocated V8 buffers per context
theduke 2d186bb
feat(napi): enable metered WebAssembly with memory and code limits
theduke 1e075d2
fix(napi): enforce V8 heap limits without aborting the host
theduke e0e0bf5
fix(v8): bound foreground task processing per checkpoint
theduke 4ced8ee
tests(v8): distinguish invalid and metered WebAssembly policies
theduke be51d10
fix(napi): keep standalone execution unrestricted by default
theduke 3cead23
fix(build): finalize rebase compatibility
theduke 918a62e
test(napi): gate managed-lane assertion to native backend
theduke 490a382
fix(napi): validate module links and test opt-in quotas
theduke File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # Released EdgeJS 0.0.1 N-API compatibility | ||
|
|
||
| The frozen guest is the `edgejs` atom from `wasmer/edgejs@0.0.1`, SHA-256 | ||
| `ca6467e67c8503474cb4204cd2dbbae387c8fa19cad6f6c23131844143e27ccc`. | ||
| `tests/fixtures/edgejs-0.0.1-imports.txt` records its import section; | ||
| `tests/fixtures/edgejs-0.0.1-napi-signatures.txt` records all 186 `napi` | ||
| function types. Linking rejects a changed signature. The legacy names use the | ||
| same provider environment, resource budget, lane admission, and sticky stop as | ||
| the versioned extension. | ||
|
|
||
| ## Verified paths | ||
|
|
||
| - The exact atom prints `v24.13.2-pre` for `--version` and runs | ||
| `-e "console.log('LEGACY_NAPI_BOOT_OK')"`. | ||
| - Its default V8 flag string is validated and inert. Unexpected flags fail | ||
| before creating a V8 environment. | ||
| - Legacy serialized message handles retain their app budget until explicit | ||
| release. Deserialization may read the same handle repeatedly. Release, | ||
| stale-handle access, double release, and host-stop cleanup are covered by | ||
| `tests/legacy_manifest.rs`; host stop removes the native holder and charge. | ||
| - The legacy module creation and state queries use the provider's bounded | ||
| module handles. Its old heap-statistics layout is translated from one | ||
| provider observation. Structured clone uses the existing transient budget. | ||
| - The old contextify cache entry compiles source without executing it and | ||
| returns an empty guest-owned Buffer. It retains no code cache. The released | ||
| guest reports `cachedDataProduced` as true when requested even though the | ||
| buffer is empty; this legacy ABI does not pass that request to the host. | ||
|
|
||
| The exact atom probes require a local copy and are intentionally opt in: | ||
|
|
||
| ```sh | ||
| NAPI_EDGEJS_0_0_1_ATOM=/path/to/edgejs \ | ||
| ./cargo-standalone.sh test --quiet --features cli --test legacy_manifest | ||
| ``` | ||
|
|
||
| ## Current limits | ||
|
|
||
| - Dynamic `import('data:text/javascript,export default 7')` starts from a | ||
| running `-e` script, then rejects in the released guest's ESM translator: | ||
| `internalBinding('cjs_lexer')` is undefined. The probe does not reach a | ||
| `module_wrap_create` host call. The ESM test is ignored until the released | ||
| guest's binding path and the remaining legacy module-wrap operations are | ||
| resolved. | ||
| - The frozen worker probe now creates a worker, receives its posted message, | ||
| and exits cleanly. The regression test runs whenever | ||
| `NAPI_EDGEJS_0_0_1_ATOM` points to the exact released atom. Native environment | ||
| IDs are allocated across all sessions of the instance, including WASIX | ||
| workers; this prevents one worker's environment from resolving to another | ||
| worker's native V8 environment. The earlier owning-thread assertion has not | ||
| recurred in this probe. | ||
| - The frozen serdes binding, profiler/snapshot operations, and several stack | ||
| introspection calls fail explicitly. Their existing native implementations | ||
| retain buffers or samples without a workload budget, or have no equivalent | ||
| in the current provider. Calling `node:v8` serialization therefore needs a | ||
| metered implementation before it can be supported. | ||
| - Both module-wrap `create_cached_data` imports fail before entering V8. | ||
| `CreateCodeCache` allocates native `CachedData` before reporting its size; | ||
| the provider needs an enforced allocation limit before this path can be | ||
| charged to a workload. This is separate from the legacy contextify cache | ||
| entry described above. | ||
| - A V8 fatal or out-of-memory callback records a workload stop if control | ||
| returns to the N-API import boundary. V8 can terminate the host process | ||
| before returning from a native fatal error; the callback alone cannot | ||
| provide process-level fault containment. | ||
|
|
||
| These limitations are recorded so a successful import-only link or zero exit | ||
| from an ESM flag probe is not mistaken for application compatibility. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #ifndef NAPI_PRIVATE_RESOURCE_LIMITS_H_ | ||
| #define NAPI_PRIVATE_RESOURCE_LIMITS_H_ | ||
|
|
||
| #include "js_native_api.h" | ||
|
|
||
| // Host-only configuration, not a guest import or public module API. | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
| napi_status NAPI_CDECL snapi_private_set_resource_limits(napi_env env, int enabled); | ||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
|
|
||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we may get by with only having one function