Difference between revisions of "Pas2js optimizations"
From Free Pascal wiki
Jump to navigationJump to search (Created page with "= Overview = This page describes existing optimizations for the pas2js transpiler as well as feature requests. = Compiler itself = The compiler was deliberately written *...") |
|||
Line 2: | Line 2: | ||
This page describes existing optimizations for the pas2js transpiler as well as feature requests. | This page describes existing optimizations for the pas2js transpiler as well as feature requests. | ||
+ | |||
+ | = Generated JavaScript = | ||
+ | |||
+ | == Existing optimizations == | ||
+ | |||
+ | * -O-: Disable all optimizations | ||
+ | * -O1 : Level 1 optimizations (quick and debugger friendly) | ||
+ | * -OoEnumNumbers[-]: write enum value as number instead of name. Default in -O1. | ||
+ | * -OoRemoveNotUsedPrivates[-]: Default is enabled | ||
+ | * -OoRemoveNotUsedDeclarations[-]: Default enabled for programs with -Jc | ||
+ | * omit unneeded brackets in associative operations (a||b)||(c||d), (a&&b)&&(c&&d), (a|b)|c, (a&b)&c, (a^b)^c, (a+b)+c, (a-b)-c, (a*b)*c | ||
+ | |||
+ | == Feature requests == | ||
+ | |||
+ | * -O2 : Level 2 optimizations, slow and not debugger friendly | ||
+ | * -O3 : Level 3 optimizations, slow and might break special code | ||
= Compiler itself = | = Compiler itself = |
Revision as of 12:08, 30 December 2018
Overview
This page describes existing optimizations for the pas2js transpiler as well as feature requests.
Generated JavaScript
Existing optimizations
- -O-: Disable all optimizations
- -O1 : Level 1 optimizations (quick and debugger friendly)
- -OoEnumNumbers[-]: write enum value as number instead of name. Default in -O1.
- -OoRemoveNotUsedPrivates[-]: Default is enabled
- -OoRemoveNotUsedDeclarations[-]: Default enabled for programs with -Jc
- omit unneeded brackets in associative operations (a||b)||(c||d), (a&&b)&&(c&&d), (a|b)|c, (a&b)&c, (a^b)^c, (a+b)+c, (a-b)-c, (a*b)*c
Feature requests
- -O2 : Level 2 optimizations, slow and not debugger friendly
- -O3 : Level 3 optimizations, slow and might break special code
Compiler itself
The compiler was deliberately written
- in a modular fashion. Each part has its own test suite and is used by other projects.
- can be used in a library, i.e. no restart required to compile another program.
- can be used without a filesystem, i.e. in a browser
- threadsafe, i.e. the compilation can run in a thread. Compiling a program with multiple threads is planned.
- easy maintenance has higher priority than high speed and low memory