summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/ArrayBuffer.cpp
AgeCommit message (Collapse)Author
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-23LibJS: Replace GlobalObject with VM in common AOs [Part 18/19]Linus Groh
2022-08-23LibJS: Replace GlobalObject with VM in ArrayBuffer AOs [Part 11/19]Linus Groh
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-07-06LibJS: Revert partial resizable ArrayBuffer implementationLinus Groh
This is a manual but clean revert of all commits from #12595. Adding a partial implementation of the resizable ArrayBuffer proposal without implementing all the updates to TypedArray infrastructure that is also covered by the spec introduced a bunch of crashes, so we decided to revert it for now until a full implementation is completed.
2022-05-03LibJS: Remove implicit wrapping/unwrapping of completion recordsLinus Groh
This is an editorial change in the ECMA-262 spec, with similar changes in some proposals. See: - https://github.com/tc39/ecma262/commit/7575f74 - https://github.com/tc39/proposal-array-grouping/commit/df899eb - https://github.com/tc39/proposal-shadowrealm/commit/9eb5a12 - https://github.com/tc39/proposal-shadowrealm/commit/c81f527
2022-04-16LibJS: Remove cloneConstructor parameter from CloneArrayBufferTimothy Flynn
This is a normative change in the ECMA-262 spec. See: https://github.com/tc39/ecma262/commit/e7979fd Note that this implements a FIXME in InitializeTypedArrayFromTypedArray, now that shared array buffers are no longer a concern there. We already have test coverage for the now-handled case.
2022-04-08LibJS: Move DetachArrayBuffer implementation to the ArrayBuffer objectTimothy Flynn
The spec notes that this AO is unused by ECMA-262, but is provided for ECMAScript hosts. Move the definition to a common location to allow test-js to also use it.
2022-03-16Libraries: Use default constructors/destructors in LibJSLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
2022-03-02LibJS: Implement and test getters added by resizable ArrayBufferForLoveOfCats
2022-03-02LibJS: Construct ArrayBuffer with max byte length when providedForLoveOfCats
2022-03-02LibJS: Accept ArrayBuffer constructor options argumentForLoveOfCats
Test262 seems to test the changes in the "Resizable ArrayBuffer and growable SharedArrayBuffer" proposal. Begin implementing this proposal by accepting the new options object argument to the ArrayBuffer constructor. https://tc39.es/proposal-resizablearraybuffer https://github.com/tc39/test262/blob/main/test/built-ins/ArrayBuffer/options-maxbytelength-diminuitive.js
2022-02-08LibJS: Implement the CloneArrayBuffer AOIdan Horowitz
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.
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2021-12-14LibJS: Add ArrayBuffer::create() for ByteBuffer passed by valueLinus Groh
2021-10-09LibJS: Implement the AllocateArrayBuffer() AOLinus Groh
This should be used instead of ArrayBuffer::create() in most places, as it uses OrdinaryCreateFromConstructor to allow for a custom prototype. The data block (ByteBuffer) is allocated separately and attached afterwards, if we didn't fail due to OOM.
2021-09-11LibJS+LibWeb+Spreadsheet: Upcall visit_edges() via Base typedefAndreas Kling
Let's use Base::visit_edges() when calling the base class, to prevent accidentally skipping over anyone in the inheritance chain.
2021-09-06LibJS: Handle possible allocation failure in ArrayBuffer(size_t)Ali Mohammad Pur
...by replacing it with a ctor that takes the buffer instead, and handling the allocation failure in ArrayBuffer::create(size_t) by throwing a RangeError as specified by the spec.
2021-09-06Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safeAli Mohammad Pur
2021-06-11LibWeb: Set a detach key for ArrayBuffers returned from WASMIdan Horowitz
As required by the specification: `Set buffer.[[ArrayBufferDetachKey]] to "WebAssembly.Memory".`
2021-06-10LibJS: Allow and check for detached ArrayBuffersIdan Horowitz
This is required by the specification and will be used for the $262.detachArrayBuffer method in test262.
2021-06-10LibJS: Bring ArrayBuffer.prototype.slice closer to specIdan Horowitz
The exception order was incorrect in the old implementation, and it did not use the Symbol.species constructor as required by the spec.
2021-05-26LibJS: Allow ArrayBuffer to not own its backing data buffer as wellAli Mohammad Pur
This is implemented as a ByteBuffer* in a variant, so its size should only be increased by an index.
2021-04-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-03LibJS: ArrayBuffer.prototype.sliceJamie Mansfield
Implements the aforementioned native Javascript function, following the specification's [1] implementation. [1] https://tc39.es/ecma262/#sec-arraybuffer.prototype.slice
2021-01-12Libraries: Move to Userland/Libraries/Andreas Kling