summaryrefslogtreecommitdiff
path: root/Tests/LibWasm
AgeCommit message (Collapse)Author
2023-04-14LibJS: Port Value::to_object() to NonnullGCPtrLinus Groh
2023-04-13LibJS: Make intrinsics getters return NonnullGCPtrLinus Groh
Some of these are allocated upon initialization of the intrinsics, and some lazily, but in neither case the getters actually return a nullptr. This saves us a whole bunch of pointer dereferences (as NonnullGCPtr has an `operator T&()`), and also has the interesting side effect of forcing us to explicitly use the FunctionObject& overload of call(), as passing a NonnullGCPtr is ambigous - it could implicitly be turned into a Value _or_ a FunctionObject& (so we have to dereference manually).
2023-03-13Everywhere: Remove unintentional partial stream reads and writesTim Schumacher
2023-03-13AK: Rename Stream::{read,write} to Stream::{read_some,write_some}Tim Schumacher
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-02-26Tests: Implement multi-value returns in test-wasmAli Mohammad Pur
2023-02-26LibWasm+LibWeb: Sneak a JS::Completion into Wasm::ResultAli Mohammad Pur
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-17LibJS+Everywhere: Convert JS::Error to StringTimothy Flynn
This includes an Error::create overload to create an Error from a UTF-8 StringView. If creating a String from that view fails, the factory will return an OOM InternalError instead. VM::throw_completion can also make use of this overload via its perfect forwarding.
2023-02-13LibCore: Remove `Stream.h`Tim Schumacher
2023-02-13LibCore: Move Stream-based file into the `Core` namespaceTim Schumacher
2023-02-08AK: Remove the fallible constructor from `FixedMemoryStream`Tim Schumacher
2023-01-29AK: Move memory streams from `LibCore`Tim Schumacher
2023-01-29LibJS+Everywhere: Propagate Cell::initialize errors from Heap::allocateTimothy Flynn
Callers that are already in a fallible context will now TRY to allocate cells. Callers in infallible contexts get a FIXME.
2023-01-29LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errorsTimothy Flynn
Note that as of this commit, there aren't any such throwers, and the call site in Heap::allocate will drop exceptions on the floor. This commit only serves to change the declaration of the overrides, make sure they return an empty value, and to propagate OOM errors frm their base initialize invocations.
2023-01-25LibWasm: Port the parser to `Core::Stream`Tim Schumacher
2023-01-15LibJS+Everywhere: Rename Value::to_string to to_deprecated_stringTimothy Flynn
2022-12-25test-wasm: Don't cast signed values to unsigned types in wasm_invokeAndrew Kaster
If a negative value ends up in one of the arguments for an invoked function, we don't want to cast it from a floating point type to an unsigned type. This fixes a float-cast-overflow UBSAN error on macOS with llvm 15.0.6.
2022-12-15LibJS: Convert Heap::allocate{,_without_realm}() to NonnullGCPtrLinus Groh
2022-12-14LibJS: Remove Object(Object& prototype) footgunAndreas Kling
This constructor was easily confused with a copy constructor, and it was possible to accidentally copy-construct Objects in at least one way that we dicovered (via generic ThrowCompletionOr construction). This patch adds a mandatory ConstructWithPrototypeTag parameter to the constructor to disambiguate it.
2022-12-14LibJS: Convert TypedArray::create() to NonnullGCPtrLinus Groh
2022-12-07LibJS: Replace standalone js_bigint() with BigInt::create()Linus Groh
Three standalone Cell creation functions remain in the JS namespace: - js_bigint() - js_string() - js_symbol() All of them are leftovers from early iterations when LibJS still took inspiration from JSC, which itself has jsString(). Nowadays, we pretty much exclusively use static create() functions to construct types allocated on the JS heap, and there's no reason to not do the same for these. Also change the return type from BigInt* to NonnullGCPtr<BigInt> while we're here. This is patch 1/3, replacement of js_string() and js_symbol() follow.
2022-12-06Everywhere: Rename to_{string => deprecated_string}() where applicableLinus Groh
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
2022-12-06AK+Everywhere: Rename String to DeprecatedStringLinus Groh
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
2022-08-27LibJS: Move intrinsics to the realmLinus Groh
Intrinsics, i.e. mostly constructor and prototype objects, but also things like empty and new object shape now live on a new heap-allocated JS::Intrinsics object, thus completing the long journey of taking all the magic away from the global object. This represents the Realm's [[Intrinsics]] slot in the spec and matches its existing [[GlobalObject]] / [[GlobalEnv]] slots in terms of architecture. In the majority of cases it should now be possibly to fully allocate a regular object without the global object existing, and in fact that's what we do now - the realm is allocated before the global object, and the intrinsics between both :^)
2022-08-26LibCrypto+LibJS: Remove the create_from methods from BigIntegerdavidot
Instead we just use a specific constructor. With this set of constructors using curly braces for constructing is highly recommended. As then it will not do too many implicit conversions which could lead to unexpected loss of data or calling the much slower double constructor. Also to ensure we don't feed (Un)SignedBigInteger infinities we throw RangeError earlier for Durations.
2022-08-23LibJS: Pass Realm to define_native_{accessor,function}()Linus Groh
This is needed so that the allocated NativeFunction receives the correct realm, usually forwarded from the Object's initialize() function, rather than using the current realm.
2022-08-23LibJS: Remove GlobalObject parameter from native functionsLinus Groh
2022-08-23LibJS: Replace GlobalObject with VM in Value AOs [Part 4/19]Linus Groh
This is where the fun begins. :^)
2022-08-23LibJS: Remove GlobalObject from VM::this_value()Linus Groh
This is a continuation of the previous six commits. The global object is only needed to return it if the execution context stack is empty, but that doesn't seem like a useful thing to allow in the first place - if you're not currently executing JS, and the execution context stack is empty, there is no this value to retrieve.
2022-08-23LibJS: Remove GlobalObject from VM::throw_completion()Linus Groh
This is a continuation of the previous five commits. A first big step into the direction of no longer having to pass a realm (or currently, a global object) trough layers upon layers of AOs! Unlike the create() APIs we can safely assume that this is only ever called when a running execution context and therefore current realm exists. If not, you can always manually allocate the Error and put it in a Completion :^) In the spec, throw exceptions implicitly use the current realm's intrinsics as well: https://tc39.es/ecma262/#sec-throw-an-exception
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in Heap::allocate<T>()Linus Groh
This is a continuation of the previous three commits. Now that create() receives the allocating realm, we can simply forward that to allocate(), which accounts for the majority of these changes. Additionally, we can get rid of the realm_from_global_object() in one place, with one more remaining in VM::throw_completion().
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in create() functionsLinus Groh
This is a continuation of the previous two commits. As allocating a JS cell already primarily involves a realm instead of a global object, and we'll need to pass one to the allocate() function itself eventually (it's bridged via the global object right now), the create() functions need to receive a realm as well. The plan is for this to be the highest-level function that actually receives a realm and passes it around, AOs on an even higher level will use the "current realm" concept via VM::current_realm() as that's what the spec assumes; passing around realms (or global objects, for that matter) on higher AO levels is pointless and unlike for allocating individual objects, which may happen outside of regular JS execution, we don't need control over the specific realm that is being used there.
2022-08-23LibJS+LibWeb: Replace GlobalObject with Realm in initialize() functionsLinus Groh
This is a continuation of the previous commit. Calling initialize() is the first thing that's done after allocating a cell on the JS heap - and in the common case of allocating an object, that's where properties are assigned and intrinsics occasionally accessed. Since those are supposed to live on the realm eventually, this is another step into that direction.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-10Tests: Port test-wasm to Core::StreamSam Atkins
2022-02-08LibJS: Convert ArrayBuffer construction to ThrowCompletionOrdavidot
This also allows us to create TypedArrays with an existing buffer thus clearing up an additional FIXME in TextEncoder.
2021-12-31test-wasm: Convert WebAssemblyModule::create() to ThrowCompletionOrLinus Groh
This exposed a missing exception check in parseWebAssemblyModule(), which could throw but still return a normal completion (which currently works as we check VM::exception() at the right point, but breaks when moving everything to exceptions).
2021-11-08LibCore: Use ErrorOr<T> for Core::File::open()Andreas Kling
2021-10-31Tests: Convert test-wasm functions to ThrowCompletionOrIdan Horowitz
2021-10-20LibJS: Convert test-js/test-web/test-wasm to ThrowCompletionOrIdan Horowitz
2021-10-20LibJS: Rename define_native_function => define_old_native_functionIdan Horowitz
This method will eventually be removed once all native functions are converted to ThrowCompletionOr
2021-10-20LibJS: Add ThrowCompletionOr versions of the JS native function macrosIdan Horowitz
The old versions were renamed to JS_DECLARE_OLD_NATIVE_FUNCTION and JS_DEFINE_OLD_NATIVE_FUNCTION, and will be eventually removed once all native functions were converted to the new format.
2021-10-17LibJS: Convert to_double() to ThrowCompletionOrIdan Horowitz
2021-10-17LibJS: Convert to_bigint_int64() to ThrowCompletionOrIdan Horowitz
2021-10-13LibJS: Convert to_object() to ThrowCompletionOrLinus Groh
2021-10-13LibJS: Convert to_string() to ThrowCompletionOrLinus Groh
Also update get_function_name() to use ThrowCompletionOr, but this is not a standard AO and should be refactored out of existence eventually.
2021-10-01Tests: Fix typosNico Weber
2021-08-30Tests/LibWasm: Handle all stream errors in parse_webassembly_moduleAli Mohammad Pur
2021-08-30Tests/LibWasm: Add support for javascript bigint valuesAli Mohammad Pur
Some i64 values will not fit in normal doubles, and these values _are_ tested by the test suite, this makes the test runtime capable of handling them correctly.
2021-08-20LibCore: Make Core::File::open() return OSError in case of failureAndreas Kling
2021-07-17LibWasm+Everywhere: Make the instruction count limit configurableAli Mohammad Pur
...and enable it for LibWeb and test-wasm. Note that `wasm` will not be limited by this.