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 25 matching lines...) Expand all Loading... |
36 #include "bindings/core/v8/V8RecursionScope.h" | 36 #include "bindings/core/v8/V8RecursionScope.h" |
37 #include "bindings/core/v8/V8ScriptRunner.h" | 37 #include "bindings/core/v8/V8ScriptRunner.h" |
38 #include "core/frame/UseCounter.h" | 38 #include "core/frame/UseCounter.h" |
39 #include "public/platform/Platform.h" | 39 #include "public/platform/Platform.h" |
40 #include "wtf/MainThread.h" | 40 #include "wtf/MainThread.h" |
41 | 41 |
42 namespace WebCore { | 42 namespace WebCore { |
43 | 43 |
44 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 44 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
45 | 45 |
46 #ifndef NDEBUG | 46 #if ENABLE(ASSERT) |
47 static void assertV8RecursionScope() | 47 static void assertV8RecursionScope() |
48 { | 48 { |
49 ASSERT(V8RecursionScope::properlyUsed(v8::Isolate::GetCurrent())); | 49 ASSERT(V8RecursionScope::properlyUsed(v8::Isolate::GetCurrent())); |
50 } | 50 } |
51 #endif | 51 #endif |
52 | 52 |
53 static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeat
ure feature) | 53 static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeat
ure feature) |
54 { | 54 { |
55 switch (feature) { | 55 switch (feature) { |
56 case v8::Isolate::kUseAsm: | 56 case v8::Isolate::kUseAsm: |
57 UseCounter::count(currentExecutionContext(isolate), UseCounter::UseAsm); | 57 UseCounter::count(currentExecutionContext(isolate), UseCounter::UseAsm); |
58 break; | 58 break; |
59 default: | 59 default: |
60 ASSERT_NOT_REACHED(); | 60 ASSERT_NOT_REACHED(); |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) | 64 V8PerIsolateData::V8PerIsolateData(v8::Isolate* isolate) |
65 : m_isolate(isolate) | 65 : m_isolate(isolate) |
66 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) | 66 , m_isolateHolder(adoptPtr(new gin::IsolateHolder(m_isolate, v8ArrayBufferAl
locator()))) |
67 , m_stringCache(adoptPtr(new StringCache(m_isolate))) | 67 , m_stringCache(adoptPtr(new StringCache(m_isolate))) |
68 , m_hiddenValue(adoptPtr(new V8HiddenValue())) | 68 , m_hiddenValue(adoptPtr(new V8HiddenValue())) |
69 , m_constructorMode(ConstructorMode::CreateNewObject) | 69 , m_constructorMode(ConstructorMode::CreateNewObject) |
70 , m_recursionLevel(0) | 70 , m_recursionLevel(0) |
71 , m_isHandlingRecursionLevelError(false) | 71 , m_isHandlingRecursionLevelError(false) |
72 #ifndef NDEBUG | 72 #if ENABLE(ASSERT) |
73 , m_internalScriptRecursionLevel(0) | 73 , m_internalScriptRecursionLevel(0) |
74 #endif | 74 #endif |
75 , m_gcEventData(adoptPtr(new GCEventData())) | 75 , m_gcEventData(adoptPtr(new GCEventData())) |
76 , m_performingMicrotaskCheckpoint(false) | 76 , m_performingMicrotaskCheckpoint(false) |
77 { | 77 { |
78 #ifndef NDEBUG | 78 #if ENABLE(ASSERT) |
79 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. | 79 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. |
80 if (blink::Platform::current()->currentThread()) | 80 if (blink::Platform::current()->currentThread()) |
81 isolate->AddCallCompletedCallback(&assertV8RecursionScope); | 81 isolate->AddCallCompletedCallback(&assertV8RecursionScope); |
82 #endif | 82 #endif |
83 if (isMainThread()) { | 83 if (isMainThread()) { |
84 mainThreadPerIsolateData = this; | 84 mainThreadPerIsolateData = this; |
85 PageScriptDebugServer::setMainThreadIsolate(isolate); | 85 PageScriptDebugServer::setMainThreadIsolate(isolate); |
86 } | 86 } |
87 isolate->SetUseCounterCallback(&useCounterCallback); | 87 isolate->SetUseCounterCallback(&useCounterCallback); |
88 } | 88 } |
(...skipping 24 matching lines...) Expand all Loading... |
113 | 113 |
114 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() | 114 v8::Persistent<v8::Value>& V8PerIsolateData::ensureLiveRoot() |
115 { | 115 { |
116 if (m_liveRoot.isEmpty()) | 116 if (m_liveRoot.isEmpty()) |
117 m_liveRoot.set(m_isolate, v8::Null(m_isolate)); | 117 m_liveRoot.set(m_isolate, v8::Null(m_isolate)); |
118 return m_liveRoot.getUnsafe(); | 118 return m_liveRoot.getUnsafe(); |
119 } | 119 } |
120 | 120 |
121 void V8PerIsolateData::dispose(v8::Isolate* isolate) | 121 void V8PerIsolateData::dispose(v8::Isolate* isolate) |
122 { | 122 { |
123 #ifndef NDEBUG | 123 #if ENABLE(ASSERT) |
124 if (blink::Platform::current()->currentThread()) | 124 if (blink::Platform::current()->currentThread()) |
125 isolate->RemoveCallCompletedCallback(&assertV8RecursionScope); | 125 isolate->RemoveCallCompletedCallback(&assertV8RecursionScope); |
126 #endif | 126 #endif |
127 void* data = isolate->GetData(gin::kEmbedderBlink); | 127 void* data = isolate->GetData(gin::kEmbedderBlink); |
128 delete static_cast<V8PerIsolateData*>(data); | 128 delete static_cast<V8PerIsolateData*>(data); |
129 isolate->SetData(gin::kEmbedderBlink, 0); | 129 isolate->SetData(gin::kEmbedderBlink, 0); |
130 } | 130 } |
131 | 131 |
132 V8PerIsolateData::DOMTemplateMap& V8PerIsolateData::currentDOMTemplateMap() | 132 V8PerIsolateData::DOMTemplateMap& V8PerIsolateData::currentDOMTemplateMap() |
133 { | 133 { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 226 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
227 { | 227 { |
228 if (m_toStringTemplate.isEmpty()) | 228 if (m_toStringTemplate.isEmpty()) |
229 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); | 229 m_toStringTemplate.set(m_isolate, v8::FunctionTemplate::New(m_isolate, c
onstructorOfToString)); |
230 return m_toStringTemplate.newLocal(m_isolate); | 230 return m_toStringTemplate.newLocal(m_isolate); |
231 } | 231 } |
232 | 232 |
233 } // namespace WebCore | 233 } // namespace WebCore |
OLD | NEW |