diff --git a/src/c.zig b/src/c.zig index aaeb980da0..7817bdfe95 100644 --- a/src/c.zig +++ b/src/c.zig @@ -249,3 +249,59 @@ pub fn getSelfExeSharedLibPaths(allocator: std.mem.Allocator) error{OutOfMemory} else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"), } } + +/// The madvise() system call allows a process that has knowledge of its mem-ory memory +/// ory behavior to describe it to the system. The advice passed in may be +/// used by the system to alter its virtual memory paging strategy. This +/// advice may improve application and system performance. The behavior +/// specified in advice can only be one of the following values: +/// +/// MADV_NORMAL Indicates that the application has no advice to give on +/// its behavior in the specified address range. This is +/// the system default behavior. This is used with +/// madvise() system call. +/// +/// POSIX_MADV_NORMAL +/// Same as MADV_NORMAL but used with posix_madvise() system +/// call. +/// +/// MADV_SEQUENTIAL Indicates that the application expects to access this +/// address range in a sequential manner. This is used with +/// madvise() system call. +/// +/// POSIX_MADV_SEQUENTIAL +/// Same as MADV_SEQUENTIAL but used with posix_madvise() +/// system call. +/// +/// MADV_RANDOM Indicates that the application expects to access this +/// address range in a random manner. This is used with +/// madvise() system call. +/// +/// POSIX_MADV_RANDOM +/// Same as MADV_RANDOM but used with posix_madvise() system +/// call. +/// +/// MADV_WILLNEED Indicates that the application expects to access this +/// address range soon. This is used with madvise() system +/// call. +/// +/// POSIX_MADV_WILLNEED +/// Same as MADV_WILLNEED but used with posix_madvise() sys-tem system +/// tem call. +/// +/// MADV_DONTNEED Indicates that the application is not expecting to +/// access this address range soon. This is used with +/// madvise() system call. +/// +/// POSIX_MADV_DONTNEED +/// Same as MADV_DONTNEED but used with posix_madvise() sys-tem system +/// tem call. +/// +/// MADV_FREE Indicates that the application will not need the infor-mation information +/// mation contained in this address range, so the pages may +/// be reused right away. The address range will remain +/// valid. This is used with madvise() system call. +/// +/// The posix_madvise() behaves same as madvise() except that it uses values +/// with POSIX_ prefix for the advice system call argument. +pub extern "c" fn posix_madvise(ptr: *anyopaque, len: usize, advice: i32) c_int; diff --git a/src/global.zig b/src/global.zig index f2d9d97290..868b0ad10d 100644 --- a/src/global.zig +++ b/src/global.zig @@ -3,11 +3,27 @@ pub const Environment = @import("env.zig"); pub const use_mimalloc = !Environment.isTest; +/// For sizes less than 8 MB, allocate via mimalloc pub const default_allocator: std.mem.Allocator = if (!use_mimalloc) std.heap.c_allocator else @import("./memory_allocator.zig").c_allocator; +/// For sizes larger than 8 MB, allocate via mmap() instead of malloc(). +pub const huge_allocator: std.mem.Allocator = if (!use_mimalloc) + std.heap.c_allocator +else + @import("./memory_allocator.zig").huge_allocator; + +/// For sizes larger than 8 MB, allocate via mmap() instead of malloc(). +/// For sizes less than 8 MB, allocate via mimalloc +pub const auto_allocator: std.mem.Allocator = if (!use_mimalloc) + std.heap.c_allocator +else + @import("./memory_allocator.zig").auto_allocator; + +pub const huge_allocator_threshold = 1024 * 1024 * 2; + pub const C = @import("c.zig"); pub const FeatureFlags = @import("feature_flags.zig"); diff --git a/src/io/io_darwin.zig b/src/io/io_darwin.zig index 1de5d494fb..f72ea73ae5 100644 --- a/src/io/io_darwin.zig +++ b/src/io/io_darwin.zig @@ -270,8 +270,9 @@ pub const darwin = struct { pub extern "c" fn @"accept$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int; pub extern "c" fn @"accept4$NOCANCEL"(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int; pub extern "c" fn @"open$NOCANCEL"(path: [*:0]const u8, oflag: c_uint, ...) c_int; + pub extern "c" fn @"read$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize; + pub extern "c" fn @"pread$NOCANCEL"(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize; }; - pub const OpenError = error{ /// In WASI, this error may occur when the file descriptor does /// not hold the required rights to open a new resource relative to it. @@ -539,6 +540,8 @@ pub fn run_for_ns(self: *IO, nanoseconds: u63) !void { } } +const default_timespec = std.mem.zeroInit(os.timespec, .{}); + fn flush(self: *IO, wait_for_completions: bool) !void { var io_pending = self.io_pending.peek(); var events: [512]os.Kevent = undefined; @@ -552,7 +555,7 @@ fn flush(self: *IO, wait_for_completions: bool) !void { // Only call kevent() if we need to submit io events or if we need to wait for completions. if (change_events > 0 or self.completed.peek() == null) { // Zero timeouts for kevent() implies a non-blocking poll - var ts = std.mem.zeroes(os.timespec); + var ts = default_timespec; // We need to wait (not poll) on kevent if there's nothing to submit or complete. // We should never wait indefinitely (timeout_ptr = null for kevent) given: @@ -602,7 +605,6 @@ fn flush_io(_: *IO, events: []os.Kevent, io_pending_top: *?*Completion) usize { for (events) |*kevent, flushed| { const completion = io_pending_top.* orelse return flushed; io_pending_top.* = completion.next; - const event_info = switch (completion.operation) { .accept => |op| [3]c_int{ op.socket, diff --git a/src/javascript/jsc/base.zig b/src/javascript/jsc/base.zig index 2ecd496439..0b895ed828 100644 --- a/src/javascript/jsc/base.zig +++ b/src/javascript/jsc/base.zig @@ -2306,6 +2306,61 @@ pub const ArrayBuffer = extern struct { return this.toJSUnchecked(ctx, exception); } + pub fn toJSAutoAllocator(this: ArrayBuffer, ctx: JSC.C.JSContextRef, exception: JSC.C.ExceptionRef) JSC.JSValue { + if (!this.value.isEmpty()) { + return this.value; + } + + if (this.byte_len >= bun.huge_allocator_threshold) { + if (this.typed_array_type == .ArrayBuffer) { + return JSC.JSValue.fromRef(JSC.C.JSObjectMakeArrayBufferWithBytesNoCopy( + ctx, + this.ptr, + this.byte_len, + MmapArrayBuffer_deallocator, + @intToPtr(*anyopaque, this.byte_len), + exception, + )); + } + + return JSC.JSValue.fromRef(JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy( + ctx, + this.typed_array_type.toC(), + this.ptr, + this.byte_len, + MmapArrayBuffer_deallocator, + @intToPtr(*anyopaque, this.byte_len), + exception, + )); + } + + // If it's not a mimalloc heap buffer, we're not going to call a deallocator + if (!bun.Global.Mimalloc.mi_is_in_heap_region(this.ptr)) { + if (this.typed_array_type == .ArrayBuffer) { + return JSC.JSValue.fromRef(JSC.C.JSObjectMakeArrayBufferWithBytesNoCopy( + ctx, + this.ptr, + this.byte_len, + null, + null, + exception, + )); + } + + return JSC.JSValue.fromRef(JSC.C.JSObjectMakeTypedArrayWithBytesNoCopy( + ctx, + this.typed_array_type.toC(), + this.ptr, + this.byte_len, + null, + null, + exception, + )); + } + + return this.toJSUnchecked(ctx, exception); + } + pub fn toJSWithContext( this: ArrayBuffer, ctx: JSC.C.JSContextRef, @@ -2553,6 +2608,13 @@ pub export fn MarkedArrayBuffer_deallocator(bytes_: *anyopaque, _: *anyopaque) v // but we don't mimalloc.mi_free(bytes_); } + +pub export fn MmapArrayBuffer_deallocator(bytes: *anyopaque, length_as_ptr: *anyopaque) void { + const length = @ptrToInt(length_as_ptr); + var ptr = @ptrCast([*]u8, bytes); + + bun.auto_allocator.free(ptr[0..length]); +} pub export fn BlobArrayBuffer_deallocator(_: *anyopaque, blob: *anyopaque) void { // zig's memory allocator interface won't work here // mimalloc knows the size of things diff --git a/src/javascript/jsc/bindings/ZigGlobalObject.cpp b/src/javascript/jsc/bindings/ZigGlobalObject.cpp index 36a49312f5..8da6585263 100644 --- a/src/javascript/jsc/bindings/ZigGlobalObject.cpp +++ b/src/javascript/jsc/bindings/ZigGlobalObject.cpp @@ -98,6 +98,7 @@ #include "JSZigGlobalObjectBuiltins.h" #include "JSSQLStatement.h" #include "ReadableStreamBuiltins.h" +#include "BunJSCModule.h" using JSGlobalObject = JSC::JSGlobalObject; using Exception = JSC::Exception; @@ -717,7 +718,7 @@ static JSC_DEFINE_HOST_FUNCTION(functionATOB, const WTF::String& encodedString = callFrame->argument(0).toWTFString(globalObject); if (encodedString.isNull()) { - return JSC::JSValue::encode(JSC::jsString(vm, "")); + return JSC::JSValue::encode(JSC::jsEmptyString(vm)); } auto decodedData = WTF::base64Decode(encodedString, { @@ -903,6 +904,7 @@ JSC: } default: { static NeverDestroyed sqliteString(MAKE_STATIC_STRING_IMPL("sqlite")); + static NeverDestroyed bunJSCString(MAKE_STATIC_STRING_IMPL("bun:jsc")); static NeverDestroyed noopString(MAKE_STATIC_STRING_IMPL("noop")); JSC::JSValue moduleName = callFrame->argument(0); if (moduleName.isNumber()) { @@ -941,6 +943,10 @@ JSC: return JSC::JSValue::encode(JSSQLStatementConstructor::create(vm, globalObject, JSSQLStatementConstructor::createStructure(vm, globalObject, globalObject->m_functionPrototype.get()))); } + if (string == bunJSCString) { + return JSC::JSValue::encode(createJSCModule(globalObject)); + } + if (UNLIKELY(string == noopString)) { auto* obj = constructEmptyObject(globalObject); obj->putDirectCustomAccessor(vm, JSC::PropertyName(JSC::Identifier::fromString(vm, "getterSetter"_s)), JSC::CustomGetterSetter::create(vm, noop_getter, noop_setter), 0); @@ -1599,7 +1605,7 @@ JSC::JSInternalPromise* GlobalObject::moduleLoaderFetch(JSGlobalObject* globalOb auto moduleKey = key.toWTFString(globalObject); RETURN_IF_EXCEPTION(scope, promise->rejectWithCaughtException(globalObject, scope)); - if (moduleKey.endsWith(".node")) { + if (moduleKey.endsWith(".node"_s)) { return rejectWithError(createTypeError(globalObject, "To load Node-API modules, use require() or process.dlopen instead of import."_s)); } diff --git a/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp b/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp index d49e7d8204..335afcec16 100644 --- a/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp +++ b/src/javascript/jsc/bindings/webcore/HTTPParsers.cpp @@ -400,7 +400,7 @@ StringView extractCharsetFromMediaType(StringView mediaType) unsigned length = mediaType.length(); while (pos < length) { - pos = mediaType.findIgnoringASCIICase("charset", pos); + pos = mediaType.findIgnoringASCIICase("charset"_s, pos); if (pos == notFound || pos == 0) { charsetLen = 0; break; diff --git a/src/javascript/jsc/bindings/webcore/JSAbortController.cpp b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp index 4411d07bd3..b2ba038e3e 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortController.cpp +++ b/src/javascript/jsc/bindings/webcore/JSAbortController.cpp @@ -139,9 +139,9 @@ template<> void JSAbortControllerDOMConstructor::initializeProperties(VM& vm, JS /* Hash table for prototype */ static const HashTableValue JSAbortControllerPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsAbortControllerConstructor), (intptr_t) static_cast(0) } }, - { "signal", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortController_signal), (intptr_t) static_cast(0) } }, - { "abort", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortControllerPrototypeFunction_abort), (intptr_t)(0) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsAbortControllerConstructor), (intptr_t) static_cast(0) } }, + { "signal"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortController_signal), (intptr_t) static_cast(0) } }, + { "abort"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortControllerPrototypeFunction_abort), (intptr_t)(0) } }, }; const ClassInfo JSAbortControllerPrototype::s_info = { "AbortController"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortControllerPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp index ba7b3c69fb..bce823102f 100644 --- a/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp +++ b/src/javascript/jsc/bindings/webcore/JSAbortSignal.cpp @@ -109,9 +109,9 @@ using JSAbortSignalDOMConstructor = JSDOMConstructorNotConstructable(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t)(2) } }, - { "abort", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_abort), (intptr_t)(0) } }, - { "timeout", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_timeout), (intptr_t)(1) } }, + { "whenSignalAborted"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_whenSignalAborted), (intptr_t)(2) } }, + { "abort"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_abort), (intptr_t)(0) } }, + { "timeout"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructorFunction_timeout), (intptr_t)(1) } }, }; template<> const ClassInfo JSAbortSignalDOMConstructor::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalDOMConstructor) }; @@ -140,11 +140,11 @@ template<> void JSAbortSignalDOMConstructor::initializeProperties(VM& vm, JSDOMG /* Hash table for prototype */ static const HashTableValue JSAbortSignalPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructor), (intptr_t) static_cast(0) } }, - { "aborted", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_aborted), (intptr_t) static_cast(0) } }, - { "reason", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_reason), (intptr_t) static_cast(0) } }, - { "onabort", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_onabort), (intptr_t) static_cast(setJSAbortSignal_onabort) } }, - { "throwIfAborted", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t)(0) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalConstructor), (intptr_t) static_cast(0) } }, + { "aborted"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_aborted), (intptr_t) static_cast(0) } }, + { "reason"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_reason), (intptr_t) static_cast(0) } }, + { "onabort"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignal_onabort), (intptr_t) static_cast(setJSAbortSignal_onabort) } }, + { "throwIfAborted"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsAbortSignalPrototypeFunction_throwIfAborted), (intptr_t)(0) } }, }; const ClassInfo JSAbortSignalPrototype::s_info = { "AbortSignal"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSAbortSignalPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp b/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp index 843211d8db..383688c42e 100644 --- a/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp +++ b/src/javascript/jsc/bindings/webcore/JSCustomEvent.cpp @@ -202,9 +202,9 @@ template<> void JSCustomEventDOMConstructor::initializeProperties(VM& vm, JSDOMG /* Hash table for prototype */ static const HashTableValue JSCustomEventPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsCustomEventConstructor), (intptr_t) static_cast(0) } }, - { "detail", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsCustomEvent_detail), (intptr_t) static_cast(0) } }, - { "initCustomEvent", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsCustomEventPrototypeFunction_initCustomEvent), (intptr_t)(1) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsCustomEventConstructor), (intptr_t) static_cast(0) } }, + { "detail"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsCustomEvent_detail), (intptr_t) static_cast(0) } }, + { "initCustomEvent"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsCustomEventPrototypeFunction_initCustomEvent), (intptr_t)(1) } }, }; const ClassInfo JSCustomEventPrototype::s_info = { "CustomEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCustomEventPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSDOMException.cpp b/src/javascript/jsc/bindings/webcore/JSDOMException.cpp index 9847b3d517..5dde2de4ef 100644 --- a/src/javascript/jsc/bindings/webcore/JSDOMException.cpp +++ b/src/javascript/jsc/bindings/webcore/JSDOMException.cpp @@ -93,31 +93,31 @@ using JSDOMExceptionDOMConstructor = JSDOMConstructor; /* Hash table for constructor */ static const HashTableValue JSDOMExceptionConstructorTableValues[] = { - { "INDEX_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, - { "DOMSTRING_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, - { "HIERARCHY_REQUEST_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, - { "WRONG_DOCUMENT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, - { "INVALID_CHARACTER_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, - { "NO_DATA_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, - { "NO_MODIFICATION_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, - { "NOT_FOUND_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, - { "NOT_SUPPORTED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, - { "INUSE_ATTRIBUTE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, - { "INVALID_STATE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, - { "SYNTAX_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, - { "INVALID_MODIFICATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, - { "NAMESPACE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, - { "INVALID_ACCESS_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, - { "VALIDATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, - { "TYPE_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, - { "SECURITY_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, - { "NETWORK_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, - { "ABORT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, - { "URL_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, - { "QUOTA_EXCEEDED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, - { "TIMEOUT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, - { "INVALID_NODE_TYPE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, - { "DATA_CLONE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, + { "INDEX_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, + { "DOMSTRING_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, + { "HIERARCHY_REQUEST_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, + { "WRONG_DOCUMENT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, + { "INVALID_CHARACTER_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, + { "NO_DATA_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, + { "NO_MODIFICATION_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, + { "NOT_FOUND_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, + { "NOT_SUPPORTED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, + { "INUSE_ATTRIBUTE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, + { "INVALID_STATE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, + { "SYNTAX_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, + { "INVALID_MODIFICATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, + { "NAMESPACE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, + { "INVALID_ACCESS_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, + { "VALIDATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, + { "TYPE_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, + { "SECURITY_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, + { "NETWORK_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, + { "ABORT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, + { "URL_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, + { "QUOTA_EXCEEDED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, + { "TIMEOUT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, + { "INVALID_NODE_TYPE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, + { "DATA_CLONE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, }; template<> EncodedJSValue JSC_HOST_CALL_ATTRIBUTES JSDOMExceptionDOMConstructor::construct(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame) @@ -166,35 +166,35 @@ template<> void JSDOMExceptionDOMConstructor::initializeProperties(VM& vm, JSDOM /* Hash table for prototype */ static const HashTableValue JSDOMExceptionPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsDOMExceptionConstructor), (intptr_t) static_cast(0) } }, - { "code", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_code), (intptr_t) static_cast(0) } }, - { "name", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_name), (intptr_t) static_cast(0) } }, - { "message", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_message), (intptr_t) static_cast(0) } }, - { "INDEX_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, - { "DOMSTRING_SIZE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, - { "HIERARCHY_REQUEST_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, - { "WRONG_DOCUMENT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, - { "INVALID_CHARACTER_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, - { "NO_DATA_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, - { "NO_MODIFICATION_ALLOWED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, - { "NOT_FOUND_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, - { "NOT_SUPPORTED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, - { "INUSE_ATTRIBUTE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, - { "INVALID_STATE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, - { "SYNTAX_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, - { "INVALID_MODIFICATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, - { "NAMESPACE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, - { "INVALID_ACCESS_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, - { "VALIDATION_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, - { "TYPE_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, - { "SECURITY_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, - { "NETWORK_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, - { "ABORT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, - { "URL_MISMATCH_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, - { "QUOTA_EXCEEDED_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, - { "TIMEOUT_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, - { "INVALID_NODE_TYPE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, - { "DATA_CLONE_ERR", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsDOMExceptionConstructor), (intptr_t) static_cast(0) } }, + { "code"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_code), (intptr_t) static_cast(0) } }, + { "name"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_name), (intptr_t) static_cast(0) } }, + { "message"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMException_message), (intptr_t) static_cast(0) } }, + { "INDEX_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, + { "DOMSTRING_SIZE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, + { "HIERARCHY_REQUEST_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, + { "WRONG_DOCUMENT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(4) } }, + { "INVALID_CHARACTER_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(5) } }, + { "NO_DATA_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(6) } }, + { "NO_MODIFICATION_ALLOWED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(7) } }, + { "NOT_FOUND_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(8) } }, + { "NOT_SUPPORTED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(9) } }, + { "INUSE_ATTRIBUTE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(10) } }, + { "INVALID_STATE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(11) } }, + { "SYNTAX_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(12) } }, + { "INVALID_MODIFICATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(13) } }, + { "NAMESPACE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(14) } }, + { "INVALID_ACCESS_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(15) } }, + { "VALIDATION_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(16) } }, + { "TYPE_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(17) } }, + { "SECURITY_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(18) } }, + { "NETWORK_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(19) } }, + { "ABORT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(20) } }, + { "URL_MISMATCH_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(21) } }, + { "QUOTA_EXCEEDED_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(22) } }, + { "TIMEOUT_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(23) } }, + { "INVALID_NODE_TYPE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(24) } }, + { "DATA_CLONE_ERR"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(25) } }, }; const ClassInfo JSDOMExceptionPrototype::s_info = { "DOMException"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMExceptionPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp b/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp index fcf6d5b72d..95bf264dd6 100644 --- a/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp +++ b/src/javascript/jsc/bindings/webcore/JSDOMURL.cpp @@ -129,8 +129,8 @@ using JSDOMURLDOMConstructor = JSDOMConstructor; /* Hash table for constructor */ static const HashTableValue JSDOMURLConstructorTableValues[] = { - { "createObjectURL", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructorFunction_createObjectURL), (intptr_t)(1) } }, - { "revokeObjectURL", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructorFunction_revokeObjectURL), (intptr_t)(1) } }, + { "createObjectURL"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructorFunction_createObjectURL), (intptr_t)(1) } }, + { "revokeObjectURL"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructorFunction_revokeObjectURL), (intptr_t)(1) } }, }; static inline EncodedJSValue constructJSDOMURL1(JSGlobalObject* lexicalGlobalObject, CallFrame* callFrame) @@ -223,21 +223,21 @@ template<> void JSDOMURLDOMConstructor::initializeProperties(VM& vm, JSDOMGlobal /* Hash table for prototype */ static const HashTableValue JSDOMURLPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructor), (intptr_t) static_cast(0) } }, - { "href", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_href), (intptr_t) static_cast(setJSDOMURL_href) } }, - { "origin", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_origin), (intptr_t) static_cast(0) } }, - { "protocol", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_protocol), (intptr_t) static_cast(setJSDOMURL_protocol) } }, - { "username", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_username), (intptr_t) static_cast(setJSDOMURL_username) } }, - { "password", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_password), (intptr_t) static_cast(setJSDOMURL_password) } }, - { "host", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_host), (intptr_t) static_cast(setJSDOMURL_host) } }, - { "hostname", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_hostname), (intptr_t) static_cast(setJSDOMURL_hostname) } }, - { "port", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_port), (intptr_t) static_cast(setJSDOMURL_port) } }, - { "pathname", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_pathname), (intptr_t) static_cast(setJSDOMURL_pathname) } }, - { "hash", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_hash), (intptr_t) static_cast(setJSDOMURL_hash) } }, - { "search", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_search), (intptr_t) static_cast(setJSDOMURL_search) } }, - { "searchParams", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_searchParams), (intptr_t) static_cast(0) } }, - { "toJSON", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLPrototypeFunction_toJSON), (intptr_t)(0) } }, - { "toString", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLPrototypeFunction_toString), (intptr_t)(0) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLConstructor), (intptr_t) static_cast(0) } }, + { "href"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_href), (intptr_t) static_cast(setJSDOMURL_href) } }, + { "origin"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_origin), (intptr_t) static_cast(0) } }, + { "protocol"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_protocol), (intptr_t) static_cast(setJSDOMURL_protocol) } }, + { "username"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_username), (intptr_t) static_cast(setJSDOMURL_username) } }, + { "password"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_password), (intptr_t) static_cast(setJSDOMURL_password) } }, + { "host"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_host), (intptr_t) static_cast(setJSDOMURL_host) } }, + { "hostname"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_hostname), (intptr_t) static_cast(setJSDOMURL_hostname) } }, + { "port"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_port), (intptr_t) static_cast(setJSDOMURL_port) } }, + { "pathname"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_pathname), (intptr_t) static_cast(setJSDOMURL_pathname) } }, + { "hash"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_hash), (intptr_t) static_cast(setJSDOMURL_hash) } }, + { "search"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_search), (intptr_t) static_cast(setJSDOMURL_search) } }, + { "searchParams"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsDOMURL_searchParams), (intptr_t) static_cast(0) } }, + { "toJSON"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLPrototypeFunction_toJSON), (intptr_t)(0) } }, + { "toString"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsDOMURLPrototypeFunction_toString), (intptr_t)(0) } }, }; const ClassInfo JSDOMURLPrototype::s_info = { "URL"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMURLPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp b/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp index be909421cb..73010ffcba 100644 --- a/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp +++ b/src/javascript/jsc/bindings/webcore/JSErrorEvent.cpp @@ -250,12 +250,12 @@ template<> void JSErrorEventDOMConstructor::initializeProperties(VM& vm, JSDOMGl /* Hash table for prototype */ static const HashTableValue JSErrorEventPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsErrorEventConstructor), (intptr_t) static_cast(0) } }, - { "message", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_message), (intptr_t) static_cast(0) } }, - { "filename", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_filename), (intptr_t) static_cast(0) } }, - { "lineno", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_lineno), (intptr_t) static_cast(0) } }, - { "colno", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_colno), (intptr_t) static_cast(0) } }, - { "error", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_error), (intptr_t) static_cast(0) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsErrorEventConstructor), (intptr_t) static_cast(0) } }, + { "message"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_message), (intptr_t) static_cast(0) } }, + { "filename"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_filename), (intptr_t) static_cast(0) } }, + { "lineno"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_lineno), (intptr_t) static_cast(0) } }, + { "colno"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_colno), (intptr_t) static_cast(0) } }, + { "error"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsErrorEvent_error), (intptr_t) static_cast(0) } }, }; const ClassInfo JSErrorEventPrototype::s_info = { "ErrorEvent"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSErrorEventPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSEvent.cpp b/src/javascript/jsc/bindings/webcore/JSEvent.cpp index 058298923e..fc729b4c86 100644 --- a/src/javascript/jsc/bindings/webcore/JSEvent.cpp +++ b/src/javascript/jsc/bindings/webcore/JSEvent.cpp @@ -128,17 +128,17 @@ static const struct CompactHashIndex JSEventTableIndex[2] = { }; static const HashTableValue JSEventTableValues[] = { - { "isTrusted", static_cast(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_isTrusted), (intptr_t) static_cast(0) } }, + { "isTrusted"_s, static_cast(JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_isTrusted), (intptr_t) static_cast(0) } }, }; static const HashTable JSEventTable = { 1, 1, true, JSEvent::info(), JSEventTableValues, JSEventTableIndex }; /* Hash table for constructor */ static const HashTableValue JSEventConstructorTableValues[] = { - { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, - { "CAPTURING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, - { "AT_TARGET", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, - { "BUBBLING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, + { "NONE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, + { "CAPTURING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, + { "AT_TARGET"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, + { "BUBBLING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, }; static_assert(Event::NONE == 0, "NONE in Event does not match value from IDL"); @@ -194,28 +194,28 @@ template<> void JSEventDOMConstructor::initializeProperties(VM& vm, JSDOMGlobalO /* Hash table for prototype */ static const HashTableValue JSEventPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsEventConstructor), (intptr_t) static_cast(0) } }, - { "type", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_type), (intptr_t) static_cast(0) } }, - { "target", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_target), (intptr_t) static_cast(0) } }, - { "currentTarget", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_currentTarget), (intptr_t) static_cast(0) } }, - { "eventPhase", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_eventPhase), (intptr_t) static_cast(0) } }, - { "cancelBubble", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_cancelBubble), (intptr_t) static_cast(setJSEvent_cancelBubble) } }, - { "bubbles", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_bubbles), (intptr_t) static_cast(0) } }, - { "cancelable", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_cancelable), (intptr_t) static_cast(0) } }, - { "defaultPrevented", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_defaultPrevented), (intptr_t) static_cast(0) } }, - { "composed", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_composed), (intptr_t) static_cast(0) } }, - { "timeStamp", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_timeStamp), (intptr_t) static_cast(0) } }, - { "srcElement", static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_srcElement), (intptr_t) static_cast(0) } }, - { "returnValue", static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_returnValue), (intptr_t) static_cast(setJSEvent_returnValue) } }, - { "composedPath", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_composedPath), (intptr_t)(0) } }, - { "stopPropagation", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_stopPropagation), (intptr_t)(0) } }, - { "stopImmediatePropagation", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_stopImmediatePropagation), (intptr_t)(0) } }, - { "preventDefault", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_preventDefault), (intptr_t)(0) } }, - { "initEvent", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_initEvent), (intptr_t)(1) } }, - { "NONE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, - { "CAPTURING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, - { "AT_TARGET", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, - { "BUBBLING_PHASE", JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsEventConstructor), (intptr_t) static_cast(0) } }, + { "type"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_type), (intptr_t) static_cast(0) } }, + { "target"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_target), (intptr_t) static_cast(0) } }, + { "currentTarget"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_currentTarget), (intptr_t) static_cast(0) } }, + { "eventPhase"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_eventPhase), (intptr_t) static_cast(0) } }, + { "cancelBubble"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_cancelBubble), (intptr_t) static_cast(setJSEvent_cancelBubble) } }, + { "bubbles"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_bubbles), (intptr_t) static_cast(0) } }, + { "cancelable"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_cancelable), (intptr_t) static_cast(0) } }, + { "defaultPrevented"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_defaultPrevented), (intptr_t) static_cast(0) } }, + { "composed"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_composed), (intptr_t) static_cast(0) } }, + { "timeStamp"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_timeStamp), (intptr_t) static_cast(0) } }, + { "srcElement"_s, static_cast(JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_srcElement), (intptr_t) static_cast(0) } }, + { "returnValue"_s, static_cast(JSC::PropertyAttribute::CustomAccessor | JSC::PropertyAttribute::DOMAttribute), NoIntrinsic, { (intptr_t) static_cast(jsEvent_returnValue), (intptr_t) static_cast(setJSEvent_returnValue) } }, + { "composedPath"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_composedPath), (intptr_t)(0) } }, + { "stopPropagation"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_stopPropagation), (intptr_t)(0) } }, + { "stopImmediatePropagation"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_stopImmediatePropagation), (intptr_t)(0) } }, + { "preventDefault"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_preventDefault), (intptr_t)(0) } }, + { "initEvent"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventPrototypeFunction_initEvent), (intptr_t)(1) } }, + { "NONE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(0) } }, + { "CAPTURING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(1) } }, + { "AT_TARGET"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(2) } }, + { "BUBBLING_PHASE"_s, JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::ConstantInteger, NoIntrinsic, { (long long)(3) } }, }; const ClassInfo JSEventPrototype::s_info = { "Event"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSEventPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp b/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp index fb5a35a487..15f282ef86 100644 --- a/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp +++ b/src/javascript/jsc/bindings/webcore/JSEventTarget.cpp @@ -148,10 +148,10 @@ template<> void JSEventTargetDOMConstructor::initializeProperties(VM& vm, JSDOMG /* Hash table for prototype */ static const HashTableValue JSEventTargetPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetConstructor), (intptr_t) static_cast(0) } }, - { "addEventListener", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_addEventListener), (intptr_t)(2) } }, - { "removeEventListener", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_removeEventListener), (intptr_t)(2) } }, - { "dispatchEvent", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_dispatchEvent), (intptr_t)(1) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetConstructor), (intptr_t) static_cast(0) } }, + { "addEventListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_addEventListener), (intptr_t)(2) } }, + { "removeEventListener"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_removeEventListener), (intptr_t)(2) } }, + { "dispatchEvent"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsEventTargetPrototypeFunction_dispatchEvent), (intptr_t)(1) } }, }; const ClassInfo JSEventTargetPrototype::s_info = { "EventTarget"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSEventTargetPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp b/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp index 9ac6cd9f8e..8ea72b5674 100644 --- a/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp +++ b/src/javascript/jsc/bindings/webcore/JSFetchHeaders.cpp @@ -151,16 +151,16 @@ template<> void JSFetchHeadersDOMConstructor::initializeProperties(VM& vm, JSDOM /* Hash table for prototype */ static const HashTableValue JSFetchHeadersPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersConstructor), (intptr_t) static_cast(0) } }, - { "append", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_append), (intptr_t)(2) } }, - { "delete", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_delete), (intptr_t)(1) } }, - { "get", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_get), (intptr_t)(1) } }, - { "has", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_has), (intptr_t)(1) } }, - { "set", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_set), (intptr_t)(2) } }, - { "entries", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_entries), (intptr_t)(0) } }, - { "keys", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_keys), (intptr_t)(0) } }, - { "values", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_values), (intptr_t)(0) } }, - { "forEach", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_forEach), (intptr_t)(1) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersConstructor), (intptr_t) static_cast(0) } }, + { "append"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_append), (intptr_t)(2) } }, + { "delete"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_delete), (intptr_t)(1) } }, + { "get"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_get), (intptr_t)(1) } }, + { "has"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_has), (intptr_t)(1) } }, + { "set"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_set), (intptr_t)(2) } }, + { "entries"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_entries), (intptr_t)(0) } }, + { "keys"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_keys), (intptr_t)(0) } }, + { "values"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_values), (intptr_t)(0) } }, + { "forEach"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsFetchHeadersPrototypeFunction_forEach), (intptr_t)(1) } }, }; const ClassInfo JSFetchHeadersPrototype::s_info = { "Headers"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSFetchHeadersPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp index e404322cba..7934bf0049 100644 --- a/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp +++ b/src/javascript/jsc/bindings/webcore/JSReadableStream.cpp @@ -123,7 +123,8 @@ void JSReadableStreamPrototype::finishCreation(VM& vm) { Base::finishCreation(vm); auto clientData = WebCore::clientData(vm); - this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), jsNumber(0), JSC::PropertyAttribute::ReadOnly | JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); + this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); + this->putDirect(vm, clientData->builtinNames().bunNativeTypePrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); reifyStaticProperties(vm, JSReadableStream::info(), JSReadableStreamPrototypeTableValues, *this); JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); } diff --git a/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp index c27e0918b4..af62fd5113 100644 --- a/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp +++ b/src/javascript/jsc/bindings/webcore/JSReadableStreamSource.cpp @@ -105,7 +105,8 @@ void JSReadableStreamSourcePrototype::finishCreation(VM& vm) Base::finishCreation(vm); // -- BUN ADDITION -- auto clientData = WebCore::clientData(vm); - this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), JSC::jsUndefined(), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); + this->putDirect(vm, clientData->builtinNames().bunNativePtrPrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); + this->putDirect(vm, clientData->builtinNames().bunNativeTypePrivateName(), jsNumber(0), JSC::PropertyAttribute::DontEnum | JSC::PropertyAttribute::DontDelete | 0); // -- BUN ADDITION -- reifyStaticProperties(vm, JSReadableStreamSource::info(), JSReadableStreamSourcePrototypeTableValues, *this); diff --git a/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp b/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp index 0387313713..e132aecf82 100644 --- a/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp +++ b/src/javascript/jsc/bindings/webcore/JSURLSearchParams.cpp @@ -155,19 +155,19 @@ template<> void JSURLSearchParamsDOMConstructor::initializeProperties(VM& vm, JS /* Hash table for prototype */ static const HashTableValue JSURLSearchParamsPrototypeTableValues[] = { - { "constructor", static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsConstructor), (intptr_t) static_cast(0) } }, - { "append", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_append), (intptr_t)(2) } }, - { "delete", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_delete), (intptr_t)(1) } }, - { "get", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_get), (intptr_t)(1) } }, - { "getAll", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_getAll), (intptr_t)(1) } }, - { "has", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_has), (intptr_t)(1) } }, - { "set", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_set), (intptr_t)(2) } }, - { "sort", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_sort), (intptr_t)(0) } }, - { "entries", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_entries), (intptr_t)(0) } }, - { "keys", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_keys), (intptr_t)(0) } }, - { "values", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_values), (intptr_t)(0) } }, - { "forEach", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_forEach), (intptr_t)(1) } }, - { "toString", static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_toString), (intptr_t)(0) } }, + { "constructor"_s, static_cast(JSC::PropertyAttribute::DontEnum), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsConstructor), (intptr_t) static_cast(0) } }, + { "append"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_append), (intptr_t)(2) } }, + { "delete"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_delete), (intptr_t)(1) } }, + { "get"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_get), (intptr_t)(1) } }, + { "getAll"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_getAll), (intptr_t)(1) } }, + { "has"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_has), (intptr_t)(1) } }, + { "set"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_set), (intptr_t)(2) } }, + { "sort"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_sort), (intptr_t)(0) } }, + { "entries"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_entries), (intptr_t)(0) } }, + { "keys"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_keys), (intptr_t)(0) } }, + { "values"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_values), (intptr_t)(0) } }, + { "forEach"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_forEach), (intptr_t)(1) } }, + { "toString"_s, static_cast(JSC::PropertyAttribute::Function), NoIntrinsic, { (intptr_t) static_cast(jsURLSearchParamsPrototypeFunction_toString), (intptr_t)(0) } }, }; const ClassInfo JSURLSearchParamsPrototype::s_info = { "URLSearchParams"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSURLSearchParamsPrototype) }; diff --git a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp index f95b5f194c..4c9660e265 100644 --- a/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp +++ b/src/javascript/jsc/bindings/webcore/WebCoreTypedArrayController.cpp @@ -35,11 +35,6 @@ #include "JavaScriptCore/JSArrayBuffer.h" -namespace JSC { -TypedArrayController::TypedArrayController() {} -TypedArrayController::~TypedArrayController() {} -} - namespace WebCore { WebCoreTypedArrayController::WebCoreTypedArrayController(bool allowAtomicsWait) diff --git a/src/javascript/jsc/bindings/webcore/weak_handle.cpp b/src/javascript/jsc/bindings/webcore/weak_handle.cpp new file mode 100644 index 0000000000..e210a5ba18 --- /dev/null +++ b/src/javascript/jsc/bindings/webcore/weak_handle.cpp @@ -0,0 +1,21 @@ + +#include "weak_handle.h" +#include "JavaScriptCore/WeakHandleOwner.h" + +namespace JSC { +class SlotVisitor; +template class Handle; + +// WeakHandleOwner::~WeakHandleOwner() +// { +// } + +// bool WeakHandleOwner::isReachableFromOpaqueRoots(Handle, void*, AbstractSlotVisitor&, const char**) +// { +// return false; +// } + +// void WeakHandleOwner::finalize(Handle, void*) +// { +// } +} \ No newline at end of file diff --git a/src/javascript/jsc/bindings/webcore/weak_handle.h b/src/javascript/jsc/bindings/webcore/weak_handle.h index 2a0f8b5f8c..22d6e702c5 100644 --- a/src/javascript/jsc/bindings/webcore/weak_handle.h +++ b/src/javascript/jsc/bindings/webcore/weak_handle.h @@ -4,20 +4,4 @@ namespace JSC { -class SlotVisitor; -template class Handle; - -WeakHandleOwner::~WeakHandleOwner() -{ -} - -bool WeakHandleOwner::isReachableFromOpaqueRoots(Handle, void*, AbstractSlotVisitor&, const char**) -{ - return false; -} - -void WeakHandleOwner::finalize(Handle, void*) -{ -} - } // namespace JSC diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig index 19b738add4..b6b9283fa1 100644 --- a/src/memory_allocator.zig +++ b/src/memory_allocator.zig @@ -214,3 +214,128 @@ const z_allocator_vtable = Allocator.VTable{ .resize = ZAllocator.resize, .free = ZAllocator.free, }; + +const HugeAllocator = struct { + fn alloc( + _: *anyopaque, + len: usize, + alignment: u29, + len_align: u29, + return_address: usize, + ) error{OutOfMemory}![]u8 { + _ = return_address; + assert(len > 0); + assert(std.math.isPowerOfTwo(alignment)); + + var slice = std.os.mmap( + null, + len, + std.os.PROT.READ | std.os.PROT.WRITE, + std.os.MAP.ANONYMOUS | std.os.MAP.PRIVATE, + -1, + 0, + ) catch + return error.OutOfMemory; + + _ = len_align; + return slice; + } + + fn resize( + _: *anyopaque, + _: []u8, + _: u29, + _: usize, + _: u29, + _: usize, + ) ?usize { + return null; + } + + fn free( + _: *anyopaque, + buf: []u8, + _: u29, + _: usize, + ) void { + std.os.munmap(@alignCast(std.meta.alignment([]align(std.mem.page_size) u8), buf)); + } +}; + +pub const huge_allocator = Allocator{ + .ptr = undefined, + .vtable = &huge_allocator_vtable, +}; +const huge_allocator_vtable = Allocator.VTable{ + .alloc = HugeAllocator.alloc, + .resize = HugeAllocator.resize, + .free = HugeAllocator.free, +}; + +const AutoSizeAllocator = struct { + fn alloc( + _: *anyopaque, + len: usize, + alignment: u29, + len_align: u29, + return_address: usize, + ) error{OutOfMemory}![]u8 { + if (len > 1024 * 1024 * 2) { + return huge_allocator.rawAlloc( + len, + alignment, + len_align, + return_address, + ); + } + + return c_allocator.rawAlloc( + len, + alignment, + len_align, + return_address, + ); + } + + fn resize( + _: *anyopaque, + _: []u8, + _: u29, + _: usize, + _: u29, + _: usize, + ) ?usize { + return null; + } + + fn free( + _: *anyopaque, + buf: []u8, + a: u29, + b: usize, + ) void { + if (buf.len > 1024 * 1024 * 2) { + return huge_allocator.rawFree( + buf, + a, + b, + ); + } + + return c_allocator.rawFree( + buf, + a, + b, + ); + } +}; + +pub const auto_allocator = Allocator{ + .ptr = undefined, + .vtable = &auto_allocator_vtable, +}; +const auto_allocator_vtable = Allocator.VTable{ + .alloc = AutoSizeAllocator.alloc, + .resize = AutoSizeAllocator.resize, + .free = AutoSizeAllocator.free, +}; diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 6846e39c6b..094d63f91e 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -108,7 +108,7 @@ pub inline fn indexOf(self: string, str: string) ?usize { } // -- -// This is faster when the string is found, by about 2x for a 4 MB file. +// This is faster when the string is found, by about 2x for a 8 MB file. // It is slower when the string is NOT found // fn indexOfPosN(comptime T: type, buf: []const u8, start_index: usize, delimiter: []const u8, comptime n: comptime_int) ?usize { // const k = delimiter.len;