mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
WASM test analyzer (#4043)
* wasm * WASM test scanner * Update Makefile * Update Makefile * Configurable heap limit * slightly better error * Update js_parser.zig * Update path.test.js * Update node.mjs --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -271,6 +271,10 @@ pub inline fn lastIndexOf(self: string, str: string) ?usize {
|
||||
}
|
||||
|
||||
pub inline fn indexOf(self: string, str: string) ?usize {
|
||||
if (comptime !bun.Environment.isNative) {
|
||||
return std.mem.indexOf(u8, self, str);
|
||||
}
|
||||
|
||||
const self_len = self.len;
|
||||
const str_len = str.len;
|
||||
|
||||
@@ -921,7 +925,7 @@ inline fn eqlComptimeCheckLenWithKnownType(comptime Type: type, a: []const Type,
|
||||
}
|
||||
|
||||
const len = comptime b.len;
|
||||
comptime var dword_length = b.len >> 3;
|
||||
comptime var dword_length = b.len >> if (Environment.isNative) 3 else 2;
|
||||
const slice = b;
|
||||
const divisor = comptime @sizeOf(Type);
|
||||
|
||||
@@ -1521,7 +1525,11 @@ pub fn toUTF8ListWithTypeBun(list_: std.ArrayList(u8), comptime Type: type, utf1
|
||||
utf16_remaining = utf16_remaining[replacement.len..];
|
||||
|
||||
const count: usize = replacement.utf8Width();
|
||||
try list.ensureTotalCapacityPrecise(i + count + list.items.len + @as(usize, @intFromFloat((@as(f64, @floatFromInt(@as(u52, @truncate(utf16_remaining.len)))) * 1.2))));
|
||||
if (comptime Environment.isNative) {
|
||||
try list.ensureTotalCapacityPrecise(i + count + list.items.len + @as(usize, @intFromFloat((@as(f64, @floatFromInt(@as(u52, @truncate(utf16_remaining.len)))) * 1.2))));
|
||||
} else {
|
||||
try list.ensureTotalCapacityPrecise(i + count + list.items.len + utf16_remaining.len + 4);
|
||||
}
|
||||
list.items.len += i;
|
||||
|
||||
copyU16IntoU8(
|
||||
@@ -3445,6 +3453,10 @@ pub fn indexOfCharUsize(slice: []const u8, char: u8) ?usize {
|
||||
if (slice.len == 0)
|
||||
return null;
|
||||
|
||||
if (comptime !Environment.isNative) {
|
||||
return std.mem.indexOfScalar(u8, slice, char);
|
||||
}
|
||||
|
||||
const ptr = bun.C.memchr(slice.ptr, char, slice.len) orelse return null;
|
||||
const i = @intFromPtr(ptr) - @intFromPtr(slice.ptr);
|
||||
std.debug.assert(i < slice.len);
|
||||
@@ -3704,7 +3716,7 @@ pub fn getLinesInText(text: []const u8, line: u32, comptime line_range_count: us
|
||||
pub fn firstNonASCII16CheckMin(comptime Slice: type, slice: Slice, comptime check_min: bool) ?u32 {
|
||||
var remaining = slice;
|
||||
|
||||
if (comptime Environment.enableSIMD) {
|
||||
if (comptime Environment.enableSIMD and Environment.isNative) {
|
||||
const end_ptr = remaining.ptr + remaining.len - (remaining.len % ascii_u16_vector_size);
|
||||
if (remaining.len > ascii_u16_vector_size) {
|
||||
const remaining_start = remaining.ptr;
|
||||
@@ -3780,7 +3792,7 @@ pub fn @"nextUTF16NonASCIIOr$`\\"(
|
||||
) ?u32 {
|
||||
var remaining = slice;
|
||||
|
||||
if (comptime Environment.enableSIMD) {
|
||||
if (comptime Environment.enableSIMD and Environment.isNative) {
|
||||
while (remaining.len >= ascii_u16_vector_size) {
|
||||
const vec: AsciiU16Vector = remaining[0..ascii_u16_vector_size].*;
|
||||
|
||||
@@ -4054,7 +4066,8 @@ pub fn join(slices: []const string, delimiter: string, allocator: std.mem.Alloca
|
||||
|
||||
pub fn order(a: []const u8, b: []const u8) std.math.Order {
|
||||
const len = @min(a.len, b.len);
|
||||
const cmp = bun.C.memcmp(a.ptr, b.ptr, len);
|
||||
|
||||
const cmp = if (comptime Environment.isNative) bun.C.memcmp(a.ptr, b.ptr, len) else return std.mem.order(u8, a, b);
|
||||
return switch (std.math.sign(cmp)) {
|
||||
0 => std.math.order(a.len, b.len),
|
||||
1 => .gt,
|
||||
|
||||
Reference in New Issue
Block a user