mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 23:18:47 +00:00
Compare commits
1 Commits
dylan/pyth
...
ben/transl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1375f27ea5 |
57
build.zig
57
build.zig
@@ -508,34 +508,35 @@ fn getTranslateC(b: *Build, initial_target: std.Build.ResolvedTarget, optimize:
|
||||
translate_c.defineCMacroRaw(b.fmt("{s}={d}", .{ str, @intFromBool(value) }));
|
||||
}
|
||||
|
||||
if (target.result.os.tag == .windows) {
|
||||
// translate-c is unable to translate the unsuffixed windows functions
|
||||
// like `SetCurrentDirectory` since they are defined with an odd macro
|
||||
// that translate-c doesn't handle.
|
||||
//
|
||||
// #define SetCurrentDirectory __MINGW_NAME_AW(SetCurrentDirectory)
|
||||
//
|
||||
// In these cases, it's better to just reference the underlying function
|
||||
// directly: SetCurrentDirectoryW. To make the error better, a post
|
||||
// processing step is applied to the translate-c file.
|
||||
//
|
||||
// Additionally, this step makes it so that decls like NTSTATUS and
|
||||
// HANDLE point to the standard library structures.
|
||||
const helper_exe = b.addExecutable(.{
|
||||
.name = "process_windows_translate_c",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/codegen/process_windows_translate_c.zig"),
|
||||
.target = b.graph.host,
|
||||
.optimize = .Debug,
|
||||
}),
|
||||
});
|
||||
const in = translate_c.getOutput();
|
||||
const run = b.addRunArtifact(helper_exe);
|
||||
run.addFileArg(in);
|
||||
const out = run.addOutputFileArg("c-headers-for-zig.zig");
|
||||
return out;
|
||||
}
|
||||
return translate_c.getOutput();
|
||||
// translate-c is unable to translate the unsuffixed windows functions
|
||||
// like `SetCurrentDirectory` since they are defined with an odd macro
|
||||
// that translate-c doesn't handle.
|
||||
//
|
||||
// #define SetCurrentDirectory __MINGW_NAME_AW(SetCurrentDirectory)
|
||||
//
|
||||
// In these cases, it's better to just reference the underlying function
|
||||
// directly: SetCurrentDirectoryW. To make the error better, a post
|
||||
// processing step is applied to the translate-c file.
|
||||
//
|
||||
// Additionally, this step makes it so that decls like NTSTATUS and
|
||||
// HANDLE point to the standard library structures.
|
||||
//
|
||||
// We also use this to replace some `opaque` declarations generated by
|
||||
// translate-c with their equivalents defined in our own Zig code,
|
||||
// since our definitions have useful declarations on them.
|
||||
const helper_exe = b.addExecutable(.{
|
||||
.name = "process_translate_c",
|
||||
.root_module = b.createModule(.{
|
||||
.root_source_file = b.path("src/codegen/process_translate_c.zig"),
|
||||
.target = b.graph.host,
|
||||
.optimize = .Debug,
|
||||
}),
|
||||
});
|
||||
const in = translate_c.getOutput();
|
||||
const run = b.addRunArtifact(helper_exe);
|
||||
run.addFileArg(in);
|
||||
const out = run.addOutputFileArg("c-headers-for-zig.zig");
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn addBunObject(b: *Build, opts: *BunBuildOptions) *Compile {
|
||||
|
||||
@@ -201,131 +201,6 @@ pub const Reader = struct {
|
||||
const value = @as(*align(1) u64, @ptrFromInt(addr)).*;
|
||||
return JSValue.fromUInt64NoTruncate(globalObject, value);
|
||||
}
|
||||
|
||||
pub fn u8WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u8, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn u16WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u16, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn u32WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn ptrWithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn i8WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i8, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn i16WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i16, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn i32WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
pub fn intptrWithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
|
||||
pub fn f32WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) f32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
|
||||
pub fn f64WithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) f64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
}
|
||||
|
||||
pub fn u64WithoutTypeChecks(
|
||||
global: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u64, @ptrFromInt(addr)).*;
|
||||
return JSValue.fromUInt64NoTruncate(global, value);
|
||||
}
|
||||
|
||||
pub fn i64WithoutTypeChecks(
|
||||
global: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i64, @ptrFromInt(addr)).*;
|
||||
return JSValue.fromInt64NoTruncate(global, value);
|
||||
}
|
||||
};
|
||||
|
||||
pub fn ptr(
|
||||
@@ -340,14 +215,6 @@ pub fn ptr(
|
||||
};
|
||||
}
|
||||
|
||||
pub fn ptrWithoutTypeChecks(
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
array: *JSC.JSUint8Array,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
return JSValue.fromPtrAddress(@intFromPtr(array.ptr()));
|
||||
}
|
||||
|
||||
fn ptr_(
|
||||
globalThis: *JSGlobalObject,
|
||||
value: JSValue,
|
||||
|
||||
@@ -42,30 +42,13 @@ export default [
|
||||
proto: {
|
||||
getRandomValues: {
|
||||
fn: "getRandomValues",
|
||||
// https://discord.com/channels/876711213126520882/1276103693665828894/1276133319033229363
|
||||
// https://discord.com/channels/876711213126520882/1276103693665828894/1276127092047609919
|
||||
// DOMJIT: {
|
||||
// returns: "JSValue",
|
||||
// "pure": false,
|
||||
// args: ["JSUint8Array"],
|
||||
// },
|
||||
},
|
||||
randomUUID: {
|
||||
fn: "randomUUID",
|
||||
length: 1,
|
||||
DOMJIT: {
|
||||
returns: "JSString",
|
||||
"pure": false,
|
||||
args: [],
|
||||
},
|
||||
},
|
||||
timingSafeEqual: {
|
||||
fn: "timingSafeEqual",
|
||||
DOMJIT: {
|
||||
returns: "JSValue",
|
||||
"pure": false,
|
||||
args: ["JSUint8Array", "JSUint8Array"],
|
||||
},
|
||||
length: 2,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -214,44 +214,18 @@ export default [
|
||||
sendText: {
|
||||
fn: "sendText",
|
||||
length: 2,
|
||||
// ASSERTION FAILED: m_data[index].lockCount
|
||||
// /Users/jarred/actions-runner/_work/WebKit/WebKit/Source/JavaScriptCore/dfg/DFGRegisterBank.h(204) : void JSC::DFG::RegisterBank<JSC::GPRInfo>::unlock(RegID) [BankInfo = JSC::GPRInfo]
|
||||
// 1 0x102740124 WTFCrash
|
||||
// 3 0x103076bac JSC::MacroAssemblerARM64::add64(JSC::AbstractMacroAssembler<JSC::ARM64Assembler>::TrustedImm64, JSC::ARM64Registers::RegisterID, JSC::ARM64Registers::RegisterID)
|
||||
// 4 0x10309a2d0 JSC::DFG::SpeculativeJIT::compileCallDOM(JSC::DFG::Node*)::$_0::operator()(JSC::DFG::Edge) const
|
||||
// DOMJIT: {
|
||||
// returns: "int",
|
||||
// args: ["JSString", "bool"],
|
||||
// },
|
||||
},
|
||||
sendBinary: {
|
||||
fn: "sendBinary",
|
||||
length: 2,
|
||||
// ASSERTION FAILED: m_data[index].lockCount
|
||||
// /Users/jarred/actions-runner/_work/WebKit/WebKit/Source/JavaScriptCore/dfg/DFGRegisterBank.h(204) : void JSC::DFG::RegisterBank<JSC::GPRInfo>::unlock(RegID) [BankInfo = JSC::GPRInfo]
|
||||
// 1 0x102740124 WTFCrash
|
||||
// 3 0x103076bac JSC::MacroAssemblerARM64::add64(JSC::AbstractMacroAssembler<JSC::ARM64Assembler>::TrustedImm64, JSC::ARM64Registers::RegisterID, JSC::ARM64Registers::RegisterID)
|
||||
// 4 0x10309a2d0 JSC::DFG::SpeculativeJIT::compileCallDOM(JSC::DFG::Node*)::$_0::operator()(JSC::DFG::Edge) const
|
||||
// DOMJIT: {
|
||||
// returns: "int",
|
||||
// args: ["JSUint8Array", "bool"],
|
||||
// },
|
||||
},
|
||||
publishText: {
|
||||
fn: "publishText",
|
||||
length: 2,
|
||||
DOMJIT: {
|
||||
returns: "int",
|
||||
args: ["JSString", "JSString"],
|
||||
},
|
||||
},
|
||||
publishBinary: {
|
||||
fn: "publishBinary",
|
||||
length: 2,
|
||||
DOMJIT: {
|
||||
returns: "int",
|
||||
args: ["JSString", "JSUint8Array"],
|
||||
},
|
||||
},
|
||||
ping: {
|
||||
fn: "ping",
|
||||
|
||||
@@ -572,87 +572,6 @@ pub fn publishBinary(
|
||||
);
|
||||
}
|
||||
|
||||
pub fn publishBinaryWithoutTypeChecks(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
topic_str: *JSC.JSString,
|
||||
array: *JSC.JSUint8Array,
|
||||
) bun.JSError!JSC.JSValue {
|
||||
const app = this.handler.app orelse {
|
||||
log("publish() closed", .{});
|
||||
return JSValue.jsNumber(0);
|
||||
};
|
||||
const flags = this.handler.flags;
|
||||
const ssl = flags.ssl;
|
||||
const publish_to_self = flags.publish_to_self;
|
||||
|
||||
var topic_slice = topic_str.toSlice(globalThis, bun.default_allocator);
|
||||
defer topic_slice.deinit();
|
||||
if (topic_slice.len == 0) {
|
||||
return globalThis.throw("publishBinary requires a non-empty topic", .{});
|
||||
}
|
||||
|
||||
const compress = true;
|
||||
|
||||
const buffer = array.slice();
|
||||
if (buffer.len == 0) {
|
||||
return JSC.JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
const result = if (!publish_to_self and !this.isClosed())
|
||||
this.websocket().publish(topic_slice.slice(), buffer, .binary, compress)
|
||||
else
|
||||
uws.AnyWebSocket.publishWithOptions(ssl, app, topic_slice.slice(), buffer, .binary, compress);
|
||||
|
||||
return JSValue.jsNumber(
|
||||
// if 0, return 0
|
||||
// else return number of bytes sent
|
||||
if (result) @as(i32, @intCast(@as(u31, @truncate(buffer.len)))) else @as(i32, 0),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn publishTextWithoutTypeChecks(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
topic_str: *JSC.JSString,
|
||||
str: *JSC.JSString,
|
||||
) bun.JSError!JSC.JSValue {
|
||||
const app = this.handler.app orelse {
|
||||
log("publish() closed", .{});
|
||||
return JSValue.jsNumber(0);
|
||||
};
|
||||
const flags = this.handler.flags;
|
||||
const ssl = flags.ssl;
|
||||
const publish_to_self = flags.publish_to_self;
|
||||
|
||||
var topic_slice = topic_str.toSlice(globalThis, bun.default_allocator);
|
||||
defer topic_slice.deinit();
|
||||
if (topic_slice.len == 0) {
|
||||
return globalThis.throw("publishBinary requires a non-empty topic", .{});
|
||||
}
|
||||
|
||||
const compress = true;
|
||||
|
||||
const slice = str.toSlice(globalThis, bun.default_allocator);
|
||||
defer slice.deinit();
|
||||
const buffer = slice.slice();
|
||||
|
||||
if (buffer.len == 0) {
|
||||
return JSC.JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
const result = if (!publish_to_self and !this.isClosed())
|
||||
this.websocket().publish(topic_slice.slice(), buffer, .text, compress)
|
||||
else
|
||||
uws.AnyWebSocket.publishWithOptions(ssl, app, topic_slice.slice(), buffer, .text, compress);
|
||||
|
||||
return JSValue.jsNumber(
|
||||
// if 0, return 0
|
||||
// else return number of bytes sent
|
||||
if (result) @as(i32, @intCast(@as(u31, @truncate(buffer.len)))) else @as(i32, 0),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn cork(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
@@ -826,37 +745,6 @@ pub fn sendText(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sendTextWithoutTypeChecks(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
message_str: *JSC.JSString,
|
||||
compress: bool,
|
||||
) JSValue {
|
||||
if (this.isClosed()) {
|
||||
log("sendText() closed", .{});
|
||||
return JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
var string_slice = message_str.toSlice(globalThis, bun.default_allocator);
|
||||
defer string_slice.deinit();
|
||||
|
||||
const buffer = string_slice.slice();
|
||||
switch (this.websocket().send(buffer, .text, compress, true)) {
|
||||
.backpressure => {
|
||||
log("sendText() backpressure ({d} bytes string)", .{buffer.len});
|
||||
return JSValue.jsNumber(-1);
|
||||
},
|
||||
.success => {
|
||||
log("sendText() success ({d} bytes string)", .{buffer.len});
|
||||
return JSValue.jsNumber(buffer.len);
|
||||
},
|
||||
.dropped => {
|
||||
log("sendText() dropped ({d} bytes string)", .{buffer.len});
|
||||
return JSValue.jsNumber(0);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sendBinary(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
@@ -903,35 +791,6 @@ pub fn sendBinary(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sendBinaryWithoutTypeChecks(
|
||||
this: *ServerWebSocket,
|
||||
_: *JSC.JSGlobalObject,
|
||||
array_buffer: *JSC.JSUint8Array,
|
||||
compress: bool,
|
||||
) JSValue {
|
||||
if (this.isClosed()) {
|
||||
log("sendBinary() closed", .{});
|
||||
return JSValue.jsNumber(0);
|
||||
}
|
||||
|
||||
const buffer = array_buffer.slice();
|
||||
|
||||
switch (this.websocket().send(buffer, .binary, compress, true)) {
|
||||
.backpressure => {
|
||||
log("sendBinary() backpressure ({d} bytes)", .{buffer.len});
|
||||
return JSValue.jsNumber(-1);
|
||||
},
|
||||
.success => {
|
||||
log("sendBinary() success ({d} bytes)", .{buffer.len});
|
||||
return JSValue.jsNumber(buffer.len);
|
||||
},
|
||||
.dropped => {
|
||||
log("sendBinary() dropped ({d} bytes)", .{buffer.len});
|
||||
return JSValue.jsNumber(0);
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ping(
|
||||
this: *ServerWebSocket,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
|
||||
@@ -1960,30 +1960,6 @@ static JSC::EncodedJSValue jsBufferPrototypeFunction_SliceWithEncoding(JSC::JSGl
|
||||
return jsBufferToString(lexicalGlobalObject, scope, castedThis, start, end - start, encoding);
|
||||
}
|
||||
|
||||
// DOMJIT makes it slower! TODO: investigate why
|
||||
// JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(jsBufferPrototypeToStringWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSC::JSUint8Array* thisValue, JSC::JSString* encodingValue));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(jsBufferPrototypeToStringWithoutTypeChecks, JSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSUint8Array* thisValue, JSString* encodingValue))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
|
||||
// std::optional<BufferEncodingType> encoded = parseEnumeration<BufferEncodingType>(*lexicalGlobalObject, encodingValue);
|
||||
// if (!encoded) {
|
||||
// auto scope = DECLARE_THROW_SCOPE(vm);
|
||||
|
||||
// throwTypeError(lexicalGlobalObject, scope, "Invalid encoding"_s);
|
||||
// return {};
|
||||
// }
|
||||
|
||||
// auto encoding = encoded.value();
|
||||
|
||||
// return JSValue::decode(jsBufferToString(vm, lexicalGlobalObject, thisValue, 0, thisValue->byteLength(), encoding));
|
||||
// }
|
||||
|
||||
// https://github.com/nodejs/node/blob/2eff28fb7a93d3f672f80b582f664a7c701569fb/src/node_buffer.cc#L711
|
||||
template<BufferEncodingType encoding>
|
||||
static JSC::EncodedJSValue jsBufferPrototypeFunction_writeEncodingBody(JSC::VM& vm, JSC::JSGlobalObject* lexicalGlobalObject, JSArrayBufferView* castedThis, JSString* str, JSValue offsetValue, JSValue lengthValue)
|
||||
|
||||
@@ -13,12 +13,6 @@ pub const JSObject = opaque {
|
||||
return JSC__JSObject__maxInlineCapacity;
|
||||
}
|
||||
|
||||
extern fn JSC__JSObject__getIndex(this: JSValue, globalThis: *JSGlobalObject, i: u32) JSValue;
|
||||
extern fn JSC__JSObject__putRecord(this: *JSObject, global: *JSGlobalObject, key: *ZigString, values: [*]ZigString, len: usize) void;
|
||||
extern fn Bun__JSObject__getCodePropertyVMInquiry(global: *JSGlobalObject, obj: *JSObject) JSValue;
|
||||
extern fn JSC__createStructure(global: *JSC.JSGlobalObject, owner: *JSC.JSCell, length: u32, names: [*]ExternColumnIdentifier) JSC.JSValue;
|
||||
extern fn JSC__JSObject__create(global_object: *JSGlobalObject, length: usize, ctx: *anyopaque, initializer: InitializeCallback) JSValue;
|
||||
|
||||
pub fn toJS(obj: *JSObject) JSValue {
|
||||
return JSValue.fromCell(obj);
|
||||
}
|
||||
@@ -133,28 +127,28 @@ pub const JSObject = opaque {
|
||||
|
||||
pub fn Initializer(comptime Ctx: type, comptime func: fn (*Ctx, obj: *JSObject, global: *JSGlobalObject) void) type {
|
||||
return struct {
|
||||
pub fn call(this: *anyopaque, obj: *JSObject, global: *JSGlobalObject) callconv(.C) void {
|
||||
@call(bun.callmod_inline, func, .{ @as(*Ctx, @ptrCast(@alignCast(this))), obj, global });
|
||||
pub fn call(this: ?*anyopaque, obj: *JSObject, global: *JSGlobalObject) callconv(.C) void {
|
||||
@call(bun.callmod_inline, func, .{ @as(*Ctx, @ptrCast(@alignCast(this.?))), obj, global });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn createWithInitializer(comptime Ctx: type, creator: *Ctx, global: *JSGlobalObject, length: usize) JSValue {
|
||||
const Type = Initializer(Ctx, Ctx.create);
|
||||
return JSC__JSObject__create(global, length, creator, Type.call);
|
||||
return bun.c.JSC__JSObject__create(global, length, creator, Type.call);
|
||||
}
|
||||
|
||||
pub fn getIndex(this: JSValue, globalThis: *JSGlobalObject, i: u32) JSValue {
|
||||
return JSC__JSObject__getIndex(this, globalThis, i);
|
||||
return bun.c.JSC__JSObject__getIndex(this, globalThis, i);
|
||||
}
|
||||
|
||||
pub fn putRecord(this: *JSObject, global: *JSGlobalObject, key: *ZigString, values: []ZigString) void {
|
||||
return JSC__JSObject__putRecord(this, global, key, values.ptr, values.len);
|
||||
return bun.c.JSC__JSObject__putRecord(this, global, key, values.ptr, values.len);
|
||||
}
|
||||
|
||||
/// This will not call getters or be observable from JavaScript.
|
||||
pub fn getCodePropertyVMInquiry(obj: *JSObject, global: *JSGlobalObject) ?JSValue {
|
||||
const v = Bun__JSObject__getCodePropertyVMInquiry(global, obj);
|
||||
const v = bun.c.Bun__JSObject__getCodePropertyVMInquiry(global, obj);
|
||||
if (v == .zero) return null;
|
||||
return v;
|
||||
}
|
||||
|
||||
325
src/bun.js/bindings/ZigGeneratedCode.cpp
generated
325
src/bun.js/bindings/ZigGeneratedCode.cpp
generated
@@ -15,18 +15,6 @@ using namespace WebCore;
|
||||
|
||||
/* -- BEGIN DOMCall DEFINITIONS -- */
|
||||
|
||||
// BUN_DECLARE_HOST_FUNCTION(FFI__ptr__slowpathWrapper);
|
||||
// extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array*));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(FFI__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, JSC::JSUint8Array* arg1))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { FFI__ptr__fastpath(lexicalGlobalObject, thisValue, arg1) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(FFI__ptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return FFI__ptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -35,19 +23,6 @@ JSC_DEFINE_HOST_FUNCTION(FFI__ptr__slowpathWrapper, (JSC::JSGlobalObject * globa
|
||||
extern "C" void FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_ptr_signature(
|
||||
// FFI__ptr__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecDoubleReal,
|
||||
// JSC::SpecUint8Array);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 1,
|
||||
// String("ptr"_s),
|
||||
// FFI__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, FFI__ptr__slowpathWrapper,
|
||||
// &DOMJIT_ptr_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -63,17 +38,7 @@ extern "C" void FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSV
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__u8__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__u8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__u8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__u8__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__u8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -82,21 +47,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__u8__slowpathWrapper, (JSC::JSGlobalObject * glo
|
||||
extern "C" void Reader__u8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_u8_signature(
|
||||
// Reader__u8__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("u8"_s),
|
||||
// Reader__u8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u8__slowpathWrapper,
|
||||
// &DOMJIT_u8_signature);
|
||||
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -112,17 +62,6 @@ extern "C" void Reader__u8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJ
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__u16__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__u16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__u16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__u16__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__u16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -131,20 +70,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__u16__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__u16__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_u16_signature(
|
||||
// Reader__u16__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("u16"_s),
|
||||
// Reader__u16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u16__slowpathWrapper,
|
||||
// &DOMJIT_u16_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -158,17 +83,6 @@ extern "C" void Reader__u16__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__u32__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__u32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__u32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__u32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__u32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -177,20 +91,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__u32__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__u32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_u32_signature(
|
||||
// Reader__u32__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("u32"_s),
|
||||
// Reader__u32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u32__slowpathWrapper,
|
||||
// &DOMJIT_u32_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -204,17 +104,6 @@ extern "C" void Reader__u32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__ptr__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__ptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__ptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__ptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__ptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -223,20 +112,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__ptr__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_ptr_signature(
|
||||
// Reader__ptr__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("ptr"_s),
|
||||
// Reader__ptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__ptr__slowpathWrapper,
|
||||
// &DOMJIT_ptr_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -250,17 +125,6 @@ extern "C" void Reader__ptr__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__i8__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__i8__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__i8__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__i8__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__i8__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -269,20 +133,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__i8__slowpathWrapper, (JSC::JSGlobalObject * glo
|
||||
extern "C" void Reader__i8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_i8_signature(
|
||||
// Reader__i8__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("i8"_s),
|
||||
// Reader__i8__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i8__slowpathWrapper,
|
||||
// &DOMJIT_i8_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -296,17 +146,6 @@ extern "C" void Reader__i8__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJ
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__i16__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__i16__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__i16__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__i16__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__i16__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -315,20 +154,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__i16__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__i16__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_i16_signature(
|
||||
// Reader__i16__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("i16"_s),
|
||||
// Reader__i16__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i16__slowpathWrapper,
|
||||
// &DOMJIT_i16_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -342,17 +167,6 @@ extern "C" void Reader__i16__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__i32__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__i32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__i32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__i32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__i32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -361,20 +175,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__i32__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__i32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_i32_signature(
|
||||
// Reader__i32__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt32Only,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("i32"_s),
|
||||
// Reader__i32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i32__slowpathWrapper,
|
||||
// &DOMJIT_i32_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -388,17 +188,6 @@ extern "C" void Reader__i32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__i64__slowpathWrapper);
|
||||
extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__i64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__i64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__i64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__i64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -407,20 +196,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__i64__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__i64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_i64_signature(
|
||||
// Reader__i64__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecHeapTop,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("i64"_s),
|
||||
// Reader__i64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__i64__slowpathWrapper,
|
||||
// &DOMJIT_i64_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -434,17 +209,6 @@ extern "C" void Reader__i64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__u64__slowpathWrapper);
|
||||
// extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__u64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__u64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__u64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__u64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -453,20 +217,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__u64__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__u64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_u64_signature(
|
||||
// Reader__u64__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecHeapTop,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("u64"_s),
|
||||
// Reader__u64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__u64__slowpathWrapper,
|
||||
// &DOMJIT_u64_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -480,17 +230,6 @@ extern "C" void Reader__u64__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__intptr__slowpathWrapper);
|
||||
// extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__intptr__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__intptr__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__intptr__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__intptr__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -499,20 +238,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__intptr__slowpathWrapper, (JSC::JSGlobalObject *
|
||||
extern "C" void Reader__intptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_intptr_signature(
|
||||
// Reader__intptr__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("intptr"_s),
|
||||
// Reader__intptr__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__intptr__slowpathWrapper,
|
||||
// &DOMJIT_intptr_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -526,17 +251,6 @@ extern "C" void Reader__intptr__put(JSC::JSGlobalObject* globalObject, JSC::Enco
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__f32__slowpathWrapper);
|
||||
// extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__f32__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__f32__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__f32__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__f32__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -545,20 +259,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__f32__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__f32__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_f32_signature(
|
||||
// Reader__f32__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecDoubleReal,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("f32"_s),
|
||||
// Reader__f32__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f32__slowpathWrapper,
|
||||
// &DOMJIT_f32_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
@@ -572,17 +272,6 @@ extern "C" void Reader__f32__put(JSC::JSGlobalObject* globalObject, JSC::Encoded
|
||||
}
|
||||
|
||||
BUN_DECLARE_HOST_FUNCTION(Reader__f64__slowpathWrapper);
|
||||
// extern "C" JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t, int32_t));
|
||||
|
||||
// JSC_DEFINE_JIT_OPERATION(Reader__f64__fastpathWrapper, EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue, int64_t arg1, int32_t arg2))
|
||||
// {
|
||||
// auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
// IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
// CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
// IGNORE_WARNINGS_END
|
||||
// JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
// return { Reader__f64__fastpath(lexicalGlobalObject, thisValue, arg1, arg2) };
|
||||
// }
|
||||
JSC_DEFINE_HOST_FUNCTION(Reader__f64__slowpathWrapper, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* frame))
|
||||
{
|
||||
return Reader__f64__slowpath(globalObject, JSValue::encode(frame->thisValue()), reinterpret_cast<JSC::EncodedJSValue*>(frame->addressOfArgumentsStart()), frame->argumentCount());
|
||||
@@ -591,20 +280,6 @@ JSC_DEFINE_HOST_FUNCTION(Reader__f64__slowpathWrapper, (JSC::JSGlobalObject * gl
|
||||
extern "C" void Reader__f64__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
// static const JSC::DOMJIT::Signature DOMJIT_f64_signature(
|
||||
// Reader__f64__fastpathWrapper,
|
||||
// thisObject->classInfo(),
|
||||
// JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
|
||||
// JSC::SpecDoubleReal,
|
||||
// JSC::SpecInt52Any,
|
||||
// JSC::SpecInt32Only);
|
||||
// JSFunction* function = JSFunction::create(
|
||||
// globalObject->vm(),
|
||||
// globalObject,
|
||||
// 2,
|
||||
// String("f64"_s),
|
||||
// Reader__f64__slowpathWrapper, ImplementationVisibility::Public, NoIntrinsic, Reader__f64__slowpathWrapper,
|
||||
// &DOMJIT_f64_signature);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// GENERATED FILE
|
||||
#pragma once
|
||||
|
||||
namespace Zig {
|
||||
|
||||
/* -- BEGIN DOMCall DEFINITIONS -- */
|
||||
|
||||
static void DOMCall__FFI__ptr__put(JSC::JSGlobalObject* globalObject, JSC::EncodedJSValue value)
|
||||
{
|
||||
JSC::JSObject* thisObject = JSC::jsCast<JSC::JSObject*>(JSC::JSValue::decode(value));
|
||||
static const JSC::DOMJIT::Signature DOMJIT_ptr_signature(
|
||||
FFI__ptr__fastpath,
|
||||
thisObject->classInfo(),
|
||||
JSC::DOMJIT::Effect::forPure(),
|
||||
JSC::SpecHeapTop,
|
||||
JSC::SpecUint8Array);
|
||||
JSFunction* function = JSFunction::create(
|
||||
globalObject->vm(),
|
||||
globalObject,
|
||||
1,
|
||||
String("ptr"_s),
|
||||
FFI__ptr__slowpath, ImplementationVisibility::Public, NoIntrinsic, FFI__ptr__slowpath,
|
||||
&DOMJIT_ptr_signature);
|
||||
thisObject->putDirect(
|
||||
globalObject->vm(),
|
||||
Identifier::fromString(globalObject->vm(), "ptr"_s),
|
||||
function,
|
||||
0);
|
||||
}
|
||||
|
||||
/* -- END DOMCall DEFINITIONS-- */
|
||||
|
||||
} // namespace Zig
|
||||
@@ -3025,7 +3025,7 @@ CPP_DECL void JSC__JSValue__push(JSC::EncodedJSValue JSValue0, JSC::JSGlobalObje
|
||||
}
|
||||
|
||||
JSC::EncodedJSValue JSC__JSGlobalObject__createAggregateError(JSC::JSGlobalObject* globalObject,
|
||||
const JSValue* errors, size_t errors_count,
|
||||
const EncodedJSValue* errors, size_t errors_count,
|
||||
const ZigString* arg3)
|
||||
{
|
||||
auto& vm = JSC::getVM(globalObject);
|
||||
@@ -3042,7 +3042,7 @@ JSC::EncodedJSValue JSC__JSGlobalObject__createAggregateError(JSC::JSGlobalObjec
|
||||
errors_count))) {
|
||||
|
||||
for (size_t i = 0; i < errors_count; ++i) {
|
||||
array->initializeIndexWithoutBarrier(initializationScope, i, errors[i]);
|
||||
array->initializeIndexWithoutBarrier(initializationScope, i, JSValue::decode(errors[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
54
src/bun.js/bindings/c-typedefs.h
Normal file
54
src/bun.js/bindings/c-typedefs.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "root.h"
|
||||
#define DECLARE_TYPE_FOR_C_AND_CPP(ns, T) \
|
||||
namespace ns { \
|
||||
class T; \
|
||||
} \
|
||||
using ns##__##T = ns::T
|
||||
|
||||
using JSC__EncodedJSValue = JSC::EncodedJSValue;
|
||||
// We can't handle JSUint8Array with DECLARE_TYPE_FOR_C_AND_CPP because the C++ definition is a
|
||||
// template instantiation, not a regular class
|
||||
using JSC__JSUint8Array = JSC::JSUint8Array;
|
||||
using WTF__OrdinalNumber = WTF::OrdinalNumber;
|
||||
#define AUTO_EXTERN_C extern "C"
|
||||
#else
|
||||
#ifdef _WIN32
|
||||
#define SYSV_ABI __attribute__((sysv_abi))
|
||||
#else
|
||||
#define SYSV_ABI
|
||||
#endif
|
||||
|
||||
#define DECLARE_TYPE_FOR_C_AND_CPP(ns, T) typedef struct ns##__##T ns##__##T
|
||||
typedef int64_t JSC__EncodedJSValue;
|
||||
typedef struct JSC__JSUint8Array JSC__JSUint8Array;
|
||||
typedef int WTF__OrdinalNumber;
|
||||
#define AUTO_EXTERN_C
|
||||
#endif
|
||||
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSGlobalObject);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, Exception);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSObject);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSInternalPromise);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSString);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSCell);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSMap);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, JSPromise);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, CatchScope);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, VM);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, ThrowScope);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, CallFrame);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, GetterSetter);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, CustomGetterSetter);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, SourceProvider);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(JSC, Structure);
|
||||
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WebCore, FetchHeaders);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WebCore, DOMFormData);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WebCore, AbortSignal);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WebCore, DOMURL);
|
||||
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WTF, StringImpl);
|
||||
DECLARE_TYPE_FOR_C_AND_CPP(WTF, String);
|
||||
@@ -1,9 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include "wtf/Compiler.h"
|
||||
#include "wtf/text/OrdinalNumber.h"
|
||||
#include "JavaScriptCore/JSCJSValue.h"
|
||||
#include "JavaScriptCore/ArgList.h"
|
||||
#include <set>
|
||||
#endif
|
||||
|
||||
#include "c-typedefs.h"
|
||||
|
||||
#ifndef HEADERS_HANDWRITTEN
|
||||
#define HEADERS_HANDWRITTEN
|
||||
@@ -12,10 +17,6 @@ typedef struct VirtualMachine VirtualMachine;
|
||||
// exists to make headers.h happy
|
||||
typedef struct CppWebSocket CppWebSocket;
|
||||
|
||||
namespace WTF {
|
||||
class String;
|
||||
}
|
||||
|
||||
typedef struct ZigString {
|
||||
const unsigned char* ptr;
|
||||
size_t len;
|
||||
@@ -23,22 +24,7 @@ typedef struct ZigString {
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef uint8_t BunStringTag;
|
||||
typedef union BunStringImpl {
|
||||
ZigString zig;
|
||||
void* wtf;
|
||||
} BunStringImpl;
|
||||
|
||||
#else
|
||||
namespace WTF {
|
||||
class StringImpl;
|
||||
class String;
|
||||
}
|
||||
|
||||
typedef union BunStringImpl {
|
||||
ZigString zig;
|
||||
WTF::StringImpl* wtf;
|
||||
} BunStringImpl;
|
||||
|
||||
enum class BunStringTag : uint8_t {
|
||||
Dead = 0,
|
||||
WTFStringImpl = 1,
|
||||
@@ -48,10 +34,16 @@ enum class BunStringTag : uint8_t {
|
||||
};
|
||||
#endif
|
||||
|
||||
typedef union BunStringImpl {
|
||||
ZigString zig;
|
||||
WTF__StringImpl* wtf;
|
||||
} BunStringImpl;
|
||||
|
||||
typedef struct BunString {
|
||||
BunStringTag tag;
|
||||
BunStringImpl impl;
|
||||
|
||||
#ifdef __cplusplus
|
||||
enum ZeroCopyTag { ZeroCopy };
|
||||
enum NonNullTag { NonNull };
|
||||
|
||||
@@ -80,7 +72,7 @@ typedef struct BunString {
|
||||
WTF::String toWTFString() const;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
#endif
|
||||
} BunString;
|
||||
|
||||
typedef struct ZigErrorType {
|
||||
@@ -108,9 +100,9 @@ typedef struct ResolvedSource {
|
||||
BunString source_code;
|
||||
BunString source_url;
|
||||
bool isCommonJSModule;
|
||||
JSC::EncodedJSValue cjsCustomExtension;
|
||||
JSC__EncodedJSValue cjsCustomExtension;
|
||||
void* allocator;
|
||||
JSC::EncodedJSValue jsvalue_for_export;
|
||||
JSC__EncodedJSValue jsvalue_for_export;
|
||||
uint32_t tag;
|
||||
bool needsDeref;
|
||||
bool already_bundled;
|
||||
@@ -156,7 +148,7 @@ const ZigStackFrameCode ZigStackFrameCodeGlobal = 4;
|
||||
const ZigStackFrameCode ZigStackFrameCodeWasm = 5;
|
||||
const ZigStackFrameCode ZigStackFrameCodeConstructor = 6;
|
||||
|
||||
extern "C" void __attribute((__noreturn__)) Bun__panic(const char* message, size_t length);
|
||||
AUTO_EXTERN_C void __attribute((__noreturn__)) Bun__panic(const char* message, size_t length);
|
||||
#define BUN_PANIC(message) Bun__panic(message, sizeof(message) - 1)
|
||||
|
||||
typedef struct ZigStackFramePosition {
|
||||
@@ -164,6 +156,7 @@ typedef struct ZigStackFramePosition {
|
||||
int32_t column_zero_based;
|
||||
int32_t byte_position;
|
||||
|
||||
#ifdef __cplusplus
|
||||
ALWAYS_INLINE WTF::OrdinalNumber column()
|
||||
{
|
||||
return OrdinalNumber::fromZeroBasedInt(this->column_zero_based);
|
||||
@@ -172,6 +165,7 @@ typedef struct ZigStackFramePosition {
|
||||
{
|
||||
return OrdinalNumber::fromZeroBasedInt(this->line_zero_based);
|
||||
}
|
||||
#endif
|
||||
} ZigStackFramePosition;
|
||||
|
||||
typedef struct ZigStackFrame {
|
||||
@@ -184,12 +178,12 @@ typedef struct ZigStackFrame {
|
||||
|
||||
typedef struct ZigStackTrace {
|
||||
BunString* source_lines_ptr;
|
||||
OrdinalNumber* source_lines_numbers;
|
||||
WTF__OrdinalNumber* source_lines_numbers;
|
||||
uint8_t source_lines_len;
|
||||
uint8_t source_lines_to_collect;
|
||||
ZigStackFrame* frames_ptr;
|
||||
uint8_t frames_len;
|
||||
JSC::SourceProvider* referenced_source_provider;
|
||||
JSC__SourceProvider* referenced_source_provider;
|
||||
} ZigStackTrace;
|
||||
|
||||
typedef struct ZigException {
|
||||
@@ -283,16 +277,15 @@ typedef void WebSocketClientTLS;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef struct Bun__ArrayBuffer Bun__ArrayBuffer;
|
||||
typedef struct JSC::JSUint8Array JSC::JSUint8Array;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
extern "C" void Bun__WTFStringImpl__deref(WTF::StringImpl* impl);
|
||||
extern "C" void Bun__WTFStringImpl__ref(WTF::StringImpl* impl);
|
||||
extern "C" bool BunString__fromJS(JSC::JSGlobalObject*, JSC::EncodedJSValue, BunString*);
|
||||
extern "C" JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject*, const BunString*);
|
||||
extern "C" void BunString__toWTFString(BunString*);
|
||||
AUTO_EXTERN_C void Bun__WTFStringImpl__deref(WTF::StringImpl* impl);
|
||||
AUTO_EXTERN_C void Bun__WTFStringImpl__ref(WTF::StringImpl* impl);
|
||||
AUTO_EXTERN_C bool BunString__fromJS(JSC::JSGlobalObject*, JSC::EncodedJSValue, BunString*);
|
||||
AUTO_EXTERN_C JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject*, const BunString*);
|
||||
AUTO_EXTERN_C void BunString__toWTFString(BunString*);
|
||||
|
||||
namespace Bun {
|
||||
JSC::JSString* toJS(JSC::JSGlobalObject*, BunString);
|
||||
@@ -324,13 +317,13 @@ typedef struct {
|
||||
|
||||
#include "SyntheticModuleType.h"
|
||||
|
||||
extern "C" const char* Bun__userAgent;
|
||||
AUTO_EXTERN_C const char* Bun__userAgent;
|
||||
|
||||
extern "C" ZigErrorCode Zig_ErrorCodeParserError;
|
||||
AUTO_EXTERN_C ZigErrorCode Zig_ErrorCodeParserError;
|
||||
|
||||
extern "C" void ZigString__free(const unsigned char* ptr, size_t len, void* allocator);
|
||||
AUTO_EXTERN_C void ZigString__free(const unsigned char* ptr, size_t len, void* allocator);
|
||||
|
||||
extern "C" bool Bun__transpileVirtualModule(
|
||||
AUTO_EXTERN_C bool Bun__transpileVirtualModule(
|
||||
JSC::JSGlobalObject* global,
|
||||
const BunString* specifier,
|
||||
const BunString* referrer,
|
||||
@@ -338,11 +331,11 @@ extern "C" bool Bun__transpileVirtualModule(
|
||||
BunLoaderType loader,
|
||||
ErrorableResolvedSource* result);
|
||||
|
||||
extern "C" JSC::EncodedJSValue Bun__runVirtualModule(
|
||||
AUTO_EXTERN_C JSC::EncodedJSValue Bun__runVirtualModule(
|
||||
JSC::JSGlobalObject* global,
|
||||
const BunString* specifier);
|
||||
|
||||
extern "C" JSC::JSInternalPromise* Bun__transpileFile(
|
||||
AUTO_EXTERN_C JSC::JSInternalPromise* Bun__transpileFile(
|
||||
void* bunVM,
|
||||
JSC::JSGlobalObject* global,
|
||||
BunString* specifier,
|
||||
@@ -353,54 +346,54 @@ extern "C" JSC::JSInternalPromise* Bun__transpileFile(
|
||||
bool isCommonJSRequire,
|
||||
BunLoaderType forceLoaderType);
|
||||
|
||||
extern "C" bool Bun__fetchBuiltinModule(
|
||||
AUTO_EXTERN_C bool Bun__fetchBuiltinModule(
|
||||
void* bunVM,
|
||||
JSC::JSGlobalObject* global,
|
||||
const BunString* specifier,
|
||||
const BunString* referrer,
|
||||
ErrorableResolvedSource* result);
|
||||
extern "C" bool Bun__resolveAndFetchBuiltinModule(
|
||||
AUTO_EXTERN_C bool Bun__resolveAndFetchBuiltinModule(
|
||||
void* bunVM,
|
||||
const BunString* specifier,
|
||||
ErrorableResolvedSource* result);
|
||||
|
||||
// Used in process.version
|
||||
extern "C" const char* Bun__version;
|
||||
extern "C" const char* Bun__version_with_sha;
|
||||
AUTO_EXTERN_C const char* Bun__version;
|
||||
AUTO_EXTERN_C const char* Bun__version_with_sha;
|
||||
|
||||
// Used in process.versions
|
||||
extern "C" const char* Bun__versions_boringssl;
|
||||
extern "C" const char* Bun__versions_libarchive;
|
||||
extern "C" const char* Bun__versions_mimalloc;
|
||||
extern "C" const char* Bun__versions_picohttpparser;
|
||||
extern "C" const char* Bun__versions_uws;
|
||||
extern "C" const char* Bun__versions_webkit;
|
||||
extern "C" const char* Bun__versions_libdeflate;
|
||||
extern "C" const char* Bun__versions_zig;
|
||||
extern "C" const char* Bun__versions_zlib;
|
||||
extern "C" const char* Bun__versions_tinycc;
|
||||
extern "C" const char* Bun__versions_lolhtml;
|
||||
extern "C" const char* Bun__versions_c_ares;
|
||||
extern "C" const char* Bun__versions_lshpack;
|
||||
extern "C" const char* Bun__versions_zstd;
|
||||
extern "C" const char* Bun__versions_usockets;
|
||||
AUTO_EXTERN_C const char* Bun__versions_boringssl;
|
||||
AUTO_EXTERN_C const char* Bun__versions_libarchive;
|
||||
AUTO_EXTERN_C const char* Bun__versions_mimalloc;
|
||||
AUTO_EXTERN_C const char* Bun__versions_picohttpparser;
|
||||
AUTO_EXTERN_C const char* Bun__versions_uws;
|
||||
AUTO_EXTERN_C const char* Bun__versions_webkit;
|
||||
AUTO_EXTERN_C const char* Bun__versions_libdeflate;
|
||||
AUTO_EXTERN_C const char* Bun__versions_zig;
|
||||
AUTO_EXTERN_C const char* Bun__versions_zlib;
|
||||
AUTO_EXTERN_C const char* Bun__versions_tinycc;
|
||||
AUTO_EXTERN_C const char* Bun__versions_lolhtml;
|
||||
AUTO_EXTERN_C const char* Bun__versions_c_ares;
|
||||
AUTO_EXTERN_C const char* Bun__versions_lshpack;
|
||||
AUTO_EXTERN_C const char* Bun__versions_zstd;
|
||||
AUTO_EXTERN_C const char* Bun__versions_usockets;
|
||||
|
||||
extern "C" const char* Bun__version_sha;
|
||||
AUTO_EXTERN_C const char* Bun__version_sha;
|
||||
|
||||
extern "C" void ZigString__freeGlobal(const unsigned char* ptr, size_t len);
|
||||
AUTO_EXTERN_C void ZigString__freeGlobal(const unsigned char* ptr, size_t len);
|
||||
|
||||
extern "C" size_t Bun__encoding__writeLatin1(const unsigned char* ptr, size_t len, unsigned char* to, size_t other_len, Encoding encoding);
|
||||
extern "C" size_t Bun__encoding__writeUTF16(const UChar* ptr, size_t len, unsigned char* to, size_t other_len, Encoding encoding);
|
||||
AUTO_EXTERN_C size_t Bun__encoding__writeLatin1(const unsigned char* ptr, size_t len, unsigned char* to, size_t other_len, Encoding encoding);
|
||||
AUTO_EXTERN_C size_t Bun__encoding__writeUTF16(const UChar* ptr, size_t len, unsigned char* to, size_t other_len, Encoding encoding);
|
||||
|
||||
extern "C" size_t Bun__encoding__byteLengthLatin1AsUTF8(const unsigned char* ptr, size_t len);
|
||||
extern "C" size_t Bun__encoding__byteLengthUTF16AsUTF8(const UChar* ptr, size_t len);
|
||||
AUTO_EXTERN_C size_t Bun__encoding__byteLengthLatin1AsUTF8(const unsigned char* ptr, size_t len);
|
||||
AUTO_EXTERN_C size_t Bun__encoding__byteLengthUTF16AsUTF8(const UChar* ptr, size_t len);
|
||||
|
||||
extern "C" int64_t Bun__encoding__constructFromLatin1(void*, const unsigned char* ptr, size_t len, Encoding encoding);
|
||||
extern "C" int64_t Bun__encoding__constructFromUTF16(void*, const UChar* ptr, size_t len, Encoding encoding);
|
||||
AUTO_EXTERN_C int64_t Bun__encoding__constructFromLatin1(void*, const unsigned char* ptr, size_t len, Encoding encoding);
|
||||
AUTO_EXTERN_C int64_t Bun__encoding__constructFromUTF16(void*, const UChar* ptr, size_t len, Encoding encoding);
|
||||
|
||||
extern "C" void Bun__EventLoop__runCallback1(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1);
|
||||
extern "C" void Bun__EventLoop__runCallback2(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1, JSC::EncodedJSValue arg2);
|
||||
extern "C" void Bun__EventLoop__runCallback3(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1, JSC::EncodedJSValue arg2, JSC::EncodedJSValue arg3);
|
||||
AUTO_EXTERN_C void Bun__EventLoop__runCallback1(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1);
|
||||
AUTO_EXTERN_C void Bun__EventLoop__runCallback2(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1, JSC::EncodedJSValue arg2);
|
||||
AUTO_EXTERN_C void Bun__EventLoop__runCallback3(JSC::JSGlobalObject* global, JSC::EncodedJSValue callback, JSC::EncodedJSValue thisValue, JSC::EncodedJSValue arg1, JSC::EncodedJSValue arg2, JSC::EncodedJSValue arg3);
|
||||
|
||||
/// @note throws a JS exception and returns false if a stack overflow occurs
|
||||
template<bool isStrict, bool enableAsymmetricMatchers>
|
||||
@@ -450,7 +443,7 @@ bool Bun__deepMatch(
|
||||
bool replacePropsWithAsymmetricMatchers,
|
||||
bool isMatchingObjectContaining);
|
||||
|
||||
extern "C" void Bun__remapStackFramePositions(void*, ZigStackFrame*, size_t);
|
||||
AUTO_EXTERN_C void Bun__remapStackFramePositions(void*, ZigStackFrame*, size_t);
|
||||
|
||||
namespace Inspector {
|
||||
class ScriptArguments;
|
||||
|
||||
862
src/bun.js/bindings/headers.h
generated
862
src/bun.js/bindings/headers.h
generated
File diff suppressed because it is too large
Load Diff
@@ -469,9 +469,6 @@ pub fn DOMCall(
|
||||
return jsc.toJSHostValue(globalObject, @field(Container, functionName)(globalObject, thisValue, arguments_ptr[0..arguments_len]));
|
||||
}
|
||||
|
||||
pub const fastpath = @field(Container, functionName ++ "WithoutTypeChecks");
|
||||
pub const Fastpath = @TypeOf(fastpath);
|
||||
pub const Arguments = std.meta.ArgsTuple(Fastpath);
|
||||
const PutFnType = *const fn (globalObject: *jsc.JSGlobalObject, value: jsc.JSValue) callconv(.c) void;
|
||||
const put_fn = @extern(PutFnType, .{ .name = className ++ "__" ++ functionName ++ "__put" });
|
||||
|
||||
@@ -483,7 +480,6 @@ pub fn DOMCall(
|
||||
|
||||
comptime {
|
||||
@export(&slowpath, .{ .name = className ++ "__" ++ functionName ++ "__slowpath" });
|
||||
@export(&fastpath, .{ .name = className ++ "__" ++ functionName ++ "__fastpath" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,23 +27,6 @@ pub fn timingSafeEqual(_: *@This(), global: *JSC.JSGlobalObject, callframe: *JSC
|
||||
return JSC.Node.crypto.timingSafeEqual(global, callframe);
|
||||
}
|
||||
|
||||
pub fn timingSafeEqualWithoutTypeChecks(
|
||||
_: *@This(),
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
array_a: *JSC.JSUint8Array,
|
||||
array_b: *JSC.JSUint8Array,
|
||||
) JSC.JSValue {
|
||||
const a = array_a.slice();
|
||||
const b = array_b.slice();
|
||||
|
||||
const len = a.len;
|
||||
if (b.len != len) {
|
||||
return globalThis.ERR(.CRYPTO_TIMING_SAFE_EQUAL_LENGTH, "Input buffers must have the same byte length", .{}).throw();
|
||||
}
|
||||
|
||||
return JSC.jsBoolean(bun.BoringSSL.c.CRYPTO_memcmp(a.ptr, b.ptr, len) == 0);
|
||||
}
|
||||
|
||||
pub fn getRandomValues(
|
||||
_: *@This(),
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
@@ -64,16 +47,6 @@ pub fn getRandomValues(
|
||||
return arguments[0];
|
||||
}
|
||||
|
||||
pub fn getRandomValuesWithoutTypeChecks(
|
||||
_: *@This(),
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
array: *JSC.JSUint8Array,
|
||||
) JSC.JSValue {
|
||||
const slice = array.slice();
|
||||
randomData(globalThis, slice.ptr, slice.len);
|
||||
return @as(JSC.JSValue, @enumFromInt(@as(i64, @bitCast(@intFromPtr(array)))));
|
||||
}
|
||||
|
||||
fn randomData(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
ptr: [*]u8,
|
||||
@@ -162,21 +135,6 @@ pub fn Bun__randomUUIDv7_(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallF
|
||||
return encoding.encodeWithMaxSize(globalThis, 32, &uuid.bytes);
|
||||
}
|
||||
|
||||
pub fn randomUUIDWithoutTypeChecks(
|
||||
_: *Crypto,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
const str, var bytes = bun.String.createUninitialized(.latin1, 36);
|
||||
defer str.deref();
|
||||
|
||||
// randomUUID must have been called already many times before this kicks
|
||||
// in so we can skip the rare_data pointer check.
|
||||
const uuid = globalThis.bunVM().rare_data.?.nextUUID();
|
||||
|
||||
uuid.print(bytes[0..36]);
|
||||
return str.toJS(globalThis);
|
||||
}
|
||||
|
||||
pub fn constructor(globalThis: *JSC.JSGlobalObject, _: *JSC.CallFrame) bun.JSError!*Crypto {
|
||||
return JSC.Error.ILLEGAL_CONSTRUCTOR.throw(globalThis, "Crypto is not constructable", .{});
|
||||
}
|
||||
|
||||
@@ -187,10 +187,6 @@ pub fn decode(this: *TextDecoder, globalThis: *JSC.JSGlobalObject, callframe: *J
|
||||
};
|
||||
}
|
||||
|
||||
pub fn decodeWithoutTypeChecks(this: *TextDecoder, globalThis: *JSC.JSGlobalObject, uint8array: *JSC.JSUint8Array) bun.JSError!JSValue {
|
||||
return this.decodeSlice(globalThis, uint8array.slice(), false);
|
||||
}
|
||||
|
||||
fn decodeSlice(this: *TextDecoder, globalThis: *JSC.JSGlobalObject, buffer_slice: []const u8, comptime flush: bool) bun.JSError!JSValue {
|
||||
switch (this.encoding) {
|
||||
EncodingLabel.latin1 => {
|
||||
|
||||
@@ -32,16 +32,6 @@ pub fn encode(this: *TextEncoderStreamEncoder, globalObject: *JSC.JSGlobalObject
|
||||
return this.encodeLatin1(globalObject, str.slice());
|
||||
}
|
||||
|
||||
pub fn encodeWithoutTypeChecks(this: *TextEncoderStreamEncoder, globalObject: *JSC.JSGlobalObject, input: *JSC.JSString) JSValue {
|
||||
const str = input.getZigString(globalObject);
|
||||
|
||||
if (str.is16Bit()) {
|
||||
return this.encodeUTF16(globalObject, str.utf16SliceAligned());
|
||||
}
|
||||
|
||||
return this.encodeLatin1(globalObject, str.slice());
|
||||
}
|
||||
|
||||
fn encodeLatin1(this: *TextEncoderStreamEncoder, globalObject: *JSGlobalObject, input: []const u8) JSValue {
|
||||
log("encodeLatin1: \"{s}\"", .{input});
|
||||
|
||||
@@ -185,10 +175,6 @@ pub fn flush(this: *TextEncoderStreamEncoder, globalObject: *JSGlobalObject, _:
|
||||
return flushBody(this, globalObject);
|
||||
}
|
||||
|
||||
pub fn flushWithoutTypeChecks(this: *TextEncoderStreamEncoder, globalObject: *JSGlobalObject) JSValue {
|
||||
return flushBody(this, globalObject);
|
||||
}
|
||||
|
||||
fn flushBody(this: *TextEncoderStreamEncoder, globalObject: *JSGlobalObject) JSValue {
|
||||
return if (this.pending_lead_surrogate == null)
|
||||
JSUint8Array.createEmpty(globalObject)
|
||||
|
||||
@@ -23,11 +23,6 @@ export default [
|
||||
decode: {
|
||||
fn: "decode",
|
||||
length: 1,
|
||||
|
||||
DOMJIT: {
|
||||
returns: "JSString",
|
||||
args: ["JSUint8Array"],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -42,20 +37,10 @@ export default [
|
||||
encode: {
|
||||
fn: "encode",
|
||||
length: 1,
|
||||
|
||||
DOMJIT: {
|
||||
returns: "JSUint8Array",
|
||||
args: ["JSString"],
|
||||
},
|
||||
},
|
||||
flush: {
|
||||
fn: "flush",
|
||||
length: 0,
|
||||
|
||||
DOMJIT: {
|
||||
returns: "JSUint8Array",
|
||||
args: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -69,3 +69,5 @@
|
||||
#undef lstat
|
||||
#undef fstat
|
||||
#undef stat
|
||||
|
||||
#include "bun.js/bindings/headers.h"
|
||||
|
||||
@@ -54,10 +54,6 @@ function constructorName(typeName) {
|
||||
return `JS${typeName}Constructor`;
|
||||
}
|
||||
|
||||
function DOMJITName(fnName) {
|
||||
return `${fnName}WithoutTypeChecks`;
|
||||
}
|
||||
|
||||
function argTypeName(arg) {
|
||||
return {
|
||||
["bool"]: "bool",
|
||||
@@ -68,116 +64,12 @@ function argTypeName(arg) {
|
||||
}[arg];
|
||||
}
|
||||
|
||||
function DOMJITType(type) {
|
||||
return {
|
||||
["bool"]: "JSC::SpecBoolean",
|
||||
["int"]: "JSC::SpecInt32Only",
|
||||
["JSUint8Array"]: "JSC::SpecUint8Array",
|
||||
["JSString"]: "JSC::SpecString",
|
||||
["JSValue"]: "JSC::SpecHeapTop",
|
||||
}[type];
|
||||
}
|
||||
|
||||
function ZigDOMJITArgType(type) {
|
||||
return {
|
||||
["bool"]: "bool",
|
||||
["int"]: "i32",
|
||||
["JSUint8Array"]: "*jsc.JSUint8Array",
|
||||
["JSString"]: "*jsc.JSString",
|
||||
["JSValue"]: "jsc.JSValue",
|
||||
}[type];
|
||||
}
|
||||
|
||||
function ZigDOMJITArgTypeDefinition(type, index) {
|
||||
return `arg${index}: ${ZigDOMJITArgType(type)}`;
|
||||
}
|
||||
|
||||
function ZigDOMJITFunctionType(thisName, { args, returns }) {
|
||||
return `fn (*${thisName}, *jsc.JSGlobalObject, ${args
|
||||
.map(ZigDOMJITArgType)
|
||||
.join(", ")}) callconv(jsc.conv) ${ZigDOMJITArgType("JSValue")}`;
|
||||
}
|
||||
|
||||
function DOMJITReturnType(type) {
|
||||
return {
|
||||
["bool"]: "bool",
|
||||
["int"]: "int32_t",
|
||||
["JSUint8Array"]: "JSC::JSUint8Array*",
|
||||
["JSString"]: "JSString*",
|
||||
["JSValue"]: "EncodedJSValue",
|
||||
}[type];
|
||||
}
|
||||
|
||||
function DOMJITFunctionDeclaration(jsClassName, fnName, symName, { args, returns, pure = false }) {
|
||||
const argNames = args.map((arg, i) => `${argTypeName(arg)} arg${i}`);
|
||||
const formattedArgs = argNames.length > 0 ? `, ${argNames.join(", ")}` : "";
|
||||
const domJITArgs = args.length > 0 ? `, ${args.map(DOMJITType).join(", ")}` : "";
|
||||
externs += `
|
||||
extern JSC_CALLCONV JSC::EncodedJSValue JSC_HOST_CALL_ATTRIBUTES ${DOMJITName(symName)}(void* ptr, JSC::JSGlobalObject * lexicalGlobalObject${formattedArgs});
|
||||
`;
|
||||
|
||||
return (
|
||||
`
|
||||
extern JSC_CALLCONV JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(${DOMJITName(
|
||||
fnName,
|
||||
)}Wrapper, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue${formattedArgs}));
|
||||
static const JSC::DOMJIT::Signature DOMJITSignatureFor${fnName}(${DOMJITName(fnName)}Wrapper,
|
||||
${jsClassName}::info(),
|
||||
${
|
||||
pure
|
||||
? "JSC::DOMJIT::Effect::forPure()"
|
||||
: "JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top())"
|
||||
},
|
||||
${returns === "JSString" ? "JSC::SpecString" : DOMJITType("JSValue")}${domJITArgs});
|
||||
`.trim() + "\n"
|
||||
);
|
||||
}
|
||||
|
||||
function DOMJITFunctionDefinition(jsClassName, fnName, symName, { args }, fn) {
|
||||
const argNames = args.map((arg, i) => `${argTypeName(arg)} arg${i}`);
|
||||
const formattedArgs = argNames.length > 0 ? `, ${argNames.join(", ")}` : "";
|
||||
const retArgs = argNames.length > 0 ? `, ${args.map((b, i) => "arg" + i).join(", ")}` : "";
|
||||
|
||||
return `
|
||||
JSC_DEFINE_JIT_OPERATION(${DOMJITName(
|
||||
fnName,
|
||||
)}Wrapper, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, void* thisValue${formattedArgs}))
|
||||
{
|
||||
auto& vm = JSC::getVM(lexicalGlobalObject);
|
||||
IGNORE_WARNINGS_BEGIN("frame-address")
|
||||
CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
|
||||
IGNORE_WARNINGS_END
|
||||
JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
|
||||
#if BUN_DEBUG
|
||||
${jsClassName}* wrapper = reinterpret_cast<${jsClassName}*>(thisValue);
|
||||
JSC::EncodedJSValue result = ${DOMJITName(symName)}(wrapper->wrapped(), lexicalGlobalObject${retArgs});
|
||||
JSValue decoded = JSValue::decode(result);
|
||||
if (wrapper->m_${fn}_expectedResultType) {
|
||||
if (decoded.isCell() && !decoded.isEmpty()) {
|
||||
ASSERT_WITH_MESSAGE(wrapper->m_${fn}_expectedResultType.value().has_value(), "DOMJIT function return type changed!");
|
||||
ASSERT_WITH_MESSAGE(wrapper->m_${fn}_expectedResultType.value().value() == decoded.asCell()->type(), "DOMJIT function return type changed!");
|
||||
} else {
|
||||
ASSERT_WITH_MESSAGE(!wrapper->m_${fn}_expectedResultType.value().has_value(), "DOMJIT function return type changed!");
|
||||
}
|
||||
} else if (!decoded.isEmpty()) {
|
||||
wrapper->m_${fn}_expectedResultType = decoded.isCell()
|
||||
? std::optional<JSC::JSType>(decoded.asCell()->type())
|
||||
: std::optional<JSC::JSType>(std::nullopt);
|
||||
}
|
||||
return { result };
|
||||
#endif
|
||||
return {${DOMJITName(symName)}(reinterpret_cast<${jsClassName}*>(thisValue)->wrapped(), lexicalGlobalObject${retArgs})};
|
||||
}
|
||||
`.trim();
|
||||
}
|
||||
|
||||
function zigExportName(to: Map<string, string>, symbolName: (name: string) => string, prop) {
|
||||
var { defaultValue, getter, setter, accessor, fn, DOMJIT, cache } = prop;
|
||||
var { defaultValue, getter, setter, accessor, fn, cache } = prop;
|
||||
const exportNames = {
|
||||
getter: "",
|
||||
setter: "",
|
||||
fn: "",
|
||||
DOMJIT: "",
|
||||
};
|
||||
|
||||
if (accessor) {
|
||||
@@ -194,9 +86,6 @@ function zigExportName(to: Map<string, string>, symbolName: (name: string) => st
|
||||
}
|
||||
|
||||
if (fn && !to.get(fn)) {
|
||||
if (DOMJIT) {
|
||||
to.set(DOMJITName(fn), (exportNames.DOMJIT = symbolName(DOMJITName(fn))));
|
||||
}
|
||||
to.set(fn, (exportNames.fn = symbolName(fn)));
|
||||
}
|
||||
|
||||
@@ -220,7 +109,6 @@ function propRow(
|
||||
fn,
|
||||
length = 0,
|
||||
cache,
|
||||
DOMJIT,
|
||||
enumerable = true,
|
||||
configurable = false,
|
||||
value,
|
||||
@@ -274,12 +162,6 @@ function propRow(
|
||||
} } }
|
||||
`.trim();
|
||||
} else if (fn !== undefined) {
|
||||
if (DOMJIT) {
|
||||
// { "getElementById"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction), NoIntrinsic, { HashTableValue::DOMJITFunctionType, jsTestDOMJITPrototypeFunction_getElementById, &DOMJITSignatureForTestDOMJITGetElementById } },
|
||||
return `
|
||||
{ "${name}"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function | JSC::PropertyAttribute::DOMJITFunction${extraPropertyAttributes}), NoIntrinsic, { HashTableValue::DOMJITFunctionType, ${fn}, &DOMJITSignatureFor${symbol} } }
|
||||
`.trim();
|
||||
}
|
||||
return `
|
||||
{ "${name}"_s, static_cast<unsigned>(JSC::PropertyAttribute::Function${extraPropertyAttributes}), NoIntrinsic, { HashTableValue::NativeFunctionType, ${fn}, ${
|
||||
length || 0
|
||||
@@ -912,24 +794,6 @@ function renderDecls(symbolName, typeName, proto, supportsObjectCreate = false)
|
||||
`.trim(),
|
||||
"\n",
|
||||
);
|
||||
|
||||
if (proto[name].DOMJIT) {
|
||||
rows.push(
|
||||
DOMJITFunctionDeclaration(
|
||||
className(typeName),
|
||||
symbolName(typeName, name),
|
||||
symbolName(typeName, proto[name].fn),
|
||||
proto[name].DOMJIT,
|
||||
),
|
||||
DOMJITFunctionDefinition(
|
||||
className(typeName),
|
||||
symbolName(typeName, name),
|
||||
symbolName(typeName, proto[name].fn),
|
||||
proto[name].DOMJIT,
|
||||
proto[name].fn,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1201,25 +1065,6 @@ JSC_DEFINE_HOST_FUNCTION(${symbolName(typeName, name)}Callback, (JSGlobalObject
|
||||
|
||||
ASSERT_WITH_MESSAGE(!JSValue::decode(result).isEmpty() or DECLARE_CATCH_SCOPE(vm).exception() != 0, \"${typeName}.${proto[name].fn} returned an empty value without an exception\");
|
||||
|
||||
${
|
||||
!proto[name].DOMJIT
|
||||
? ""
|
||||
: `
|
||||
JSValue decoded = JSValue::decode(result);
|
||||
if (thisObject->m_${fn}_expectedResultType) {
|
||||
if (decoded.isCell() && !decoded.isEmpty()) {
|
||||
ASSERT_WITH_MESSAGE(thisObject->m_${fn}_expectedResultType.value().has_value(), "DOMJIT function return type changed!");
|
||||
ASSERT_WITH_MESSAGE(thisObject->m_${fn}_expectedResultType.value().value() == decoded.asCell()->type(), "DOMJIT function return type changed!");
|
||||
} else {
|
||||
ASSERT_WITH_MESSAGE(!thisObject->m_${fn}_expectedResultType.value().has_value(), "DOMJIT function return type changed!");
|
||||
}
|
||||
} else if (!decoded.isEmpty()) {
|
||||
thisObject->m_${fn}_expectedResultType = decoded.isCell()
|
||||
? std::optional<JSC::JSType>(decoded.asCell()->type())
|
||||
: std::optional<JSC::JSType>(std::nullopt);
|
||||
}`
|
||||
}
|
||||
|
||||
return result;
|
||||
#endif
|
||||
|
||||
@@ -1398,8 +1243,6 @@ function generateClassHeader(typeName, obj: ClassDefinition) {
|
||||
})
|
||||
.join("\n")}
|
||||
|
||||
${domJITTypeCheckFields(proto, klass)}
|
||||
|
||||
${weakOwner}
|
||||
|
||||
${DECLARE_VISIT_CHILDREN}
|
||||
@@ -1411,23 +1254,6 @@ function generateClassHeader(typeName, obj: ClassDefinition) {
|
||||
`.trim();
|
||||
}
|
||||
|
||||
function domJITTypeCheckFields(proto, klass) {
|
||||
var output = "#if BUN_DEBUG\n";
|
||||
for (const name in proto) {
|
||||
const { DOMJIT, fn } = proto[name];
|
||||
if (!DOMJIT) continue;
|
||||
output += `std::optional<std::optional<JSC::JSType>> m_${fn}_expectedResultType = std::nullopt;\n`;
|
||||
}
|
||||
|
||||
for (const name in klass) {
|
||||
const { DOMJIT, fn } = klass[name];
|
||||
if (!DOMJIT) continue;
|
||||
output += `std::optional<std::optional<JSC::JSType>> m_${fn}_expectedResultType = std::nullopt;\n`;
|
||||
}
|
||||
output += "#endif\n";
|
||||
return output;
|
||||
}
|
||||
|
||||
function generateClassImpl(typeName, obj: ClassDefinition) {
|
||||
const {
|
||||
klass: fields,
|
||||
@@ -1945,7 +1771,7 @@ const JavaScriptCoreBindings = struct {
|
||||
{
|
||||
const exportNames = name => zigExportName(exports, name => protoSymbolName(typeName, name), proto[name]);
|
||||
for (const name in proto) {
|
||||
const { getter, setter, accessor, fn, this: thisValue = false, cache, DOMJIT } = proto[name];
|
||||
const { getter, setter, accessor, fn, this: thisValue = false, cache } = proto[name];
|
||||
const names = exportNames(name);
|
||||
if (names.getter) {
|
||||
output += `
|
||||
@@ -1983,17 +1809,6 @@ const JavaScriptCoreBindings = struct {
|
||||
}
|
||||
|
||||
if (names.fn) {
|
||||
if (names.DOMJIT) {
|
||||
const { args, returns } = DOMJIT;
|
||||
output += `
|
||||
pub fn ${names.DOMJIT}(thisValue: *${typeName}, globalObject: *jsc.JSGlobalObject, ${args
|
||||
.map(ZigDOMJITArgTypeDefinition)
|
||||
.join(", ")}) callconv(jsc.conv) jsc.JSValue {
|
||||
return @call(bun.callmod_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
output += `
|
||||
pub fn ${names.fn}(thisValue: *${typeName}, globalObject: *jsc.JSGlobalObject, callFrame: *jsc.CallFrame${proto[name].passThis ? ", js_this_value: jsc.JSValue" : ""}) callconv(jsc.conv) jsc.JSValue {
|
||||
if (comptime Environment.enable_logs) log_zig_method("${typeName}", "${name}", callFrame);
|
||||
@@ -2007,7 +1822,7 @@ const JavaScriptCoreBindings = struct {
|
||||
{
|
||||
const exportNames = name => zigExportName(exports, name => classSymbolName(typeName, name), klass[name]);
|
||||
for (const name in klass) {
|
||||
const { getter, setter, accessor, fn, this: thisValue = true, cache, DOMJIT } = klass[name];
|
||||
const { getter, setter, accessor, fn, this: thisValue = true, cache } = klass[name];
|
||||
const names = exportNames(name);
|
||||
if (names.getter) {
|
||||
output += `
|
||||
@@ -2035,19 +1850,6 @@ const JavaScriptCoreBindings = struct {
|
||||
}
|
||||
|
||||
if (names.fn) {
|
||||
if (DOMJIT) {
|
||||
const { args, returns } = DOMJIT;
|
||||
|
||||
output += `
|
||||
pub fn ${names.DOMJIT}(globalObject: *jsc.JSGlobalObject, thisValue: jsc.JSValue, ${args
|
||||
.map(ZigDOMJITArgTypeDefinition)
|
||||
.join(", ")}) callconv(jsc.conv) jsc.JSValue {
|
||||
if (comptime Environment.enable_logs) log_zig_class_domjit("${typeName}", "${name}");
|
||||
return @call(.always_inline, ${typeName}.${DOMJITName(fn)}, .{thisValue, globalObject, ${args.map((_, i) => `arg${i}`).join(", ")}});
|
||||
}
|
||||
`;
|
||||
}
|
||||
|
||||
output += `
|
||||
pub fn ${names.fn}(globalObject: *jsc.JSGlobalObject, callFrame: *jsc.CallFrame) callconv(jsc.conv) jsc.JSValue {
|
||||
if (comptime Environment.enable_logs) log_zig_class_method("${typeName}", "${name}", callFrame);
|
||||
@@ -2277,11 +2079,6 @@ const GENERATED_CLASSES_IMPL_HEADER_PRE = `
|
||||
#include <JavaScriptCore/LazyClassStructureInlines.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
|
||||
#include <JavaScriptCore/DOMJITAbstractHeap.h>
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMJITHelpers.h"
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
|
||||
#include "JSDOMConvertBufferSource.h"
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
// translate-c is unable to translate the unsuffixed windows functions
|
||||
// like `SetCurrentDirectory` since they are defined with an odd macro
|
||||
// that translate-c doesn't handle.
|
||||
//
|
||||
// #define SetCurrentDirectory __MINGW_NAME_AW(SetCurrentDirectory)
|
||||
//
|
||||
// In these cases, it's better to just reference the underlying function
|
||||
// directly: SetCurrentDirectoryW. To make the error better, a post
|
||||
// processing step is applied to the translate-c file.
|
||||
//! translate-c is unable to translate the unsuffixed windows functions
|
||||
//! like `SetCurrentDirectory` since they are defined with an odd macro
|
||||
//! that translate-c doesn't handle.
|
||||
//!
|
||||
//! #define SetCurrentDirectory __MINGW_NAME_AW(SetCurrentDirectory)
|
||||
//!
|
||||
//! In these cases, it's better to just reference the underlying function
|
||||
//! directly: SetCurrentDirectoryW. To make the error better, a post
|
||||
//! processing step is applied to the translate-c file.
|
||||
//!
|
||||
//! Additionally, this step makes it so that decls like NTSTATUS and
|
||||
//! HANDLE point to the standard library structures.
|
||||
//!
|
||||
//! We also use this to replace some `opaque` declarations generated by
|
||||
//! translate-c with their equivalents defined in our own Zig code,
|
||||
//! since our definitions have useful declarations on them.
|
||||
const std = @import("std");
|
||||
const mem = std.mem;
|
||||
|
||||
@@ -14,6 +21,10 @@ const symbol_replacements = std.StaticStringMap([]const u8).initComptime(&.{
|
||||
&.{ "NTSTATUS", "@import(\"std\").os.windows.NTSTATUS" },
|
||||
&.{ "HANDLE", "@import(\"std\").os.windows.HANDLE" },
|
||||
&.{ "PHANDLE", "*HANDLE" },
|
||||
&.{ "JSC__JSGlobalObject", "@import(\"bun\").jsc.JSGlobalObject" },
|
||||
&.{ "JSC__JSObject", "@import(\"bun\").jsc.JSObject" },
|
||||
&.{ "JSC__EncodedJSValue", "@import(\"bun\").jsc.JSValue" },
|
||||
&.{ "ZigString", "@import(\"bun\").jsc.ZigString" },
|
||||
});
|
||||
|
||||
pub fn main() !void {
|
||||
Reference in New Issue
Block a user