diff options
27 files changed, 1669 insertions, 827 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json index f2b65071c..2ae7aa2d6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,6 +27,15 @@ "src/javascript/jsc/WebKit/WebKitBuild": true, "src/javascript/jsc/WebKit/WebInspectorUI": true }, + "[cpp]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "[h]": { + "editor.defaultFormatter": "xaver.clang-format" + }, + "[c]": { + "editor.defaultFormatter": "xaver.clang-format" + }, "files.associations": { "*.idl": "cpp", "memory": "cpp", @@ -33,7 +33,7 @@ CLANG_FLAGS = -Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/Pri -DNDEBUG=1 \ -DNOMINMAX \ -DIS_BUILD \ - -O3 \ + -O1 \ -g \ -DENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0 \ -DBUILDING_JSCONLY__ \ diff --git a/demos/css-stress-test/src/index.tsx b/demos/css-stress-test/src/index.tsx index c9ec51a7e..ce6f9a930 100644 --- a/demos/css-stress-test/src/index.tsx +++ b/demos/css-stress-test/src/index.tsx @@ -1,6 +1,7 @@ import { Main } from "./main"; import classNames from "classnames"; import * as ReactDOM from "react-dom"; +import * as ReactDOMServer from "react-dom/server.browser"; const Base = ({}) => { const name = @@ -22,9 +23,8 @@ if (typeof window !== "undefined") { startReact(); } else { + console.log("test"); console.log(ReactDOMServer.renderToString(<Base />)); } export { Base }; - - diff --git a/src/feature_flags.zig b/src/feature_flags.zig index 828bae1fd..b5fc7cb5e 100644 --- a/src/feature_flags.zig +++ b/src/feature_flags.zig @@ -32,6 +32,7 @@ pub const verbose_watcher = true; pub const css_supports_fence = true; pub const disable_entry_cache = false; +pub const enable_bytecode_caching = true; pub const CSSModulePolyfill = enum { // When you import a .css file and you reference the import in JavaScript diff --git a/src/fs.zig b/src/fs.zig index ba7eaf32f..a8da71588 100644 --- a/src/fs.zig +++ b/src/fs.zig @@ -5,7 +5,7 @@ const alloc = @import("alloc.zig"); const expect = std.testing.expect; const Mutex = sync.Mutex; const Semaphore = sync.Semaphore; - +const Fs = @This(); const path_handler = @import("./resolver/resolve_path.zig"); const allocators = @import("./allocators.zig"); @@ -22,6 +22,51 @@ pub const Preallocate = struct { }; }; +pub const BytecodeCacheFetcher = struct { + fd: ?StoredFileDescriptorType = null, + + pub const Available = enum { + Unknown, + Available, + NotAvailable, + + pub inline fn determine(fd: ?StoredFileDescriptorType) Available { + if (!comptime FeatureFlags.enable_bytecode_caching) return .NotAvailable; + + const _fd = fd orelse return .Unknown; + return if (_fd > 0) .Available else return .NotAvailable; + } + }; + + pub fn fetch(this: *BytecodeCacheFetcher, sourcename: string, fs: *FileSystem.RealFS) ?StoredFileDescriptorType { + switch (Available.determine(this.fd)) { + .Available => { + return this.fd.?; + }, + .NotAvailable => { + return null; + }, + .Unknown => { + var basename_buf: [512]u8 = undefined; + var pathname = Fs.PathName.init(sourcename); + std.mem.copy(u8, &basename_buf, pathname.base); + std.mem.copy(u8, basename_buf[pathname.base.len..], ".bytecode"); + const basename = basename_buf[0 .. pathname.base.len + ".bytecode".len]; + + if (fs.fetchCacheFile(basename)) |cache_file| { + this.fd = @truncate(StoredFileDescriptorType, cache_file.handle); + return @truncate(StoredFileDescriptorType, cache_file.handle); + } else |err| { + Output.prettyWarnln("<r><yellow>Warn<r>: Bytecode caching unavailable due to error: {s}", .{@errorName(err)}); + Output.flush(); + this.fd = 0; + return null; + } + }, + } + } +}; + pub const FileSystem = struct { allocator: *std.mem.Allocator, top_level_dir: string = "/", @@ -421,21 +466,44 @@ pub const FileSystem = struct { file_quota: usize = 32, pub var tmpdir_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; + + const PLATFORM_TMP_DIR: string = switch (std.Target.current.os.tag) { + .windows => "%TMPDIR%", + .macos => "/private/tmp", + else => "/tmp", + }; + pub var tmpdir_path: []const u8 = undefined; pub fn openTmpDir(fs: *const RealFS) !std.fs.Dir { - if (isMac) { - var tmpdir_base = std.os.getenv("TMPDIR") orelse "/private/tmp"; - tmpdir_path = try std.fs.realpath(tmpdir_base, &tmpdir_buf); - return try std.fs.openDirAbsolute(tmpdir_path, .{ .access_sub_paths = true, .iterate = true }); - } else { - @compileError("Implement openTmpDir"); + var tmpdir_base = std.os.getenv("TMPDIR") orelse PLATFORM_TMP_DIR; + tmpdir_path = try std.fs.realpath(tmpdir_base, &tmpdir_buf); + return try std.fs.openDirAbsolute(tmpdir_path, .{ .access_sub_paths = true, .iterate = true }); + } + + pub fn fetchCacheFile(fs: *RealFS, basename: string) !std.fs.File { + const file = try fs._fetchCacheFile(basename); + if (comptime FeatureFlags.store_file_descriptors) { + setMaxFd(file.handle); } + return file; + } + + inline fn _fetchCacheFile(fs: *RealFS, basename: string) !std.fs.File { + var parts = [_]string{ "node_modules", ".cache", basename }; + var path = fs.parent_fs.join(&parts); + return std.fs.cwd().openFile(path, .{ .write = true, .read = true, .lock = .Shared }) catch |err| { + path = fs.parent_fs.join(parts[0..2]); + try std.fs.cwd().makePath(path); + + path = fs.parent_fs.join(&parts); + return try std.fs.cwd().createFile(path, .{ .read = true, .lock = .Shared }); + }; } pub fn needToCloseFiles(rfs: *const RealFS) bool { // On Windows, we must always close open file handles // Windows locks files - if (!FeatureFlags.store_file_descriptors) { + if (comptime !FeatureFlags.store_file_descriptors) { return true; } diff --git a/src/global.zig b/src/global.zig index 9258a0ac8..daa30e676 100644 --- a/src/global.zig +++ b/src/global.zig @@ -236,7 +236,11 @@ pub const Output = struct { printer(new_fmt[0..new_fmt_i], args); } - pub fn prettyWithPrinter(comptime fmt: string, args: anytype, printer: anytype) void { + pub fn prettyWithPrinter(comptime fmt: string, args: anytype, printer: anytype, comptime l: Level) void { + if (comptime l == .Warn) { + if (level == .Error) return; + } + if (enable_ansi_colors) { _pretty(fmt, args, printer, true); } else { @@ -245,7 +249,7 @@ pub const Output = struct { } pub fn pretty(comptime fmt: string, args: anytype) void { - prettyWithPrinter(fmt, args, print); + prettyWithPrinter(fmt, args, print, .Error); } pub fn prettyln(comptime fmt: string, args: anytype) void { @@ -265,7 +269,7 @@ pub const Output = struct { } pub fn prettyError(comptime fmt: string, args: anytype) void { - prettyWithPrinter(fmt, args, printError); + prettyWithPrinter(fmt, args, printError, .Error); } pub fn prettyErrorln(comptime fmt: string, args: anytype) void { @@ -274,6 +278,7 @@ pub const Output = struct { fmt ++ "\n", args, printError, + .Error, ); } @@ -281,9 +286,29 @@ pub const Output = struct { fmt, args, printError, + .Error, ); } + pub const Level = enum(u8) { + Warn, + Error, + }; + + pub var level = if (isDebug) Level.Warn else Level.Error; + + pub fn prettyWarn(comptime fmt: string, args: anytype) void { + prettyWithPrinter(fmt, args, printError, .Warn); + } + + pub fn prettyWarnln(comptime fmt: string, args: anytype) void { + if (fmt[fmt.len - 1] != '\n') { + return prettyWithPrinter(fmt ++ "\n", args, printError, .Warn); + } + + return prettyWithPrinter(fmt, args, printError, .Warn); + } + pub fn errorLn(comptime fmt: string, args: anytype) void { return printErrorln(fmt, args); } diff --git a/src/javascript/jsc/api/router.zig b/src/javascript/jsc/api/router.zig index 5c3559636..84dad71ef 100644 --- a/src/javascript/jsc/api/router.zig +++ b/src/javascript/jsc/api/router.zig @@ -20,7 +20,7 @@ pub fn importRoute( arguments: []const js.JSValueRef, exception: js.ExceptionRef, ) js.JSObjectRef { - return JavaScript.VirtualMachine.vm.require( + return JavaScript.VirtualMachine.instance.require( ctx, std.fs.path.dirname(this.route.file_path).?, this.route.file_path, diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 26ad666ba..8897b8d21 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -1,40 +1,42 @@ #include "ZigGlobalObject.h" #include "helpers.h" +#include "ZigConsoleClient.h" #include <JavaScriptCore/CallFrameInlines.h> #include <JavaScriptCore/CatchScope.h> +#include <JavaScriptCore/ClassInfo.h> #include <JavaScriptCore/Completion.h> #include <JavaScriptCore/Error.h> #include <JavaScriptCore/Exception.h> +#include <JavaScriptCore/Identifier.h> +#include <JavaScriptCore/InitializeThreading.h> +#include <JavaScriptCore/JSCast.h> #include <JavaScriptCore/JSContextInternal.h> #include <JavaScriptCore/JSInternalPromise.h> #include <JavaScriptCore/JSModuleLoader.h> #include <JavaScriptCore/JSNativeStdFunction.h> #include <JavaScriptCore/JSPromise.h> #include <JavaScriptCore/JSSourceCode.h> +#include <JavaScriptCore/JSString.h> #include <JavaScriptCore/JSValueInternal.h> #include <JavaScriptCore/JSVirtualMachineInternal.h> #include <JavaScriptCore/ObjectConstructor.h> #include <JavaScriptCore/SourceOrigin.h> -#include <JavaScriptCore/Identifier.h> -#include <wtf/URL.h> -#include <JavaScriptCore/ClassInfo.h> -#include <JavaScriptCore/JSString.h> #include <JavaScriptCore/VM.h> #include <JavaScriptCore/WasmFaultSignalHandler.h> -#include <JavaScriptCore/JSCast.h> -#include <JavaScriptCore/InitializeThreading.h> -#include "ZigConsoleClient.h" +#include <wtf/URL.h> #include <JavaScriptCore/JSLock.h> #include <wtf/StdLibExtras.h> -#include <iostream> #include <cstdlib> #include <exception> +#include <iostream> -#include <JavaScriptCore/JSClassRef.h> #include <JavaScriptCore/JSCallbackObject.h> +#include <JavaScriptCore/JSClassRef.h> + +#include "ZigSourceProvider.h" using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; @@ -48,193 +50,199 @@ using JSObject = JSC::JSObject; using JSNonFinalObject = JSC::JSNonFinalObject; namespace JSCastingHelpers = JSC::JSCastingHelpers; +extern "C" JSC__JSGlobalObject *Zig__GlobalObject__create(JSClassRef *globalObjectClass, int count, + void *console_client) { + std::set_terminate([]() { Zig__GlobalObject__onCrash(); }); + JSC::initialize(); -extern "C" JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* globalObjectClass, int count, void* console_client) { - std::set_terminate([](){ Zig__GlobalObject__onCrash(); }); - JSC::initialize(); - - JSC::VM& vm = JSC::VM::create(JSC::LargeHeap).leakRef(); + JSC::VM &vm = JSC::VM::create(JSC::LargeHeap).leakRef(); - #if ENABLE(WEBASSEMBLY) - JSC::Wasm::enableFastMemory(); - #endif +#if ENABLE(WEBASSEMBLY) + JSC::Wasm::enableFastMemory(); +#endif - JSC::JSLockHolder locker(vm); - Zig::GlobalObject *globalObject = Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull())); - globalObject->setConsole(globalObject); + JSC::JSLockHolder locker(vm); + Zig::GlobalObject *globalObject = + Zig::GlobalObject::create(vm, Zig::GlobalObject::createStructure(vm, JSC::jsNull())); + globalObject->setConsole(globalObject); - if (count > 0) { - globalObject->installAPIGlobals(globalObjectClass, count); - } + if (count > 0) { globalObject->installAPIGlobals(globalObjectClass, count); } - - JSC::gcProtect(globalObject); - vm.ref(); - return globalObject; + JSC::gcProtect(globalObject); + vm.ref(); + return globalObject; } namespace Zig { -const JSC::ClassInfo GlobalObject::s_info = { "GlobalObject", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(GlobalObject) }; +const JSC::ClassInfo GlobalObject::s_info = {"GlobalObject", &Base::s_info, nullptr, nullptr, + CREATE_METHOD_TABLE(GlobalObject)}; const JSC::GlobalObjectMethodTable GlobalObject::s_globalObjectMethodTable = { - &supportsRichSourceInfo, - &shouldInterruptScript, - &javaScriptRuntimeFlags, - nullptr, // queueTaskToEventLoop - nullptr, // &shouldInterruptScriptBeforeTimeout, - &moduleLoaderImportModule, // moduleLoaderImportModule - &moduleLoaderResolve, // moduleLoaderResolve - &moduleLoaderFetch, // moduleLoaderFetch - &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties - &moduleLoaderEvaluate, // moduleLoaderEvaluate - &promiseRejectionTracker, // promiseRejectionTracker - &reportUncaughtExceptionAtEventLoop, - ¤tScriptExecutionOwner, - &scriptExecutionStatus, - nullptr, // defaultLanguage - nullptr, // compileStreaming - nullptr, // instantiateStreaming + &supportsRichSourceInfo, + &shouldInterruptScript, + &javaScriptRuntimeFlags, + nullptr, // queueTaskToEventLoop + nullptr, // &shouldInterruptScriptBeforeTimeout, + &moduleLoaderImportModule, // moduleLoaderImportModule + &moduleLoaderResolve, // moduleLoaderResolve + &moduleLoaderFetch, // moduleLoaderFetch + &moduleLoaderCreateImportMetaProperties, // moduleLoaderCreateImportMetaProperties + &moduleLoaderEvaluate, // moduleLoaderEvaluate + &promiseRejectionTracker, // promiseRejectionTracker + &reportUncaughtExceptionAtEventLoop, + ¤tScriptExecutionOwner, + &scriptExecutionStatus, + nullptr, // defaultLanguage + nullptr, // compileStreaming + nullptr, // instantiateStreaming }; -void GlobalObject::reportUncaughtExceptionAtEventLoop(JSGlobalObject* globalObject, Exception* exception) { - Zig__GlobalObject__reportUncaughtException(globalObject, exception); +void GlobalObject::reportUncaughtExceptionAtEventLoop(JSGlobalObject *globalObject, + Exception *exception) { + Zig__GlobalObject__reportUncaughtException(globalObject, exception); } -void GlobalObject::promiseRejectionTracker(JSGlobalObject* obj, JSC::JSPromise* prom, JSC::JSPromiseRejectionOperation reject) { - Zig__GlobalObject__promiseRejectionTracker(obj, prom, reject == JSC::JSPromiseRejectionOperation::Reject ? 0 : 1); +void GlobalObject::promiseRejectionTracker(JSGlobalObject *obj, JSC::JSPromise *prom, + JSC::JSPromiseRejectionOperation reject) { + Zig__GlobalObject__promiseRejectionTracker( + obj, prom, reject == JSC::JSPromiseRejectionOperation::Reject ? 0 : 1); } -static Zig::ConsoleClient* m_console; +static Zig::ConsoleClient *m_console; -void GlobalObject::setConsole(void* console) { - m_console = new Zig::ConsoleClient(console); - this->setConsoleClient(makeWeakPtr(m_console)); +void GlobalObject::setConsole(void *console) { + m_console = new Zig::ConsoleClient(console); + this->setConsoleClient(makeWeakPtr(m_console)); } -void GlobalObject::installAPIGlobals(JSClassRef* globals, int count) { - WTF::Vector<GlobalPropertyInfo> extraStaticGlobals; - extraStaticGlobals.reserveCapacity((size_t)count); +void GlobalObject::installAPIGlobals(JSClassRef *globals, int count) { + WTF::Vector<GlobalPropertyInfo> extraStaticGlobals; + extraStaticGlobals.reserveCapacity((size_t)count); - for (int i = 0; i < count; i++) { - auto jsClass = globals[i]; + for (int i = 0; i < count; i++) { + auto jsClass = globals[i]; - JSC::JSCallbackObject<JSNonFinalObject>* object = JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(), jsClass, nullptr); - if (JSObject* prototype = jsClass->prototype(this)) - object->setPrototypeDirect(vm(), prototype); + JSC::JSCallbackObject<JSNonFinalObject> *object = + JSC::JSCallbackObject<JSNonFinalObject>::create(this, this->callbackObjectStructure(), + jsClass, nullptr); + if (JSObject *prototype = jsClass->prototype(this)) object->setPrototypeDirect(vm(), prototype); - extraStaticGlobals.uncheckedAppend(GlobalPropertyInfo{ JSC::Identifier::fromString(vm(), jsClass->className()), JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0 }); - } - this->addStaticGlobals(extraStaticGlobals.data(), count); - extraStaticGlobals.releaseBuffer(); + extraStaticGlobals.uncheckedAppend( + GlobalPropertyInfo{JSC::Identifier::fromString(vm(), jsClass->className()), + JSC::JSValue(object), JSC::PropertyAttribute::DontDelete | 0}); + } + this->addStaticGlobals(extraStaticGlobals.data(), count); + extraStaticGlobals.releaseBuffer(); } -JSC::Identifier GlobalObject::moduleLoaderResolve( - JSGlobalObject* globalObject, - JSModuleLoader* loader, - JSValue key, - JSValue referrer, - JSValue origin -) { - auto res = Zig__GlobalObject__resolve( - globalObject, - toZigString(key, globalObject), - referrer.isString() ? toZigString(referrer, globalObject) : ZigStringEmpty - ); - - if (res.success) { - return toIdentifier(res.result.value, globalObject); - } else { - auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); - throwException(scope, res.result.err.message, globalObject); - return globalObject->vm().propertyNames->emptyIdentifier; - } - +JSC::Identifier GlobalObject::moduleLoaderResolve(JSGlobalObject *globalObject, + JSModuleLoader *loader, JSValue key, + JSValue referrer, JSValue origin) { + auto res = Zig__GlobalObject__resolve(globalObject, toZigString(key, globalObject), + referrer.isString() ? toZigString(referrer, globalObject) + : ZigStringEmpty); + + if (res.success) { + return toIdentifier(res.result.value, globalObject); + } else { + auto scope = DECLARE_THROW_SCOPE(globalObject->vm()); + throwException(scope, res.result.err.message, globalObject); + return globalObject->vm().propertyNames->emptyIdentifier; + } } -JSC::JSInternalPromise* GlobalObject::moduleLoaderImportModule(JSGlobalObject* globalObject, JSModuleLoader*, JSString* moduleNameValue, JSValue parameters, const SourceOrigin& sourceOrigin) -{ - JSC::VM& vm = globalObject->vm(); - auto scope = DECLARE_THROW_SCOPE(vm); +JSC::JSInternalPromise *GlobalObject::moduleLoaderImportModule(JSGlobalObject *globalObject, + JSModuleLoader *, + JSString *moduleNameValue, + JSValue parameters, + const SourceOrigin &sourceOrigin) { + JSC::VM &vm = globalObject->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); + + auto *promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); + RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); + + auto sourceURL = sourceOrigin.url(); + auto resolved = Zig__GlobalObject__resolve( + globalObject, toZigString(moduleNameValue, globalObject), + sourceURL.isEmpty() ? ZigStringCwd : toZigString(sourceURL.fileSystemPath())); + if (!resolved.success) { + throwException(scope, resolved.result.err.message, globalObject); + return promise->rejectWithCaughtException(globalObject, scope); + } + + auto result = JSC::importModule(globalObject, toIdentifier(resolved.result.value, globalObject), + parameters, JSC::jsUndefined()); + RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); + + return result; +} - auto* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); - RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); +JSC::JSInternalPromise *GlobalObject::moduleLoaderFetch(JSGlobalObject *globalObject, + JSModuleLoader *loader, JSValue key, + JSValue value1, JSValue value2) { + JSC::VM &vm = globalObject->vm(); + JSC::JSInternalPromise *promise = + JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); - auto sourceURL = sourceOrigin.url(); - auto resolved = Zig__GlobalObject__resolve(globalObject, toZigString(moduleNameValue, globalObject), sourceURL.isEmpty() ? ZigStringCwd : toZigString(sourceURL.fileSystemPath())); - if (!resolved.success) { - throwException(scope, resolved.result.err.message, globalObject); - return promise->rejectWithCaughtException(globalObject, scope); - } + auto scope = DECLARE_THROW_SCOPE(vm); - auto result = JSC::importModule(globalObject, toIdentifier(resolved.result.value, globalObject), parameters, JSC::jsUndefined()); - RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); + auto rejectWithError = [&](JSC::JSValue error) { + promise->reject(globalObject, error); + return promise; + }; - return result; -} + auto moduleKey = key.toWTFString(globalObject); + RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); + auto moduleKeyZig = toZigString(moduleKey); + auto res = Zig__GlobalObject__fetch(globalObject, moduleKeyZig, ZigStringEmpty); -JSC::JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSValue value1, JSValue value2) { - JSC::VM& vm = globalObject->vm(); - JSC::JSInternalPromise* promise = JSC::JSInternalPromise::create(vm, globalObject->internalPromiseStructure()); + if (!res.success) { + throwException(scope, res.result.err.message, globalObject); + RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); + } - auto scope = DECLARE_THROW_SCOPE(vm); + auto code = Zig::toString(res.result.value.source_code); + auto provider = Zig::SourceProvider::create(res.result.value); - auto rejectWithError = [&](JSC::JSValue error) { - promise->reject(globalObject, error); - return promise; - }; + auto jsSourceCode = JSC::JSSourceCode::create(vm, JSC::SourceCode(provider)); - auto moduleKey = key.toWTFString(globalObject); - RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); - auto moduleKeyZig = toZigString(moduleKey); - - auto res = Zig__GlobalObject__fetch( - globalObject, - moduleKeyZig, - ZigStringEmpty - ); - - if (!res.success) { - throwException(scope, res.result.err.message, globalObject); - RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); - } - - auto code = Zig::toString(res.result.value); - auto sourceCode = JSC::JSSourceCode::create( - vm, - JSC::makeSource( - code, - JSC::SourceOrigin { WTF::URL::fileURLWithFileSystemPath(moduleKey) }, - WTFMove(moduleKey), - TextPosition(), - JSC::SourceProviderSourceType::Module - ) - ); - - scope.release(); - promise->resolve(globalObject, sourceCode); - globalObject->vm().drainMicrotasks(); - return promise; -} + // if (provider.ptr()->isBytecodeCacheEnabled()) { + // provider.ptr()->readOrGenerateByteCodeCache(vm, jsSourceCode->sourceCode()); + // } -JSC::JSObject* GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObject* globalObject, JSModuleLoader* loader, JSValue key, JSModuleRecord* record, JSValue val) { - return nullptr; - // auto res = Zig__GlobalObject__createImportMetaProperties( - // globalObject, - // loader, - // JSValue::encode(key), - // record, - // JSValue::encode(val) - // ); - - // return JSValue::decode(res).getObject(); + scope.release(); + promise->resolve(globalObject, jsSourceCode); + globalObject->vm().drainMicrotasks(); + return promise; } -JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject* globalObject, JSModuleLoader* moduleLoader, JSValue key, JSValue moduleRecordValue, JSValue scriptFetcher, JSValue sentValue, JSValue resumeMode) { - // VM& vm = globalObject->vm(); - return moduleLoader->evaluateNonVirtual(globalObject, key, moduleRecordValue, scriptFetcher, sentValue, resumeMode); +JSC::JSObject *GlobalObject::moduleLoaderCreateImportMetaProperties(JSGlobalObject *globalObject, + JSModuleLoader *loader, + JSValue key, + JSModuleRecord *record, + JSValue val) { + return nullptr; + // auto res = Zig__GlobalObject__createImportMetaProperties( + // globalObject, + // loader, + // JSValue::encode(key), + // record, + // JSValue::encode(val) + // ); + + // return JSValue::decode(res).getObject(); } +JSC::JSValue GlobalObject::moduleLoaderEvaluate(JSGlobalObject *globalObject, + JSModuleLoader *moduleLoader, JSValue key, + JSValue moduleRecordValue, JSValue scriptFetcher, + JSValue sentValue, JSValue resumeMode) { + // VM& vm = globalObject->vm(); + return moduleLoader->evaluateNonVirtual(globalObject, key, moduleRecordValue, scriptFetcher, + sentValue, resumeMode); +} } // namespace Zig
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.h b/src/javascript/jsc/bindings/ZigGlobalObject.h index 1a036024f..d3e7f0f81 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.h +++ b/src/javascript/jsc/bindings/ZigGlobalObject.h @@ -1,75 +1,71 @@ #include "root.h" -#pragma once +#pragma once namespace JSC { - class Structure; - class Identifier; - -} +class Structure; +class Identifier; +} // namespace JSC -#include <JavaScriptCore/Structure.h> +#include "ZigConsoleClient.h" #include <JavaScriptCore/JSGlobalObject.h> #include <JavaScriptCore/JSTypeInfo.h> - -#include "ZigConsoleClient.h" - +#include <JavaScriptCore/Structure.h> namespace Zig { - - class GlobalObject : public JSC::JSGlobalObject { - using Base = JSC::JSGlobalObject; - -public: - - DECLARE_EXPORT_INFO; - static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; - - static constexpr bool needsDestruction = true; - template<typename CellType, JSC::SubspaceAccess mode> - static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) - { - return vm.globalObjectSpace<mode>(); - } - - static GlobalObject* create(JSC::VM& vm, JSC::Structure* structure) - { - auto* object = new (NotNull, JSC::allocateCell<GlobalObject>(vm.heap)) GlobalObject(vm, structure); - object->finishCreation(vm); - return object; - } - - static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSValue prototype) - { - auto* result = JSC::Structure::create(vm, nullptr, prototype, JSC::TypeInfo(JSC::GlobalObjectType, Base::StructureFlags), info()); - result->setTransitionWatchpointIsLikelyToBeFired(true); - return result; - } - - static void reportUncaughtExceptionAtEventLoop(JSGlobalObject*, JSC::Exception*); - - static JSC::JSInternalPromise* moduleLoaderImportModule(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSString* moduleNameValue, JSC::JSValue parameters, const JSC::SourceOrigin&); - static JSC::Identifier moduleLoaderResolve(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue keyValue, JSC::JSValue referrerValue, JSC::JSValue); - static JSC::JSInternalPromise* moduleLoaderFetch(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue); - static JSC::JSObject* moduleLoaderCreateImportMetaProperties(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSModuleRecord*, JSC::JSValue); - static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject*, JSC::JSModuleLoader*, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue); - static void promiseRejectionTracker(JSGlobalObject*, JSC::JSPromise*, JSC::JSPromiseRejectionOperation); - void setConsole(void* console); - void installAPIGlobals(JSClassRef* globals, int count); - -private: - - GlobalObject(JSC::VM& vm, JSC::Structure* structure) - : JSC::JSGlobalObject(vm, structure, &s_globalObjectMethodTable) - { - - } + using Base = JSC::JSGlobalObject; + + public: + DECLARE_EXPORT_INFO; + static const JSC::GlobalObjectMethodTable s_globalObjectMethodTable; + + static constexpr bool needsDestruction = true; + template <typename CellType, JSC::SubspaceAccess mode> + static JSC::IsoSubspace *subspaceFor(JSC::VM &vm) { + return vm.globalObjectSpace<mode>(); + } + + static GlobalObject *create(JSC::VM &vm, JSC::Structure *structure) { + auto *object = + new (NotNull, JSC::allocateCell<GlobalObject>(vm.heap)) GlobalObject(vm, structure); + object->finishCreation(vm); + return object; + } + + static JSC::Structure *createStructure(JSC::VM &vm, JSC::JSValue prototype) { + auto *result = JSC::Structure::create( + vm, nullptr, prototype, JSC::TypeInfo(JSC::GlobalObjectType, Base::StructureFlags), info()); + result->setTransitionWatchpointIsLikelyToBeFired(true); + return result; + } + + static void reportUncaughtExceptionAtEventLoop(JSGlobalObject *, JSC::Exception *); + + static JSC::JSInternalPromise *moduleLoaderImportModule(JSGlobalObject *, JSC::JSModuleLoader *, + JSC::JSString *moduleNameValue, + JSC::JSValue parameters, + const JSC::SourceOrigin &); + static JSC::Identifier moduleLoaderResolve(JSGlobalObject *, JSC::JSModuleLoader *, + JSC::JSValue keyValue, JSC::JSValue referrerValue, + JSC::JSValue); + static JSC::JSInternalPromise *moduleLoaderFetch(JSGlobalObject *, JSC::JSModuleLoader *, + JSC::JSValue, JSC::JSValue, JSC::JSValue); + static JSC::JSObject *moduleLoaderCreateImportMetaProperties(JSGlobalObject *, + JSC::JSModuleLoader *, JSC::JSValue, + JSC::JSModuleRecord *, JSC::JSValue); + static JSC::JSValue moduleLoaderEvaluate(JSGlobalObject *, JSC::JSModuleLoader *, JSC::JSValue, + JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue); + static void promiseRejectionTracker(JSGlobalObject *, JSC::JSPromise *, + JSC::JSPromiseRejectionOperation); + void setConsole(void *console); + void installAPIGlobals(JSClassRef *globals, int count); + + private: + GlobalObject(JSC::VM &vm, JSC::Structure *structure) + : JSC::JSGlobalObject(vm, structure, &s_globalObjectMethodTable) {} }; -} - - - +} // namespace Zig diff --git a/src/javascript/jsc/bindings/ZigSourceProvider.cpp b/src/javascript/jsc/bindings/ZigSourceProvider.cpp new file mode 100644 index 000000000..6a08e1057 --- /dev/null +++ b/src/javascript/jsc/bindings/ZigSourceProvider.cpp @@ -0,0 +1,134 @@ +#include "ZigSourceProvider.h" +#include "helpers.h" +#include <JavaScriptCore/BytecodeCacheError.h> +#include <JavaScriptCore/CodeCache.h> + +#include <JavaScriptCore/Completion.h> +#include <sys/stat.h> +#include <wtf/FileSystem.h> +#include <wtf/Scope.h> +#include <wtf/text/StringHash.h> + +namespace Zig { + +using Base = JSC::SourceProvider; +using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator; +using UnlinkedFunctionExecutable = JSC::UnlinkedFunctionExecutable; +using CachedBytecode = JSC::CachedBytecode; +using UnlinkedFunctionCodeBlock = JSC::UnlinkedFunctionCodeBlock; +using SourceCode = JSC::SourceCode; +using CodeSpecializationKind = JSC::CodeSpecializationKind; +using SourceOrigin = JSC::SourceOrigin; +using String = WTF::String; +using SourceProviderSourceType = JSC::SourceProviderSourceType; + +Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource) { + return adoptRef(*new SourceProvider( + resolvedSource, + JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))), + toStringNotConst(resolvedSource.source_url), TextPosition(), + JSC::SourceProviderSourceType::Module)); +} + +unsigned SourceProvider::getHash() { + if (m_hash) { return m_hash; } + + m_hash = WTF::StringHash::hash(WTF::String(WTF::StringImpl::createWithoutCopying( + m_resolvedSource.source_code.ptr, m_resolvedSource.source_code.len))); + return m_hash; +} + +void SourceProvider::updateCache(const UnlinkedFunctionExecutable *executable, const SourceCode &, + CodeSpecializationKind kind, + const UnlinkedFunctionCodeBlock *codeBlock) { + if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode) return; + + JSC::BytecodeCacheError error; + RefPtr<JSC::CachedBytecode> cachedBytecode = + JSC::encodeFunctionCodeBlock(executable->vm(), codeBlock, error); + if (cachedBytecode && !error.isValid()) + m_cachedBytecode->addFunctionUpdate(executable, kind, *cachedBytecode); +} + +void SourceProvider::cacheBytecode(const BytecodeCacheGenerator &generator) { + if (!m_resolvedSource.bytecodecache_fd) return; + + if (!m_cachedBytecode) m_cachedBytecode = JSC::CachedBytecode::create(); + auto update = generator(); + if (update) m_cachedBytecode->addGlobalUpdate(*update); +} +void SourceProvider::commitCachedBytecode() { + if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode || !m_cachedBytecode->hasUpdates()) + return; + + auto clearBytecode = WTF::makeScopeExit([&] { m_cachedBytecode = nullptr; }); + const auto fd = m_resolvedSource.bytecodecache_fd; + + auto fileSize = FileSystem::fileSize(fd); + if (!fileSize) return; + + size_t cacheFileSize; + if (!WTF::convertSafely(*fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) { + // The bytecode cache has already been updated + return; + } + + if (!FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate())) return; + + m_cachedBytecode->commitUpdates([&](off_t offset, const void *data, size_t size) { + long long result = FileSystem::seekFile(fd, offset, FileSystem::FileSeekOrigin::Beginning); + ASSERT_UNUSED(result, result != -1); + size_t bytesWritten = static_cast<size_t>(FileSystem::writeToFile(fd, data, size)); + ASSERT_UNUSED(bytesWritten, bytesWritten == size); + }); +} + +bool SourceProvider::isBytecodeCacheEnabled() const { + return m_resolvedSource.bytecodecache_fd > 0; +} + +void SourceProvider::readOrGenerateByteCodeCache(JSC::VM &vm, const JSC::SourceCode &sourceCode) { + auto status = this->readCache(vm, sourceCode); + switch (status) { + case -1: { + m_resolvedSource.bytecodecache_fd = 0; + break; + } + case 0: { + JSC::BytecodeCacheError err; + m_cachedBytecode = + JSC::generateModuleBytecode(vm, sourceCode, m_resolvedSource.bytecodecache_fd, err); + + if (err.isValid()) { + m_resolvedSource.bytecodecache_fd = 0; + m_cachedBytecode = JSC::CachedBytecode::create(); + } + } + } +} +int SourceProvider::readCache(JSC::VM &vm, const JSC::SourceCode &sourceCode) { + if (m_resolvedSource.bytecodecache_fd == 0) return -1; + if (!FileSystem::isHandleValid(m_resolvedSource.bytecodecache_fd)) return -1; + const auto fd = m_resolvedSource.bytecodecache_fd; + + bool success; + FileSystem::MappedFileData mappedFile(fd, FileSystem::MappedFileMode::Shared, success); + if (!success) return -1; + + const uint8_t *fileData = reinterpret_cast<const uint8_t *>(mappedFile.data()); + unsigned fileTotalSize = mappedFile.size(); + if (fileTotalSize == 0) return 0; + + Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTFMove(mappedFile)); + auto key = JSC::sourceCodeKeyForSerializedModule(vm, sourceCode); + if (isCachedBytecodeStillValid(vm, cachedBytecode.copyRef(), key, + JSC::SourceCodeType::ModuleType)) { + m_cachedBytecode = WTFMove(cachedBytecode); + return 1; + } else { + FileSystem::truncateFile(fd, 0); + return 0; + } +} + +}; // namespace Zig
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/ZigSourceProvider.h b/src/javascript/jsc/bindings/ZigSourceProvider.h new file mode 100644 index 000000000..2012b45b6 --- /dev/null +++ b/src/javascript/jsc/bindings/ZigSourceProvider.h @@ -0,0 +1,70 @@ +#include "headers.h" +#include "root.h" + +#pragma once + +namespace JSC { +class Structure; +class Identifier; + +} // namespace JSC + +#include "ZigConsoleClient.h" +#include <JavaScriptCore/CachedBytecode.h> +#include <JavaScriptCore/JSGlobalObject.h> +#include <JavaScriptCore/JSTypeInfo.h> +#include <JavaScriptCore/SourceProvider.h> +#include <JavaScriptCore/Structure.h> +#include <wtf/FileSystem.h> + +namespace Zig { + +class SourceProvider final : public JSC::SourceProvider { + WTF_MAKE_FAST_ALLOCATED; + using Base = JSC::SourceProvider; + using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator; + using UnlinkedFunctionExecutable = JSC::UnlinkedFunctionExecutable; + using CachedBytecode = JSC::CachedBytecode; + using UnlinkedFunctionCodeBlock = JSC::UnlinkedFunctionCodeBlock; + using SourceCode = JSC::SourceCode; + using CodeSpecializationKind = JSC::CodeSpecializationKind; + using SourceOrigin = JSC::SourceOrigin; + + public: + static Ref<SourceProvider> create(ResolvedSource resolvedSource); + ~SourceProvider() { commitCachedBytecode(); } + + unsigned hash() const { return m_hash; }; + StringView source() const { + return StringView(m_resolvedSource.source_code.ptr, m_resolvedSource.source_code.len); + } + RefPtr<JSC::CachedBytecode> cachedBytecode() { + if (m_resolvedSource.bytecodecache_fd == 0) { return nullptr; } + + return m_cachedBytecode; + }; + + void updateCache(const UnlinkedFunctionExecutable *executable, const SourceCode &, + CodeSpecializationKind kind, const UnlinkedFunctionCodeBlock *codeBlock); + void cacheBytecode(const BytecodeCacheGenerator &generator); + void commitCachedBytecode(); + bool isBytecodeCacheEnabled() const; + void readOrGenerateByteCodeCache(JSC::VM &vm, const JSC::SourceCode &sourceCode); + ResolvedSource m_resolvedSource; + int readCache(JSC::VM &vm, const JSC::SourceCode &sourceCode); + + private: + SourceProvider(ResolvedSource resolvedSource, const SourceOrigin &sourceOrigin, + WTF::String &&sourceURL, const TextPosition &startPosition, + JSC::SourceProviderSourceType sourceType) + : Base(sourceOrigin, WTFMove(sourceURL), startPosition, sourceType) { + m_resolvedSource = resolvedSource; + m_hash = resolvedSource.hash; + getHash(); + } + unsigned m_hash; + unsigned getHash(); + RefPtr<JSC::CachedBytecode> m_cachedBytecode; +}; + +} // namespace Zig
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp index 3408a1c30..9afe9a00b 100644 --- a/src/javascript/jsc/bindings/bindings.cpp +++ b/src/javascript/jsc/bindings/bindings.cpp @@ -1,6 +1,7 @@ #include "helpers.h" #include "root.h" #include <JavaScriptCore/Completion.h> +#include <JavaScriptCore/ErrorInstance.h> #include <JavaScriptCore/ExceptionScope.h> #include <JavaScriptCore/FunctionConstructor.h> #include <JavaScriptCore/Identifier.h> @@ -15,6 +16,7 @@ #include <JavaScriptCore/JSSet.h> #include <JavaScriptCore/JSString.h> #include <JavaScriptCore/ParserError.h> +#include <JavaScriptCore/StackFrame.h> #include <JavaScriptCore/VM.h> #include <JavaScriptCore/WasmFaultSignalHandler.h> #include <wtf/text/ExternalStringImpl.h> @@ -572,7 +574,7 @@ JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObje return JSC::JSValue::encode(value.getPrototype(arg1)); } bool JSC__JSValue__isException(JSC__JSValue JSValue0, JSC__VM *arg1) { - return JSC::jsDynamicCast<JSC::Exception>(*arg1, JSC::JSValue::decode(JSValue0)) != nullptr; + return JSC::jsDynamicCast<JSC::Exception *>(*arg1, JSC::JSValue::decode(JSValue0)) != nullptr; } bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0) { return JSC::JSValue::decode(JSValue0).isAnyInt(); @@ -685,16 +687,100 @@ bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObjec return Wrap<WTF::String, bWTF__String>::wrap(value.toWTFString(arg1)); }; +static ZigException fromErrorInstance(JSC::JSGlobalObject *global, JSC::ErrorInstance *err, + JSC::JSValue val) { + ZigException except = Zig::ZigExceptionNone; + JSC::JSObject *obj = JSC::jsDynamicCast<JSC::JSObject *>(global->vm(), val); + if (err->stackTrace() != nullptr && err->stackTrace()->size() > 0) { + JSC::StackFrame *stack = &err->stackTrace()->first(); + except.sourceURL = Zig::toZigString(stack->sourceURL()); + + if (stack->hasLineAndColumnInfo()) { + unsigned lineNumber; + unsigned column; + stack->computeLineAndColumn(lineNumber, column); + except.line = lineNumber; + except.column = column; + } + } else { + // JSC::ErrorInstance marks these as protected. + // To work around that, we cast as a JSC::JSObject + // This code path triggers when there was an exception before the code was executed + // For example, ParserError becomes one of these + auto source_url_value = obj->getDirect(global->vm(), global->vm().propertyNames->sourceURL); + auto str = source_url_value.toWTFString(global); + except.sourceURL = Zig::toZigString(str); + except.line = obj->getDirect(global->vm(), global->vm().propertyNames->line).toInt32(global); + except.column = + obj->getDirect(global->vm(), global->vm().propertyNames->column).toInt32(global); + } + + if (obj->hasProperty(global, global->vm().propertyNames->stack)) { + except.stack = Zig::toZigString( + obj->getDirect(global->vm(), global->vm().propertyNames->stack).toWTFString(global)); + } + + except.code = (unsigned char)err->errorType(); + if (err->isStackOverflowError()) { except.code = 253; } + if (err->isOutOfMemoryError()) { except.code = 8; } + + if (obj->hasProperty(global, global->vm().propertyNames->message)) { + except.message = Zig::toZigString( + obj->getDirect(global->vm(), global->vm().propertyNames->message).toWTFString(global)); + + } else { + except.message = Zig::toZigString(err->sanitizedMessageString(global)); + } + except.name = Zig::toZigString(err->sanitizedNameString(global)); + except.runtime_type = err->runtimeTypeForCause(); + + except.exception = err; + + return except; +} + +static ZigException exceptionFromString(WTF::String &str) { + ZigException except = Zig::ZigExceptionNone; + auto ref = OpaqueJSString::tryCreate(str); + except.message = ZigString{ref->characters8(), ref->length()}; + ref->ref(); + + return except; +} + +static ZigException exceptionFromString(JSC::JSValue value, JSC::JSGlobalObject *global) { + auto scope = DECLARE_THROW_SCOPE(global->vm()); + auto str = value.toWTFString(global); + if (scope.exception()) { + scope.clearException(); + scope.release(); + return Zig::ZigExceptionNone; + } + scope.release(); + + ZigException except = Zig::ZigExceptionNone; + auto ref = OpaqueJSString::tryCreate(str); + except.message = ZigString{ref->characters8(), ref->length()}; + ref->ref(); + + return except; +} + ZigException JSC__JSValue__toZigException(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1) { JSC::JSValue value = JSC::JSValue::decode(JSValue0); - if (JSC::ErrorInstance *error = - JSC::jsDynamicCast<JSC::ErrorInstance>(*arg1, JSC::JSValue::decode(JSValue0))) {} + if (JSC::ErrorInstance *error = JSC::jsDynamicCast<JSC::ErrorInstance *>(arg1->vm(), value)) { + return fromErrorInstance(arg1, error, value); + } - if (JSC::Exception *exception = - JSC::jsDynamicCast<JSC::Exception>(*arg1, JSC::JSValue::decode(JSValue0))) {} + if (JSC::Exception *exception = JSC::jsDynamicCast<JSC::Exception *>(arg1->vm(), value)) { + if (JSC::ErrorInstance *error = + JSC::jsDynamicCast<JSC::ErrorInstance *>(arg1->vm(), exception->value())) { + return fromErrorInstance(arg1, error, value); + } + } - return Zig::ZigExceptionNone; + return exceptionFromString(value, arg1); } #pragma mark - JSC::PropertyName diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 09f40d475..4055c26bb 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -45,7 +45,7 @@ pub const ZigString = extern struct { pub const Empty = ZigString{ .ptr = "", .len = 0 }; pub fn slice(this: *const ZigString) []const u8 { - return this.ptr[0..this.len]; + return this.ptr[0..std.math.min(this.len, 4096)]; } }; @@ -184,11 +184,11 @@ pub fn NewGlobalObject(comptime Type: type) type { } return ErrorableZigString.err(error.ResolveFailed, "resolve not implemented"); } - pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableZigString { + pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableResolvedSource { if (comptime @hasDecl(Type, "fetch")) { return @call(.{ .modifier = .always_inline }, Type.fetch, .{ global, specifier, source }); } - return ErrorableZigString.err(error.FetchFailed, "Module fetch not implemented"); + return ErrorableResolvedSource.err(error.FetchFailed, "Module fetch not implemented"); } pub fn promiseRejectionTracker(global: *JSGlobalObject, promise: *JSPromise, rejection: JSPromiseRejectionOperation) callconv(.C) JSValue { if (comptime @hasDecl(Type, "promiseRejectionTracker")) { @@ -687,18 +687,6 @@ pub const JSGlobalObject = extern struct { pub const name = "JSC::JSGlobalObject"; pub const namespace = "JSC"; - pub const ErrorType = enum(u8) { - Error = 0, - EvalError = 1, - RangeError = 2, - ReferenceError = 3, - SyntaxError = 4, - TypeError = 5, - URIError = 6, - AggregateError = 7, - OutOfMemoryError = 8, - }; - // pub fn createError(globalObject: *JSGlobalObject, error_type: ErrorType, message: *String) *JSObject { // return cppFn("createError", .{ globalObject, error_type, message }); // } @@ -1173,6 +1161,14 @@ pub const JSValue = enum(i64) { return cppFn("isCallable", .{ this, vm }); } + pub fn isException(this: JSValue, vm: *VM) bool { + return cppFn("isException", .{ this, vm }); + } + + pub fn toZigException(this: JSValue, global: *JSGlobalObject) ZigException { + return cppFn("toZigException", .{ this, global }); + } + // On exception, this returns the empty string. pub fn toString(this: JSValue, globalThis: *JSGlobalObject) *JSString { return cppFn("toString", .{ this, globalThis }); @@ -1226,7 +1222,7 @@ pub const JSValue = enum(i64) { }); } - pub const Extern = [_][]const u8{ "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "get", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" }; + pub const Extern = [_][]const u8{ "toZigException", "isException", "toWTFString", "hasProperty", "getPropertyNames", "getDirect", "putDirect", "get", "getIfExists", "asString", "asObject", "asNumber", "isError", "jsNull", "jsUndefined", "jsTDZValue", "jsBoolean", "jsDoubleNumber", "jsNumberFromDouble", "jsNumberFromChar", "jsNumberFromU16", "jsNumberFromInt32", "jsNumberFromInt64", "jsNumberFromUint64", "isUndefined", "isNull", "isUndefinedOrNull", "isBoolean", "isAnyInt", "isUInt32AsAnyInt", "isInt32AsAnyInt", "isNumber", "isString", "isBigInt", "isHeapBigInt", "isBigInt32", "isSymbol", "isPrimitive", "isGetterSetter", "isCustomGetterSetter", "isObject", "isCell", "asCell", "toString", "toStringOrNull", "toPropertyKey", "toPropertyKeyValue", "toObject", "toString", "getPrototype", "getPropertyByPropertyName", "eqlValue", "eqlCell", "isCallable" }; }; pub const PropertyName = extern struct { diff --git a/src/javascript/jsc/bindings/exports.zig b/src/javascript/jsc/bindings/exports.zig index 82c9e8dd0..1c2dae1f9 100644 --- a/src/javascript/jsc/bindings/exports.zig +++ b/src/javascript/jsc/bindings/exports.zig @@ -47,7 +47,7 @@ pub const ZigGlobalObject = extern struct { } return @call(.{ .modifier = .always_inline }, Interface.resolve, .{ global, specifier, source }); } - pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableZigString { + pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableResolvedSource { if (comptime is_bindgen) { unreachable; } @@ -128,6 +128,39 @@ pub const ZigErrorType = extern struct { message: ZigString, }; +pub const JSErrorCode = enum(u8) { + Error = 0, + EvalError = 1, + RangeError = 2, + ReferenceError = 3, + SyntaxError = 4, + TypeError = 5, + URIError = 6, + AggregateError = 7, + + // StackOverflow & OutOfMemoryError is not an ErrorType in <JavaScriptCore/ErrorType.h> within JSC, so the number here is just totally made up + OutOfMemoryError = 8, + StackOverflow = 253, + UserErrorCode = 254, + _, +}; + +pub const JSRuntimeType = enum(u16) { + Nothing = 0x0, + Function = 0x1, + Undefined = 0x2, + Null = 0x4, + Boolean = 0x8, + AnyInt = 0x10, + Number = 0x20, + String = 0x40, + Object = 0x80, + Symbol = 0x100, + BigInt = 0x200, + + _, +}; + pub fn Errorable(comptime Type: type) type { return extern struct { result: Result, @@ -168,9 +201,47 @@ pub fn Errorable(comptime Type: type) type { }; } +pub const ResolvedSource = extern struct { + pub const shim = Shimmer("Zig", "ResolvedSource", @This()); + pub const name = "ResolvedSource"; + pub const namespace = shim.namespace; + + specifier: ZigString, + source_code: ZigString, + source_url: ZigString, + hash: u32, + + // 0 means disabled + bytecodecache_fd: u64, +}; + +pub const ErrorableResolvedSource = Errorable(ResolvedSource); + pub const ErrorableZigString = Errorable(ZigString); pub const ErrorableJSValue = Errorable(JSValue); +pub const ZigException = extern struct { + pub const shim = Shimmer("Zig", "Exception", @This()); + pub const name = "ZigException"; + pub const namespace = shim.namespace; + + code: JSErrorCode, + runtime_type: JSRuntimeType, + name: ZigString, + message: ZigString, + sourceURL: ZigString, + line: i32, + column: i32, + stack: ZigString, + exception: ?*c_void, + + pub fn fromException(exception: *Exception) ZigException { + return shim.cppFn("fromException", .{exception}); + } + + pub const Extern = [_][]const u8{"fromException"}; +}; + pub const ZigConsoleClient = struct { pub const shim = Shimmer("Zig", "ConsoleClient", @This()); pub const Type = *c_void; diff --git a/src/javascript/jsc/bindings/header-gen.zig b/src/javascript/jsc/bindings/header-gen.zig index bef19daff..e912bf4f8 100644 --- a/src/javascript/jsc/bindings/header-gen.zig +++ b/src/javascript/jsc/bindings/header-gen.zig @@ -600,12 +600,16 @@ pub fn HeaderGen(comptime import: type, comptime fname: []const u8) type { \\#endif \\typedef struct ZigString { const unsigned char* ptr; size_t len; } ZigString; \\typedef struct ZigErrorType { ZigErrorCode code; ZigString message; } ZigErrorType; + \\typedef struct ZigException { unsigned char code; uint16_t runtime_type; ZigString name; ZigString message; ZigString sourceURL; int32_t line; int32_t column; ZigString stack; void* exception; } ZigException; \\typedef union ErrorableZigStringResult { ZigString value; ZigErrorType err; } ErrorableZigStringResult; \\typedef struct ErrorableZigString { ErrorableZigStringResult result; bool success; } ErrorableZigString; + \\typedef struct ResolvedSource { ZigString specifier; ZigString source_code; ZigString source_url; uint32_t hash; uint32_t bytecodecache_fd; } ResolvedSource; + \\typedef union ErrorableResolvedSourceResult { ResolvedSource value; ZigErrorType err; } ErrorableResolvedSourceResult; + \\typedef struct ErrorableResolvedSource { ErrorableResolvedSourceResult result; bool success; } ErrorableResolvedSource; \\ ) catch {}; - impl.writer().print("//-- AUTOGENERATED FILE -- {d}\n", .{std.time.timestamp()}) catch unreachable; + impl.writer().print("//-- AUTOGENERATED FILE -- {d}\n// clang-format off\n", .{std.time.timestamp()}) catch unreachable; impl.writer().writeAll( \\#pragma once \\ diff --git a/src/javascript/jsc/bindings/headers-cpp.h b/src/javascript/jsc/bindings/headers-cpp.h index 46486557a..e8b096bb2 100644 --- a/src/javascript/jsc/bindings/headers-cpp.h +++ b/src/javascript/jsc/bindings/headers-cpp.h @@ -1,4 +1,5 @@ -//-- AUTOGENERATED FILE -- 1627515944 +//-- AUTOGENERATED FILE -- 1627603981 +// clang-format off #pragma once #include <stddef.h> @@ -223,8 +224,8 @@ extern "C" const size_t Zig__GlobalObject_object_align_ = alignof(Zig::GlobalObj extern "C" const size_t Zig__ConsoleClient_object_size_ = sizeof(Zig::ConsoleClient); extern "C" const size_t Zig__ConsoleClient_object_align_ = alignof(Zig::ConsoleClient); -const size_t sizes[26] = {sizeof(JSC::JSObject), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::CallFrame), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView), sizeof(Zig::GlobalObject)}; +const size_t sizes[27] = {sizeof(JSC::JSObject), sizeof(JSC::JSCell), sizeof(JSC::JSString), sizeof(Inspector::ScriptArguments), sizeof(JSC::JSModuleLoader), sizeof(JSC::JSModuleRecord), sizeof(JSC::JSPromise), sizeof(JSC::JSInternalPromise), sizeof(JSC::SourceOrigin), sizeof(JSC::SourceCode), sizeof(JSC::JSFunction), sizeof(JSC::JSGlobalObject), sizeof(WTF::URL), sizeof(WTF::String), sizeof(JSC::JSValue), sizeof(JSC::PropertyName), sizeof(JSC::Exception), sizeof(JSC::VM), sizeof(JSC::ThrowScope), sizeof(JSC::CatchScope), sizeof(JSC::CallFrame), sizeof(JSC::Identifier), sizeof(WTF::StringImpl), sizeof(WTF::ExternalStringImpl), sizeof(WTF::StringView), sizeof(Zig::GlobalObject), sizeof(ZigException)}; -const char* names[26] = {"JSC__JSObject", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__CallFrame", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView", "Zig__GlobalObject"}; +const char* names[27] = {"JSC__JSObject", "JSC__JSCell", "JSC__JSString", "Inspector__ScriptArguments", "JSC__JSModuleLoader", "JSC__JSModuleRecord", "JSC__JSPromise", "JSC__JSInternalPromise", "JSC__SourceOrigin", "JSC__SourceCode", "JSC__JSFunction", "JSC__JSGlobalObject", "WTF__URL", "WTF__String", "JSC__JSValue", "JSC__PropertyName", "JSC__Exception", "JSC__VM", "JSC__ThrowScope", "JSC__CatchScope", "JSC__CallFrame", "JSC__Identifier", "WTF__StringImpl", "WTF__ExternalStringImpl", "WTF__StringView", "Zig__GlobalObject", "ZigException"}; -const size_t aligns[26] = {alignof(JSC::JSObject), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::CallFrame), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), alignof(Zig::GlobalObject)}; +const size_t aligns[27] = {alignof(JSC::JSObject), alignof(JSC::JSCell), alignof(JSC::JSString), alignof(Inspector::ScriptArguments), alignof(JSC::JSModuleLoader), alignof(JSC::JSModuleRecord), alignof(JSC::JSPromise), alignof(JSC::JSInternalPromise), alignof(JSC::SourceOrigin), alignof(JSC::SourceCode), alignof(JSC::JSFunction), alignof(JSC::JSGlobalObject), alignof(WTF::URL), alignof(WTF::String), alignof(JSC::JSValue), alignof(JSC::PropertyName), alignof(JSC::Exception), alignof(JSC::VM), alignof(JSC::ThrowScope), alignof(JSC::CatchScope), alignof(JSC::CallFrame), alignof(JSC::Identifier), alignof(WTF::StringImpl), alignof(WTF::ExternalStringImpl), alignof(WTF::StringView), alignof(Zig::GlobalObject), alignof(ZigException)}; diff --git a/src/javascript/jsc/bindings/headers-replacements.zig b/src/javascript/jsc/bindings/headers-replacements.zig index d17eec6a2..65b9658d8 100644 --- a/src/javascript/jsc/bindings/headers-replacements.zig +++ b/src/javascript/jsc/bindings/headers-replacements.zig @@ -44,4 +44,8 @@ pub const bJSC__CatchScope = bindings.CatchScope; pub const bJSC__CallFrame = bindings.CallFrame; pub const bInspector__ScriptArguments = bindings.ScriptArguments; pub const JSC__JSValue = bindings.JSValue; + +// Inlined types pub const ZigString = bindings.ZigString; +pub const ZigException = bindings.ZigException; +pub const ResolvedSource = bindings.ResolvedSource; diff --git a/src/javascript/jsc/bindings/headers.h b/src/javascript/jsc/bindings/headers.h index 944ceffb5..21b964e9e 100644 --- a/src/javascript/jsc/bindings/headers.h +++ b/src/javascript/jsc/bindings/headers.h @@ -1,14 +1,14 @@ -//-- AUTOGENERATED FILE -- 1627515944 +//-- AUTOGENERATED FILE -- 1627603981 #pragma once +#include <stdbool.h> #include <stddef.h> #include <stdint.h> -#include <stdbool.h> #ifdef __cplusplus - #define AUTO_EXTERN_C extern "C" +#define AUTO_EXTERN_C extern "C" #else - #define AUTO_EXTERN_C +#define AUTO_EXTERN_C #endif #define ZIG_DECL AUTO_EXTERN_C #define CPP_DECL AUTO_EXTERN_C @@ -16,399 +16,580 @@ typedef uint16_t ZigErrorCode; #ifndef __cplusplus -typedef void* JSClassRef; +typedef void *JSClassRef; +#endif + +#ifdef __cplusplus +#include "root.h" +#include <JavaScriptCore/JSClassRef.h> #endif -typedef struct ZigString { const unsigned char* ptr; size_t len; } ZigString; -typedef struct ZigErrorType { ZigErrorCode code; ZigString message; } ZigErrorType; -typedef union ErrorableZigStringResult { ZigString value; ZigErrorType err; } ErrorableZigStringResult; -typedef struct ErrorableZigString { ErrorableZigStringResult result; bool success; } ErrorableZigString; - typedef struct bJSC__JSModuleRecord { unsigned char bytes[216]; } bJSC__JSModuleRecord; - typedef char* bJSC__JSModuleRecord_buf; - typedef struct bJSC__ThrowScope { unsigned char bytes[8]; } bJSC__ThrowScope; - typedef char* bJSC__ThrowScope_buf; - typedef struct bJSC__PropertyName { unsigned char bytes[8]; } bJSC__PropertyName; - typedef char* bJSC__PropertyName_buf; - typedef struct bJSC__CallFrame { unsigned char bytes[8]; } bJSC__CallFrame; - typedef char* bJSC__CallFrame_buf; - typedef struct bJSC__CatchScope { unsigned char bytes[8]; } bJSC__CatchScope; - typedef char* bJSC__CatchScope_buf; - typedef struct bWTF__String { unsigned char bytes[8]; } bWTF__String; - typedef char* bWTF__String_buf; - typedef struct bWTF__StringView { unsigned char bytes[16]; } bWTF__StringView; - typedef char* bWTF__StringView_buf; - typedef struct bJSC__JSModuleLoader { unsigned char bytes[16]; } bJSC__JSModuleLoader; - typedef char* bJSC__JSModuleLoader_buf; - typedef struct bJSC__Exception { unsigned char bytes[40]; } bJSC__Exception; - typedef char* bJSC__Exception_buf; - typedef struct bJSC__VM { unsigned char bytes[48824]; } bJSC__VM; - typedef char* bJSC__VM_buf; - typedef struct bJSC__JSString { unsigned char bytes[16]; } bJSC__JSString; - typedef char* bJSC__JSString_buf; - typedef struct bJSC__SourceOrigin { unsigned char bytes[48]; } bJSC__SourceOrigin; - typedef char* bJSC__SourceOrigin_buf; - typedef struct bWTF__ExternalStringImpl { unsigned char bytes[32]; } bWTF__ExternalStringImpl; - typedef char* bWTF__ExternalStringImpl_buf; - typedef struct bWTF__StringImpl { unsigned char bytes[24]; } bWTF__StringImpl; - typedef char* bWTF__StringImpl_buf; - typedef struct bJSC__JSPromise { unsigned char bytes[32]; } bJSC__JSPromise; - typedef char* bJSC__JSPromise_buf; - typedef struct bJSC__SourceCode { unsigned char bytes[24]; } bJSC__SourceCode; - typedef char* bJSC__SourceCode_buf; - typedef struct bWTF__URL { unsigned char bytes[40]; } bWTF__URL; - typedef char* bWTF__URL_buf; - typedef struct bJSC__JSFunction { unsigned char bytes[32]; } bJSC__JSFunction; - typedef char* bJSC__JSFunction_buf; - typedef struct bJSC__JSGlobalObject { unsigned char bytes[2400]; } bJSC__JSGlobalObject; - typedef char* bJSC__JSGlobalObject_buf; - typedef struct bJSC__JSCell { unsigned char bytes[8]; } bJSC__JSCell; - typedef char* bJSC__JSCell_buf; - typedef struct bJSC__JSLock { unsigned char bytes[40]; } bJSC__JSLock; - typedef char* bJSC__JSLock_buf; - typedef struct bInspector__ScriptArguments { unsigned char bytes[32]; } bInspector__ScriptArguments; - typedef char* bInspector__ScriptArguments_buf; - typedef struct bJSC__JSInternalPromise { unsigned char bytes[32]; } bJSC__JSInternalPromise; - typedef char* bJSC__JSInternalPromise_buf; - typedef struct bJSC__JSObject { unsigned char bytes[16]; } bJSC__JSObject; - typedef char* bJSC__JSObject_buf; - typedef struct bJSC__Identifier { unsigned char bytes[8]; } bJSC__Identifier; - typedef char* bJSC__Identifier_buf; + +typedef struct ZigString { + const unsigned char *ptr; + size_t len; +} ZigString; +typedef struct ZigErrorType { + ZigErrorCode code; + ZigString message; +} ZigErrorType; +typedef struct ZigException { + unsigned char code; + uint16_t runtime_type; + ZigString name; + ZigString message; + ZigString sourceURL; + int32_t line; + int32_t column; + ZigString stack; + void *exception; +} ZigException; +typedef union ErrorableZigStringResult { + ZigString value; + ZigErrorType err; +} ErrorableZigStringResult; +typedef struct ErrorableZigString { + ErrorableZigStringResult result; + bool success; +} ErrorableZigString; +typedef struct ResolvedSource { + ZigString specifier; + ZigString source_code; + ZigString source_url; + uint32_t hash; + uint64_t bytecodecache_fd; +} ResolvedSource; +typedef union ErrorableResolvedSourceResult { + ResolvedSource value; + ZigErrorType err; +} ErrorableResolvedSourceResult; +typedef struct ErrorableResolvedSource { + ErrorableResolvedSourceResult result; + bool success; +} ErrorableResolvedSource; +typedef struct bJSC__JSModuleRecord { + unsigned char bytes[216]; +} bJSC__JSModuleRecord; +typedef char *bJSC__JSModuleRecord_buf; +typedef struct bJSC__ThrowScope { + unsigned char bytes[8]; +} bJSC__ThrowScope; +typedef char *bJSC__ThrowScope_buf; +typedef struct bJSC__PropertyName { + unsigned char bytes[8]; +} bJSC__PropertyName; +typedef char *bJSC__PropertyName_buf; +typedef struct bJSC__CallFrame { + unsigned char bytes[8]; +} bJSC__CallFrame; +typedef char *bJSC__CallFrame_buf; +typedef struct bJSC__CatchScope { + unsigned char bytes[8]; +} bJSC__CatchScope; +typedef char *bJSC__CatchScope_buf; +typedef struct bWTF__String { + unsigned char bytes[8]; +} bWTF__String; +typedef char *bWTF__String_buf; +typedef struct bWTF__StringView { + unsigned char bytes[16]; +} bWTF__StringView; +typedef char *bWTF__StringView_buf; +typedef struct bJSC__JSModuleLoader { + unsigned char bytes[16]; +} bJSC__JSModuleLoader; +typedef char *bJSC__JSModuleLoader_buf; +typedef struct bJSC__Exception { + unsigned char bytes[40]; +} bJSC__Exception; +typedef char *bJSC__Exception_buf; +typedef struct bJSC__VM { + unsigned char bytes[48824]; +} bJSC__VM; +typedef char *bJSC__VM_buf; +typedef struct bJSC__JSString { + unsigned char bytes[16]; +} bJSC__JSString; +typedef char *bJSC__JSString_buf; +typedef struct bJSC__SourceOrigin { + unsigned char bytes[48]; +} bJSC__SourceOrigin; +typedef char *bJSC__SourceOrigin_buf; +typedef struct bWTF__ExternalStringImpl { + unsigned char bytes[32]; +} bWTF__ExternalStringImpl; +typedef char *bWTF__ExternalStringImpl_buf; +typedef struct bWTF__StringImpl { + unsigned char bytes[24]; +} bWTF__StringImpl; +typedef char *bWTF__StringImpl_buf; +typedef struct bJSC__JSPromise { + unsigned char bytes[32]; +} bJSC__JSPromise; +typedef char *bJSC__JSPromise_buf; +typedef struct bJSC__SourceCode { + unsigned char bytes[24]; +} bJSC__SourceCode; +typedef char *bJSC__SourceCode_buf; +typedef struct bWTF__URL { + unsigned char bytes[40]; +} bWTF__URL; +typedef char *bWTF__URL_buf; +typedef struct bJSC__JSFunction { + unsigned char bytes[32]; +} bJSC__JSFunction; +typedef char *bJSC__JSFunction_buf; +typedef struct bJSC__JSGlobalObject { + unsigned char bytes[2400]; +} bJSC__JSGlobalObject; +typedef char *bJSC__JSGlobalObject_buf; +typedef struct bJSC__JSCell { + unsigned char bytes[8]; +} bJSC__JSCell; +typedef char *bJSC__JSCell_buf; +typedef struct bJSC__JSLock { + unsigned char bytes[40]; +} bJSC__JSLock; +typedef char *bJSC__JSLock_buf; +typedef struct bInspector__ScriptArguments { + unsigned char bytes[32]; +} bInspector__ScriptArguments; +typedef char *bInspector__ScriptArguments_buf; +typedef struct bJSC__JSInternalPromise { + unsigned char bytes[32]; +} bJSC__JSInternalPromise; +typedef char *bJSC__JSInternalPromise_buf; +typedef struct bJSC__JSObject { + unsigned char bytes[16]; +} bJSC__JSObject; +typedef char *bJSC__JSObject_buf; +typedef struct bJSC__Identifier { + unsigned char bytes[8]; +} bJSC__Identifier; +typedef char *bJSC__Identifier_buf; #ifndef __cplusplus - typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype - typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype - typedef struct JSC__ArrayIteratorPrototype JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype - typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype - typedef bWTF__StringView WTF__StringView; // WTF::StringView - typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype - typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope - typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope - typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName - typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject - typedef ErrorableZigString ErrorableZigString; - typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl - typedef struct JSC__AsyncIteratorPrototype JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype - typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl - typedef bJSC__JSLock JSC__JSLock; // JSC::JSLock - typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader - typedef bJSC__VM JSC__VM; // JSC::VM - typedef JSClassRef JSClassRef; - typedef struct JSC__AsyncGeneratorPrototype JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype - typedef struct JSC__AsyncGeneratorFunctionPrototype JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype - typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject - typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction - typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype - typedef struct JSC__AsyncFunctionPrototype JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype - typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier - typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise - typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype - typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode - typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell - typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype - typedef struct JSC__GeneratorFunctionPrototype JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype - typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin - typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord - typedef bWTF__String WTF__String; // WTF::String - typedef bWTF__URL WTF__URL; // WTF::URL - typedef int64_t JSC__JSValue; - typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype - typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise - typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype - typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments - typedef bJSC__Exception JSC__Exception; // JSC::Exception - typedef bJSC__JSString JSC__JSString; // JSC::JSString - typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype - typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame - typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype +typedef struct JSC__RegExpPrototype JSC__RegExpPrototype; // JSC::RegExpPrototype +typedef struct JSC__GeneratorPrototype JSC__GeneratorPrototype; // JSC::GeneratorPrototype +typedef struct JSC__ArrayIteratorPrototype + JSC__ArrayIteratorPrototype; // JSC::ArrayIteratorPrototype +typedef struct JSC__StringPrototype JSC__StringPrototype; // JSC::StringPrototype +typedef bWTF__StringView WTF__StringView; // WTF::StringView +typedef struct JSC__JSPromisePrototype JSC__JSPromisePrototype; // JSC::JSPromisePrototype +typedef bJSC__CatchScope JSC__CatchScope; // JSC::CatchScope +typedef bJSC__ThrowScope JSC__ThrowScope; // JSC::ThrowScope +typedef bJSC__PropertyName JSC__PropertyName; // JSC::PropertyName +typedef bJSC__JSObject JSC__JSObject; // JSC::JSObject +typedef ErrorableResolvedSource ErrorableResolvedSource; +typedef ErrorableZigString ErrorableZigString; +typedef bWTF__ExternalStringImpl WTF__ExternalStringImpl; // WTF::ExternalStringImpl +typedef struct JSC__AsyncIteratorPrototype + JSC__AsyncIteratorPrototype; // JSC::AsyncIteratorPrototype +typedef bWTF__StringImpl WTF__StringImpl; // WTF::StringImpl +typedef bJSC__JSLock JSC__JSLock; // JSC::JSLock +typedef bJSC__JSModuleLoader JSC__JSModuleLoader; // JSC::JSModuleLoader +typedef bJSC__VM JSC__VM; // JSC::VM +typedef JSClassRef JSClassRef; +typedef struct JSC__AsyncGeneratorPrototype + JSC__AsyncGeneratorPrototype; // JSC::AsyncGeneratorPrototype +typedef struct JSC__AsyncGeneratorFunctionPrototype + JSC__AsyncGeneratorFunctionPrototype; // JSC::AsyncGeneratorFunctionPrototype +typedef bJSC__JSGlobalObject JSC__JSGlobalObject; // JSC::JSGlobalObject +typedef bJSC__JSFunction JSC__JSFunction; // JSC::JSFunction +typedef struct JSC__ArrayPrototype JSC__ArrayPrototype; // JSC::ArrayPrototype +typedef struct JSC__AsyncFunctionPrototype + JSC__AsyncFunctionPrototype; // JSC::AsyncFunctionPrototype +typedef bJSC__Identifier JSC__Identifier; // JSC::Identifier +typedef bJSC__JSPromise JSC__JSPromise; // JSC::JSPromise +typedef ZigException ZigException; +typedef struct JSC__SetIteratorPrototype JSC__SetIteratorPrototype; // JSC::SetIteratorPrototype +typedef bJSC__SourceCode JSC__SourceCode; // JSC::SourceCode +typedef bJSC__JSCell JSC__JSCell; // JSC::JSCell +typedef struct JSC__BigIntPrototype JSC__BigIntPrototype; // JSC::BigIntPrototype +typedef struct JSC__GeneratorFunctionPrototype + JSC__GeneratorFunctionPrototype; // JSC::GeneratorFunctionPrototype +typedef bJSC__SourceOrigin JSC__SourceOrigin; // JSC::SourceOrigin +typedef bJSC__JSModuleRecord JSC__JSModuleRecord; // JSC::JSModuleRecord +typedef bWTF__String WTF__String; // WTF::String +typedef bWTF__URL WTF__URL; // WTF::URL +typedef int64_t JSC__JSValue; +typedef struct JSC__IteratorPrototype JSC__IteratorPrototype; // JSC::IteratorPrototype +typedef bJSC__JSInternalPromise JSC__JSInternalPromise; // JSC::JSInternalPromise +typedef struct JSC__FunctionPrototype JSC__FunctionPrototype; // JSC::FunctionPrototype +typedef bInspector__ScriptArguments Inspector__ScriptArguments; // Inspector::ScriptArguments +typedef bJSC__Exception JSC__Exception; // JSC::Exception +typedef bJSC__JSString JSC__JSString; // JSC::JSString +typedef struct JSC__ObjectPrototype JSC__ObjectPrototype; // JSC::ObjectPrototype +typedef bJSC__CallFrame JSC__CallFrame; // JSC::CallFrame +typedef struct JSC__MapIteratorPrototype JSC__MapIteratorPrototype; // JSC::MapIteratorPrototype #endif #ifdef __cplusplus - namespace JSC { - class JSCell; - class Exception; - class StringPrototype; - class JSPromisePrototype; - class GeneratorFunctionPrototype; - class ArrayPrototype; - class JSString; - class JSObject; - class AsyncIteratorPrototype; - class AsyncGeneratorFunctionPrototype; - class Identifier; - class JSPromise; - class RegExpPrototype; - class AsyncFunctionPrototype; - class CatchScope; - class VM; - class BigIntPrototype; - class SetIteratorPrototype; - class ThrowScope; - class SourceOrigin; - class AsyncGeneratorPrototype; - class PropertyName; - class MapIteratorPrototype; - class JSModuleRecord; - class JSInternalPromise; - class ArrayIteratorPrototype; - class JSFunction; - class JSModuleLoader; - class GeneratorPrototype; - class JSGlobalObject; - class SourceCode; - class JSLock; - class FunctionPrototype; - class IteratorPrototype; - class CallFrame; - class ObjectPrototype; - } - namespace WTF { - class URL; - class StringImpl; - class String; - class StringView; - class ExternalStringImpl; - } - namespace Inspector { - class ScriptArguments; - } - - typedef ErrorableZigString ErrorableZigString; - typedef JSClassRef JSClassRef; - typedef int64_t JSC__JSValue; - using JSC__JSCell = JSC::JSCell; - using JSC__Exception = JSC::Exception; - using JSC__StringPrototype = JSC::StringPrototype; - using JSC__JSPromisePrototype = JSC::JSPromisePrototype; - using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype; - using JSC__ArrayPrototype = JSC::ArrayPrototype; - using JSC__JSString = JSC::JSString; - using JSC__JSObject = JSC::JSObject; - using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype; - using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype; - using JSC__Identifier = JSC::Identifier; - using JSC__JSPromise = JSC::JSPromise; - using JSC__RegExpPrototype = JSC::RegExpPrototype; - using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype; - using JSC__CatchScope = JSC::CatchScope; - using JSC__VM = JSC::VM; - using JSC__BigIntPrototype = JSC::BigIntPrototype; - using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype; - using JSC__ThrowScope = JSC::ThrowScope; - using JSC__SourceOrigin = JSC::SourceOrigin; - using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; - using JSC__PropertyName = JSC::PropertyName; - using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; - using JSC__JSModuleRecord = JSC::JSModuleRecord; - using JSC__JSInternalPromise = JSC::JSInternalPromise; - using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype; - using JSC__JSFunction = JSC::JSFunction; - using JSC__JSModuleLoader = JSC::JSModuleLoader; - using JSC__GeneratorPrototype = JSC::GeneratorPrototype; - using JSC__JSGlobalObject = JSC::JSGlobalObject; - using JSC__SourceCode = JSC::SourceCode; - using JSC__JSLock = JSC::JSLock; - using JSC__FunctionPrototype = JSC::FunctionPrototype; - using JSC__IteratorPrototype = JSC::IteratorPrototype; - using JSC__CallFrame = JSC::CallFrame; - using JSC__ObjectPrototype = JSC::ObjectPrototype; - using WTF__URL = WTF::URL; - using WTF__StringImpl = WTF::StringImpl; - using WTF__String = WTF::String; - using WTF__StringView = WTF::StringView; - using WTF__ExternalStringImpl = WTF::ExternalStringImpl; - using Inspector__ScriptArguments = Inspector::ScriptArguments; +namespace JSC { +class JSCell; +class Exception; +class StringPrototype; +class JSPromisePrototype; +class GeneratorFunctionPrototype; +class ArrayPrototype; +class JSString; +class JSObject; +class AsyncIteratorPrototype; +class AsyncGeneratorFunctionPrototype; +class Identifier; +class JSPromise; +class RegExpPrototype; +class AsyncFunctionPrototype; +class CatchScope; +class VM; +class BigIntPrototype; +class SetIteratorPrototype; +class ThrowScope; +class SourceOrigin; +class AsyncGeneratorPrototype; +class PropertyName; +class MapIteratorPrototype; +class JSModuleRecord; +class JSInternalPromise; +class ArrayIteratorPrototype; +class JSFunction; +class JSModuleLoader; +class GeneratorPrototype; +class JSGlobalObject; +class SourceCode; +class JSLock; +class FunctionPrototype; +class IteratorPrototype; +class CallFrame; +class ObjectPrototype; +} // namespace JSC +namespace WTF { +class URL; +class StringImpl; +class String; +class StringView; +class ExternalStringImpl; +} // namespace WTF +namespace Inspector { +class ScriptArguments; +} + +typedef ErrorableResolvedSource ErrorableResolvedSource; +typedef ErrorableZigString ErrorableZigString; +typedef JSClassRef JSClassRef; +typedef ZigException ZigException; +typedef int64_t JSC__JSValue; +using JSC__JSCell = JSC::JSCell; +using JSC__Exception = JSC::Exception; +using JSC__StringPrototype = JSC::StringPrototype; +using JSC__JSPromisePrototype = JSC::JSPromisePrototype; +using JSC__GeneratorFunctionPrototype = JSC::GeneratorFunctionPrototype; +using JSC__ArrayPrototype = JSC::ArrayPrototype; +using JSC__JSString = JSC::JSString; +using JSC__JSObject = JSC::JSObject; +using JSC__AsyncIteratorPrototype = JSC::AsyncIteratorPrototype; +using JSC__AsyncGeneratorFunctionPrototype = JSC::AsyncGeneratorFunctionPrototype; +using JSC__Identifier = JSC::Identifier; +using JSC__JSPromise = JSC::JSPromise; +using JSC__RegExpPrototype = JSC::RegExpPrototype; +using JSC__AsyncFunctionPrototype = JSC::AsyncFunctionPrototype; +using JSC__CatchScope = JSC::CatchScope; +using JSC__VM = JSC::VM; +using JSC__BigIntPrototype = JSC::BigIntPrototype; +using JSC__SetIteratorPrototype = JSC::SetIteratorPrototype; +using JSC__ThrowScope = JSC::ThrowScope; +using JSC__SourceOrigin = JSC::SourceOrigin; +using JSC__AsyncGeneratorPrototype = JSC::AsyncGeneratorPrototype; +using JSC__PropertyName = JSC::PropertyName; +using JSC__MapIteratorPrototype = JSC::MapIteratorPrototype; +using JSC__JSModuleRecord = JSC::JSModuleRecord; +using JSC__JSInternalPromise = JSC::JSInternalPromise; +using JSC__ArrayIteratorPrototype = JSC::ArrayIteratorPrototype; +using JSC__JSFunction = JSC::JSFunction; +using JSC__JSModuleLoader = JSC::JSModuleLoader; +using JSC__GeneratorPrototype = JSC::GeneratorPrototype; +using JSC__JSGlobalObject = JSC::JSGlobalObject; +using JSC__SourceCode = JSC::SourceCode; +using JSC__JSLock = JSC::JSLock; +using JSC__FunctionPrototype = JSC::FunctionPrototype; +using JSC__IteratorPrototype = JSC::IteratorPrototype; +using JSC__CallFrame = JSC::CallFrame; +using JSC__ObjectPrototype = JSC::ObjectPrototype; +using WTF__URL = WTF::URL; +using WTF__StringImpl = WTF::StringImpl; +using WTF__String = WTF::String; +using WTF__StringView = WTF::StringView; +using WTF__ExternalStringImpl = WTF::ExternalStringImpl; +using Inspector__ScriptArguments = Inspector::ScriptArguments; #endif - #pragma mark - JSC::JSObject -CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject* arg0); -CPP_DECL JSC__JSValue JSC__JSObject__getAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); -CPP_DECL bool JSC__JSObject__putAtIndex(JSC__JSObject* arg0, JSC__JSGlobalObject* arg1, JSC__PropertyName* arg2, uint32_t arg3); +CPP_DECL size_t JSC__JSObject__getArrayLength(JSC__JSObject *arg0); +CPP_DECL JSC__JSValue JSC__JSObject__getAtIndex(JSC__JSObject *arg0, JSC__JSGlobalObject *arg1, + JSC__PropertyName *arg2, uint32_t arg3); +CPP_DECL bool JSC__JSObject__putAtIndex(JSC__JSObject *arg0, JSC__JSGlobalObject *arg1, + JSC__PropertyName *arg2, uint32_t arg3); #pragma mark - JSC::JSCell -CPP_DECL JSC__JSObject* JSC__JSCell__getObject(JSC__JSCell* arg0); -CPP_DECL bWTF__String JSC__JSCell__getString(JSC__JSCell* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL unsigned char JSC__JSCell__getType(JSC__JSCell* arg0); +CPP_DECL JSC__JSObject *JSC__JSCell__getObject(JSC__JSCell *arg0); +CPP_DECL bWTF__String JSC__JSCell__getString(JSC__JSCell *arg0, JSC__JSGlobalObject *arg1); +CPP_DECL unsigned char JSC__JSCell__getType(JSC__JSCell *arg0); #pragma mark - JSC::JSString -CPP_DECL JSC__JSString* JSC__JSString__createFromOwnedString(JSC__VM* arg0, const WTF__String* arg1); -CPP_DECL JSC__JSString* JSC__JSString__createFromString(JSC__VM* arg0, const WTF__String* arg1); -CPP_DECL bool JSC__JSString__eql(const JSC__JSString* arg0, JSC__JSGlobalObject* arg1, JSC__JSString* arg2); -CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString* arg0); -CPP_DECL size_t JSC__JSString__length(const JSC__JSString* arg0); -CPP_DECL JSC__JSObject* JSC__JSString__toObject(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL bWTF__String JSC__JSString__value(JSC__JSString* arg0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSString *JSC__JSString__createFromOwnedString(JSC__VM *arg0, + const WTF__String *arg1); +CPP_DECL JSC__JSString *JSC__JSString__createFromString(JSC__VM *arg0, const WTF__String *arg1); +CPP_DECL bool JSC__JSString__eql(const JSC__JSString *arg0, JSC__JSGlobalObject *arg1, + JSC__JSString *arg2); +CPP_DECL bool JSC__JSString__is8Bit(const JSC__JSString *arg0); +CPP_DECL size_t JSC__JSString__length(const JSC__JSString *arg0); +CPP_DECL JSC__JSObject *JSC__JSString__toObject(JSC__JSString *arg0, JSC__JSGlobalObject *arg1); +CPP_DECL bWTF__String JSC__JSString__value(JSC__JSString *arg0, JSC__JSGlobalObject *arg1); #pragma mark - Inspector::ScriptArguments -CPP_DECL JSC__JSValue Inspector__ScriptArguments__argumentAt(Inspector__ScriptArguments* arg0, size_t arg1); -CPP_DECL size_t Inspector__ScriptArguments__argumentCount(Inspector__ScriptArguments* arg0); -CPP_DECL bWTF__String Inspector__ScriptArguments__getFirstArgumentAsString(Inspector__ScriptArguments* arg0); -CPP_DECL bool Inspector__ScriptArguments__isEqual(Inspector__ScriptArguments* arg0, Inspector__ScriptArguments* arg1); -CPP_DECL void Inspector__ScriptArguments__release(Inspector__ScriptArguments* arg0); +CPP_DECL JSC__JSValue Inspector__ScriptArguments__argumentAt(Inspector__ScriptArguments *arg0, + size_t arg1); +CPP_DECL size_t Inspector__ScriptArguments__argumentCount(Inspector__ScriptArguments *arg0); +CPP_DECL bWTF__String +Inspector__ScriptArguments__getFirstArgumentAsString(Inspector__ScriptArguments *arg0); +CPP_DECL bool Inspector__ScriptArguments__isEqual(Inspector__ScriptArguments *arg0, + Inspector__ScriptArguments *arg1); +CPP_DECL void Inspector__ScriptArguments__release(Inspector__ScriptArguments *arg0); #pragma mark - JSC::JSModuleLoader -CPP_DECL bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1, bool arg2); -CPP_DECL JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject* arg0, const unsigned char* arg1, size_t arg2, const unsigned char* arg3, size_t arg4, JSC__JSValue JSValue5, JSC__JSValue* arg6); -CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__importModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1); -CPP_DECL JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject* arg0, const JSC__Identifier* arg1); -CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject* arg0, ZigString arg1); -CPP_DECL JSC__JSInternalPromise* JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject* arg0, const JSC__SourceCode* arg1); +CPP_DECL bool JSC__JSModuleLoader__checkSyntax(JSC__JSGlobalObject *arg0, + const JSC__SourceCode *arg1, bool arg2); +CPP_DECL JSC__JSValue JSC__JSModuleLoader__evaluate(JSC__JSGlobalObject *arg0, + const unsigned char *arg1, size_t arg2, + const unsigned char *arg3, size_t arg4, + JSC__JSValue JSValue5, JSC__JSValue *arg6); +CPP_DECL JSC__JSInternalPromise *JSC__JSModuleLoader__importModule(JSC__JSGlobalObject *arg0, + const JSC__Identifier *arg1); +CPP_DECL JSC__JSValue JSC__JSModuleLoader__linkAndEvaluateModule(JSC__JSGlobalObject *arg0, + const JSC__Identifier *arg1); +CPP_DECL JSC__JSInternalPromise * +JSC__JSModuleLoader__loadAndEvaluateModule(JSC__JSGlobalObject *arg0, ZigString arg1); +CPP_DECL JSC__JSInternalPromise * +JSC__JSModuleLoader__loadAndEvaluateModuleEntryPoint(JSC__JSGlobalObject *arg0, + const JSC__SourceCode *arg1); #pragma mark - JSC::JSModuleRecord -CPP_DECL bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord* arg0); +CPP_DECL bJSC__SourceCode JSC__JSModuleRecord__sourceCode(JSC__JSModuleRecord *arg0); #pragma mark - JSC::JSPromise -CPP_DECL bool JSC__JSPromise__isHandled(const JSC__JSPromise* arg0, JSC__VM* arg1); -CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); -CPP_DECL JSC__JSPromise* JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); -CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2); -CPP_DECL void JSC__JSPromise__resolve(JSC__JSPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL JSC__JSPromise* JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); -CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise* arg0, JSC__VM* arg1); -CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise* arg0, JSC__VM* arg1); +CPP_DECL bool JSC__JSPromise__isHandled(const JSC__JSPromise *arg0, JSC__VM *arg1); +CPP_DECL void JSC__JSPromise__reject(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2); +CPP_DECL void JSC__JSPromise__rejectAsHandled(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2); +CPP_DECL void JSC__JSPromise__rejectAsHandledException(JSC__JSPromise *arg0, + JSC__JSGlobalObject *arg1, + JSC__Exception *arg2); +CPP_DECL JSC__JSPromise *JSC__JSPromise__rejectedPromise(JSC__JSGlobalObject *arg0, + JSC__JSValue JSValue1); +CPP_DECL void JSC__JSPromise__rejectWithCaughtException(JSC__JSPromise *arg0, + JSC__JSGlobalObject *arg1, + bJSC__ThrowScope arg2); +CPP_DECL void JSC__JSPromise__resolve(JSC__JSPromise *arg0, JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2); +CPP_DECL JSC__JSPromise *JSC__JSPromise__resolvedPromise(JSC__JSGlobalObject *arg0, + JSC__JSValue JSValue1); +CPP_DECL JSC__JSValue JSC__JSPromise__result(const JSC__JSPromise *arg0, JSC__VM *arg1); +CPP_DECL uint32_t JSC__JSPromise__status(const JSC__JSPromise *arg0, JSC__VM *arg1); #pragma mark - JSC::JSInternalPromise -CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__create(JSC__JSGlobalObject* arg0); -CPP_DECL bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); -CPP_DECL void JSC__JSInternalPromise__reject(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__Exception* arg2); -CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); -CPP_DECL void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, bJSC__ThrowScope arg2); -CPP_DECL void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2); -CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject* arg0, JSC__JSValue JSValue1); -CPP_DECL JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); -CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise* arg0, JSC__VM* arg1); -CPP_DECL JSC__JSInternalPromise* JSC__JSInternalPromise__then(JSC__JSInternalPromise* arg0, JSC__JSGlobalObject* arg1, JSC__JSFunction* arg2, JSC__JSFunction* arg3); +CPP_DECL JSC__JSInternalPromise *JSC__JSInternalPromise__create(JSC__JSGlobalObject *arg0); +CPP_DECL bool JSC__JSInternalPromise__isHandled(const JSC__JSInternalPromise *arg0, JSC__VM *arg1); +CPP_DECL void JSC__JSInternalPromise__reject(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, JSC__JSValue JSValue2); +CPP_DECL void JSC__JSInternalPromise__rejectAsHandled(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2); +CPP_DECL void JSC__JSInternalPromise__rejectAsHandledException(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, + JSC__Exception *arg2); +CPP_DECL JSC__JSInternalPromise *JSC__JSInternalPromise__rejectedPromise(JSC__JSGlobalObject *arg0, + JSC__JSValue JSValue1); +CPP_DECL void JSC__JSInternalPromise__rejectWithCaughtException(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, + bJSC__ThrowScope arg2); +CPP_DECL void JSC__JSInternalPromise__resolve(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, JSC__JSValue JSValue2); +CPP_DECL JSC__JSInternalPromise *JSC__JSInternalPromise__resolvedPromise(JSC__JSGlobalObject *arg0, + JSC__JSValue JSValue1); +CPP_DECL JSC__JSValue JSC__JSInternalPromise__result(const JSC__JSInternalPromise *arg0, + JSC__VM *arg1); +CPP_DECL uint32_t JSC__JSInternalPromise__status(const JSC__JSInternalPromise *arg0, JSC__VM *arg1); +CPP_DECL JSC__JSInternalPromise *JSC__JSInternalPromise__then(JSC__JSInternalPromise *arg0, + JSC__JSGlobalObject *arg1, + JSC__JSFunction *arg2, + JSC__JSFunction *arg3); #pragma mark - JSC::SourceOrigin -CPP_DECL bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL* arg0); +CPP_DECL bJSC__SourceOrigin JSC__SourceOrigin__fromURL(const WTF__URL *arg0); #pragma mark - JSC::SourceCode -CPP_DECL void JSC__SourceCode__fromString(JSC__SourceCode* arg0, const WTF__String* arg1, const JSC__SourceOrigin* arg2, WTF__String* arg3, unsigned char SourceType4); +CPP_DECL void JSC__SourceCode__fromString(JSC__SourceCode *arg0, const WTF__String *arg1, + const JSC__SourceOrigin *arg2, WTF__String *arg3, + unsigned char SourceType4); #pragma mark - JSC::JSFunction -CPP_DECL bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction* arg0, JSC__VM* arg1); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3); -CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue* arg2, size_t arg3, JSC__Exception** arg4, const char* arg5); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget(JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject* arg2, JSC__JSValue* arg3, size_t arg4, JSC__Exception** arg5, const char* arg6); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__JSValue JSValue2, JSC__Exception** arg3, const char* arg4); -CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1, JSC__Exception** arg2, const char* arg3); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromNative(JSC__JSGlobalObject* arg0, uint16_t arg1, const WTF__String* arg2, void* arg3, JSC__JSValue (* ArgFn4)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2)); -CPP_DECL JSC__JSFunction* JSC__JSFunction__createFromSourceCode(JSC__JSGlobalObject* arg0, const unsigned char* arg1, uint16_t arg2, JSC__JSValue* arg3, uint16_t arg4, const JSC__SourceCode* arg5, JSC__SourceOrigin* arg6, JSC__JSObject** arg7); -CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction* arg0, JSC__VM* arg1); -CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction* arg0, JSC__VM* arg1); +CPP_DECL bWTF__String JSC__JSFunction__calculatedDisplayName(JSC__JSFunction *arg0, JSC__VM *arg1); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArguments(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1, + JSC__JSValue *arg2, size_t arg3, + JSC__Exception **arg4, const char *arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithArgumentsAndThis( + JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject *arg2, JSC__JSValue *arg3, + size_t arg4, JSC__Exception **arg5, const char *arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithoutAnyArgumentsOrThis(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1, + JSC__Exception **arg2, + const char *arg3); +CPP_DECL JSC__JSValue JSC__JSFunction__callWithThis(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2, JSC__Exception **arg3, + const char *arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArguments(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1, + JSC__JSValue *arg2, size_t arg3, + JSC__Exception **arg4, + const char *arg5); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithArgumentsAndNewTarget( + JSC__JSValue JSValue0, JSC__JSValue JSValue1, JSC__JSGlobalObject *arg2, JSC__JSValue *arg3, + size_t arg4, JSC__Exception **arg5, const char *arg6); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithNewTarget(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1, + JSC__JSValue JSValue2, + JSC__Exception **arg3, + const char *arg4); +CPP_DECL JSC__JSValue JSC__JSFunction__constructWithoutAnyArgumentsOrNewTarget( + JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1, JSC__Exception **arg2, const char *arg3); +CPP_DECL JSC__JSFunction *JSC__JSFunction__createFromNative( + JSC__JSGlobalObject *arg0, uint16_t arg1, const WTF__String *arg2, void *arg3, + JSC__JSValue (*ArgFn4)(void *arg0, JSC__JSGlobalObject *arg1, JSC__CallFrame *arg2)); +CPP_DECL JSC__JSFunction *JSC__JSFunction__createFromSourceCode( + JSC__JSGlobalObject *arg0, const unsigned char *arg1, uint16_t arg2, JSC__JSValue *arg3, + uint16_t arg4, const JSC__SourceCode *arg5, JSC__SourceOrigin *arg6, JSC__JSObject **arg7); +CPP_DECL bWTF__String JSC__JSFunction__displayName(JSC__JSFunction *arg0, JSC__VM *arg1); +CPP_DECL bWTF__String JSC__JSFunction__getName(JSC__JSFunction *arg0, JSC__VM *arg1); #pragma mark - JSC::JSGlobalObject -CPP_DECL JSC__ArrayIteratorPrototype* JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__ArrayPrototype* JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__AsyncFunctionPrototype* JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__AsyncGeneratorFunctionPrototype* JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__AsyncGeneratorPrototype* JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__AsyncIteratorPrototype* JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__BigIntPrototype* JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__FunctionPrototype* JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__GeneratorFunctionPrototype* JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__GeneratorPrototype* JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__IteratorPrototype* JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__MapIteratorPrototype* JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__ObjectPrototype* JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSPromisePrototype* JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__RegExpPrototype* JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__SetIteratorPrototype* JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__StringPrototype* JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__JSObject* JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject* arg0); -CPP_DECL JSC__VM* JSC__JSGlobalObject__vm(JSC__JSGlobalObject* arg0); +CPP_DECL JSC__ArrayIteratorPrototype * +JSC__JSGlobalObject__arrayIteratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__ArrayPrototype *JSC__JSGlobalObject__arrayPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__AsyncFunctionPrototype * +JSC__JSGlobalObject__asyncFunctionPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__AsyncGeneratorFunctionPrototype * +JSC__JSGlobalObject__asyncGeneratorFunctionPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__AsyncGeneratorPrototype * +JSC__JSGlobalObject__asyncGeneratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__AsyncIteratorPrototype * +JSC__JSGlobalObject__asyncIteratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__BigIntPrototype *JSC__JSGlobalObject__bigIntPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__booleanPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__datePrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__errorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__FunctionPrototype *JSC__JSGlobalObject__functionPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__GeneratorFunctionPrototype * +JSC__JSGlobalObject__generatorFunctionPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__GeneratorPrototype * +JSC__JSGlobalObject__generatorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__IteratorPrototype *JSC__JSGlobalObject__iteratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__jsSetPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__MapIteratorPrototype * +JSC__JSGlobalObject__mapIteratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__mapPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__numberPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__ObjectPrototype *JSC__JSGlobalObject__objectPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSPromisePrototype *JSC__JSGlobalObject__promisePrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__RegExpPrototype *JSC__JSGlobalObject__regExpPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__SetIteratorPrototype * +JSC__JSGlobalObject__setIteratorPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__StringPrototype *JSC__JSGlobalObject__stringPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__JSObject *JSC__JSGlobalObject__symbolPrototype(JSC__JSGlobalObject *arg0); +CPP_DECL JSC__VM *JSC__JSGlobalObject__vm(JSC__JSGlobalObject *arg0); #pragma mark - WTF::URL -CPP_DECL bWTF__StringView WTF__URL__encodedPassword(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__encodedUser(WTF__URL* arg0); -CPP_DECL bWTF__String WTF__URL__fileSystemPath(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL* arg0); -CPP_DECL void WTF__URL__fromFileSystemPath(WTF__URL* arg0, bWTF__StringView arg1); +CPP_DECL bWTF__StringView WTF__URL__encodedPassword(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__encodedUser(WTF__URL *arg0); +CPP_DECL bWTF__String WTF__URL__fileSystemPath(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifier(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__fragmentIdentifierWithLeadingNumberSign(WTF__URL *arg0); +CPP_DECL void WTF__URL__fromFileSystemPath(WTF__URL *arg0, bWTF__StringView arg1); CPP_DECL bWTF__URL WTF__URL__fromString(bWTF__String arg0, bWTF__String arg1); -CPP_DECL bWTF__StringView WTF__URL__host(WTF__URL* arg0); -CPP_DECL bWTF__String WTF__URL__hostAndPort(WTF__URL* arg0); -CPP_DECL bool WTF__URL__isEmpty(const WTF__URL* arg0); -CPP_DECL bool WTF__URL__isValid(const WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__lastPathComponent(WTF__URL* arg0); -CPP_DECL bWTF__String WTF__URL__password(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__path(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__protocol(WTF__URL* arg0); -CPP_DECL bWTF__String WTF__URL__protocolHostAndPort(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__query(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL* arg0); -CPP_DECL void WTF__URL__setHost(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setHostAndPort(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setPassword(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setPath(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setProtocol(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setQuery(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL void WTF__URL__setUser(WTF__URL* arg0, bWTF__StringView arg1); -CPP_DECL bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL* arg0); -CPP_DECL bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL* arg0); -CPP_DECL bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL* arg0); -CPP_DECL bWTF__String WTF__URL__user(WTF__URL* arg0); +CPP_DECL bWTF__StringView WTF__URL__host(WTF__URL *arg0); +CPP_DECL bWTF__String WTF__URL__hostAndPort(WTF__URL *arg0); +CPP_DECL bool WTF__URL__isEmpty(const WTF__URL *arg0); +CPP_DECL bool WTF__URL__isValid(const WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__lastPathComponent(WTF__URL *arg0); +CPP_DECL bWTF__String WTF__URL__password(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__path(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__protocol(WTF__URL *arg0); +CPP_DECL bWTF__String WTF__URL__protocolHostAndPort(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__query(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__queryWithLeadingQuestionMark(WTF__URL *arg0); +CPP_DECL void WTF__URL__setHost(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setHostAndPort(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setPassword(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setPath(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setProtocol(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setQuery(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL void WTF__URL__setUser(WTF__URL *arg0, bWTF__StringView arg1); +CPP_DECL bWTF__String WTF__URL__stringWithoutFragmentIdentifier(WTF__URL *arg0); +CPP_DECL bWTF__StringView WTF__URL__stringWithoutQueryOrFragmentIdentifier(WTF__URL *arg0); +CPP_DECL bWTF__URL WTF__URL__truncatedForUseAsBase(WTF__URL *arg0); +CPP_DECL bWTF__String WTF__URL__user(WTF__URL *arg0); #pragma mark - WTF::String -CPP_DECL const uint16_t* WTF__String__characters16(WTF__String* arg0); -CPP_DECL const unsigned char* WTF__String__characters8(WTF__String* arg0); +CPP_DECL const uint16_t *WTF__String__characters16(WTF__String *arg0); +CPP_DECL const unsigned char *WTF__String__characters8(WTF__String *arg0); CPP_DECL bWTF__String WTF__String__createFromExternalString(bWTF__ExternalStringImpl arg0); -CPP_DECL void WTF__String__createWithoutCopyingFromPtr(WTF__String* arg0, const unsigned char* arg1, size_t arg2); -CPP_DECL bool WTF__String__eqlSlice(WTF__String* arg0, const unsigned char* arg1, size_t arg2); -CPP_DECL bool WTF__String__eqlString(WTF__String* arg0, const WTF__String* arg1); -CPP_DECL const WTF__StringImpl* WTF__String__impl(WTF__String* arg0); -CPP_DECL bool WTF__String__is16Bit(WTF__String* arg0); -CPP_DECL bool WTF__String__is8Bit(WTF__String* arg0); -CPP_DECL bool WTF__String__isEmpty(WTF__String* arg0); -CPP_DECL bool WTF__String__isExternal(WTF__String* arg0); -CPP_DECL bool WTF__String__isStatic(WTF__String* arg0); -CPP_DECL size_t WTF__String__length(WTF__String* arg0); +CPP_DECL void WTF__String__createWithoutCopyingFromPtr(WTF__String *arg0, const unsigned char *arg1, + size_t arg2); +CPP_DECL bool WTF__String__eqlSlice(WTF__String *arg0, const unsigned char *arg1, size_t arg2); +CPP_DECL bool WTF__String__eqlString(WTF__String *arg0, const WTF__String *arg1); +CPP_DECL const WTF__StringImpl *WTF__String__impl(WTF__String *arg0); +CPP_DECL bool WTF__String__is16Bit(WTF__String *arg0); +CPP_DECL bool WTF__String__is8Bit(WTF__String *arg0); +CPP_DECL bool WTF__String__isEmpty(WTF__String *arg0); +CPP_DECL bool WTF__String__isExternal(WTF__String *arg0); +CPP_DECL bool WTF__String__isStatic(WTF__String *arg0); +CPP_DECL size_t WTF__String__length(WTF__String *arg0); #pragma mark - JSC::JSValue -CPP_DECL JSC__JSCell* JSC__JSValue__asCell(JSC__JSValue JSValue0); +CPP_DECL JSC__JSCell *JSC__JSValue__asCell(JSC__JSValue JSValue0); CPP_DECL double JSC__JSValue__asNumber(JSC__JSValue JSValue0); CPP_DECL bJSC__JSObject JSC__JSValue__asObject(JSC__JSValue JSValue0); -CPP_DECL JSC__JSString* JSC__JSValue__asString(JSC__JSValue JSValue0); -CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell* arg1); +CPP_DECL JSC__JSString *JSC__JSValue__asString(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__eqlCell(JSC__JSValue JSValue0, JSC__JSCell *arg1); CPP_DECL bool JSC__JSValue__eqlValue(JSC__JSValue JSValue0, JSC__JSValue JSValue1); -CPP_DECL JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSValue JSC__JSValue__getPrototype(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1); CPP_DECL bool JSC__JSValue__isAnyInt(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isBigInt(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isBigInt32(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isBoolean(JSC__JSValue JSValue0); -CPP_DECL bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM* arg1); +CPP_DECL bool JSC__JSValue__isCallable(JSC__JSValue JSValue0, JSC__VM *arg1); CPP_DECL bool JSC__JSValue__isCell(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isCustomGetterSetter(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isError(JSC__JSValue JSValue0); +CPP_DECL bool JSC__JSValue__isException(JSC__JSValue JSValue0, JSC__VM *arg1); CPP_DECL bool JSC__JSValue__isGetterSetter(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isHeapBigInt(JSC__JSValue JSValue0); CPP_DECL bool JSC__JSValue__isInt32AsAnyInt(JSC__JSValue JSValue0); @@ -432,141 +613,184 @@ CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromU16(uint16_t arg0); CPP_DECL JSC__JSValue JSC__JSValue__jsNumberFromUint64(uint64_t arg0); CPP_DECL JSC__JSValue JSC__JSValue__jsTDZValue(); CPP_DECL JSC__JSValue JSC__JSValue__jsUndefined(); -CPP_DECL JSC__JSObject* JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL JSC__JSString* JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL JSC__JSString* JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); -CPP_DECL bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject* arg1); +CPP_DECL JSC__JSObject *JSC__JSValue__toObject(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1); +CPP_DECL bJSC__Identifier JSC__JSValue__toPropertyKey(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1); +CPP_DECL JSC__JSValue JSC__JSValue__toPropertyKeyValue(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1); +CPP_DECL JSC__JSString *JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1); +CPP_DECL JSC__JSString *JSC__JSValue__toString(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1); +CPP_DECL JSC__JSString *JSC__JSValue__toStringOrNull(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1); +CPP_DECL bWTF__String JSC__JSValue__toWTFString(JSC__JSValue JSValue0, JSC__JSGlobalObject *arg1); +CPP_DECL ZigException JSC__JSValue__toZigException(JSC__JSValue JSValue0, + JSC__JSGlobalObject *arg1); #pragma mark - JSC::PropertyName -CPP_DECL bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName* arg0, const JSC__Identifier* arg1); -CPP_DECL bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName* arg0, const JSC__PropertyName* arg1); -CPP_DECL const WTF__StringImpl* JSC__PropertyName__publicName(JSC__PropertyName* arg0); -CPP_DECL const WTF__StringImpl* JSC__PropertyName__uid(JSC__PropertyName* arg0); +CPP_DECL bool JSC__PropertyName__eqlToIdentifier(JSC__PropertyName *arg0, + const JSC__Identifier *arg1); +CPP_DECL bool JSC__PropertyName__eqlToPropertyName(JSC__PropertyName *arg0, + const JSC__PropertyName *arg1); +CPP_DECL const WTF__StringImpl *JSC__PropertyName__publicName(JSC__PropertyName *arg0); +CPP_DECL const WTF__StringImpl *JSC__PropertyName__uid(JSC__PropertyName *arg0); #pragma mark - JSC::Exception -CPP_DECL JSC__Exception* JSC__Exception__create(JSC__JSGlobalObject* arg0, JSC__JSObject* arg1, unsigned char StackCaptureAction2); +CPP_DECL JSC__Exception *JSC__Exception__create(JSC__JSGlobalObject *arg0, JSC__JSObject *arg1, + unsigned char StackCaptureAction2); #pragma mark - JSC::VM -CPP_DECL JSC__JSLock* JSC__VM__apiLock(JSC__VM* arg0); -CPP_DECL JSC__VM* JSC__VM__create(unsigned char HeapType0); -CPP_DECL void JSC__VM__deinit(JSC__VM* arg0, JSC__JSGlobalObject* arg1); -CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0); -CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0); -CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0); -CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1); -CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4); +CPP_DECL JSC__JSLock *JSC__VM__apiLock(JSC__VM *arg0); +CPP_DECL JSC__VM *JSC__VM__create(unsigned char HeapType0); +CPP_DECL void JSC__VM__deinit(JSC__VM *arg0, JSC__JSGlobalObject *arg1); +CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM *arg0); +CPP_DECL bool JSC__VM__executionForbidden(JSC__VM *arg0); +CPP_DECL bool JSC__VM__isEntered(JSC__VM *arg0); +CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM *arg0, bool arg1); +CPP_DECL bool JSC__VM__throwError(JSC__VM *arg0, JSC__JSGlobalObject *arg1, JSC__ThrowScope *arg2, + const unsigned char *arg3, size_t arg4); #pragma mark - JSC::ThrowScope -CPP_DECL void JSC__ThrowScope__clearException(JSC__ThrowScope* arg0); -CPP_DECL bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3); -CPP_DECL JSC__Exception* JSC__ThrowScope__exception(JSC__ThrowScope* arg0); -CPP_DECL void JSC__ThrowScope__release(JSC__ThrowScope* arg0); +CPP_DECL void JSC__ThrowScope__clearException(JSC__ThrowScope *arg0); +CPP_DECL bJSC__ThrowScope JSC__ThrowScope__declare(JSC__VM *arg0, unsigned char *arg1, + unsigned char *arg2, size_t arg3); +CPP_DECL JSC__Exception *JSC__ThrowScope__exception(JSC__ThrowScope *arg0); +CPP_DECL void JSC__ThrowScope__release(JSC__ThrowScope *arg0); #pragma mark - JSC::CatchScope -CPP_DECL void JSC__CatchScope__clearException(JSC__CatchScope* arg0); -CPP_DECL bJSC__CatchScope JSC__CatchScope__declare(JSC__VM* arg0, unsigned char* arg1, unsigned char* arg2, size_t arg3); -CPP_DECL JSC__Exception* JSC__CatchScope__exception(JSC__CatchScope* arg0); +CPP_DECL void JSC__CatchScope__clearException(JSC__CatchScope *arg0); +CPP_DECL bJSC__CatchScope JSC__CatchScope__declare(JSC__VM *arg0, unsigned char *arg1, + unsigned char *arg2, size_t arg3); +CPP_DECL JSC__Exception *JSC__CatchScope__exception(JSC__CatchScope *arg0); #pragma mark - JSC::CallFrame -CPP_DECL JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame* arg0, uint16_t arg1); -CPP_DECL size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame* arg0); -CPP_DECL JSC__JSObject* JSC__CallFrame__jsCallee(const JSC__CallFrame* arg0); -CPP_DECL JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame* arg0); -CPP_DECL JSC__JSValue JSC__CallFrame__setNewTarget(JSC__CallFrame* arg0, JSC__JSValue JSValue1); -CPP_DECL JSC__JSValue JSC__CallFrame__setThisValue(JSC__CallFrame* arg0, JSC__JSValue JSValue1); -CPP_DECL JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame* arg0); -CPP_DECL JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame* arg0, uint16_t arg1); +CPP_DECL JSC__JSValue JSC__CallFrame__argument(const JSC__CallFrame *arg0, uint16_t arg1); +CPP_DECL size_t JSC__CallFrame__argumentsCount(const JSC__CallFrame *arg0); +CPP_DECL JSC__JSObject *JSC__CallFrame__jsCallee(const JSC__CallFrame *arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__newTarget(const JSC__CallFrame *arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__setNewTarget(JSC__CallFrame *arg0, JSC__JSValue JSValue1); +CPP_DECL JSC__JSValue JSC__CallFrame__setThisValue(JSC__CallFrame *arg0, JSC__JSValue JSValue1); +CPP_DECL JSC__JSValue JSC__CallFrame__thisValue(const JSC__CallFrame *arg0); +CPP_DECL JSC__JSValue JSC__CallFrame__uncheckedArgument(const JSC__CallFrame *arg0, uint16_t arg1); #pragma mark - JSC::Identifier -CPP_DECL void JSC__Identifier__deinit(const JSC__Identifier* arg0); -CPP_DECL bool JSC__Identifier__eqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1); -CPP_DECL bool JSC__Identifier__eqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1); -CPP_DECL bool JSC__Identifier__eqlUTF8(const JSC__Identifier* arg0, const unsigned char* arg1, size_t arg2); -CPP_DECL bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM* arg0, const unsigned char* arg1, size_t arg2); -CPP_DECL bJSC__Identifier JSC__Identifier__fromString(JSC__VM* arg0, const WTF__String* arg1); -CPP_DECL bool JSC__Identifier__isEmpty(const JSC__Identifier* arg0); -CPP_DECL bool JSC__Identifier__isNull(const JSC__Identifier* arg0); -CPP_DECL bool JSC__Identifier__isPrivateName(const JSC__Identifier* arg0); -CPP_DECL bool JSC__Identifier__isSymbol(const JSC__Identifier* arg0); -CPP_DECL size_t JSC__Identifier__length(const JSC__Identifier* arg0); -CPP_DECL bool JSC__Identifier__neqlIdent(const JSC__Identifier* arg0, const JSC__Identifier* arg1); -CPP_DECL bool JSC__Identifier__neqlStringImpl(const JSC__Identifier* arg0, const WTF__StringImpl* arg1); -CPP_DECL bWTF__String JSC__Identifier__toString(const JSC__Identifier* arg0); +CPP_DECL void JSC__Identifier__deinit(const JSC__Identifier *arg0); +CPP_DECL bool JSC__Identifier__eqlIdent(const JSC__Identifier *arg0, const JSC__Identifier *arg1); +CPP_DECL bool JSC__Identifier__eqlStringImpl(const JSC__Identifier *arg0, + const WTF__StringImpl *arg1); +CPP_DECL bool JSC__Identifier__eqlUTF8(const JSC__Identifier *arg0, const unsigned char *arg1, + size_t arg2); +CPP_DECL bJSC__Identifier JSC__Identifier__fromSlice(JSC__VM *arg0, const unsigned char *arg1, + size_t arg2); +CPP_DECL bJSC__Identifier JSC__Identifier__fromString(JSC__VM *arg0, const WTF__String *arg1); +CPP_DECL bool JSC__Identifier__isEmpty(const JSC__Identifier *arg0); +CPP_DECL bool JSC__Identifier__isNull(const JSC__Identifier *arg0); +CPP_DECL bool JSC__Identifier__isPrivateName(const JSC__Identifier *arg0); +CPP_DECL bool JSC__Identifier__isSymbol(const JSC__Identifier *arg0); +CPP_DECL size_t JSC__Identifier__length(const JSC__Identifier *arg0); +CPP_DECL bool JSC__Identifier__neqlIdent(const JSC__Identifier *arg0, const JSC__Identifier *arg1); +CPP_DECL bool JSC__Identifier__neqlStringImpl(const JSC__Identifier *arg0, + const WTF__StringImpl *arg1); +CPP_DECL bWTF__String JSC__Identifier__toString(const JSC__Identifier *arg0); #pragma mark - WTF::StringImpl -CPP_DECL const uint16_t* WTF__StringImpl__characters16(const WTF__StringImpl* arg0); -CPP_DECL const unsigned char* WTF__StringImpl__characters8(const WTF__StringImpl* arg0); -CPP_DECL bool WTF__StringImpl__is16Bit(const WTF__StringImpl* arg0); -CPP_DECL bool WTF__StringImpl__is8Bit(const WTF__StringImpl* arg0); -CPP_DECL bool WTF__StringImpl__isEmpty(const WTF__StringImpl* arg0); -CPP_DECL bool WTF__StringImpl__isExternal(const WTF__StringImpl* arg0); -CPP_DECL bool WTF__StringImpl__isStatic(const WTF__StringImpl* arg0); -CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl* arg0); +CPP_DECL const uint16_t *WTF__StringImpl__characters16(const WTF__StringImpl *arg0); +CPP_DECL const unsigned char *WTF__StringImpl__characters8(const WTF__StringImpl *arg0); +CPP_DECL bool WTF__StringImpl__is16Bit(const WTF__StringImpl *arg0); +CPP_DECL bool WTF__StringImpl__is8Bit(const WTF__StringImpl *arg0); +CPP_DECL bool WTF__StringImpl__isEmpty(const WTF__StringImpl *arg0); +CPP_DECL bool WTF__StringImpl__isExternal(const WTF__StringImpl *arg0); +CPP_DECL bool WTF__StringImpl__isStatic(const WTF__StringImpl *arg0); +CPP_DECL size_t WTF__StringImpl__length(const WTF__StringImpl *arg0); #pragma mark - WTF::ExternalStringImpl -CPP_DECL const uint16_t* WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl* arg0); -CPP_DECL const unsigned char* WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl* arg0); -CPP_DECL bWTF__ExternalStringImpl WTF__ExternalStringImpl__create(const unsigned char* arg0, size_t arg1, void (* ArgFn2)(void* arg0, unsigned char* arg1, size_t arg2)); -CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl* arg0); -CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl* arg0); -CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl* arg0); -CPP_DECL size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl* arg0); +CPP_DECL const uint16_t *WTF__ExternalStringImpl__characters16(const WTF__ExternalStringImpl *arg0); +CPP_DECL const unsigned char * +WTF__ExternalStringImpl__characters8(const WTF__ExternalStringImpl *arg0); +CPP_DECL bWTF__ExternalStringImpl +WTF__ExternalStringImpl__create(const unsigned char *arg0, size_t arg1, + void (*ArgFn2)(void *arg0, unsigned char *arg1, size_t arg2)); +CPP_DECL bool WTF__ExternalStringImpl__is16Bit(const WTF__ExternalStringImpl *arg0); +CPP_DECL bool WTF__ExternalStringImpl__is8Bit(const WTF__ExternalStringImpl *arg0); +CPP_DECL bool WTF__ExternalStringImpl__isEmpty(const WTF__ExternalStringImpl *arg0); +CPP_DECL size_t WTF__ExternalStringImpl__length(const WTF__ExternalStringImpl *arg0); #pragma mark - WTF::StringView -CPP_DECL const uint16_t* WTF__StringView__characters16(const WTF__StringView* arg0); -CPP_DECL const unsigned char* WTF__StringView__characters8(const WTF__StringView* arg0); -CPP_DECL void WTF__StringView__from8Bit(WTF__StringView* arg0, const unsigned char* arg1, size_t arg2); -CPP_DECL bool WTF__StringView__is16Bit(const WTF__StringView* arg0); -CPP_DECL bool WTF__StringView__is8Bit(const WTF__StringView* arg0); -CPP_DECL bool WTF__StringView__isEmpty(const WTF__StringView* arg0); -CPP_DECL size_t WTF__StringView__length(const WTF__StringView* arg0); +CPP_DECL const uint16_t *WTF__StringView__characters16(const WTF__StringView *arg0); +CPP_DECL const unsigned char *WTF__StringView__characters8(const WTF__StringView *arg0); +CPP_DECL void WTF__StringView__from8Bit(WTF__StringView *arg0, const unsigned char *arg1, + size_t arg2); +CPP_DECL bool WTF__StringView__is16Bit(const WTF__StringView *arg0); +CPP_DECL bool WTF__StringView__is8Bit(const WTF__StringView *arg0); +CPP_DECL bool WTF__StringView__isEmpty(const WTF__StringView *arg0); +CPP_DECL size_t WTF__StringView__length(const WTF__StringView *arg0); #pragma mark - Zig::GlobalObject -CPP_DECL JSC__JSGlobalObject* Zig__GlobalObject__create(JSClassRef* arg0, int32_t arg1, void* arg2); +CPP_DECL JSC__JSGlobalObject *Zig__GlobalObject__create(JSClassRef *arg0, int32_t arg1, void *arg2); #ifdef __cplusplus -ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject* arg0, JSC__JSModuleLoader* arg1, JSC__JSValue JSValue2, JSC__JSModuleRecord* arg3, JSC__JSValue JSValue4); -ZIG_DECL ErrorableZigString Zig__GlobalObject__fetch(JSC__JSGlobalObject* arg0, ZigString arg1, ZigString arg2); -ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject* arg0, ZigString arg1, ZigString arg2); +ZIG_DECL JSC__JSValue Zig__GlobalObject__createImportMetaProperties(JSC__JSGlobalObject *arg0, + JSC__JSModuleLoader *arg1, + JSC__JSValue JSValue2, + JSC__JSModuleRecord *arg3, + JSC__JSValue JSValue4); +ZIG_DECL ErrorableResolvedSource Zig__GlobalObject__fetch(JSC__JSGlobalObject *arg0, ZigString arg1, + ZigString arg2); +ZIG_DECL ErrorableZigString Zig__GlobalObject__import(JSC__JSGlobalObject *arg0, ZigString arg1, + ZigString arg2); ZIG_DECL void Zig__GlobalObject__onCrash(); -ZIG_DECL JSC__JSValue Zig__GlobalObject__promiseRejectionTracker(JSC__JSGlobalObject* arg0, JSC__JSPromise* arg1, uint32_t JSPromiseRejectionOperation2); -ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject* arg0, JSC__Exception* arg1); -ZIG_DECL ErrorableZigString Zig__GlobalObject__resolve(JSC__JSGlobalObject* arg0, ZigString arg1, ZigString arg2); +ZIG_DECL JSC__JSValue Zig__GlobalObject__promiseRejectionTracker( + JSC__JSGlobalObject *arg0, JSC__JSPromise *arg1, uint32_t JSPromiseRejectionOperation2); +ZIG_DECL JSC__JSValue Zig__GlobalObject__reportUncaughtException(JSC__JSGlobalObject *arg0, + JSC__Exception *arg1); +ZIG_DECL ErrorableZigString Zig__GlobalObject__resolve(JSC__JSGlobalObject *arg0, ZigString arg1, + ZigString arg2); #endif +CPP_DECL ZigException ZigException__fromException(JSC__Exception *arg0); #pragma mark - Zig::ConsoleClient - #ifdef __cplusplus -ZIG_DECL void Zig__ConsoleClient__count(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__countReset(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__messageWithTypeAndLevel(void* arg0, uint32_t arg1, uint32_t arg2, JSC__JSGlobalObject* arg3, JSC__JSValue* arg4, size_t arg5); -ZIG_DECL void Zig__ConsoleClient__profile(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__profileEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__record(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); -ZIG_DECL void Zig__ConsoleClient__recordEnd(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); -ZIG_DECL void Zig__ConsoleClient__screenshot(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); -ZIG_DECL void Zig__ConsoleClient__takeHeapSnapshot(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__time(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__timeEnd(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3); -ZIG_DECL void Zig__ConsoleClient__timeLog(void* arg0, JSC__JSGlobalObject* arg1, const unsigned char* arg2, size_t arg3, Inspector__ScriptArguments* arg4); -ZIG_DECL void Zig__ConsoleClient__timeStamp(void* arg0, JSC__JSGlobalObject* arg1, Inspector__ScriptArguments* arg2); +ZIG_DECL void Zig__ConsoleClient__count(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__countReset(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__messageWithTypeAndLevel(void *arg0, uint32_t arg1, uint32_t arg2, + JSC__JSGlobalObject *arg3, + JSC__JSValue *arg4, size_t arg5); +ZIG_DECL void Zig__ConsoleClient__profile(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__profileEnd(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__record(void *arg0, JSC__JSGlobalObject *arg1, + Inspector__ScriptArguments *arg2); +ZIG_DECL void Zig__ConsoleClient__recordEnd(void *arg0, JSC__JSGlobalObject *arg1, + Inspector__ScriptArguments *arg2); +ZIG_DECL void Zig__ConsoleClient__screenshot(void *arg0, JSC__JSGlobalObject *arg1, + Inspector__ScriptArguments *arg2); +ZIG_DECL void Zig__ConsoleClient__takeHeapSnapshot(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__time(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__timeEnd(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3); +ZIG_DECL void Zig__ConsoleClient__timeLog(void *arg0, JSC__JSGlobalObject *arg1, + const unsigned char *arg2, size_t arg3, + Inspector__ScriptArguments *arg4); +ZIG_DECL void Zig__ConsoleClient__timeStamp(void *arg0, JSC__JSGlobalObject *arg1, + Inspector__ScriptArguments *arg2); #endif diff --git a/src/javascript/jsc/bindings/headers.zig b/src/javascript/jsc/bindings/headers.zig index 783d9c82d..2dfc7eb11 100644 --- a/src/javascript/jsc/bindings/headers.zig +++ b/src/javascript/jsc/bindings/headers.zig @@ -37,7 +37,7 @@ pub const __mbstate_t = extern union { pub const __darwin_mbstate_t = __mbstate_t; pub const __darwin_ptrdiff_t = c_long; pub const __darwin_size_t = c_ulong; - + pub const JSC__RegExpPrototype = struct_JSC__RegExpPrototype; pub const JSC__GeneratorPrototype = struct_JSC__GeneratorPrototype; @@ -241,6 +241,7 @@ pub extern fn JSC__JSValue__isCallable(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM pub extern fn JSC__JSValue__isCell(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isCustomGetterSetter(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isError(JSValue0: JSC__JSValue) bool; +pub extern fn JSC__JSValue__isException(JSValue0: JSC__JSValue, arg1: [*c]JSC__VM) bool; pub extern fn JSC__JSValue__isGetterSetter(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isHeapBigInt(JSValue0: JSC__JSValue) bool; pub extern fn JSC__JSValue__isInt32AsAnyInt(JSValue0: JSC__JSValue) bool; @@ -270,6 +271,7 @@ pub extern fn JSC__JSValue__toPropertyKeyValue(JSValue0: JSC__JSValue, arg1: [*c pub extern fn JSC__JSValue__toString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString; pub extern fn JSC__JSValue__toStringOrNull(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) [*c]JSC__JSString; pub extern fn JSC__JSValue__toWTFString(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) bWTF__String; +pub extern fn JSC__JSValue__toZigException(JSValue0: JSC__JSValue, arg1: [*c]JSC__JSGlobalObject) ZigException; pub extern fn JSC__PropertyName__eqlToIdentifier(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__Identifier) bool; pub extern fn JSC__PropertyName__eqlToPropertyName(arg0: [*c]JSC__PropertyName, arg1: [*c]const JSC__PropertyName) bool; pub extern fn JSC__PropertyName__publicName(arg0: [*c]JSC__PropertyName) [*c]const WTF__StringImpl; @@ -334,4 +336,5 @@ pub extern fn WTF__StringView__is16Bit(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__is8Bit(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__isEmpty(arg0: [*c]const WTF__StringView) bool; pub extern fn WTF__StringView__length(arg0: [*c]const WTF__StringView) usize; -pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*c_void) [*c]JSC__JSGlobalObject;
\ No newline at end of file +pub extern fn Zig__GlobalObject__create(arg0: [*c]JSClassRef, arg1: i32, arg2: ?*c_void) [*c]JSC__JSGlobalObject; +pub extern fn ZigException__fromException(arg0: [*c]JSC__Exception) ZigException;
\ No newline at end of file diff --git a/src/javascript/jsc/bindings/helpers.h b/src/javascript/jsc/bindings/helpers.h index 591f9e4e4..a24ecefcb 100644 --- a/src/javascript/jsc/bindings/helpers.h +++ b/src/javascript/jsc/bindings/helpers.h @@ -1,182 +1,149 @@ #include "headers.h" #include "root.h" -#include <JavaScriptCore/JSCInlines.h> -#include <JavaScriptCore/VM.h> +#include <JavaScriptCore/Error.h> +#include <JavaScriptCore/Exception.h> #include <JavaScriptCore/Identifier.h> -#include <JavaScriptCore/JSValue.h> +#include <JavaScriptCore/JSCInlines.h> #include <JavaScriptCore/JSString.h> +#include <JavaScriptCore/JSValue.h> #include <JavaScriptCore/ThrowScope.h> -#include <JavaScriptCore/Error.h> -#include <JavaScriptCore/Exception.h> - -template<class CppType, typename ZigType> -class Wrap { -public: - Wrap(){ - }; - - Wrap(ZigType zig){ - result = zig; - cpp = static_cast<CppType*>(static_cast<void*>(&zig)); - }; - - Wrap(ZigType* zig){ - cpp = static_cast<CppType*>(static_cast<void*>(&zig)); - }; - +#include <JavaScriptCore/VM.h> - Wrap(CppType _cpp){ - auto buffer = alignedBuffer(); - cpp = new (buffer) CppType(_cpp); - }; +template <class CppType, typename ZigType> class Wrap { + public: + Wrap(){}; + Wrap(ZigType zig) { + result = zig; + cpp = static_cast<CppType *>(static_cast<void *>(&zig)); + }; - ~Wrap(){}; + Wrap(ZigType *zig) { cpp = static_cast<CppType *>(static_cast<void *>(&zig)); }; - unsigned char* alignedBuffer() { - return result.bytes + alignof(CppType) - reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType); - } + Wrap(CppType _cpp) { + auto buffer = alignedBuffer(); + cpp = new (buffer) CppType(_cpp); + }; - ZigType result; - CppType* cpp; + ~Wrap(){}; - static ZigType wrap(CppType obj) { - return *static_cast<ZigType*>(static_cast<void*>(&obj)); - } + unsigned char *alignedBuffer() { + return result.bytes + alignof(CppType) - + reinterpret_cast<intptr_t>(result.bytes) % alignof(CppType); + } - static CppType unwrap(ZigType obj) { - return *static_cast<CppType*>(static_cast<void*>(&obj)); - } + ZigType result; + CppType *cpp; - static CppType* unwrap(ZigType* obj) { - return static_cast<CppType*>(static_cast<void*>(obj)); - } + static ZigType wrap(CppType obj) { return *static_cast<ZigType *>(static_cast<void *>(&obj)); } - + static CppType unwrap(ZigType obj) { return *static_cast<CppType *>(static_cast<void *>(&obj)); } - + static CppType *unwrap(ZigType *obj) { return static_cast<CppType *>(static_cast<void *>(obj)); } }; - - - - -template<class To, class From> -To cast(From v) -{ - return *static_cast<To*>(static_cast<void*>(v)); +template <class To, class From> To cast(From v) { + return *static_cast<To *>(static_cast<void *>(v)); } -template<class To, class From> -To ccast(From v) -{ - return *static_cast<const To*>(static_cast<const void*>(v)); +template <class To, class From> To ccast(From v) { + return *static_cast<const To *>(static_cast<const void *>(v)); } -typedef JSC__JSValue (* NativeCallbackFunction)(void* arg0, JSC__JSGlobalObject* arg1, JSC__CallFrame* arg2); +typedef JSC__JSValue (*NativeCallbackFunction)(void *arg0, JSC__JSGlobalObject *arg1, + JSC__CallFrame *arg2); -static const JSC::ArgList makeArgs(JSC__JSValue* v, size_t count) { - JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer(); - args.ensureCapacity(count); - for (size_t i = 0; i < count; ++i) { - args.append(JSC::JSValue::decode(v[i])); - } +static const JSC::ArgList makeArgs(JSC__JSValue *v, size_t count) { + JSC::MarkedArgumentBuffer args = JSC::MarkedArgumentBuffer(); + args.ensureCapacity(count); + for (size_t i = 0; i < count; ++i) { args.append(JSC::JSValue::decode(v[i])); } - return JSC::ArgList(args); + return JSC::ArgList(args); } namespace Zig { +static const JSC::Identifier toIdentifier(ZigString str, JSC::JSGlobalObject *global) { + if (str.len == 0 || str.ptr == nullptr) { return JSC::Identifier::EmptyIdentifier; } + return JSC::Identifier::fromString(global->vm(), str.ptr, str.len); +} +static const WTF::String toString(ZigString str) { + if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); } -static const JSC::Identifier toIdentifier(ZigString str, JSC::JSGlobalObject* global) { - if (str.len == 0 || str.ptr == nullptr) { - return JSC::Identifier::EmptyIdentifier; - } - - return JSC::Identifier::fromString(global->vm(), str.ptr, str.len); + return WTF::String(WTF::StringImpl::createWithoutCopying(str.ptr, str.len)); } -static const WTF::String toString(ZigString str) { - if (str.len == 0 || str.ptr == nullptr) { - return WTF::String(); - } +static WTF::String toStringNotConst(ZigString str) { + if (str.len == 0 || str.ptr == nullptr) { return WTF::String(); } - return WTF::String(WTF::StringImpl::createWithoutCopying(str.ptr, str.len)); + return WTF::String(WTF::StringImpl::createWithoutCopying(str.ptr, str.len)); } -static const JSC::JSString* toJSString(ZigString str, JSC::JSGlobalObject* global) { - return JSC::jsOwnedString(global->vm(), toString(str)); +static const JSC::JSString *toJSString(ZigString str, JSC::JSGlobalObject *global) { + return JSC::jsOwnedString(global->vm(), toString(str)); } static const ZigString ZigStringEmpty = ZigString{nullptr, 0}; -static const unsigned char __dot_char = '.'; +static const unsigned char __dot_char = '.'; static const ZigString ZigStringCwd = ZigString{&__dot_char, 1}; - - static ZigString toZigString(WTF::String str) { - return str.isEmpty() ? ZigStringEmpty : ZigString{ str.characters8(), str.length() }; + return str.isEmpty() ? ZigStringEmpty : ZigString{str.characters8(), str.length()}; } - -static ZigString toZigString(WTF::String* str) { - return str->isEmpty() ? ZigStringEmpty : ZigString{ str->characters8(), str->length() }; +static ZigString toZigString(WTF::String *str) { + return str->isEmpty() ? ZigStringEmpty : ZigString{str->characters8(), str->length()}; } - -static ZigString toZigString(WTF::StringImpl& str) { - return str.isEmpty() ? ZigStringEmpty : ZigString{ str.characters8(), str.length() }; +static ZigString toZigString(WTF::StringImpl &str) { + return str.isEmpty() ? ZigStringEmpty : ZigString{str.characters8(), str.length()}; } -static ZigString toZigString(WTF::StringView& str) { - return str.isEmpty() ? ZigStringEmpty : ZigString{ str.characters8(), str.length() }; +static ZigString toZigString(WTF::StringView &str) { + return str.isEmpty() ? ZigStringEmpty : ZigString{str.characters8(), str.length()}; } -static ZigString toZigString(JSC::JSString& str, JSC::JSGlobalObject *global) { - return toZigString(str.value(global)); +static ZigString toZigString(JSC::JSString &str, JSC::JSGlobalObject *global) { + return toZigString(str.value(global)); } - -static ZigString toZigString(JSC::JSString* str, JSC::JSGlobalObject *global) { - return toZigString(str->value(global)); +static ZigString toZigString(JSC::JSString *str, JSC::JSGlobalObject *global) { + return toZigString(str->value(global)); } - -static ZigString toZigString(JSC::Identifier& str, JSC::JSGlobalObject *global) { - return toZigString(str.string()); +static ZigString toZigString(JSC::Identifier &str, JSC::JSGlobalObject *global) { + return toZigString(str.string()); } -static ZigString toZigString(JSC::Identifier* str, JSC::JSGlobalObject *global) { - return toZigString(str->string()); +static ZigString toZigString(JSC::Identifier *str, JSC::JSGlobalObject *global) { + return toZigString(str->string()); } +static WTF::StringView toStringView(ZigString str) { return WTF::StringView(str.ptr, str.len); } - -static void throwException(JSC::ThrowScope& scope, ZigString msg, JSC::JSGlobalObject* global) { - auto str = toJSString(msg, global); - scope.throwException(global, JSC::Exception::create(global->vm(), JSC::JSValue(str))); +static void throwException(JSC::ThrowScope &scope, ZigString msg, JSC::JSGlobalObject *global) { + auto str = toJSString(msg, global); + scope.throwException(global, JSC::Exception::create(global->vm(), JSC::JSValue(str))); } +static ZigString toZigString(JSC::JSValue val, JSC::JSGlobalObject *global) { + auto scope = DECLARE_THROW_SCOPE(global->vm()); + WTF::String str = val.toWTFString(global); - -static ZigString toZigString(JSC::JSValue val, JSC::JSGlobalObject* global) { - auto scope = DECLARE_THROW_SCOPE(global->vm()); - WTF::String str = val.toWTFString(global); - - if (scope.exception()) { - scope.clearException(); - scope.release(); - return ZigStringEmpty; - } - + if (scope.exception()) { + scope.clearException(); scope.release(); + return ZigStringEmpty; + } + scope.release(); - return toZigString(str); + return toZigString(str); } - -}
\ No newline at end of file +static ZigException ZigExceptionNone = ZigException{ + 0, 0, ZigStringEmpty, ZigStringEmpty, ZigStringEmpty, -1, -1, ZigStringEmpty, nullptr}; +} // namespace Zig diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 9850f0c6a..e63cee40f 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -65,20 +65,20 @@ pub const VirtualMachine = struct { vm = try allocator.create(VirtualMachine); var console = try allocator.create(ZigConsoleClient); console.* = ZigConsoleClient.init(Output.errorWriter(), Output.writer()); - + const bundler = try Bundler.init( + allocator, + log, + try configureTransformOptionsForSpeedy(allocator, _args), + existing_bundle, + ); vm.* = VirtualMachine{ .global = undefined, .allocator = allocator, .require_cache = RequireCacheType.init(allocator), .event_listeners = EventListenerMixin.Map.init(allocator), - .bundler = try Bundler.init( - allocator, - log, - try configureTransformOptionsForSpeedy(allocator, _args), - existing_bundle, - ), + .bundler = bundler, .console = console, - .node_modules = existing_bundle, + .node_modules = bundler.options.node_modules_bundle, .log = log, }; @@ -106,12 +106,39 @@ pub const VirtualMachine = struct { threadlocal var source_code_printer: js_printer.BufferPrinter = undefined; threadlocal var source_code_printer_loaded: bool = false; - inline fn _fetch(global: *JSGlobalObject, specifier: string, source: string) !string { + inline fn _fetch(global: *JSGlobalObject, specifier: string, source: string) !ResolvedSource { std.debug.assert(VirtualMachine.vm_loaded); std.debug.assert(VirtualMachine.vm.global == global); - if (strings.eqlComptime(specifier, Runtime.Runtime.Imports.Name)) { - return Runtime.Runtime.sourceContent(); + if (vm.node_modules != null and strings.eql(vm.bundler.linker.nodeModuleBundleImportPath(), specifier)) { + // We kind of need an abstraction around this. + // Basically we should subclass JSC::SourceCode with: + // - hash + // - file descriptor for source input + // - file path + file descriptor for bytecode caching + // - separate bundles for server build vs browser build OR at least separate sections + const code = try vm.node_modules.?.readCodeAsStringSlow(vm.allocator); + return ResolvedSource{ + .source_code = ZigString.init(code), + .specifier = ZigString.init(vm.bundler.linker.nodeModuleBundleImportPath()), + .source_url = ZigString.init(vm.bundler.options.node_modules_bundle_pretty_path), + .hash = 0, // TODO + .bytecodecache_fd = std.math.lossyCast(u64, vm.node_modules.?.fetchByteCodeCache( + vm.bundler.options.node_modules_bundle_pretty_path, + &vm.bundler.fs.fs, + ) orelse 0), + }; + } else if (strings.eqlComptime(specifier, Runtime.Runtime.Imports.Name)) { + return ResolvedSource{ + .source_code = ZigString.init(Runtime.Runtime.sourceContent()), + .specifier = ZigString.init(Runtime.Runtime.Imports.Name), + .source_url = ZigString.init(Runtime.Runtime.Imports.Name), + .hash = Runtime.Runtime.versionHash(), + .bytecodecache_fd = std.math.lossyCast( + u64, + Runtime.Runtime.byteCodeCacheFile(&vm.bundler.fs.fs) orelse 0, + ), + }; } const result = vm.bundler.resolve_results.get(specifier) orelse return error.MissingResolveResult; @@ -172,18 +199,32 @@ pub const VirtualMachine = struct { return error.PrintingErrorWriteFailed; } - return vm.allocator.dupe(u8, source_code_printer.ctx.written) catch unreachable; + return ResolvedSource{ + .source_code = ZigString.init(vm.allocator.dupe(u8, source_code_printer.ctx.written) catch unreachable), + .specifier = ZigString.init(specifier), + .source_url = ZigString.init(path.pretty), + .hash = 0, + .bytecodecache_fd = 0, + }; }, else => { - return try strings.quotedAlloc(VirtualMachine.vm.allocator, path.pretty); + return ResolvedSource{ + .source_code = ZigString.init(try strings.quotedAlloc(VirtualMachine.vm.allocator, path.pretty)), + .specifier = ZigString.init(path.text), + .source_url = ZigString.init(path.pretty), + .hash = 0, + .bytecodecache_fd = 0, + }; }, } } inline fn _resolve(global: *JSGlobalObject, specifier: string, source: string) !string { std.debug.assert(VirtualMachine.vm_loaded); std.debug.assert(VirtualMachine.vm.global == global); - if (strings.eqlComptime(specifier, Runtime.Runtime.Imports.Name)) { + if (vm.node_modules == null and strings.eqlComptime(specifier, Runtime.Runtime.Imports.Name)) { return Runtime.Runtime.Imports.Name; + } else if (vm.node_modules != null and strings.eql(specifier, vm.bundler.linker.nodeModuleBundleImportPath())) { + return vm.bundler.linker.nodeModuleBundleImportPath(); } const result: resolver.Result = vm.bundler.resolve_results.get(specifier) orelse brk: { @@ -198,6 +239,47 @@ pub const VirtualMachine = struct { break :brk res; }; + if (vm.node_modules != null and result.isLikelyNodeModule()) { + const node_modules_bundle = vm.node_modules.?; + + node_module_checker: { + const package_json = result.package_json orelse brk: { + if (vm.bundler.linker.resolver.packageJSONForResolvedNodeModule(&result)) |pkg| { + break :brk pkg; + } else { + break :node_module_checker; + } + }; + + if (node_modules_bundle.getPackageIDByName(package_json.name)) |possible_pkg_ids| { + const pkg_id: u32 = brk: { + for (possible_pkg_ids) |pkg_id| { + const pkg = node_modules_bundle.bundle.packages[pkg_id]; + if (pkg.hash == package_json.hash) { + break :brk pkg_id; + } + } + break :node_module_checker; + }; + + const package = &node_modules_bundle.bundle.packages[pkg_id]; + + if (isDebug) { + std.debug.assert(strings.eql(node_modules_bundle.str(package.name), package_json.name)); + } + + const package_relative_path = vm.bundler.fs.relative( + package_json.source.path.name.dirWithTrailingSlash(), + result.path_pair.primary.text, + ); + + if (node_modules_bundle.findModuleIDInPackage(package, package_relative_path) == null) break :node_module_checker; + + return vm.bundler.linker.nodeModuleBundleImportPath(); + } + } + } + return result.path_pair.primary.text; } @@ -213,15 +295,15 @@ pub const VirtualMachine = struct { return ErrorableZigString.ok(ZigString.init(result)); } - pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) ErrorableZigString { + pub fn fetch(global: *JSGlobalObject, specifier: ZigString, source: ZigString) callconv(.C) ErrorableResolvedSource { const result = _fetch(global, specifier.slice(), source.slice()) catch |err| { - return ErrorableZigString.errFmt(err, "{s}: \"{s}\"", .{ + return ErrorableResolvedSource.errFmt(err, "{s}: \"{s}\"", .{ @errorName(err), specifier.slice(), }); }; - return ErrorableZigString.ok(ZigString.init(result)); + return ErrorableResolvedSource.ok(result); } pub fn loadEntryPoint(this: *VirtualMachine, entry_point: string) !void { @@ -230,9 +312,21 @@ pub const VirtualMachine = struct { var promise = JSModuleLoader.loadAndEvaluateModule(this.global, ZigString.init(path)); this.global.vm().drainMicrotasks(); + + while (promise.status(this.global.vm()) == JSPromise.Status.Pending) { + this.global.vm().drainMicrotasks(); + } + if (promise.status(this.global.vm()) == JSPromise.Status.Rejected) { - var str = promise.result(this.global.vm()).toWTFString(this.global); - Output.prettyErrorln("<r><red>Error<r>: <b>{s}<r>", .{str.slice()}); + var exception = promise.result(this.global.vm()).toZigException(this.global); + Output.prettyErrorln("<r><red>{s}<r><d>:<r> <b>{s}<r>\n<blue>{s}<r>:{d}:{d}\n{s}", .{ + exception.name.slice(), + exception.message.slice(), + exception.sourceURL.slice(), + exception.line, + exception.column, + exception.stack.slice(), + }); } } }; diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig index 5ee6eab94..a987351c7 100644 --- a/src/js_parser/js_parser.zig +++ b/src/js_parser/js_parser.zig @@ -1,5 +1,19 @@ usingnamespace @import("imports.zig"); +// Dear reader, +// There are some things you should know about this file to make it easier for humans to read +// "P" is the internal parts of the parser +// "p.e" allocates a new Expr +// "p.b" allocates a new Binding +// "p.s" allocates a new Stmt +// We do it this way so if we want to refactor how these are allocated in the future, we only have to modify one function to change it everywhere +// Everything in JavaScript is either an Expression, a Binding, or a Statement. +// Expression: foo(1) +// Statement: let a = 1; +// Binding: 1 +// While the names for Expr, Binding, and Stmt are directly copied from esbuild, those were likely inspired by Go's parser. +// which is another example of a very fast parser. + const TemplatePartTuple = std.meta.Tuple(&[_]type{ []E.TemplatePart, logger.Loc }); const ScopeOrderList = std.ArrayListUnmanaged(?ScopeOrder); diff --git a/src/linker.zig b/src/linker.zig index d0f48e8a1..44439a0ec 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -160,6 +160,12 @@ pub fn NewLinker(comptime BundlerType: type) type { unreachable; } + + pub inline fn nodeModuleBundleImportPath(this: *const ThisLinker) string { + return if (this.options.node_modules_bundle_url.len > 0) this.options.node_modules_bundle_url else this.options.node_modules_bundle.?.bundle.import_from_name; + } + + // pub const Scratch = struct { // threadlocal var externals: std.ArrayList(u32) = undefined; // threadlocal var has_externals: std.ArrayList(u32) = undefined; @@ -190,8 +196,8 @@ pub fn NewLinker(comptime BundlerType: type) type { if (comptime !ignore_runtime) { if (strings.eqlComptime(import_record.path.text, Runtime.Imports.Name)) { // runtime is included in the bundle, so we don't need to dynamically import it - if (linker.options.node_modules_bundle) |node_modules_bundle| { - import_record.path.text = if (linker.options.node_modules_bundle_url.len > 0) linker.options.node_modules_bundle_url else node_modules_bundle.bundle.import_from_name; + if (linker.options.node_modules_bundle != null) { + import_record.path.text = linker.nodeModuleBundleImportPath(); } else { import_record.path = try linker.generateImportPath( source_dir, @@ -272,7 +278,7 @@ pub fn NewLinker(comptime BundlerType: type) type { }; import_record.is_bundled = true; - import_record.path.text = if (linker.options.node_modules_bundle_url.len > 0) linker.options.node_modules_bundle_url else node_modules_bundle.bundle.import_from_name; + import_record.path.text = linker.nodeModuleBundleImportPath(); import_record.module_id = found_module.id; needs_bundle = true; continue; diff --git a/src/node_module_bundle.zig b/src/node_module_bundle.zig index 98b9067c0..94bbe5258 100644 --- a/src/node_module_bundle.zig +++ b/src/node_module_bundle.zig @@ -1,6 +1,7 @@ const schema = @import("./api/schema.zig"); const Api = schema.Api; const std = @import("std"); +const Fs = @import("./fs.zig"); usingnamespace @import("global.zig"); pub fn modulesIn(bundle: *const Api.JavascriptBundle, pkg: *const Api.JavascriptBundledPackage) []const Api.JavascriptBundledModule { @@ -16,13 +17,20 @@ const PackageIDMap = std.AutoHashMap(BundledPackageHash, BundledPackageID); const PackageNameMap = std.StringHashMap([]BundledPackageID); +pub const AllocatedString = struct { + str: string, + len: u32, + allocator: *std.mem.Allocator, +}; + pub const NodeModuleBundle = struct { container: Api.JavascriptBundleContainer, bundle: Api.JavascriptBundle, allocator: *std.mem.Allocator, bytes_ptr: []u8 = undefined, - bytes: []u8 = undefined, + bytes: []u8 = &[_]u8{}, fd: FileDescriptorType = 0, + code_end_pos: u32 = 0, // Lookup packages by ID - hash(name@version) package_id_map: PackageIDMap, @@ -33,6 +41,10 @@ pub const NodeModuleBundle = struct { // This is stored as a single pre-allocated, flat array so we can avoid dynamic allocations. package_name_ids_ptr: []BundledPackageID = &([_]BundledPackageID{}), + code_string: ?AllocatedString = null, + + bytecode_cache_fetcher: Fs.BytecodeCacheFetcher = Fs.BytecodeCacheFetcher{}, + pub const magic_bytes = "#!/usr/bin/env speedy\n\n"; threadlocal var jsbundle_prefix: [magic_bytes.len + 5]u8 = undefined; @@ -41,6 +53,23 @@ pub const NodeModuleBundle = struct { return this.package_name_map.contains("react-refresh"); } + pub inline fn fetchByteCodeCache(this: *NodeModuleBundle, basename: string, fs: *Fs.FileSystem.RealFS) ?StoredFileDescriptorType { + return this.bytecode_cache_fetcher.fetch(basename, fs); + } + + pub fn readCodeAsStringSlow(this: *NodeModuleBundle, allocator: *std.mem.Allocator) !string { + if (this.code_string) |code| { + return code.str; + } + + var file = std.fs.File{ .handle = this.fd }; + + var buf = try allocator.alloc(u8, this.code_end_pos); + const count = try file.preadAll(buf, this.codeStartOffset()); + this.code_string = AllocatedString{ .str = buf[0..count], .len = @truncate(u32, buf.len), .allocator = allocator }; + return this.code_string.?.str; + } + pub fn loadPackageMap(this: *NodeModuleBundle) !void { this.package_name_map = PackageNameMap.init(this.allocator); this.package_id_map = PackageIDMap.init(this.allocator); @@ -268,12 +297,13 @@ pub const NodeModuleBundle = struct { var read_bytes = file_bytes[0..read_count]; var reader = schema.Reader.init(read_bytes, allocator); var container = try Api.JavascriptBundleContainer.decode(&reader); - var bundle = NodeModuleBundle{ .allocator = allocator, .container = container, .bundle = container.bundle.?, .fd = stream.handle, + // sorry you can't have 4 GB of node_modules + .code_end_pos = @truncate(u32, file_end) - @intCast(u32, jsbundle_prefix.len), .bytes = read_bytes, .bytes_ptr = file_bytes, .package_id_map = undefined, @@ -346,7 +376,7 @@ pub const NodeModuleBundle = struct { Output.prettyln(indent ++ "<b>{d:6} packages", .{this.bundle.packages.len}); } - pub fn codeStartOffset(this: *const NodeModuleBundle) u32 { + pub inline fn codeStartOffset(this: *const NodeModuleBundle) u32 { return @intCast(u32, jsbundle_prefix.len); } diff --git a/src/options.zig b/src/options.zig index c90f671a9..a92857620 100644 --- a/src/options.zig +++ b/src/options.zig @@ -616,6 +616,7 @@ pub const BundleOptions = struct { output_dir: string = "", output_dir_handle: ?std.fs.Dir = null, node_modules_bundle_url: string = "", + node_modules_bundle_pretty_path: string = "", public_dir_handle: ?std.fs.Dir = null, write: bool = false, preserve_symlinks: bool = false, @@ -804,8 +805,19 @@ pub const BundleOptions = struct { relative = relative[1..]; } - opts.node_modules_bundle_url = try std.fmt.allocPrint(allocator, "{s}{s}", .{ opts.public_url, relative }); + const buf_size = opts.public_url.len + relative.len + pretty_path.len; + var buf = try allocator.alloc(u8, buf_size); + opts.node_modules_bundle_url = try std.fmt.bufPrint(buf, "{s}{s}", .{ opts.public_url, relative }); + opts.node_modules_bundle_pretty_path = buf[opts.node_modules_bundle_url.len..]; + std.mem.copy( + u8, + buf[opts.node_modules_bundle_url.len..], + pretty_path, + ); + } else { + opts.node_modules_bundle_pretty_path = try allocator.dupe(u8, pretty_path); } + const elapsed = @intToFloat(f64, (std.time.nanoTimestamp() - time_start)) / std.time.ns_per_ms; Output.prettyErrorln( "<r><b><d>\"{s}\"<r><d> - {d} modules, {d} packages <b>[{d:>.2}ms]<r>", diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index 329b517b0..59b5fdce8 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -167,6 +167,8 @@ pub const Result = struct { dirname_fd: StoredFileDescriptorType = 0, file_fd: StoredFileDescriptorType = 0, + // remember: non-node_modules can have package.json + // checking package.json may not be relevant pub fn isLikelyNodeModule(this: *const Result) bool { const dir = this.path_pair.primary.name.dirWithTrailingSlash(); return strings.indexOf(dir, "/node_modules/") != null; diff --git a/src/runtime.zig b/src/runtime.zig index ac2a2f0ff..33a8fbd0c 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -4,6 +4,8 @@ usingnamespace @import("global.zig"); const std = @import("std"); pub const ProdSourceContent = @embedFile("./runtime.out.js"); +const Fs = @import("./fs.zig"); + pub const Runtime = struct { pub fn sourceContent() string { if (comptime isDebug) { @@ -15,7 +17,22 @@ pub const Runtime = struct { return ProdSourceContent; } } - pub var version_hash = @embedFile("./runtime.version"); + pub const version_hash = @embedFile("./runtime.version"); + var version_hash_int: u32 = 0; + pub fn versionHash() u32 { + if (version_hash_int == 0) { + version_hash_int = @truncate(u32, std.fmt.parseInt(u64, version(), 16) catch unreachable); + } + return version_hash_int; + } + + const bytecodeCacheFilename = std.fmt.comptimePrint("__runtime.{s}", .{version_hash}); + var bytecodeCacheFetcher = Fs.BytecodeCacheFetcher{}; + + pub fn byteCodeCacheFile(fs: *Fs.FileSystem.RealFS) ?StoredFileDescriptorType { + return bytecodeCacheFetcher.fetch(bytecodeCacheFilename, fs); + } + pub fn version() string { return version_hash; } |