Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump webkit #15328

Merged
merged 182 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
5b7e752
span and __bit_cast
dylan-conway Nov 21, 2024
e7d5396
Update SetupWebKit.cmake
dylan-conway Nov 22, 2024
b2ba8d4
`bun run clang-format`
dylan-conway Nov 22, 2024
a0f9a07
Merge branch 'main' into dylan/bump-webkit
dylan-conway Nov 22, 2024
e485341
update
dylan-conway Nov 22, 2024
00745c9
Merge branch 'main' into dylan/bump-webkit
Jarred-Sumner Dec 1, 2024
e3e5e1e
Use LLVM 18
Jarred-Sumner Dec 1, 2024
59f1472
Bump LLVM
Jarred-Sumner Dec 1, 2024
ed68e1f
Set file descriptor limit in more places
Jarred-Sumner Dec 1, 2024
e150c9a
Bump
Jarred-Sumner Dec 1, 2024
29f337b
Remove comment
Jarred-Sumner Dec 1, 2024
b91db5f
Don't bother setup llvm for zig only builds
Jarred-Sumner Dec 1, 2024
bab451c
Fix
Jarred-Sumner Dec 1, 2024
a9d172b
override libc stat
Jarred-Sumner Dec 2, 2024
df0fa4a
fix
Jarred-Sumner Dec 2, 2024
5c420d9
Fix
Jarred-Sumner Dec 2, 2024
3f7627e
case sensitive
dylan-conway Dec 4, 2024
b5862d0
maybe fix build
dylan-conway Dec 5, 2024
e7b4a8f
Update src/linux_c.zig
Jarred-Sumner Dec 5, 2024
ab71d5c
Update cmake/tools/SetupWebKit.cmake
dylan-conway Dec 5, 2024
d7df0ce
Fix stat and lstat calling non-existent arm64 syscalls
190n Dec 5, 2024
333ba0f
Clarify symbols.test.ts
190n Dec 5, 2024
46140e9
Fix pthread_sigmask version on aarch64
190n Dec 5, 2024
819e64c
Wrap more symbols on ARM
190n Dec 6, 2024
7eb58b3
Add __wrap___pthread_key_create
Jarred-Sumner Dec 6, 2024
e07563f
This is probably incorrect
Jarred-Sumner Dec 6, 2024
ac92284
Merge branch 'main' into dylan/bump-webkit
Jarred-Sumner Dec 6, 2024
7e3f887
[build images]
Jarred-Sumner Dec 6, 2024
d5fc7ad
[build images]
Jarred-Sumner Dec 6, 2024
ac707a1
Update ci.mjs
Jarred-Sumner Dec 6, 2024
8c3a024
[build images]
Jarred-Sumner Dec 6, 2024
9707757
Update ci.mjs
Jarred-Sumner Dec 6, 2024
0fd7928
[build images]
nektro Dec 6, 2024
eccf03f
[build images]
Jarred-Sumner Dec 6, 2024
0ef42f9
[build images]
Jarred-Sumner Dec 6, 2024
dd4c359
Update bootstrap.sh
Jarred-Sumner Dec 6, 2024
5ddfde7
[build image]
Jarred-Sumner Dec 6, 2024
84859c2
Update bootstrap.sh
Jarred-Sumner Dec 6, 2024
aa962f5
[build images]
Jarred-Sumner Dec 6, 2024
7820667
when buildImages is set use it
nektro Dec 6, 2024
560e48e
forgot to pull dryRun out of the options object there [build images]
nektro Dec 6, 2024
bfd2e80
Do not reference glibc's version of __libc_single_threaded
190n Dec 6, 2024
f96c22d
[build images]
190n Dec 6, 2024
70ca52d
Fix image [build image]
Electroid Dec 6, 2024
4362acf
Fix ubuntu 24.04 [build image]
Electroid Dec 6, 2024
7c2c558
Bump WebKit to include oven-sh/WebKit#71
190n Dec 6, 2024
ca495d3
[build image]
190n Dec 6, 2024
6759e64
Fix WTF::constantTimeMemcmp calls for new signature [build images]
190n Dec 6, 2024
7e658a3
Revert: Bump WebKit to include oven-sh/WebKit#71 [build images]
190n Dec 6, 2024
fbdbcab
Link pthread
190n Dec 6, 2024
e0235c5
[build images]
Jarred-Sumner Dec 6, 2024
0377baf
`-fno-semantic-interposition` [build images]
Jarred-Sumner Dec 7, 2024
54fe995
Clearer glibc version requirement in symbols.test.ts
190n Dec 7, 2024
0eb43bc
[build image]
190n Dec 7, 2024
b6d2d32
Clearer glibc version requirement in symbols.test.ts [build image]
190n Dec 7, 2024
88ddef4
[build images]
Jarred-Sumner Dec 7, 2024
79518ae
[build images]
Jarred-Sumner Dec 7, 2024
0a7e2b2
[build images]
Jarred-Sumner Dec 7, 2024
348f7fc
[build images]
Jarred-Sumner Dec 7, 2024
1123e04
add -H to sudo, [build images]
nektro Dec 7, 2024
950fbcf
[builds images]
nektro Dec 7, 2024
660661a
[build images]
nektro Dec 7, 2024
c7a4981
[build images]
nektro Dec 7, 2024
774d139
[build images]
nektro Dec 7, 2024
8a3a085
[build images]
nektro Dec 7, 2024
948c42d
[dry run]
nektro Dec 7, 2024
1d553e2
[build images]
nektro Dec 7, 2024
e4f4c71
[build images]
nektro Dec 7, 2024
ac089d2
[build images]
nektro Dec 7, 2024
247241c
[build images]
nektro Dec 7, 2024
64f221e
[build images]
nektro Dec 7, 2024
11ba451
[build images]
nektro Dec 7, 2024
9a6f355
wip
Jarred-Sumner Dec 7, 2024
790ff45
[build images]
Jarred-Sumner Dec 7, 2024
7011d79
[build images]
Jarred-Sumner Dec 7, 2024
a653bfb
[build images]
Jarred-Sumner Dec 7, 2024
2876409
[build images]
Jarred-Sumner Dec 7, 2024
02a4f16
[build images]
Jarred-Sumner Dec 7, 2024
32de236
[build images]
Jarred-Sumner Dec 7, 2024
b87fba7
[build images]
Jarred-Sumner Dec 7, 2024
e8843f1
more files
Jarred-Sumner Dec 7, 2024
223c147
files
Jarred-Sumner Dec 7, 2024
de8a9f6
[build images]
Jarred-Sumner Dec 7, 2024
ebb3dcd
[build images]
Jarred-Sumner Dec 7, 2024
537fb6c
[build images]
Jarred-Sumner Dec 7, 2024
58af2ee
[build images]
Jarred-Sumner Dec 7, 2024
1950adb
[build images]
Jarred-Sumner Dec 7, 2024
8f8d7b8
[build images]
Jarred-Sumner Dec 7, 2024
acdb085
[build images]
Jarred-Sumner Dec 7, 2024
9e19ede
sudo [build images]
Jarred-Sumner Dec 7, 2024
04f6964
[sudo] build images
Jarred-Sumner Dec 7, 2024
887573d
[build images]
Jarred-Sumner Dec 7, 2024
66a6cfc
[build images]
Jarred-Sumner Dec 7, 2024
13c0340
[build images]
Jarred-Sumner Dec 7, 2024
ae7e566
[build images]
Jarred-Sumner Dec 7, 2024
3bfe5d7
[build images]
Jarred-Sumner Dec 7, 2024
1901969
[build images]
Jarred-Sumner Dec 7, 2024
2918a4e
[build images]
Jarred-Sumner Dec 7, 2024
551004f
[build images]
Jarred-Sumner Dec 7, 2024
24460b1
[build images]
Jarred-Sumner Dec 7, 2024
1fb5aa9
[build images]
Jarred-Sumner Dec 7, 2024
6977bb3
[build images]
Jarred-Sumner Dec 7, 2024
4d468ff
[build images]
Jarred-Sumner Dec 7, 2024
5952797
[build images]
Jarred-Sumner Dec 7, 2024
6a8aaa7
[build images]
Jarred-Sumner Dec 7, 2024
e4f2044
[build images]
Jarred-Sumner Dec 7, 2024
2454fec
[build images]
Jarred-Sumner Dec 7, 2024
a0c9942
[build images]
Jarred-Sumner Dec 7, 2024
6764f4d
[build images]
Jarred-Sumner Dec 7, 2024
4694118
[build images]
Jarred-Sumner Dec 7, 2024
e74b326
[build images]
Jarred-Sumner Dec 8, 2024
cb064bf
[build images]
Jarred-Sumner Dec 8, 2024
ba31a32
[build images]
Jarred-Sumner Dec 8, 2024
54ede97
[build images]
Jarred-Sumner Dec 8, 2024
68c7b5c
[build images]
Jarred-Sumner Dec 8, 2024
8635218
[build images]
Jarred-Sumner Dec 8, 2024
38f79d8
[build images]
Jarred-Sumner Dec 8, 2024
458cc88
[build images]
Jarred-Sumner Dec 8, 2024
972dfb0
[build images]
Jarred-Sumner Dec 8, 2024
bd8452a
[build images]
Jarred-Sumner Dec 8, 2024
7c9020e
[build images]
Jarred-Sumner Dec 8, 2024
b1c5912
[build images]
Jarred-Sumner Dec 8, 2024
8832ace
[build images]
Jarred-Sumner Dec 8, 2024
de6d417
[build images]
Jarred-Sumner Dec 8, 2024
15609e2
[build images]
Jarred-Sumner Dec 8, 2024
b60abb0
[build images]
Jarred-Sumner Dec 8, 2024
19ec021
[build images]
Jarred-Sumner Dec 8, 2024
7cad480
[build images]
Electroid Dec 9, 2024
c6a3e79
[build images]
Electroid Dec 9, 2024
201e40c
[build images]
Jarred-Sumner Dec 10, 2024
1e916f6
[build images]
Jarred-Sumner Dec 10, 2024
0740dff
Update flake.nix
Jarred-Sumner Dec 10, 2024
148d23e
[build images]
Jarred-Sumner Dec 10, 2024
3cfe70e
Fix tests [build images]
Jarred-Sumner Dec 10, 2024
89f94df
[build images]
Jarred-Sumner Dec 10, 2024
d77df36
Testing [build images]
Electroid Dec 11, 2024
4ae7896
Try symbol
Electroid Dec 11, 2024
a9b1737
[build images]
Jarred-Sumner Dec 11, 2024
ba64df8
Fix type [build images]
Electroid Dec 11, 2024
a4572e7
Fix [build images]
Electroid Dec 11, 2024
aaa229e
Fix [build images]
Electroid Dec 11, 2024
9c4a9dc
Fix [build images]
Electroid Dec 11, 2024
6f99d55
Remove last usages of nix [build images]
Electroid Dec 11, 2024
7828790
Fix permissions [build images]
Electroid Dec 11, 2024
099696a
Fix shell path? [build images]
Electroid Dec 11, 2024
f210496
Fix typo [build images]
Electroid Dec 11, 2024
a8d26b3
Fix typo [build images]
Electroid Dec 11, 2024
4d96b70
Merge branch 'main' into dylan/bump-webkit
Jarred-Sumner Dec 11, 2024
629ba98
[build images]
Jarred-Sumner Dec 11, 2024
9f3558b
[build images]
Jarred-Sumner Dec 11, 2024
2b81932
[build images]
Jarred-Sumner Dec 11, 2024
3279cd5
[build images]
Jarred-Sumner Dec 11, 2024
b1551c5
[build images]
Jarred-Sumner Dec 11, 2024
e9ab841
[build images]
Jarred-Sumner Dec 11, 2024
a25bfae
[build images]
Jarred-Sumner Dec 11, 2024
774a352
[build images]
Jarred-Sumner Dec 11, 2024
0838807
[build images]
Jarred-Sumner Dec 11, 2024
121d843
[build images]
Jarred-Sumner Dec 11, 2024
b9cb65c
[build images]
Jarred-Sumner Dec 11, 2024
49f6a9b
[build images]
Jarred-Sumner Dec 11, 2024
d988fd6
[build images]
Electroid Dec 11, 2024
58f5399
[build images]
Electroid Dec 11, 2024
dcbf413
[build images]
Electroid Dec 11, 2024
7603f58
[build images]
Electroid Dec 11, 2024
83b602a
[build images]
Electroid Dec 11, 2024
b17ba8d
[build images]
Electroid Dec 11, 2024
31aeb97
[build images]
Electroid Dec 11, 2024
91ba75b
[build images]
Electroid Dec 11, 2024
bad87b8
Try this [build images]
Electroid Dec 11, 2024
73b0eba
Fix image [build image]
Electroid Dec 12, 2024
9ff6e44
[build images]
Jarred-Sumner Dec 12, 2024
a9b6504
[build images]
Jarred-Sumner Dec 12, 2024
cd8ec12
Merge branch 'main' into dylan/bump-webkit
Jarred-Sumner Dec 12, 2024
9c43179
[build images]
Jarred-Sumner Dec 12, 2024
63722b9
[build images]
Jarred-Sumner Dec 12, 2024
7bba103
[build image]
Jarred-Sumner Dec 12, 2024
f7ee0b6
[build images]
Jarred-Sumner Dec 12, 2024
8a08ee5
[build images]
Jarred-Sumner Dec 12, 2024
26213e0
[build images]
Jarred-Sumner Dec 12, 2024
9181842
[build images]
Jarred-Sumner Dec 12, 2024
51daac2
Merge branch 'main' into dylan/bump-webkit
Jarred-Sumner Dec 12, 2024
2998a81
[build images]
Jarred-Sumner Dec 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .buildkite/ci.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,10 @@ function getPipeline(options) {
agents: getZigAgent(platform),
retry: getRetry(),
cancel_on_build_failing: isMergeQueue(),
env: getBuildEnv(platform),
env: {
...getBuildEnv(platform),
ENABLE_LLVM: "OFF",
},
command: `bun run build:ci --target bun-zig --toolchain ${toolchain}`,
};
};
Expand Down Expand Up @@ -545,9 +548,9 @@ function getPipeline(options) {
const buildPlatforms = [
{ os: "darwin", arch: "aarch64", release: "14" },
{ os: "darwin", arch: "x64", release: "14" },
{ os: "linux", arch: "aarch64", distro: "debian", release: "11" },
{ os: "linux", arch: "x64", distro: "debian", release: "11" },
{ os: "linux", arch: "x64", baseline: true, distro: "debian", release: "11" },
{ os: "linux", arch: "aarch64", distro: "debian", release: "12" },
{ os: "linux", arch: "x64", distro: "debian", release: "12" },
{ os: "linux", arch: "x64", baseline: true, distro: "debian", release: "12" },
{ os: "linux", arch: "aarch64", abi: "musl", distro: "alpine", release: "3.20" },
{ os: "linux", arch: "x64", abi: "musl", distro: "alpine", release: "3.20" },
{ os: "linux", arch: "x64", abi: "musl", baseline: true, distro: "alpine", release: "3.20" },
Expand Down
57 changes: 46 additions & 11 deletions cmake/targets/BuildBun.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -854,25 +854,60 @@ if(LINUX)
if(ARCH STREQUAL "aarch64")
target_link_options(${bun} PUBLIC
-Wl,--wrap=fcntl64
-Wl,--wrap=statx
)
endif()

if(ARCH STREQUAL "x64")
target_link_options(${bun} PUBLIC
-Wl,--wrap=__isoc23_sscanf
-Wl,--wrap=__isoc23_strtol
-Wl,--wrap=__isoc23_strtoul
-Wl,--wrap=__isoc23_strtoull
-Wl,--wrap=__isoc23_vfscanf
-Wl,--wrap=__isoc23_vscanf
-Wl,--wrap=__isoc23_vsscanf
-Wl,--wrap=__libc_single_threaded
-Wl,--wrap=__libc_start_main
-Wl,--wrap=_dl_find_object
-Wl,--wrap=arc4random_buf
-Wl,--wrap=dladdr
-Wl,--wrap=dlclose
-Wl,--wrap=dlerror
-Wl,--wrap=dlopen
-Wl,--wrap=dlsym
-Wl,--wrap=dlvsym
-Wl,--wrap=fcntl
-Wl,--wrap=fcntl64
-Wl,--wrap=fstat
-Wl,--wrap=fstat64
-Wl,--wrap=fstatat
-Wl,--wrap=fstatat64
-Wl,--wrap=lstat
-Wl,--wrap=lstat64
-Wl,--wrap=getrandom
-Wl,--wrap=mknod
-Wl,--wrap=mknodat
-Wl,--wrap=stat
-Wl,--wrap=stat64
-Wl,--wrap=statx
-Wl,--wrap=pthread_attr_getstack
-Wl,--wrap=pthread_attr_setguardsize
-Wl,--wrap=pthread_attr_setstacksize
-Wl,--wrap=pthread_create
-Wl,--wrap=pthread_detach
-Wl,--wrap=pthread_getattr_np
-Wl,--wrap=pthread_getspecific
-Wl,--wrap=pthread_join
-Wl,--wrap=pthread_key_create
-Wl,--wrap=pthread_key_delete
-Wl,--wrap=pthread_kill
-Wl,--wrap=pthread_mutex_trylock
-Wl,--wrap=pthread_mutexattr_destroy
-Wl,--wrap=pthread_mutexattr_init
-Wl,--wrap=pthread_mutexattr_settype
-Wl,--wrap=pthread_once
-Wl,--wrap=pthread_rwlock_destroy
-Wl,--wrap=pthread_rwlock_init
-Wl,--wrap=pthread_rwlock_rdlock
-Wl,--wrap=pthread_rwlock_unlock
-Wl,--wrap=pthread_rwlock_wrlock
-Wl,--wrap=pthread_setspecific
-Wl,--wrap=pthread_sigmask
-Wl,--wrap=quick_exit
-Wl,--wrap=sem_init
-Wl,--wrap=sem_post
-Wl,--wrap=sem_wait
)
endif()

Expand Down Expand Up @@ -921,7 +956,7 @@ if(LINUX)
-Wl,-z,combreloc
-Wl,--no-eh-frame-hdr
-Wl,--sort-section=name
-Wl,--hash-style=gnu
-Wl,--hash-style=both
-Wl,--build-id=sha1 # Better for debugging than default
-Wl,-Map=${bun}.linker-map
)
Expand Down
2 changes: 1 addition & 1 deletion cmake/targets/BuildLibArchive.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ register_cmake_command(
-DENABLE_INSTALL=OFF
-DENABLE_TEST=OFF
-DENABLE_WERROR=OFF
-DENABLE_BZIP2=OFF
-DENABLE_BZip2=OFF
-DENABLE_CAT=OFF
-DENABLE_EXPAT=OFF
-DENABLE_ICONV=OFF
Expand Down
16 changes: 10 additions & 6 deletions cmake/tools/SetupLLVM.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
optionx(ENABLE_LLVM BOOL "If LLVM should be used for compilation" DEFAULT ON)

set(DEFAULT_ENABLE_LLVM ON)

# if target is bun-zig, set ENABLE_LLVM to OFF
if(TARGET bun-zig)
set(DEFAULT_ENABLE_LLVM OFF)
endif()

optionx(ENABLE_LLVM BOOL "If LLVM should be used for compilation" DEFAULT ${DEFAULT_ENABLE_LLVM})

if(NOT ENABLE_LLVM)
return()
endif()

if(CMAKE_HOST_WIN32 OR CMAKE_HOST_APPLE OR EXISTS "/etc/alpine-release")
set(DEFAULT_LLVM_VERSION "18.1.8")
else()
set(DEFAULT_LLVM_VERSION "16.0.6")
endif()
set(DEFAULT_LLVM_VERSION "18.1.8")

optionx(LLVM_VERSION STRING "The version of LLVM to use" DEFAULT ${DEFAULT_LLVM_VERSION})

Expand Down
2 changes: 1 addition & 1 deletion cmake/tools/SetupWebKit.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ option(WEBKIT_VERSION "The version of WebKit to use")
option(WEBKIT_LOCAL "If a local version of WebKit should be used instead of downloading")

if(NOT WEBKIT_VERSION)
set(WEBKIT_VERSION 8f9ae4f01a047c666ef548864294e01df731d4ea)
set(WEBKIT_VERSION 8bbd4ed494f66395f9ae42aed1beb57e998265ca)
dylan-conway marked this conversation as resolved.
Show resolved Hide resolved
endif()

if(WEBKIT_LOCAL)
Expand Down
27 changes: 16 additions & 11 deletions scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -714,14 +714,7 @@ install_build_essentials() {
}

llvm_version_exact() {
case "$os-$abi" in
darwin-* | windows-* | linux-musl)
print "18.1.8"
;;
linux-*)
print "16.0.6"
;;
esac
print "18.1.8"
}

llvm_version() {
Expand Down Expand Up @@ -980,8 +973,20 @@ install_chrome_dependencies() {
}

raise_file_descriptor_limit() {
append_to_file_sudo /etc/security/limits.conf '* soft nofile 262144'
append_to_file_sudo /etc/security/limits.conf '* hard nofile 262144'
if [ -d /etc/security ]; then
append_to_file_sudo /etc/security/limits.conf '* soft nofile 262144'
append_to_file_sudo /etc/security/limits.conf '* hard nofile 262144'
fi

append_to_file_sudo /etc/profile 'ulimit -n 262144'

if [ -d /etc/systemd ]; then
append_to_file_sudo /etc/systemd/user.conf 'DefaultLimitNOFILE=262144'
fi

if [ -d /etc/sysctl.d ]; then
append_to_file_sudo /etc/sysctl.d/99-file-max.conf 'fs.file-max=262144'
fi
}

main() {
Expand All @@ -994,7 +999,7 @@ main() {
install_common_software
install_build_essentials
install_chrome_dependencies
raise_file_descriptor_limit # XXX: temporary
raise_file_descriptor_limit
}

main "$@"
8 changes: 4 additions & 4 deletions src/bun.js/bindings/Base64Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ ExceptionOr<String> atob(const String& encodedString)
if (!encodedString.is8Bit()) {
const auto span = encodedString.span16();
size_t expected_length = simdutf::latin1_length_from_utf16(span.size());
LChar* ptr;
std::span<LChar> ptr;
WTF::String convertedString = WTF::String::createUninitialized(expected_length, ptr);
if (UNLIKELY(convertedString.isNull())) {
return WebCore::Exception { OutOfMemoryError };
}

auto result = simdutf::convert_utf16le_to_latin1_with_errors(span.data(), span.size(), reinterpret_cast<char*>(ptr));
auto result = simdutf::convert_utf16le_to_latin1_with_errors(span.data(), span.size(), reinterpret_cast<char*>(ptr.data()));

if (result.error) {
return WebCore::Exception { InvalidCharacterError };
Expand All @@ -34,12 +34,12 @@ ExceptionOr<String> atob(const String& encodedString)

const auto span = encodedString.span8();
size_t result_length = simdutf::maximal_binary_length_from_base64(reinterpret_cast<const char*>(span.data()), encodedString.length());
LChar* ptr;
std::span<LChar> ptr;
WTF::String outString = WTF::String::createUninitialized(result_length, ptr);
if (UNLIKELY(outString.isNull())) {
return WebCore::Exception { OutOfMemoryError };
}
auto result = simdutf::base64_to_binary(reinterpret_cast<const char*>(span.data()), span.size(), reinterpret_cast<char*>(ptr), simdutf::base64_default);
auto result = simdutf::base64_to_binary(reinterpret_cast<const char*>(span.data()), span.size(), reinterpret_cast<char*>(ptr.data()), simdutf::base64_default);
if (result.error != simdutf::error_code::SUCCESS) {
return WebCore::Exception { InvalidCharacterError };
}
Expand Down
20 changes: 10 additions & 10 deletions src/bun.js/bindings/BunString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ extern "C" JSC::EncodedJSValue BunString__toJS(JSC::JSGlobalObject* globalObject
extern "C" BunString BunString__fromUTF16Unitialized(size_t length)
{
ASSERT(length > 0);
UChar* ptr;
std::span<UChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(length, ptr);
if (UNLIKELY(!impl)) {
return { .tag = BunStringTag::Dead };
Expand All @@ -237,7 +237,7 @@ extern "C" BunString BunString__fromUTF16Unitialized(size_t length)
extern "C" BunString BunString__fromLatin1Unitialized(size_t length)
{
ASSERT(length > 0);
LChar* ptr;
std::span<LChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(length, ptr);
if (UNLIKELY(!impl)) {
return { .tag = BunStringTag::Dead };
Expand All @@ -250,12 +250,12 @@ extern "C" BunString BunString__fromUTF8(const char* bytes, size_t length)
ASSERT(length > 0);
if (simdutf::validate_utf8(bytes, length)) {
size_t u16Length = simdutf::utf16_length_from_utf8(bytes, length);
UChar* ptr;
std::span<UChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(static_cast<unsigned int>(u16Length), ptr);
if (UNLIKELY(!impl)) {
return { .tag = BunStringTag::Dead };
}
RELEASE_ASSERT(simdutf::convert_utf8_to_utf16(bytes, length, ptr) == u16Length);
RELEASE_ASSERT(simdutf::convert_utf8_to_utf16(bytes, length, ptr.data()) == u16Length);
impl->ref();
return { BunStringTag::WTFStringImpl, { .wtf = impl.leakRef() } };
}
Expand All @@ -271,12 +271,12 @@ extern "C" BunString BunString__fromUTF8(const char* bytes, size_t length)
extern "C" BunString BunString__fromLatin1(const char* bytes, size_t length)
{
ASSERT(length > 0);
LChar* ptr;
std::span<LChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(length, ptr);
if (UNLIKELY(!impl)) {
return { .tag = BunStringTag::Dead };
}
memcpy(ptr, bytes, length);
memcpy(ptr.data(), bytes, length);

return { BunStringTag::WTFStringImpl, { .wtf = impl.leakRef() } };
}
Expand All @@ -286,26 +286,26 @@ extern "C" BunString BunString__fromUTF16ToLatin1(const char16_t* bytes, size_t
ASSERT(length > 0);
ASSERT_WITH_MESSAGE(simdutf::validate_utf16le(bytes, length), "This function only accepts ascii UTF16 strings");
size_t outLength = simdutf::latin1_length_from_utf16(length);
LChar* ptr = nullptr;
std::span<LChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(outLength, ptr);
if (UNLIKELY(!impl)) {
return { BunStringTag::Dead };
}

size_t latin1_length = simdutf::convert_valid_utf16le_to_latin1(bytes, length, reinterpret_cast<char*>(ptr));
size_t latin1_length = simdutf::convert_valid_utf16le_to_latin1(bytes, length, reinterpret_cast<char*>(ptr.data()));
ASSERT_WITH_MESSAGE(latin1_length == outLength, "Failed to convert UTF16 to Latin1");
return { BunStringTag::WTFStringImpl, { .wtf = impl.leakRef() } };
}

extern "C" BunString BunString__fromUTF16(const char16_t* bytes, size_t length)
{
ASSERT(length > 0);
UChar* ptr;
std::span<UChar> ptr;
auto impl = WTF::StringImpl::tryCreateUninitialized(length, ptr);
if (UNLIKELY(!impl)) {
return { .tag = BunStringTag::Dead };
}
memcpy(ptr, bytes, length * sizeof(char16_t));
memcpy(ptr.data(), bytes, length * sizeof(char16_t));
return { BunStringTag::WTFStringImpl, { .wtf = impl.leakRef() } };
}

Expand Down
12 changes: 6 additions & 6 deletions src/bun.js/bindings/JSBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1547,21 +1547,21 @@ static inline JSC::EncodedJSValue jsBufferToString(JSC::VM& vm, JSC::JSGlobalObj

switch (encoding) {
case WebCore::BufferEncodingType::latin1: {
LChar* data = nullptr;
std::span<LChar> data;
auto str = String::createUninitialized(length, data);
memcpy(data, reinterpret_cast<const char*>(castedThis->vector()) + offset, length);
memcpy(data.data(), reinterpret_cast<const char*>(castedThis->vector()) + offset, length);
return JSC::JSValue::encode(JSC::jsString(vm, WTFMove(str)));
}

case WebCore::BufferEncodingType::ucs2:
case WebCore::BufferEncodingType::utf16le: {
UChar* data = nullptr;
std::span<UChar> data;
size_t u16length = length / 2;
if (u16length == 0) {
return JSC::JSValue::encode(JSC::jsEmptyString(vm));
} else {
auto str = String::createUninitialized(u16length, data);
memcpy(reinterpret_cast<void*>(data), reinterpret_cast<const char*>(castedThis->vector()) + offset, u16length * 2);
memcpy(reinterpret_cast<void*>(data.data()), reinterpret_cast<const char*>(castedThis->vector()) + offset, u16length * 2);
return JSC::JSValue::encode(JSC::jsString(vm, str));
}

Expand All @@ -1571,9 +1571,9 @@ static inline JSC::EncodedJSValue jsBufferToString(JSC::VM& vm, JSC::JSGlobalObj
case WebCore::BufferEncodingType::ascii: {
// ascii: we always know the length
// so we might as well allocate upfront
LChar* data = nullptr;
std::span<LChar> data;
auto str = String::createUninitialized(length, data);
Bun__encoding__writeLatin1(reinterpret_cast<const unsigned char*>(castedThis->vector()) + offset, length, data, length, static_cast<uint8_t>(encoding));
Bun__encoding__writeLatin1(reinterpret_cast<const unsigned char*>(castedThis->vector()) + offset, length, data.data(), length, static_cast<uint8_t>(encoding));
return JSC::JSValue::encode(JSC::jsString(vm, WTFMove(str)));
}

Expand Down
5 changes: 3 additions & 2 deletions src/bun.js/bindings/JSBufferEncodingType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ using namespace JSC;

String convertEnumerationToString(BufferEncodingType enumerationValue)
{
static const NeverDestroyed<String> values[] = {

static const std::array<NeverDestroyed<String>, 8> values = {
MAKE_STATIC_STRING_IMPL("utf8"),
MAKE_STATIC_STRING_IMPL("ucs2"),
MAKE_STATIC_STRING_IMPL("utf16le"),
Expand All @@ -56,7 +57,7 @@ template<> std::optional<BufferEncodingType> parseEnumeration<BufferEncodingType
if (UNLIKELY(!arg.isString())) {
return std::nullopt;
}
return parseEnumeration2(lexicalGlobalObject, asString(arg)->getString(&lexicalGlobalObject));
return parseEnumeration2(lexicalGlobalObject, arg.toWTFString(&lexicalGlobalObject));
}

std::optional<BufferEncodingType> parseEnumeration2(JSGlobalObject& lexicalGlobalObject, WTF::String encoding)
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/bindings/JSBundlerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include <JavaScriptCore/JSPromise.h>
namespace Bun {

#define WRAP_BUNDLER_PLUGIN(argName) jsDoubleNumber(bitwise_cast<double>(reinterpret_cast<uintptr_t>(argName)))
#define UNWRAP_BUNDLER_PLUGIN(callFrame) reinterpret_cast<void*>(bitwise_cast<uintptr_t>(callFrame->argument(0).asDouble()))
#define WRAP_BUNDLER_PLUGIN(argName) jsDoubleNumber(std::bit_cast<double>(reinterpret_cast<uintptr_t>(argName)))
#define UNWRAP_BUNDLER_PLUGIN(callFrame) reinterpret_cast<void*>(std::bit_cast<uintptr_t>(callFrame->argument(0).asDouble()))

/// These are callbacks defined in Zig and to be run after their associated JS version is run
extern "C" void JSBundlerPlugin__addError(void*, void*, JSC::EncodedJSValue, JSC::EncodedJSValue);
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/bindings/JSFFIFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ extern "C" JSC::EncodedJSValue Bun__CreateFFIFunctionValue(Zig::GlobalObject* gl
// We should only expose the "ptr" field when it's a JSCallback for bun:ffi.
// Not for internal usages of this function type.
// We should also consider a separate JSFunction type for our usage to not have this branch in the first place...
function->putDirect(vm, JSC::Identifier::fromString(vm, String(MAKE_STATIC_STRING_IMPL("ptr"))), JSC::jsNumber(bitwise_cast<double>(functionPointer)), JSC::PropertyAttribute::ReadOnly | 0);
function->putDirect(vm, JSC::Identifier::fromString(vm, String(MAKE_STATIC_STRING_IMPL("ptr"))), JSC::jsNumber(__bit_cast<double>(functionPointer)), JSC::PropertyAttribute::ReadOnly | 0);

return JSC::JSValue::encode(function);
}
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/bindings/NodeHTTP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ static EncodedJSValue assignHeadersFromUWebSockets(uWS::HttpRequest* request, JS
for (auto it = request->begin(); it != request->end(); ++it) {
auto pair = *it;
StringView nameView = StringView(std::span { reinterpret_cast<const LChar*>(pair.first.data()), pair.first.length() });
LChar* data = nullptr;
std::span<LChar> data;
auto value = String::createUninitialized(pair.second.length(), data);
if (pair.second.length() > 0)
memcpy(data, pair.second.data(), pair.second.length());
memcpy(data.data(), pair.second.data(), pair.second.length());

HTTPHeaderName name;
WTF::String nameString;
Expand Down
Loading
Loading