Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/bun_core/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2817,10 +2817,6 @@ pub fn hex_int_lower<const NIBBLES: usize>(value: u64) -> HexIntFormatter<true,
HexIntFormatter { value }
}

pub fn hex_int_upper<const NIBBLES: usize>(value: u64) -> HexIntFormatter<false, NIBBLES> {
HexIntFormatter { value }
}

/// `{:0N x}` / `{:0N X}` — zero-padded fixed-width hex of a u64 into a stack
/// buffer. Thin alias over [`HexIntFormatter::get_out_buf`] for callers that
/// want bytes, not a `Display` adapter.
Expand Down
33 changes: 0 additions & 33 deletions src/jsc/bindings/AsyncContextFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,6 @@ extern "C" JSC::EncodedJSValue AsyncContextFrame__withAsyncContextIfNeeded(JSGlo
} \
return result;

// JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, const ArgList& args, ASCIILiteral errorMessage)
// {
// ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, args, errorMessage);
// }
// JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, ASCIILiteral errorMessage)
// {
// ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, thisValue, args, errorMessage);
// }
JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
#if ASSERT_ENABLED
Expand All @@ -134,33 +126,8 @@ JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject,

ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args);
}
JSValue AsyncContextFrame::call(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, NakedPtr<JSC::Exception>& returnedException)
{
#if ASSERT_ENABLED
auditEverything(global, functionObject, thisValue, args);
#endif

if (!global->isAsyncContextTrackingEnabled()) [[likely]] {
return JSC::profiledCall(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args, returnedException);
}

ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args, returnedException);
}
JSValue AsyncContextFrame::profiledCall(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
return AsyncContextFrame::call(global, functionObject, thisValue, args);
}
JSValue AsyncContextFrame::profiledCall(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args, NakedPtr<JSC::Exception>& returnedException)
{
return AsyncContextFrame::call(global, functionObject, thisValue, args, returnedException);
}

JSC::JSValue AsyncContextFrame::run(JSGlobalObject* global, JSValue functionObject, JSValue thisValue, const ArgList& args)
{
ASSERT(global->isAsyncContextTrackingEnabled());
#if ASSERT_ENABLED
auditEverything(global, functionObject, thisValue, args);
#endif
ASYNCCONTEXTFRAME_CALL_IMPL(global, ProfilingReason::API, functionObject, JSC::getCallData(functionObject), thisValue, args);
}
#undef ASYNCCONTEXTFRAME_CALL_IMPL
13 changes: 0 additions & 13 deletions src/jsc/bindings/AsyncContextFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,17 @@ class AsyncContextFrame : public JSC::JSNonFinalObject {
// The following is JSC::call but
// - it unwraps AsyncContextFrame
// - does not take a CallData, because JSC::getCallData(AsyncContextFrame) -> not callable
// static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, const JSC::ArgList&, ASCIILiteral errorMessage);
// static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, ASCIILiteral errorMessage);
static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&);
static JSC::JSValue call(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, NakedPtr<JSC::Exception>& returnedException);

// Alias of call.
static JSC::JSValue profiledCall(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&);

// Alias of call.
static JSC::JSValue profiledCall(JSC::JSGlobalObject*, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList&, NakedPtr<JSC::Exception>& returnedException);

DECLARE_INFO;
DECLARE_VISIT_CHILDREN;

mutable JSC::WriteBarrier<JSC::Unknown> callback;
mutable JSC::WriteBarrier<JSC::Unknown> context;

/**
* When you have a **specific** AsyncContextFrame to run the function in, use this
*
* Usually, you do not want to use this. Usually, you want to use `call` or `profiledCall`.
*/
JSC::JSValue run(JSC::JSGlobalObject* globalObject, JSC::JSValue functionObject, JSC::JSValue thisValue, const JSC::ArgList& args);

template<typename, JSC::SubspaceAccess mode>
static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
{
Expand Down
1 change: 0 additions & 1 deletion src/jsc/bindings/ConsoleObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@
}
void ConsoleObject::record(JSGlobalObject*, Ref<ScriptArguments>&&) {}
void ConsoleObject::recordEnd(JSGlobalObject*, Ref<ScriptArguments>&&) {}
void ConsoleObject::screenshot(JSGlobalObject*, Ref<ScriptArguments>&&)
{
}

Check warning on line 110 in src/jsc/bindings/ConsoleObject.cpp

View check run for this annotation

Claude / Claude Code Review

Sibling files retain same-class dead code after sweep: ConsoleObject.cpp Inspector*Agent includes and EventPath.h

Two more same-class leftovers in sibling files of ones this PR swept: (1) `ConsoleObject.cpp:18-20` still `#include` `InspectorScriptProfilerAgent.h`/`InspectorDebuggerAgent.h`/`InspectorConsoleAgent.h` — after the agent fields/aliases were removed from `ConsoleObject.{h,cpp}`, nothing references those types (surviving code only uses `inspectorController().consoleClient()`); (2) `webcore/EventPath.h` — the paired header of the swept `EventPath.cpp` — still has `// #include "PseudoElement.h"`/SVG
Comment thread
robobun marked this conversation as resolved.
void ConsoleObject::warnUnimplemented(const String& method) {}

void ConsoleObject::profile(JSC::JSGlobalObject* globalObject, const String& title)
{
Expand Down
31 changes: 0 additions & 31 deletions src/jsc/bindings/ConsoleObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,9 @@
#include "root.h"

#include <JavaScriptCore/ConsoleClient.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>

#include <JavaScriptCore/InspectorConsoleAgent.h>

namespace Inspector {
class InspectorConsoleAgent;
class InspectorDebuggerAgent;
class InspectorScriptProfilerAgent;
} // namespace Inspector
namespace Bun {
using InspectorConsoleAgent = Inspector::InspectorConsoleAgent;
using InspectorDebuggerAgent = Inspector::InspectorDebuggerAgent;
using InspectorScriptProfilerAgent = Inspector::InspectorScriptProfilerAgent;
using namespace JSC;

class ConsoleObject final : public JSC::ConsoleClient {
Expand All @@ -30,16 +19,6 @@ class ConsoleObject final : public JSC::ConsoleClient {
m_client = client;
}

static bool logToSystemConsole();
static void setLogToSystemConsole(bool);

Inspector::InspectorConsoleAgent* consoleAgent() { return m_consoleAgent; }
void setDebuggerAgent(InspectorDebuggerAgent* agent) { m_debuggerAgent = agent; }
void setPersistentScriptProfilerAgent(InspectorScriptProfilerAgent* agent)
{
m_scriptProfilerAgent = agent;
}

void* m_client;

private:
Expand All @@ -57,16 +36,6 @@ class ConsoleObject final : public JSC::ConsoleClient {
void record(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
void recordEnd(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
void screenshot(JSC::JSGlobalObject*, Ref<Inspector::ScriptArguments>&&);
Comment thread
robobun marked this conversation as resolved.

void warnUnimplemented(const String& method);
void internalAddMessage(MessageType, MessageLevel, JSC::JSGlobalObject*,
Ref<Inspector::ScriptArguments>&&);

Inspector::InspectorConsoleAgent* m_consoleAgent;
Inspector::InspectorDebuggerAgent* m_debuggerAgent { nullptr };
Inspector::InspectorScriptProfilerAgent* m_scriptProfilerAgent { nullptr };
Vector<String> m_profiles;
bool m_profileRestoreBreakpointActiveValue { false };
};

} // namespace Zig
75 changes: 0 additions & 75 deletions src/jsc/bindings/JSDOMGlobalObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,79 +9,4 @@ Zig::GlobalObject* toJSDOMGlobalObject(ScriptExecutionContext& ctx, DOMWrapperWo
return uncheckedDowncast<Zig::GlobalObject>(ctx.jsGlobalObject());
}

// static JSDOMGlobalObject& callerGlobalObject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame, bool skipFirstFrame, bool lookUpFromVMEntryScope)
// {
// VM& vm = lexicalGlobalObject.vm();
// if (callFrame) {
// class GetCallerGlobalObjectFunctor {
// public:
// GetCallerGlobalObjectFunctor(bool skipFirstFrame)
// : m_skipFirstFrame(skipFirstFrame)
// {
// }

// StackVisitor::Status operator()(StackVisitor& visitor) const
// {
// if (m_skipFirstFrame) {
// if (!m_hasSkippedFirstFrame) {
// m_hasSkippedFirstFrame = true;
// return StackVisitor::Continue;
// }
// }

// if (auto* codeBlock = visitor->codeBlock())
// m_globalObject = codeBlock->globalObject();
// else {
// ASSERT(visitor->callee().rawPtr());
// // FIXME: Callee is not an object if the caller is Web Assembly.
// // Figure out what to do here. We can probably get the global object
// // from the top-most Wasm Instance. https://bugs.webkit.org/show_bug.cgi?id=165721
// if (visitor->callee().isCell() && visitor->callee().asCell()->isObject())
// m_globalObject = uncheckedDowncast<JSObject>(visitor->callee().asCell())->globalObject();
// }
// return StackVisitor::Done;
// }

// JSC::JSGlobalObject* globalObject() const { return m_globalObject; }

// private:
// bool m_skipFirstFrame { false };
// mutable bool m_hasSkippedFirstFrame { false };
// mutable JSC::JSGlobalObject* m_globalObject { nullptr };
// };

// GetCallerGlobalObjectFunctor iter(skipFirstFrame);
// callFrame->iterate(vm, iter);
// if (iter.globalObject())
// return *uncheckedDowncast<JSDOMGlobalObject>(iter.globalObject());
// }

// // In the case of legacyActiveGlobalObjectForAccessor, it is possible that vm.topCallFrame is nullptr when the script is evaluated as JSONP.
// // Since we put JSGlobalObject to VMEntryScope, we can retrieve the right globalObject from that.
// // For callerGlobalObject, we do not check vm.entryScope to keep it the old behavior.
// if (lookUpFromVMEntryScope) {
// if (vm.entryScope) {
// if (auto* result = vm.entryScope->globalObject())
// return *uncheckedDowncast<JSDOMGlobalObject>(result);
// }
// }

// // If we cannot find JSGlobalObject in caller frames, we just return the current lexicalGlobalObject.
// return *uncheckedDowncast<JSDOMGlobalObject>(&lexicalGlobalObject);
// }

// JSDOMGlobalObject& callerGlobalObject(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame)
// {
// constexpr bool skipFirstFrame = true;
// constexpr bool lookUpFromVMEntryScope = false;
// return callerGlobalObject(lexicalGlobalObject, callFrame, skipFirstFrame, lookUpFromVMEntryScope);
// }

// JSDOMGlobalObject& legacyActiveGlobalObjectForAccessor(JSC::JSGlobalObject& lexicalGlobalObject, JSC::CallFrame* callFrame)
// {
// constexpr bool skipFirstFrame = false;
// constexpr bool lookUpFromVMEntryScope = true;
// return callerGlobalObject(lexicalGlobalObject, callFrame, skipFirstFrame, lookUpFromVMEntryScope);
// }

}
129 changes: 0 additions & 129 deletions src/jsc/bindings/ZigSourceProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "MimallocWTFMalloc.h"
#include "BunAnalyzeTranspiledModule.h"

#include <JavaScriptCore/BytecodeCacheError.h>
#include "ZigGlobalObject.h"
#include "wtf/Assertions.h"

Expand All @@ -20,13 +19,6 @@

namespace Zig {

using Base = JSC::SourceProvider;
using BytecodeCacheGenerator = JSC::BytecodeCacheGenerator;
using UnlinkedFunctionExecutable = JSC::UnlinkedFunctionExecutable;
using CachedBytecode = JSC::CachedBytecode;
using UnlinkedFunctionCodeBlock = JSC::UnlinkedFunctionCodeBlock;
using SourceCode = JSC::SourceCode;
using CodeSpecializationKind = JSC::CodeSpecializationKind;
using SourceOrigin = JSC::SourceOrigin;
using String = WTF::String;
using SourceProviderSourceType = JSC::SourceProviderSourceType;
Expand All @@ -50,10 +42,6 @@ SourceOrigin toSourceOrigin(const String& sourceURL, bool isBuiltin)

extern "C" int ByteRangeMapping__getSourceID(void* mappings, BunString sourceURL);
extern "C" void* ByteRangeMapping__find(BunString sourceURL);
void* sourceMappingForSourceURL(const WTF::String& sourceURL)
{
return ByteRangeMapping__find(Bun::toString(sourceURL));
}

extern "C" void ByteRangeMapping__generate(BunString sourceURL, BunString code, int sourceID);

Expand Down Expand Up @@ -287,123 +275,6 @@ unsigned SourceProvider::hash() const
return m_source->hash();
}

void SourceProvider::freeSourceCode()
{
}

void SourceProvider::updateCache(const UnlinkedFunctionExecutable* executable, const SourceCode&,
CodeSpecializationKind kind,
const UnlinkedFunctionCodeBlock* codeBlock)
{
// if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode)
return;

JSC::BytecodeCacheError error;
RefPtr<JSC::CachedBytecode> cachedBytecode = JSC::encodeFunctionCodeBlock(executable->vm(), codeBlock, error);
if (cachedBytecode && !error.isValid())
m_cachedBytecode->addFunctionUpdate(executable, kind, *cachedBytecode);
}

void SourceProvider::cacheBytecode(const BytecodeCacheGenerator& generator)
{
// if (!m_resolvedSource.bytecodecache_fd)
return;

if (!m_cachedBytecode)
m_cachedBytecode = JSC::CachedBytecode::create();
auto update = generator();
if (update)
m_cachedBytecode->addGlobalUpdate(*update);
}

void SourceProvider::commitCachedBytecode()
{
// if (!m_resolvedSource.bytecodecache_fd || !m_cachedBytecode || !m_cachedBytecode->hasUpdates())
return;

// auto clearBytecode = WTF::makeScopeExit([&] { m_cachedBytecode = nullptr; });
// const auto fd = m_resolvedSource.bytecodecache_fd;

// auto fileSize = FileSystem::fileSize(fd);
// if (!fileSize)
// return;

// size_t cacheFileSize;
// if (!WTF::convertSafely(*fileSize, cacheFileSize) || cacheFileSize != m_cachedBytecode->size()) {
// // The bytecode cache has already been updated
// return;
// }

// if (!FileSystem::truncateFile(fd, m_cachedBytecode->sizeForUpdate()))
// return;

// m_cachedBytecode->commitUpdates([&](off_t offset, const void* data, size_t size) {
// long long result = FileSystem::seekFile(fd, offset, FileSystem::FileSeekOrigin::Beginning);
// ASSERT_UNUSED(result, result != -1);
// size_t bytesWritten = static_cast<size_t>(FileSystem::writeToFile(fd, data, size));
// ASSERT_UNUSED(bytesWritten, bytesWritten == size);
// });
}

bool SourceProvider::isBytecodeCacheEnabled() const
{
// return m_resolvedSource.bytecodecache_fd > 0;
return false;
}

void SourceProvider::readOrGenerateByteCodeCache(JSC::VM& vm, const JSC::SourceCode& sourceCode)
{
// auto status = this->readCache(vm, sourceCode);
// switch (status) {
// case -1: {
// m_resolvedSource.bytecodecache_fd = 0;
// break;
// }
// case 0: {
// JSC::BytecodeCacheError err;
// m_cachedBytecode = JSC::generateModuleBytecode(vm, sourceCode, m_resolvedSource.bytecodecache_fd, err);

// if (err.isValid()) {
// m_resolvedSource.bytecodecache_fd = 0;
// m_cachedBytecode = JSC::CachedBytecode::create();
// }
// }
// // TODO: read the bytecode into a JSC::SourceCode object here
// case 1: {
// }
// }
}
int SourceProvider::readCache(JSC::VM& vm, const JSC::SourceCode& sourceCode)
{
return -1;
// if (m_resolvedSource.bytecodecache_fd == 0)
// return -1;
// if (!FileSystem::isHandleValid(m_resolvedSource.bytecodecache_fd))
// return -1;
// const auto fd = m_resolvedSource.bytecodecache_fd;

// bool success;
// FileSystem::MappedFileData mappedFile(fd, FileSystem::MappedFileMode::Shared, success);
// if (!success)
// return -1;

// const uint8_t* fileData = reinterpret_cast<const uint8_t*>(mappedFile.data());
// unsigned fileTotalSize = mappedFile.size();
// if (fileTotalSize == 0)
// return 0;

// Ref<JSC::CachedBytecode> cachedBytecode = JSC::CachedBytecode::create(WTF::move(mappedFile));
// // auto key = JSC::sourceCodeKeyForSerializedModule(vm, sourceCode);
// // if (isCachedBytecodeStillValid(vm, cachedBytecode.copyRef(), key,
// // JSC::SourceCodeType::ModuleType)) {
// m_cachedBytecode = WTF::move(cachedBytecode);
// return 1;
// } else {
// FileSystem::truncateFile(fd, 0);
// return 0;
// }
}

extern "C" BunString ZigSourceProvider__getSourceSlice(SourceProvider* provider)
{
return Bun::toStringView(provider->source());
Expand Down
Loading
Loading