| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 static void beforeCallEnteredCallback(v8::Isolate* isolate) | 45 static void beforeCallEnteredCallback(v8::Isolate* isolate) |
| 46 { | 46 { |
| 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 { | 51 { |
| 52 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); | 52 V8PerIsolateData::from(isolate)->runEndOfScopeTasks(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeat
ure feature) | 55 V8PerIsolateData::V8PerIsolateData() |
| 56 : m_isolateHolder(adoptPtr(new gin::IsolateHolder())) |
| 57 , m_stringCache(adoptPtr(new StringCache(isolate()))) |
| 58 , m_hiddenValue(V8HiddenValue::create()) |
| 59 , m_constructorMode(ConstructorMode::CreateNewObject) |
| 60 , m_useCounterDisabled(false) |
| 61 , m_isHandlingRecursionLevelError(false) |
| 62 , m_isReportingException(false) |
| 56 { | 63 { |
| 64 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
| 65 isolate()->Enter(); |
| 66 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); |
| 67 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); |
| 68 if (isMainThread()) |
| 69 mainThreadPerIsolateData = this; |
| 70 isolate()->SetUseCounterCallback(&useCounterCallback); |
| 71 } |
| 72 |
| 73 V8PerIsolateData::~V8PerIsolateData() |
| 74 { |
| 75 } |
| 76 |
| 77 v8::Isolate* V8PerIsolateData::mainThreadIsolate() |
| 78 { |
| 79 ASSERT(isMainThread()); |
| 80 ASSERT(mainThreadPerIsolateData); |
| 81 return mainThreadPerIsolateData->isolate(); |
| 82 } |
| 83 |
| 84 v8::Isolate* V8PerIsolateData::initialize() |
| 85 { |
| 86 V8PerIsolateData* data = new V8PerIsolateData(); |
| 87 v8::Isolate* isolate = data->isolate(); |
| 88 isolate->SetData(gin::kEmbedderBlink, data); |
| 89 return isolate; |
| 90 } |
| 91 |
| 92 void V8PerIsolateData::enableIdleTasks(v8::Isolate* isolate, PassOwnPtr<gin::V8I
dleTaskRunner> taskRunner) |
| 93 { |
| 94 from(isolate)->m_isolateHolder->EnableIdleTasks(std::unique_ptr<gin::V8IdleT
askRunner>(taskRunner.leakPtr())); |
| 95 } |
| 96 |
| 97 void V8PerIsolateData::useCounterCallback(v8::Isolate* isolate, v8::Isolate::Use
CounterFeature feature) |
| 98 { |
| 99 if (V8PerIsolateData::from(isolate)->m_useCounterDisabled) |
| 100 return; |
| 101 |
| 57 UseCounter::Feature blinkFeature; | 102 UseCounter::Feature blinkFeature; |
| 58 bool deprecated = false; | 103 bool deprecated = false; |
| 59 switch (feature) { | 104 switch (feature) { |
| 60 case v8::Isolate::kUseAsm: | 105 case v8::Isolate::kUseAsm: |
| 61 blinkFeature = UseCounter::UseAsm; | 106 blinkFeature = UseCounter::UseAsm; |
| 62 break; | 107 break; |
| 63 case v8::Isolate::kBreakIterator: | 108 case v8::Isolate::kBreakIterator: |
| 64 blinkFeature = UseCounter::BreakIterator; | 109 blinkFeature = UseCounter::BreakIterator; |
| 65 break; | 110 break; |
| 66 case v8::Isolate::kLegacyConst: | 111 case v8::Isolate::kLegacyConst: |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // This can happen if V8 has added counters that this version of Blink | 167 // This can happen if V8 has added counters that this version of Blink |
| 123 // does not know about. It's harmless. | 168 // does not know about. It's harmless. |
| 124 return; | 169 return; |
| 125 } | 170 } |
| 126 if (deprecated) | 171 if (deprecated) |
| 127 Deprecation::countDeprecation(currentExecutionContext(isolate), blinkFea
ture); | 172 Deprecation::countDeprecation(currentExecutionContext(isolate), blinkFea
ture); |
| 128 else | 173 else |
| 129 UseCounter::count(currentExecutionContext(isolate), blinkFeature); | 174 UseCounter::count(currentExecutionContext(isolate), blinkFeature); |
| 130 } | 175 } |
| 131 | 176 |
| 132 V8PerIsolateData::V8PerIsolateData() | |
| 133 : m_isolateHolder(adoptPtr(new gin::IsolateHolder())) | |
| 134 , m_stringCache(adoptPtr(new StringCache(isolate()))) | |
| 135 , m_hiddenValue(V8HiddenValue::create()) | |
| 136 , m_constructorMode(ConstructorMode::CreateNewObject) | |
| 137 , m_isHandlingRecursionLevelError(false) | |
| 138 , m_isReportingException(false) | |
| 139 { | |
| 140 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | |
| 141 isolate()->Enter(); | |
| 142 isolate()->AddBeforeCallEnteredCallback(&beforeCallEnteredCallback); | |
| 143 isolate()->AddMicrotasksCompletedCallback(µtasksCompletedCallback); | |
| 144 if (isMainThread()) | |
| 145 mainThreadPerIsolateData = this; | |
| 146 isolate()->SetUseCounterCallback(&useCounterCallback); | |
| 147 } | |
| 148 | |
| 149 V8PerIsolateData::~V8PerIsolateData() | |
| 150 { | |
| 151 } | |
| 152 | |
| 153 v8::Isolate* V8PerIsolateData::mainThreadIsolate() | |
| 154 { | |
| 155 ASSERT(isMainThread()); | |
| 156 ASSERT(mainThreadPerIsolateData); | |
| 157 return mainThreadPerIsolateData->isolate(); | |
| 158 } | |
| 159 | |
| 160 v8::Isolate* V8PerIsolateData::initialize() | |
| 161 { | |
| 162 V8PerIsolateData* data = new V8PerIsolateData(); | |
| 163 v8::Isolate* isolate = data->isolate(); | |
| 164 isolate->SetData(gin::kEmbedderBlink, data); | |
| 165 return isolate; | |
| 166 } | |
| 167 | |
| 168 void V8PerIsolateData::enableIdleTasks(v8::Isolate* isolate, PassOwnPtr<gin::V8I
dleTaskRunner> taskRunner) | |
| 169 { | |
| 170 from(isolate)->m_isolateHolder->EnableIdleTasks(std::unique_ptr<gin::V8IdleT
askRunner>(taskRunner.leakPtr())); | |
| 171 } | |
| 172 | |
| 173 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() | 177 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() |
| 174 { | 178 { |
| 175 if (m_liveRoot.isEmpty()) | 179 if (m_liveRoot.isEmpty()) |
| 176 m_liveRoot.set(isolate(), v8::Null(isolate())); | 180 m_liveRoot.set(isolate(), v8::Null(isolate())); |
| 177 return m_liveRoot.getUnsafe(); | 181 return m_liveRoot.getUnsafe(); |
| 178 } | 182 } |
| 179 | 183 |
| 180 // willBeDestroyed() clear things that should be cleared before | 184 // willBeDestroyed() clear things that should be cleared before |
| 181 // ThreadState::detach() gets called. | 185 // ThreadState::detach() gets called. |
| 182 void V8PerIsolateData::willBeDestroyed(v8::Isolate* isolate) | 186 void V8PerIsolateData::willBeDestroyed(v8::Isolate* isolate) |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 ASSERT(!m_threadDebugger); | 336 ASSERT(!m_threadDebugger); |
| 333 m_threadDebugger = std::move(threadDebugger); | 337 m_threadDebugger = std::move(threadDebugger); |
| 334 } | 338 } |
| 335 | 339 |
| 336 ThreadDebugger* V8PerIsolateData::threadDebugger() | 340 ThreadDebugger* V8PerIsolateData::threadDebugger() |
| 337 { | 341 { |
| 338 return m_threadDebugger.get(); | 342 return m_threadDebugger.get(); |
| 339 } | 343 } |
| 340 | 344 |
| 341 } // namespace blink | 345 } // namespace blink |
| OLD | NEW |