Skip to content

Commit c0064d5

Browse files
committed
v8 update (7.7.299)
1 parent 607a257 commit c0064d5

23 files changed

+4639
-634
lines changed

Source/V8/Private/Delegates.cpp

+13-9
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "JavascriptStats.h"
55
#include "UObject/GCObject.h"
66
#include "../../Launch/Resources/Version.h"
7+
#include "v8-version.h"
78

89
PRAGMA_DISABLE_SHADOW_VARIABLE_WARNINGS
910

@@ -107,29 +108,31 @@ class FJavascriptDelegate : public FGCObject, public TSharedFromThis<FJavascript
107108
auto toJSON = [](const FunctionCallbackInfo<Value>& info) {
108109
auto payload = reinterpret_cast<FJavascriptDelegate*>(Local<External>::Cast(info.Data())->Value());
109110

110-
uint32_t Index = 0;
111-
auto arr = Array::New(info.GetIsolate(), payload->DelegateObjects.Num());
111+
uint32_t Index = 0;
112+
auto isolate_ = info.GetIsolate();
113+
auto context_ = isolate_->GetCurrentContext();
114+
auto arr = Array::New(isolate_, payload->DelegateObjects.Num());
112115
const bool bIsMulticastDelegate = payload->Property->IsA(UMulticastDelegateProperty::StaticClass());
113116

114117
for (auto DelegateObject : payload->DelegateObjects)
115118
{
116119
auto JavascriptFunction = payload->functions.Find(DelegateObject->UniqueId);
117120
if (JavascriptFunction)
118121
{
119-
auto function = Local<Function>::New(info.GetIsolate(), *JavascriptFunction);
122+
auto function = Local<Function>::New(isolate_, *JavascriptFunction);
120123
if (!bIsMulticastDelegate)
121124
{
122125
info.GetReturnValue().Set(function);
123126
return;
124127
}
125128

126-
arr->Set(Index++, function);
129+
arr->Set(context_, Index++, function);
127130
}
128131
}
129132

130133
if (!bIsMulticastDelegate)
131134
{
132-
info.GetReturnValue().Set(Null(info.GetIsolate()));
135+
info.GetReturnValue().Set(Null(isolate_));
133136
}
134137
else
135138
{
@@ -382,17 +385,18 @@ struct FDelegateManager : IDelegateManager
382385
virtual Local<Value> GetProxy(Local<Object> This, UObject* Object, UProperty* Property) override
383386
{
384387
auto cache_id = V8_KeywordString(isolate_, FString::Printf(TEXT("$internal_%s"), *(Property->GetName())));
385-
auto cached = This->Get(cache_id);
386-
if (cached.IsEmpty() || cached->IsUndefined())
388+
auto context_ = isolate_->GetCurrentContext();
389+
auto maybe_cached = This->Get(context_, cache_id);
390+
if (maybe_cached.IsEmpty() || maybe_cached.ToLocalChecked()->IsUndefined())
387391
{
388392
auto created = CreateDelegate(Object, Property);
389393

390-
This->Set(cache_id, created);
394+
This->Set(context_, cache_id, created);
391395
return created;
392396
}
393397
else
394398
{
395-
return cached;
399+
return maybe_cached.ToLocalChecked();
396400
}
397401
}
398402
};

Source/V8/Private/FunctionCall.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,22 @@ namespace v8
100100
// pass return parameter as '$'
101101
if (PropertyFlags & CPF_ReturnParm)
102102
{
103-
auto sub_value = Object->Get(I.Keyword("$"));
103+
auto sub_value = Object->Get(context, I.Keyword("$"));
104104

105-
WriteProperty(isolate, ReturnParam, Buffer, sub_value, FNoPropertyOwner());
105+
if (!sub_value.IsEmpty())
106+
{
107+
WriteProperty(isolate, ReturnParam, Buffer, sub_value.ToLocalChecked(), FNoPropertyOwner());
108+
}
106109
}
107110
// rejects 'const T&' and pass 'T&' as its name
108111
else if ((PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm)
109112
{
110-
auto sub_value = Object->Get(I.Keyword(Param->GetName()));
113+
auto sub_value = Object->Get(context, I.Keyword(Param->GetName()));
111114

112115
if (!sub_value.IsEmpty())
113116
{
114117
// value can be null if isolate is in trouble
115-
WriteProperty(isolate, Param, Buffer, sub_value, FNoPropertyOwner());
118+
WriteProperty(isolate, Param, Buffer, sub_value.ToLocalChecked(), FNoPropertyOwner());
116119
}
117120
}
118121
}

Source/V8/Private/Inspector.cpp

+36-23
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,11 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
427427
FIsolateHelper I(isolate_);
428428

429429
{
430-
auto console = InContext->Global()->Get(I.Keyword("console"));
431-
InContext->Global()->Set(I.Keyword("$console"), console);
430+
auto console = InContext->Global()->Get(InContext, I.Keyword("console"));
431+
if (!console.IsEmpty())
432+
{
433+
InContext->Global()->Set(InContext, I.Keyword("$console"), console.ToLocalChecked());
434+
}
432435
}
433436

434437
v8inspector = v8_inspector::V8Inspector::create(isolate_, this);
@@ -487,33 +490,43 @@ class FInspector : public IJavascriptInspector, public FTickableAnyObject, publi
487490
HandleScope handle_scope(isolate_);
488491

489492
FIsolateHelper I(isolate_);
490-
493+
auto context_ = context();
491494
Isolate::Scope isolate_scope(isolate_);
492-
Context::Scope context_scope(context());
495+
Context::Scope context_scope(context_);
493496

494497
TryCatch try_catch(isolate_);
495498

496-
auto console = context()->Global()->Get(I.Keyword("console")).As<v8::Object>();
499+
auto maybe_console = context_->Global()->Get(context_, I.Keyword("console"));
500+
if (!maybe_console.IsEmpty())
501+
{
502+
auto console = maybe_console.ToLocalChecked().As<v8::Object>();
497503

498-
auto method =
499-
Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword("$error") :
500-
Verbosity == ELogVerbosity::Warning ? I.Keyword("$warn") :
501-
Verbosity == ELogVerbosity::Display ? I.Keyword("info") :
502-
I.Keyword("$log");
503-
auto function = console->Get(method).As<v8::Function>();
504+
auto method =
505+
Verbosity == ELogVerbosity::Fatal || Verbosity == ELogVerbosity::Error ? I.Keyword("$error") :
506+
Verbosity == ELogVerbosity::Warning ? I.Keyword("$warn") :
507+
Verbosity == ELogVerbosity::Display ? I.Keyword("info") :
508+
I.Keyword("$log");
504509

505-
if (Verbosity == ELogVerbosity::Display)
506-
{
507-
Handle<Value> argv[2];
508-
argv[0] = I.String(FString::Printf(TEXT("%%c%s: %s"), *Category.ToString(), V));
509-
argv[1] = I.String(TEXT("color:gray"));
510-
(void)function->Call(context(), console, 2, argv);
511-
}
512-
else
513-
{
514-
Handle<Value> argv[1];
515-
argv[0] = I.String(FString::Printf(TEXT("%s: %s"), *Category.ToString(), V));
516-
(void)function->Call(context(), console, 1, argv);
510+
auto maybe_function = console->Get(context_, method);
511+
512+
if (!maybe_function.IsEmpty())
513+
{
514+
auto function = maybe_function.ToLocalChecked().As<v8::Function>();
515+
516+
if (Verbosity == ELogVerbosity::Display)
517+
{
518+
Handle<Value> argv[2];
519+
argv[0] = I.String(FString::Printf(TEXT("%%c%s: %s"), *Category.ToString(), V));
520+
argv[1] = I.String(TEXT("color:gray"));
521+
(void)function->Call(context(), console, 2, argv);
522+
}
523+
else
524+
{
525+
Handle<Value> argv[1];
526+
argv[0] = I.String(FString::Printf(TEXT("%s: %s"), *Category.ToString(), V));
527+
(void)function->Call(context(), console, 1, argv);
528+
}
529+
}
517530
}
518531
}
519532
}

0 commit comments

Comments
 (0)