diff options
author | 2022-03-31 05:07:18 -0700 | |
---|---|---|
committer | 2022-03-31 05:07:18 -0700 | |
commit | 4f1320854762ffa29c2b48755706000070ad1fb5 (patch) | |
tree | 181c0d9de00e5edcbf5f6b4229dabfe5833e4802 /src/javascript | |
parent | 5fa5df02f505a9b50c264625706af7280997d557 (diff) | |
download | bun-4f1320854762ffa29c2b48755706000070ad1fb5.tar.gz bun-4f1320854762ffa29c2b48755706000070ad1fb5.tar.zst bun-4f1320854762ffa29c2b48755706000070ad1fb5.zip |
Bugfixes to how we build WebCore code
Diffstat (limited to 'src/javascript')
28 files changed, 368 insertions, 156 deletions
diff --git a/src/javascript/jsc/bindings/ActiveDOMCallback.h b/src/javascript/jsc/bindings/ActiveDOMCallback.h index 1117b952f..bed84a90b 100644 --- a/src/javascript/jsc/bindings/ActiveDOMCallback.h +++ b/src/javascript/jsc/bindings/ActiveDOMCallback.h @@ -56,9 +56,9 @@ public: WEBCORE_EXPORT bool activeDOMObjectsAreSuspended() const; WEBCORE_EXPORT bool activeDOMObjectAreStopped() const; - - virtual void visitJSFunction(JSC::AbstractSlotVisitor&) { } - virtual void visitJSFunction(JSC::SlotVisitor&) { } + + virtual void visitJSFunction(JSC::AbstractSlotVisitor&) {} + virtual void visitJSFunction(JSC::SlotVisitor&) {} }; } // namespace WebCore diff --git a/src/javascript/jsc/bindings/BunClientData.cpp b/src/javascript/jsc/bindings/BunClientData.cpp index 9a4fa25f4..690ee8653 100644 --- a/src/javascript/jsc/bindings/BunClientData.cpp +++ b/src/javascript/jsc/bindings/BunClientData.cpp @@ -17,6 +17,9 @@ #include "BunGCOutputConstraint.h" #include "WebCoreTypedArrayController.h" +#include "JavaScriptCore/AbstractSlotVisitorInlines.h" +#include "JavaScriptCore/JSCellInlines.h" +#include "JavaScriptCore/WeakInlines.h" namespace WebCore { using namespace JSC; @@ -63,9 +66,9 @@ void JSVMClientData::create(VM* vm) vm->clientData = clientData; // ~VM deletes this pointer. clientData->m_normalWorld = DOMWrapperWorld::create(*vm, DOMWrapperWorld::Type::Normal); - // vm->heap.addMarkingConstraint(makeUnique<BunGCOutputConstraint>(*vm, *clientData)); + // vm->heap.addMarkingConstraint(makeUnique<WebCore::DOMGCOutputConstraint>(*vm, clientData->heapData())); - // vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(true)); + vm->m_typedArrayController = adoptRef(new WebCoreTypedArrayController(true)); } } // namespace WebCore
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/BunClientData.h b/src/javascript/jsc/bindings/BunClientData.h index 4e4573a62..4b0a36769 100644 --- a/src/javascript/jsc/bindings/BunClientData.h +++ b/src/javascript/jsc/bindings/BunClientData.h @@ -20,6 +20,8 @@ class DOMWrapperWorld; #include "wtf/Function.h" #include "wtf/HashSet.h" #include "wtf/RefPtr.h" +#include "JavaScriptCore/WeakHandleOwner.h" +#include "JavaScriptCore/WeakInlines.h" #include "JavaScriptCore/IsoSubspacePerVM.h" diff --git a/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp index ef5bba244..3954c7acf 100644 --- a/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp +++ b/src/javascript/jsc/bindings/BunGCOutputConstraint.cpp @@ -1,28 +1,164 @@ +/* + * Copyright (C) 2017-2022 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ - +#include "config.h" #include "BunGCOutputConstraint.h" -#include "BunClientData.h" +#include "JavaScriptCore/JSCInlines.h" +#include "WebCoreJSClientData.h" #include "JavaScriptCore/BlockDirectoryInlines.h" #include "JavaScriptCore/HeapInlines.h" #include "JavaScriptCore/MarkedBlockInlines.h" -#include "JavaScriptCore/MarkingConstraint.h" #include "JavaScriptCore/SubspaceInlines.h" -#include "JavaScriptCore/VM.h" + +// #include "JavaScriptCore/WeakInlines.h" +// #include "JavaScriptCore/AbstractSlotVisitorInlines.h" + +// #include "JavaScriptCore/VM.h" +// #include "JavaScriptCore/MarkingConstraint.h" + +// #include "JavaScriptCore/JSCInlines.h" + +// namespace JSC { + +// class VisitCounter { +// public: +// VisitCounter() {} + +// VisitCounter(AbstractSlotVisitor& visitor) +// : m_visitor(&visitor) +// , m_initialVisitCount(visitor.visitCount()) +// { +// } + +// AbstractSlotVisitor& visitor() const { return *m_visitor; } + +// size_t visitCount() const +// { +// return m_visitor->visitCount() - m_initialVisitCount; +// } + +// private: +// AbstractSlotVisitor* m_visitor { nullptr }; +// size_t m_initialVisitCount { 0 }; +// }; + +// static constexpr bool verboseMarkingConstraint = false; + +// MarkingConstraint::MarkingConstraint(CString abbreviatedName, CString name, ConstraintVolatility volatility, ConstraintConcurrency concurrency, ConstraintParallelism parallelism) +// : m_abbreviatedName(abbreviatedName) +// , m_name(WTFMove(name)) +// , m_volatility(volatility) +// , m_concurrency(concurrency) +// , m_parallelism(parallelism) +// { +// } + +// MarkingConstraint::~MarkingConstraint() +// { +// } + +// void MarkingConstraint::resetStats() +// { +// m_lastVisitCount = 0; +// } + +// void MarkingConstraint::execute(SlotVisitor& visitor) +// { +// ASSERT(!visitor.heap()->isMarkingForGCVerifier()); +// VisitCounter visitCounter(visitor); +// executeImpl(visitor); +// m_lastVisitCount += visitCounter.visitCount(); +// if (verboseMarkingConstraint && visitCounter.visitCount()) +// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in execute)"); +// } + +// void MarkingConstraint::executeSynchronously(AbstractSlotVisitor& visitor) +// { +// prepareToExecuteImpl(NoLockingNecessary, visitor); +// executeImpl(visitor); +// } + +// double MarkingConstraint::quickWorkEstimate(SlotVisitor&) +// { +// return 0; +// } + +// double MarkingConstraint::workEstimate(SlotVisitor& visitor) +// { +// return lastVisitCount() + quickWorkEstimate(visitor); +// } + +// void MarkingConstraint::prepareToExecute(const AbstractLocker& constraintSolvingLocker, SlotVisitor& visitor) +// { +// ASSERT(!visitor.heap()->isMarkingForGCVerifier()); +// dataLogIf(Options::logGC(), abbreviatedName()); +// VisitCounter visitCounter(visitor); +// prepareToExecuteImpl(constraintSolvingLocker, visitor); +// m_lastVisitCount = visitCounter.visitCount(); +// if (verboseMarkingConstraint && visitCounter.visitCount()) +// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in prepareToExecute)"); +// } + +// void MarkingConstraint::doParallelWork(SlotVisitor& visitor, SharedTask<void(SlotVisitor&)>& task) +// { +// ASSERT(!visitor.heap()->isMarkingForGCVerifier()); +// VisitCounter visitCounter(visitor); +// task.run(visitor); +// if (verboseMarkingConstraint && visitCounter.visitCount()) +// dataLog("(", abbreviatedName(), " visited ", visitCounter.visitCount(), " in doParallelWork)"); +// { +// Locker locker { m_lock }; +// m_lastVisitCount += visitCounter.visitCount(); +// } +// } + +// void MarkingConstraint::prepareToExecuteImpl(const AbstractLocker&, AbstractSlotVisitor&) +// { +// } + +// } // namespace JSC namespace WebCore { using namespace JSC; -BunGCOutputConstraint::BunGCOutputConstraint(VM& vm, WebCore::JSVMClientData& clientData) +DOMGCOutputConstraint::DOMGCOutputConstraint(VM& vm, JSHeapData& heapData) : MarkingConstraint("Domo", "DOM Output", ConstraintVolatility::SeldomGreyed, ConstraintConcurrency::Concurrent, ConstraintParallelism::Parallel) , m_vm(vm) - , m_clientData(clientData) + , m_heapData(heapData) , m_lastExecutionVersion(vm.heap.mutatorExecutionVersion()) { } -template<typename Visitor> void BunGCOutputConstraint::executeImplImpl(Visitor& visitor) +DOMGCOutputConstraint::~DOMGCOutputConstraint() +{ +} + +template<typename Visitor> +void DOMGCOutputConstraint::executeImplImpl(Visitor& visitor) { Heap& heap = m_vm.heap; @@ -31,22 +167,20 @@ template<typename Visitor> void BunGCOutputConstraint::executeImplImpl(Visitor& m_lastExecutionVersion = heap.mutatorExecutionVersion(); - m_clientData.forEachOutputConstraintSpace([&](Subspace& subspace) { - auto func = [](Visitor& visitor, HeapCell* heapCell, HeapCell::Kind) { - SetRootMarkReasonScope rootScope(visitor, RootMarkReason::DOMGCOutput); - JSCell* cell = static_cast<JSCell*>(heapCell); - cell->methodTable(visitor.vm())->visitOutputConstraints(cell, visitor); - }; + m_heapData.forEachOutputConstraintSpace( + [&](Subspace& subspace) { + auto func = [](Visitor& visitor, HeapCell* heapCell, HeapCell::Kind) { + SetRootMarkReasonScope rootScope(visitor, RootMarkReason::DOMGCOutput); + JSCell* cell = static_cast<JSCell*>(heapCell); + cell->methodTable(visitor.vm())->visitOutputConstraints(cell, visitor); + }; - RefPtr<SharedTask<void(Visitor&)>> task = subspace.template forEachMarkedCellInParallel<Visitor>(func); - visitor.addParallelConstraintTask(task); - }); + RefPtr<SharedTask<void(Visitor&)>> task = subspace.template forEachMarkedCellInParallel<Visitor>(func); + visitor.addParallelConstraintTask(task); + }); } -void BunGCOutputConstraint::executeImpl(AbstractSlotVisitor& visitor) -{ - executeImplImpl(visitor); -} -void BunGCOutputConstraint::executeImpl(SlotVisitor& visitor) { executeImplImpl(visitor); } +void DOMGCOutputConstraint::executeImpl(AbstractSlotVisitor& visitor) { executeImplImpl(visitor); } +void DOMGCOutputConstraint::executeImpl(SlotVisitor& visitor) { executeImplImpl(visitor); } } // namespace WebCore diff --git a/src/javascript/jsc/bindings/BunGCOutputConstraint.h b/src/javascript/jsc/bindings/BunGCOutputConstraint.h index ad23c5e32..eaf4ef9ec 100644 --- a/src/javascript/jsc/bindings/BunGCOutputConstraint.h +++ b/src/javascript/jsc/bindings/BunGCOutputConstraint.h @@ -1,9 +1,31 @@ +/* + * Copyright (C) 2017-2022 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #pragma once -#include "root.h" - -#include "JavaScriptCore/MarkingConstraint.h" +#include <JavaScriptCore/MarkingConstraint.h> namespace JSC { class VM; @@ -11,14 +33,14 @@ class VM; namespace WebCore { -class JSVMClientData; +class JSHeapData; -class BunGCOutputConstraint : public JSC::MarkingConstraint { +class DOMGCOutputConstraint : public JSC::MarkingConstraint { WTF_MAKE_FAST_ALLOCATED; public: - BunGCOutputConstraint(JSC::VM&, WebCore::JSVMClientData&); - ~BunGCOutputConstraint() {}; + DOMGCOutputConstraint(JSC::VM&, JSHeapData&); + ~DOMGCOutputConstraint(); protected: void executeImpl(JSC::AbstractSlotVisitor&) override; @@ -28,7 +50,7 @@ private: template<typename Visitor> void executeImplImpl(Visitor&); JSC::VM& m_vm; - JSVMClientData& m_clientData; + JSHeapData& m_heapData; uint64_t m_lastExecutionVersion; }; diff --git a/src/javascript/jsc/bindings/JSDOMWrapperCache.h b/src/javascript/jsc/bindings/JSDOMWrapperCache.h index beeeb2654..61d86d49e 100644 --- a/src/javascript/jsc/bindings/JSDOMWrapperCache.h +++ b/src/javascript/jsc/bindings/JSDOMWrapperCache.h @@ -23,6 +23,8 @@ #pragma once +#include "root.h" + #include "DOMWrapperWorld.h" #include "JSDOMGlobalObject.h" #include "JSDOMWrapper.h" diff --git a/src/javascript/jsc/bindings/ScriptExecutionContext.h b/src/javascript/jsc/bindings/ScriptExecutionContext.h index 3acd476d7..4265ffccd 100644 --- a/src/javascript/jsc/bindings/ScriptExecutionContext.h +++ b/src/javascript/jsc/bindings/ScriptExecutionContext.h @@ -65,7 +65,7 @@ public: bool isDocument() { return false; } bool isWorkerGlobalScope() { return true; } bool isJSExecutionForbidden() { return false; } - void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception*, RefPtr<void*>&&, CachedScript* = nullptr, bool = false) + void reportException(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL, JSC::Exception* exception, RefPtr<void*>&&, CachedScript* = nullptr, bool = false) { } // void reportUnhandledPromiseRejection(JSC::JSGlobalObject&, JSC::JSPromise&, RefPtr<Inspector::ScriptCallStack>&&) @@ -74,6 +74,7 @@ public: void postTask(Task&&) { + } // Executes the task on context's thread asynchronously. template<typename... Arguments> @@ -87,7 +88,6 @@ public: JSC::VM& vm() { return *m_vm; } private: - int m_junk = 0; JSC::VM* m_vm = nullptr; JSC::JSGlobalObject* m_globalObject = nullptr; WTF::URL m_url = WTF::URL(); diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 72a1afa87..a99087abf 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -89,6 +89,8 @@ #include "Process.h" +#include "JavaScriptCore/RemoteInspectorServer.h" + using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; using JSValue = JSC::JSValue; @@ -848,6 +850,11 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly); extraStaticGlobals.releaseBuffer(); + + // this->setRemoteDebuggingEnabled(true); + // auto& server = Inspector::RemoteInspectorServer::singleton(); + // if (server.start("127.0.0.1", 9222)) { + // } } template<typename Visitor> @@ -872,6 +879,9 @@ void GlobalObject::visitChildrenImpl(JSCell* cell, Visitor& visitor) visitor.append(constructor); // thisObject->m_builtinInternalFunctions.visit(visitor); + + ScriptExecutionContext* context = thisObject->scriptExecutionContext(); + visitor.addOpaqueRoot(context); } DEFINE_VISIT_CHILDREN(GlobalObject); diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h index 721f2c032..da67f93c1 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.h +++ b/src/javascript/jsc/bindings/ZigGlobalObject.h @@ -1,5 +1,8 @@ #pragma once +#ifndef ZIG_GLOBAL_OBJECT +#define ZIG_GLOBAL_OBJECT + namespace JSC { class Structure; class Identifier; @@ -168,4 +171,6 @@ private: namespace WebCore { using JSDOMGlobalObject = Zig::GlobalObject; } +#endif + #endif
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index 86d8ca7a0..ab5dead54 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,4 @@ -//-- AUTOGENERATED FILE -- 1648698232 +//-- AUTOGENERATED FILE -- 1648722142 // clang-format off #pragma once diff --git a/src/javascript/jsc/bindings/headers-replacements.zig b/src/javascript/jsc/bindings/headers-replacements.zig index f17cef709..fd1e7b4e9 100644 --- a/src/javascript/jsc/bindings/headers-replacements.zig +++ b/src/javascript/jsc/bindings/headers-replacements.zig @@ -59,4 +59,4 @@ pub const JSC__CatchScope = bindings.CatchScope; pub const Bun__Readable = bindings.NodeReadableStream; pub const Bun__Writable = bindings.NodeWritableStream; pub const Bun__ArrayBuffer = bindings.ArrayBuffer; -pub const WebCore__DOMURL = bindings.DOMURL; +pub const struct_WebCore__DOMURL = bindings.DOMURL; diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index 501f21d23..d99f24e58 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,5 +1,5 @@ // clang-format: off -//-- AUTOGENERATED FILE -- 1648698232 +//-- AUTOGENERATED FILE -- 1648722142 #pragma once #include <stddef.h> diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig index fd2abbf13..e82ca8e70 100644 --- a/src/javascript/jsc/bindings/headers.zig +++ b/src/javascript/jsc/bindings/headers.zig @@ -45,8 +45,6 @@ pub const bJSC__CallFrame = bindings.CallFrame; pub const bInspector__ScriptArguments = bindings.ScriptArguments; pub const JSC__JSValue = bindings.JSValue; -pub const struct_WebCore__DOMURL = bindings.DOMURL; - // Inlined types pub const ZigString = bindings.ZigString; pub const ZigException = bindings.ZigException; @@ -61,6 +59,7 @@ pub const JSC__CatchScope = bindings.CatchScope; pub const Bun__Readable = bindings.NodeReadableStream; pub const Bun__Writable = bindings.NodeWritableStream; pub const Bun__ArrayBuffer = bindings.ArrayBuffer; +pub const struct_WebCore__DOMURL = bindings.DOMURL; // GENERATED CODE - DO NOT MODIFY BY HAND pub const ptrdiff_t = c_long; diff --git a/src/javascript/jsc/bindings/root.h b/src/javascript/jsc/bindings/root.h index 00fd2dc75..ec2d228f7 100644 --- a/src/javascript/jsc/bindings/root.h +++ b/src/javascript/jsc/bindings/root.h @@ -1,5 +1,8 @@ #pragma once +#ifndef BUN__ROOT__H +#define BUN__ROOT__H + /* * Copyright (C) 2006-2021 Apple Inc. All rights reserved. * Copyright (C) 2006 Samuel Weinig "sam.weinig@gmail.com" @@ -67,9 +70,7 @@ #endif #include "wtf/PlatformCallingConventions.h" -#include "JavaScriptCore/Strong.h" -#include "JavaScriptCore/Weak.h" -#include "JavaScriptCore/WeakInlines.h" +#include "JavaScriptCore/JSCInlines.h" #define WTF_MAKE_ISO_ALLOCATED(className) \ WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(className) @@ -77,3 +78,4 @@ #define WTF_MAKE_ISO_ALLOCATED_EXPORT(className, a) WTF_MAKE_FAST_ALLOCATED_WITH_HEAP_IDENTIFIER(className); #define WTF_MAKE_ISO_ALLOCATED_IMPL(className) +#endif
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/webcore/AbortController.h b/src/javascript/jsc/bindings/webcore/AbortController.h index 853892d8a..f7bf96f25 100644 --- a/src/javascript/jsc/bindings/webcore/AbortController.h +++ b/src/javascript/jsc/bindings/webcore/AbortController.h @@ -25,15 +25,22 @@ #pragma once +#include "root.h" + +#include "ZigGlobalObject.h" + #include "ScriptWrappable.h" #include <wtf/Ref.h> #include <wtf/RefCounted.h> -#include "ZigGlobalObject.h" namespace JSC { class JSValue; } +namespace Zig { +class GlobalObject; +} + namespace WebCore { class AbortSignal; @@ -48,7 +55,7 @@ public: ~AbortController(); AbortSignal& signal(); - void abort(JSDOMGlobalObject&, JSC::JSValue reason); + void abort(Zig::GlobalObject&, JSC::JSValue reason); private: explicit AbortController(ScriptExecutionContext&); diff --git a/src/javascript/jsc/bindings/webcore/JSAbortController.cpp b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp index 5c93b9d83..3a9744b40 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortController.cpp +++ b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp @@ -39,16 +39,18 @@ #include "JSDOMWrapperCache.h" #include "ScriptExecutionContext.h" #include "WebCoreJSClientData.h" -#include <JavaScriptCore/FunctionPrototype.h> -#include <JavaScriptCore/HeapAnalyzer.h> -#include <JavaScriptCore/JSCInlines.h> -#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h> -#include <JavaScriptCore/SlotVisitorMacros.h> -#include <JavaScriptCore/SubspaceInlines.h> +#include "JavaScriptCore/FunctionPrototype.h" +#include "JavaScriptCore/HeapAnalyzer.h" +#include "JavaScriptCore/JSCInlines.h" +#include "JavaScriptCore/JSDestructibleObjectHeapCellType.h" +#include "JavaScriptCore/SlotVisitorMacros.h" +#include "JavaScriptCore/SubspaceInlines.h" #include <wtf/GetPtr.h> #include <wtf/PointerPreparations.h> #include <wtf/URL.h> +#include "weak_handle.h" + namespace WebCore { using namespace JSC; @@ -273,38 +275,8 @@ void JSAbortControllerOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* co uncacheWrapper(world, &jsAbortController->wrapped(), jsAbortController); } -#if ENABLE(BINDING_INTEGRITY) -#if PLATFORM(WIN) -#pragma warning(disable : 4483) -extern "C" { -extern void (*const __identifier("??_7AbortController@WebCore@@6B@")[])(); -} -#else -extern "C" { -extern void* _ZTVN7WebCore15AbortControllerE[]; -} -#endif -#endif - JSC::JSValue toJSNewlyCreated(JSC::JSGlobalObject*, JSDOMGlobalObject* globalObject, Ref<AbortController>&& impl) { - - if constexpr (std::is_polymorphic_v<AbortController>) { -#if ENABLE(BINDING_INTEGRITY) - const void* actualVTablePointer = getVTablePointer(impl.ptr()); -#if PLATFORM(WIN) - void* expectedVTablePointer = __identifier("??_7AbortController@WebCore@@6B@"); -#else - void* expectedVTablePointer = &_ZTVN7WebCore15AbortControllerE[2]; -#endif - - // If you hit this assertion you either have a use after free bug, or - // AbortController has subclasses. If AbortController has subclasses that get passed - // to toJS() we currently require AbortController you to opt out of binding hardening - // by adding the SkipVTableValidation attribute to the interface IDL definition - RELEASE_ASSERT(actualVTablePointer == expectedVTablePointer); -#endif - } return createWrapper<AbortController>(globalObject, WTFMove(impl)); } diff --git a/src/javascript/jsc/bindings/webcore/JSAbortController.h b/src/javascript/jsc/bindings/webcore/JSAbortController.h index 4b5d02f72..7801a6207 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortController.h +++ b/src/javascript/jsc/bindings/webcore/JSAbortController.h @@ -20,6 +20,8 @@ #pragma once +#include "root.h" + #include "AbortController.h" #include "JSDOMWrapper.h" #include <wtf/NeverDestroyed.h> @@ -59,6 +61,7 @@ public: DECLARE_VISIT_CHILDREN; static void analyzeHeap(JSCell*, JSC::HeapAnalyzer&); + protected: JSAbortController(JSC::Structure*, JSDOMGlobalObject&, Ref<AbortController>&&); diff --git a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp index 24320ba82..5738bcc25 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp +++ b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp @@ -54,7 +54,6 @@ #include <wtf/PointerPreparations.h> #include <wtf/URL.h> - namespace WebCore { using namespace JSC; @@ -109,11 +108,10 @@ using JSAbortSignalDOMConstructor = JSDOMConstructorNotConstructable<JSAbortSign /* Hash table for constructor */ -static const HashTableValue JSAbortSignalConstructorTableValues[] = -{ - { "whenSignalAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t) (2) } }, - { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_abort), (intptr_t) (0) } }, - { "timeout", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_timeout), (intptr_t) (1) } }, +static const HashTableValue JSAbortSignalConstructorTableValues[] = { + { "whenSignalAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t)(2) } }, + { "abort", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_abort), (intptr_t)(0) } }, + { "timeout", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalConstructorFunction_timeout), (intptr_t)(1) } }, }; template<> const ClassInfo JSAbortSignalDOMConstructor::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalDOMConstructor) }; @@ -141,13 +139,12 @@ template<> void JSAbortSignalDOMConstructor::initializeProperties(VM& vm, JSDOMG /* Hash table for prototype */ -static const HashTableValue JSAbortSignalPrototypeTableValues[] = -{ - { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortSignalConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, - { "aborted", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_aborted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, - { "reason", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_reason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, - { "onabort", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_onabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAbortSignal_onabort) } }, - { "throwIfAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t)static_cast<RawNativeFunction>(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t) (0) } }, +static const HashTableValue JSAbortSignalPrototypeTableValues[] = { + { "constructor", static_cast<unsigned>(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignalConstructor), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, + { "aborted", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_aborted), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, + { "reason", static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_reason), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(0) } }, + { "onabort", static_cast<unsigned>(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast<PropertySlot::GetValueFunc>(jsAbortSignal_onabort), (intptr_t) static_cast<PutPropertySlot::PutValueFunc>(setJSAbortSignal_onabort) } }, + { "throwIfAborted", static_cast<unsigned>(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast<RawNativeFunction>(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t)(0) } }, }; const ClassInfo JSAbortSignalPrototype::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalPrototype) }; @@ -171,7 +168,6 @@ void JSAbortSignal::finishCreation(VM& vm) { Base::finishCreation(vm); ASSERT(inherits(vm, info())); - } JSObject* JSAbortSignal::createPrototype(VM& vm, JSDOMGlobalObject& globalObject) @@ -189,7 +185,7 @@ JSValue JSAbortSignal::getConstructor(VM& vm, const JSGlobalObject* globalObject return getDOMConstructor<JSAbortSignalDOMConstructor, DOMConstructorID::AbortSignal>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject)); } -JSC_DEFINE_CUSTOM_GETTER(jsAbortSignalConstructor, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)) +JSC_DEFINE_CUSTOM_GETTER(jsAbortSignalConstructor, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName)) { VM& vm = JSC::getVM(lexicalGlobalObject); auto throwScope = DECLARE_THROW_SCOPE(vm); @@ -207,7 +203,7 @@ static inline JSValue jsAbortSignal_abortedGetter(JSGlobalObject& lexicalGlobalO RELEASE_AND_RETURN(throwScope, (toJS<IDLBoolean>(lexicalGlobalObject, throwScope, impl.aborted()))); } -JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_aborted, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_aborted, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { return IDLAttribute<JSAbortSignal>::get<jsAbortSignal_abortedGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName); } @@ -220,7 +216,7 @@ static inline JSValue jsAbortSignal_reasonGetter(JSGlobalObject& lexicalGlobalOb RELEASE_AND_RETURN(throwScope, (toJS<IDLAny>(lexicalGlobalObject, throwScope, impl.reason()))); } -JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_reason, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_reason, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { return IDLAttribute<JSAbortSignal>::get<jsAbortSignal_reasonGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName); } @@ -231,7 +227,7 @@ static inline JSValue jsAbortSignal_onabortGetter(JSGlobalObject& lexicalGlobalO return eventHandlerAttribute(thisObject.wrapped(), eventNames().abortEvent, worldForDOMObject(thisObject)); } -JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_onabort, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) +JSC_DEFINE_CUSTOM_GETTER(jsAbortSignal_onabort, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName)) { return IDLAttribute<JSAbortSignal>::get<jsAbortSignal_onabortGetter, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, thisValue, attributeName); } @@ -246,7 +242,7 @@ static inline bool setJSAbortSignal_onabortSetter(JSGlobalObject& lexicalGlobalO return true; } -JSC_DEFINE_CUSTOM_SETTER(setJSAbortSignal_onabort, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName)) +JSC_DEFINE_CUSTOM_SETTER(setJSAbortSignal_onabort, (JSGlobalObject * lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName)) { return IDLAttribute<JSAbortSignal>::set<setJSAbortSignal_onabortSetter>(*lexicalGlobalObject, thisValue, encodedValue, attributeName); } @@ -268,7 +264,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_whenSignalAbo RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLBoolean>(*lexicalGlobalObject, throwScope, AbortSignal::whenSignalAborted(*object, algorithm.releaseNonNull())))); } -JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_whenSignalAborted, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_whenSignalAborted, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation<JSAbortSignal>::callStatic<jsAbortSignalConstructorFunction_whenSignalAbortedBody, CastedThisErrorBehavior::Assert>(*lexicalGlobalObject, *callFrame, "whenSignalAborted"); } @@ -288,7 +284,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_abortBody(JSC RELEASE_AND_RETURN(throwScope, JSValue::encode(toJSNewlyCreated<IDLInterface<AbortSignal>>(*lexicalGlobalObject, *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), throwScope, AbortSignal::abort(*jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), *context, WTFMove(reason))))); } -JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_abort, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_abort, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation<JSAbortSignal>::callStatic<jsAbortSignalConstructorFunction_abortBody>(*lexicalGlobalObject, *callFrame, "abort"); } @@ -310,7 +306,7 @@ static inline JSC::EncodedJSValue jsAbortSignalConstructorFunction_timeoutBody(J RELEASE_AND_RETURN(throwScope, JSValue::encode(toJSNewlyCreated<IDLInterface<AbortSignal>>(*lexicalGlobalObject, *jsCast<JSDOMGlobalObject*>(lexicalGlobalObject), throwScope, AbortSignal::timeout(*context, WTFMove(milliseconds))))); } -JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_timeout, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(jsAbortSignalConstructorFunction_timeout, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation<JSAbortSignal>::callStatic<jsAbortSignalConstructorFunction_timeoutBody>(*lexicalGlobalObject, *callFrame, "timeout"); } @@ -325,19 +321,19 @@ static inline JSC::EncodedJSValue jsAbortSignalPrototypeFunction_throwIfAbortedB RELEASE_AND_RETURN(throwScope, JSValue::encode(toJS<IDLUndefined>(*lexicalGlobalObject, throwScope, [&]() -> decltype(auto) { return impl.throwIfAborted(*jsCast<JSDOMGlobalObject*>(lexicalGlobalObject)); }))); } -JSC_DEFINE_HOST_FUNCTION(jsAbortSignalPrototypeFunction_throwIfAborted, (JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame)) +JSC_DEFINE_HOST_FUNCTION(jsAbortSignalPrototypeFunction_throwIfAborted, (JSGlobalObject * lexicalGlobalObject, CallFrame* callFrame)) { return IDLOperation<JSAbortSignal>::call<jsAbortSignalPrototypeFunction_throwIfAbortedBody>(*lexicalGlobalObject, *callFrame, "throwIfAborted"); } JSC::GCClient::IsoSubspace* JSAbortSignal::subspaceForImpl(JSC::VM& vm) { - return WebCore::subspaceForImpl<JSAbortSignal, UseCustomHeapCellType::No>(vm, - [] (auto& spaces) { return spaces.m_clientSubspaceForAbortSignal.get(); }, - [] (auto& spaces, auto&& space) { spaces.m_clientSubspaceForAbortSignal = WTFMove(space); }, - [] (auto& spaces) { return spaces.m_subspaceForAbortSignal.get(); }, - [] (auto& spaces, auto&& space) { spaces.m_subspaceForAbortSignal = WTFMove(space); } - ); + return WebCore::subspaceForImpl<JSAbortSignal, UseCustomHeapCellType::No>( + vm, + [](auto& spaces) { return spaces.m_clientSubspaceForAbortSignal.get(); }, + [](auto& spaces, auto&& space) { spaces.m_clientSubspaceForAbortSignal = WTFMove(space); }, + [](auto& spaces) { return spaces.m_subspaceForAbortSignal.get(); }, + [](auto& spaces, auto&& space) { spaces.m_subspaceForAbortSignal = WTFMove(space); }); } template<typename Visitor> @@ -380,10 +376,14 @@ void JSAbortSignalOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* contex #if ENABLE(BINDING_INTEGRITY) #if PLATFORM(WIN) -#pragma warning(disable: 4483) -extern "C" { extern void (*const __identifier("??_7AbortSignal@WebCore@@6B@")[])(); } +#pragma warning(disable : 4483) +extern "C" { +extern void (*const __identifier("??_7AbortSignal@WebCore@@6B@")[])(); +} #else -extern "C" { extern void* _ZTVN7WebCore11AbortSignalE[]; } +extern "C" { +extern void* _ZTVN7WebCore11AbortSignalE[]; +} #endif #endif diff --git a/src/javascript/jsc/bindings/webcore/JSAbortSignalCustom.cpp b/src/javascript/jsc/bindings/webcore/JSAbortSignalCustom.cpp index 41e0f3376..7aac447e2 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortSignalCustom.cpp +++ b/src/javascript/jsc/bindings/webcore/JSAbortSignalCustom.cpp @@ -1,31 +1,35 @@ /* -* Copyright (C) 2019-2022 Apple Inc. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions -* are met: -* 1. Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* 2. Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ + * Copyright (C) 2019-2022 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ #include "config.h" +#include "JSDOMWrapper.h" +#include "wtf/NeverDestroyed.h" #include "JSAbortSignal.h" +#include "JavaScriptCore/WeakHandleOwner.h" + namespace WebCore { bool JSAbortSignalOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, JSC::AbstractSlotVisitor& visitor, const char** reason) diff --git a/src/javascript/jsc/bindings/webcore/JSErrorEventCustom.cpp b/src/javascript/jsc/bindings/webcore/JSErrorEventCustom.cpp new file mode 100644 index 000000000..728e404a9 --- /dev/null +++ b/src/javascript/jsc/bindings/webcore/JSErrorEventCustom.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2018 Yusuke Suzuki <yusukesuzuki@slowstart.org>. + * Copyright (C) 2021 Apple Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "JSErrorEvent.h" + +namespace WebCore { + +template<typename Visitor> +void JSErrorEvent::visitAdditionalChildren(Visitor& visitor) +{ + wrapped().originalError().visit(visitor); +} + +DEFINE_VISIT_ADDITIONAL_CHILDREN(JSErrorEvent); + +} // namespace WebCore diff --git a/src/javascript/jsc/bindings/webcore/JSEventTargetCustom.h b/src/javascript/jsc/bindings/webcore/JSEventTargetCustom.h index 5e2d4671e..9bbc58004 100644 --- a/src/javascript/jsc/bindings/webcore/JSEventTargetCustom.h +++ b/src/javascript/jsc/bindings/webcore/JSEventTargetCustom.h @@ -25,9 +25,7 @@ #pragma once -// #include "DOMWindow.h" #include "JSDOMBinding.h" -// #include "JSDOMBindingSecurity.h";/ #include "JSDOMOperation.h" namespace WebCore { @@ -71,11 +69,6 @@ public: return throwThisTypeError(lexicalGlobalObject, throwScope, "EventTarget", operationName); auto& wrapped = thisObject->wrapped(); - // if (is<DOMWindow>(wrapped)) { - // auto& window = downcast<DOMWindow>(wrapped); - // if (!window.frame() || !BindingSecurity::shouldAllowAccessToDOMWindow(&lexicalGlobalObject, window, ThrowSecurityError)) - // return JSC::JSValue::encode(JSC::jsUndefined()); - // } RELEASE_AND_RETURN(throwScope, (operation(&lexicalGlobalObject, &callFrame, thisObject.get()))); } diff --git a/src/javascript/jsc/bindings/webcore/ScriptWrappable.h b/src/javascript/jsc/bindings/webcore/ScriptWrappable.h index 5d5f609d6..ac6fd7649 100644 --- a/src/javascript/jsc/bindings/webcore/ScriptWrappable.h +++ b/src/javascript/jsc/bindings/webcore/ScriptWrappable.h @@ -31,17 +31,14 @@ #pragma once -#include "JavaScriptCore/Weak.h" -// #include "wtf/IsoMalloc.h" +#include "root.h" +#include "JavaScriptCore/JSCInlines.h" +#include "JSDOMWrapper.h" -namespace JSC { -class WeakHandleOwner; -} +// #include "wtf/IsoMalloc.h" namespace WebCore { -class JSDOMObject; - class ScriptWrappable { WTF_MAKE_FAST_ALLOCATED; diff --git a/src/javascript/jsc/bindings/webcore/WebCoreJSClientData.h b/src/javascript/jsc/bindings/webcore/WebCoreJSClientData.h index 68ada7e35..965f0bb98 100644 --- a/src/javascript/jsc/bindings/webcore/WebCoreJSClientData.h +++ b/src/javascript/jsc/bindings/webcore/WebCoreJSClientData.h @@ -1 +1,3 @@ +#pragma once + #include "BunClientData.h"
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp index 9b68adc9a..d0ac19064 100644 --- a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp +++ b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp @@ -37,6 +37,11 @@ #include "JavaScriptCore/JSArrayBuffer.h" +namespace JSC { +TypedArrayController::TypedArrayController() {} +TypedArrayController::~TypedArrayController() {} +} + namespace WebCore { WebCoreTypedArrayController::WebCoreTypedArrayController(bool allowAtomicsWait) diff --git a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.h b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.h index 437fb7d16..c689e019d 100644 --- a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.h +++ b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.h @@ -28,10 +28,6 @@ #include "JavaScriptCore/JSGlobalObject.h" #include "JavaScriptCore/TypedArrayController.h" -namespace JSC { -class WeakHandleOwner; -} - namespace WebCore { class WebCoreTypedArrayController : public JSC::TypedArrayController { diff --git a/src/javascript/jsc/bindings/webcore/config.h b/src/javascript/jsc/bindings/webcore/config.h index a9f9f5d29..8d25cbc46 100644 --- a/src/javascript/jsc/bindings/webcore/config.h +++ b/src/javascript/jsc/bindings/webcore/config.h @@ -1 +1,6 @@ -#include "root.h"
\ No newline at end of file +#pragma once + +#ifndef WEBCORE_CONFIG +#define WEBCORE_CONFIG +#include "root.h" +#endif
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/webcore/weak_handle.cpp b/src/javascript/jsc/bindings/webcore/weak_handle.h index f10ae654d..201b0696b 100644 --- a/src/javascript/jsc/bindings/webcore/weak_handle.cpp +++ b/src/javascript/jsc/bindings/webcore/weak_handle.h @@ -1,3 +1,5 @@ +#pragma once + #include "config.h" #include "JavaScriptCore/WeakHandleOwner.h" diff --git a/src/javascript/jsc/script_execution_context.zig b/src/javascript/jsc/script_execution_context.zig new file mode 100644 index 000000000..37594e0f4 --- /dev/null +++ b/src/javascript/jsc/script_execution_context.zig @@ -0,0 +1,7 @@ +const JSC = @import("../../jsc.zig"); + +pub const ScriptExecutionContext = extern struct { + main_file_path: JSC.ZigString, + is_macro: bool = false, + js_global_object: bool = false, +}; |