Ali Mohammad Pur
6820e0e175
LibWasm: Make sure to place imported functions before the module's
...
aafef1e92d
broke this while trying to
make the global import available in initialisation, this commit makes
sure we place the module's own functions after all resolved imports.
2023-09-26 07:47:20 +03:30
Ali Mohammad Pur
4fb209d25f
LibWasm: Explicitly place the paddings in the WASI API types
...
This makes it so we don't rely on e.g. u64 to have an 8-byte alignment,
fixing breakage on i686 systems.
2023-09-04 13:32:36 +03:30
Ali Mohammad Pur
3c176bafee
LibWasm: Implement a few SIMD instructions
2023-08-21 13:39:32 +03:30
Ali Mohammad Pur
2462064fcd
LibWasm+LibWeb: Parse and validate all Wasm SIMD instructions
2023-08-21 13:39:32 +03:30
Ali Mohammad Pur
b005691497
LibWasm: Disallow out-of-range br_table labels
2023-08-21 13:39:32 +03:30
Ali Mohammad Pur
8668851cb1
LibWasm: Do not allow self-referencial globals
...
This is written in a somewhat roundabout way in the spec, so the
initial implementation did not implement it correctly.
2023-08-21 13:39:32 +03:30
Andreas Kling
97ebfd9f0f
LibJS: Make Value::to_string_without_side_effects() infallible
...
Work towards #20449 .
2023-08-09 17:09:16 +02:00
Ali Mohammad Pur
59e8f713db
LibWasm: Implement Element section segment type 4
2023-07-08 15:13:25 +02:00
Ali Mohammad Pur
aafef1e92d
LibWasm: Make the main module's functions addressable by globals
2023-07-08 15:13:25 +02:00
Timothy Flynn
c911781c21
Everywhere: Remove needless trailing semi-colons after functions
...
This is a new option in clang-format-16.
2023-07-08 10:32:56 +01:00
Timothy Flynn
aff81d318b
Everywhere: Run clang-format
...
The following command was used to clang-format these files:
clang-format-16 -i $(find . \
-not \( -path "./\.*" -prune \) \
-not \( -path "./Base/*" -prune \) \
-not \( -path "./Build/*" -prune \) \
-not \( -path "./Toolchain/*" -prune \) \
-not \( -path "./Ports/*" -prune \) \
-type f -name "*.cpp" -o -name "*.h")
2023-07-08 10:32:56 +01:00
Ali Mohammad Pur
538c308357
LibWasm: Stop passing a nonzero 'mode' to open(..., O_DIRECTORY)
...
Bionic warns on this, but not passing the mode argument is technically
undefined behaviour (depending on the libc implementation of open), as
our LibC reads `mode` unconditionally (yolo!), just pass a zero to avoid
the UB.
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
5f999097e5
LibWasm: Implement wasi fd_read
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
ae9c40451a
LibWasm: Implement wasi fd_filestat_get()
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
f62187ed5d
LibWasm: Accept newly-created wasi file descriptors as well
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
a608e87ff9
LibWasm: Show wasi function arguments and result in debug mode
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
47248a3511
LibWasm: Keep track of created directory fds in path_create_directory
2023-06-10 07:18:02 +02:00
Ali Mohammad Pur
5121b368cd
LibWasm: Implement the random_get() call
2023-06-10 07:18:02 +02:00
Andreas Kling
f5bf53bc99
LibWasm: Create AK::StackInfo once per AbstractMachine
...
This makes test-wasm about 20% faster on my Linux machine :^)
2023-05-28 13:20:56 +02:00
Niklas Poslovski
fcbb8d63c0
LibWasm: Change dir_fd to auto instead of int
2023-05-20 03:27:38 +03:30
Ali Mohammad Pur
7e6341587b
AK+Everywhere: Disallow Error::from_string_view(FooString)
...
That pattern seems to show up a lot in code written by people that
aren't intimately familiar with the lifetime model of Error and Strings.
This commit makes the compiler detect it and present a more helpful
diagnostic than "garbage string at runtime".
2023-04-28 05:55:20 +02:00
Ali Mohammad Pur
7e4e9fdb8f
LibWasm: Start implementing WASI
...
This commit starts adding support for WASI, along with the framework to
implement all the functions (though only a couple are currently
implemented).
2023-04-26 03:47:15 +03:30
Ali Mohammad Pur
eceb244bef
LibWasm: Allow Value::to<T>() to perform statically valid conversions
...
e.g. i32 -> i16 (if within range).
2023-04-26 03:47:15 +03:30
Tim Schumacher
547a08670e
LibWasm: Replace usages of the Endian bytes accessor
2023-04-12 07:33:15 -04:00
Ali Mohammad Pur
64da05a96d
LibWeb+LibWasm: Implement and use the "reset the Memory buffer" steps
...
This implements the memory object cache and its "reset on grow"
semantics, as the web depends on the exact behaviour.
2023-03-29 07:16:37 +02:00
Tim Schumacher
d1f6a28ffd
AK: Move ConstrainedStream from LibWasm and limit discarding
2023-03-21 10:25:13 +01:00
Tim Schumacher
ecd1862859
AK: Rename Stream::write_entire_buffer to Stream::write_until_depleted
...
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
a3f73e7d85
AK: Rename Stream::read_entire_buffer to Stream::read_until_filled
...
No functional changes.
2023-03-13 15:16:20 +00:00
Tim Schumacher
d5871f5717
AK: Rename Stream::{read,write} to Stream::{read_some,write_some}
...
Similar to POSIX read, the basic read and write functions of AK::Stream
do not have a lower limit of how much data they read or write (apart
from "none at all").
Rename the functions to "read some [data]" and "write some [data]" (with
"data" being omitted, since everything here is reading and writing data)
to make them sufficiently distinct from the functions that ensure to
use the entire buffer (which should be the go-to function for most
usages).
No functional changes, just a lot of new FIXMEs.
2023-03-13 15:16:20 +00:00
Andreas Kling
21db2b7b90
Everywhere: Remove NonnullOwnPtr.h includes
2023-03-06 23:46:35 +01:00
Ali Mohammad Pur
6b50f23242
LibWasm+LibWeb: Sneak a JS::Completion into Wasm::Result
...
Imported functions in Wasm may throw JS exceptions, and we need to
preserve these exceptions so we can pass them to the calling JS code.
This also adds a `assert_wasm_result()` API to Result for cases where
only Wasm traps or values are expected (e.g. internal uses) to avoid
making LibWasm (pointlessly) handle JS exceptions that will never show
up in reality.
2023-02-26 10:54:23 +03:30
Tim Schumacher
43f98ac6e1
Everywhere: Remove the AK::
qualifier from Stream usages
2023-02-13 00:50:07 +00:00
Tim Schumacher
874c7bba28
LibCore: Remove Stream.h
2023-02-13 00:50:07 +00:00
Tim Schumacher
220fbcaa7e
AK: Remove the fallible constructor from FixedMemoryStream
2023-02-08 17:44:32 +00:00
Tim Schumacher
47531a42a9
AK: Make LEB128 decoding work with read_value
2023-02-04 18:41:27 -07:00
Tim Schumacher
787f4d639a
AK: Port LEB128
to the new AK::Stream
2023-02-04 18:41:27 -07:00
Tim Schumacher
093cf428a3
AK: Move memory streams from LibCore
2023-01-29 19:16:44 -07:00
Tim Schumacher
8464da1439
AK: Move Stream
and SeekableStream
from LibCore
...
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Tim Schumacher
ae64b68717
AK: Deprecate the old AK::Stream
...
This also removes a few cases where the respective header wasn't
actually required to be included.
2023-01-29 19:16:44 -07:00
Sam Atkins
53ebe607f8
LibWasm: Implement data.drop instruction
2023-01-28 22:57:25 +03:30
Sam Atkins
a2f42512c2
LibWasm: Move memory.init code together with other memory.foo impls
...
And add a spec link while I'm at it.
2023-01-28 22:57:25 +03:30
Sam Atkins
330911a274
LibWasm: Implement memory.copy instruction
2023-01-28 22:57:25 +03:30
Sam Atkins
42adba5ad4
LibWasm: Implement memory.fill instruction
2023-01-28 22:57:25 +03:30
Sam Atkins
8d31e04b8a
LibWasm: Remove declarations for non-existent methods
2023-01-27 20:33:18 +00:00
Tim Schumacher
2552399bcd
LibWasm: Use Core::Stream
to read values in the bytecode interpreter
2023-01-25 17:10:05 +03:30
Tim Schumacher
982ebbc304
LibWasm: Port the parser to Core::Stream
2023-01-25 17:10:05 +03:30
Tim Schumacher
409fb0fe79
LibWasm: Port Wasm::Printer
to Core::Stream
2023-01-25 17:10:05 +03:30
Tim Schumacher
52cb066cae
LibWasm: Use AllocatingMemoryStream
around Wasm::Printer
2023-01-20 20:48:40 +00:00
Ben Wiederhake
8a331d4fa0
Everywhere: Move AK/Debug.h include to using files or remove
2023-01-02 20:27:20 -05:00
Andrew Kaster
9a66a9ac4a
LibWasm: Split SaturatingTruncate conversion function by float/non-float
...
It's possible to construct a floating point value that when converted to
double is not larger than i64::max(), but when remaining a float is
larger. This patch avoids that edge case with some even less exciting if
constexpr branches to fix a float-cast-overflow UBSAN error on macOS
with llvm 15.0.6.
2022-12-25 07:58:58 -07:00