| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * THE POSSIBILITY OF SUCH DAMAGE. | 23 * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "bindings/core/v8/V8PerIsolateData.h" | 26 #include "bindings/core/v8/V8PerIsolateData.h" |
| 27 | 27 |
| 28 #include <memory> | 28 #include <memory> |
| 29 | 29 |
| 30 #include "bindings/core/v8/DOMDataStore.h" | 30 #include "bindings/core/v8/DOMDataStore.h" |
| 31 #include "bindings/core/v8/ScriptSourceCode.h" | 31 #include "bindings/core/v8/ScriptSourceCode.h" |
| 32 #include "bindings/core/v8/V8Binding.h" | 32 #include "bindings/core/v8/V8Binding.h" |
| 33 #include "bindings/core/v8/V8HiddenValue.h" | |
| 34 #include "bindings/core/v8/V8ObjectConstructor.h" | 33 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 35 #include "bindings/core/v8/V8PrivateProperty.h" | 34 #include "bindings/core/v8/V8PrivateProperty.h" |
| 36 #include "bindings/core/v8/V8ScriptRunner.h" | 35 #include "bindings/core/v8/V8ScriptRunner.h" |
| 37 #include "bindings/core/v8/V8ValueCache.h" | 36 #include "bindings/core/v8/V8ValueCache.h" |
| 38 #include "platform/ScriptForbiddenScope.h" | 37 #include "platform/ScriptForbiddenScope.h" |
| 39 #include "platform/wtf/LeakAnnotations.h" | 38 #include "platform/wtf/LeakAnnotations.h" |
| 40 #include "platform/wtf/PtrUtil.h" | 39 #include "platform/wtf/PtrUtil.h" |
| 41 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 42 #include "v8/include/v8-debug.h" | 41 #include "v8/include/v8-debug.h" |
| 43 | 42 |
| 44 namespace blink { | 43 namespace blink { |
| 45 | 44 |
| 46 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 45 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
| 47 | 46 |
| 48 static void beforeCallEnteredCallback(v8::Isolate* isolate) { | 47 static void beforeCallEnteredCallback(v8::Isolate* isolate) { |
| 49 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 48 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
| 50 } | 49 } |
| 51 | 50 |
| 52 static void microtasksCompletedCallback(v8::Isolate* isolate) { | 51 static void microtasksCompletedCallback(v8::Isolate* isolate) { |
| 53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); | 52 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
| 54 } | 53 } |
| 55 | 54 |
| 56 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) | 55 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) |
| 57 : m_isolateHolder( | 56 : m_isolateHolder( |
| 58 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, | 57 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, |
| 59 gin::IsolateHolder::kSingleThread, | 58 gin::IsolateHolder::kSingleThread, |
| 60 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait | 59 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait |
| 61 : gin::IsolateHolder::kAllowAtomicsWait), | 60 : gin::IsolateHolder::kAllowAtomicsWait), |
| 62 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), | 61 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), |
| 63 m_hiddenValue(V8HiddenValue::create()), | |
| 64 m_privateProperty(V8PrivateProperty::create()), | 62 m_privateProperty(V8PrivateProperty::create()), |
| 65 m_constructorMode(ConstructorMode::CreateNewObject), | 63 m_constructorMode(ConstructorMode::CreateNewObject), |
| 66 m_useCounterDisabled(false), | 64 m_useCounterDisabled(false), |
| 67 m_isHandlingRecursionLevelError(false), | 65 m_isHandlingRecursionLevelError(false), |
| 68 m_isReportingException(false) { | 66 m_isReportingException(false) { |
| 69 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 67 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
| 70 isolate()->Enter(); | 68 isolate()->Enter(); |
| 71 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 69 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| 72 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); | 70 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); |
| 73 if (isMainThread()) | 71 if (isMainThread()) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // gets called but before the Isolate exits. | 115 // gets called but before the Isolate exits. |
| 118 void V8PerIsolateData::destroy(v8::Isolate* isolate) { | 116 void V8PerIsolateData::destroy(v8::Isolate* isolate) { |
| 119 isolate->RemoveBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 117 isolate->RemoveBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| 120 isolate->RemoveMicrotasksCompletedCallback(µtasksCompletedCallback); | 118 isolate->RemoveMicrotasksCompletedCallback(µtasksCompletedCallback); |
| 121 V8PerIsolateData* data = from(isolate); | 119 V8PerIsolateData* data = from(isolate); |
| 122 | 120 |
| 123 // Clear everything before exiting the Isolate. | 121 // Clear everything before exiting the Isolate. |
| 124 if (data->m_scriptRegexpScriptState) | 122 if (data->m_scriptRegexpScriptState) |
| 125 data->m_scriptRegexpScriptState->disposePerContextData(); | 123 data->m_scriptRegexpScriptState->disposePerContextData(); |
| 126 data->m_liveRoot.clear(); | 124 data->m_liveRoot.clear(); |
| 127 data->m_hiddenValue.reset(); | |
| 128 data->m_privateProperty.reset(); | 125 data->m_privateProperty.reset(); |
| 129 data->m_stringCache->dispose(); | 126 data->m_stringCache->dispose(); |
| 130 data->m_stringCache.reset(); | 127 data->m_stringCache.reset(); |
| 131 data->m_interfaceTemplateMapForNonMainWorld.clear(); | 128 data->m_interfaceTemplateMapForNonMainWorld.clear(); |
| 132 data->m_interfaceTemplateMapForMainWorld.clear(); | 129 data->m_interfaceTemplateMapForMainWorld.clear(); |
| 133 data->m_operationTemplateMapForNonMainWorld.clear(); | 130 data->m_operationTemplateMapForNonMainWorld.clear(); |
| 134 data->m_operationTemplateMapForMainWorld.clear(); | 131 data->m_operationTemplateMapForMainWorld.clear(); |
| 135 if (isMainThread()) | 132 if (isMainThread()) |
| 136 mainThreadPerIsolateData = 0; | 133 mainThreadPerIsolateData = 0; |
| 137 | 134 |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 ScriptWrappableVisitor* current = currentVisitor(); | 310 ScriptWrappableVisitor* current = currentVisitor(); |
| 314 if (current) | 311 if (current) |
| 315 current->performCleanup(); | 312 current->performCleanup(); |
| 316 | 313 |
| 317 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( | 314 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( |
| 318 m_savedVisitor); | 315 m_savedVisitor); |
| 319 m_isolate->SetEmbedderHeapTracer(currentVisitor()); | 316 m_isolate->SetEmbedderHeapTracer(currentVisitor()); |
| 320 } | 317 } |
| 321 | 318 |
| 322 } // namespace blink | 319 } // namespace blink |
| OLD | NEW |