1
-
2
1
#include " CV8ScriptRuntime.h"
3
2
#include " inspector/CV8InspectorClient.h"
4
3
#include " inspector/CV8InspectorChannel.h"
5
4
#include " V8Module.h"
6
5
#include " events/Events.h"
7
- #include " CProfiler.h"
6
+ #include " CProfiler.h"
7
+ #include < Windows.h>
8
8
9
9
CV8ScriptRuntime::CV8ScriptRuntime ()
10
10
{
11
11
// !!! Don't change these without adjusting bytecode module !!!
12
12
v8::V8::SetFlagsFromString (" --harmony-import-assertions --short-builtin-calls --no-lazy --no-flush-bytecode" );
13
- platform = v8::platform::NewDefaultPlatform ();
13
+ platform = v8::platform::NewDefaultPlatform ();
14
+
15
+ v8::LogEventCallback;
16
+
14
17
v8::V8::InitializePlatform (platform.get ());
15
18
v8::V8::InitializeICU ((alt::ICore::Instance ().GetClientPath () + " /libs/icudtl_v8.dat" ).c_str ());
19
+ // MessageBoxA(NULL, "js init 3", "", MB_OK);
16
20
v8::V8::Initialize ();
17
21
18
22
create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator ();
@@ -22,9 +26,10 @@ CV8ScriptRuntime::CV8ScriptRuntime()
22
26
isolate->SetFatalErrorHandler ([](const char * location, const char * message) { Log::Error << " [V8] " << location << " : " << message << Log::Endl; });
23
27
24
28
isolate->SetOOMErrorHandler (
25
- [](const char * location, bool isHeap )
29
+ [](const char * location, const v8::OOMDetails& details )
26
30
{
27
- if (!isHeap) return ;
31
+ if (!details.is_heap_oom ) return ;
32
+
28
33
Log::Error << " [V8] " << location << " : Heap out of memory. Forward this to the server developers." << Log::Endl;
29
34
Log::Error << " [V8] The current heap limit can be shown with the 'heap' console command. Consider increasing your system RAM." << Log::Endl;
30
35
});
@@ -79,22 +84,26 @@ CV8ScriptRuntime::CV8ScriptRuntime()
79
84
});
80
85
81
86
isolate->SetHostImportModuleDynamicallyCallback (
82
- [](v8::Local<v8::Context> context, v8::Local<v8::ScriptOrModule> referrer, v8::Local<v8::String> specifier, v8::Local<v8::FixedArray> importAssertions)
87
+ [](v8::Local<v8::Context> context,
88
+ v8::Local<v8::Data> host_defined_options,
89
+ v8::Local<v8::Value> resource_name,
90
+ v8::Local<v8::String> specifier,
91
+ v8::Local<v8::FixedArray> import_attributes)
83
92
{
84
93
v8::Isolate* isolate = context->GetIsolate ();
85
94
86
- auto referrerVal = referrer-> GetResourceName ();
87
- if (referrerVal-> IsUndefined ()) return v8::MaybeLocal<v8::Promise>();
95
+ if (resource_name-> IsUndefined ())
96
+ return v8::MaybeLocal<v8::Promise>();
88
97
89
- std::string referrerUrl = *v8::String::Utf8Value (isolate, referrer-> GetResourceName () );
98
+ std::string referrerUrl = *v8::String::Utf8Value (isolate, resource_name );
90
99
auto resource = static_cast <CV8ResourceImpl*>(V8ResourceImpl::Get (context));
91
100
92
101
auto resolver = v8::Promise::Resolver::New (context).ToLocalChecked ();
93
102
94
103
V8Helpers::CPersistent<v8::Promise::Resolver> presolver (isolate, resolver);
95
104
V8Helpers::CPersistent<v8::String> pspecifier (isolate, specifier);
96
105
V8Helpers::CPersistent<v8::Module> preferrerModule (isolate, resource->GetModuleFromPath (referrerUrl));
97
- V8Helpers::CPersistent<v8::FixedArray> pimportAssertions (isolate, importAssertions );
106
+ V8Helpers::CPersistent<v8::FixedArray> pimportAssertions (isolate, import_attributes );
98
107
99
108
// careful what we take in by value in the lambda
100
109
// it is possible pass v8::Local but should not be done
@@ -236,7 +245,7 @@ void CV8ScriptRuntime::OnDispose()
236
245
while (isolate->IsInUse ()) isolate->Exit ();
237
246
isolate->Dispose ();
238
247
v8::V8::Dispose ();
239
- v8::V8::ShutdownPlatform ();
248
+ v8::V8::DisposePlatform ();
240
249
delete create_params.array_buffer_allocator ;
241
250
242
251
if (CProfiler::Instance ().IsEnabled ()) CProfiler::Instance ().Dump (alt::ICore::Instance ().GetClientPath ());
0 commit comments