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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 #endif | 158 #endif |
159 V8PerIsolateData* data = from(isolate); | 159 V8PerIsolateData* data = from(isolate); |
160 | 160 |
161 // Clear everything before exiting the Isolate. | 161 // Clear everything before exiting the Isolate. |
162 if (data->m_scriptRegexpScriptState) | 162 if (data->m_scriptRegexpScriptState) |
163 data->m_scriptRegexpScriptState->disposePerContextData(); | 163 data->m_scriptRegexpScriptState->disposePerContextData(); |
164 data->m_liveRoot.clear(); | 164 data->m_liveRoot.clear(); |
165 data->m_hiddenValue.clear(); | 165 data->m_hiddenValue.clear(); |
166 data->m_stringCache->dispose(); | 166 data->m_stringCache->dispose(); |
167 data->m_stringCache.clear(); | 167 data->m_stringCache.clear(); |
168 data->m_toStringTemplate.clear(); | |
169 data->m_domTemplateMapForNonMainWorld.clear(); | 168 data->m_domTemplateMapForNonMainWorld.clear(); |
170 data->m_domTemplateMapForMainWorld.clear(); | 169 data->m_domTemplateMapForMainWorld.clear(); |
171 if (isMainThread()) | 170 if (isMainThread()) |
172 mainThreadPerIsolateData = 0; | 171 mainThreadPerIsolateData = 0; |
173 | 172 |
174 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 173 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
175 isolate->Exit(); | 174 isolate->Exit(); |
176 delete data; | 175 delete data; |
177 } | 176 } |
178 | 177 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 { | 251 { |
253 if (value.IsEmpty() || !value->IsObject()) | 252 if (value.IsEmpty() || !value->IsObject()) |
254 return v8::Local<v8::Object>(); | 253 return v8::Local<v8::Object>(); |
255 DOMTemplateMap::iterator result = domTemplateMap.find(info); | 254 DOMTemplateMap::iterator result = domTemplateMap.find(info); |
256 if (result == domTemplateMap.end()) | 255 if (result == domTemplateMap.end()) |
257 return v8::Local<v8::Object>(); | 256 return v8::Local<v8::Object>(); |
258 v8::Local<v8::FunctionTemplate> templ = result->value.Get(isolate()); | 257 v8::Local<v8::FunctionTemplate> templ = result->value.Get(isolate()); |
259 return v8::Local<v8::Object>::Cast(value)->FindInstanceInPrototypeChain(temp
l); | 258 return v8::Local<v8::Object>::Cast(value)->FindInstanceInPrototypeChain(temp
l); |
260 } | 259 } |
261 | 260 |
262 static void constructorOfToString(const v8::FunctionCallbackInfo<v8::Value>& inf
o) | |
263 { | |
264 // The DOM constructors' toString functions grab the current toString | |
265 // for Functions by taking the toString function of itself and then | |
266 // calling it with the constructor as its receiver. This means that | |
267 // changes to the Function prototype chain or toString function are | |
268 // reflected when printing DOM constructors. The only wart is that | |
269 // changes to a DOM constructor's toString's toString will cause the | |
270 // toString of the DOM constructor itself to change. This is extremely | |
271 // obscure and unlikely to be a problem. | |
272 v8::Isolate* isolate = info.GetIsolate(); | |
273 v8::Local<v8::Value> value; | |
274 if (!info.Callee()->Get(isolate->GetCurrentContext(), v8AtomicString(isolate
, "toString")).ToLocal(&value) || !value->IsFunction()) { | |
275 v8SetReturnValue(info, v8::String::Empty(isolate)); | |
276 return; | |
277 } | |
278 v8::Local<v8::Value> result; | |
279 if (V8ScriptRunner::callInternalFunction(v8::Local<v8::Function>::Cast(value
), info.This(), 0, 0, isolate).ToLocal(&result)) | |
280 v8SetReturnValue(info, result); | |
281 } | |
282 | |
283 v8::Local<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | |
284 { | |
285 if (m_toStringTemplate.isEmpty()) | |
286 m_toStringTemplate.set(isolate(), v8::FunctionTemplate::New(isolate(), c
onstructorOfToString)); | |
287 return m_toStringTemplate.newLocal(isolate()); | |
288 } | |
289 | |
290 void V8PerIsolateData::addEndOfScopeTask(PassOwnPtr<EndOfScopeTask> task) | 261 void V8PerIsolateData::addEndOfScopeTask(PassOwnPtr<EndOfScopeTask> task) |
291 { | 262 { |
292 m_endOfScopeTasks.append(task); | 263 m_endOfScopeTasks.append(task); |
293 } | 264 } |
294 | 265 |
295 void V8PerIsolateData::runEndOfScopeTasks() | 266 void V8PerIsolateData::runEndOfScopeTasks() |
296 { | 267 { |
297 Vector<OwnPtr<EndOfScopeTask>> tasks; | 268 Vector<OwnPtr<EndOfScopeTask>> tasks; |
298 tasks.swap(m_endOfScopeTasks); | 269 tasks.swap(m_endOfScopeTasks); |
299 for (const auto& task : tasks) | 270 for (const auto& task : tasks) |
300 task->run(); | 271 task->run(); |
301 ASSERT(m_endOfScopeTasks.isEmpty()); | 272 ASSERT(m_endOfScopeTasks.isEmpty()); |
302 } | 273 } |
303 | 274 |
304 void V8PerIsolateData::clearEndOfScopeTasks() | 275 void V8PerIsolateData::clearEndOfScopeTasks() |
305 { | 276 { |
306 m_endOfScopeTasks.clear(); | 277 m_endOfScopeTasks.clear(); |
307 } | 278 } |
308 | 279 |
309 void V8PerIsolateData::setScriptDebugger(PassOwnPtr<ScriptDebuggerBase> debugger
) | 280 void V8PerIsolateData::setScriptDebugger(PassOwnPtr<ScriptDebuggerBase> debugger
) |
310 { | 281 { |
311 ASSERT(!m_scriptDebugger); | 282 ASSERT(!m_scriptDebugger); |
312 m_scriptDebugger = debugger; | 283 m_scriptDebugger = debugger; |
313 } | 284 } |
314 | 285 |
315 } // namespace blink | 286 } // namespace blink |
OLD | NEW |