Skip to main content
Porffor provides a wide range of compiler options to control optimization, parsing, memory allocation, and runtime behavior.

Core Options

Debug Mode

-d
flag
Enable debug mode. Includes function names in generated Wasm and enables debug logging.
porf -d script.js

Module Parsing

--module
flag
Parse input as an ES module instead of a script.
porf --module app.js

Secure Mode

--secure
flag
Enable secure mode. Errors on unsafe Porffor features like FFI.
porf --secure untrusted.js

Memory & Allocation

Allocator

--allocator
string
default:"chunk"
Select the memory allocator algorithm.Options:
  • chunk (default) - Chunk-based allocator with dynamic growth
  • oneshot - One-shot allocator, faster for short-lived programs (used in Lambda)
porf --allocator=oneshot script.js
The chunk allocator grows memory in configurable chunks (see --allocator-chunks).
--allocator-chunks
number
default:"16"
Number of Wasm pages (64KB each) to allocate per chunk when using the chunk allocator.
porf --allocator-chunks=32 script.js
Source reference: source/compiler/builtins.js:1046

Page Size

--page-size
number
default:"16384"
Internal page size for memory allocation. Default is 16384 (65536 / 4).
porf --page-size=8192 script.js
Source reference: source/compiler/index.js:80

Exception Handling

--exception-mode
string
default:"stack"
Exception handling mode to use.Options:
  • stack (default) - Stack-based exception handling
  • lut - Look-up table based exception handling
porf --exception-mode=lut script.js
The lut mode is used by precompile for built-in functions. The stack mode passes exception values on the stack.Source reference: source/compiler/codegen.js:5499
--wasm-exceptions
boolean
default:"true"
Enable or disable Wasm exception handling proposal.
porf --no-wasm-exceptions script.js

Random Number Generation

--prng
string
default:"xorshift128+"
Select the pseudo-random number generator algorithm for Math.random().Options:
  • xorshift32+
  • xorshift64+
  • xorshift128+ (default)
  • xoroshiro128+
  • xoshiro128+
porf --prng=xoshiro128+ script.js
Different algorithms offer different trade-offs between speed and randomness quality. The default xorshift128+ provides a good balance.Source reference: source/compiler/builtins.js:617-852

Valtype

--valtype
string
default:"f64"
Primary value type for Wasm operations.Options:
  • f64 (default) - 64-bit floating point
  • i32 - 32-bit integer (not well supported)
porf --valtype=i32 script.js
Using i32 is not well supported and may cause issues. The default f64 is recommended.
Source reference: source/runtime/index.js:64

Output & Analysis

Disassembly

-f
flag | string
Print disassembled Wasm generated from user functions.
# Disassemble all functions
porf -f script.js

# Disassemble specific function
porf -f=functionName script.js
Source reference: source/compiler/index.js:18
--opt-funcs
flag
Display function disassembly after optimization.
porf --opt-funcs script.js

Benchmarking

-t
flag
Print timing information for compilation and execution.
porf -t script.js
-b
flag
Print Wasm binary size.
porf -b script.js
--profile-compiler
flag
Log general compiler performance. Enabled by default when compiling to a file.
porf --profile-compiler script.js

Builtin Analysis

--builtin-tree
flag | string
Display tree of builtin function dependencies.
# Show all builtin dependencies
porf --builtin-tree script.js

# Show dependencies for specific builtin
porf --builtin-tree=Array.prototype.map script.js
--compile-alloc-log
flag
Log memory allocation details during compilation.
porf --compile-alloc-log script.js
Source reference: source/compiler/index.js:208

Wasm Import/Export

--treeshake-wasm-imports
boolean
default:"true"
Treeshake (remove) unused Wasm imports.
porf --no-treeshake-wasm-imports script.js
--passive-data
boolean
default:"true"
Use passive Wasm data segments.
porf --no-passive-data script.js
Automatically disabled when compiling to C/native.

Advanced Options

Tail Call Optimization

--tail-call
flag
Enable tail call optimization using Wasm tail call proposal.
porf --tail-call script.js
The tail call proposal is not widely implemented across Wasm runtimes.
Source reference: source/compiler/opt.js:10

Wasm Optimizer

--wasm-opt
flag
Run wasm-opt on generated Wasm binary.
porf --wasm-opt script.js output.wasm
Requires wasm-opt to be installed and available in PATH.Source reference: source/compiler/index.js:215

COCTC

--coctc
boolean
default:"true"
Enable Cross-Object Compile-Time Cache.
porf --no-coctc script.js

Closures

--closures
boolean
default:"true"
Enable closure support.
porf --no-closures script.js

See Also

Build docs developers (and LLMs) love