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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 namespace blink { | 42 namespace blink { |
43 | 43 |
44 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 44 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
45 | 45 |
46 static void beforeCallEnteredCallback(v8::Isolate* isolate) | 46 static void beforeCallEnteredCallback(v8::Isolate* isolate) |
47 { | 47 { |
48 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 48 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
49 } | 49 } |
50 | 50 |
| 51 static void microtasksCompletedCallback(v8::Isolate* isolate) |
| 52 { |
| 53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
| 54 } |
| 55 |
51 #if ENABLE(ASSERT) | 56 #if ENABLE(ASSERT) |
52 static void assertV8RecursionScope(v8::Isolate* isolate) | 57 static void assertV8RecursionScope(v8::Isolate* isolate) |
53 { | 58 { |
54 ASSERT(V8RecursionScope::properlyUsed(isolate)); | 59 ASSERT(V8RecursionScope::properlyUsed(isolate)); |
55 } | 60 } |
56 | 61 |
57 static bool runningUnitTest() | 62 static bool runningUnitTest() |
58 { | 63 { |
59 return Platform::current()->unitTestSupport(); | 64 return Platform::current()->unitTestSupport(); |
60 } | 65 } |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 #endif | 156 #endif |
152 , m_performingMicrotaskCheckpoint(false) | 157 , m_performingMicrotaskCheckpoint(false) |
153 { | 158 { |
154 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 159 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
155 isolate()->Enter(); | 160 isolate()->Enter(); |
156 #if ENABLE(ASSERT) | 161 #if ENABLE(ASSERT) |
157 if (!runningUnitTest()) | 162 if (!runningUnitTest()) |
158 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); | 163 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); |
159 #endif | 164 #endif |
160 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 165 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| 166 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); |
161 if (isMainThread()) | 167 if (isMainThread()) |
162 mainThreadPerIsolateData = this; | 168 mainThreadPerIsolateData = this; |
163 isolate()->SetUseCounterCallback(&useCounterCallback); | 169 isolate()->SetUseCounterCallback(&useCounterCallback); |
164 } | 170 } |
165 | 171 |
166 V8PerIsolateData::~V8PerIsolateData() | 172 V8PerIsolateData::~V8PerIsolateData() |
167 { | 173 { |
168 } | 174 } |
169 | 175 |
170 v8::Isolate* V8PerIsolateData::mainThreadIsolate() | 176 v8::Isolate* V8PerIsolateData::mainThreadIsolate() |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 | 217 |
212 // destroy() clear things that should be cleared after ThreadState::detach() | 218 // destroy() clear things that should be cleared after ThreadState::detach() |
213 // gets called but before the Isolate exits. | 219 // gets called but before the Isolate exits. |
214 void V8PerIsolateData::destroy(v8::Isolate* isolate) | 220 void V8PerIsolateData::destroy(v8::Isolate* isolate) |
215 { | 221 { |
216 #if ENABLE(ASSERT) | 222 #if ENABLE(ASSERT) |
217 if (!runningUnitTest()) | 223 if (!runningUnitTest()) |
218 isolate->RemoveCallCompletedCallback(&assertV8RecursionScope); | 224 isolate->RemoveCallCompletedCallback(&assertV8RecursionScope); |
219 #endif | 225 #endif |
220 isolate->RemoveBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 226 isolate->RemoveBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| 227 isolate->RemoveMicrotasksCompletedCallback(µtasksCompletedCallback); |
221 V8PerIsolateData* data = from(isolate); | 228 V8PerIsolateData* data = from(isolate); |
222 | 229 |
223 // Clear everything before exiting the Isolate. | 230 // Clear everything before exiting the Isolate. |
224 if (data->m_scriptRegexpScriptState) | 231 if (data->m_scriptRegexpScriptState) |
225 data->m_scriptRegexpScriptState->disposePerContextData(); | 232 data->m_scriptRegexpScriptState->disposePerContextData(); |
226 data->m_liveRoot.clear(); | 233 data->m_liveRoot.clear(); |
227 data->m_hiddenValue.clear(); | 234 data->m_hiddenValue.clear(); |
228 data->m_stringCache->dispose(); | 235 data->m_stringCache->dispose(); |
229 data->m_stringCache.clear(); | 236 data->m_stringCache.clear(); |
230 data->m_domTemplateMapForNonMainWorld.clear(); | 237 data->m_domTemplateMapForNonMainWorld.clear(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 ASSERT(!m_threadDebugger); | 352 ASSERT(!m_threadDebugger); |
346 m_threadDebugger = std::move(threadDebugger); | 353 m_threadDebugger = std::move(threadDebugger); |
347 } | 354 } |
348 | 355 |
349 ThreadDebugger* V8PerIsolateData::threadDebugger() | 356 ThreadDebugger* V8PerIsolateData::threadDebugger() |
350 { | 357 { |
351 return m_threadDebugger.get(); | 358 return m_threadDebugger.get(); |
352 } | 359 } |
353 | 360 |
354 } // namespace blink | 361 } // namespace blink |
OLD | NEW |