Make signal.abort() from native code fast (#13064)

This commit is contained in:
Jarred Sumner
2024-08-05 15:50:36 -07:00
committed by GitHub
parent 0d7d789ebd
commit cacbaba524
67 changed files with 1209 additions and 679 deletions

View File

@@ -62,7 +62,7 @@ pub const OS = struct {
} catch {
const err = JSC.SystemError{
.message = bun.String.static("Failed to get cpu information"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static(@tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR)),
};
globalThis.vm().throwError(globalThis, err.toErrorInstance(globalThis));
@@ -313,13 +313,10 @@ pub const OS = struct {
const arguments: []const JSC.JSValue = args_.ptr[0..args_.len];
if (arguments.len > 0 and !arguments[0].isNumber()) {
const err = JSC.toTypeError(
JSC.Node.ErrorCode.ERR_INVALID_ARG_TYPE,
globalThis.ERR_INVALID_ARG_TYPE(
"getPriority() expects a number",
.{},
globalThis,
);
globalThis.vm().throwError(globalThis, err);
).throw();
return .undefined;
}
@@ -335,7 +332,7 @@ pub const OS = struct {
const err = JSC.SystemError{
.message = bun.String.static("A system error occurred: uv_os_getpriority returned ESRCH (no such process)"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static("ERR_SYSTEM_ERROR"),
//.info = info,
.errno = -3,
.syscall = bun.String.static("uv_os_getpriority"),
@@ -419,7 +416,7 @@ pub const OS = struct {
if (rc != 0) {
const err = JSC.SystemError{
.message = bun.String.static("A system error occurred: getifaddrs returned an error"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static("ERR_SYSTEM_ERROR"),
.errno = @intFromEnum(std.posix.errno(rc)),
.syscall = bun.String.static("getifaddrs"),
};
@@ -602,7 +599,7 @@ pub const OS = struct {
if (err != 0) {
const sys_err = JSC.SystemError{
.message = bun.String.static("uv_interface_addresses failed"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static("ERR_SYSTEM_ERROR"),
//.info = info,
.errno = err,
.syscall = bun.String.static("uv_interface_addresses"),
@@ -730,7 +727,7 @@ pub const OS = struct {
if (arguments.len == 0) {
const err = JSC.toTypeError(
JSC.Node.ErrorCode.ERR_INVALID_ARG_TYPE,
.ERR_INVALID_ARG_TYPE,
"The \"priority\" argument must be of type number. Received undefined",
.{},
globalThis,
@@ -744,7 +741,7 @@ pub const OS = struct {
if (priority < -20 or priority > 19) {
const err = JSC.toTypeError(
JSC.Node.ErrorCode.ERR_OUT_OF_RANGE,
.ERR_OUT_OF_RANGE,
"The value of \"priority\" is out of range. It must be >= -20 && <= 19",
.{},
globalThis,
@@ -758,7 +755,7 @@ pub const OS = struct {
.SRCH => {
const err = JSC.SystemError{
.message = bun.String.static("A system error occurred: uv_os_setpriority returned ESRCH (no such process)"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static(@tagName(.ERR_SYSTEM_ERROR)),
//.info = info,
.errno = -3,
.syscall = bun.String.static("uv_os_setpriority"),
@@ -770,7 +767,7 @@ pub const OS = struct {
.ACCES => {
const err = JSC.SystemError{
.message = bun.String.static("A system error occurred: uv_os_setpriority returned EACCESS (permission denied)"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static(@tagName(.ERR_SYSTEM_ERROR)),
//.info = info,
.errno = -13,
.syscall = bun.String.static("uv_os_setpriority"),
@@ -811,7 +808,7 @@ pub const OS = struct {
if (err != 0) {
const sys_err = JSC.SystemError{
.message = bun.String.static("failed to get system uptime"),
.code = bun.String.static(@as(string, @tagName(JSC.Node.ErrorCode.ERR_SYSTEM_ERROR))),
.code = bun.String.static("ERR_SYSTEM_ERROR"),
.errno = err,
.syscall = bun.String.static("uv_uptime"),
};
@@ -853,7 +850,7 @@ pub const OS = struct {
return JSC.ZigString.init(C.getVersion(&name_buffer)).withEncoding().toJS(globalThis);
}
inline fn getMachineName() []const u8 {
inline fn getMachineName() [:0]const u8 {
return switch (@import("builtin").target.cpu.arch) {
.arm => "arm",
.aarch64 => "arm64",