mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 23:18:47 +00:00
Compare commits
1 Commits
don/refact
...
jdalton/ar
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8843060a24 |
@@ -1,7 +1,7 @@
|
||||
#include "root.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "AsyncContextFrame.h"
|
||||
#include <JavaScriptCore/InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/Bun_InternalFieldTuple.h>
|
||||
|
||||
using namespace JSC;
|
||||
using namespace WebCore;
|
||||
@@ -10,11 +10,11 @@ const ClassInfo AsyncContextFrame::s_info = { "AsyncContextFrame"_s, &Base::s_in
|
||||
|
||||
AsyncContextFrame* AsyncContextFrame::create(VM& vm, JSC::Structure* structure, JSValue callback, JSValue context)
|
||||
{
|
||||
AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, structure);
|
||||
asyncContextData->finishCreation(vm);
|
||||
asyncContextData->callback.set(vm, asyncContextData, callback);
|
||||
asyncContextData->context.set(vm, asyncContextData, context);
|
||||
return asyncContextData;
|
||||
AsyncContextFrame* asyncContextFrame = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, structure);
|
||||
asyncContextFrame->finishCreation(vm);
|
||||
asyncContextFrame->callback.set(vm, asyncContextFrame, callback);
|
||||
asyncContextFrame->context.set(vm, asyncContextFrame, context);
|
||||
return asyncContextFrame;
|
||||
}
|
||||
|
||||
AsyncContextFrame* AsyncContextFrame::create(JSGlobalObject* global, JSValue callback, JSValue context)
|
||||
@@ -22,11 +22,11 @@ AsyncContextFrame* AsyncContextFrame::create(JSGlobalObject* global, JSValue cal
|
||||
auto& vm = global->vm();
|
||||
ASSERT(callback.isCallable());
|
||||
auto* structure = jsCast<Zig::GlobalObject*>(global)->AsyncContextFrameStructure();
|
||||
AsyncContextFrame* asyncContextData = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, structure);
|
||||
asyncContextData->finishCreation(vm);
|
||||
asyncContextData->callback.set(vm, asyncContextData, callback);
|
||||
asyncContextData->context.set(vm, asyncContextData, context);
|
||||
return asyncContextData;
|
||||
AsyncContextFrame* asyncContextFrame = new (NotNull, allocateCell<AsyncContextFrame>(vm)) AsyncContextFrame(vm, structure);
|
||||
asyncContextFrame->finishCreation(vm);
|
||||
asyncContextFrame->callback.set(vm, asyncContextFrame, callback);
|
||||
asyncContextFrame->context.set(vm, asyncContextFrame, context);
|
||||
return asyncContextFrame;
|
||||
}
|
||||
|
||||
JSC::Structure* AsyncContextFrame::createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
|
||||
@@ -36,10 +36,10 @@ JSC::Structure* AsyncContextFrame::createStructure(JSC::VM& vm, JSC::JSGlobalObj
|
||||
|
||||
JSValue AsyncContextFrame::withAsyncContextIfNeeded(JSGlobalObject* globalObject, JSValue callback)
|
||||
{
|
||||
JSValue context = globalObject->m_asyncContextData.get()->getInternalField(0);
|
||||
JSValue asyncContextData = globalObject->asyncContextTuple()->getInternalField(0);
|
||||
|
||||
// If there is no async context, do not snapshot the callback.
|
||||
if (context.isUndefined()) {
|
||||
if (asyncContextData.isUndefined()) {
|
||||
return callback;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ JSValue AsyncContextFrame::withAsyncContextIfNeeded(JSGlobalObject* globalObject
|
||||
vm,
|
||||
jsCast<Zig::GlobalObject*>(globalObject)->AsyncContextFrameStructure(),
|
||||
callback,
|
||||
context);
|
||||
asyncContextData);
|
||||
}
|
||||
|
||||
template<typename Visitor>
|
||||
@@ -73,17 +73,17 @@ extern "C" JSC::EncodedJSValue AsyncContextFrame__withAsyncContextIfNeeded(JSGlo
|
||||
if (!functionObject.isCell()) \
|
||||
return jsUndefined(); \
|
||||
auto& vm = global->vm(); \
|
||||
JSValue restoreAsyncContext; \
|
||||
InternalFieldTuple* asyncContextData = nullptr; \
|
||||
JSValue oldAsyncContextData; \
|
||||
InternalFieldTuple* asyncContextTuple = nullptr; \
|
||||
if (auto* wrapper = jsDynamicCast<AsyncContextFrame*>(functionObject)) { \
|
||||
functionObject = jsCast<JSC::JSObject*>(wrapper->callback.get()); \
|
||||
asyncContextData = global->m_asyncContextData.get(); \
|
||||
restoreAsyncContext = asyncContextData->getInternalField(0); \
|
||||
asyncContextData->putInternalField(vm, 0, wrapper->context.get()); \
|
||||
asyncContextTuple = global->asyncContextTuple(); \
|
||||
oldAsyncContextData = asyncContextTuple->getInternalField(0); \
|
||||
asyncContextTuple->putInternalField(vm, 0, wrapper->context.get()); \
|
||||
} \
|
||||
auto result = JSC::profiledCall(__VA_ARGS__); \
|
||||
if (asyncContextData) { \
|
||||
asyncContextData->putInternalField(vm, 0, restoreAsyncContext); \
|
||||
if (asyncContextTuple) { \
|
||||
asyncContextTuple->putInternalField(vm, 0, oldAsyncContextData); \
|
||||
} \
|
||||
return result;
|
||||
|
||||
|
||||
@@ -1,36 +1,39 @@
|
||||
|
||||
#include "root.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "JavaScriptCore/ArgList.h"
|
||||
#include "JSDOMURL.h"
|
||||
#include "headers.h"
|
||||
#include "helpers.h"
|
||||
#include "IDLTypes.h"
|
||||
#include "DOMURL.h"
|
||||
#include <JavaScriptCore/JSPromise.h>
|
||||
#include <JavaScriptCore/JSBase.h>
|
||||
|
||||
#include <JavaScriptCore/ArgList.h>
|
||||
#include <JavaScriptCore/BuiltinNames.h>
|
||||
#include "ScriptExecutionContext.h"
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/JSBase.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/JSObject.h>
|
||||
#include <JavaScriptCore/JSPromise.h>
|
||||
#include <JavaScriptCore/LazyClassStructure.h>
|
||||
#include <JavaScriptCore/LazyClassStructureInlines.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include "headers.h"
|
||||
#include <wtf/Compiler.h>
|
||||
|
||||
#include "JSDOMURL.h"
|
||||
#include "BunObject.h"
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
#include <JavaScriptCore/JSObject.h>
|
||||
|
||||
#include "BunObject+exports.h"
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMURL.h"
|
||||
#include "Exception.h"
|
||||
#include "BunObject+exports.h"
|
||||
#include "JSDOMException.h"
|
||||
#include "IDLTypes.h"
|
||||
#include "JSDOMConvert.h"
|
||||
#include "wtf/Compiler.h"
|
||||
#include "JSDOMException.h"
|
||||
#include "JSDOMURL.h"
|
||||
#include "PathInlines.h"
|
||||
#include "ScriptExecutionContext.h"
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
namespace Bun {
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "BunProcess.h"
|
||||
#include <JavaScriptCore/InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/Bun_InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/JSMicrotask.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/NumberPrototype.h>
|
||||
|
||||
@@ -29,49 +29,46 @@
|
||||
* different value. In that case, it will have a stale value.
|
||||
*/
|
||||
|
||||
#include "headers.h"
|
||||
#include "JavaScriptCore/JSCast.h"
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include "root.h"
|
||||
#include "JavaScriptCore/SourceCode.h"
|
||||
#include "headers-handwritten.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "headers.h"
|
||||
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSCast.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSSourceCode.h>
|
||||
#include <JavaScriptCore/JSString.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/OptionsList.h>
|
||||
#include <JavaScriptCore/ParserError.h>
|
||||
#include <JavaScriptCore/ScriptExecutable.h>
|
||||
#include <JavaScriptCore/SourceOrigin.h>
|
||||
#include <JavaScriptCore/StackFrame.h>
|
||||
#include <JavaScriptCore/StackVisitor.h>
|
||||
#include "BunClientData.h"
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include "ImportMetaObject.h"
|
||||
|
||||
#include <JavaScriptCore/TypedArrayInlines.h>
|
||||
#include <JavaScriptCore/PropertyNameArray.h>
|
||||
#include <JavaScriptCore/JSWeakMap.h>
|
||||
#include <JavaScriptCore/JSWeakMapInlines.h>
|
||||
#include <JavaScriptCore/JSWithScope.h>
|
||||
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include "ModuleLoader.h"
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include "ZigSourceProvider.h"
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include "CommonJSModuleRecord.h"
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSSourceCode.h>
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/OptionsList.h>
|
||||
#include <JavaScriptCore/ParserError.h>
|
||||
#include <JavaScriptCore/PropertyNameArray.h>
|
||||
#include <JavaScriptCore/ScriptExecutable.h>
|
||||
#include <JavaScriptCore/SourceCode.h>
|
||||
#include <JavaScriptCore/SourceOrigin.h>
|
||||
#include <JavaScriptCore/StackFrame.h>
|
||||
#include <JavaScriptCore/StackVisitor.h>
|
||||
#include <JavaScriptCore/TypedArrayInlines.h>
|
||||
#include <wtf/NakedPtr.h>
|
||||
#include <wtf/URL.h>
|
||||
|
||||
#include "ModuleLoader.h"
|
||||
#include "CommonJSModuleRecord.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "ImportMetaObject.h"
|
||||
#include "PathInlines.h"
|
||||
#include "wtf/NakedPtr.h"
|
||||
#include "wtf/URL.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "ZigSourceProvider.h"
|
||||
|
||||
extern "C" bool Bun__isBunMain(JSC::JSGlobalObject* global, const BunString*);
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#include "JavaScriptCore/JSGlobalObject.h"
|
||||
#include "root.h"
|
||||
#include "headers-handwritten.h"
|
||||
#include "wtf/NakedPtr.h"
|
||||
|
||||
#include <JavaScriptCore/JSGlobalObject.h>
|
||||
#include <wtf/NakedPtr.h>
|
||||
|
||||
namespace Zig {
|
||||
class GlobalObject;
|
||||
|
||||
@@ -1,23 +1,20 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "JavaScriptCore/ArgList.h"
|
||||
#include "headers.h"
|
||||
#include "ConsoleObject.h"
|
||||
|
||||
#include <JavaScriptCore/ArgList.h>
|
||||
#include <JavaScriptCore/ConsoleClient.h>
|
||||
#include <JavaScriptCore/ConsoleMessage.h>
|
||||
#include <JavaScriptCore/InspectorConsoleAgent.h>
|
||||
#include <JavaScriptCore/InspectorDebuggerAgent.h>
|
||||
#include <JavaScriptCore/InspectorScriptProfilerAgent.h>
|
||||
#include <JavaScriptCore/JSGlobalObjectDebuggable.h>
|
||||
#include <JavaScriptCore/JSGlobalObjectInspectorController.h>
|
||||
#include <JavaScriptCore/JSString.h>
|
||||
#include <JavaScriptCore/ScriptArguments.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
|
||||
#include <JavaScriptCore/JSGlobalObjectInspectorController.h>
|
||||
#include <JavaScriptCore/JSGlobalObjectDebuggable.h>
|
||||
#include <JavaScriptCore/ConsoleClient.h>
|
||||
|
||||
#include "ConsoleObject.h"
|
||||
#include "GCDefferalContext.h"
|
||||
#include <JavaScriptCore/InspectorScriptProfilerAgent.h>
|
||||
#include <JavaScriptCore/InspectorDebuggerAgent.h>
|
||||
#include <JavaScriptCore/InspectorConsoleAgent.h>
|
||||
|
||||
namespace Bun {
|
||||
using namespace JSC;
|
||||
|
||||
@@ -1,16 +1,38 @@
|
||||
|
||||
#include "root.h"
|
||||
|
||||
#include <JavaScriptCore/ArgList.h>
|
||||
#include <JavaScriptCore/BuiltinNames.h>
|
||||
#include <JavaScriptCore/DOMJITAbstractHeap.h>
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/ExceptionScope.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/JSArrayBufferViewInlines.h>
|
||||
#include <JavaScriptCore/JSBase.h>
|
||||
#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/LazyClassStructure.h>
|
||||
#include <JavaScriptCore/LazyClassStructureInlines.h>
|
||||
#include <JavaScriptCore/SlotVisitorMacros.h>
|
||||
#include <JavaScriptCore/SubspaceInlines.h>
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/GetPtr.h>
|
||||
#include <wtf/PointerPreparations.h>
|
||||
#include <wtf/URL.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
|
||||
#include "JSBuffer.h"
|
||||
|
||||
#include "JavaScriptCore/ArgList.h"
|
||||
#include "JavaScriptCore/ExceptionScope.h"
|
||||
|
||||
#include "ActiveDOMObject.h"
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMJITHelpers.h"
|
||||
#include "ExtendedDOMClientIsoSubspaces.h"
|
||||
#include "ExtendedDOMIsoSubspaces.h"
|
||||
#include "IDLTypes.h"
|
||||
// #include "JSBlob.h"
|
||||
#include "JSBufferEncodingType.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSDOMBinding.h"
|
||||
#include "JSDOMConstructor.h"
|
||||
@@ -24,27 +46,7 @@
|
||||
#include "JSDOMWrapperCache.h"
|
||||
#include "ScriptExecutionContext.h"
|
||||
#include "WebCoreJSClientData.h"
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
|
||||
#include <JavaScriptCore/JSFunction.h>
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/LazyClassStructure.h>
|
||||
#include <JavaScriptCore/LazyClassStructureInlines.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
|
||||
#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
|
||||
#include <JavaScriptCore/SlotVisitorMacros.h>
|
||||
#include <JavaScriptCore/SubspaceInlines.h>
|
||||
#include <wtf/GetPtr.h>
|
||||
#include <wtf/PointerPreparations.h>
|
||||
#include <wtf/URL.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
#include <JavaScriptCore/BuiltinNames.h>
|
||||
|
||||
#include "JSBufferEncodingType.h"
|
||||
#include "wtf/Assertions.h"
|
||||
#include <JavaScriptCore/JSBase.h>
|
||||
#if ENABLE(MEDIA_SOURCE)
|
||||
#include "BufferMediaSource.h"
|
||||
#include "JSMediaSource.h"
|
||||
@@ -55,16 +57,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <JavaScriptCore/DOMJITAbstractHeap.h>
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMJITHelpers.h"
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
|
||||
// #include <JavaScriptCore/JSTypedArrayViewPrototype.h>
|
||||
#include <JavaScriptCore/JSArrayBufferViewInlines.h>
|
||||
|
||||
using namespace JSC;
|
||||
using namespace WebCore;
|
||||
|
||||
@@ -880,9 +872,9 @@ public:
|
||||
using Base = JSC::JSNonFinalObject;
|
||||
static JSBufferPrototype* create(JSC::VM& vm, JSGlobalObject* globalObject, JSC::Structure* structure)
|
||||
{
|
||||
JSBufferPrototype* ptr = new (NotNull, JSC::allocateCell<JSBufferPrototype>(vm)) JSBufferPrototype(vm, globalObject, structure);
|
||||
ptr->finishCreation(vm, globalObject);
|
||||
return ptr;
|
||||
JSBufferPrototype* prototype = new (NotNull, JSC::allocateCell<JSBufferPrototype>(vm)) JSBufferPrototype(vm, globalObject, structure);
|
||||
prototype->finishCreation(vm, globalObject);
|
||||
return prototype;
|
||||
}
|
||||
|
||||
DECLARE_INFO;
|
||||
@@ -2013,11 +2005,12 @@ static const HashTableValue JSBufferPrototypeTableValues[]
|
||||
{ "writeBigUint64LE"_s, static_cast<unsigned>(JSC::PropertyAttribute::Builtin), NoIntrinsic, { HashTableValue::BuiltinGeneratorType, jsBufferPrototypeWriteBigUInt64LECodeGenerator, 1 } },
|
||||
};
|
||||
|
||||
void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject* globalThis)
|
||||
void JSBufferPrototype::finishCreation(VM& vm, JSC::JSGlobalObject*)
|
||||
{
|
||||
Base::finishCreation(vm);
|
||||
JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
|
||||
reifyStaticProperties(vm, JSBuffer::info(), JSBufferPrototypeTableValues, *this);
|
||||
putAllPrivateAliasesWithoutTransition(vm);
|
||||
}
|
||||
|
||||
const ClassInfo JSBufferPrototype::s_info = {
|
||||
@@ -2050,6 +2043,8 @@ void JSBufferConstructor::finishCreation(VM& vm, JSGlobalObject* globalObject, J
|
||||
Base::finishCreation(vm, 3, "Buffer"_s, PropertyAdditionMode::WithoutStructureTransition);
|
||||
putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
prototype->putDirect(vm, vm.propertyNames->speciesSymbol, this, PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
|
||||
reifyAllStaticProperties(globalObject);
|
||||
putAllPrivateAliasesWithoutTransition(vm);
|
||||
}
|
||||
|
||||
JSC::Structure* createBufferStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "root.h"
|
||||
#include "JavaScriptCore/VM.h"
|
||||
#include <JavaScriptCore/VM.h>
|
||||
|
||||
// On Linux, signals are used to suspend/resume threads in JavaScriptCore
|
||||
// When `.acquireAccess` is called, the signal might be raised.
|
||||
|
||||
@@ -1,28 +1,32 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "JSMockFunction.h"
|
||||
#include <JavaScriptCore/JSPromise.h>
|
||||
#include "ZigGlobalObject.h"
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include "ExtendedDOMClientIsoSubspaces.h"
|
||||
#include "ExtendedDOMIsoSubspaces.h"
|
||||
#include "BunClientData.h"
|
||||
#include <JavaScriptCore/LazyProperty.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/VMTrapsInlines.h>
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/WeakMapImpl.h>
|
||||
#include <JavaScriptCore/WeakMapImplInlines.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/DateConstructor.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSPromise.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/JSModuleEnvironment.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/LazyProperty.h>
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/VMTrapsInlines.h>
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
#include <JavaScriptCore/WeakMapImpl.h>
|
||||
#include <JavaScriptCore/WeakMapImplInlines.h>
|
||||
|
||||
#include "JSMockFunction.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "BunPlugin.h"
|
||||
#include "ExtendedDOMClientIsoSubspaces.h"
|
||||
#include "ExtendedDOMIsoSubspaces.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
namespace Bun {
|
||||
|
||||
/**
|
||||
@@ -82,7 +86,7 @@ extern "C" JSC::EncodedJSValue JSMock__jsUseRealTimers(JSC::JSGlobalObject* glob
|
||||
|
||||
extern "C" JSC::EncodedJSValue JSMock__jsNow(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
|
||||
{
|
||||
return JSValue::encode(jsNumber(globalObject->jsDateNow()));
|
||||
return JSValue::encode(dateNowImpl(globalObject));
|
||||
}
|
||||
extern "C" JSC::EncodedJSValue JSMock__jsSetSystemTime(JSC::JSGlobalObject* globalObject, JSC::CallFrame* callFrame)
|
||||
{
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "JavaScriptCore/JSCJSValueInlines.h"
|
||||
#include "JavaScriptCore/JSInternalPromise.h"
|
||||
#include "JavaScriptCore/LazyPropertyInlines.h"
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSGlobalObject.h>
|
||||
#include <JavaScriptCore/JSInternalFieldObjectImplInlines.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/LazyPropertyInlines.h>
|
||||
#include <JavaScriptCore/Structure.h>
|
||||
#include <JavaScriptCore/Weak.h>
|
||||
|
||||
#include "JSNextTickQueue.h"
|
||||
#include <JavaScriptCore/JSGlobalObject.h>
|
||||
#include <JavaScriptCore/Structure.h>
|
||||
#include <JavaScriptCore/JSInternalFieldObjectImplInlines.h>
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "ExtendedDOMClientIsoSubspaces.h"
|
||||
#include "ExtendedDOMIsoSubspaces.h"
|
||||
#include "BunClientData.h"
|
||||
|
||||
namespace Bun {
|
||||
|
||||
@@ -84,7 +85,7 @@ void JSNextTickQueue::drain(JSC::VM& vm, JSC::JSGlobalObject* globalObject)
|
||||
|
||||
if (!isEmpty()) {
|
||||
if (mustResetContext) {
|
||||
globalObject->m_asyncContextData.get()->putInternalField(vm, 0, jsUndefined());
|
||||
globalObject->asyncContextTuple()->putInternalField(vm, 0, jsUndefined());
|
||||
}
|
||||
auto* drainFn = internalField(2).get().getObject();
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "root.h"
|
||||
#include "headers-handwritten.h"
|
||||
|
||||
#include "JavaScriptCore/JSCInlines.h"
|
||||
#include "BunClientData.h"
|
||||
#include <JavaScriptCore/JSCInlines.h>
|
||||
#include <JavaScriptCore/JSInternalFieldObjectImpl.h>
|
||||
|
||||
#include "BunClientData.h"
|
||||
|
||||
namespace Bun {
|
||||
using namespace JSC;
|
||||
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
#include "headers.h"
|
||||
|
||||
#include <JavaScriptCore/Lookup.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/StrongInlines.h>
|
||||
|
||||
#include "JSReadableHelper.h"
|
||||
#include "JSReadableState.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSDOMConvertEnumeration.h"
|
||||
#include "JSDOMOperation.h"
|
||||
#include "JSBufferList.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JSEventEmitter.h"
|
||||
#include "JSReadableState.h"
|
||||
#include "JSStringDecoder.h"
|
||||
#include "JavaScriptCore/Lookup.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "JSDOMOperation.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "headers.h"
|
||||
#include "JSDOMConvertEnumeration.h"
|
||||
#include "JavaScriptCore/StrongInlines.h"
|
||||
#include "BunClientData.h"
|
||||
|
||||
|
||||
namespace WebCore {
|
||||
using namespace JSC;
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
#include "JSReadableState.h"
|
||||
#include "JSBufferList.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JavaScriptCore/Lookup.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "JSDOMOperation.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "headers.h"
|
||||
#include "JSDOMConvertEnumeration.h"
|
||||
|
||||
#include <JavaScriptCore/Lookup.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
#include "JSReadableState.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JSBufferList.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSDOMConvertEnumeration.h"
|
||||
#include "JSDOMOperation.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "JSSocketAddress.h"
|
||||
|
||||
#include <JavaScriptCore/JSCast.h>
|
||||
#include <JavaScriptCore/JSObjectInlines.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/JSCast.h"
|
||||
|
||||
using namespace JSC;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// The object returned by Bun.serve's .requestIP()
|
||||
#pragma once
|
||||
#include "root.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
#include <JavaScriptCore/JSObjectInlines.h>
|
||||
|
||||
using namespace JSC;
|
||||
|
||||
|
||||
@@ -22,39 +22,42 @@
|
||||
// IN THE SOFTWARE.
|
||||
|
||||
#include "KeyObject.h"
|
||||
#include "JavaScriptCore/JSArrayBufferView.h"
|
||||
#include "JavaScriptCore/JSCJSValue.h"
|
||||
#include "JavaScriptCore/JSCast.h"
|
||||
#include "webcrypto/JSCryptoKey.h"
|
||||
#include "webcrypto/JSSubtleCrypto.h"
|
||||
#include "webcrypto/CryptoKeyOKP.h"
|
||||
#include "webcrypto/CryptoKeyEC.h"
|
||||
#include "webcrypto/CryptoKeyRSA.h"
|
||||
#include "webcrypto/CryptoKeyAES.h"
|
||||
#include "webcrypto/CryptoKeyHMAC.h"
|
||||
#include "webcrypto/CryptoKeyRaw.h"
|
||||
#include "webcrypto/CryptoKeyUsage.h"
|
||||
#include "webcrypto/JsonWebKey.h"
|
||||
#include "webcrypto/JSJsonWebKey.h"
|
||||
#include "JavaScriptCore/JSObject.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "headers-handwritten.h"
|
||||
|
||||
#include <JavaScriptCore/JSArrayBufferView.h>
|
||||
#include <JavaScriptCore/JSCast.h>
|
||||
#include <JavaScriptCore/JSObject.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/JSCJSValue.h>
|
||||
#include <openssl/curve25519.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/mem.h>
|
||||
#include <openssl/x509.h>
|
||||
#include <openssl/pem.h>
|
||||
#include <openssl/curve25519.h>
|
||||
#include "JSBuffer.h"
|
||||
#include "CryptoAlgorithmHMAC.h"
|
||||
#include "CryptoAlgorithmEd25519.h"
|
||||
#include "CryptoAlgorithmRSA_PSS.h"
|
||||
#include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h"
|
||||
#include <openssl/x509.h>
|
||||
#include <wtf/ForbidHeapAllocation.h>
|
||||
#include <wtf/Noncopyable.h>
|
||||
|
||||
#include "CryptoAlgorithmECDSA.h"
|
||||
#include "CryptoAlgorithmEcdsaParams.h"
|
||||
#include "CryptoAlgorithmHMAC.h"
|
||||
#include "CryptoAlgorithmRSA_PSS.h"
|
||||
#include "CryptoAlgorithmRSASSA_PKCS1_v1_5.h"
|
||||
#include "CryptoAlgorithmRsaPssParams.h"
|
||||
#include "CryptoAlgorithmRegistry.h"
|
||||
#include "wtf/ForbidHeapAllocation.h"
|
||||
#include "wtf/Noncopyable.h"
|
||||
#include "CryptoAlgorithmEd25519.h"
|
||||
#include "CryptoKeyAES.h"
|
||||
#include "CryptoKeyEC.h"
|
||||
#include "CryptoKeyHMAC.h"
|
||||
#include "CryptoKeyOKP.h"
|
||||
#include "CryptoKeyRaw.h"
|
||||
#include "CryptoKeyRSA.h"
|
||||
#include "CryptoKeyUsage.h"
|
||||
#include "JsonWebKey.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JSCryptoKey.h"
|
||||
#include "JSJsonWebKey.h"
|
||||
#include "JSSubtleCrypto.h"
|
||||
#include "headers-handwritten.h"
|
||||
|
||||
using namespace JSC;
|
||||
using namespace Bun;
|
||||
using JSGlobalObject
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#include "root.h"
|
||||
#include "headers-handwritten.h"
|
||||
#include "JavaScriptCore/JSGlobalObject.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "JavaScriptCore/Identifier.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSCInlines.h>
|
||||
#include <JavaScriptCore/JSNativeStdFunction.h>
|
||||
#include <JavaScriptCore/JSCJSValueInlines.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/JSGlobalObject.h>
|
||||
#include <JavaScriptCore/JSInternalFieldObjectImpl.h>
|
||||
|
||||
#include "ZigSourceProvider.h"
|
||||
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include <JavaScriptCore/JSModuleLoader.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSNativeStdFunction.h>
|
||||
#include <JavaScriptCore/JSSourceCode.h>
|
||||
#include <JavaScriptCore/JSString.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
@@ -23,17 +23,13 @@
|
||||
#include <JavaScriptCore/StackVisitor.h>
|
||||
|
||||
#include "EventEmitter.h"
|
||||
#include "JSEventEmitter.h"
|
||||
|
||||
#include <JavaScriptCore/JSModuleLoader.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include "ModuleLoader.h"
|
||||
#include "NativeModuleImpl.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "ZigSourceProvider.h"
|
||||
#include "headers-handwritten.h"
|
||||
|
||||
#include "../modules/_NativeModule.h"
|
||||
#include "NativeModuleImpl.h"
|
||||
|
||||
#include "../modules/ObjectModule.h"
|
||||
#include "wtf/Assertions.h"
|
||||
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
#include "root.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include <JavaScriptCore/GlobalObjectMethodTable.h>
|
||||
#include "helpers.h"
|
||||
#include "BunClientData.h"
|
||||
|
||||
#include "JavaScriptCore/AggregateError.h"
|
||||
#include "JavaScriptCore/InternalFieldTuple.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/JSFunction.h"
|
||||
#include "wtf/URL.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "JSDOMExceptionHandling.h"
|
||||
#include <bun-uws/src/App.h>
|
||||
#include <JavaScriptCore/AggregateError.h>
|
||||
#include <JavaScriptCore/Bun_InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/GlobalObjectMethodTable.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <wtf/URL.h>
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "JSDOMExceptionHandling.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "ZigGeneratedClasses.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
namespace Bun {
|
||||
|
||||
@@ -262,7 +261,7 @@ JSC_DEFINE_HOST_FUNCTION(jsHTTPAssignHeaders, (JSGlobalObject * globalObject, Ca
|
||||
JSValue requestValue = callFrame->argument(0);
|
||||
JSObject* objectValue = callFrame->argument(1).getObject();
|
||||
|
||||
JSC::InternalFieldTuple* tuple = JSC::InternalFieldTuple::create(vm, globalObject->m_internalFieldTupleStructure.get());
|
||||
JSC::InternalFieldTuple* tuple = JSC::InternalFieldTuple::create(vm, globalObject->internalFieldTupleStructure());
|
||||
|
||||
JSValue headersValue = JSValue();
|
||||
JSValue urlValue = JSValue();
|
||||
|
||||
@@ -1,35 +1,34 @@
|
||||
#include "root.h"
|
||||
|
||||
#include "NodeVM.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
#include "wtf/text/ExternalStringImpl.h"
|
||||
|
||||
#include "JavaScriptCore/FunctionPrototype.h"
|
||||
#include "JavaScriptCore/HeapAnalyzer.h"
|
||||
|
||||
#include "JavaScriptCore/JSDestructibleObjectHeapCellType.h"
|
||||
#include "JavaScriptCore/SlotVisitorMacros.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/SubspaceInlines.h"
|
||||
#include "wtf/GetPtr.h"
|
||||
#include "wtf/PointerPreparations.h"
|
||||
#include "wtf/URL.h"
|
||||
#include "JavaScriptCore/TypedArrayInlines.h"
|
||||
#include "JavaScriptCore/PropertyNameArray.h"
|
||||
#include "JavaScriptCore/JSWeakMap.h"
|
||||
#include "JavaScriptCore/JSWeakMapInlines.h"
|
||||
#include "JavaScriptCore/JSWithScope.h"
|
||||
#include "JavaScriptCore/JSGlobalProxyInlines.h"
|
||||
#include "GCDefferalContext.h"
|
||||
#include "JSBuffer.h"
|
||||
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/DOMJITAbstractHeap.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/HeapAnalyzer.h>
|
||||
#include <JavaScriptCore/JSDestructibleObjectHeapCellType.h>
|
||||
#include <JavaScriptCore/JSGlobalProxyInlines.h>
|
||||
#include <JavaScriptCore/JSObjectInlines.h>
|
||||
#include <JavaScriptCore/JSWeakMap.h>
|
||||
#include <JavaScriptCore/JSWeakMapInlines.h>
|
||||
#include <JavaScriptCore/JSWithScope.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/PropertyNameArray.h>
|
||||
#include <JavaScriptCore/SlotVisitorMacros.h>
|
||||
#include <JavaScriptCore/SubspaceInlines.h>
|
||||
#include <JavaScriptCore/TypedArrayInlines.h>
|
||||
#include <wtf/GetPtr.h>
|
||||
#include <wtf/PointerPreparations.h>
|
||||
#include <wtf/URL.h>
|
||||
#include <wtf/text/ExternalStringImpl.h>
|
||||
|
||||
#include "NodeVM.h"
|
||||
|
||||
#include "DOMJITHelpers.h"
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMJITHelpers.h"
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include "GCDefferalContext.h"
|
||||
#include "JSBuffer.h"
|
||||
|
||||
namespace WebCore {
|
||||
using namespace JSC;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Modelled off of https://github.com/nodejs/node/blob/main/src/node_constants.cc
|
||||
// Note that if you change any of this code, you probably also have to change NodeConstantsModule.h
|
||||
#include "ProcessBindingNatives.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
namespace Bun {
|
||||
using namespace JSC;
|
||||
|
||||
@@ -1,29 +1,28 @@
|
||||
#include "mimalloc.h"
|
||||
#include "root.h"
|
||||
|
||||
#include "JavaScriptCore/JSDestructibleObject.h"
|
||||
#include "JavaScriptCore/ExceptionScope.h"
|
||||
#include "JavaScriptCore/Identifier.h"
|
||||
|
||||
#include <JavaScriptCore/ExceptionScope.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/JSDestructibleObject.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
#include "ProcessBindingTTYWrap.h"
|
||||
#include "NodeTTYModule.h"
|
||||
#include "ProcessBindingTTYWrap.h"
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
|
||||
#ifndef WIN32
|
||||
#include <errno.h>
|
||||
#include <dlfcn.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <uv.h>
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <uv.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
#include "ProcessBindingUV.h"
|
||||
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/JSMap.h"
|
||||
#include "JavaScriptCore/JSMapInlines.h"
|
||||
|
||||
// clang-format off
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "root.h"
|
||||
#include "headers.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "ScriptExecutionContext.h"
|
||||
#include "MessagePort.h"
|
||||
|
||||
#include "webcore/WebSocket.h"
|
||||
#include "libusockets.h"
|
||||
#include "_libusockets.h"
|
||||
#include "BunClientData.h"
|
||||
#include "libusockets.h"
|
||||
#include "webcore/WebSocket.h"
|
||||
|
||||
extern "C" void Bun__startLoop(us_loop_t* loop);
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "root.h"
|
||||
#include "ActiveDOMObject.h"
|
||||
#include "ContextDestructionObserver.h"
|
||||
#include "BunBroadcastChannelRegistry.h"
|
||||
|
||||
#include <wtf/CrossThreadTask.h>
|
||||
#include <wtf/Function.h>
|
||||
#include <wtf/HashSet.h>
|
||||
@@ -11,9 +9,13 @@
|
||||
#include <wtf/WeakPtr.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
#include <wtf/CompletionHandler.h>
|
||||
#include "CachedScript.h"
|
||||
#include <wtf/URL.h>
|
||||
|
||||
#include "ActiveDOMObject.h"
|
||||
#include "BunBroadcastChannelRegistry.h"
|
||||
#include "CachedScript.h"
|
||||
#include "ContextDestructionObserver.h"
|
||||
|
||||
namespace uWS {
|
||||
template<bool isServer, bool isClient, typename UserData>
|
||||
struct WebSocketContext;
|
||||
|
||||
@@ -1,156 +1,142 @@
|
||||
|
||||
#include "root.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
#include <JavaScriptCore/AggregateError.h>
|
||||
#include <JavaScriptCore/Bun_InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/BytecodeIndex.h>
|
||||
#include <JavaScriptCore/CallData.h>
|
||||
#include <JavaScriptCore/CallFrameInlines.h>
|
||||
#include <JavaScriptCore/CatchScope.h>
|
||||
#include <JavaScriptCore/ClassInfo.h>
|
||||
#include <JavaScriptCore/CodeBlock.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/DeferredWorkTimer.h>
|
||||
#include <JavaScriptCore/Error.h>
|
||||
#include <JavaScriptCore/ErrorInstance.h>
|
||||
#include <JavaScriptCore/Exception.h>
|
||||
#include <JavaScriptCore/ExceptionScope.h>
|
||||
#include <JavaScriptCore/FunctionConstructor.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/GlobalObjectMethodTable.h>
|
||||
#include "helpers.h"
|
||||
#include <JavaScriptCore/HashMapImpl.h>
|
||||
#include <JavaScriptCore/HashMapImplInlines.h>
|
||||
#include <JavaScriptCore/Heap.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/InitializeThreading.h>
|
||||
#include <JavaScriptCore/InternalFunction.h>
|
||||
#include <JavaScriptCore/IteratorOperations.h>
|
||||
#include <JavaScriptCore/JSArray.h>
|
||||
#include <JavaScriptCore/JSCJSValue.h>
|
||||
#include <JavaScriptCore/JSCallbackConstructor.h>
|
||||
#include <JavaScriptCore/JSCallbackObject.h>
|
||||
#include <JavaScriptCore/JSCast.h>
|
||||
#include <JavaScriptCore/JSGlobalProxyInlines.h>
|
||||
#include <JavaScriptCore/JSMicrotask.h>
|
||||
#include <JavaScriptCore/JSModuleLoader.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObject.h>
|
||||
#include <JavaScriptCore/JSModuleNamespaceObjectInlines.h>
|
||||
#include <JavaScriptCore/JSModuleRecord.h>
|
||||
#include <JavaScriptCore/JSNativeStdFunction.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSPromise.h>
|
||||
#include <JavaScriptCore/JSScriptFetchParameters.h>
|
||||
#include <JavaScriptCore/JSSet.h>
|
||||
#include <JavaScriptCore/JSSourceCode.h>
|
||||
#include <JavaScriptCore/JSString.h>
|
||||
#include <JavaScriptCore/JSValueInternal.h>
|
||||
#include <JavaScriptCore/JSVirtualMachineInternal.h>
|
||||
#include <JavaScriptCore/JSWeakMap.h>
|
||||
#include <JavaScriptCore/LazyClassStructure.h>
|
||||
#include <JavaScriptCore/LazyClassStructureInlines.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/OptionsList.h>
|
||||
#include <JavaScriptCore/ParserError.h>
|
||||
#include <JavaScriptCore/ScriptExecutable.h>
|
||||
#include <JavaScriptCore/ScriptFetchParameters.h>
|
||||
#include <JavaScriptCore/SourceOrigin.h>
|
||||
#include <JavaScriptCore/StackFrame.h>
|
||||
#include <JavaScriptCore/StackVisitor.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
#include <JavaScriptCore/WasmFaultSignalHandler.h>
|
||||
#include <unicode/uidna.h>
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/Gigacage.h>
|
||||
#include <wtf/URL.h>
|
||||
#include <wtf/URLParser.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
#include <wtf/text/ExternalStringImpl.h>
|
||||
#include <wtf/text/StringCommon.h>
|
||||
#include <wtf/text/StringImpl.h>
|
||||
#include <wtf/text/StringView.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
|
||||
#include "AsyncContextFrame.h"
|
||||
#include "BunClientData.h"
|
||||
#include "JavaScriptCore/JSCJSValue.h"
|
||||
#include "JavaScriptCore/AggregateError.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
#include "JavaScriptCore/InternalFieldTuple.h"
|
||||
#include "JavaScriptCore/BytecodeIndex.h"
|
||||
#include "JavaScriptCore/CallFrameInlines.h"
|
||||
#include "JavaScriptCore/ClassInfo.h"
|
||||
#include "JavaScriptCore/CodeBlock.h"
|
||||
#include "JavaScriptCore/Completion.h"
|
||||
#include "JavaScriptCore/Error.h"
|
||||
#include "JavaScriptCore/ErrorInstance.h"
|
||||
#include "JavaScriptCore/Exception.h"
|
||||
#include "JavaScriptCore/ExceptionScope.h"
|
||||
#include "JavaScriptCore/FunctionConstructor.h"
|
||||
#include "JavaScriptCore/HashMapImpl.h"
|
||||
#include "JavaScriptCore/HashMapImplInlines.h"
|
||||
#include "JavaScriptCore/Heap.h"
|
||||
#include "JavaScriptCore/Identifier.h"
|
||||
#include "JavaScriptCore/InitializeThreading.h"
|
||||
#include "JavaScriptCore/IteratorOperations.h"
|
||||
#include "JavaScriptCore/JSArray.h"
|
||||
#include "JavaScriptCore/JSGlobalProxyInlines.h"
|
||||
#include "JavaScriptCore/JSCallbackConstructor.h"
|
||||
#include "JavaScriptCore/JSCallbackObject.h"
|
||||
#include "JavaScriptCore/JSCast.h"
|
||||
#include "JavaScriptCore/JSClassRef.h"
|
||||
#include "JavaScriptCore/JSMicrotask.h"
|
||||
#include "BunObject.h"
|
||||
#include "BunPlugin.h"
|
||||
#include "BunProcess.h"
|
||||
#include "BunWorkerGlobalScope.h"
|
||||
#include "ConsoleObject.h"
|
||||
// #include "JavaScriptCore/JSContextInternal.h"
|
||||
#include "JavaScriptCore/CatchScope.h"
|
||||
#include "JavaScriptCore/DeferredWorkTimer.h"
|
||||
#include "JavaScriptCore/JSInternalPromise.h"
|
||||
#include "JavaScriptCore/JSLock.h"
|
||||
#include "JavaScriptCore/JSMap.h"
|
||||
#include "JavaScriptCore/JSModuleLoader.h"
|
||||
#include "JavaScriptCore/JSModuleNamespaceObject.h"
|
||||
#include "JavaScriptCore/JSModuleNamespaceObjectInlines.h"
|
||||
#include "JavaScriptCore/JSModuleRecord.h"
|
||||
#include "JavaScriptCore/JSNativeStdFunction.h"
|
||||
#include "JavaScriptCore/JSObject.h"
|
||||
#include "JavaScriptCore/JSPromise.h"
|
||||
#include "JavaScriptCore/JSSet.h"
|
||||
#include "JavaScriptCore/JSSourceCode.h"
|
||||
#include "JavaScriptCore/JSString.h"
|
||||
#include "JavaScriptCore/JSValueInternal.h"
|
||||
#include "JavaScriptCore/JSVirtualMachineInternal.h"
|
||||
#include "JavaScriptCore/JSWeakMap.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/OptionsList.h"
|
||||
#include "JavaScriptCore/ParserError.h"
|
||||
#include "JavaScriptCore/ScriptExecutable.h"
|
||||
#include "JavaScriptCore/SourceOrigin.h"
|
||||
#include "JavaScriptCore/StackFrame.h"
|
||||
#include "JavaScriptCore/StackVisitor.h"
|
||||
#include "JavaScriptCore/VM.h"
|
||||
#include "JavaScriptCore/WasmFaultSignalHandler.h"
|
||||
#include "wtf/Assertions.h"
|
||||
#include "wtf/Gigacage.h"
|
||||
#include "wtf/URL.h"
|
||||
#include "wtf/text/ExternalStringImpl.h"
|
||||
#include "wtf/text/StringCommon.h"
|
||||
#include "wtf/text/StringImpl.h"
|
||||
#include "wtf/text/StringView.h"
|
||||
#include "wtf/text/WTFString.h"
|
||||
#include "JavaScriptCore/JSScriptFetchParameters.h"
|
||||
#include "JavaScriptCore/ScriptFetchParameters.h"
|
||||
|
||||
#include "wtf/text/Base64.h"
|
||||
// #include "JavaScriptCore/CachedType.h"
|
||||
#include "JavaScriptCore/JSCallbackObject.h"
|
||||
#include "JavaScriptCore/JSClassRef.h"
|
||||
#include "JavaScriptCore/CallData.h"
|
||||
#include "GCDefferalContext.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
|
||||
#include "ZigSourceProvider.h"
|
||||
|
||||
#include "JSDOMURL.h"
|
||||
#include "JSURLSearchParams.h"
|
||||
#include "JSDOMException.h"
|
||||
#include "JSEventTarget.h"
|
||||
#include "JSEventEmitter.h"
|
||||
#include "DOMIsoSubspaces.h"
|
||||
#include "EventTargetConcrete.h"
|
||||
#include "JSAbortSignal.h"
|
||||
#include "JSCustomEvent.h"
|
||||
#include "JSAbortController.h"
|
||||
#include "JS2Native.h"
|
||||
#include "JSDOMException.h"
|
||||
#include "JSDOMFile.h"
|
||||
#include "JSDOMURL.h"
|
||||
#include "JSEnvironmentVariableMap.h"
|
||||
#include "JSEvent.h"
|
||||
#include "JSErrorEvent.h"
|
||||
#include "JSEventEmitter.h"
|
||||
#include "JSEventTarget.h"
|
||||
#include "JSAbortController.h"
|
||||
#include "JSAbortSignal.h"
|
||||
#include "JSBroadcastChannel.h"
|
||||
#include "JSCloseEvent.h"
|
||||
#include "JSCustomEvent.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "JSFFIFunction.h"
|
||||
#include "JSMessageChannel.h"
|
||||
#include "JSMessagePort.h"
|
||||
#include "JSBroadcastChannel.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JSBufferList.h"
|
||||
#include "JSErrorEvent.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "JSNextTickQueue.h"
|
||||
#include "JSStringDecoder.h"
|
||||
#include "JSReadableState.h"
|
||||
#include "JSReadableHelper.h"
|
||||
#include "JSPerformance.h"
|
||||
#include "Performance.h"
|
||||
#include "JSPerformanceEntry.h"
|
||||
#include "JSPerformanceMark.h"
|
||||
#include "JSPerformanceMeasure.h"
|
||||
#include "JSPerformanceObserver.h"
|
||||
#include "JSPerformanceObserverEntryList.h"
|
||||
#include "JSPerformanceEntry.h"
|
||||
#include "JSPerformanceMeasure.h"
|
||||
#include "JSPerformanceMark.h"
|
||||
#include "BunProcess.h"
|
||||
#include "AsyncContextFrame.h"
|
||||
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
#include "JSBuffer.h"
|
||||
#include "JSBufferList.h"
|
||||
#include "JSFFIFunction.h"
|
||||
#include "JavaScriptCore/InternalFunction.h"
|
||||
#include "JavaScriptCore/LazyClassStructure.h"
|
||||
#include "JavaScriptCore/LazyClassStructureInlines.h"
|
||||
#include "JavaScriptCore/FunctionPrototype.h"
|
||||
#include "JavaScriptCore/GetterSetter.h"
|
||||
#include "napi.h"
|
||||
#include "JSWorker.h"
|
||||
#include "JSSQLStatement.h"
|
||||
#include "JSURLSearchParams.h"
|
||||
#include "ModuleLoader.h"
|
||||
#include "NodeHTTP.h"
|
||||
#include "NodeTTYModule.h"
|
||||
#include "NodeVM.h"
|
||||
#include "Performance.h"
|
||||
#include "ProcessBindingConstants.h"
|
||||
#include "ProcessIdentifier.h"
|
||||
#include "SerializedScriptValue.h"
|
||||
#include "NodeTTYModule.h"
|
||||
|
||||
#include "WebCoreJSBuiltins.h"
|
||||
#include "ZigGeneratedClasses.h"
|
||||
#include "JavaScriptCore/DateInstance.h"
|
||||
|
||||
#include "JS2Native.h"
|
||||
|
||||
#include "BunPlugin.h"
|
||||
#include "JSEnvironmentVariableMap.h"
|
||||
#include "DOMIsoSubspaces.h"
|
||||
#include "BunWorkerGlobalScope.h"
|
||||
#include "JSWorker.h"
|
||||
#include "JSMessageChannel.h"
|
||||
#include "JSMessagePort.h"
|
||||
#include "JSBroadcastChannel.h"
|
||||
|
||||
#include "JSDOMFile.h"
|
||||
|
||||
#include "ProcessBindingConstants.h"
|
||||
#include "ZigSourceProvider.h"
|
||||
#include "helpers.h"
|
||||
#include "napi.h"
|
||||
#include "napi_external.h"
|
||||
|
||||
#if ENABLE(REMOTE_INSPECTOR)
|
||||
#include "JavaScriptCore/RemoteInspectorServer.h"
|
||||
#include <JavaScriptCore/RemoteInspectorServer.h>
|
||||
#endif
|
||||
|
||||
#include "BunObject.h"
|
||||
#include "JSNextTickQueue.h"
|
||||
#include "NodeHTTP.h"
|
||||
#include "napi_external.h"
|
||||
using namespace Bun;
|
||||
|
||||
extern "C" JSC__JSValue Bun__NodeUtil__jsParseArgs(JSC::JSGlobalObject*, JSC::CallFrame*);
|
||||
@@ -176,42 +162,31 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#include "IDLTypes.h"
|
||||
|
||||
#include "JSAbortAlgorithm.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSByteLengthQueuingStrategy.h"
|
||||
#include "JSCountQueuingStrategy.h"
|
||||
#include "JSReadableByteStreamController.h"
|
||||
#include "JSReadableStream.h"
|
||||
#include "JSReadableStreamBYOBReader.h"
|
||||
#include "JSReadableStreamBYOBRequest.h"
|
||||
#include "JSReadableStreamDefaultController.h"
|
||||
#include "JSReadableStreamDefaultReader.h"
|
||||
#include "JSTransformStream.h"
|
||||
#include "JSTransformStreamDefaultController.h"
|
||||
#include "JSWritableStream.h"
|
||||
#include "JSWritableStreamDefaultController.h"
|
||||
#include "JSWritableStreamDefaultWriter.h"
|
||||
#include "JavaScriptCore/BuiltinNames.h"
|
||||
#include "JSTextEncoder.h"
|
||||
#include "StructuredClone.h"
|
||||
#include "JSWebSocket.h"
|
||||
#include "JSMessageEvent.h"
|
||||
#include "JSEventListener.h"
|
||||
|
||||
#include "ReadableStream.h"
|
||||
#include "JSSink.h"
|
||||
#include "ImportMetaObject.h"
|
||||
|
||||
#include <JavaScriptCore/BuiltinNames.h>
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
#include <JavaScriptCore/DOMJITAbstractHeap.h>
|
||||
#include <wtf/RAMSize.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
|
||||
#include "AddEventListenerOptions.h"
|
||||
#include "CallSite.h"
|
||||
#include "CallSitePrototype.h"
|
||||
#include "CommonJSModuleRecord.h"
|
||||
#include "DOMJITIDLConvert.h"
|
||||
#include "DOMJITIDLType.h"
|
||||
#include "DOMJITIDLTypeFilter.h"
|
||||
#include "DOMJITHelpers.h"
|
||||
#include <JavaScriptCore/DFGAbstractHeap.h>
|
||||
|
||||
#include "JSDOMFormData.h"
|
||||
#include "ErrorStackTrace.h"
|
||||
#include "IDLTypes.h"
|
||||
#include "ImportMetaObject.h"
|
||||
#include "JSAbortAlgorithm.h"
|
||||
#include "JSByteLengthQueuingStrategy.h"
|
||||
#include "JSCountQueuingStrategy.h"
|
||||
#include "JSCryptoKey.h"
|
||||
#include "JSDOMAttribute.h"
|
||||
#include "JSDOMBinding.h"
|
||||
#include "JSDOMConstructor.h"
|
||||
#include "JSDOMConvertBase.h"
|
||||
@@ -222,21 +197,33 @@ namespace JSCastingHelpers = JSC::JSCastingHelpers;
|
||||
#include "JSDOMConvertNullable.h"
|
||||
#include "JSDOMConvertStrings.h"
|
||||
#include "JSDOMConvertUnion.h"
|
||||
#include "AddEventListenerOptions.h"
|
||||
#include "JSDOMFormData.h"
|
||||
#include "JSEventListener.h"
|
||||
#include "JSMessageEvent.h"
|
||||
#include "JSReadableByteStreamController.h"
|
||||
#include "JSReadableStream.h"
|
||||
#include "JSReadableStreamBYOBReader.h"
|
||||
#include "JSReadableStreamBYOBRequest.h"
|
||||
#include "JSReadableStreamDefaultController.h"
|
||||
#include "JSReadableStreamDefaultReader.h"
|
||||
#include "JSSink.h"
|
||||
#include "JSSocketAddress.h"
|
||||
|
||||
#include "ErrorStackTrace.h"
|
||||
#include "CallSite.h"
|
||||
#include "CallSitePrototype.h"
|
||||
#include "DOMWrapperWorld-class.h"
|
||||
#include "CommonJSModuleRecord.h"
|
||||
#include <wtf/RAMSize.h>
|
||||
#include <wtf/text/Base64.h>
|
||||
#include "simdutf.h"
|
||||
#include "libusockets.h"
|
||||
#include "JSSubtleCrypto.h"
|
||||
#include "JSTextEncoder.h"
|
||||
#include "JSTransformStream.h"
|
||||
#include "JSTransformStreamDefaultController.h"
|
||||
#include "JSWebSocket.h"
|
||||
#include "JSWritableStream.h"
|
||||
#include "JSWritableStreamDefaultController.h"
|
||||
#include "JSWritableStreamDefaultWriter.h"
|
||||
#include "KeyObject.h"
|
||||
#include "ProcessBindingTTYWrap.h"
|
||||
#include "ReadableStream.h"
|
||||
#include "StructuredClone.h"
|
||||
#include "webcrypto/JSCryptoKey.h"
|
||||
#include "webcrypto/JSSubtleCrypto.h"
|
||||
#include "libusockets.h"
|
||||
#include "simdutf.h"
|
||||
|
||||
constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10;
|
||||
|
||||
@@ -247,8 +234,6 @@ constexpr size_t DEFAULT_ERROR_STACK_TRACE_LIMIT = 10;
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "ProcessBindingTTYWrap.h"
|
||||
|
||||
// #include <iostream>
|
||||
static bool has_loaded_jsc = false;
|
||||
|
||||
@@ -717,7 +702,7 @@ static void checkIfNextTickWasCalledDuringMicrotask(JSC::VM& vm)
|
||||
static void cleanupAsyncHooksData(JSC::VM& vm)
|
||||
{
|
||||
auto* globalObject = Bun__getDefaultGlobal();
|
||||
globalObject->m_asyncContextData.get()->putInternalField(vm, 0, jsUndefined());
|
||||
globalObject->asyncContextTuple()->putInternalField(vm, 0, jsUndefined());
|
||||
globalObject->asyncHooksNeedsCleanup = false;
|
||||
if (!globalObject->m_nextTickQueue) {
|
||||
vm.setOnEachMicrotaskTick(&checkIfNextTickWasCalledDuringMicrotask);
|
||||
@@ -1297,10 +1282,10 @@ JSC_DEFINE_HOST_FUNCTION(functionQueueMicrotask,
|
||||
}
|
||||
|
||||
Zig::GlobalObject* global = JSC::jsCast<Zig::GlobalObject*>(globalObject);
|
||||
JSC::JSValue asyncContext = global->m_asyncContextData.get()->getInternalField(0);
|
||||
JSC::JSValue asyncContextData = global->asyncContextTuple()->getInternalField(0);
|
||||
|
||||
// This is a JSC builtin function
|
||||
globalObject->queueMicrotask(global->performMicrotaskFunction(), job, asyncContext,
|
||||
globalObject->queueMicrotask(global->performMicrotaskFunction(), job, asyncContextData,
|
||||
JSC::JSValue {}, JSC::JSValue {});
|
||||
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
@@ -2262,13 +2247,13 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj
|
||||
JSValue result;
|
||||
WTF::NakedPtr<JSC::Exception> exceptionPtr;
|
||||
|
||||
JSValue restoreAsyncContext = {};
|
||||
InternalFieldTuple* asyncContextData = nullptr;
|
||||
auto setAsyncContext = callframe->argument(1);
|
||||
if (!setAsyncContext.isUndefined()) {
|
||||
asyncContextData = globalObject->m_asyncContextData.get();
|
||||
restoreAsyncContext = asyncContextData->getInternalField(0);
|
||||
asyncContextData->putInternalField(vm, 0, setAsyncContext);
|
||||
JSValue oldAsyncContextData = {};
|
||||
InternalFieldTuple* asyncContextTuple = nullptr;
|
||||
auto newAsyncContextData = callframe->argument(1);
|
||||
if (!newAsyncContextData.isUndefined()) {
|
||||
asyncContextTuple = globalObject->asyncContextTuple();
|
||||
oldAsyncContextData = asyncContextTuple->getInternalField(0);
|
||||
asyncContextTuple->putInternalField(vm, 0, newAsyncContextData);
|
||||
}
|
||||
|
||||
size_t argCount = callframe->argumentCount();
|
||||
@@ -2288,8 +2273,8 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotask, (JSGlobalObject * globalObj
|
||||
|
||||
JSC::call(globalObject, job, callData, jsUndefined(), arguments, exceptionPtr);
|
||||
|
||||
if (asyncContextData) {
|
||||
asyncContextData->putInternalField(vm, 0, restoreAsyncContext);
|
||||
if (asyncContextTuple) {
|
||||
asyncContextTuple->putInternalField(vm, 0, oldAsyncContextData);
|
||||
}
|
||||
|
||||
if (auto* exception = exceptionPtr.get()) {
|
||||
@@ -2329,19 +2314,19 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionPerformMicrotaskVariadic, (JSGlobalObject * g
|
||||
thisValue = callframe->argument(3);
|
||||
}
|
||||
|
||||
JSValue restoreAsyncContext = {};
|
||||
InternalFieldTuple* asyncContextData = nullptr;
|
||||
auto setAsyncContext = callframe->argument(2);
|
||||
if (!setAsyncContext.isUndefined()) {
|
||||
asyncContextData = globalObject->m_asyncContextData.get();
|
||||
restoreAsyncContext = asyncContextData->getInternalField(0);
|
||||
asyncContextData->putInternalField(vm, 0, setAsyncContext);
|
||||
JSValue oldAsyncContextData = {};
|
||||
InternalFieldTuple* asyncContextTuple = nullptr;
|
||||
auto newAsyncContextData = callframe->argument(2);
|
||||
if (!newAsyncContextData.isUndefined()) {
|
||||
asyncContextTuple = globalObject->asyncContextTuple();
|
||||
oldAsyncContextData = asyncContextTuple->getInternalField(0);
|
||||
asyncContextTuple->putInternalField(vm, 0, newAsyncContextData);
|
||||
}
|
||||
|
||||
JSC::call(globalObject, job, callData, thisValue, arguments, exceptionPtr);
|
||||
|
||||
if (asyncContextData) {
|
||||
asyncContextData->putInternalField(vm, 0, restoreAsyncContext);
|
||||
if (asyncContextTuple) {
|
||||
asyncContextTuple->putInternalField(vm, 0, oldAsyncContextData);
|
||||
}
|
||||
|
||||
if (auto* exception = exceptionPtr.get()) {
|
||||
|
||||
@@ -1,72 +1,84 @@
|
||||
|
||||
#include "root.h"
|
||||
|
||||
#include "JavaScriptCore/JSCJSValue.h"
|
||||
#include "JavaScriptCore/JSGlobalObject.h"
|
||||
#include "JavaScriptCore/DeleteAllCodeEffort.h"
|
||||
|
||||
#include "headers.h"
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "GCDefferalContext.h"
|
||||
|
||||
#include "JavaScriptCore/AggregateError.h"
|
||||
#include "JavaScriptCore/BytecodeIndex.h"
|
||||
#include "JavaScriptCore/CodeBlock.h"
|
||||
#include "JavaScriptCore/Completion.h"
|
||||
#include "JavaScriptCore/ErrorInstance.h"
|
||||
#include "JavaScriptCore/ExceptionHelpers.h"
|
||||
#include "JavaScriptCore/ExceptionScope.h"
|
||||
#include "JavaScriptCore/FunctionConstructor.h"
|
||||
#include "JavaScriptCore/HeapSnapshotBuilder.h"
|
||||
#include "JavaScriptCore/Identifier.h"
|
||||
#include "JavaScriptCore/IteratorOperations.h"
|
||||
#include "JavaScriptCore/JSArray.h"
|
||||
#include "JavaScriptCore/JSArrayBuffer.h"
|
||||
#include "JavaScriptCore/JSArrayInlines.h"
|
||||
#include "JavaScriptCore/ErrorInstanceInlines.h"
|
||||
|
||||
#include "JavaScriptCore/JSCallbackObject.h"
|
||||
#include "JavaScriptCore/JSClassRef.h"
|
||||
#include "JavaScriptCore/JSInternalPromise.h"
|
||||
#include "JavaScriptCore/JSMap.h"
|
||||
#include "JavaScriptCore/JSModuleLoader.h"
|
||||
#include "JavaScriptCore/JSModuleRecord.h"
|
||||
#include "JavaScriptCore/JSNativeStdFunction.h"
|
||||
#include "JavaScriptCore/JSONObject.h"
|
||||
#include "JavaScriptCore/JSObject.h"
|
||||
#include "JavaScriptCore/JSSet.h"
|
||||
#include "JavaScriptCore/JSString.h"
|
||||
#include "JavaScriptCore/ProxyObject.h"
|
||||
#include "JavaScriptCore/Microtask.h"
|
||||
#include "JavaScriptCore/ObjectConstructor.h"
|
||||
#include "JavaScriptCore/ParserError.h"
|
||||
#include "JavaScriptCore/ScriptExecutable.h"
|
||||
#include "JavaScriptCore/StackFrame.h"
|
||||
#include "JavaScriptCore/StackVisitor.h"
|
||||
#include "JavaScriptCore/VM.h"
|
||||
#include "JavaScriptCore/WasmFaultSignalHandler.h"
|
||||
#include "JavaScriptCore/Watchdog.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
#include "helpers.h"
|
||||
#include "JavaScriptCore/JSObjectInlines.h"
|
||||
|
||||
#include "wtf/Assertions.h"
|
||||
#include "wtf/text/ExternalStringImpl.h"
|
||||
#include "wtf/text/StringCommon.h"
|
||||
#include "wtf/text/StringImpl.h"
|
||||
#include "wtf/text/StringView.h"
|
||||
#include "wtf/text/WTFString.h"
|
||||
#include "JavaScriptCore/FunctionPrototype.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "FetchHeaders.h"
|
||||
#include "DOMURL.h"
|
||||
#include "JSDOMURL.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <bun-uws/src/App.h>
|
||||
#include <bun-usockets/src/internal/internal.h>
|
||||
|
||||
#include <JavaScriptCore/AggregateError.h>
|
||||
#include <JavaScriptCore/BytecodeIndex.h>
|
||||
#include <JavaScriptCore/Bun_InternalFieldTuple.h>
|
||||
#include <JavaScriptCore/CodeBlock.h>
|
||||
#include <JavaScriptCore/Completion.h>
|
||||
#include <JavaScriptCore/CustomGetterSetter.h>
|
||||
#include <JavaScriptCore/DateInstance.h>
|
||||
#include <JavaScriptCore/DeleteAllCodeEffort.h>
|
||||
#include <JavaScriptCore/ErrorInstance.h>
|
||||
#include <JavaScriptCore/ErrorInstanceInlines.h>
|
||||
#include <JavaScriptCore/ExceptionHelpers.h>
|
||||
#include <JavaScriptCore/ExceptionScope.h>
|
||||
#include <JavaScriptCore/FunctionConstructor.h>
|
||||
#include <JavaScriptCore/FunctionPrototype.h>
|
||||
#include <JavaScriptCore/GetterSetter.h>
|
||||
#include <JavaScriptCore/HashMapImpl.h>
|
||||
#include <JavaScriptCore/HashMapImplInlines.h>
|
||||
#include <JavaScriptCore/HeapSnapshotBuilder.h>
|
||||
#include <JavaScriptCore/Identifier.h>
|
||||
#include <JavaScriptCore/IteratorOperations.h>
|
||||
#include <JavaScriptCore/JSArray.h>
|
||||
#include <JavaScriptCore/JSArrayBuffer.h>
|
||||
#include <JavaScriptCore/JSArrayInlines.h>
|
||||
#include <JavaScriptCore/JSCallbackObject.h>
|
||||
#include <JavaScriptCore/JSClassRef.h>
|
||||
#include <JavaScriptCore/JSInternalPromise.h>
|
||||
#include <JavaScriptCore/JSMap.h>
|
||||
#include <JavaScriptCore/JSMapInlines.h>
|
||||
#include <JavaScriptCore/JSModuleLoader.h>
|
||||
#include <JavaScriptCore/JSModuleRecord.h>
|
||||
#include <JavaScriptCore/JSNativeStdFunction.h>
|
||||
#include <JavaScriptCore/JSONObject.h>
|
||||
#include <JavaScriptCore/JSObject.h>
|
||||
#include <JavaScriptCore/JSSet.h>
|
||||
#include <JavaScriptCore/JSString.h>
|
||||
#include <JavaScriptCore/JSWeakMap.h>
|
||||
#include <JavaScriptCore/PropertyNameArray.h>
|
||||
#include <JavaScriptCore/ProxyObject.h>
|
||||
#include <JavaScriptCore/Microtask.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
#include <JavaScriptCore/ParserError.h>
|
||||
#include <JavaScriptCore/RegExpObject.h>
|
||||
#include <JavaScriptCore/ScriptExecutable.h>
|
||||
#include <JavaScriptCore/StackFrame.h>
|
||||
#include <JavaScriptCore/StackVisitor.h>
|
||||
#include <JavaScriptCore/TestRunnerUtils.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
#include <JavaScriptCore/WasmFaultSignalHandler.h>
|
||||
#include <JavaScriptCore/Watchdog.h>
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include <wtf/Assertions.h>
|
||||
#include <wtf/Scope.h>
|
||||
#include <wtf/text/AtomString.h>
|
||||
#include <wtf/text/ExternalStringImpl.h>
|
||||
#include <wtf/text/StringCommon.h>
|
||||
#include <wtf/text/StringImpl.h>
|
||||
#include <wtf/text/StringToIntegerConversion.h>
|
||||
#include <wtf/text/StringView.h>
|
||||
#include <wtf/text/WTFString.h>
|
||||
|
||||
#include "webcore/JSAbortSignal.h"
|
||||
|
||||
#include "AsyncContextFrame.h"
|
||||
#include "DOMFormData.h"
|
||||
#include "DOMURL.h"
|
||||
#include "BunClientData.h"
|
||||
#include "FetchHeaders.h"
|
||||
#include "GCDefferalContext.h"
|
||||
#include "HTTPHeaderNames.h"
|
||||
#include "IDLTypes.h"
|
||||
#include "JSAbortAlgorithm.h"
|
||||
#include "JSDOMBinding.h"
|
||||
#include "JSDOMConstructor.h"
|
||||
#include "JSDOMConvertBase.h"
|
||||
@@ -78,38 +90,17 @@
|
||||
#include "JSDOMConvertStrings.h"
|
||||
#include "JSDOMConvertUnion.h"
|
||||
#include "JSDOMExceptionHandling.h"
|
||||
#include "JSDOMFormData.h"
|
||||
#include "JSDOMGlobalObjectInlines.h"
|
||||
#include "JSDOMIterator.h"
|
||||
#include "JSDOMOperation.h"
|
||||
#include "JSDOMWrapperCache.h"
|
||||
|
||||
#include "wtf/text/AtomString.h"
|
||||
#include "wtf/Scope.h"
|
||||
#include "HTTPHeaderNames.h"
|
||||
#include "JSDOMPromiseDeferred.h"
|
||||
#include "JavaScriptCore/TestRunnerUtils.h"
|
||||
#include "JavaScriptCore/DateInstance.h"
|
||||
#include "JavaScriptCore/RegExpObject.h"
|
||||
#include "JavaScriptCore/PropertyNameArray.h"
|
||||
#include "JavaScriptCore/HashMapImpl.h"
|
||||
#include "JavaScriptCore/HashMapImplInlines.h"
|
||||
#include "webcore/JSAbortSignal.h"
|
||||
#include "JSAbortAlgorithm.h"
|
||||
|
||||
#include "DOMFormData.h"
|
||||
#include "JSDOMFormData.h"
|
||||
#include "ZigGeneratedClasses.h"
|
||||
#include "JavaScriptCore/JSMapInlines.h"
|
||||
|
||||
#include <JavaScriptCore/JSWeakMap.h>
|
||||
#include "JSDOMURL.h"
|
||||
#include "JSDOMWrapperCache.h"
|
||||
#include "JSFetchHeaders.h"
|
||||
#include "JSURLSearchParams.h"
|
||||
|
||||
#include "AsyncContextFrame.h"
|
||||
#include "JavaScriptCore/InternalFieldTuple.h"
|
||||
#include "wtf/text/StringToIntegerConversion.h"
|
||||
|
||||
#include "JavaScriptCore/GetterSetter.h"
|
||||
#include "JavaScriptCore/CustomGetterSetter.h"
|
||||
#include "ZigGeneratedClasses.h"
|
||||
#include "ZigGlobalObject.h"
|
||||
|
||||
static WTF::StringView StringView_slice(WTF::StringView sv, unsigned start, unsigned end)
|
||||
{
|
||||
@@ -2181,13 +2172,13 @@ extern "C" JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSC_
|
||||
JSC::JSValue jsObject = JSValue::decode(object);
|
||||
JSC::JSValue jsThisObject = JSValue::decode(thisObject);
|
||||
|
||||
JSValue restoreAsyncContext;
|
||||
InternalFieldTuple* asyncContextData = nullptr;
|
||||
JSValue oldAsyncContextData;
|
||||
InternalFieldTuple* asyncContextTuple = nullptr;
|
||||
if (auto* wrapper = jsDynamicCast<AsyncContextFrame*>(jsObject)) {
|
||||
jsObject = jsCast<JSC::JSObject*>(wrapper->callback.get());
|
||||
asyncContextData = globalObject->m_asyncContextData.get();
|
||||
restoreAsyncContext = asyncContextData->getInternalField(0);
|
||||
asyncContextData->putInternalField(vm, 0, wrapper->context.get());
|
||||
asyncContextTuple = globalObject->asyncContextTuple();
|
||||
oldAsyncContextData = asyncContextTuple->getInternalField(0);
|
||||
asyncContextTuple->putInternalField(vm, 0, wrapper->context.get());
|
||||
}
|
||||
|
||||
if (!jsThisObject)
|
||||
@@ -2204,8 +2195,8 @@ extern "C" JSC__JSValue JSObjectCallAsFunctionReturnValue(JSContextRef ctx, JSC_
|
||||
NakedPtr<JSC::Exception> returnedException = nullptr;
|
||||
auto result = JSC::profiledCall(globalObject, ProfilingReason::API, jsObject, callData, jsThisObject, argList, returnedException);
|
||||
|
||||
if (asyncContextData) {
|
||||
asyncContextData->putInternalField(vm, 0, restoreAsyncContext);
|
||||
if (asyncContextTuple) {
|
||||
asyncContextTuple->putInternalField(vm, 0, oldAsyncContextData);
|
||||
}
|
||||
|
||||
if (returnedException.get()) {
|
||||
@@ -2969,7 +2960,7 @@ void JSC__JSPromise__rejectOnNextTickWithHandled(JSC__JSPromise* promise, JSC__J
|
||||
globalObject->queueMicrotask(
|
||||
globalObject->performMicrotaskFunction(),
|
||||
globalObject->rejectPromiseFunction(),
|
||||
globalObject->m_asyncContextData.get()->getInternalField(0),
|
||||
globalObject->asyncContextTuple()->getInternalField(0),
|
||||
promise,
|
||||
value);
|
||||
RETURN_IF_EXCEPTION(scope, void());
|
||||
@@ -5194,7 +5185,7 @@ extern "C" void JSC__JSGlobalObject__queueMicrotaskJob(JSC__JSGlobalObject* arg0
|
||||
Zig::GlobalObject* globalObject = reinterpret_cast<Zig::GlobalObject*>(arg0);
|
||||
JSValue microtaskArgs[] = {
|
||||
JSValue::decode(JSValue1),
|
||||
globalObject->m_asyncContextData.get()->getInternalField(0),
|
||||
globalObject->asyncContextTuple()->getInternalField(0),
|
||||
JSValue::decode(JSValue3),
|
||||
JSValue::decode(JSValue4)
|
||||
};
|
||||
|
||||
@@ -43,8 +43,6 @@
|
||||
#define JSC_MAC_VERSION_TBA 0
|
||||
#define JSC_IOS_VERSION_TBA 0
|
||||
|
||||
#include <wtf/ExportMacros.h>
|
||||
|
||||
#define JS_EXPORT_PRIVATE
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -53,8 +51,6 @@
|
||||
#include <wtf/FastMalloc.h>
|
||||
#endif
|
||||
|
||||
#include <wtf/DisallowCType.h>
|
||||
|
||||
/* Disabling warning C4206: nonstandard extension used: translation unit is empty.
|
||||
By design, we rely on #define flags to make some translation units empty.
|
||||
Make sure this warning does not turn into an error.
|
||||
@@ -67,12 +63,14 @@
|
||||
#define WEBCORE_EXPORT JS_EXPORT_PRIVATE
|
||||
#endif
|
||||
|
||||
#include <wtf/PlatformCallingConventions.h>
|
||||
#include <JavaScriptCore/JSCJSValue.h>
|
||||
#include <JavaScriptCore/HandleSet.h>
|
||||
#include <JavaScriptCore/JSCInlines.h>
|
||||
#include <JavaScriptCore/JSCJSValue.h>
|
||||
#include <wtf/DisallowCType.h>
|
||||
#include <wtf/ExportMacros.h>
|
||||
#include <wtf/IsoMalloc.h>
|
||||
#include <wtf/IsoMallocInlines.h>
|
||||
#include <JavaScriptCore/HandleSet.h>
|
||||
#include <wtf/PlatformCallingConventions.h>
|
||||
|
||||
#define ENABLE_WEB_CRYPTO 1
|
||||
#define USE_OPENSSL 1
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "BunBroadcastChannelRegistry.h"
|
||||
#include <wtf/CallbackAggregator.h>
|
||||
#include "webcore/BroadcastChannel.h"
|
||||
#include "webcore/MessageWithMessagePorts.h"
|
||||
#include <wtf/CallbackAggregator.h>
|
||||
|
||||
#include "BunBroadcastChannelRegistry.h"
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wtf/NeverDestroyed.h>
|
||||
#include "DOMURL.h"
|
||||
#include "JSDOMWrapper.h"
|
||||
#include <wtf/NeverDestroyed.h>
|
||||
|
||||
namespace WebCore {
|
||||
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "BunClientData.h"
|
||||
#include "JavaScriptCore/CatchScope.h"
|
||||
#include "_NativeModule.h"
|
||||
|
||||
#include "napi_external.h"
|
||||
#include "webcrypto/JSCryptoKey.h"
|
||||
#include "webcrypto/JSJsonWebKey.h"
|
||||
#include <JavaScriptCore/AggregateError.h>
|
||||
#include <JavaScriptCore/AsyncFunctionPrototype.h>
|
||||
#include <JavaScriptCore/CallFrame.h>
|
||||
#include <JavaScriptCore/CallFrameInlines.h>
|
||||
#include <JavaScriptCore/CatchScope.h>
|
||||
#include <JavaScriptCore/ErrorPrototype.h>
|
||||
#include <JavaScriptCore/GeneratorFunctionPrototype.h>
|
||||
#include <JavaScriptCore/JSArrayBuffer.h>
|
||||
#include <JavaScriptCore/ObjectConstructor.h>
|
||||
|
||||
#include "_NativeModule.h"
|
||||
#include "BunClientData.h"
|
||||
#include "napi_external.h"
|
||||
#include "webcrypto/JSCryptoKey.h"
|
||||
#include "webcrypto/JSJsonWebKey.h"
|
||||
|
||||
using namespace JSC;
|
||||
|
||||
#define GET_FIRST_VALUE \
|
||||
|
||||
@@ -8,14 +8,16 @@
|
||||
// library, instead of RegExp hacks.
|
||||
//
|
||||
// For explanation on this, please nag @paperdave to write documentation on how everything works.
|
||||
import { readdirSync, rmSync } from "fs";
|
||||
import path from "path";
|
||||
import { mkdirSync, readdirSync, rmSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
import { sliceSourceCode } from "./builtin-parser";
|
||||
import { applyGlobalReplacements, define } from "./replacements";
|
||||
import { cap, fmtCPPCharArray, low, writeIfNotChanged } from "./helpers";
|
||||
import { alphanumComparator, cap, fmtCPPCharArray, hasTsExt, low, writeIfChanged } from "./helpers";
|
||||
import { createInternalModuleRegistry } from "./internal-module-registry-scanner";
|
||||
import { createAssertClientJS, createLogClientJS } from "./client-js";
|
||||
import { getJS2NativeDTS } from "./js2native-generator";
|
||||
|
||||
const EOL = "\n";
|
||||
const PARALLEL = false;
|
||||
const KEEP_TMP = true;
|
||||
|
||||
@@ -23,7 +25,7 @@ if (import.meta.main) {
|
||||
throw new Error("This script is not meant to be run directly");
|
||||
}
|
||||
|
||||
const CMAKE_BUILD_ROOT = globalThis.CMAKE_BUILD_ROOT;
|
||||
const { CMAKE_BUILD_ROOT } = globalThis;
|
||||
if (!CMAKE_BUILD_ROOT) {
|
||||
throw new Error("CMAKE_BUILD_ROOT is not defined");
|
||||
}
|
||||
@@ -63,11 +65,11 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
|
||||
|
||||
contents = applyGlobalReplacements(contents);
|
||||
|
||||
// first approach doesnt work perfectly because we actually need to split each function declaration
|
||||
// first approach doesn't work perfectly because we actually need to split each function declaration
|
||||
// and then compile those separately
|
||||
|
||||
const consumeWhitespace = /^\s*/;
|
||||
const consumeTopLevelContent = /^(\/\*|\/\/|type|import|interface|\$|export (?:async )?function|(?:async )?function)/;
|
||||
const consumeTopLevelContent = /^(?:\/\*|\/\/|type|import|interface|\$|(?:export )?(?:async )?function)/;
|
||||
const consumeEndOfType = /;|.(?=export|type|interface|\$|\/\/|\/\*|function)/;
|
||||
|
||||
const functions: ParsedBuiltin[] = [];
|
||||
@@ -80,37 +82,37 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
|
||||
if (!contents.length) break;
|
||||
const match = contents.match(consumeTopLevelContent);
|
||||
if (!match) {
|
||||
throw new SyntaxError("Could not process input:\n" + contents.slice(0, contents.indexOf("\n")));
|
||||
throw new SyntaxError(`Could not process input:${EOL}${contents.slice(0, contents.indexOf(EOL))}`);
|
||||
}
|
||||
contents = contents.slice(match.index!);
|
||||
if (match[1] === "import") {
|
||||
contents = contents.slice(match.index);
|
||||
if (match[0] === "import") {
|
||||
// TODO: we may want to do stuff with these
|
||||
const i = contents.indexOf(";");
|
||||
contents = contents.slice(i + 1);
|
||||
} else if (match[1] === "/*") {
|
||||
} else if (match[0] === "/*") {
|
||||
const i = contents.indexOf("*/") + 2;
|
||||
internal ||= contents.slice(0, i).includes("@internal");
|
||||
contents = contents.slice(i);
|
||||
} else if (match[1] === "//") {
|
||||
const i = contents.indexOf("\n") + 1;
|
||||
} else if (match[0] === "//") {
|
||||
const i = contents.indexOf(EOL) + 1;
|
||||
internal ||= contents.slice(0, i).includes("@internal");
|
||||
contents = contents.slice(i);
|
||||
} else if (match[1] === "type" || match[1] === "export type") {
|
||||
} else if (match[0] === "type" || match[0] === "export type") {
|
||||
const i = contents.search(consumeEndOfType);
|
||||
contents = contents.slice(i + 1);
|
||||
} else if (match[1] === "interface") {
|
||||
} else if (match[0] === "interface") {
|
||||
contents = sliceSourceCode(contents, false).rest;
|
||||
} else if (match[1] === "$") {
|
||||
const directive = contents.match(/^\$([a-zA-Z0-9]+)(?:\s*=\s*([^\r\n]+?))?\s*;?\r?\n/);
|
||||
} else if (match[0] === "$") {
|
||||
const directive = contents.match(/^\$(\w+)(?:\s*=\s*([^\r\n]+?))?\s*;?\r?\n/);
|
||||
if (!directive) {
|
||||
throw new SyntaxError("Could not parse directive:\n" + contents.slice(0, contents.indexOf("\n")));
|
||||
throw new SyntaxError(`Could not parse directive:${EOL}${contents.slice(0, contents.indexOf(EOL))}`);
|
||||
}
|
||||
const name = directive[1];
|
||||
let value;
|
||||
try {
|
||||
value = directive[2] ? JSON.parse(directive[2]) : true;
|
||||
} catch (error) {
|
||||
throw new SyntaxError("Could not parse directive value " + directive[2] + " (must be JSON parsable)");
|
||||
throw new SyntaxError(`Could not parse directive value ${directive[2]} (must be JSON parsable)`);
|
||||
}
|
||||
if (name === "constructor") {
|
||||
directives.ConstructAbility = "CanConstruct";
|
||||
@@ -121,12 +123,12 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
|
||||
directives[name] = value;
|
||||
}
|
||||
contents = contents.slice(directive[0].length);
|
||||
} else if (match[1] === "export function" || match[1] === "export async function") {
|
||||
} else if (match[0] === "export function" || match[0] === "export async function") {
|
||||
const declaration = contents.match(
|
||||
/^export\s+(async\s+)?function\s+([a-zA-Z0-9]+)\s*\(([^)]*)\)(?:\s*:\s*([^{\n]+))?\s*{?/,
|
||||
/^export\s+(async\s+)?function\s+([$\w]+)\s*\(([^)]*)\)(?:\s*:\s*([^\r\n{]+))?\s*{?/,
|
||||
);
|
||||
if (!declaration)
|
||||
throw new SyntaxError("Could not parse function declaration:\n" + contents.slice(0, contents.indexOf("\n")));
|
||||
throw new SyntaxError(`Could not parse function declaration:${EOL}${contents.slice(0, contents.indexOf(EOL))}`);
|
||||
|
||||
const async = !!declaration[1];
|
||||
const name = declaration[2];
|
||||
@@ -138,7 +140,7 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
|
||||
}
|
||||
|
||||
const { result, rest } = sliceSourceCode(contents.slice(declaration[0].length - 1), true, x =>
|
||||
globalThis.requireTransformer(x, SRC_DIR + "/" + basename),
|
||||
globalThis.requireTransformer(x, `${SRC_DIR}/${basename}`),
|
||||
);
|
||||
|
||||
functions.push({
|
||||
@@ -150,11 +152,11 @@ async function processFileSplit(filename: string): Promise<{ functions: BundledB
|
||||
});
|
||||
contents = rest;
|
||||
directives = {};
|
||||
} else if (match[1] === "function" || match[1] === "async function") {
|
||||
const fnname = contents.match(/^function ([a-zA-Z0-9]+)\(([^)]*)\)(?:\s*:\s*([^{\n]+))?\s*{?/)![1];
|
||||
throw new SyntaxError("All top level functions must be exported: " + fnname);
|
||||
} else if (match[0] === "function" || match[0] === "async function") {
|
||||
const fnName = contents.match(/^function ([$\w]+)/)?.[1] ?? "anonymous";
|
||||
throw new SyntaxError(`All top level functions must be exported: ${fnName}`);
|
||||
} else {
|
||||
throw new Error("TODO: parse " + match[1]);
|
||||
throw new Error(`TODO: parse ${match[1]}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,15 +191,15 @@ $$capture_start$$(${fn.async ? "async " : ""}${
|
||||
minify: { syntax: true, whitespace: false },
|
||||
});
|
||||
if (!build.success) {
|
||||
throw new AggregateError(build.logs, "Failed bundling builtin function " + fn.name + " from " + basename + ".ts");
|
||||
throw new AggregateError(build.logs, `Failed bundling builtin function ${fn.name} from ${basename}.ts`);
|
||||
}
|
||||
if (build.outputs.length !== 1) {
|
||||
throw new Error("expected one output");
|
||||
}
|
||||
const output = await build.outputs[0].text();
|
||||
let usesDebug = output.includes("$debug_log");
|
||||
let usesAssert = output.includes("$assert");
|
||||
const captured = output.match(/\$\$capture_start\$\$([\s\S]+)\.\$\$capture_end\$\$/)![1];
|
||||
const usesDebug = output.includes("$debug_log");
|
||||
const usesAssert = output.includes("$assert");
|
||||
const captured = output.match(/\$\$capture_start\$\$([\s\S]+)\.\$\$capture_end\$\$/)?.[1] ?? "";
|
||||
const finalReplacement =
|
||||
(fn.directives.sloppy
|
||||
? captured
|
||||
@@ -209,12 +211,12 @@ $$capture_start$$(${fn.async ? "async " : ""}${
|
||||
)
|
||||
)
|
||||
.replace(/^\((async )?function\(/, "($1function (")
|
||||
.replace(/__intrinsic__/g, "@")
|
||||
.replace(/__no_intrinsic__/g, "") + "\n";
|
||||
.replaceAll("__intrinsic__", "@")
|
||||
.replaceAll("__no_intrinsic__", "") + EOL;
|
||||
|
||||
const errors = [...finalReplacement.matchAll(/@bundleError\((.*)\)/g)];
|
||||
if (errors.length) {
|
||||
throw new Error(`Errors in ${basename}.ts:\n${errors.map(x => x[1]).join("\n")}`);
|
||||
throw new Error(`Errors in ${basename}.ts:${EOL}${errors.map(x => x[1]).join(EOL)}`);
|
||||
}
|
||||
|
||||
bundledFunctions.push({
|
||||
@@ -237,7 +239,7 @@ $$capture_start$$(${fn.async ? "async " : ""}${
|
||||
}
|
||||
|
||||
return {
|
||||
functions: bundledFunctions.sort((a, b) => a.name.localeCompare(b.name)),
|
||||
functions: bundledFunctions.sort((a, b) => alphanumComparator(a.name, b.name)),
|
||||
internal,
|
||||
};
|
||||
}
|
||||
@@ -251,7 +253,7 @@ async function processFunctionFile(x: string) {
|
||||
...(await processFileSplit(path.join(SRC_DIR, x))),
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to process file: " + basename + ".ts");
|
||||
console.error(`Failed to process file: ${basename}.ts`);
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
@@ -262,9 +264,7 @@ interface BundleBuiltinFunctionsArgs {
|
||||
}
|
||||
|
||||
export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuiltinFunctionsArgs) {
|
||||
const filesToProcess = readdirSync(SRC_DIR)
|
||||
.filter(x => x.endsWith(".ts") && !x.endsWith(".d.ts"))
|
||||
.sort();
|
||||
const filesToProcess = readdirSync(SRC_DIR).filter(hasTsExt).sort(alphanumComparator);
|
||||
|
||||
// Bun seems to crash if this is parallelized, :(
|
||||
if (PARALLEL) {
|
||||
@@ -289,7 +289,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
`;
|
||||
|
||||
for (const { basename, functions } of files) {
|
||||
bundledCPP += `/* ${basename}.ts */\n`;
|
||||
bundledCPP += `/* ${basename}.ts */${EOL}`;
|
||||
const lowerBasename = low(basename);
|
||||
for (const fn of functions) {
|
||||
const [code, count] = fmtCPPCharArray(fn.source, true);
|
||||
@@ -329,7 +329,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) {
|
||||
bundledCPP += ` , m_${low(basename)}(vm)\n`;
|
||||
bundledCPP += ` , m_${low(basename)}(vm)${EOL}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
{
|
||||
`;
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) bundledCPP += ` m_${low(basename)}.visit(visitor);\n`;
|
||||
if (internal) bundledCPP += ` m_${low(basename)}.visit(visitor);${EOL}`;
|
||||
}
|
||||
|
||||
bundledCPP += `
|
||||
@@ -360,7 +360,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) {
|
||||
bundledCPP += ` m_${low(basename)}.init(globalObject);\n`;
|
||||
bundledCPP += ` m_${low(basename)}.init(globalObject);${EOL}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -426,20 +426,20 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
`;
|
||||
}
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_DATA(macro) \\\n`;
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_DATA(macro) \\${EOL}`;
|
||||
for (const fn of functions) {
|
||||
bundledHeader += ` macro(${fn.name}, ${lowerBasename}${cap(fn.name)}, ${fn.params.length}) \\\n`;
|
||||
bundledHeader += ` macro(${fn.name}, ${lowerBasename}${cap(fn.name)}, ${fn.params.length}) \\${EOL}`;
|
||||
}
|
||||
bundledHeader += "\n";
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(macro) \\\n`;
|
||||
bundledHeader += EOL;
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_CODE(macro) \\${EOL}`;
|
||||
for (const fn of functions) {
|
||||
const name = `${lowerBasename}${cap(fn.name)}Code`;
|
||||
bundledHeader += ` macro(${name}, ${fn.name}, ${fn.overriddenName}, s_${name}Length) \\\n`;
|
||||
bundledHeader += ` macro(${name}, ${fn.name}, ${fn.overriddenName}, s_${name}Length) \\${EOL}`;
|
||||
}
|
||||
bundledHeader += "\n";
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(macro) \\\n`;
|
||||
bundledHeader += EOL;
|
||||
bundledHeader += `#define WEBCORE_FOREACH_${basename.toUpperCase()}_BUILTIN_FUNCTION_NAME(macro) \\${EOL}`;
|
||||
for (const fn of functions) {
|
||||
bundledHeader += ` macro(${fn.name}) \\\n`;
|
||||
bundledHeader += ` macro(${fn.name}) \\${EOL}`;
|
||||
}
|
||||
bundledHeader += `
|
||||
#define DECLARE_BUILTIN_GENERATOR(codeName, functionName, overriddenName, argumentCount) \\
|
||||
@@ -549,7 +549,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
`;
|
||||
|
||||
for (const { basename } of files) {
|
||||
bundledHeader += ` , m_${low(basename)}Builtins(m_vm)\n`;
|
||||
bundledHeader += ` , m_${low(basename)}Builtins(m_vm)${EOL}`;
|
||||
}
|
||||
|
||||
bundledHeader += `
|
||||
@@ -558,7 +558,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) {
|
||||
bundledHeader += ` m_${low(basename)}Builtins.exportNames();\n`;
|
||||
bundledHeader += ` m_${low(basename)}Builtins.exportNames();${EOL}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -568,7 +568,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
for (const { basename } of files) {
|
||||
bundledHeader += ` ${basename}BuiltinsWrapper& ${low(basename)}Builtins() { return m_${low(
|
||||
basename,
|
||||
)}Builtins; }\n`;
|
||||
)}Builtins; }${EOL}`;
|
||||
}
|
||||
|
||||
bundledHeader += `
|
||||
@@ -577,7 +577,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
`;
|
||||
|
||||
for (const { basename } of files) {
|
||||
bundledHeader += ` ${basename}BuiltinsWrapper m_${low(basename)}Builtins;\n`;
|
||||
bundledHeader += ` ${basename}BuiltinsWrapper m_${low(basename)}Builtins;${EOL}`;
|
||||
}
|
||||
|
||||
bundledHeader += `;
|
||||
@@ -593,7 +593,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) {
|
||||
bundledHeader += ` ${basename}BuiltinFunctions& ${low(basename)}() { return m_${low(basename)}; }\n`;
|
||||
bundledHeader += ` ${basename}BuiltinFunctions& ${low(basename)}() { return m_${low(basename)}; }${EOL}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -604,7 +604,7 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, internal } of files) {
|
||||
if (internal) {
|
||||
bundledHeader += ` ${basename}BuiltinFunctions m_${low(basename)};\n`;
|
||||
bundledHeader += ` ${basename}BuiltinFunctions m_${low(basename)};${EOL}`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,8 +614,8 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
} // namespace WebCore
|
||||
`;
|
||||
|
||||
writeIfNotChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.h"), bundledHeader);
|
||||
writeIfNotChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.cpp"), bundledCPP);
|
||||
writeIfChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.h"), bundledHeader);
|
||||
writeIfChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.cpp"), bundledCPP);
|
||||
|
||||
// Generate TS types
|
||||
let dts = `// Generated by \`bun src/js/builtins/codegen\`
|
||||
@@ -625,19 +625,19 @@ export async function bundleBuiltinFunctions({ requireTransformer }: BundleBuilt
|
||||
|
||||
for (const { basename, functions, internal } of files) {
|
||||
if (internal) {
|
||||
dts += `\n// ${basename}.ts\n`;
|
||||
dts += `${EOL}// ${basename}.ts${EOL}`;
|
||||
for (const fn of functions) {
|
||||
dts += `declare const \$${fn.name}: RemoveThis<typeof import("${path.relative(
|
||||
CODEGEN_DIR,
|
||||
path.join(SRC_DIR, basename),
|
||||
)}")[${JSON.stringify(fn.name)}]>;\n`;
|
||||
)}")[${JSON.stringify(fn.name)}]>;${EOL}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dts += getJS2NativeDTS();
|
||||
|
||||
writeIfNotChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.d.ts"), dts);
|
||||
writeIfChanged(path.join(CODEGEN_DIR, "WebCoreJSBuiltins.d.ts"), dts);
|
||||
|
||||
const totalJSSize = files.reduce(
|
||||
(acc, { functions }) => acc + functions.reduce((acc, fn) => acc + fn.source.length, 0),
|
||||
|
||||
@@ -8,17 +8,26 @@
|
||||
// library, instead of RegExp hacks.
|
||||
//
|
||||
// For explanation on this, please nag @paperdave to write documentation on how everything works.
|
||||
import fs from "fs";
|
||||
import { writeFile, mkdir } from "fs/promises";
|
||||
import path from "path";
|
||||
import { sliceSourceCode } from "./builtin-parser";
|
||||
import { cap, declareASCIILiteral, writeIfNotChanged } from "./helpers";
|
||||
import { createAssertClientJS, createLogClientJS } from "./client-js";
|
||||
import fs from "node:fs";
|
||||
import { writeFile, mkdir } from "node:fs/promises";
|
||||
import { builtinModules } from "node:module";
|
||||
import path from "node:path";
|
||||
import { sliceSourceCode } from "./builtin-parser";
|
||||
import {
|
||||
declareASCIILiteral,
|
||||
idToEnumName,
|
||||
idToPublicSpecifierOrEnumName,
|
||||
matchAllNonIdentCharsRegExp,
|
||||
replaceScriptExtWithDotJS,
|
||||
trimScriptExt,
|
||||
writeIfChanged,
|
||||
} from "./helpers";
|
||||
import { createAssertClientJS, createLogClientJS } from "./client-js";
|
||||
import { define } from "./replacements";
|
||||
import { createInternalModuleRegistry } from "./internal-module-registry-scanner";
|
||||
import { getJS2NativeCPP, getJS2NativeZig } from "./js2native-generator";
|
||||
|
||||
const EOL = "\n";
|
||||
const BASE = path.join(import.meta.dir, "../js");
|
||||
const debug = process.argv[2] === "--debug=ON";
|
||||
const CMAKE_BUILD_ROOT = process.argv[3];
|
||||
@@ -31,8 +40,19 @@ if (!CMAKE_BUILD_ROOT) {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const {
|
||||
//
|
||||
moduleList,
|
||||
nativeModuleIds,
|
||||
nativeModuleEnumToId,
|
||||
nativeModuleEnums,
|
||||
requireTransformer,
|
||||
} = createInternalModuleRegistry(BASE);
|
||||
|
||||
globalThis.CMAKE_BUILD_ROOT = CMAKE_BUILD_ROOT;
|
||||
const bundleBuiltinFunctions = require("./bundle-functions").bundleBuiltinFunctions;
|
||||
globalThis.requireTransformer = requireTransformer;
|
||||
|
||||
const { bundleBuiltinFunctions } = require("./bundle-functions");
|
||||
|
||||
const TMP_DIR = path.join(CMAKE_BUILD_ROOT, "tmp_modules");
|
||||
const CODEGEN_DIR = path.join(CMAKE_BUILD_ROOT, "codegen");
|
||||
@@ -47,10 +67,6 @@ function mark(log: string) {
|
||||
start = now;
|
||||
}
|
||||
|
||||
const { moduleList, nativeModuleIds, nativeModuleEnumToId, nativeModuleEnums, requireTransformer } =
|
||||
createInternalModuleRegistry(BASE);
|
||||
globalThis.requireTransformer = requireTransformer;
|
||||
|
||||
// these logs surround a very weird issue where writing files and then bundling sometimes doesn't
|
||||
// work, so i have lot of debug logs that blow up the console because not sure what is going on.
|
||||
// that is also the reason for using `retry` when theoretically writing a file the first time
|
||||
@@ -73,10 +89,9 @@ async function retry(n, fn) {
|
||||
|
||||
// Preprocess builtins
|
||||
const bundledEntryPoints: string[] = [];
|
||||
for (let i = 0; i < moduleList.length; i++) {
|
||||
for (let i = 0, { length } = moduleList; i < length; i += 1) {
|
||||
try {
|
||||
let input = fs.readFileSync(path.join(BASE, moduleList[i]), "utf8");
|
||||
|
||||
const input = fs.readFileSync(path.join(BASE, moduleList[i]), "utf8");
|
||||
const scannedImports = t.scanImports(input);
|
||||
for (const imp of scannedImports) {
|
||||
if (imp.kind === "import-statement") {
|
||||
@@ -94,23 +109,22 @@ for (let i = 0; i < moduleList.length; i++) {
|
||||
}
|
||||
}
|
||||
|
||||
let importStatements: string[] = [];
|
||||
|
||||
const importStatements: string[] = [];
|
||||
const processed = sliceSourceCode(
|
||||
"{" +
|
||||
input
|
||||
.replace(
|
||||
/\bimport(\s*type)?\s*(\{[^}]*\}|(\*\s*as)?\s[a-zA-Z0-9_$]+)\s*from\s*['"][^'"]+['"]/g,
|
||||
/\bimport(\s*type)?\s*(\{[^}]*\}|(\*\s*as)?\s[$\w]+)\s*from\s*['"][^'"]+['"]/g,
|
||||
stmt => (importStatements.push(stmt), ""),
|
||||
)
|
||||
.replace(/export\s*{\s*}\s*;/g, ""),
|
||||
.replace(/export\s*\{\s*\}\s*;/g, ""),
|
||||
true,
|
||||
x => requireTransformer(x, moduleList[i]),
|
||||
);
|
||||
let fileToTranspile = `// @ts-nocheck
|
||||
// GENERATED TEMP FILE - DO NOT EDIT
|
||||
// Sourced from src/js/${moduleList[i]}
|
||||
${importStatements.join("\n")}
|
||||
${importStatements.join(EOL)}
|
||||
|
||||
${processed.result.slice(1).trim()}
|
||||
$$EXPORT$$(__intrinsic__exports).$$EXPORT_END$$;
|
||||
@@ -118,25 +132,19 @@ $$EXPORT$$(__intrinsic__exports).$$EXPORT_END$$;
|
||||
|
||||
// Attempt to optimize "$exports = ..." to a variableless return
|
||||
// otherwise, declare $exports so it works.
|
||||
let exportOptimization = false;
|
||||
const { length: oldLength } = fileToTranspile;
|
||||
fileToTranspile = fileToTranspile.replace(
|
||||
/__intrinsic__exports\s*=\s*(.*|.*\{[^\}]*}|.*\([^\)]*\))\n+\s*\$\$EXPORT\$\$\(__intrinsic__exports\).\$\$EXPORT_END\$\$;/,
|
||||
(_, a) => {
|
||||
exportOptimization = true;
|
||||
return "$$EXPORT$$(" + a.replace(/;$/, "") + ").$$EXPORT_END$$;";
|
||||
},
|
||||
/__intrinsic__exports\s*=\s*([^\r\n;]+?|.*\{[^\}]*\}|.*\([^\)]*\))(?:\r?\n)+\s*\$\$EXPORT\$\$\(__intrinsic__exports\)/,
|
||||
"$$EXPORT$$($1)",
|
||||
);
|
||||
if (!exportOptimization) {
|
||||
fileToTranspile = `var $;` + fileToTranspile.replaceAll("__intrinsic__exports", "$");
|
||||
if (oldLength === fileToTranspile.length) {
|
||||
fileToTranspile = `var $;${fileToTranspile.replaceAll("__intrinsic__exports", "$")}`;
|
||||
}
|
||||
const outputPath = path.join(TMP_DIR, moduleList[i].slice(0, -3) + ".ts");
|
||||
|
||||
const outputPath = path.join(TMP_DIR, `${moduleList[i].slice(0, -3)}.ts`);
|
||||
await mkdir(path.dirname(outputPath), { recursive: true });
|
||||
if (!fs.existsSync(path.dirname(outputPath))) {
|
||||
verbose("directory did not exist after mkdir twice:", path.dirname(outputPath));
|
||||
}
|
||||
// await Bun.sleep(10);
|
||||
|
||||
try {
|
||||
await writeFile(outputPath, fileToTranspile);
|
||||
if (!fs.existsSync(outputPath)) {
|
||||
@@ -150,7 +158,7 @@ $$EXPORT$$(__intrinsic__exports).$$EXPORT_END$$;
|
||||
await writeFile(outputPath, fileToTranspile);
|
||||
if (!fs.existsSync(outputPath)) {
|
||||
verbose("file did not exist after write:", outputPath);
|
||||
throw new Error("file did not exist after write: " + outputPath);
|
||||
throw new Error(`file did not exist after write: ${outputPath}`);
|
||||
}
|
||||
verbose("wrote to", outputPath, "successfully later");
|
||||
});
|
||||
@@ -206,34 +214,34 @@ for (const entrypoint of bundledEntryPoints) {
|
||||
const file_path = entrypoint.slice(TMP_DIR.length + 1).replace(/\.ts$/, ".js");
|
||||
const file = Bun.file(path.join(TMP_DIR, "modules_out", file_path));
|
||||
const output = await file.text();
|
||||
let captured = `(function (){${output.replace("// @bun\n", "").trim()}})`;
|
||||
let usesDebug = output.includes("$debug_log");
|
||||
let usesAssert = output.includes("$assert");
|
||||
let captured = `(function (){${output.replace(`// @bun${EOL}`, "").trim()}})`;
|
||||
const usesDebug = output.includes("$debug_log");
|
||||
const usesAssert = output.includes("$assert");
|
||||
captured =
|
||||
captured
|
||||
.replace(/\$\$EXPORT\$\$\((.*)\).\$\$EXPORT_END\$\$;/, "return $1")
|
||||
.replace(/]\s*,\s*__(debug|assert)_end__\)/g, ")")
|
||||
.replace(/]\s*,\s*__debug_end__\)/g, ")")
|
||||
.replace(/import.meta.require\((.*?)\)/g, (expr, specifier) => {
|
||||
.replace(/\$\$EXPORT\$\$\((.*)\)\.\$\$EXPORT_END\$\$;/, "return $1")
|
||||
.replace(/]\s*,\s*__(?:assert|debug)_end__\)/g, ")")
|
||||
.replace(/\bimport\.meta\.require\(([^)]+)\)/g, (expr, specifier) => {
|
||||
throw new Error(`Builtin Bundler: do not use import.meta.require() (in ${file_path}))`);
|
||||
})
|
||||
.replace(/return \$\nexport /, "return")
|
||||
.replace(/__intrinsic__/g, "@")
|
||||
.replace(/__no_intrinsic__/g, "") + "\n";
|
||||
.replace(/return \$\r?\nexport /, "return")
|
||||
.replaceAll("__intrinsic__", "@")
|
||||
.replaceAll("__no_intrinsic__", "") + EOL;
|
||||
captured = captured.replace(
|
||||
/function\s*\(.*?\)\s*{/,
|
||||
/function\s*\([^)]*\)\s*\{/,
|
||||
'$&"use strict";' +
|
||||
(usesDebug
|
||||
? createLogClientJS(
|
||||
file_path.replace(".js", ""),
|
||||
idToPublicSpecifierOrEnumName(file_path).replace(/^node:|^bun:/, ""),
|
||||
idToPublicSpecifierOrEnumName(file_path).replace(/^(?:bun|node):/, ""),
|
||||
)
|
||||
: "") +
|
||||
(usesAssert ? createAssertClientJS(idToPublicSpecifierOrEnumName(file_path).replace(/^node:|^bun:/, "")) : ""),
|
||||
(usesAssert ? createAssertClientJS(idToPublicSpecifierOrEnumName(file_path).replace(/^(?:bun|node):/, "")) : ""),
|
||||
);
|
||||
|
||||
const errors = [...captured.matchAll(/@bundleError\((.*)\)/g)];
|
||||
if (errors.length) {
|
||||
throw new Error(`Errors in ${entrypoint}:\n${errors.map(x => x[1]).join("\n")}`);
|
||||
throw new Error(`Errors in ${entrypoint}:${EOL}${errors.map(x => x[1]).join(EOL)}`);
|
||||
}
|
||||
|
||||
const outputPath = path.join(JS_DIR, file_path);
|
||||
@@ -244,29 +252,6 @@ for (const entrypoint of bundledEntryPoints) {
|
||||
|
||||
mark("Postprocesss modules");
|
||||
|
||||
function idToEnumName(id: string) {
|
||||
return id
|
||||
.replace(/\.[mc]?[tj]s$/, "")
|
||||
.replace(/[^a-zA-Z0-9]+/g, " ")
|
||||
.split(" ")
|
||||
.map(x => (["jsc", "ffi", "vm", "tls", "os", "ws", "fs", "dns"].includes(x) ? x.toUpperCase() : cap(x)))
|
||||
.join("");
|
||||
}
|
||||
|
||||
function idToPublicSpecifierOrEnumName(id: string) {
|
||||
id = id.replace(/\.[mc]?[tj]s$/, "");
|
||||
if (id.startsWith("node/")) {
|
||||
return "node:" + id.slice(5).replaceAll(".", "/");
|
||||
} else if (id.startsWith("bun/")) {
|
||||
return "bun:" + id.slice(4).replaceAll(".", "/");
|
||||
} else if (id.startsWith("internal/")) {
|
||||
return "internal:" + id.slice(9).replaceAll(".", "/");
|
||||
} else if (id.startsWith("thirdparty/")) {
|
||||
return id.slice(11).replaceAll(".", "/");
|
||||
}
|
||||
return idToEnumName(id);
|
||||
}
|
||||
|
||||
await bundleBuiltinFunctions({
|
||||
requireTransformer,
|
||||
});
|
||||
@@ -274,27 +259,19 @@ await bundleBuiltinFunctions({
|
||||
mark("Bundle Functions");
|
||||
|
||||
// This is a file with a single macro that is used in defining InternalModuleRegistry.h
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "InternalModuleRegistry+numberOfModules.h"),
|
||||
`#define BUN_INTERNAL_MODULE_COUNT ${moduleList.length}\n`,
|
||||
`#define BUN_INTERNAL_MODULE_COUNT ${moduleList.length}${EOL}`,
|
||||
);
|
||||
|
||||
// This code slice is used in InternalModuleRegistry.h for inlining the enum. I dont think we
|
||||
// actually use this enum but it's probably a good thing to include.
|
||||
writeIfNotChanged(
|
||||
// This code slice is used in InternalModuleRegistry.h for inlining the enum.
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "InternalModuleRegistry+enum.h"),
|
||||
`${
|
||||
moduleList
|
||||
.map((id, n) => {
|
||||
return `${idToEnumName(id)} = ${n},`;
|
||||
})
|
||||
.join("\n") + "\n"
|
||||
}
|
||||
`,
|
||||
`${moduleList.map((id, n) => `${idToEnumName(id)} = ${n},`).join(EOL)}${EOL}`,
|
||||
);
|
||||
|
||||
// This code slice is used in InternalModuleRegistry.cpp. It defines the loading function for modules.
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "InternalModuleRegistry+createInternalModuleById.h"),
|
||||
`// clang-format off
|
||||
JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalObject, VM& vm, Field id)
|
||||
@@ -302,16 +279,17 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO
|
||||
switch (id) {
|
||||
// JS internal modules
|
||||
${moduleList
|
||||
.map((id, n) => {
|
||||
.map(id => {
|
||||
return `case Field::${idToEnumName(id)}: {
|
||||
INTERNAL_MODULE_REGISTRY_GENERATE(globalObject, vm, "${idToPublicSpecifierOrEnumName(id)}"_s, ${JSON.stringify(
|
||||
id.replace(/\.[mc]?[tj]s$/, ".js"),
|
||||
)}_s, InternalModuleRegistryConstants::${idToEnumName(id)}Code, "builtin://${id
|
||||
.replace(/\.[mc]?[tj]s$/, "")
|
||||
.replace(/[^a-zA-Z0-9]+/g, "/")}"_s);
|
||||
replaceScriptExtWithDotJS(id),
|
||||
)}_s, InternalModuleRegistryConstants::${idToEnumName(id)}Code, "builtin://${trimScriptExt(id).replace(
|
||||
matchAllNonIdentCharsRegExp,
|
||||
"/",
|
||||
)}"_s);
|
||||
}`;
|
||||
})
|
||||
.join("\n ")}
|
||||
.join(`${EOL} `)}
|
||||
default: {
|
||||
__builtin_unreachable();
|
||||
}
|
||||
@@ -326,7 +304,7 @@ JSValue InternalModuleRegistry::createInternalModuleById(JSGlobalObject* globalO
|
||||
// We cannot use ASCIILiteral's `_s` operator for the module source code because for long
|
||||
// strings it fails a constexpr assert. Instead, we do that assert in JS before we format the string
|
||||
if (!debug) {
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "InternalModuleRegistryConstants.h"),
|
||||
`// clang-format off
|
||||
#pragma once
|
||||
@@ -341,27 +319,27 @@ namespace InternalModuleRegistryConstants {
|
||||
}
|
||||
return declareASCIILiteral(`${idToEnumName(id)}Code`, out);
|
||||
})
|
||||
.join("\n")}
|
||||
.join(EOL)}
|
||||
}
|
||||
}`,
|
||||
);
|
||||
} else {
|
||||
// In debug builds, we write empty strings to prevent recompilation. These are loaded from disk instead.
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "InternalModuleRegistryConstants.h"),
|
||||
`// clang-format off
|
||||
#pragma once
|
||||
|
||||
namespace Bun {
|
||||
namespace InternalModuleRegistryConstants {
|
||||
${moduleList.map((id, n) => `${declareASCIILiteral(`${idToEnumName(id)}Code`, "")}`).join("\n")}
|
||||
${moduleList.map(id => `${declareASCIILiteral(`${idToEnumName(id)}Code`, "")}`).join(EOL)}
|
||||
}
|
||||
}`,
|
||||
);
|
||||
}
|
||||
|
||||
// This is a generated enum for zig code (exports.zig)
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "ResolvedSourceTag.zig"),
|
||||
`// zig fmt: off
|
||||
pub const ResolvedSourceTag = enum(u32) {
|
||||
@@ -376,17 +354,17 @@ pub const ResolvedSourceTag = enum(u32) {
|
||||
|
||||
// Built in modules are loaded through InternalModuleRegistry by numerical ID.
|
||||
// In this enum are represented as \`(1 << 9) & id\`
|
||||
${moduleList.map((id, n) => ` @"${idToPublicSpecifierOrEnumName(id)}" = ${(1 << 9) | n},`).join("\n")}
|
||||
${moduleList.map((id, n) => ` @"${idToPublicSpecifierOrEnumName(id)}" = ${(1 << 9) | n},`).join(EOL)}
|
||||
// Native modules run through a different system using ESM registry.
|
||||
${Object.entries(nativeModuleIds)
|
||||
.map(([id, n]) => ` @"${id}" = ${(1 << 10) | n},`)
|
||||
.join("\n")}
|
||||
.join(EOL)}
|
||||
};
|
||||
`,
|
||||
);
|
||||
|
||||
// This is a generated enum for c++ code (headers-handwritten.h)
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "SyntheticModuleType.h"),
|
||||
`enum SyntheticModuleType : uint32_t {
|
||||
JavaScript = 0,
|
||||
@@ -400,32 +378,32 @@ writeIfNotChanged(
|
||||
// Built in modules are loaded through InternalModuleRegistry by numerical ID.
|
||||
// In this enum are represented as \`(1 << 9) & id\`
|
||||
InternalModuleRegistryFlag = 1 << 9,
|
||||
${moduleList.map((id, n) => ` ${idToEnumName(id)} = ${(1 << 9) | n},`).join("\n")}
|
||||
${moduleList.map((id, n) => ` ${idToEnumName(id)} = ${(1 << 9) | n},`).join(EOL)}
|
||||
|
||||
// Native modules run through the same system, but with different underlying initializers.
|
||||
// They also have bit 10 set to differentiate them from JS builtins.
|
||||
NativeModuleFlag = (1 << 10) | (1 << 9),
|
||||
${Object.entries(nativeModuleEnumToId)
|
||||
.map(([id, n]) => ` ${id} = ${(1 << 10) | n},`)
|
||||
.join("\n")}
|
||||
.join(EOL)}
|
||||
};
|
||||
|
||||
`,
|
||||
);
|
||||
|
||||
// This is used in ModuleLoader.cpp to link to all the headers for native modules.
|
||||
writeIfNotChanged(
|
||||
writeIfChanged(
|
||||
path.join(CODEGEN_DIR, "NativeModuleImpl.h"),
|
||||
Object.values(nativeModuleEnums)
|
||||
`${Object.values(nativeModuleEnums)
|
||||
.map(value => `#include "../../bun.js/modules/${value}Module.h"`)
|
||||
.join("\n") + "\n",
|
||||
.join(EOL)}${EOL}`,
|
||||
);
|
||||
|
||||
writeIfNotChanged(path.join(CODEGEN_DIR, "GeneratedJS2Native.h"), getJS2NativeCPP());
|
||||
writeIfChanged(path.join(CODEGEN_DIR, "GeneratedJS2Native.h"), getJS2NativeCPP());
|
||||
|
||||
// zig will complain if this file is outside of the module
|
||||
const js2nativeZigPath = path.join(import.meta.dir, "../bun.js/bindings/GeneratedJS2Native.zig");
|
||||
writeIfNotChanged(js2nativeZigPath, getJS2NativeZig(js2nativeZigPath));
|
||||
writeIfChanged(js2nativeZigPath, getJS2NativeZig(js2nativeZigPath));
|
||||
|
||||
mark("Generate Code");
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { spawn } from "bun";
|
||||
import path from "path";
|
||||
import { writeIfNotChanged } from "./helpers";
|
||||
import { writeIfChanged } from "./helpers";
|
||||
|
||||
const input = process.argv[2];
|
||||
const output = process.argv[3];
|
||||
@@ -45,4 +45,4 @@ str = str.replaceAll(`namespace JSC {`, "");
|
||||
str = str.replaceAll(`} // namespace JSC`, "");
|
||||
str = "// File generated via `static-hash-table.ts`\n" + str.trim() + "\n";
|
||||
|
||||
writeIfNotChanged(output, str);
|
||||
writeIfChanged(output, str);
|
||||
|
||||
@@ -42,7 +42,7 @@ my $hasSetter = "false";
|
||||
my $includeBuiltin = 0;
|
||||
my $inside = 0;
|
||||
my $name;
|
||||
my $pefectHashSize;
|
||||
my $perfectHashSize;
|
||||
my $compactSize;
|
||||
my $compactHashSizeMask;
|
||||
my $banner = 0;
|
||||
@@ -58,14 +58,14 @@ while (<IN>) {
|
||||
chomp;
|
||||
s/^\s+//;
|
||||
next if /^\#|^$/; # Comment or blank line. Do nothing.
|
||||
if (/^\@begin/ && !$inside) {
|
||||
if (!$inside && /^\@begin/) {
|
||||
if (/^\@begin\s*([:_\w]+)\s*\d*\s*$/) {
|
||||
$inside = 1;
|
||||
$name = $1;
|
||||
} else {
|
||||
print STDERR "WARNING: \@begin without table name, skipping $_\n";
|
||||
}
|
||||
} elsif (/^\@end\s*$/ && $inside) {
|
||||
} elsif ($inside && /^\@end\s*$/) {
|
||||
output();
|
||||
|
||||
@keys = ();
|
||||
@@ -74,12 +74,14 @@ while (<IN>) {
|
||||
$includeBuiltin = 0;
|
||||
|
||||
$inside = 0;
|
||||
} elsif (/^(\S+)\s*(\S+)\s*([\w\|]*)\s*(\w*)\s*(\w*)\s*$/ && $inside) {
|
||||
} elsif ($inside && /^(\S+)\s*(\S+)\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*$/) {
|
||||
my $key = $1;
|
||||
my $val = $2;
|
||||
my $att = $3;
|
||||
my $param = $4;
|
||||
my $intrinsic = $5;
|
||||
# Adds support for marking entries as conditional, e.g. "#if USE(BUN_JSC_ADDITIONS)"
|
||||
my $if = $6;
|
||||
|
||||
push(@keys, $key);
|
||||
push(@attrs, length($att) > 0 ? $att : "None");
|
||||
@@ -89,31 +91,34 @@ while (<IN>) {
|
||||
}
|
||||
|
||||
if ($att =~ m/Function/) {
|
||||
push(@values, { "type" => "PropertyAttribute::Function", "function" => $val, "params" => (length($param) ? $param : ""), "intrinsic" => (length($intrinsic) ? $intrinsic : "NoIntrinsic") });
|
||||
push(@values, { "type" => "PropertyAttribute::Function", "function" => $val, "params" => (length($param) ? $param : ""), "intrinsic" => length($intrinsic) ? $intrinsic : "NoIntrinsic", "if" => $if });
|
||||
#printf STDERR "WARNING: Number of arguments missing for $key/$val\n" if (length($param) == 0);
|
||||
} elsif ($att =~ m/CellProperty/) {
|
||||
my $property = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::CellProperty", "property" => $property });
|
||||
} elsif ($att =~ m/ClassStructure/) {
|
||||
my $property = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::ClassStructure", "property" => $property });
|
||||
} elsif ($att =~ m/PropertyCallback/) {
|
||||
my $cback = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::PropertyCallback", "cback" => $cback });
|
||||
} elsif (length($att)) {
|
||||
my $get = $val;
|
||||
my $put = "0";
|
||||
my $type = "PropertyAttribute::Property";
|
||||
if ($att =~ m/Builtin/) {
|
||||
$type = "PropertyAttribute::BuiltinAccessor";
|
||||
}
|
||||
if (!($att =~ m/ReadOnly/)) {
|
||||
$put = "set" . jsc_ucfirst($val);
|
||||
}
|
||||
$hasSetter = "true";
|
||||
push(@values, { "type" => $type, "get" => $get, "put" => $put });
|
||||
} else {
|
||||
push(@values, { "type" => "Lexer", "value" => $val });
|
||||
$if = $intrinsic;
|
||||
if ($att =~ m/CellProperty/) {
|
||||
my $property = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::CellProperty", "property" => $property, "if" => (length($if) ? $if : "") });
|
||||
} elsif ($att =~ m/ClassStructure/) {
|
||||
my $property = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::ClassStructure", "property" => $property, "if" => (length($if) ? $if : "") });
|
||||
} elsif ($att =~ m/PropertyCallback/) {
|
||||
my $cback = $val;
|
||||
push(@values, { "type" => "PropertyAttribute::PropertyCallback", "cback" => $cback, "if" => (length($if) ? $if : "") });
|
||||
} elsif (length($att)) {
|
||||
my $get = $val;
|
||||
my $put = "0";
|
||||
my $type = "PropertyAttribute::Property";
|
||||
if ($att =~ m/Builtin/) {
|
||||
$type = "PropertyAttribute::BuiltinAccessor";
|
||||
}
|
||||
if (!($att =~ m/ReadOnly/)) {
|
||||
$put = "set" . jsc_ucfirst($val);
|
||||
}
|
||||
$hasSetter = "true";
|
||||
push(@values, { "type" => $type, "get" => $get, "put" => $put, "if" => (length($if) ? $if : "") });
|
||||
} else {
|
||||
push(@values, { "type" => "Lexer", "value" => $val, "if" => (length($if) ? $if : "") });
|
||||
}
|
||||
}
|
||||
} elsif ($inside) {
|
||||
die "invalid data {" . $_ . "}";
|
||||
@@ -137,10 +142,10 @@ sub jsc_ucfirst($)
|
||||
|
||||
sub ceilingToPowerOf2
|
||||
{
|
||||
my ($pefectHashSize) = @_;
|
||||
my ($perfectHashSize) = @_;
|
||||
|
||||
my $powerOf2 = 1;
|
||||
while ($pefectHashSize > $powerOf2) {
|
||||
while ($perfectHashSize > $powerOf2) {
|
||||
$powerOf2 <<= 1;
|
||||
}
|
||||
|
||||
@@ -151,10 +156,10 @@ sub calcPerfectHashSize($)
|
||||
{
|
||||
my ($isMac) = @_;
|
||||
tableSizeLoop:
|
||||
for ($pefectHashSize = ceilingToPowerOf2(scalar @keys); ; $pefectHashSize += $pefectHashSize) {
|
||||
for ($perfectHashSize = ceilingToPowerOf2(scalar @keys); ; $perfectHashSize += $perfectHashSize) {
|
||||
my @table = ();
|
||||
foreach my $key (@keys) {
|
||||
my $h = hashValue($key, $isMac) % $pefectHashSize;
|
||||
my $h = hashValue($key, $isMac) % $perfectHashSize;
|
||||
next tableSizeLoop if $table[$h];
|
||||
$table[$h] = 1;
|
||||
}
|
||||
@@ -474,7 +479,12 @@ sub output() {
|
||||
my $secondValue = "";
|
||||
my $hasSecondValue = 1;
|
||||
my $intrinsic = "NoIntrinsic";
|
||||
my $if = $values[$i]{"if"};
|
||||
|
||||
if ($if ne "") {
|
||||
# Adds support for marking entries as conditional, e.g. "#if USE(BUN_JSC_ADDITIONS)"
|
||||
$hashTableString .= "$if\n";
|
||||
}
|
||||
if ($values[$i]{"type"} eq "PropertyAttribute::Function") {
|
||||
$typeTag = "NativeFunction";
|
||||
$firstValue = $values[$i]{"function"};
|
||||
@@ -515,6 +525,10 @@ sub output() {
|
||||
else {
|
||||
$hashTableString .= " { \"$key\"_s, $attributes, $intrinsic, { HashTableValue::" . $typeTag . "Type, $firstValue" . ($hasSecondValue ? ", " . $secondValue : "") . " } },\n";
|
||||
}
|
||||
if ($if ne "") {
|
||||
# Closes the conditional block, e.g. "#if USE(BUN_JSC_ADDITIONS)"
|
||||
$hashTableString .= "#endif\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$hashTableString .= "};\n";
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// @ts-nocheck
|
||||
import path from "path";
|
||||
import type { Field, ClassDefinition } from "./class-definitions";
|
||||
import { writeIfNotChanged } from "./helpers";
|
||||
import { writeIfChanged } from "./helpers";
|
||||
import { camelCase, pascalCase } from "change-case";
|
||||
|
||||
const files = process.argv.slice(2);
|
||||
@@ -2039,7 +2039,7 @@ function writeCppSerializers() {
|
||||
return output;
|
||||
}
|
||||
|
||||
await writeIfNotChanged(`${outBase}/ZigGeneratedClasses.zig`, [
|
||||
await writeIfChanged(`${outBase}/ZigGeneratedClasses.zig`, [
|
||||
ZIG_GENERATED_CLASSES_HEADER,
|
||||
|
||||
...classes.map(a => generateZig(a.name, a).trim()).join("\n"),
|
||||
@@ -2053,35 +2053,35 @@ comptime {
|
||||
]);
|
||||
if (!process.env.ONLY_ZIG) {
|
||||
const allHeaders = classes.map(a => generateHeader(a.name, a));
|
||||
await writeIfNotChanged(`${outBase}/ZigGeneratedClasses.h`, [
|
||||
await writeIfChanged(`${outBase}/ZigGeneratedClasses.h`, [
|
||||
GENERATED_CLASSES_HEADER[0],
|
||||
...[...new Set(extraIncludes.map(a => `#include "${a}";` + "\n"))],
|
||||
GENERATED_CLASSES_HEADER[1],
|
||||
...allHeaders,
|
||||
GENERATED_CLASSES_FOOTER,
|
||||
]);
|
||||
await writeIfNotChanged(`${outBase}/ZigGeneratedClasses.cpp`, [
|
||||
await writeIfChanged(`${outBase}/ZigGeneratedClasses.cpp`, [
|
||||
GENERATED_CLASSES_IMPL_HEADER,
|
||||
...classes.map(a => generateImpl(a.name, a)),
|
||||
writeCppSerializers(classes),
|
||||
GENERATED_CLASSES_IMPL_FOOTER,
|
||||
]);
|
||||
await writeIfNotChanged(
|
||||
await writeIfChanged(
|
||||
`${outBase}/ZigGeneratedClasses+lazyStructureHeader.h`,
|
||||
classes.map(a => generateLazyClassStructureHeader(a.name, a)).join("\n"),
|
||||
);
|
||||
|
||||
await writeIfNotChanged(
|
||||
await writeIfChanged(
|
||||
`${outBase}/ZigGeneratedClasses+DOMClientIsoSubspaces.h`,
|
||||
classes.map(a => [`std::unique_ptr<GCClient::IsoSubspace> ${clientSubspaceFor(a.name)};`].join("\n")),
|
||||
);
|
||||
|
||||
await writeIfNotChanged(
|
||||
await writeIfChanged(
|
||||
`${outBase}/ZigGeneratedClasses+DOMIsoSubspaces.h`,
|
||||
classes.map(a => [`std::unique_ptr<IsoSubspace> ${subspaceFor(a.name)};`].join("\n")),
|
||||
);
|
||||
|
||||
await writeIfNotChanged(
|
||||
await writeIfChanged(
|
||||
`${outBase}/ZigGeneratedClasses+lazyStructureImpl.h`,
|
||||
initLazyClasses(classes.map(a => generateLazyClassStructureImpl(a.name, a))) + "\n" + visitLazyClasses(classes),
|
||||
);
|
||||
|
||||
@@ -1,60 +1,19 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { isAscii } from "buffer";
|
||||
import { isAscii } from "node:buffer";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
// MSVC has a max of 16k characters per string literal
|
||||
// Combining string literals didn't support constexpr apparently
|
||||
// so we have to do this the gigantic array way
|
||||
export function fmtCPPCharArray(str: string, nullTerminated: boolean = true) {
|
||||
const normalized = str + "\n";
|
||||
const EOL = "\n";
|
||||
const EOL_CHAR_CODE = EOL.charCodeAt(0);
|
||||
const scriptExtRegExp = /\.[mc]?[tj]s$/;
|
||||
|
||||
var remain = normalized;
|
||||
export const matchAllNonIdentCharsRegExp = /[^\$\w]+/g;
|
||||
|
||||
const chars =
|
||||
"{" +
|
||||
remain
|
||||
.split("")
|
||||
.map(a => a.charCodeAt(0))
|
||||
.join(",") +
|
||||
(nullTerminated ? ",0" : "") +
|
||||
"}";
|
||||
return [chars, normalized.length + (nullTerminated ? 1 : 0)];
|
||||
}
|
||||
|
||||
export function declareASCIILiteral(name: string, value: string) {
|
||||
const [chars, count] = fmtCPPCharArray(value);
|
||||
return `static constexpr const char ${name}Bytes[${count}] = ${chars};
|
||||
static constexpr ASCIILiteral ${name} = ASCIILiteral::fromLiteralUnsafe(${name}Bytes);`;
|
||||
}
|
||||
export const alphanumComparator = new Intl.Collator("en", { numeric: true }).compare;
|
||||
|
||||
export function cap(str: string) {
|
||||
return str[0].toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export function low(str: string) {
|
||||
if (str.startsWith("JS")) {
|
||||
return "js" + str.slice(2);
|
||||
}
|
||||
|
||||
return str[0].toLowerCase() + str.slice(1);
|
||||
}
|
||||
|
||||
export function readdirRecursive(root: string): string[] {
|
||||
const files = fs.readdirSync(root, { withFileTypes: true });
|
||||
return files.flatMap(file => {
|
||||
const fullPath = path.join(root, file.name);
|
||||
return file.isDirectory() ? readdirRecursive(fullPath) : fullPath;
|
||||
});
|
||||
}
|
||||
|
||||
export function resolveSyncOrNull(specifier: string, from: string) {
|
||||
try {
|
||||
return Bun.resolveSync(specifier, from);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function checkAscii(str: string) {
|
||||
if (!isAscii(Buffer.from(str))) {
|
||||
throw new Error(`non-ascii character in string "${str}". this will not be a valid ASCIILiteral`);
|
||||
@@ -63,22 +22,81 @@ export function checkAscii(str: string) {
|
||||
return str;
|
||||
}
|
||||
|
||||
export function writeIfNotChanged(file: string, contents: string) {
|
||||
if (Array.isArray(contents)) contents = contents.join("");
|
||||
export function declareASCIILiteral(name: string, value: string) {
|
||||
const { 0: chars, 1: count } = fmtCPPCharArray(value);
|
||||
return `static constexpr const char ${name}Bytes[${count}] = ${chars};
|
||||
static constexpr ASCIILiteral ${name} = ASCIILiteral::fromLiteralUnsafe(${name}Bytes);`;
|
||||
}
|
||||
|
||||
if (fs.existsSync(file)) {
|
||||
const oldContents = fs.readFileSync(file, "utf8");
|
||||
if (oldContents === contents) {
|
||||
return;
|
||||
}
|
||||
// MSVC has a max of 16k characters per string literal
|
||||
// Combining string literals didn't support constexpr apparently
|
||||
// so we have to do this the gigantic array way
|
||||
export function fmtCPPCharArray(str: string, nullTerminated: boolean = true) {
|
||||
const { length } = str;
|
||||
let chars = "{";
|
||||
for (let i = 0; i < length; i += 1) {
|
||||
chars += `${str.charCodeAt(i)},`;
|
||||
}
|
||||
chars += `${EOL_CHAR_CODE}${nullTerminated ? ",0" : ""}}`;
|
||||
return [chars, length + 1 + (nullTerminated ? 1 : 0)];
|
||||
}
|
||||
|
||||
try {
|
||||
fs.writeFileSync(file, contents);
|
||||
} catch (error) {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file, contents);
|
||||
export function hasJsExt(str: string) {
|
||||
return str.endsWith(".js");
|
||||
}
|
||||
|
||||
export function hasTsExt(str: string) {
|
||||
return str.endsWith(".ts") && !str.endsWith(".d.ts");
|
||||
}
|
||||
|
||||
const upperCaseIds = new Set(["jsc", "ffi", "vm", "tls", "os", "ws", "fs", "dns"]);
|
||||
|
||||
export function idToEnumName(id: string) {
|
||||
const trimmed = trimScriptExt(id);
|
||||
// We don't match \w because we want to remove _ too.
|
||||
const parts = trimmed.match(/[a-zA-Z0-9]+/g);
|
||||
if (!parts) {
|
||||
throw new Error(`Invalid id ${id}`);
|
||||
}
|
||||
let enumName = "";
|
||||
for (let i = 0, { length } = parts; i < length; i += 1) {
|
||||
enumName += upperCaseIds.has(parts[i]) ? parts[i].toUpperCase() : cap(parts[i]);
|
||||
}
|
||||
return enumName;
|
||||
}
|
||||
|
||||
export function idToPublicSpecifierOrEnumName(id: string) {
|
||||
id = trimScriptExt(id);
|
||||
if (id.startsWith("node/")) {
|
||||
return "node:" + id.slice(5).replaceAll(".", "/");
|
||||
} else if (id.startsWith("bun/")) {
|
||||
return "bun:" + id.slice(4).replaceAll(".", "/");
|
||||
} else if (id.startsWith("internal/")) {
|
||||
return "internal:" + id.slice(9).replaceAll(".", "/");
|
||||
} else if (id.startsWith("thirdparty/")) {
|
||||
return id.slice(11).replaceAll(".", "/");
|
||||
}
|
||||
return idToEnumName(id);
|
||||
}
|
||||
|
||||
export function low(str: string) {
|
||||
return str.startsWith("JS") ? `js${str.slice(2)}` : `${str[0].toLowerCase()}${str.slice(1)}`;
|
||||
}
|
||||
|
||||
export function pathToUpperSnakeCase(filepath: string) {
|
||||
return filepath
|
||||
.replace(/^[^:]+:/, "")
|
||||
.split(/[-_./\\]/g)
|
||||
.join("_")
|
||||
.toUpperCase();
|
||||
}
|
||||
|
||||
export function readdirRecursive(root: string): string[] {
|
||||
const files = fs.readdirSync(root, { withFileTypes: true });
|
||||
return files.flatMap(file => {
|
||||
const fullPath = path.join(root, file.name);
|
||||
return file.isDirectory() ? readdirRecursive(fullPath) : fullPath;
|
||||
});
|
||||
}
|
||||
|
||||
export function readdirRecursiveWithExclusionsAndExtensionsSync(
|
||||
@@ -98,10 +116,34 @@ export function readdirRecursiveWithExclusionsAndExtensionsSync(
|
||||
});
|
||||
}
|
||||
|
||||
export function pathToUpperSnakeCase(filepath: string) {
|
||||
return filepath
|
||||
.replace(/^.*?:/, "")
|
||||
.split(/[-_./\\]/g)
|
||||
.join("_")
|
||||
.toUpperCase();
|
||||
export function replaceScriptExtWithDotJS(str: string) {
|
||||
return str.replace(scriptExtRegExp, ".js");
|
||||
}
|
||||
|
||||
export function resolveSyncOrNull(specifier: string, from: string) {
|
||||
try {
|
||||
return Bun.resolveSync(specifier, from);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export function trimScriptExt(str: string) {
|
||||
return str.replace(scriptExtRegExp, "");
|
||||
}
|
||||
|
||||
export function writeIfChanged(file: string, content: string | string[]) {
|
||||
const contentAsString = Array.isArray(content) ? content.join("") : content;
|
||||
if (fs.existsSync(file) && fs.readFileSync(file, "utf8") === contentAsString) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
fs.writeFileSync(file, contentAsString);
|
||||
} catch {
|
||||
fs.mkdirSync(path.dirname(file), { recursive: true });
|
||||
fs.writeFileSync(file, contentAsString);
|
||||
}
|
||||
}
|
||||
|
||||
export const writeIfNotChanged = writeIfChanged;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { readdirRecursive, resolveSyncOrNull } from "./helpers";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { alphanumComparator, hasJsExt, hasTsExt, readdirRecursive, resolveSyncOrNull } from "./helpers";
|
||||
|
||||
export function createInternalModuleRegistry(basedir: string) {
|
||||
const sliceStart = basedir.length + 1;
|
||||
const moduleList = ["bun", "node", "thirdparty", "internal"]
|
||||
.flatMap(dir => readdirRecursive(path.join(basedir, dir)))
|
||||
.filter(file => file.endsWith(".js") || (file.endsWith(".ts") && !file.endsWith(".d.ts")))
|
||||
.map(file => file.slice(basedir.length + 1))
|
||||
.map(x => x.replaceAll("\\", "/"))
|
||||
.sort();
|
||||
.filter(filePath => hasJsExt(filePath) || hasTsExt(filePath))
|
||||
.map(filePath => filePath.slice(sliceStart).replaceAll("\\", "/"))
|
||||
.sort(alphanumComparator);
|
||||
|
||||
// Create the Internal Module Registry
|
||||
const internalRegistry = new Map();
|
||||
@@ -31,7 +31,7 @@ export function createInternalModuleRegistry(basedir: string) {
|
||||
|
||||
// Native Module registry
|
||||
const nativeModuleH = fs.readFileSync(path.join(basedir, "../bun.js/modules/_NativeModule.h"), "utf8");
|
||||
const nativeModuleDefine = nativeModuleH.match(/BUN_FOREACH_NATIVE_MODULE\(macro\)\s*\\\n((.*\\\n)*\n)/);
|
||||
const nativeModuleDefine = nativeModuleH.match(/BUN_FOREACH_NATIVE_MODULE\(macro\)\s*\\\r?\n((.*\\\r?\n)*\r?\n)/);
|
||||
if (!nativeModuleDefine) {
|
||||
throw new Error(
|
||||
"Could not find BUN_FOREACH_NATIVE_MODULE in _NativeModule.h. Knowing native module IDs is a part of the codegen process.",
|
||||
@@ -41,8 +41,8 @@ export function createInternalModuleRegistry(basedir: string) {
|
||||
const nativeModuleIds: Record<string, number> = {};
|
||||
const nativeModuleEnums: Record<string, string> = {};
|
||||
const nativeModuleEnumToId: Record<string, number> = {};
|
||||
for (const [_, idString, enumValue] of nativeModuleDefine[0].matchAll(/macro\((.*?),(.*?)\)/g)) {
|
||||
const processedIdString = JSON.parse(idString.trim().replace(/_s$/, ""));
|
||||
for (const { 1: idString, 2: enumValue } of nativeModuleDefine[0].matchAll(/macro\(([^)]+),([^)]+)\)/g)) {
|
||||
const processedIdString = idString.trim().replace(/_s$/, "").slice(1, -1);
|
||||
const processedEnumValue = enumValue.trim();
|
||||
const processedNumericId = nextNativeModuleId++;
|
||||
nativeModuleIds[processedIdString] = processedNumericId;
|
||||
@@ -55,15 +55,16 @@ export function createInternalModuleRegistry(basedir: string) {
|
||||
}
|
||||
|
||||
function codegenRequireNativeModule(id: string) {
|
||||
return `(__intrinsic__requireNativeModule(${id.replace(/node:/, "")}))`;
|
||||
return `(__intrinsic__requireNativeModule(${JSON.stringify(id.replace(/^node:/, ""))}))`;
|
||||
}
|
||||
|
||||
const requireTransformer = (specifier: string, from: string) => {
|
||||
const directMatch = internalRegistry.get(specifier);
|
||||
if (directMatch) return codegenRequireId(`${directMatch}/*${specifier}*/`);
|
||||
|
||||
if (directMatch) {
|
||||
return codegenRequireId(`${directMatch}/*${specifier}*/`);
|
||||
}
|
||||
if (specifier in nativeModuleIds) {
|
||||
return codegenRequireNativeModule(JSON.stringify(specifier));
|
||||
return codegenRequireNativeModule(specifier);
|
||||
}
|
||||
|
||||
const relativeMatch =
|
||||
|
||||
@@ -2,63 +2,137 @@ import { LoaderKeys } from "../api/schema";
|
||||
import { sliceSourceCode } from "./builtin-parser";
|
||||
import { registerNativeCall } from "./js2native-generator";
|
||||
|
||||
// This is a list of extra syntax replacements to do. Kind of like macros
|
||||
// These are only run on code itself, not string contents or comments.
|
||||
export const replacements: ReplacementRule[] = [
|
||||
{ from: /\bthrow new TypeError\b/g, to: "$throwTypeError" },
|
||||
{ from: /\bthrow new RangeError\b/g, to: "$throwRangeError" },
|
||||
{ from: /\bthrow new OutOfMemoryError\b/g, to: "$throwOutOfMemoryError" },
|
||||
{ from: /\bnew TypeError\b/g, to: "$makeTypeError" },
|
||||
{ from: /\bexport\s*default/g, to: "$exports =" },
|
||||
];
|
||||
|
||||
// These rules are run on the entire file, including within strings.
|
||||
export const globalReplacements: ReplacementRule[] = [
|
||||
{
|
||||
from: /\bnotImplementedIssue\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g,
|
||||
to: "new TypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)",
|
||||
},
|
||||
{
|
||||
from: /\bnotImplementedIssueFn\(\s*([0-9]+)\s*,\s*((?:"[^"]*"|'[^']+'))\s*\)/g,
|
||||
to: "() => $throwTypeError(`${$2} is not implemented yet. See https://github.com/oven-sh/bun/issues/$1`)",
|
||||
},
|
||||
];
|
||||
|
||||
// This is a list of globals we should access using @ notation
|
||||
// This is a list of globals we should access using @ notation.
|
||||
// This prevents a global override attacks.
|
||||
// Note that the public `Bun` global is immutable.
|
||||
// undefined -> __intrinsic__undefined -> @undefined
|
||||
export const globalsToPrefix = [
|
||||
"console",
|
||||
"decodeURI",
|
||||
"decodeURIComponent",
|
||||
"encodeURI",
|
||||
"encodeURIComponent",
|
||||
"escape",
|
||||
"eval",
|
||||
"globalThis",
|
||||
"isFinite",
|
||||
"isNaN",
|
||||
"parseFloat",
|
||||
"parseInt",
|
||||
"undefined",
|
||||
"unescape",
|
||||
"AbortSignal",
|
||||
"Array",
|
||||
"ArrayBuffer",
|
||||
"Atomics",
|
||||
"BigInt",
|
||||
"BigInt64Array",
|
||||
"BigUint64Array",
|
||||
"Boolean",
|
||||
"Buffer",
|
||||
"DataView",
|
||||
"Date",
|
||||
"Error",
|
||||
"EvalError",
|
||||
"FinalizationRegistry",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
"Function",
|
||||
"Infinity",
|
||||
"Int8Array",
|
||||
"Int16Array",
|
||||
"Int32Array",
|
||||
"Intl",
|
||||
"JSON",
|
||||
"Loader",
|
||||
"Math",
|
||||
"Promise",
|
||||
"Proxy",
|
||||
"RangeError",
|
||||
"ReferenceError",
|
||||
"Reflect",
|
||||
"ReadableByteStreamController",
|
||||
"ReadableStream",
|
||||
"ReadableStreamBYOBReader",
|
||||
"ReadableStreamBYOBRequest",
|
||||
"ReadableStreamDefaultController",
|
||||
"ReadableStreamDefaultReader",
|
||||
"RegExp",
|
||||
"String",
|
||||
"SuppressedError",
|
||||
"Symbol",
|
||||
"SyntaxError",
|
||||
"TransformStream",
|
||||
"TransformStreamDefaultController",
|
||||
"TypeError",
|
||||
"Uint8Array",
|
||||
"String",
|
||||
"Buffer",
|
||||
"RegExp",
|
||||
"URIError",
|
||||
"WeakMap",
|
||||
"WeakRef",
|
||||
"WeakSet",
|
||||
"WritableStream",
|
||||
"WritableStreamDefaultController",
|
||||
"WritableStreamDefaultWriter",
|
||||
"isFinite",
|
||||
"undefined",
|
||||
];
|
||||
|
||||
replacements.push({
|
||||
from: new RegExp(`\\bextends\\s+(${globalsToPrefix.join("|")})`, "g"),
|
||||
to: "extends __no_intrinsic__%1",
|
||||
});
|
||||
// This is a list of symbol we should access using @ notation.
|
||||
// Transforms: Array.prototype.$$iterator -> Array.prototype.__intrinsic_$iterator -> Array.prototype.@$iterator
|
||||
// to enable accessing a snapshot of the symbol property value.
|
||||
// AND
|
||||
// Transforms: Array.prototype[$$iterator] -> Array.prototype.__intrinsic___intrinsic_iterator -> Array.prototype.@@iterator
|
||||
// to enable accessing the live symbol property value.
|
||||
const symbolPropsToPrefix = Reflect.ownKeys(Symbol).filter(k => typeof Symbol[k] === "symbol") as string[];
|
||||
|
||||
function escapeDoubleQuotes(str: string) {
|
||||
return str.replace(/\\?"/g, '\\"');
|
||||
}
|
||||
|
||||
function replaceDollarSignWithIntrinsic(str: string) {
|
||||
return str.replaceAll("$", "__intrinsic__");
|
||||
}
|
||||
|
||||
function replacePercentSignWithDollar(str: string) {
|
||||
return str.replaceAll("%", "$");
|
||||
}
|
||||
|
||||
function toReplacer(replacement: string | Replacer) {
|
||||
return typeof replacement === "function"
|
||||
? (substring: string, ...args: string[]) => replaceDollarSignWithIntrinsic(replacement(substring, ...args))
|
||||
: replacePercentSignWithDollar(replaceDollarSignWithIntrinsic(replacement));
|
||||
}
|
||||
|
||||
// These rules are run on the entire file, including within strings.
|
||||
export const globalReplacements: ReplacementRule[] = [
|
||||
{
|
||||
// https://blog.stevenlevithan.com/archives/match-quoted-string
|
||||
from: /\bnotImplementedIssueFn\(\s*(\d+)\s*,\s*"((?:(?!")[^\n\\]|\\.)*)"\s*\)/g,
|
||||
to: (_match, issueNumber, description) =>
|
||||
replaceDollarSignWithIntrinsic(
|
||||
`() => $throwTypeError("${escapeDoubleQuotes(description)} is not implemented yet. See https://github.com/oven-sh/bun/issues/${issueNumber}")`,
|
||||
),
|
||||
},
|
||||
];
|
||||
for (const replacement of globalReplacements) {
|
||||
replacement.to = toReplacer(replacement.to);
|
||||
}
|
||||
|
||||
// This is a list of extra syntax replacements to do. Kind of like macros
|
||||
// These are only run on code itself, not string contents or comments.
|
||||
export const replacements: ReplacementRule[] = [
|
||||
{ from: /\bnew Array\([$\w]+\)/g, to: "$newArrayWithSize($1)" },
|
||||
{ from: /\bthrow new TypeError\b/g, to: "$throwTypeError" },
|
||||
{ from: /\bthrow new RangeError\b/g, to: "$throwRangeError" },
|
||||
{ from: /\bthrow new OutOfMemoryError\b/g, to: "$throwOutOfMemoryError" },
|
||||
{ from: /\bnew TypeError\b/g, to: "$makeTypeError" },
|
||||
{ from: /\bexport\s*default/g, to: "$exports =" },
|
||||
{
|
||||
from: new RegExp(`\\bextends\\s+(${globalsToPrefix.join("|")})`, "g"),
|
||||
to: "extends __no_intrinsic__%1",
|
||||
},
|
||||
];
|
||||
for (const replacement of replacements) {
|
||||
replacement.to = toReplacer(replacement.to);
|
||||
}
|
||||
|
||||
// These enums map to $<enum>IdToLabel and $<enum>LabelToId
|
||||
// Make sure to define in ./builtins.d.ts
|
||||
@@ -82,52 +156,58 @@ export const enums = {
|
||||
export const warnOnIdentifiersNotPresentAtRuntime = [
|
||||
//
|
||||
"OutOfMemoryError",
|
||||
"notImplementedIssue",
|
||||
"notImplementedIssueFn",
|
||||
];
|
||||
|
||||
// These are passed to --define to the bundler
|
||||
const debug = process.argv[2] === "--debug=ON";
|
||||
export const define: Record<string, string> = {
|
||||
"process.env.NODE_ENV": JSON.stringify(debug ? "development" : "production"),
|
||||
"IS_BUN_DEVELOPMENT": String(debug),
|
||||
|
||||
IS_BUN_DEVELOPMENT: String(debug),
|
||||
$streamClosed: "1",
|
||||
$streamClosing: "2",
|
||||
$streamErrored: "3",
|
||||
$streamReadable: "4",
|
||||
$streamWaiting: "5",
|
||||
$streamWritable: "6",
|
||||
|
||||
"process.platform": JSON.stringify(Bun.env.TARGET_PLATFORM ?? process.platform),
|
||||
"process.arch": JSON.stringify(Bun.env.TARGET_ARCH ?? process.arch),
|
||||
"process.env.NODE_ENV": JSON.stringify(debug ? "development" : "production"),
|
||||
"process.platform": JSON.stringify(Bun.env.TARGET_PLATFORM ?? process.platform),
|
||||
};
|
||||
|
||||
// ------------------------------ //
|
||||
|
||||
for (const name in enums) {
|
||||
const value = enums[name];
|
||||
if (typeof value !== "object") throw new Error("Invalid enum object " + name + " defined in " + import.meta.file);
|
||||
if (typeof value === null) throw new Error("Invalid enum object " + name + " defined in " + import.meta.file);
|
||||
const keys = Array.isArray(value) ? value : Object.keys(value).filter(k => !k.match(/^[0-9]+$/));
|
||||
define[`$${name}IdToLabel`] = "[" + keys.map(k => `"${k}"`).join(", ") + "]";
|
||||
define[`$${name}LabelToId`] = "{" + keys.map(k => `"${k}": ${keys.indexOf(k)}`).join(", ") + "}";
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`Invalid enum object ${name} defined in ${import.meta.file}`);
|
||||
}
|
||||
const keys = Array.isArray(value) ? value : Object.keys(value).filter(k => !/^\d+$/.test(k));
|
||||
const idToLabel = `$${name}IdToLabel`;
|
||||
const labelToId = `$${name}LabelToId`;
|
||||
if (keys.length) {
|
||||
define[idToLabel] = `["${keys.join('", "')}"]`;
|
||||
define[labelToId] = `{${keys.map((k, i) => `"${k}": ${i}`).join(", ")}}`;
|
||||
} else {
|
||||
define[idToLabel] = "[]";
|
||||
define[labelToId] = "{}";
|
||||
}
|
||||
}
|
||||
|
||||
for (const name of globalsToPrefix) {
|
||||
define[name] = "__intrinsic__" + name;
|
||||
define[name] = `__intrinsic__${name}`;
|
||||
}
|
||||
|
||||
for (const key in define) {
|
||||
if (key.startsWith("$")) {
|
||||
define["__intrinsic__" + key.slice(1)] = define[key];
|
||||
define[`__intrinsic__${key.slice(1)}`] = define[key];
|
||||
delete define[key];
|
||||
}
|
||||
}
|
||||
|
||||
type Replacer = (substring: string, ...args: any[]) => string;
|
||||
export interface ReplacementRule {
|
||||
from: RegExp;
|
||||
to: string;
|
||||
to: string | Replacer;
|
||||
global?: boolean;
|
||||
}
|
||||
|
||||
@@ -136,11 +216,20 @@ export const function_replacements = ["$debug", "$assert", "$zig", "$newZigFunct
|
||||
/** Applies source code replacements as defined in `replacements` */
|
||||
export function applyReplacements(src: string, length: number) {
|
||||
let slice = src.slice(0, length);
|
||||
let rest = src.slice(length);
|
||||
slice = slice.replace(/([^a-zA-Z0-9_\$])\$([a-zA-Z0-9_]+\b)/gm, `$1__intrinsic__$2`);
|
||||
for (const replacement of replacements) {
|
||||
slice = slice.replace(replacement.from, replacement.to.replaceAll("$", "__intrinsic__").replaceAll("%", "$"));
|
||||
// Replace symbol @@ names first.
|
||||
for (const name of symbolPropsToPrefix) {
|
||||
// First replace live symbol property references.
|
||||
slice = slice.replace(new RegExp(`.\\[\\$\\$${name}\\]`, "g"), m =>
|
||||
/[$\w]/.test(m[0]) ? `.__intrinsic____intrinsic__${name}` : `${m[0]}[__intrinsic____intrinsic__${name}]`,
|
||||
);
|
||||
// Then replace snapshot symbol property references.
|
||||
slice = slice.replaceAll(`$$${name}`, `__intrinsic__$${name}`);
|
||||
}
|
||||
slice = slice.replace(/([^\$\w])\$(\w+\b)/gm, "$1__intrinsic__$2");
|
||||
for (const replacement of replacements) {
|
||||
slice = slice.replace(replacement.from, replacement.to as Replacer);
|
||||
}
|
||||
let rest = src.slice(length);
|
||||
let match;
|
||||
if (
|
||||
(match = slice.match(/__intrinsic__(debug|assert|zig|cpp|newZigFunction|newCppFunction)$/)) &&
|
||||
@@ -150,32 +239,24 @@ export function applyReplacements(src: string, length: number) {
|
||||
if (name === "debug") {
|
||||
const innerSlice = sliceSourceCode(rest, true);
|
||||
return [
|
||||
slice.slice(0, match.index) + "(IS_BUN_DEVELOPMENT?$debug_log" + innerSlice.result + ":void 0)",
|
||||
`${slice.slice(0, match.index)}(IS_BUN_DEVELOPMENT?$debug_log${innerSlice.result}:void 0)`,
|
||||
innerSlice.rest,
|
||||
true,
|
||||
];
|
||||
} else if (name === "assert") {
|
||||
}
|
||||
if (name === "assert") {
|
||||
const checkSlice = sliceSourceCode(rest, true, undefined, true);
|
||||
let rest2 = checkSlice.rest;
|
||||
let { rest: rest2 } = checkSlice;
|
||||
let extraArgs = "";
|
||||
if (checkSlice.result.at(-1) === ",") {
|
||||
const sliced = sliceSourceCode("(" + rest2.slice(1), true, undefined, false);
|
||||
extraArgs = ", " + sliced.result.slice(1, -1);
|
||||
const sliced = sliceSourceCode(`(${rest2.slice(1)}`, true, undefined, false);
|
||||
extraArgs = `, ${sliced.result.slice(1, -1)}`;
|
||||
rest2 = sliced.rest;
|
||||
}
|
||||
return [
|
||||
slice.slice(0, match.index) +
|
||||
"(IS_BUN_DEVELOPMENT?$assert(" +
|
||||
checkSlice.result.slice(1, -1) +
|
||||
"," +
|
||||
JSON.stringify(
|
||||
checkSlice.result
|
||||
.slice(1, -1)
|
||||
.replace(/__intrinsic__/g, "$")
|
||||
.trim(),
|
||||
) +
|
||||
extraArgs +
|
||||
"):void 0)",
|
||||
`${slice.slice(0, match.index)}(IS_BUN_DEVELOPMENT?$assert(${checkSlice.result.slice(1, -1)},${JSON.stringify(
|
||||
checkSlice.result.slice(1, -1).replaceAll("__intrinsic__", "$").trim(),
|
||||
)}${extraArgs}):void 0)`,
|
||||
rest2,
|
||||
true,
|
||||
];
|
||||
@@ -222,7 +303,7 @@ export function applyReplacements(src: string, length: number) {
|
||||
export function applyGlobalReplacements(src: string) {
|
||||
let result = src;
|
||||
for (const replacement of globalReplacements) {
|
||||
result = result.replace(replacement.from, replacement.to.replaceAll("$", "__intrinsic__"));
|
||||
result = result.replace(replacement.from, replacement.to as Replacer);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
2
src/js/builtins.d.ts
vendored
2
src/js/builtins.d.ts
vendored
@@ -221,7 +221,7 @@ declare const $processBindingConstants: {
|
||||
crypto: typeof import("crypto").constants;
|
||||
zlib: typeof import("zlib").constants;
|
||||
};
|
||||
declare const $asyncContext: InternalFieldObject<[ReadonlyArray<any> | undefined]>;
|
||||
declare const $asyncContextTuple: InternalFieldObject<[ReadonlyArray<any> | undefined]>;
|
||||
|
||||
// We define our intrinsics in ./BunBuiltinNames.h. Some of those are globals.
|
||||
|
||||
|
||||
@@ -20,6 +20,103 @@ namespace WebCore {
|
||||
using namespace JSC;
|
||||
|
||||
#define BUN_COMMON_PRIVATE_IDENTIFIERS_EACH_PROPERTY_NAME(macro) \
|
||||
/* Buffer */ \
|
||||
macro(alloc) \
|
||||
macro(allocUnsafe) \
|
||||
macro(allocUnsafeSlow) \
|
||||
macro(compare) \
|
||||
macro(copyBytesFrom) \
|
||||
macro(isBuffer) \
|
||||
macro(isEncoding) \
|
||||
macro(poolSize) \
|
||||
/* Buffer.prototype */ \
|
||||
macro(asciiSlice) \
|
||||
macro(asciiWrite) \
|
||||
macro(base64Slice) \
|
||||
macro(base64Write) \
|
||||
macro(base64urlSlice) \
|
||||
macro(base64urlWrite) \
|
||||
macro(copy) \
|
||||
macro(equals) \
|
||||
macro(hexSlice) \
|
||||
macro(hexWrite) \
|
||||
macro(inspect) \
|
||||
macro(lastIndexOf) \
|
||||
macro(latin1Slice) \
|
||||
macro(latin1Write) \
|
||||
macro(offset) \
|
||||
macro(parent) \
|
||||
macro(readBigInt64BE) \
|
||||
macro(readBigInt64LE) \
|
||||
macro(readBigUInt64BE) \
|
||||
macro(readBigUInt64LE) \
|
||||
macro(readBigUint64BE) \
|
||||
macro(readBigUint64LE) \
|
||||
macro(readDoubleBE) \
|
||||
macro(readDoubleLE) \
|
||||
macro(readFloatBE) \
|
||||
macro(readFloatLE) \
|
||||
macro(readInt16BE) \
|
||||
macro(readInt16LE) \
|
||||
macro(readInt32BE) \
|
||||
macro(readInt32LE) \
|
||||
macro(readInt8) \
|
||||
macro(readIntBE) \
|
||||
macro(readIntLE) \
|
||||
macro(readUInt16BE) \
|
||||
macro(readUInt16LE) \
|
||||
macro(readUInt32BE) \
|
||||
macro(readUInt32LE) \
|
||||
macro(readUInt8) \
|
||||
macro(readUIntBE) \
|
||||
macro(readUIntLE) \
|
||||
macro(readUint16BE) \
|
||||
macro(readUint16LE) \
|
||||
macro(readUint32BE) \
|
||||
macro(readUint32LE) \
|
||||
macro(readUint8) \
|
||||
macro(readUintBE) \
|
||||
macro(readUintLE) \
|
||||
macro(swap16) \
|
||||
macro(swap32) \
|
||||
macro(swap64) \
|
||||
macro(ucs2Slice) \
|
||||
macro(ucs2Write) \
|
||||
macro(utf8Slice) \
|
||||
macro(utf8Write) \
|
||||
macro(write) \
|
||||
macro(writeBigInt64BE) \
|
||||
macro(writeBigInt64LE) \
|
||||
macro(writeBigUInt64BE) \
|
||||
macro(writeBigUInt64LE) \
|
||||
macro(writeBigUint64BE) \
|
||||
macro(writeBigUint64LE) \
|
||||
macro(writeDoubleBE) \
|
||||
macro(writeDoubleLE) \
|
||||
macro(writeFloatBE) \
|
||||
macro(writeFloatLE) \
|
||||
macro(writeInt16BE) \
|
||||
macro(writeInt16LE) \
|
||||
macro(writeInt32BE) \
|
||||
macro(writeInt32LE) \
|
||||
macro(writeInt8) \
|
||||
macro(writeIntBE) \
|
||||
macro(writeIntLE) \
|
||||
macro(writeUInt16BE) \
|
||||
macro(writeUInt16LE) \
|
||||
macro(writeUInt32BE) \
|
||||
macro(writeUInt32LE) \
|
||||
macro(writeUInt8) \
|
||||
macro(writeUIntBE) \
|
||||
macro(writeUIntLE) \
|
||||
macro(writeUint16BE) \
|
||||
macro(writeUint16LE) \
|
||||
macro(writeUint32BE) \
|
||||
macro(writeUint32LE) \
|
||||
macro(writeUint8) \
|
||||
macro(writeUintBE) \
|
||||
macro(writeUintLE) \
|
||||
/* Misc */ \
|
||||
macro(__esModule) \
|
||||
macro(_events) \
|
||||
macro(abortAlgorithm) \
|
||||
@@ -239,7 +336,6 @@ using namespace JSC;
|
||||
macro(WritableStream) \
|
||||
macro(WritableStreamDefaultController) \
|
||||
macro(WritableStreamDefaultWriter) \
|
||||
macro(write) \
|
||||
macro(writeAlgorithm) \
|
||||
macro(writer) \
|
||||
macro(writeRequests) \
|
||||
|
||||
@@ -65,10 +65,10 @@ export function getStdinStream(fd) {
|
||||
// but we need to extend TTY/FS ReadStream
|
||||
const native = Bun.stdin.stream();
|
||||
|
||||
var reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
|
||||
var readerRef;
|
||||
let reader: ReadableStreamDefaultReader<Uint8Array> | undefined;
|
||||
let readerRef;
|
||||
|
||||
var shouldUnref = false;
|
||||
let shouldUnref = false;
|
||||
|
||||
function ref() {
|
||||
$debug("ref();", reader ? "already has reader" : "getting reader");
|
||||
@@ -162,7 +162,7 @@ export function getStdinStream(fd) {
|
||||
async function internalRead(stream) {
|
||||
$debug("internalRead();");
|
||||
try {
|
||||
var done: boolean, value: Uint8Array[];
|
||||
let done: boolean, value: Uint8Array[];
|
||||
$assert(reader);
|
||||
const pendingRead = reader.readMany();
|
||||
|
||||
@@ -238,34 +238,30 @@ export function getStdinStream(fd) {
|
||||
}
|
||||
|
||||
export function initializeNextTickQueue(process, nextTickQueue, drainMicrotasksFn, reportUncaughtExceptionFn) {
|
||||
var queue;
|
||||
var process;
|
||||
var nextTickQueue = nextTickQueue;
|
||||
var drainMicrotasks = drainMicrotasksFn;
|
||||
var reportUncaughtException = reportUncaughtExceptionFn;
|
||||
let queue;
|
||||
let drainMicrotasks = drainMicrotasksFn;
|
||||
let reportUncaughtException = reportUncaughtExceptionFn;
|
||||
|
||||
function validateFunction(cb) {
|
||||
const validateFunction = cb => {
|
||||
if (typeof cb !== "function") {
|
||||
const err = new TypeError(`The "callback" argument must be of type "function". Received type ${typeof cb}`);
|
||||
err.code = "ERR_INVALID_ARG_TYPE";
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var setup;
|
||||
let setup;
|
||||
setup = () => {
|
||||
const { FixedQueue } = require("internal/fixed_queue");
|
||||
queue = new FixedQueue();
|
||||
|
||||
function processTicksAndRejections() {
|
||||
var tock;
|
||||
let tock;
|
||||
do {
|
||||
while ((tock = queue.shift()) !== null) {
|
||||
var callback = tock.callback;
|
||||
var args = tock.args;
|
||||
var frame = tock.frame;
|
||||
var restore = $getInternalField($asyncContext, 0);
|
||||
$putInternalField($asyncContext, 0, frame);
|
||||
const { args, callback } = tock;
|
||||
const oldAsyncContextData = $getInternalField($asyncContextTuple, 0);
|
||||
$putInternalField($asyncContextTuple, 0, tock.frame);
|
||||
try {
|
||||
if (args === undefined) {
|
||||
callback();
|
||||
@@ -291,7 +287,7 @@ export function initializeNextTickQueue(process, nextTickQueue, drainMicrotasksF
|
||||
} catch (e) {
|
||||
reportUncaughtException(e);
|
||||
} finally {
|
||||
$putInternalField($asyncContext, 0, restore);
|
||||
$putInternalField($asyncContextTuple, 0, oldAsyncContextData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +301,7 @@ export function initializeNextTickQueue(process, nextTickQueue, drainMicrotasksF
|
||||
setup = undefined;
|
||||
};
|
||||
|
||||
function nextTick(cb, args) {
|
||||
const nextTick = cb => {
|
||||
validateFunction(cb);
|
||||
if (setup) {
|
||||
setup();
|
||||
@@ -316,17 +312,17 @@ export function initializeNextTickQueue(process, nextTickQueue, drainMicrotasksF
|
||||
queue.push({
|
||||
callback: cb,
|
||||
args: $argumentCount() > 1 ? Array.prototype.slice.$call(arguments, 1) : undefined,
|
||||
frame: $getInternalField($asyncContext, 0),
|
||||
frame: $getInternalField($asyncContextTuple, 0),
|
||||
});
|
||||
$putInternalField(nextTickQueue, 0, 1);
|
||||
}
|
||||
};
|
||||
|
||||
return nextTick;
|
||||
}
|
||||
|
||||
$getter;
|
||||
export function mainModule() {
|
||||
var existing = $getByIdDirectPrivate(this, "main");
|
||||
const existing = $getByIdDirectPrivate(this, "main");
|
||||
// note: this doesn't handle "process.mainModule = undefined"
|
||||
if (typeof existing !== "undefined") {
|
||||
return existing;
|
||||
|
||||
@@ -49,7 +49,7 @@ export function initializeReadableStream(
|
||||
$putByIdDirectPrivate(this, "readableStreamController", null);
|
||||
this.$bunNativePtr = $getByIdDirectPrivate(underlyingSource, "bunNativePtr") ?? undefined;
|
||||
|
||||
$putByIdDirectPrivate(this, "asyncContext", $getInternalField($asyncContext, 0));
|
||||
$putByIdDirectPrivate(this, "asyncContextData", $getInternalField($asyncContextTuple, 0));
|
||||
|
||||
const isDirect = underlyingSource.type === "direct";
|
||||
// direct streams are always lazy
|
||||
|
||||
@@ -122,7 +122,7 @@ export function setupReadableStreamDefaultController(
|
||||
underlyingSource,
|
||||
size,
|
||||
highWaterMark,
|
||||
startMethod,
|
||||
_startMethod,
|
||||
pullMethod,
|
||||
cancelMethod,
|
||||
) {
|
||||
@@ -134,15 +134,15 @@ export function setupReadableStreamDefaultController(
|
||||
$isReadableStream,
|
||||
);
|
||||
|
||||
var asyncContext = stream.$asyncContext;
|
||||
const newAsyncContextData = stream.$asyncContextData;
|
||||
const pullAlgorithm = () => $promiseInvokeOrNoopMethod(underlyingSource, pullMethod, [controller]);
|
||||
const cancelAlgorithm = asyncContext
|
||||
const cancelAlgorithm = newAsyncContextData
|
||||
? reason => {
|
||||
var prev = $getInternalField($asyncContext, 0);
|
||||
$putInternalField($asyncContext, 0, asyncContext);
|
||||
const oldAsyncContextData = $getInternalField($asyncContextTuple, 0);
|
||||
$putInternalField($asyncContextTuple, 0, newAsyncContextData);
|
||||
// this does not throw, but can returns a rejected promise
|
||||
var result = $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);
|
||||
$putInternalField($asyncContext, 0, prev);
|
||||
const result = $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);
|
||||
$putInternalField($asyncContextTuple, 0, oldAsyncContextData);
|
||||
return result;
|
||||
}
|
||||
: reason => $promiseInvokeOrNoopMethod(underlyingSource, cancelMethod, [reason]);
|
||||
@@ -652,7 +652,7 @@ export function readDirectStream(stream, sink, underlyingSource) {
|
||||
highWaterMark: !highWaterMark || highWaterMark < 64 ? 64 : highWaterMark,
|
||||
});
|
||||
|
||||
$startDirectStream.$call(sink, stream, underlyingSource.pull, close, stream.$asyncContext);
|
||||
$startDirectStream.$call(sink, stream, underlyingSource.pull, close, stream.$asyncContextData);
|
||||
|
||||
$putByIdDirectPrivate(stream, "reader", {});
|
||||
|
||||
@@ -709,7 +709,7 @@ export async function readStreamIntoSink(stream, sink, isNative) {
|
||||
stream,
|
||||
undefined,
|
||||
() => !didThrow && stream.$state !== $streamClosed && $markPromiseAsHandled(stream.cancel()),
|
||||
stream.$asyncContext,
|
||||
stream.$asyncContextData,
|
||||
);
|
||||
|
||||
sink.start({ highWaterMark: highWaterMark || 0 });
|
||||
@@ -835,10 +835,11 @@ export function onPullDirectStream(controller) {
|
||||
var deferClose;
|
||||
var deferFlush;
|
||||
|
||||
var asyncContext = stream.$asyncContext;
|
||||
if (asyncContext) {
|
||||
var prev = $getInternalField($asyncContext, 0);
|
||||
$putInternalField($asyncContext, 0, asyncContext);
|
||||
let oldAsyncContextData;
|
||||
const newAsyncContextData = stream.$asyncContextData;
|
||||
if (newAsyncContextData) {
|
||||
oldAsyncContextData = $getInternalField($asyncContextTuple, 0);
|
||||
$putInternalField($asyncContextTuple, 0, newAsyncContextData);
|
||||
}
|
||||
|
||||
// Direct streams allow $pull to be called multiple times, unlike the spec.
|
||||
@@ -864,8 +865,8 @@ export function onPullDirectStream(controller) {
|
||||
deferFlush = controller._deferFlush;
|
||||
controller._deferFlush = controller._deferClose = 0;
|
||||
|
||||
if (asyncContext) {
|
||||
$putInternalField($asyncContext, 0, prev);
|
||||
if (newAsyncContextData) {
|
||||
$putInternalField($asyncContextTuple, 0, oldAsyncContextData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -109,7 +109,6 @@ const {
|
||||
SetPrototypeValues,
|
||||
String,
|
||||
StringPrototypeCharCodeAt,
|
||||
StringPrototypeCodePointAt,
|
||||
StringPrototypeIncludes,
|
||||
StringPrototypeIndexOf,
|
||||
StringPrototypeLastIndexOf,
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
// The other functions are deprecated anyways, and would impact performance too much.
|
||||
// API: https://nodejs.org/api/async_hooks.html
|
||||
//
|
||||
// JSC has been patched to include a special global variable $asyncContext which is set to
|
||||
// JSC has been patched to include a special global variable $asyncContextTuple which is set to
|
||||
// a constant InternalFieldTuple<[AsyncContextData, never]>. `get` and `set` read/write to the
|
||||
// first element of this tuple. Inside of PromiseOperations.js, we "snapshot" the context (store it
|
||||
// in the promise reaction) and then just before we call .then, we restore it.
|
||||
//
|
||||
// This means context tracking is *kind-of* manual. If we recieve a callback in native code
|
||||
// This means context tracking is *kind-of* manual. If we receive a callback in native code
|
||||
// - In Zig, call jsValue.withAsyncContextIfNeeded(); which returns another JSValue. Store that and
|
||||
// then run .$call() on it later.
|
||||
// - In C++, call AsyncContextFrame::withAsyncContextIfNeeded(jsValue). Then to call it,
|
||||
@@ -61,14 +61,14 @@ function debugFormatContextValue(value: ReadonlyArray<any> | undefined) {
|
||||
}
|
||||
|
||||
function get(): ReadonlyArray<any> | undefined {
|
||||
$debug("get", debugFormatContextValue($getInternalField($asyncContext, 0)));
|
||||
return $getInternalField($asyncContext, 0);
|
||||
$debug("get", debugFormatContextValue($getInternalField($asyncContextTuple, 0)));
|
||||
return $getInternalField($asyncContextTuple, 0);
|
||||
}
|
||||
|
||||
function set(contextValue: ReadonlyArray<any> | undefined) {
|
||||
$assert(assertValidAsyncContextArray(contextValue));
|
||||
$debug("set", debugFormatContextValue(contextValue));
|
||||
return $putInternalField($asyncContext, 0, contextValue);
|
||||
function set(asyncContextData: ReadonlyArray<any> | undefined) {
|
||||
$assert(assertValidAsyncContextArray(asyncContextData));
|
||||
$debug("set", debugFormatContextValue(asyncContextData));
|
||||
return $putInternalField($asyncContextTuple, 0, asyncContextData);
|
||||
}
|
||||
|
||||
class AsyncLocalStorage {
|
||||
|
||||
@@ -25,8 +25,7 @@ const bunHTTP2Socket = Symbol.for("::bunhttp2socket::");
|
||||
const bunHTTP2WantTrailers = Symbol.for("::bunhttp2WantTrailers::");
|
||||
const bunHTTP2Session = Symbol.for("::bunhttp2session::");
|
||||
|
||||
const ReflectGetPrototypeOf = Reflect.getPrototypeOf;
|
||||
const FunctionPrototypeBind = primordials.FunctionPrototypeBind;
|
||||
const { FunctionPrototypeBind, ReflectGetPrototypeOf } = primordials;
|
||||
|
||||
const proxySocketHandler = {
|
||||
get(session, prop) {
|
||||
|
||||
@@ -4,9 +4,7 @@ import { createTest } from "node-harness";
|
||||
const store = new AsyncLocalStorage();
|
||||
const data = Symbol("verifier");
|
||||
|
||||
const { beforeAll, describe, expect, it, throws, assert, createCallCheckCtx, createDoneDotAll } = createTest(
|
||||
import.meta.path,
|
||||
);
|
||||
const { assert, createCallCheckCtx } = createTest(import.meta.path);
|
||||
|
||||
test("node.js test test-async-local-storage-no-mix-contexts.js", async () => {
|
||||
const asyncLocalStorage = new AsyncLocalStorage();
|
||||
|
||||
Reference in New Issue
Block a user