JSArrayBufferPrototypeInlines.h [plain text]
#pragma once
#include "JSArrayBufferPrototype.h"
#include "JSGlobalObject.h"
namespace JSC {
namespace JSArrayBufferPrototypeInternal {
static constexpr bool verbose = false;
};
ALWAYS_INLINE bool speciesWatchpointIsValid(VM& vm, JSObject* thisObject, ArrayBufferSharingMode mode)
{
JSGlobalObject* globalObject = thisObject->globalObject(vm);
auto* prototype = globalObject->arrayBufferPrototype(mode);
if (globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() == ClearWatchpoint) {
dataLogLnIf(JSArrayBufferPrototypeInternal::verbose, "Initializing ArrayBuffer species watchpoints for ArrayBuffer.prototype: ", pointerDump(prototype), " with structure: ", pointerDump(prototype->structure(vm)), "\nand ArrayBuffer: ", pointerDump(globalObject->arrayBufferConstructor(mode)), " with structure: ", pointerDump(globalObject->arrayBufferConstructor(mode)->structure(vm)));
globalObject->tryInstallArrayBufferSpeciesWatchpoint(mode);
ASSERT(globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() != ClearWatchpoint);
}
return !thisObject->hasCustomProperties(vm)
&& prototype == thisObject->getPrototypeDirect(vm)
&& globalObject->arrayBufferSpeciesWatchpointSet(mode).stateOnJSThread() == IsWatched;
}
ALWAYS_INLINE Optional<JSValue> arrayBufferSpeciesConstructor(JSGlobalObject* globalObject, JSArrayBuffer* thisObject, ArrayBufferSharingMode mode)
{
VM& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
bool isValid = speciesWatchpointIsValid(vm, thisObject, mode);
scope.assertNoException();
if (LIKELY(isValid))
return WTF::nullopt;
RELEASE_AND_RETURN(scope, arrayBufferSpeciesConstructorSlow(globalObject, thisObject, mode));
}
}