Skip to content
Open
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 = "549170099226f816a4b204ea1d8fa102fb79eefa";
export const WEBKIT_VERSION = "autobuild-preview-pr-370-06ee8632";

/**
* WebKit (JavaScriptCore) — the JS engine.
Expand Down
40 changes: 3 additions & 37 deletions src/bundler_jsc/analyze_jsc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ pub(crate) extern "C" fn zig__ModuleInfoDeserialized__toJSModuleRecord(
vm: &VM,
module_key: &IdentifierArray,
source_code: &SourceCode,
declared_variables: &mut VariableEnvironment,
lexical_variables: &mut VariableEnvironment,
res: &ModuleInfoDeserialized,
) -> *mut JSModuleRecord {
// Ownership of `res` stays with the caller; this function only reads it.
Expand Down Expand Up @@ -81,9 +79,9 @@ pub(crate) extern "C" fn zig__ModuleInfoDeserialized__toJSModuleRecord(
return core::ptr::null_mut();
}
match k {
RecordKind::DeclaredVariable => declared_variables.add(vm, identifiers, buffer[i]),
RecordKind::LexicalVariable => lexical_variables.add(vm, identifiers, buffer[i]),
RecordKind::ImportInfoSingle
RecordKind::DeclaredVariable
| RecordKind::LexicalVariable
Comment thread
robobun marked this conversation as resolved.
| RecordKind::ImportInfoSingle
| RecordKind::ImportInfoSingleTypeScript
| RecordKind::ImportInfoNamespace
| RecordKind::ImportInfoNamespaceDefer
Expand All @@ -102,8 +100,6 @@ pub(crate) extern "C" fn zig__ModuleInfoDeserialized__toJSModuleRecord(
vm,
module_key,
source_code,
declared_variables,
lexical_variables,
res.flags.contains_import_meta(),
res.flags.is_typescript(),
res.flags.has_tla(),
Expand Down Expand Up @@ -216,30 +212,6 @@ pub(crate) extern "C" fn zig__ModuleInfoDeserialized__toJSModuleRecord(

// ─── opaque FFI types ─────────────────────────────────────────────────────────

bun_opaque::opaque_ffi! { pub struct VariableEnvironment; }
unsafe extern "C" {
fn JSC__VariableEnvironment__add(
environment: *mut VariableEnvironment,
vm: *const VM,
identifier_array: *mut IdentifierArray,
identifier_index: StringID,
);
}
impl VariableEnvironment {
// Forwards `identifier_array` to C++ without dereferencing; not_unsafe_ptr_arg_deref is a false positive on opaque-token forwarding.
#[allow(clippy::not_unsafe_ptr_arg_deref)]
#[inline]
pub fn add(
&mut self,
vm: &VM,
identifier_array: *mut IdentifierArray,
identifier_index: StringID,
) {
// SAFETY: self is a valid &mut VariableEnvironment from C++; identifier_array is live (scopeguard).
unsafe { JSC__VariableEnvironment__add(self, vm, identifier_array, identifier_index) }
}
}

bun_opaque::opaque_ffi! { pub struct IdentifierArray; }
unsafe extern "C" {
fn JSC__IdentifierArray__create(len: usize) -> *mut IdentifierArray;
Expand Down Expand Up @@ -284,8 +256,6 @@ unsafe extern "C" {
vm: *const VM,
module_key: *const IdentifierArray,
source_code: *const SourceCode,
declared_variables: *mut VariableEnvironment,
lexical_variables: *mut VariableEnvironment,
has_import_meta: bool,
is_typescript: bool,
has_tla: bool,
Expand Down Expand Up @@ -384,8 +354,6 @@ impl JSModuleRecord {
vm: &VM,
module_key: &IdentifierArray,
source_code: &SourceCode,
declared_variables: &mut VariableEnvironment,
lexical_variables: &mut VariableEnvironment,
has_import_meta: bool,
is_typescript: bool,
has_tla: bool,
Expand All @@ -397,8 +365,6 @@ impl JSModuleRecord {
vm,
module_key,
source_code,
declared_variables,
lexical_variables,
has_import_meta,
is_typescript,
has_tla,
Expand Down
51 changes: 5 additions & 46 deletions src/jsc/bindings/BunAnalyzeTranspiledModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Identifier getFromIdentifierArray(VM& vm, Identifier* identifierArray, uint32_t
return identifierArray[n];
}

extern "C" JSModuleRecord* zig__ModuleInfoDeserialized__toJSModuleRecord(JSGlobalObject* globalObject, VM& vm, const Identifier& module_key, const SourceCode& source_code, VariableEnvironment& declared_variables, VariableEnvironment& lexical_variables, bun_ModuleInfoDeserialized* module_info);
extern "C" JSModuleRecord* zig__ModuleInfoDeserialized__toJSModuleRecord(JSGlobalObject* globalObject, VM& vm, const Identifier& module_key, const SourceCode& source_code, bun_ModuleInfoDeserialized* module_info);
extern "C" void zig__renderDiff(const char* expected_ptr, size_t expected_len, const char* received_ptr, size_t received_len, JSGlobalObject* globalObject);

extern "C" Identifier* JSC__IdentifierArray__create(size_t len)
Expand All @@ -55,23 +55,9 @@ extern "C" void JSC__IdentifierArray__setFromUtf8(Identifier* identifierArray, s
identifierArray[n] = Identifier::fromString(vm, AtomString::fromUTF8(std::span<const char>(str, len)));
}

extern "C" void JSC__VariableEnvironment__add(VariableEnvironment& environment, VM& vm, Identifier* identifierArray, uint32_t index)
extern "C" JSModuleRecord* JSC_JSModuleRecord__create(JSGlobalObject* globalObject, VM& vm, const Identifier* moduleKey, const SourceCode& sourceCode, bool hasImportMeta, bool isTypescript, bool hasTLA)
{
environment.add(getFromIdentifierArray(vm, identifierArray, index));
}

extern "C" VariableEnvironment* JSC_JSModuleRecord__declaredVariables(JSModuleRecord* moduleRecord)
{
return const_cast<VariableEnvironment*>(&moduleRecord->declaredVariables());
}
extern "C" VariableEnvironment* JSC_JSModuleRecord__lexicalVariables(JSModuleRecord* moduleRecord)
{
return const_cast<VariableEnvironment*>(&moduleRecord->lexicalVariables());
}

extern "C" JSModuleRecord* JSC_JSModuleRecord__create(JSGlobalObject* globalObject, VM& vm, const Identifier* moduleKey, const SourceCode& sourceCode, const VariableEnvironment& declaredVariables, const VariableEnvironment& lexicalVariables, bool hasImportMeta, bool isTypescript, bool hasTLA)
{
JSModuleRecord* result = JSModuleRecord::create(globalObject, vm, globalObject->moduleRecordStructure(), *moduleKey, sourceCode, declaredVariables, lexicalVariables, hasImportMeta ? ImportMetaFeature : 0);
JSModuleRecord* result = JSModuleRecord::create(globalObject, vm, globalObject->moduleRecordStructure(), *moduleKey, sourceCode, hasImportMeta ? ImportMetaFeature : 0);
result->m_isTypeScript = isTypescript;
result->setHasTLA(hasTLA);
return result;
Expand Down Expand Up @@ -173,9 +159,6 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj
return promise;
};

VariableEnvironment declaredVariables = VariableEnvironment();
VariableEnvironment lexicalVariables = VariableEnvironment();

auto provider = static_cast<Zig::SourceProvider*>(sourceCode.provider());

if (provider->m_resolvedSource.module_info == nullptr) {
Expand All @@ -184,7 +167,7 @@ extern "C" EncodedJSValue Bun__analyzeTranspiledModule(JSGlobalObject* globalObj
}

auto* moduleInfo = static_cast<bun_ModuleInfoDeserialized*>(provider->m_resolvedSource.module_info);
auto moduleRecord = zig__ModuleInfoDeserialized__toJSModuleRecord(globalObject, vm, moduleKey, sourceCode, declaredVariables, lexicalVariables, moduleInfo);
auto moduleRecord = zig__ModuleInfoDeserialized__toJSModuleRecord(globalObject, vm, moduleKey, sourceCode, moduleInfo);
// Under --isolate the same SourceProvider is reused across globals via the
// IsolatedModuleCache, so module_info must remain alive on the provider;
// ~SourceProvider frees it. Otherwise, free now.
Expand Down Expand Up @@ -220,7 +203,7 @@ static EncodedJSValue fallbackParse(JSGlobalObject* globalObject, const Identifi
RELEASE_AND_RETURN(scope, JSValue::encode(rejectWithError(error.toErrorObject(globalObject, sourceCode))));
ASSERT(moduleProgramNode);

ModuleAnalyzer moduleAnalyzer(globalObject, moduleKey, sourceCode, moduleProgramNode->varDeclarations(), moduleProgramNode->lexicalVariables(), moduleProgramNode->features());
ModuleAnalyzer moduleAnalyzer(globalObject, moduleKey, sourceCode, moduleProgramNode->features());
RETURN_IF_EXCEPTION(scope, JSValue::encode(promise->rejectWithCaughtException(vm, scope)));

auto result = moduleAnalyzer.analyze(*moduleProgramNode);
Expand Down Expand Up @@ -254,30 +237,6 @@ String dumpRecordInfo(JSModuleRecord* moduleRecord)
{
WTF::StringPrintStream stream;

{
Vector<String> sortedVars;
for (const auto& pair : moduleRecord->declaredVariables())
sortedVars.append(String(pair.key.get()));
std::sort(sortedVars.begin(), sortedVars.end(), [](const String& a, const String& b) {
return codePointCompare(a, b) < 0;
});
stream.print(" varDeclarations:\n");
for (const auto& name : sortedVars)
stream.print(" - ", name, "\n");
}

{
Vector<String> sortedVars;
for (const auto& pair : moduleRecord->lexicalVariables())
sortedVars.append(String(pair.key.get()));
std::sort(sortedVars.begin(), sortedVars.end(), [](const String& a, const String& b) {
return codePointCompare(a, b) < 0;
});
stream.print(" lexicalVariables:\n");
for (const auto& name : sortedVars)
stream.print(" - ", name, "\n");
}

stream.print(" features: (not accessible)\n");

stream.print("\nAnalyzing ModuleRecord key(", moduleRecord->moduleKey().impl(), ")\n");
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/bindings/JSEnvironmentVariableMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ static void applyTZFromString(JSGlobalObject* globalObject, const String& value)
{
if (value.length() < 32 && WTF::setTimeZoneOverride(value)) {
WTF::timeZoneDidChange();
JSC::getVM(globalObject).dateCache.clearForTimeZoneChange();
JSC::getVM(globalObject).clearForTimeZoneChange();
}
}
static void applyTLSRejectFromString(JSGlobalObject*, const String& value)
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/bindings/NodeVMSourceTextModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ JSValue NodeVMSourceTextModule::createModuleRecord(JSGlobalObject* globalObject)
return {};
}

ModuleAnalyzer analyzer(globalObject, Identifier::fromString(vm, m_identifier), m_sourceCode, node->varDeclarations(), node->lexicalVariables(), AllFeatures);
ModuleAnalyzer analyzer(globalObject, Identifier::fromString(vm, m_identifier), m_sourceCode, AllFeatures);

RETURN_IF_EXCEPTION(scope, {});
ASSERT(node != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/bindings/ZigGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ extern "C" bool JSGlobalObject__setTimeZone(JSC::JSGlobalObject* globalObject, c

if (WTF::setTimeZoneOverride(Zig::toString(*timeZone))) {
WTF::timeZoneDidChange();
vm.dateCache.clearForTimeZoneChange();
vm.clearForTimeZoneChange();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/jsc/bindings/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6047,7 +6047,7 @@ CPP_DECL void JSC__VM__setControlFlowProfiler(JSC::VM* vm, bool isEnabled)

CPP_DECL void JSC__VM__performOpportunisticallyScheduledTasks(JSC::VM* vm, double until)
{
vm->performOpportunisticallyScheduledTasks(MonotonicTime::now() + Seconds(until), {});
vm->performOpportunisticallyScheduledTasks(ApproximateTime::now() + Seconds(until), {});
}

extern "C" EncodedJSValue JSC__createError(JSC::JSGlobalObject* globalObject, const BunString* str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ static IterationRecord getIteratorAsync(JSC::VM& vm, JSGlobalObject* globalObjec
}
IterationRecord syncRecord = iteratorDirect(globalObject, syncIterator);
RETURN_IF_EXCEPTION(scope, {});
auto* asyncFromSyncIterator = JSAsyncFromSyncIterator::create(vm, globalObject->asyncFromSyncIteratorStructure(), syncRecord.iterator, syncRecord.nextMethod);
auto* asyncFromSyncIterator = JSAsyncFromSyncIterator::create(vm, globalObject->asyncFromSyncIteratorStructure(), asObject(syncRecord.iterator), syncRecord.nextMethod, JSC::IterationMode::Generic);
RETURN_IF_EXCEPTION(scope, {});
RELEASE_AND_RETURN(scope, iteratorDirect(globalObject, asyncFromSyncIterator));
}
Expand Down
2 changes: 1 addition & 1 deletion src/jsc/modules/BunJSCModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ JSC_DEFINE_HOST_FUNCTION(functionSetTimeZone, (JSGlobalObject * globalObject, Ca
return {};
}
WTF::timeZoneDidChange();
vm.dateCache.clearForTimeZoneChange();
vm.clearForTimeZoneChange();
WTF::Vector<char16_t, 32> buffer;
WTF::getTimeZoneOverride(buffer);
WTF::String timeZoneString(buffer.span());
Expand Down
Loading
Loading