Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion scripts/build/deps/webkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* for local mode. Override via `--webkit-version=<hash>` to test a branch.
* From https://github.com/oven-sh/WebKit releases.
*/
export const WEBKIT_VERSION = "5718a6ec579b98362ea7276a426deedcc6281ef5";
export const WEBKIT_VERSION = "0c06faadf65bf8e8c8ad3a5a8aca83e1e9ed653f";

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
32 changes: 16 additions & 16 deletions src/jsc/bindings/BunProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionDlopen, __attribute__((
filename = fileURL.fileSystemPath();
}

CString utf8;
UTF8CString utf8;

// Support embedded .node files
// See src/standalone_graph/StandaloneModuleGraph.rs for what this "$bunfs" thing is
Expand Down Expand Up @@ -558,7 +558,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionDlopen, __attribute__((
// See https://github.com/oven-sh/bun/issues/15753.
if (!fromEmbedded) {
char soname[64] = { 0 };
if (Bun__addonNeedsGlibcOnMusl(utf8.data(), utf8.length(), soname, sizeof(soname))) [[unlikely]] {
if (Bun__addonNeedsGlibcOnMusl(utf8.legacyCStringPointer(), utf8.length(), soname, sizeof(soname))) [[unlikely]] {
WTF::StringBuilder msg;
msg.append(filename);
msg.append(" is linked against glibc (DT_NEEDED "_s);
Expand All @@ -568,8 +568,8 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionDlopen, __attribute__((
}
}
#endif
CrashHandler__setDlOpenAction(utf8.data());
void* handle = dlopen(utf8.data(), RTLD_LAZY);
CrashHandler__setDlOpenAction(utf8.legacyCStringPointer());
void* handle = dlopen(utf8.legacyCStringPointer(), RTLD_LAZY);
CrashHandler__setDlOpenAction(nullptr);
#endif

Expand Down Expand Up @@ -761,7 +761,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionDlopen, __attribute__((

EncodedJSValue exportsValue = JSC::JSValue::encode(exports);

char* filename_cstr = toFileURI(utf8.span());
char* filename_cstr = toFileURI(byteCast<char>(utf8.span()));

napi_module nmodule {
.nm_version = module_version,
Expand Down Expand Up @@ -1962,7 +1962,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionExecve, __attribute__((
RETURN_IF_EXCEPTION(scope, {});
}

Vector<CString> argvStorage;
Vector<UTF8CString> argvStorage;
argvStorage.reserveInitialCapacity(argsLength);

for (unsigned i = 0; i < argsLength; i++) {
Expand Down Expand Up @@ -1990,7 +1990,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionExecve, __attribute__((
RETURN_IF_EXCEPTION(scope, {});
}

Vector<CString> envStorage;
Vector<UTF8CString> envStorage;
{
Bun::V::validateObject(scope, globalObject, envValue, "env"_s);
RETURN_IF_EXCEPTION(scope, {});
Expand Down Expand Up @@ -2026,21 +2026,21 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionExecve, __attribute__((
}
}

CString execPathUtf8 = execPath.utf8();
UTF8CString execPathUtf8 = execPath.utf8();

// Build the null-terminated argv/envp pointer arrays only after the
// backing storage is fully populated so there is no risk of pointers
// becoming stale across any intermediate Vector growth.
Vector<char*> argv;
argv.reserveInitialCapacity(argvStorage.size() + 1);
for (auto& s : argvStorage)
argv.append(const_cast<char*>(s.data()));
argv.append(const_cast<char*>(s.legacyCStringPointer()));
argv.append(nullptr);

Vector<char*> envp;
envp.reserveInitialCapacity(envStorage.size() + 1);
for (auto& s : envStorage)
envp.append(const_cast<char*>(s.data()));
envp.append(const_cast<char*>(s.legacyCStringPointer()));
envp.append(nullptr);

// Set stdin, stdout and stderr to be non-close-on-exec so that the new
Expand Down Expand Up @@ -2087,7 +2087,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionExecve, __attribute__((
posix_spawn_file_actions_addinherit_np(&actions, 2);

pid_t pid;
savedErrno = posix_spawn(&pid, execPathUtf8.data(), &actions, &attrs, argv.begin(), envp.begin());
savedErrno = posix_spawn(&pid, execPathUtf8.legacyCStringPointer(), &actions, &attrs, argv.begin(), envp.begin());
// With POSIX_SPAWN_SETEXEC a successful call never returns; reaching
// here means it failed and the return value is the errno.
posix_spawn_file_actions_destroy(&actions);
Expand Down Expand Up @@ -2118,7 +2118,7 @@ JSC_DEFINE_HOST_FUNCTION_WITH_ATTRIBUTES(Process_functionExecve, __attribute__((
sigemptyset(&emptyMask);
pthread_sigmask(SIG_SETMASK, &emptyMask, &previousMask);

::execve(execPathUtf8.data(), argv.begin(), envp.begin());
::execve(execPathUtf8.legacyCStringPointer(), argv.begin(), envp.begin());
savedErrno = errno;

// execve(2) failed; put back the signal mask we cleared above.
Expand Down Expand Up @@ -3573,7 +3573,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functioninitgroups, (JSGlobalObject * globalObj
// initgroups(3) takes a user *name*. Node passes a string user through
// as-is (initgroups(3) reports EPERM/ENOMEM/etc. itself); only a numeric
// uid is pre-resolved through passwd so we have a name to pass.
CString userNameUTF8;
UTF8CString userNameUTF8;
const char* userName = nullptr;
struct passwd pwd;
struct passwd* pp = nullptr;
Expand All @@ -3582,7 +3582,7 @@ JSC_DEFINE_HOST_FUNCTION(Process_functioninitgroups, (JSGlobalObject * globalObj
auto str = user.getString(globalObject);
RETURN_IF_EXCEPTION(scope, {});
userNameUTF8 = str.utf8();
userName = userNameUTF8.data();
userName = userNameUTF8.legacyCStringPointer();
} else {
uid_t uid = static_cast<uid_t>(user.toUInt32(globalObject));
RETURN_IF_EXCEPTION(scope, {});
Expand Down Expand Up @@ -4723,8 +4723,8 @@ JSC_DEFINE_CUSTOM_SETTER(setProcessTitle, (JSC::JSGlobalObject * globalObject, J
// call is best-effort (it fails in console-less processes).
BunString str = Bun::toString(wtfStr);
Bun__Process__setTitle(globalObject, &str);
CString cstr = wtfStr.utf8();
uv_set_process_title(cstr.data());
UTF8CString cstr = wtfStr.utf8();
uv_set_process_title(cstr.legacyCStringPointer());
return true;
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/bindings/BunString.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class UTF8View {
std::span<const char> span() const
{
if (m_isConverted)
return m_converted.span();
return byteCast<char>(m_converted.span());
return byteCast<char>(m_borrowed.span8());
}

private:
UTF8View() = default;

WTF::StringView m_borrowed {};
WTF::CString m_converted {};
WTF::UTF8CString m_converted {};
bool m_isConverted { false };
};

Expand Down
6 changes: 3 additions & 3 deletions src/jsc/bindings/JSBundlerPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,13 +388,13 @@ JSC_DEFINE_HOST_FUNCTION(jsBundlerPluginFunction_onBeforeParse, (JSC::JSGlobalOb
}
Bun::NapiModuleMeta* meta = (Bun::NapiModuleMeta*)napi_external->value();
void* dlopen_handle = meta->dlopenHandle;
CString utf8 = on_before_parse_symbol.utf8();
UTF8CString utf8 = on_before_parse_symbol.utf8();

#if OS(WINDOWS)
void* on_before_parse_symbol_ptr = GetProcAddress((HMODULE)dlopen_handle, utf8.data());
void* on_before_parse_symbol_ptr = GetProcAddress((HMODULE)dlopen_handle, utf8.legacyCStringPointer());
const char** native_plugin_name = (const char**)GetProcAddress((HMODULE)dlopen_handle, "BUN_PLUGIN_NAME");
#else
void* on_before_parse_symbol_ptr = dlsym(dlopen_handle, utf8.data());
void* on_before_parse_symbol_ptr = dlsym(dlopen_handle, utf8.legacyCStringPointer());
const char** native_plugin_name = (const char**)dlsym(dlopen_handle, "BUN_PLUGIN_NAME");
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/jsc/bindings/JSONRowsToJS.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Builds JS values from the immutable JSON AST rows (`E::JsonTape`, see src/ast/e.rs) that the
// JSON and XML parsers produce: one call for the whole document, keys and short values through
// the VM's JSONAtomStringCache the way JSON.parse does it.
// the VM's JSONCache the way JSON.parse does it.

#include "root.h"

#include <JavaScriptCore/IdentifierInlines.h>
#include <JavaScriptCore/ArgList.h>
#include <JavaScriptCore/JSArray.h>
#include <JavaScriptCore/JSCInlines.h>
#include <JavaScriptCore/JSONAtomStringCacheInlines.h>
#include <JavaScriptCore/JSONCacheInlines.h>
#include <JavaScriptCore/ObjectConstructor.h>
#include <wtf/text/ASCIIFastPath.h>

Expand Down Expand Up @@ -165,10 +165,10 @@ class RowsToJS {
ALWAYS_INLINE Identifier identifier(const RowStr& key)
{
if constexpr (encoding == RowEncoding::Utf16)
return Identifier::fromString(m_vm, m_vm.jsonAtomStringCache.makeIdentifier(utf16(key)));
return Identifier::fromString(m_vm, m_vm.jsonCache().makeIdentifier(m_vm, utf16(key)));
else {
if (encoding == RowEncoding::Latin1 || charactersAreAllASCII(key.span())) [[likely]]
return Identifier::fromString(m_vm, m_vm.jsonAtomStringCache.makeIdentifier(key.span()));
return Identifier::fromString(m_vm, m_vm.jsonCache().makeIdentifier(m_vm, key.span()));
JSValue decoded = utf8(key);
if (!decoded) [[unlikely]]
return {};
Expand All @@ -180,11 +180,11 @@ class RowsToJS {
{
JSString* result;
if constexpr (encoding == RowEncoding::Utf16)
result = m_vm.jsonAtomStringCache.tryMakeJSString(utf16(s));
result = m_vm.jsonCache().tryMakeJSString(m_vm, utf16(s));
else {
if (encoding == RowEncoding::Utf8 && !charactersAreAllASCII(s.span())) [[unlikely]]
return utf8(s);
result = m_vm.jsonAtomStringCache.tryMakeJSString(s.span());
result = m_vm.jsonCache().tryMakeJSString(m_vm, s.span());
}
if (!result) [[unlikely]] {
auto scope = DECLARE_THROW_SCOPE(m_vm);
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/bindings/JSX509CertificatePrototype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,13 @@ JSC_DEFINE_HOST_FUNCTION(jsX509CertificateProtoFuncCheckIP, (JSGlobalObject * gl
RETURN_IF_EXCEPTION(scope, {});
auto view = ipString->view(globalObject);
RETURN_IF_EXCEPTION(scope, {});
WTF::CString ip = view->utf8();
WTF::UTF8CString ip = view->utf8();

// ignore flags
// uint32_t flags = getFlags(vm, globalObject, scope, callFrame->argument(1));
// RETURN_IF_EXCEPTION(scope, {});

auto check = thisObject->checkIP(globalObject, ip.data());
auto check = thisObject->checkIP(globalObject, ip.legacyCStringPointer());
RETURN_IF_EXCEPTION(scope, {});
if (!check) return JSValue::encode(jsUndefined());
return JSValue::encode(ipString);
Expand Down
4 changes: 2 additions & 2 deletions src/jsc/bindings/NodeTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static int noPasswordCallback(char*, int, int, void*)
// because forEachInIterable drives the iterator protocol and a tampered
// %ArrayIteratorPrototype%.next can detach an earlier element between pass-1
// callbacks.
using CACertInput = std::variant<WTF::CString, JSC::JSArrayBufferView*>;
using CACertInput = std::variant<WTF::UTF8CString, JSC::JSArrayBufferView*>;

JSC_DEFINE_HOST_FUNCTION(parseCACertificates, (JSC::JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
Expand Down Expand Up @@ -234,7 +234,7 @@ JSC_DEFINE_HOST_FUNCTION(parseCACertificates, (JSC::JSGlobalObject * globalObjec

for (auto& in : inputs) {
std::span<const uint8_t> bytes;
if (auto* utf8 = std::get_if<WTF::CString>(&in)) {
if (auto* utf8 = std::get_if<WTF::UTF8CString>(&in)) {
bytes = { reinterpret_cast<const uint8_t*>(utf8->data()), utf8->length() };
} else {
auto* view = std::get<JSC::JSArrayBufferView*>(in);
Expand Down
6 changes: 3 additions & 3 deletions src/jsc/bindings/Secrets.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ enum class Persist : uint8_t {

// Sync platform-specific implementations (used by threadpool)
// These use CString for thread safety - only called from threadpool
Error setPassword(const WTF::CString& service, const WTF::CString& name, WTF::CString&& password, bool allowUnrestrictedAccess, Persist persist);
Error setPassword(const WTF::UTF8CString& service, const WTF::UTF8CString& name, WTF::UTF8CString&& password, bool allowUnrestrictedAccess, Persist persist);

// Use a WTF::Vector here so we can zero out the memory.
std::optional<WTF::Vector<uint8_t>> getPassword(const WTF::CString& service, const WTF::CString& name, Error& error);
bool deletePassword(const WTF::CString& service, const WTF::CString& name, Error& error);
std::optional<WTF::Vector<uint8_t>> getPassword(const WTF::UTF8CString& service, const WTF::UTF8CString& name, Error& error);
bool deletePassword(const WTF::UTF8CString& service, const WTF::UTF8CString& name, Error& error);

} // namespace Secrets

Expand Down
12 changes: 6 additions & 6 deletions src/jsc/bindings/SecretsDarwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,15 +275,15 @@ static void updateError(Error& err, OSStatus status)
}
}

static ScopedCFRef createQuery(const CString& service, const CString& name)
static ScopedCFRef createQuery(const UTF8CString& service, const UTF8CString& name)
{
auto* framework = securityFramework();
if (!framework) return ScopedCFRef(nullptr);

ScopedCFRef cfServiceName(framework->CFStringCreateWithCString(
framework->kCFAllocatorDefault, service.data(), kCFStringEncodingUTF8));
framework->kCFAllocatorDefault, service.legacyCStringPointer(), kCFStringEncodingUTF8));
ScopedCFRef cfUser(framework->CFStringCreateWithCString(
framework->kCFAllocatorDefault, name.data(), kCFStringEncodingUTF8));
framework->kCFAllocatorDefault, name.legacyCStringPointer(), kCFStringEncodingUTF8));

if (!cfServiceName || !cfUser) return ScopedCFRef(nullptr);

Expand All @@ -301,7 +301,7 @@ static ScopedCFRef createQuery(const CString& service, const CString& name)
return ScopedCFRef(query);
}

Error setPassword(const CString& service, const CString& name, CString&& password, bool allowUnrestrictedAccess, Persist)
Error setPassword(const UTF8CString& service, const UTF8CString& name, UTF8CString&& password, bool allowUnrestrictedAccess, Persist)
{
Error err;

Expand Down Expand Up @@ -392,7 +392,7 @@ Error setPassword(const CString& service, const CString& name, CString&& passwor
return err;
}

std::optional<WTF::Vector<uint8_t>> getPassword(const CString& service, const CString& name, Error& err)
std::optional<WTF::Vector<uint8_t>> getPassword(const UTF8CString& service, const UTF8CString& name, Error& err)
{
err = Error {};

Expand Down Expand Up @@ -429,7 +429,7 @@ std::optional<WTF::Vector<uint8_t>> getPassword(const CString& service, const CS
return std::nullopt;
}

bool deletePassword(const CString& service, const CString& name, Error& err)
bool deletePassword(const UTF8CString& service, const UTF8CString& name, Error& err)
{
err = Error {};

Expand Down
22 changes: 11 additions & 11 deletions src/jsc/bindings/SecretsLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void updateError(Error& err, GError* gerror)
}
}

Error setPassword(const CString& service, const CString& name, CString&& password, bool allowUnrestrictedAccess, Persist)
Error setPassword(const UTF8CString& service, const UTF8CString& name, UTF8CString&& password, bool allowUnrestrictedAccess, Persist)
{
Error err;

Expand All @@ -293,18 +293,18 @@ Error setPassword(const CString& service, const CString& name, CString&& passwor

GError* gerror = nullptr;
// Combine service and name for label
auto label = makeString(String::fromUTF8(service.data()), "/"_s, String::fromUTF8(name.data()));
auto label = makeString(String::fromUTF8(service.span()), "/"_s, String::fromUTF8(name.span()));
auto labelUtf8 = label.utf8();

gboolean result = framework->secret_password_store_sync(
get_bun_schema(),
nullptr, // Let libsecret handle collection creation automatically
labelUtf8.legacyCStringPointer(),
password.data(),
password.legacyCStringPointer(),
nullptr, // cancellable
&gerror,
"service", service.data(),
"account", name.data(),
"service", service.legacyCStringPointer(),
"account", name.legacyCStringPointer(),
nullptr // end of attributes
);

Expand All @@ -319,7 +319,7 @@ Error setPassword(const CString& service, const CString& name, CString&& passwor
return err;
}

std::optional<WTF::Vector<uint8_t>> getPassword(const CString& service, const CString& name, Error& err)
std::optional<WTF::Vector<uint8_t>> getPassword(const UTF8CString& service, const UTF8CString& name, Error& err)
{
err = Error {};

Expand All @@ -336,8 +336,8 @@ std::optional<WTF::Vector<uint8_t>> getPassword(const CString& service, const CS
get_bun_schema(),
nullptr, // cancellable
&gerror,
"service", service.data(),
"account", name.data(),
"service", service.legacyCStringPointer(),
"account", name.legacyCStringPointer(),
nullptr // end of attributes
);

Expand All @@ -363,7 +363,7 @@ std::optional<WTF::Vector<uint8_t>> getPassword(const CString& service, const CS
return result;
}

bool deletePassword(const CString& service, const CString& name, Error& err)
bool deletePassword(const UTF8CString& service, const UTF8CString& name, Error& err)
{
err = Error {};

Expand All @@ -380,8 +380,8 @@ bool deletePassword(const CString& service, const CString& name, Error& err)
get_bun_schema(),
nullptr, // cancellable
&gerror,
"service", service.data(),
"account", name.data(),
"service", service.legacyCStringPointer(),
"account", name.legacyCStringPointer(),
nullptr // end of attributes
);

Expand Down
Loading
Loading