Skip to content

Commit 4aa3e96

Browse files
Multiple creation isolate
1 parent abec422 commit 4aa3e96

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

module/src/CScriptRuntimeInfo.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pragma once
1+
#pragma once
22

33
#include "v8.h"
44
#include <libplatform/libplatform.h>
@@ -12,6 +12,14 @@ class CScriptRuntimeInfo
1212
public:
1313
v8::Isolate* GetIsolate() { return isolate; }
1414

15+
v8::Isolate* MakeIsolate()
16+
{
17+
auto createParams = v8::Isolate::CreateParams{};
18+
createParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
19+
20+
return v8::Isolate::New(createParams);
21+
}
22+
1523
void Instanciate()
1624
{
1725
v8::V8::SetFlagsFromString("--harmony-import-assertions --short-builtin-calls --no-lazy --no-flush-bytecode --no-enable-lazy-source-positions");
@@ -20,10 +28,7 @@ class CScriptRuntimeInfo
2028

2129
v8::V8::Initialize();
2230

23-
auto createParams = v8::Isolate::CreateParams{};
24-
createParams.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator();
25-
26-
isolate = v8::Isolate::New(createParams);
31+
isolate = MakeIsolate();
2732
}
2833

2934
static CScriptRuntimeInfo& Instance()

module/src/runtime.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackage* package)
99
{
10-
v8::Isolate* isolate = CScriptRuntimeInfo::Instance().GetIsolate();
10+
v8::Isolate* isolate = CScriptRuntimeInfo::Instance().MakeIsolate();
1111
v8::Isolate::Scope isolateScope(isolate);
1212
v8::HandleScope handleScope(isolate);
1313

@@ -79,7 +79,6 @@ void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackag
7979
package->WriteFile(clientPkgFile, buffer.data(), buffer.size());
8080
package->CloseFile(clientPkgFile);
8181
}
82-
8382
compilerLogger.Log("Converted " + std::to_string(compiledFiles.size()) + " script files to bytecode");
8483
}
8584

0 commit comments

Comments
 (0)