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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); | 47 RELEASE_ASSERT(!ScriptForbiddenScope::isScriptForbidden()); |
48 } | 48 } |
49 | 49 |
50 static void microtasksCompletedCallback(v8::Isolate* isolate) { | 50 static void microtasksCompletedCallback(v8::Isolate* isolate) { |
51 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); | 51 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
52 } | 52 } |
53 | 53 |
54 V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner) | 54 V8PerIsolateData::V8PerIsolateData( |
55 : m_isolateHolder(WTF::makeUnique<gin::IsolateHolder>( | 55 std::unique_ptr<gin::IsolateHolder> isolateHolder) |
56 taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr, | 56 : m_isolateHolder(std::move(isolateHolder)), |
57 gin::IsolateHolder::kSingleThread, | |
58 isMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait | |
59 : gin::IsolateHolder::kAllowAtomicsWait)), | |
60 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), | 57 m_stringCache(WTF::wrapUnique(new StringCache(isolate()))), |
61 m_hiddenValue(V8HiddenValue::create()), | 58 m_hiddenValue(V8HiddenValue::create()), |
62 m_privateProperty(V8PrivateProperty::create()), | 59 m_privateProperty(V8PrivateProperty::create()), |
63 m_constructorMode(ConstructorMode::CreateNewObject), | 60 m_constructorMode(ConstructorMode::CreateNewObject), |
64 m_useCounterDisabled(false), | 61 m_useCounterDisabled(false), |
65 m_isHandlingRecursionLevelError(false), | 62 m_isHandlingRecursionLevelError(false), |
66 m_isReportingException(false) { | 63 m_isReportingException(false) { |
67 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 64 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
68 isolate()->Enter(); | 65 isolate()->Enter(); |
69 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | 66 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
70 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); | 67 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); |
71 if (isMainThread()) | 68 if (isMainThread()) |
72 mainThreadPerIsolateData = this; | 69 mainThreadPerIsolateData = this; |
73 } | 70 } |
74 | 71 |
75 V8PerIsolateData::~V8PerIsolateData() {} | 72 V8PerIsolateData::~V8PerIsolateData() {} |
76 | 73 |
77 v8::Isolate* V8PerIsolateData::mainThreadIsolate() { | 74 v8::Isolate* V8PerIsolateData::mainThreadIsolate() { |
78 ASSERT(mainThreadPerIsolateData); | 75 ASSERT(mainThreadPerIsolateData); |
79 return mainThreadPerIsolateData->isolate(); | 76 return mainThreadPerIsolateData->isolate(); |
80 } | 77 } |
81 | 78 |
82 v8::Isolate* V8PerIsolateData::initialize(WebTaskRunner* taskRunner) { | 79 v8::Isolate* V8PerIsolateData::initialize( |
83 V8PerIsolateData* data = new V8PerIsolateData(taskRunner); | 80 std::unique_ptr<gin::IsolateHolder> isolateHolder) { |
| 81 V8PerIsolateData* data = new V8PerIsolateData(std::move(isolateHolder)); |
84 v8::Isolate* isolate = data->isolate(); | 82 v8::Isolate* isolate = data->isolate(); |
85 isolate->SetData(gin::kEmbedderBlink, data); | 83 isolate->SetData(gin::kEmbedderBlink, data); |
86 return isolate; | 84 return isolate; |
87 } | 85 } |
88 | 86 |
89 void V8PerIsolateData::enableIdleTasks( | 87 void V8PerIsolateData::enableIdleTasks( |
90 v8::Isolate* isolate, | 88 v8::Isolate* isolate, |
91 std::unique_ptr<gin::V8IdleTaskRunner> taskRunner) { | 89 std::unique_ptr<gin::V8IdleTaskRunner> taskRunner) { |
92 from(isolate)->m_isolateHolder->EnableIdleTasks( | 90 from(isolate)->m_isolateHolder->EnableIdleTasks( |
93 std::unique_ptr<gin::V8IdleTaskRunner>(taskRunner.release())); | 91 std::unique_ptr<gin::V8IdleTaskRunner>(taskRunner.release())); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 ScriptWrappableVisitor* current = currentVisitor(); | 287 ScriptWrappableVisitor* current = currentVisitor(); |
290 if (current) | 288 if (current) |
291 current->performCleanup(); | 289 current->performCleanup(); |
292 | 290 |
293 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( | 291 V8PerIsolateData::from(m_isolate)->m_scriptWrappableVisitor.swap( |
294 m_savedVisitor); | 292 m_savedVisitor); |
295 m_isolate->SetEmbedderHeapTracer(currentVisitor()); | 293 m_isolate->SetEmbedderHeapTracer(currentVisitor()); |
296 } | 294 } |
297 | 295 |
298 } // namespace blink | 296 } // namespace blink |
OLD | NEW |