Commit Graph

63347 Commits

Author SHA1 Message Date
Nikolay Nikolov
82b6450f19 + introduced the AT_WASM_EXCEPTION_TAG asm symbol type, use that for specifying
the parameter to the 'throw' and 'catch' instructions
2021-09-27 17:49:30 +03:00
Nikolay Nikolov
e0ad427b6c + introduced the FPC_EXCEPTION_TAG_SYM string constant 2021-09-27 17:38:28 +03:00
Nikolay Nikolov
b46c010f82 + also support immutable wasm globals in the wasm assembler writer (both internal and external) 2021-09-27 05:40:26 +03:00
Nikolay Nikolov
7b31549119 * the data section is now only written by the internal wasm object writer, when
there are data segments in the module
2021-09-27 05:17:20 +03:00
Nikolay Nikolov
e85aff2b96 * combined TWasmObjSymbol.ImportIndex and .FuncIndex into just .FuncIndex,
because there's no point in having them separate, and the name ImportIndex
  is misleading, as there are multiple import indices (they are separate for
  functions, globals, tables, memories, etc.)
2021-09-27 04:53:35 +03:00
Nikolay Nikolov
2bce4d36db + proper support for WASM globals in the internal object writer - emit
relocations, generate a Global section, if they are declared in the object
  file, etc.
2021-09-27 04:24:49 +03:00
Nikolay Nikolov
5ad2d47e23 * track wasm global types in the internal object writer 2021-09-27 03:03:57 +03:00
Nikolay Nikolov
812732cb6a + introduced the AT_WASM_GLOBAL asm symbol type 2021-09-27 02:52:29 +03:00
Nikolay Nikolov
8226233aa3 * introduced the tai_globaltype asm directive, use that to declare the stack
pointer global symbol
2021-09-27 02:39:43 +03:00
Nikolay Nikolov
a1c8e92904 * emit a tai_tagtype for __FPC_exception instead of hardcoding the asm output
directly when wasm native exceptions are enabled
2021-09-27 00:33:57 +03:00
Nikolay Nikolov
10db5ea5dc + implemented the 'delegate' and the 'rethrow' instructions in the wasm internal assembler 2021-09-26 23:58:21 +03:00
Nikolay Nikolov
6fb4b9b7dd + support the 'try' instruction in the wasm internal assembler 2021-09-26 23:50:02 +03:00
Nikolay Nikolov
0bb781c928 * omit writing the export section if there are no exported functions from
the module. This reduces object file size slightly for modules without
  exports.
2021-09-26 23:14:52 +03:00
Nikolay Nikolov
d37117c460 * use an incrementing counter variable to determine the numbers for the code
and data section, so they can be used in the relocation section, without
  hardcoding them as constants. This will automatically adjust the numbers
  when we add more sections, or when we make writing some of the sections
  optional.
2021-09-26 23:10:55 +03:00
Nikolay Nikolov
77b898fe45 * use objsym.size to determine the code size of the function (instead of
writing until the end of the section) in the wasm internal object writer.
  This removes the extra padding of 'unreachable' instructions at the end of
  each function (which are zeroes, added for alignment - they are harmless,
  but are unnecessary and cause a slight increase of the size of the
  resulting binaries), after the final 'return' instruction of the function.
2021-09-26 22:21:34 +03:00
Nikolay Nikolov
bc76487b87 + enable the WebAssembly internal assembler and object writer 2021-09-26 20:46:47 +03:00
Nikolay Nikolov
db843287a2 + generate funcdef for external procs, that don't have an import dll 2021-09-26 20:37:34 +03:00
Nikolay Nikolov
2102fbdc97 - removed debug writelns from the wasm internal object writer 2021-09-26 20:13:35 +03:00
Nikolay Nikolov
99c84da071 + generate the export section in the wasm internal obj writer 2021-09-26 20:02:48 +03:00
Nikolay Nikolov
1c8579da2e * simplified and integrated the WriteImportExport procedure into the case
statement. Use similar statements to write the asm code for the export_name,
  like we use for the import_name directive.
2021-09-26 18:40:49 +03:00
Nikolay Nikolov
346b57e238 * tai_impexp renamed tai_export_name
* ait_importexport renamed ait_export_name
2021-09-26 18:35:10 +03:00
Nikolay Nikolov
2940d0f45f - removed unused constructor of tai_impexp, as well as unused member variable extmodule 2021-09-26 18:29:28 +03:00
J. Gareth "Kit" Moreton
79f60923ba Bug fix to XMM block move optimisation 2021-09-26 14:09:29 +00:00
Nikolay Nikolov
abf831c430 + fixed the addend in the relocations that point to data 2021-09-26 11:12:08 +03:00
florian
2d1ebe4cb3 + re-added accidently removed internal error 2021-09-26 09:50:30 +02:00
Nikolay Nikolov
c881d05793 * fixed bug in the code, generated for the RELOC_FUNCTION_INDEX_LEB
relocation
2021-09-26 10:29:17 +03:00
Nikolay Nikolov
07461d0fc3 * made the constructor of TObjSymbol virtual, so it can be overriden 2021-09-26 10:17:19 +03:00
Nikolay Nikolov
cb3ac37fb3 * fixed i32.const with large unsigned 32-bit const parameter (>2GB) 2021-09-26 09:50:35 +03:00
Nikolay Nikolov
efd5831742 * generate an internal error if an attempt is made to emit a
R_WASM_MEMORY_ADDR_LEB relocation, that points to code, instead of
  data
2021-09-26 09:42:12 +03:00
Nikolay Nikolov
392ca81c20 + add threadvar symbols to the symbol table 2021-09-26 09:40:28 +03:00
Nikolay Nikolov
92fb1d2564 * fixed warning 2021-09-26 08:25:22 +03:00
Nikolay Nikolov
9e0c028142 + support load/store with op_const 2021-09-26 08:15:04 +03:00
Nikolay Nikolov
7e9607a62c * fixed warning 2021-09-26 08:07:21 +03:00
Nikolay Nikolov
2e491d1ffa + implemented the br and br_if instructions in the wasm internal asm 2021-09-26 07:58:59 +03:00
Nikolay Nikolov
ca70cb05a7 * fixed warning 2021-09-26 07:54:20 +03:00
Nikolay Nikolov
07b71ac6ce * generate an internal error instead of warning for unsupported opcodes
in the internal asm writer for wasm
2021-09-26 07:48:31 +03:00
Nikolay Nikolov
d7b141d70e + implemented the if, loop and else instructions 2021-09-26 07:45:14 +03:00
Nikolay Nikolov
6133affad6 + implemented the f32.const and f64.const instructions in the wasm
internal asm
2021-09-26 07:19:36 +03:00
Nikolay Nikolov
0486caeb91 * generate an internal error, instead of warning for i32.const and
i64.const instructions with an unknown parameter
2021-09-26 06:58:46 +03:00
Nikolay Nikolov
81b8574bfd + implemented all the load/store instructions in the wasm internal asm
writer (previously, only i32.load and i32.store were implemented)
2021-09-26 06:49:51 +03:00
Nikolay Nikolov
ea401ccc82 + support writing R_WASM_MEMORY_ADDR_I32 relocations 2021-09-26 06:27:02 +03:00
Nikolay Nikolov
7f5250bf46 + implemented support for R_WASM_TABLE_INDEX_SLEB relocations 2021-09-26 06:22:41 +03:00
Nikolay Nikolov
9fa2e2934b + support the call_indirect instruction and the R_WASM_TYPE_INDEX_LEB
relocation that it requires in the internal wasm object writer
2021-09-26 06:03:18 +03:00
Nikolay Nikolov
bd6bbb6cf4 + support writing imports from a different module in the wasm binary object writer 2021-09-26 05:36:51 +03:00
Nikolay Nikolov
238d09d875 + support writing RELOC_FUNCTION_INDEX_LEB relocations to non-external functions 2021-09-26 05:15:50 +03:00
Nikolay Nikolov
bf5048cb5e + support generating R_WASM_TABLE_INDEX_I32 relocations 2021-09-26 04:46:46 +03:00
Nikolay Nikolov
acdb65c2a3 + support tai_symbolpair in the wasm internal obj writer, so that the
PASCALMAIN alias of main can be created
2021-09-26 04:19:16 +03:00
Nikolay Nikolov
83f2f7bf37 + introduced TObjData.SymbolPairDefine, to allow custom handling of symbol
pairs in the internal object writer
2021-09-26 03:56:56 +03:00
Nikolay Nikolov
6e7e632682 * fixed another warning 2021-09-26 03:16:01 +03:00
Nikolay Nikolov
4ebf857ffc * fixed warning 2021-09-26 03:05:00 +03:00