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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 static void beforeCallEnteredCallback(v8::Isolate* isolate) { | 48 static void beforeCallEnteredCallback(v8::Isolate* isolate) { |
49 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 49 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
50 } | 50 } |
51 | 51 |
52 static void microtasksCompletedCallback(v8::Isolate* isolate) { | 52 static void microtasksCompletedCallback(v8::Isolate* isolate) { |
53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); | 53 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
54 } | 54 } |
55 | 55 |
56 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) | 56 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) |
57 : m_isolateHolder(WTF::makeUnique<gin::IsolateHolder>( | 57 : m_isolateHolder( |
58 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, | 58 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, |
59 gin::IsolateHolder::kSingleThread, | 59 gin::IsolateHolder::kSingleThread, |
60 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait | 60 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait |
61 : gin::IsolateHolder::kAllowAtomicsWait)), | 61 : gin::IsolateHolder::kAllowAtomicsWait), |
62 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), | 62 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), |
63 m_hiddenValue(V8HiddenValue::create()), | 63 m_hiddenValue(V8HiddenValue::create()), |
64 m_privateProperty(V8PrivateProperty::create()), | 64 m_privateProperty(V8PrivateProperty::create()), |
65 m_constructorMode(ConstructorMode::CreateNewObject), | 65 m_constructorMode(ConstructorMode::CreateNewObject), |
66 m_useCounterDisabled(false), | 66 m_useCounterDisabled(false), |
67 m_isHandlingRecursionLevelError(false), | 67 m_isHandlingRecursionLevelError(false), |
68 m_isReportingException(false) { | 68 m_isReportingException(false) { |
69 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 69 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
70 isolate()->Enter(); | 70 isolate()->Enter(); |
71 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 71 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
(...skipping 12 matching lines...) Expand all Loading... |
84 v8::Isolate* V8PerIsolateData::initialize(WebTaskRunner* taskRunner) { | 84 v8::Isolate* V8PerIsolateData::initialize(WebTaskRunner* taskRunner) { |
85 V8PerIsolateData* data = new V8PerIsolateData(taskRunner); | 85 V8PerIsolateData* data = new V8PerIsolateData(taskRunner); |
86 v8::Isolate* isolate = data->isolate(); | 86 v8::Isolate* isolate = data->isolate(); |
87 isolate->SetData(gin::kEmbedderBlink, data); | 87 isolate->SetData(gin::kEmbedderBlink, data); |
88 return isolate; | 88 return isolate; |
89 } | 89 } |
90 | 90 |
91 void V8PerIsolateData::enableIdleTasks( | 91 void V8PerIsolateData::enableIdleTasks( |
92 v8::Isolate* isolate, | 92 v8::Isolate* isolate, |
93 std::unique_ptr<gin::V8IdleTaskRunner> taskRunner) { | 93 std::unique_ptr<gin::V8IdleTaskRunner> taskRunner) { |
94 from(isolate)->m_isolateHolder->EnableIdleTasks( | 94 from(isolate)->m_isolateHolder.EnableIdleTasks(std::move(taskRunner)); |
95 std::unique_ptr<gin::V8IdleTaskRunner>(taskRunner.release())); | |
96 } | 95 } |
97 | 96 |
98 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() { | 97 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() { |
99 if (m_liveRoot.isEmpty()) | 98 if (m_liveRoot.isEmpty()) |
100 m_liveRoot.set(isolate(), v8::Null(isolate())); | 99 m_liveRoot.set(isolate(), v8::Null(isolate())); |
101 return m_liveRoot.get(); | 100 return m_liveRoot.get(); |
102 } | 101 } |
103 | 102 |
104 // willBeDestroyed() clear things that should be cleared before | 103 // willBeDestroyed() clear things that should be cleared before |
105 // ThreadState::detach() gets called. | 104 // ThreadState::detach() gets called. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ScriptWrappableVisitor* current = currentVisitor(); | 313 ScriptWrappableVisitor* current = currentVisitor(); |
315 if (current) | 314 if (current) |
316 current->performCleanup(); | 315 current->performCleanup(); |
317 | 316 |
318 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( | 317 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( |
319 m_savedVisitor); | 318 m_savedVisitor); |
320 m_isolate->SetEmbedderHeapTracer(currentVisitor()); | 319 m_isolate->SetEmbedderHeapTracer(currentVisitor()); |
321 } | 320 } |
322 | 321 |
323 } // namespace blink | 322 } // namespace blink |
OLD | NEW |