table.grow
Increase the number of elements a table contains.

Syntax

table.grow $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

funcref A reference to a function.
i32 The number of elements to increase the table by.

Stack Out

i32 The previous size of the table. If the value -1 is returned then the table failed to grow.

Examples

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

;; Create function
(func $growDefaultTable (result i32)
  ;; Set what to fill the new elements in the table with
  ref.null func

  ;; Set the number of elements to grow by
  i32.const 2

  ;; Grow the default table
  table.grow

  ;; The stack contains an i32 value of 4
  ;; (previous number of elements in default table)
)
;; Create labelled table of function references
(table $testTable 6 funcref)
  
;; Create function
(func $growTestTable (result i32)
  ;; Set what to fill the new elements in the table with
  ref.null func

  ;; Set the number of elements to grow by
  i32.const 2

  ;; Grow the laballed table
  table.grow $testTable

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