table.size
Gets the number of elements a table contains.

Syntax

table.size $label

Parameters

$label Optional
If there is no label then the default table is used. If used then this points to a (table...) object.

Stack In

NONE

Stack Out

i32 The number of elements the table contains.

Examples

;; Create default table of function references
(table 4 funcref)

;; Create function
(func $getTableElementCount (result i32)
  ;; Get the number of elements in the default table
  table.size

  ;; The stack contains an i32 value of 4 (elements in default table)
)
;; Create labelled table of function references
(table $testTable 6 funcref)

;; Create function
(func $getTableElementCount (result i32)
  ;; Get the number of elements in the labelled table
  table.size $testTable

  ;; The stack contains an i32 value of 6 (elements in labelled table)
)