| 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 16 matching lines...) Expand all Loading... |
| 27 #include "sky/engine/bindings/core/v8/V8PerIsolateData.h" | 27 #include "sky/engine/bindings/core/v8/V8PerIsolateData.h" |
| 28 | 28 |
| 29 #include "sky/engine/bindings/core/v8/DOMDataStore.h" | 29 #include "sky/engine/bindings/core/v8/DOMDataStore.h" |
| 30 #include "sky/engine/bindings/core/v8/ScriptGCEvent.h" | 30 #include "sky/engine/bindings/core/v8/ScriptGCEvent.h" |
| 31 #include "sky/engine/bindings/core/v8/ScriptProfiler.h" | 31 #include "sky/engine/bindings/core/v8/ScriptProfiler.h" |
| 32 #include "sky/engine/bindings/core/v8/V8Binding.h" | 32 #include "sky/engine/bindings/core/v8/V8Binding.h" |
| 33 #include "sky/engine/bindings/core/v8/V8HiddenValue.h" | 33 #include "sky/engine/bindings/core/v8/V8HiddenValue.h" |
| 34 #include "sky/engine/bindings/core/v8/V8ObjectConstructor.h" | 34 #include "sky/engine/bindings/core/v8/V8ObjectConstructor.h" |
| 35 #include "sky/engine/bindings/core/v8/V8RecursionScope.h" | 35 #include "sky/engine/bindings/core/v8/V8RecursionScope.h" |
| 36 #include "sky/engine/bindings/core/v8/V8ScriptRunner.h" | 36 #include "sky/engine/bindings/core/v8/V8ScriptRunner.h" |
| 37 #include "sky/engine/core/frame/UseCounter.h" | |
| 38 #include "sky/engine/public/platform/Platform.h" | 37 #include "sky/engine/public/platform/Platform.h" |
| 39 #include "sky/engine/wtf/MainThread.h" | 38 #include "sky/engine/wtf/MainThread.h" |
| 40 | 39 |
| 41 namespace blink { | 40 namespace blink { |
| 42 | 41 |
| 43 static V8PerIsolateData* mainThreadPerIsolateData = 0; | 42 static V8PerIsolateData* mainThreadPerIsolateData = 0; |
| 44 | 43 |
| 45 #if ENABLE(ASSERT) | 44 #if ENABLE(ASSERT) |
| 46 static void assertV8RecursionScope() | 45 static void assertV8RecursionScope() |
| 47 { | 46 { |
| 48 ASSERT(V8RecursionScope::properlyUsed(v8::Isolate::GetCurrent())); | 47 ASSERT(V8RecursionScope::properlyUsed(v8::Isolate::GetCurrent())); |
| 49 } | 48 } |
| 50 #endif | 49 #endif |
| 51 | 50 |
| 52 static void useCounterCallback(v8::Isolate* isolate, v8::Isolate::UseCounterFeat
ure feature) | |
| 53 { | |
| 54 switch (feature) { | |
| 55 case v8::Isolate::kUseAsm: | |
| 56 UseCounter::count(currentExecutionContext(isolate), UseCounter::UseAsm); | |
| 57 break; | |
| 58 default: | |
| 59 ASSERT_NOT_REACHED(); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 V8PerIsolateData::V8PerIsolateData() | 51 V8PerIsolateData::V8PerIsolateData() |
| 64 : m_isolateHolder(adoptPtr(new gin::IsolateHolder())) | 52 : m_isolateHolder(adoptPtr(new gin::IsolateHolder())) |
| 65 , m_stringCache(adoptPtr(new StringCache(isolate()))) | 53 , m_stringCache(adoptPtr(new StringCache(isolate()))) |
| 66 , m_hiddenValue(adoptPtr(new V8HiddenValue())) | 54 , m_hiddenValue(adoptPtr(new V8HiddenValue())) |
| 67 , m_constructorMode(ConstructorMode::CreateNewObject) | 55 , m_constructorMode(ConstructorMode::CreateNewObject) |
| 68 , m_recursionLevel(0) | 56 , m_recursionLevel(0) |
| 69 , m_isHandlingRecursionLevelError(false) | 57 , m_isHandlingRecursionLevelError(false) |
| 70 #if ENABLE(ASSERT) | 58 #if ENABLE(ASSERT) |
| 71 , m_internalScriptRecursionLevel(0) | 59 , m_internalScriptRecursionLevel(0) |
| 72 #endif | 60 #endif |
| 73 , m_gcEventData(adoptPtr(new GCEventData())) | 61 , m_gcEventData(adoptPtr(new GCEventData())) |
| 74 , m_performingMicrotaskCheckpoint(false) | 62 , m_performingMicrotaskCheckpoint(false) |
| 75 { | 63 { |
| 76 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. | 64 // FIXME: Remove once all v8::Isolate::GetCurrent() calls are gone. |
| 77 isolate()->Enter(); | 65 isolate()->Enter(); |
| 78 #if ENABLE(ASSERT) | 66 #if ENABLE(ASSERT) |
| 79 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. | 67 // currentThread will always be non-null in production, but can be null in C
hromium unit tests. |
| 80 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); | 68 isolate()->AddCallCompletedCallback(&assertV8RecursionScope); |
| 81 #endif | 69 #endif |
| 82 if (isMainThread()) | 70 if (isMainThread()) |
| 83 mainThreadPerIsolateData = this; | 71 mainThreadPerIsolateData = this; |
| 84 isolate()->SetUseCounterCallback(&useCounterCallback); | |
| 85 } | 72 } |
| 86 | 73 |
| 87 V8PerIsolateData::~V8PerIsolateData() | 74 V8PerIsolateData::~V8PerIsolateData() |
| 88 { | 75 { |
| 89 if (m_scriptRegexpScriptState) | 76 if (m_scriptRegexpScriptState) |
| 90 m_scriptRegexpScriptState->disposePerContextData(); | 77 m_scriptRegexpScriptState->disposePerContextData(); |
| 91 if (isMainThread()) | 78 if (isMainThread()) |
| 92 mainThreadPerIsolateData = 0; | 79 mainThreadPerIsolateData = 0; |
| 93 } | 80 } |
| 94 | 81 |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 207 } |
| 221 | 208 |
| 222 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() | 209 v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate() |
| 223 { | 210 { |
| 224 if (m_toStringTemplate.isEmpty()) | 211 if (m_toStringTemplate.isEmpty()) |
| 225 m_toStringTemplate.set(isolate(), v8::FunctionTemplate::New(isolate(), c
onstructorOfToString)); | 212 m_toStringTemplate.set(isolate(), v8::FunctionTemplate::New(isolate(), c
onstructorOfToString)); |
| 226 return m_toStringTemplate.newLocal(isolate()); | 213 return m_toStringTemplate.newLocal(isolate()); |
| 227 } | 214 } |
| 228 | 215 |
| 229 } // namespace blink | 216 } // namespace blink |
| OLD | NEW |