Skip to content

Latest commit

 

History

History
111 lines (101 loc) · 4.8 KB

todo.md

File metadata and controls

111 lines (101 loc) · 4.8 KB

goal

  • must be working nicely

plan

  • Basic compilation examples from wasm book
    • Make sure they're compilable
  • Parsing samples from wat-compiler
  • Remove subscript, use own parsing loop
  • Avoid duplicating function signatures
  • Compilation samples from wat-compiler
  • Examples tests - existing & wat-compiler ones (ideally find failing table)
  • Normalize tree in parser, not in compiler - keep compiler small & fast
  • Basic parsing instructions from mdn & examples
  • Benchmark against wabt, wat-compiler
  • Build script
  • Test: assert function;
  • make sure compiler doesn't modify tree
  • Recognize all number formats
  • Format function
  • Refactor for flat instructions: consume into stack, rather than fixed signatures
  • Multiple results: block, if, loop, func
  • Multiple params
  • SIMD
  • nan:value
  • constant expressions
  • bench wassemble - broken
  • Floating hex
  • Streamline compiler
    • Remove duplication from import section
    • Each section may have a name in advance: remove it from per-section handler
    • Sort nodes by buckets, run single pass
    • Incorporate alt compiler into main one
      • register by names from common place
      • resolve import stubs
      • push returning arrays instead of modifying ctx (section.type)
      • resolve refs / hoisting
      • collect by sections first, as array, to flat-map after
      • Use keys for ops
      • Get rid of precompile, do binary immediately, just re-add nodes as abbr
      • Optimize import
      • consumeType -> typeuse (better storage)
      • vec
      • common parts pre-parse
  • Optimizations
    • split generic precompile into section builders as was in v1
    • introduce more complete ref/deref use -> we can't really solve full hoisting issue (types, code refs)
    • make IR: types indexing, code deferring
    • make generic consuming ops for instructions instead of condition checks -> it's too metaphysical & unclear how to handle generic cases
    • flatten (deabbr) ops (if makes sense) nah, we don't have fixed immeds
    • make func init code immediately instead of duplicating code
    • Use instr instead of expr for wider support (extrapolate standard)?
    • Do away with ALIGNS const, calc mem properly
    • streamline sections parsing/build (no intermediary array)
  • Streamline building:
    • Split func into code/func to build sections separately
    • Turn import into shallow node of a kind: name alias, typeuse, replace with null ? how will it help making typeuse at the end, like func->code dodes?
    • Try detecting typeuse in sorting stage -> append all extra type nodes at the end
      • We should have all used types ready by momemt of binary build ~+ code section with import
      • traverse difficulty: we plainify nested nodes first, and detecting nested types first is wrong order ~+ unless we adjust traverse order
      • we should not register type if that's simple result or none: that would duplicate logic ~+ unless we normalize marker to (result i32)|(type $id)|empty
    • remove typeuses
    • Return binary directly from build
    • catch mistakes like having a string in place of node, eg (memory.copy 0 ...)
  • Separate slicing concert, remove unnecessary slices
  • elem all use-cases
  • Official tests
    • Include testsuite repo
    • All test instructions: assert_invalid
    • All tests
  • Compiler: Named/multiple memory;
  • Compiler: Named/multiple tables;
  • Relax no-inline limitation?
  • validation / errors: should be safe to type in anything
  • Abbr dict instead of thick plain
    • Make abbr main source of transforms, don't check for if node==section|block -> too different call signature: 1 node 1 result vs nodes list nodes result. It's section vs node
  • Indicate immediates via list -> too many expeptions, doesn't make much sense
  • Replace missing index with (;idx;) -> not so much benefit
  • Features
  • Print: make it as nice as AI
  • Bench binaryen
  • replace wabt with spec/wasm for tests

REPL

  • compiler selector
  • examples
  • perf stats
  • prettifier flag
  • binary copy/paster

Backlog

  • wat-based wat-compiler

Offering Qualifications

  • minimal & clever validator - basic checks via generic funcs
  • streamline, clear, light, sensible algorithm - easy to remember & understand
  • meaningful base of tests covered - not verbosities
  • clear, lightweight repl