aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-18 00:22:24 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-18 00:22:24 -0700
commit5de8271181985751f8fc04b6fd9fd4be4c457d1e (patch)
treeacf6e1d0f5493acdf3dd47729e99bc2102d28e88 /src
parentf4ff5ecbdf653a11e48943628b8bc363cbb44680 (diff)
downloadbun-5de8271181985751f8fc04b6fd9fd4be4c457d1e.tar.gz
bun-5de8271181985751f8fc04b6fd9fd4be4c457d1e.tar.zst
bun-5de8271181985751f8fc04b6fd9fd4be4c457d1e.zip
Handle builds with remote inspector disabled
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/bindings/BunJSCModule.cpp13
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.cpp2
-rw-r--r--src/bun.js/bindings/ZigGeneratedClasses.h2
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp24
4 files changed, 33 insertions, 8 deletions
diff --git a/src/bun.js/bindings/BunJSCModule.cpp b/src/bun.js/bindings/BunJSCModule.cpp
index 0515605e1..38e9b5618 100644
--- a/src/bun.js/bindings/BunJSCModule.cpp
+++ b/src/bun.js/bindings/BunJSCModule.cpp
@@ -10,7 +10,6 @@
#include "JavaScriptCore/APICast.h"
#include "JavaScriptCore/JSBasePrivate.h"
#include "JavaScriptCore/ObjectConstructor.h"
-#include "JavaScriptCore/RemoteInspectorServer.h"
#include "JavaScriptCore/AggregateError.h"
#include "JavaScriptCore/BytecodeIndex.h"
#include "JavaScriptCore/CallFrameInlines.h"
@@ -25,6 +24,10 @@
#include "JavaScriptCore/DeferTermination.h"
#include "JavaScriptCore/VMTrapsInlines.h"
+#if ENABLE(REMOTE_INSPECTOR)
+#include "JavaScriptCore/RemoteInspectorServer.h"
+#endif
+
#include "mimalloc.h"
using namespace JSC;
@@ -33,7 +36,7 @@ using namespace WTF;
JSC_DECLARE_HOST_FUNCTION(functionStartRemoteDebugger);
JSC_DEFINE_HOST_FUNCTION(functionStartRemoteDebugger, (JSGlobalObject * globalObject, CallFrame* callFrame))
{
-
+#if ENABLE(REMOTE_INSPECTOR)
static const char* defaultHost = "127.0.0.1\0";
static uint16_t defaultPort = 9230; // node + 1
auto& vm = globalObject->vm();
@@ -73,6 +76,12 @@ JSC_DEFINE_HOST_FUNCTION(functionStartRemoteDebugger, (JSGlobalObject * globalOb
}
RELEASE_AND_RETURN(scope, JSC::JSValue::encode(JSC::jsUndefined()));
+#else
+ auto& vm = globalObject->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ throwVMError(globalObject, scope, createTypeError(globalObject, "Remote inspector is not enabled in this build of Bun"_s));
+ return JSC::JSValue::encode(JSC::jsUndefined());
+#endif
}
JSC_DECLARE_HOST_FUNCTION(functionDescribe);
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.cpp b/src/bun.js/bindings/ZigGeneratedClasses.cpp
index 881f0ba5b..25f2f42e7 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.cpp
+++ b/src/bun.js/bindings/ZigGeneratedClasses.cpp
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-// Generated by src/bun.js/generate-classes.js
+// Generated by make codegen
#include "root.h"
#include "ZigGlobalObject.h"
diff --git a/src/bun.js/bindings/ZigGeneratedClasses.h b/src/bun.js/bindings/ZigGeneratedClasses.h
index b63081dd5..6b23611de 100644
--- a/src/bun.js/bindings/ZigGeneratedClasses.h
+++ b/src/bun.js/bindings/ZigGeneratedClasses.h
@@ -1,6 +1,6 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
-// Generated by src/bun.js/generate-classes.js
+// Generated by make codegen
#pragma once
#include "root.h"
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index 8b1aa65ea..453e8851d 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -89,7 +89,6 @@
#include "Process.h"
-#include "JavaScriptCore/RemoteInspectorServer.h"
#include "WebCoreJSBuiltinInternals.h"
#include "JSBuffer.h"
#include "JSFFIFunction.h"
@@ -104,6 +103,10 @@
#include "ZigGeneratedClasses.h"
+#if ENABLE(REMOTE_INSPECTOR)
+#include "JavaScriptCore/RemoteInspectorServer.h"
+#endif
+
using JSGlobalObject = JSC::JSGlobalObject;
using Exception = JSC::Exception;
using JSValue = JSC::JSValue;
@@ -946,9 +949,15 @@ JSC_DEFINE_HOST_FUNCTION(functionFileURLToPath, (JSC::JSGlobalObject * globalObj
{
auto& vm = globalObject->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
- auto path = JSC::JSValue::encode(callFrame->argument(0));
+ JSValue arg0 = callFrame->argument(0);
+ auto path = JSC::JSValue::encode(arg0);
auto* domURL = WebCoreCast<WebCore::JSDOMURL, WebCore__DOMURL>(path);
if (!domURL) {
+ if (arg0.isString()) {
+ auto url = WTF::URL(arg0.toWTFString(globalObject));
+ RETURN_IF_EXCEPTION(scope, JSC::JSValue::encode(JSC::jsUndefined()));
+ RETURN_AND_RELEASE_SCOPE(scope, jsString(vm, url.fileSystemPath()));
+ }
throwTypeError(globalObject, scope, "Argument must be a URL"_s);
return JSC::JSValue::encode(JSC::JSValue {});
}
@@ -1586,8 +1595,8 @@ private:
static const JSC::DOMJIT::Signature DOMJITSignatureForPerformanceNow(
functionPerformanceNowWithoutTypeCheck,
JSPerformanceObject::info(),
- JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
- WebCore::DOMJIT::IDLResultTypeFilter<IDLUnsignedLong>::value);
+ JSC::DOMJIT::Effect::forWriteKinds(DFG::AbstractHeapKind::SideState),
+ SpecBytecodeDouble);
JSFunction* function = JSFunction::create(
vm,
@@ -1909,7 +1918,10 @@ void GlobalObject::finishCreation(VM& vm)
});
addBuiltinGlobals(vm);
+
+#if ENABLE(REMOTE_INSPECTOR)
setRemoteDebuggingEnabled(false);
+#endif
RELEASE_ASSERT(classInfo());
}
@@ -2342,9 +2354,13 @@ void GlobalObject::installAPIGlobals(JSClassRef* globals, int count, JSC::VM& vm
extern "C" bool JSC__JSGlobalObject__startRemoteInspector(JSC__JSGlobalObject* globalObject, unsigned char* host, uint16_t arg1)
{
+#if !ENABLE(REMOTE_INSPECTOR)
+ return false;
+#else
globalObject->setRemoteDebuggingEnabled(true);
auto& server = Inspector::RemoteInspectorServer::singleton();
return server.start(reinterpret_cast<const char*>(host), arg1);
+#endif
}
template<typename Visitor>