Skip to content

Strange output of memset polyfill #1785

Closed
@lexaknyazev

Description

@lexaknyazev

All WAT snippets were taken from the editor on the AssemblyScript's front page.

Redundant operations

export function foo(): void {
  memory.fill(16, 255, 3);
}
;; INFO asc module.ts --textFile module.wat --binaryFile module.wasm -O3 --runtime stub
(module
 (type $none_=>_none (func))
 (memory $0 0)
 (export "foo" (func $module/foo))
 (export "memory" (memory $0))
 (func $module/foo
  i32.const 16
  i32.const 255
  i32.store8
  i32.const 18
  i32.const 255
  i32.store8
  i32.const 17
  i32.const 255
  i32.store8
  i32.const 18
  i32.const 255
  i32.store8
  i32.const 17
  i32.const 255
  i32.store8
  i32.const 16
  i32.const 255
  i32.store8
 )
)

Negative offsets

export function foo(): void {
  memory.fill(0, 0, 2);
}
;; INFO asc module.ts --textFile module.wat --binaryFile module.wasm -O3 --runtime stub
(module
 (type $none_=>_none (func))
 (memory $0 0)
 (export "foo" (func $module/foo))
 (export "memory" (memory $0))
 (func $module/foo
  i32.const 0
  i32.const 0
  i32.store8
  i32.const -2
  i32.const 0
  i32.store8 offset=3
 )
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions