summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_isolatetracker.cpp8
-rw-r--r--fxjs/cfxjse_isolatetracker.h7
-rw-r--r--fxjs/cfxjse_runtimedata.cpp6
3 files changed, 17 insertions, 4 deletions
diff --git a/fxjs/cfxjse_isolatetracker.cpp b/fxjs/cfxjse_isolatetracker.cpp
index 9594df3109..adf6f2a92e 100644
--- a/fxjs/cfxjse_isolatetracker.cpp
+++ b/fxjs/cfxjse_isolatetracker.cpp
@@ -12,8 +12,11 @@ CFXJSE_IsolateTracker::CFXJSE_IsolateTracker() {}
CFXJSE_IsolateTracker::~CFXJSE_IsolateTracker() {}
-void CFXJSE_IsolateTracker::Append(v8::Isolate* pIsolate) {
+void CFXJSE_IsolateTracker::Append(
+ v8::Isolate* pIsolate,
+ std::unique_ptr<v8::ArrayBuffer::Allocator> alloc) {
m_OwnedIsolates.push_back(pIsolate);
+ m_AllocatorMap[pIsolate] = std::move(alloc);
}
void CFXJSE_IsolateTracker::Remove(
@@ -24,6 +27,8 @@ void CFXJSE_IsolateTracker::Remove(
if (bFound)
m_OwnedIsolates.erase(it);
lpfnDisposeCallback(pIsolate, bFound);
+
+ m_AllocatorMap.erase(pIsolate);
}
void CFXJSE_IsolateTracker::RemoveAll(
@@ -32,4 +37,5 @@ void CFXJSE_IsolateTracker::RemoveAll(
lpfnDisposeCallback(pIsolate, true);
m_OwnedIsolates.clear();
+ m_AllocatorMap.clear();
}
diff --git a/fxjs/cfxjse_isolatetracker.h b/fxjs/cfxjse_isolatetracker.h
index 7558416a14..5340d9b5c0 100644
--- a/fxjs/cfxjse_isolatetracker.h
+++ b/fxjs/cfxjse_isolatetracker.h
@@ -7,6 +7,8 @@
#ifndef FXJS_CFXJSE_ISOLATETRACKER_H_
#define FXJS_CFXJSE_ISOLATETRACKER_H_
+#include <map>
+#include <memory>
#include <vector>
#include "v8/include/v8.h"
@@ -57,7 +59,8 @@ class CFXJSE_IsolateTracker {
CFXJSE_IsolateTracker();
~CFXJSE_IsolateTracker();
- void Append(v8::Isolate* pIsolate);
+ void Append(v8::Isolate* pIsolate,
+ std::unique_ptr<v8::ArrayBuffer::Allocator> alloc);
void Remove(v8::Isolate* pIsolate, DisposeCallback lpfnDisposeCallback);
void RemoveAll(DisposeCallback lpfnDisposeCallback);
@@ -65,6 +68,8 @@ class CFXJSE_IsolateTracker {
protected:
std::vector<v8::Isolate*> m_OwnedIsolates;
+ std::map<v8::Isolate*, std::unique_ptr<v8::ArrayBuffer::Allocator>>
+ m_AllocatorMap;
};
#endif // FXJS_CFXJSE_ISOLATETRACKER_H_
diff --git a/fxjs/cfxjse_runtimedata.cpp b/fxjs/cfxjse_runtimedata.cpp
index b203cb71ac..2c9379526e 100644
--- a/fxjs/cfxjse_runtimedata.cpp
+++ b/fxjs/cfxjse_runtimedata.cpp
@@ -56,11 +56,13 @@ void FXJSE_Finalize() {
}
v8::Isolate* FXJSE_Runtime_Create_Own() {
+ std::unique_ptr<v8::ArrayBuffer::Allocator> allocator(
+ new FXJSE_ArrayBufferAllocator());
v8::Isolate::CreateParams params;
- params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator();
+ params.array_buffer_allocator = allocator.get();
v8::Isolate* pIsolate = v8::Isolate::New(params);
ASSERT(pIsolate && CFXJSE_IsolateTracker::g_pInstance);
- CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate);
+ CFXJSE_IsolateTracker::g_pInstance->Append(pIsolate, std::move(allocator));
return pIsolate;
}