summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-09-22 08:36:17 -0700
committerTom Sepez <tsepez@chromium.org>2015-09-22 08:36:17 -0700
commited7b2b50aa1744e0bc5a60bef12c61fa91d863b7 (patch)
tree8661329f66b823af324441fb6accec98a8753cb8 /xfa
parent854a7f65b70d40225a53890a68a57f5c13cf268c (diff)
downloadpdfium-ed7b2b50aa1744e0bc5a60bef12c61fa91d863b7.tar.xz
XFA: contention between FXJSE and FXJS over isolate data slots
This probably broke at 06b60021e when the FXJS slot moved to 0 from 1 unless explicitly overriden by the embedder, which conflicted with the FXJSE_ usage of slot 0. Also simplify some logic used to track global intialization of the underling JS. TEST=run_javascript_tests.py on XFA branch doesn't segv. R=jochen@chromium.org Review URL: https://codereview.chromium.org/1351173002 .
Diffstat (limited to 'xfa')
-rw-r--r--xfa/src/fxjse/src/runtime.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp
index a7ee67bc2a..4a77b4f165 100644
--- a/xfa/src/fxjse/src/runtime.cpp
+++ b/xfa/src/fxjse/src/runtime.cpp
@@ -4,6 +4,7 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include "../../../../fpdfsdk/include/jsapi/fxjs_v8.h" // For per-isolate data.
#include "../../foxitlib.h"
#include "fxv8.h"
#include "runtime.h"
@@ -38,11 +39,9 @@ void FXJSE_Initialize() {
static void FXJSE_Runtime_DisposeCallback(v8::Isolate* pIsolate) {
{
v8::Locker locker(pIsolate);
- CFXJSE_RuntimeData* pRuntimeData =
- reinterpret_cast<CFXJSE_RuntimeData*>(pIsolate->GetData(0));
- if (pRuntimeData) {
- pIsolate->SetData(0, NULL);
- delete pRuntimeData;
+ if (FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate)) {
+ delete pData->m_pFXJSERuntimeData;
+ pData->m_pFXJSERuntimeData = nullptr;
}
}
pIsolate->Dispose();
@@ -73,7 +72,6 @@ void FXJSE_Runtime_Release(FXJSE_HRUNTIME hRuntime) {
}
CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) {
CFXJSE_RuntimeData* pRuntimeData = new CFXJSE_RuntimeData(pIsolate);
- ASSERT(pRuntimeData);
CFXJSE_ScopeUtil_IsolateHandle scope(pIsolate);
v8::Local<v8::FunctionTemplate> hFuncTemplate =
v8::FunctionTemplate::New(pIsolate);
@@ -85,15 +83,10 @@ CFXJSE_RuntimeData* CFXJSE_RuntimeData::Create(v8::Isolate* pIsolate) {
return pRuntimeData;
}
CFXJSE_RuntimeData* CFXJSE_RuntimeData::Get(v8::Isolate* pIsolate) {
- ASSERT(pIsolate);
- CFXJSE_RuntimeData* pRuntimeData =
- static_cast<CFXJSE_RuntimeData*>(pIsolate->GetData(0));
- if (!pRuntimeData) {
- pRuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
- ASSERT(pRuntimeData);
- pIsolate->SetData(0, pRuntimeData);
- }
- return pRuntimeData;
+ FXJS_PerIsolateData* pData = FXJS_PerIsolateData::Get(pIsolate);
+ if (!pData->m_pFXJSERuntimeData)
+ pData->m_pFXJSERuntimeData = CFXJSE_RuntimeData::Create(pIsolate);
+ return pData->m_pFXJSERuntimeData;
}
CFXJSE_RuntimeList* CFXJSE_RuntimeData::g_RuntimeList = NULL;
void CFXJSE_RuntimeList::AppendRuntime(v8::Isolate* pIsolate) {