mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
more mutexes
Former-commit-id: 52966012b4b74d24ab28a0c75740aef35fb75327
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
#include "root.h"
|
||||
#include <JavaScriptCore/SourceProvider.h>
|
||||
|
||||
#include <wtf/Lock.h>
|
||||
|
||||
namespace JSC {
|
||||
|
||||
// SourceProvider::SourceProvider(const SourceOrigin&, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType) {
|
||||
|
||||
// }
|
||||
|
||||
|
||||
// SourceProvider::SourceProvider(const SourceOrigin& sourceOrigin, String&& sourceURL, const TextPosition& startPosition, SourceProviderSourceType sourceType)
|
||||
// : m_sourceType(sourceType)
|
||||
// , m_sourceOrigin(sourceOrigin)
|
||||
// , m_sourceURL(WTFMove(sourceURL))
|
||||
// , m_startPosition(startPosition)
|
||||
// {
|
||||
// }
|
||||
|
||||
// SourceProvider::~SourceProvider()
|
||||
// {
|
||||
// }
|
||||
|
||||
// static Lock providerIdLock;
|
||||
|
||||
// void SourceProvider::getID()
|
||||
// {
|
||||
// Locker locker { providerIdLock };
|
||||
// if (!m_id) {
|
||||
// static intptr_t nextProviderID = 0;
|
||||
// m_id = ++nextProviderID;
|
||||
// RELEASE_ASSERT(m_id);
|
||||
// }
|
||||
// }
|
||||
|
||||
} // namespace JSC
|
||||
|
||||
@@ -82,14 +82,16 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
|
||||
|
||||
extern "C" JSC__JSGlobalObject *Zig__GlobalObject__create(JSClassRef *globalObjectClass, int count,
|
||||
void *console_client) {
|
||||
JSC::Options::useSourceProviderCache() = true;
|
||||
JSC::Options::useUnlinkedCodeBlockJettisoning() = false;
|
||||
JSC::Options::useTopLevelAwait() = true;
|
||||
JSC::Options::exposeInternalModuleLoader() = true;
|
||||
|
||||
std::set_terminate([]() { Zig__GlobalObject__onCrash(); });
|
||||
WTF::initializeMainThread();
|
||||
JSC::initialize();
|
||||
|
||||
// JSC::Options::useCodeCache() = false;
|
||||
JSC::Options::useSourceProviderCache() = true;
|
||||
JSC::Options::useUnlinkedCodeBlockJettisoning() = false;
|
||||
JSC::Options::useTopLevelAwait() = true;
|
||||
|
||||
JSC::VM &vm = JSC::VM::create(JSC::LargeHeap).leakRef();
|
||||
vm.heap.acquireAccess();
|
||||
@@ -288,8 +290,6 @@ extern "C" bool Zig__GlobalObject__resetModuleRegistryMap(JSC__JSGlobalObject *g
|
||||
obj->putDirect(globalObject->vm(), identifier,
|
||||
map->clone(globalObject, globalObject->vm(), globalObject->mapStructure()));
|
||||
|
||||
vm.codeCache()->write(vm);
|
||||
vm.shrinkFootprintWhenIdle();
|
||||
// vm.deleteAllLinkedCode(JSC::DeleteAllCodeEffort::DeleteAllCodeIfNotCollecting);
|
||||
// JSC::Heap::PreventCollectionScope(vm.heap);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "ZigSourceProvider.h"
|
||||
#include "helpers.h"
|
||||
#include "root.h"
|
||||
#include <JavaScriptCore/BytecodeCacheError.h>
|
||||
#include <JavaScriptCore/CodeCache.h>
|
||||
|
||||
@@ -39,12 +40,8 @@ Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource) {
|
||||
JSC::SourceProviderSourceType::Module));
|
||||
|
||||
} else {
|
||||
Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::create(
|
||||
resolvedSource.source_code.ptr, resolvedSource.source_code.len,
|
||||
[=](WTF::ExternalStringImpl *str, void *ptr, unsigned int len) {
|
||||
// ZigString__free((const unsigned char *)ptr, len,
|
||||
// allocator);
|
||||
});
|
||||
Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::createStatic(
|
||||
resolvedSource.source_code.ptr, resolvedSource.source_code.len);
|
||||
return adoptRef(*new SourceProvider(
|
||||
resolvedSource, reinterpret_cast<WTF::StringImpl *>(stringImpl_.ptr()),
|
||||
JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace JSC {
|
||||
class Structure;
|
||||
class Identifier;
|
||||
class SourceCodeKey;
|
||||
|
||||
class SourceProvider;
|
||||
} // namespace JSC
|
||||
|
||||
#include "ZigConsoleClient.h"
|
||||
|
||||
@@ -1434,6 +1434,9 @@ const WTF__StringImpl *JSC__PropertyName__uid(JSC__PropertyName *arg0) { return
|
||||
|
||||
#pragma mark - JSC::VM
|
||||
|
||||
void JSC__VM__shrinkFootprint(JSC__VM *arg0) { arg0->shrinkFootprintWhenIdle(); };
|
||||
void JSC__VM__whenIdle(JSC__VM *arg0, void (*ArgFn1)()) { arg0->whenIdle(ArgFn1); };
|
||||
|
||||
JSC__JSLock *JSC__VM__apiLock(JSC__VM *arg0) { return makeRefPtr((*arg0).apiLock()).leakRef(); }
|
||||
JSC__VM *JSC__VM__create(unsigned char HeapType0) {
|
||||
JSC::VM *vm =
|
||||
|
||||
@@ -1555,6 +1555,21 @@ pub const VM = extern struct {
|
||||
return cppFn("deleteAllCode", .{ vm, global_object });
|
||||
}
|
||||
|
||||
pub fn whenIdle(
|
||||
vm: *VM,
|
||||
callback: fn (...) callconv(.C) void,
|
||||
) void {
|
||||
return cppFn("whenIdle", .{ vm, callback });
|
||||
}
|
||||
|
||||
pub fn shrinkFootprint(
|
||||
vm: *VM,
|
||||
) void {
|
||||
return cppFn("shrinkFootprint", .{
|
||||
vm,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn setExecutionForbidden(vm: *VM, forbidden: bool) void {
|
||||
cppFn("setExecutionForbidden", .{ vm, forbidden });
|
||||
}
|
||||
@@ -1597,7 +1612,7 @@ pub const VM = extern struct {
|
||||
});
|
||||
}
|
||||
|
||||
pub const Extern = [_][]const u8{ "deleteAllCode", "apiLock", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks" };
|
||||
pub const Extern = [_][]const u8{ "deleteAllCode", "apiLock", "create", "deinit", "setExecutionForbidden", "executionForbidden", "isEntered", "throwError", "drainMicrotasks", "whenIdle", "shrinkFootprint" };
|
||||
};
|
||||
|
||||
pub const ThrowScope = extern struct {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1630718473
|
||||
//-- AUTOGENERATED FILE -- 1630806668
|
||||
// clang-format off
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//-- AUTOGENERATED FILE -- 1630718473
|
||||
//-- AUTOGENERATED FILE -- 1630806668
|
||||
// clang-format: off
|
||||
#pragma once
|
||||
|
||||
@@ -493,7 +493,9 @@ CPP_DECL void JSC__VM__drainMicrotasks(JSC__VM* arg0);
|
||||
CPP_DECL bool JSC__VM__executionForbidden(JSC__VM* arg0);
|
||||
CPP_DECL bool JSC__VM__isEntered(JSC__VM* arg0);
|
||||
CPP_DECL void JSC__VM__setExecutionForbidden(JSC__VM* arg0, bool arg1);
|
||||
CPP_DECL void JSC__VM__shrinkFootprint(JSC__VM* arg0);
|
||||
CPP_DECL bool JSC__VM__throwError(JSC__VM* arg0, JSC__JSGlobalObject* arg1, JSC__ThrowScope* arg2, const unsigned char* arg3, size_t arg4);
|
||||
CPP_DECL void JSC__VM__whenIdle(JSC__VM* arg0, void (* ArgFn1)());
|
||||
|
||||
#pragma mark - JSC::ThrowScope
|
||||
|
||||
|
||||
@@ -307,7 +307,9 @@ pub extern fn JSC__VM__drainMicrotasks(arg0: [*c]JSC__VM) void;
|
||||
pub extern fn JSC__VM__executionForbidden(arg0: [*c]JSC__VM) bool;
|
||||
pub extern fn JSC__VM__isEntered(arg0: [*c]JSC__VM) bool;
|
||||
pub extern fn JSC__VM__setExecutionForbidden(arg0: [*c]JSC__VM, arg1: bool) void;
|
||||
pub extern fn JSC__VM__shrinkFootprint(arg0: [*c]JSC__VM) void;
|
||||
pub extern fn JSC__VM__throwError(arg0: [*c]JSC__VM, arg1: [*c]JSC__JSGlobalObject, arg2: [*c]JSC__ThrowScope, arg3: [*c]const u8, arg4: usize) bool;
|
||||
pub extern fn JSC__VM__whenIdle(arg0: [*c]JSC__VM, ArgFn1: ?fn (...) callconv(.C) void) void;
|
||||
pub extern fn JSC__ThrowScope__clearException(arg0: [*c]JSC__ThrowScope) void;
|
||||
pub extern fn JSC__ThrowScope__declare(arg0: [*c]JSC__VM, arg1: [*c]u8, arg2: [*c]u8, arg3: usize) bJSC__ThrowScope;
|
||||
pub extern fn JSC__ThrowScope__exception(arg0: [*c]JSC__ThrowScope) [*c]JSC__Exception;
|
||||
|
||||
Reference in New Issue
Block a user