Skip to content

Commit

Permalink
[JSCRuntime] Set JSContext name to JSCRuntime description
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Aug 11, 2023
1 parent bbcdb40 commit 91e0972
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/react-native/ReactCommon/jsc/JSCRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "JSCRuntime.h"

#include <JavaScriptCore/JavaScript.h>
#include <JavaScriptCore/JSContextRef.h>
#include <jsi/jsilib.h>
#include <array>
#include <atomic>
Expand Down Expand Up @@ -302,6 +303,9 @@ class JSCRuntime : public jsi::Runtime {
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0
#define _JSC_NO_ARRAY_BUFFERS
#endif
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 164000
#define _JSC_HAS_INSPECTABLE
#endif
#endif
#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_11
Expand Down Expand Up @@ -400,11 +404,13 @@ JSCRuntime::JSCRuntime(JSGlobalContextRef ctx)
{
#ifndef NDEBUG
#ifdef TARGET_OS_MAC
#ifdef _JSC_HAS_INSPECTABLE
if (__builtin_available(macOS 13.3, iOS 16.4, tvOS 16.4, *)) {
JSGlobalContextSetInspectable(ctx_, true);
}
#endif
#endif
#endif
}

JSCRuntime::~JSCRuntime() {
Expand Down Expand Up @@ -444,6 +450,7 @@ jsi::Value JSCRuntime::evaluatePreparedJavaScript(
jsi::Value JSCRuntime::evaluateJavaScript(
const std::shared_ptr<const jsi::Buffer> &buffer,
const std::string &sourceURL) {
JSGlobalContextSetName(ctx_, JSStringCreateWithUTF8CString(this->description().c_str()));
std::string tmp(
reinterpret_cast<const char *>(buffer->data()), buffer->size());
JSStringRef sourceRef = JSStringCreateWithUTF8CString(tmp.c_str());
Expand Down Expand Up @@ -481,6 +488,10 @@ bool JSCRuntime::isInspectable() {
return false;
}

//void setDescription(const std::string &desc) {
// JSGlobalContextSetName(ctx_,(desc.c_str());
//}

namespace {

bool smellsLikeES6Symbol(JSGlobalContextRef ctx, JSValueRef ref) {
Expand Down

0 comments on commit 91e0972

Please sign in to comment.