Skip to content

Commit

Permalink
Don't need to check for non-zero resource rep (#427)
Browse files Browse the repository at this point in the history
Handle 0 is reserved for the sentinel value, but resource rep can be 0.

> Upon initialization, table element 0 is allocated and set to None, effectively
> reserving index 0 which is both useful for catching null/uninitialized
> accesses and allowing 0 to serve as a sentinel value.
> https://github.com/WebAssembly/component-model/blob/main/design/mvp/CanonicalABI.md#runtime-state
  • Loading branch information
kateinoigakukun authored Apr 29, 2024
1 parent 9e537cd commit 56f1540
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions crates/js-component-bindgen/src/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ pub fn render_intrinsics(

Intrinsic::ResourceTableCreateBorrow => output.push_str("
function rscTableCreateBorrow (table, rep) {
if (rep === 0) throw new TypeError('Invalid rep');
const free = table[0] & ~T_FLAG;
if (free === 0) {
table.push(scopeId);
Expand All @@ -296,7 +295,6 @@ pub fn render_intrinsics(

Intrinsic::ResourceTableCreateOwn => output.push_str("
function rscTableCreateOwn (table, rep) {
if (rep === 0) throw new TypeError('Invalid rep');
const free = table[0] & ~T_FLAG;
if (free === 0) {
table.push(0);
Expand Down

0 comments on commit 56f1540

Please sign in to comment.