mirror of
https://github.com/oven-sh/bun
synced 2026-02-11 03:18:53 +00:00
Lots of stuff (#7027)
* Use debug mode by default * Enable build with assertions enabled * Update cli.zig * Update bun-linux-build.yml * Fixes * Fix `ASSERT_ENABLED` * try this * Update Dockerfile * mimalloc debug * Update CMakeLists.txt * `Bun.deepMatch` - fix assertion failures cc @dylan-conway, looks like we need to use `putDirectMayBeIndex` and check for `isCell` more carefully. * Object.create support in code generator and callbacks wrapper * Remove unused file * zig upgrade * zls * Fix various errors * Support `BuiltinAccessor` in create_hash_table script * Fix assertion failure in `process.mainModule` * Fix assertion failure in `onerror` * Fix assertion failure when creating a Worker * Fix asssertion failure when loading lots of files in bun test * Fix assertion failure when termating a `Worker` * Add helper for converting BunString to a WTFString * Fix assertion failure in notifyNeedTermination * Add more debug logs in `bun test` * Fix compiler warning in usockets * Fix assertion failure with `Worker` termination (another) * Fix assertion failure in `coerceToInt64` * Fix assertion failure in `BroadcastChannel` * Fix assertion failure in `Headers.prototype.getAll` * Fixes #7067 * Add heap analyzer label for CommonJS modules * Fix assertion failure in module.require && module.require.resolve * Remove unused code * Fix assertion failure in debugger * Fix crash in debugger * Fix assertion failures in bun:sqlite * Bump zig * Bump WebKit * Fix assertion failure in JSPromise::reject && JSInternalPromise::reject * Fix assertion failure in ReadableStream::cancel * Fix assertion failure in AsyncContextFrame::create * Fix assertion failure in bun:sqlite * Fix assertion failure in mocks * Fix assertion failure in ServerWebSocket.close * Fix assertion failure in N-API with subclasses * [napi] Make promises cheaper * undo * Don't check for exceptions in ObjectInitializationScope * Add separate entry point for test runner that doesn't generate code * Don't deref builtin code * Fix preload test * Fix assertion failure in memoryUsage() * Fix preload test, part 2 * Ensure that the env map for a Worker is empty after it is used * The pointer for the Arena allocator used in parsing should not change * Terminate thread on exit * Start to implement scriptExecutionStatus * Update worker.test.ts * Fix Dirent.name setter * Update settings.json * Fix assertion failure in node:http * Use correct value for `JSFinalObject::maxInlineCapacity` * JSFinalObject::maxInlineCapacity x2 * Don't strip when assertions are enabled * Make `m_wasTerminated` atomic * Preserve directives in the transpiler cc @ctjlewis * Workaround assertion failure in ServerWebSocket.sendBinary and ServerWebSocket.sendText * windows * Buffer lockfile serialization in-memory * PR feedback * PR feedback * PR feedback * Windows * quotes * Update CMakeLists.txt * Update bun-linux-build.yml * Update bun-linux-build.yml * Move this code to BunString.cpp * Update BunString.cpp --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
This commit is contained in:
@@ -64,6 +64,7 @@
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSSourceCode.h>
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
|
||||
extern "C" bool Bun__isBunMain(JSC::JSGlobalObject* global, const char* input_ptr, uint64_t input_len);
|
||||
|
||||
@@ -91,6 +92,16 @@ static bool canPerformFastEnumeration(Structure* s)
|
||||
|
||||
static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObject, JSCommonJSModule* moduleObject, JSString* dirname, JSValue filename, WTF::NakedPtr<Exception>& exception)
|
||||
{
|
||||
JSSourceCode* code = moduleObject->sourceCode.get();
|
||||
|
||||
// If an exception occurred somewhere else, we might have cleared the source code.
|
||||
if (UNLIKELY(code == nullptr)) {
|
||||
auto throwScope = DECLARE_THROW_SCOPE(vm);
|
||||
throwException(globalObject, throwScope, createError(globalObject, "Failed to evaluate module"_s));
|
||||
exception = throwScope.exception();
|
||||
return false;
|
||||
}
|
||||
|
||||
JSC::Structure* thisObjectStructure = globalObject->commonJSFunctionArgumentsStructure();
|
||||
|
||||
JSFunction* resolveFunction = JSC::JSBoundFunction::create(vm,
|
||||
@@ -118,7 +129,7 @@ static bool evaluateCommonJSModuleOnce(JSC::VM& vm, Zig::GlobalObject* globalObj
|
||||
// there is some possible GC issue where `thisObject` is gc'd before it should be
|
||||
globalObject->m_BunCommonJSModuleValue.set(vm, globalObject, thisObject);
|
||||
|
||||
JSValue empty = JSC::evaluate(globalObject, moduleObject->sourceCode.get()->sourceCode(), thisObject, exception);
|
||||
JSValue empty = JSC::evaluate(globalObject, code->sourceCode(), thisObject, exception);
|
||||
|
||||
ensureStillAliveHere(thisObject);
|
||||
globalObject->m_BunCommonJSModuleValue.clear();
|
||||
@@ -198,14 +209,14 @@ Structure* RequireFunctionPrototype::createStructure(
|
||||
JSC::VM& vm,
|
||||
JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(JSFunctionType, StructureFlags), info());
|
||||
return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
Structure* RequireResolveFunctionPrototype::createStructure(
|
||||
JSC::VM& vm,
|
||||
JSC::JSGlobalObject* globalObject)
|
||||
{
|
||||
return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(JSFunctionType, StructureFlags), info());
|
||||
return Structure::create(vm, globalObject, globalObject->functionPrototype(), TypeInfo(ObjectType, StructureFlags), info());
|
||||
}
|
||||
|
||||
RequireResolveFunctionPrototype* RequireResolveFunctionPrototype::create(JSC::JSGlobalObject* globalObject)
|
||||
@@ -811,7 +822,6 @@ void JSCommonJSModule::toSyntheticSource(JSC::JSGlobalObject* globalObject,
|
||||
auto result = this->exportsObject();
|
||||
|
||||
auto& vm = globalObject->vm();
|
||||
Identifier esModuleMarker = builtinNames(vm).__esModulePublicName();
|
||||
populateESMExports(globalObject, result, exportNames, exportValues, this->ignoreESModuleAnnotation);
|
||||
}
|
||||
|
||||
@@ -845,6 +855,20 @@ void JSCommonJSModule::visitChildrenImpl(JSCell* cell, Visitor& visitor)
|
||||
}
|
||||
|
||||
DEFINE_VISIT_CHILDREN(JSCommonJSModule);
|
||||
|
||||
void JSCommonJSModule::analyzeHeap(JSCell* cell, HeapAnalyzer& analyzer)
|
||||
{
|
||||
auto* thisObject = jsCast<JSCommonJSModule*>(cell);
|
||||
|
||||
if (auto* id = thisObject->m_id.get()) {
|
||||
if (!id->isRope()) {
|
||||
auto label = id->tryGetValue(false);
|
||||
analyzer.setLabelForCell(cell, label);
|
||||
}
|
||||
}
|
||||
Base::analyzeHeap(cell, analyzer);
|
||||
}
|
||||
|
||||
const JSC::ClassInfo JSCommonJSModule::s_info = { "Module"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSCommonJSModule) };
|
||||
const JSC::ClassInfo RequireResolveFunctionPrototype::s_info = { "resolve"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireResolveFunctionPrototype) };
|
||||
const JSC::ClassInfo RequireFunctionPrototype::s_info = { "require"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(RequireFunctionPrototype) };
|
||||
@@ -936,7 +960,7 @@ std::optional<JSC::SourceCode> createCommonJSModule(
|
||||
bool isBuiltIn)
|
||||
{
|
||||
JSCommonJSModule* moduleObject;
|
||||
WTF::String sourceURL = Bun::toWTFString(source.source_url);
|
||||
WTF::String sourceURL = source.source_url.toWTFString();
|
||||
|
||||
JSValue specifierValue = Bun::toJS(globalObject, source.specifier);
|
||||
JSValue entry = globalObject->requireMap()->get(globalObject, specifierValue);
|
||||
@@ -959,13 +983,10 @@ std::optional<JSC::SourceCode> createCommonJSModule(
|
||||
dirname = JSC::jsSubstring(globalObject, requireMapKey, 0, index);
|
||||
}
|
||||
|
||||
JSC::SourceCode rawInputSource(
|
||||
WTFMove(sourceProvider));
|
||||
|
||||
moduleObject = JSCommonJSModule::create(
|
||||
vm,
|
||||
globalObject->CommonJSModuleObjectStructure(),
|
||||
requireMapKey, filename, dirname, JSC::JSSourceCode::create(vm, WTFMove(rawInputSource)));
|
||||
requireMapKey, filename, dirname, JSC::JSSourceCode::create(vm, SourceCode(WTFMove(sourceProvider))));
|
||||
|
||||
moduleObject->putDirect(vm,
|
||||
WebCore::clientData(vm)->builtinNames().exportsPublicName(),
|
||||
|
||||
Reference in New Issue
Block a user