Merge from Chromium at DEPS revision 262940
This commit was generated by merge_to_master.py.
Change-Id: I767658f35150c8e0099156a5a5daf4bdf7e8ae0f
diff --git a/Source/bindings/v8/CallbackPromiseAdapter.h b/Source/bindings/v8/CallbackPromiseAdapter.h
index f8a36a6..612dfb9 100644
--- a/Source/bindings/v8/CallbackPromiseAdapter.h
+++ b/Source/bindings/v8/CallbackPromiseAdapter.h
@@ -31,7 +31,7 @@
#ifndef CallbackPromiseAdapter_h
#define CallbackPromiseAdapter_h
-#include "bindings/v8/DOMRequestState.h"
+#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScriptPromiseResolver.h"
#include "public/platform/WebCallbacks.h"
@@ -63,26 +63,26 @@
template<typename S, typename T>
class CallbackPromiseAdapter FINAL : public blink::WebCallbacks<typename S::WebType, typename T::WebType> {
public:
- explicit CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver, ExecutionContext* context)
+ CallbackPromiseAdapter(PassRefPtr<ScriptPromiseResolver> resolver, ExecutionContext* context)
: m_resolver(resolver)
- , m_requestState(context)
+ , m_scriptState(NewScriptState::current(toIsolate(context)))
{
}
virtual ~CallbackPromiseAdapter() { }
virtual void onSuccess(typename S::WebType* result) OVERRIDE
{
- DOMRequestState::Scope scope(m_requestState);
+ NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(S::from(result));
}
virtual void onError(typename T::WebType* error) OVERRIDE
{
- DOMRequestState::Scope scope(m_requestState);
+ NewScriptState::Scope scope(m_scriptState.get());
m_resolver->reject(T::from(error));
}
private:
RefPtr<ScriptPromiseResolver> m_resolver;
- DOMRequestState m_requestState;
+ RefPtr<NewScriptState> m_scriptState;
WTF_MAKE_NONCOPYABLE(CallbackPromiseAdapter);
};
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.cpp b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
index b4e4e84..5084d76 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.cpp
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.cpp
@@ -40,8 +40,6 @@
#include "bindings/v8/DOMWrapperWorld.h"
#include "bindings/v8/Dictionary.h"
#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/ScriptState.h"
-#include "bindings/v8/UnsafePersistent.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8PerContextData.h"
@@ -56,17 +54,17 @@
static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>&);
-CustomElementConstructorBuilder::CustomElementConstructorBuilder(ScriptState* state, const Dictionary* options)
- : m_context(state->context())
+CustomElementConstructorBuilder::CustomElementConstructorBuilder(NewScriptState* scriptState, const Dictionary* options)
+ : m_scriptState(scriptState)
, m_options(options)
, m_wrapperType(0)
{
- ASSERT(m_context == v8::Isolate::GetCurrent()->GetCurrentContext());
+ ASSERT(m_scriptState->context() == v8::Isolate::GetCurrent()->GetCurrentContext());
}
bool CustomElementConstructorBuilder::isFeatureAllowed() const
{
- return DOMWrapperWorld::world(m_context).isMainWorld();
+ return m_scriptState->world().isMainWorld();
}
bool CustomElementConstructorBuilder::validateOptions(const AtomicString& type, QualifiedName& tagName, ExceptionState& exceptionState)
@@ -81,8 +79,8 @@
}
m_prototype = prototypeScriptValue.v8Value().As<v8::Object>();
} else {
- m_prototype = v8::Object::New(m_context->GetIsolate());
- v8::Local<v8::Object> basePrototype = V8PerContextData::from(m_context)->prototypeForType(&V8HTMLElement::wrapperTypeInfo);
+ m_prototype = v8::Object::New(m_scriptState->isolate());
+ v8::Local<v8::Object> basePrototype = m_scriptState->perContextData()->prototypeForType(&V8HTMLElement::wrapperTypeInfo);
if (!basePrototype.IsEmpty())
m_prototype->SetPrototype(basePrototype);
}
@@ -90,7 +88,7 @@
AtomicString extends;
bool extendsProvidedAndNonNull = m_options->get("extends", extends);
- if (!V8PerContextData::from(m_context)) {
+ if (!m_scriptState->perContextData()) {
// FIXME: This should generate an InvalidContext exception at a later point.
CustomElementException::throwException(CustomElementException::ContextDestroyedCheckingPrototype, type, exceptionState);
return false;
@@ -137,7 +135,7 @@
{
ASSERT(!m_prototype.IsEmpty());
- RefPtr<ExecutionContext> executionContext(toExecutionContext(m_context));
+ RefPtr<ExecutionContext> executionContext = m_scriptState->executionContext();
v8::TryCatch exceptionCatcher;
exceptionCatcher.SetVerbose(true);
@@ -166,7 +164,7 @@
ASSERT(m_constructor.IsEmpty());
ASSERT(document);
- v8::Isolate* isolate = m_context->GetIsolate();
+ v8::Isolate* isolate = m_scriptState->isolate();
if (!prototypeIsValid(definition->descriptor().type(), exceptionState))
return false;
@@ -190,7 +188,7 @@
m_constructor->SetName(v8Type->IsNull() ? v8TagName : v8Type.As<v8::String>());
- V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementDocument(isolate), toV8(document, m_context->Global(), isolate));
+ V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementDocument(isolate), toV8(document, m_scriptState->context()->Global(), isolate));
V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementNamespaceURI(isolate), v8String(isolate, descriptor.namespaceURI()));
V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementTagName(isolate), v8TagName);
V8HiddenValue::setHiddenValue(isolate, m_constructor, V8HiddenValue::customElementType(isolate), v8Type);
@@ -214,12 +212,12 @@
bool CustomElementConstructorBuilder::prototypeIsValid(const AtomicString& type, ExceptionState& exceptionState) const
{
- if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_context->GetIsolate(), m_prototype, V8HiddenValue::customElementIsInterfacePrototypeObject(m_context->GetIsolate())).IsEmpty()) {
+ if (m_prototype->InternalFieldCount() || !V8HiddenValue::getHiddenValue(m_scriptState->isolate(), m_prototype, V8HiddenValue::customElementIsInterfacePrototypeObject(m_scriptState->isolate())).IsEmpty()) {
CustomElementException::throwException(CustomElementException::PrototypeInUse, type, exceptionState);
return false;
}
- if (m_prototype->GetPropertyAttributes(v8String(m_context->GetIsolate(), "constructor")) & v8::DontDelete) {
+ if (m_prototype->GetPropertyAttributes(v8String(m_scriptState->isolate(), "constructor")) & v8::DontDelete) {
CustomElementException::throwException(CustomElementException::ConstructorPropertyNotConfigurable, type, exceptionState);
return false;
}
@@ -231,17 +229,17 @@
{
ASSERT(!m_constructor.IsEmpty());
- return m_callbacks->setBinding(definition, CustomElementBinding::create(m_context->GetIsolate(), m_prototype, m_wrapperType));
+ return m_callbacks->setBinding(definition, CustomElementBinding::create(m_scriptState->isolate(), m_prototype, m_wrapperType));
}
ScriptValue CustomElementConstructorBuilder::bindingsReturnValue() const
{
- return ScriptValue(m_constructor, m_context->GetIsolate());
+ return ScriptValue(m_constructor, m_scriptState->isolate());
}
bool CustomElementConstructorBuilder::hasValidPrototypeChainFor(const WrapperTypeInfo* type) const
{
- v8::Handle<v8::Object> elementPrototype = V8PerContextData::from(m_context)->prototypeForType(type);
+ v8::Handle<v8::Object> elementPrototype = m_scriptState->perContextData()->prototypeForType(type);
if (elementPrototype.IsEmpty())
return false;
diff --git a/Source/bindings/v8/CustomElementConstructorBuilder.h b/Source/bindings/v8/CustomElementConstructorBuilder.h
index 21f81e8..2ea707f 100644
--- a/Source/bindings/v8/CustomElementConstructorBuilder.h
+++ b/Source/bindings/v8/CustomElementConstructorBuilder.h
@@ -60,7 +60,7 @@
class CustomElementConstructorBuilder {
WTF_MAKE_NONCOPYABLE(CustomElementConstructorBuilder);
public:
- CustomElementConstructorBuilder(ScriptState*, const Dictionary* options);
+ CustomElementConstructorBuilder(NewScriptState*, const Dictionary* options);
// The builder accumulates state and may run script at specific
// points. These methods must be called in order. When one fails
@@ -82,7 +82,7 @@
bool prototypeIsValid(const AtomicString& type, ExceptionState&) const;
v8::Handle<v8::Function> retrieveCallback(v8::Isolate*, const char* name);
- v8::Handle<v8::Context> m_context;
+ RefPtr<NewScriptState> m_scriptState;
const Dictionary* m_options;
v8::Handle<v8::Object> m_prototype;
const WrapperTypeInfo* m_wrapperType;
diff --git a/Source/bindings/v8/DOMRequestState.h b/Source/bindings/v8/DOMRequestState.h
index 59af33f..43e6bb0 100644
--- a/Source/bindings/v8/DOMRequestState.h
+++ b/Source/bindings/v8/DOMRequestState.h
@@ -37,18 +37,9 @@
// FIXME: DOMRequestState is deprecated and going to be removed. Use NewScriptState instead.
class DOMRequestState {
public:
- explicit DOMRequestState(ExecutionContext* executionContext)
- : m_isolate(toIsolate(executionContext))
- , m_executionContext(executionContext)
- , m_world(DOMWrapperWorld::current(m_isolate))
+ explicit DOMRequestState(v8::Isolate* isolate)
+ : m_scriptState(NewScriptState::current(isolate))
{
- ASSERT(m_executionContext);
- }
-
- void clear()
- {
- m_executionContext = 0;
- m_world.clear();
}
class Scope {
@@ -63,23 +54,13 @@
v8::Context::Scope m_contextScope;
};
- v8::Local<v8::Context> context()
- {
- ASSERT(m_executionContext);
- return toV8Context(m_executionContext, *m_world);
- }
-
- v8::Isolate* isolate() const
- {
- return m_isolate;
- }
-
- bool isValid() const { return m_executionContext; }
+ void clear() { m_scriptState.clear(); }
+ v8::Local<v8::Context> context() { return m_scriptState->context(); }
+ v8::Isolate* isolate() const { return m_scriptState->isolate(); }
+ bool isValid() const { return m_scriptState; }
private:
- v8::Isolate* m_isolate;
- ExecutionContext* m_executionContext;
- RefPtr<DOMWrapperWorld> m_world;
+ RefPtr<NewScriptState> m_scriptState;
};
}
diff --git a/Source/bindings/v8/DOMWrapperMap.h b/Source/bindings/v8/DOMWrapperMap.h
index 20fe762..a2eb2d3 100644
--- a/Source/bindings/v8/DOMWrapperMap.h
+++ b/Source/bindings/v8/DOMWrapperMap.h
@@ -31,8 +31,8 @@
#ifndef DOMWrapperMap_h
#define DOMWrapperMap_h
-#include "bindings/v8/UnsafePersistent.h"
#include "bindings/v8/WrapperTypeInfo.h"
+#include <v8-util.h>
#include <v8.h>
#include "wtf/HashMap.h"
@@ -41,95 +41,124 @@
template<class KeyType>
class DOMWrapperMap {
public:
- typedef HashMap<KeyType*, UnsafePersistent<v8::Object> > MapType;
-
explicit DOMWrapperMap(v8::Isolate* isolate)
: m_isolate(isolate)
+ , m_map(isolate)
{
}
v8::Handle<v8::Object> newLocal(KeyType* key, v8::Isolate* isolate)
{
- return m_map.get(key).newLocal(isolate);
+ return m_map.Get(key);
}
bool setReturnValueFrom(v8::ReturnValue<v8::Value> returnValue, KeyType* key)
{
- typename MapType::iterator it = m_map.find(key);
- if (it == m_map.end())
- return false;
- returnValue.Set(*(it->value.persistent()));
- return true;
+ return m_map.SetReturnValue(key, returnValue);
}
void setReference(const v8::Persistent<v8::Object>& parent, KeyType* key, v8::Isolate* isolate)
{
- m_map.get(key).setReferenceFrom(parent, isolate);
+ m_map.SetReference(key, parent);
}
bool containsKey(KeyType* key)
{
- return m_map.find(key) != m_map.end();
- }
-
- bool containsKeyAndValue(KeyType* key, v8::Handle<v8::Object> value)
- {
- typename MapType::iterator it = m_map.find(key);
- if (it == m_map.end())
- return false;
- return *(it->value.persistent()) == value;
+ return m_map.Contains(key);
}
void set(KeyType* key, v8::Handle<v8::Object> wrapper, const WrapperConfiguration& configuration)
{
ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key);
- v8::Persistent<v8::Object> persistent(m_isolate, wrapper);
- configuration.configureWrapper(&persistent);
- persistent.SetWeak(this, &setWeakCallback);
- typename MapType::AddResult result = m_map.add(key, UnsafePersistent<v8::Object>());
- ASSERT(result.isNewEntry);
- // FIXME: Stop handling this case once duplicate wrappers are guaranteed not to be created.
- if (!result.isNewEntry)
- result.storedValue->value.dispose();
- result.storedValue->value = UnsafePersistent<v8::Object>(persistent);
+ v8::UniquePersistent<v8::Object> unique(m_isolate, wrapper);
+ configuration.configureWrapper(&unique);
+ m_map.Set(key, unique.Pass());
}
void clear()
{
- v8::HandleScope scope(m_isolate);
- while (!m_map.isEmpty()) {
- // Swap out m_map on each iteration to ensure any wrappers added due to side effects of the loop are cleared.
- MapType map;
- map.swap(m_map);
- for (typename MapType::iterator it = map.begin(); it != map.end(); ++it) {
- releaseObject(it->value.newLocal(m_isolate));
- it->value.dispose();
- }
- }
+ m_map.Clear();
}
void removeAndDispose(KeyType* key)
{
- typename MapType::iterator it = m_map.find(key);
- ASSERT_WITH_SECURITY_IMPLICATION(it != m_map.end());
- it->value.dispose();
- m_map.remove(it);
+ m_map.Remove(key);
}
private:
- static void setWeakCallback(const v8::WeakCallbackData<v8::Object, DOMWrapperMap<KeyType> >&);
+ class PersistentValueMapTraits {
+ public:
+ // Map traits:
+ typedef HashMap<KeyType*, v8::PersistentContainerValue> Impl;
+ typedef typename Impl::iterator Iterator;
+ static size_t Size(const Impl* impl) { return impl->size(); }
+ static bool Empty(Impl* impl) { return impl->isEmpty(); }
+ static void Swap(Impl& impl, Impl& other) { impl.swap(other); }
+ static Iterator Begin(Impl* impl) { return impl->begin(); }
+ static Iterator End(Impl* impl) { return impl->end(); }
+ static v8::PersistentContainerValue Value(Iterator& iter)
+ {
+ return iter->value;
+ }
+ static KeyType* Key(Iterator& iter) { return iter->key; }
+ static v8::PersistentContainerValue Set(
+ Impl* impl, KeyType* key, v8::PersistentContainerValue value)
+ {
+ v8::PersistentContainerValue oldValue = Get(impl, key);
+ impl->add(key, value);
+ return oldValue;
+ }
+ static v8::PersistentContainerValue Get(const Impl* impl, KeyType* key)
+ {
+ return impl->get(key);
+ }
+
+ static v8::PersistentContainerValue Remove(Impl* impl, KeyType* key)
+ {
+ return impl->take(key);
+ }
+
+ // Weak traits:
+ static const v8::PersistentContainerCallbackType kCallbackType = v8::kWeak;
+ typedef v8::PersistentValueMap<KeyType*, v8::Object, PersistentValueMapTraits> MapType;
+ typedef MapType WeakCallbackDataType;
+
+ static WeakCallbackDataType* WeakCallbackParameter(MapType* map, KeyType* key, v8::Local<v8::Object>& value)
+ {
+ return map;
+ }
+
+ static void DisposeCallbackData(WeakCallbackDataType* callbackData) { }
+
+ static MapType* MapFromWeakCallbackData(
+ const v8::WeakCallbackData<v8::Object, WeakCallbackDataType>& data)
+ {
+ return data.GetParameter();
+ }
+
+ static KeyType* KeyFromWeakCallbackData(
+ const v8::WeakCallbackData<v8::Object, WeakCallbackDataType>& data)
+ {
+ return static_cast<KeyType*>(toNative(data.GetValue()));
+ }
+
+ // Dispose traits:
+ // Generally nothing to do, but see below for a specialization for
+ // DomWrapperMap<void>.
+ static void Dispose(v8::Isolate* isolate, v8::UniquePersistent<v8::Object> value, KeyType* key) { }
+ };
v8::Isolate* m_isolate;
- MapType m_map;
+ typename PersistentValueMapTraits::MapType m_map;
};
-template<>
-inline void DOMWrapperMap<void>::setWeakCallback(const v8::WeakCallbackData<v8::Object, DOMWrapperMap<void> >& data)
+template <>
+inline void DOMWrapperMap<void>::PersistentValueMapTraits::Dispose(
+ v8::Isolate* isolate,
+ v8::UniquePersistent<v8::Object> value,
+ void* key)
{
- void* key = static_cast<void*>(toNative(data.GetValue()));
- ASSERT(*data.GetParameter()->m_map.get(key).persistent() == data.GetValue());
- data.GetParameter()->removeAndDispose(key);
- releaseObject(data.GetValue());
+ releaseObject(v8::Local<v8::Object>::New(isolate, value));
}
} // namespace WebCore
diff --git a/Source/bindings/v8/Dictionary.cpp b/Source/bindings/v8/Dictionary.cpp
index 77f2dd0..ced0df3 100644
--- a/Source/bindings/v8/Dictionary.cpp
+++ b/Source/bindings/v8/Dictionary.cpp
@@ -480,7 +480,7 @@
return true;
}
-bool Dictionary::get(const String& key, RefPtr<SpeechRecognitionError>& value) const
+bool Dictionary::get(const String& key, RefPtrWillBeMember<SpeechRecognitionError>& value) const
{
v8::Local<v8::Value> v8Value;
if (!getKey(key, v8Value))
diff --git a/Source/bindings/v8/Dictionary.h b/Source/bindings/v8/Dictionary.h
index 4a94dc2..3788afb 100644
--- a/Source/bindings/v8/Dictionary.h
+++ b/Source/bindings/v8/Dictionary.h
@@ -90,7 +90,7 @@
bool get(const String&, RefPtr<MIDIPort>&) const;
bool get(const String&, RefPtr<MediaKeyError>&) const;
bool get(const String&, RefPtr<TrackBase>&) const;
- bool get(const String&, RefPtr<SpeechRecognitionError>&) const;
+ bool get(const String&, RefPtrWillBeMember<SpeechRecognitionError>&) const;
bool get(const String&, RefPtrWillBeMember<SpeechRecognitionResult>&) const;
bool get(const String&, RefPtrWillBeMember<SpeechRecognitionResultList>&) const;
bool get(const String&, RefPtrWillBeMember<Gamepad>&) const;
diff --git a/Source/bindings/v8/MIDIAccessResolver.cpp b/Source/bindings/v8/MIDIAccessResolver.cpp
index ebd3ce5..defa40a 100644
--- a/Source/bindings/v8/MIDIAccessResolver.cpp
+++ b/Source/bindings/v8/MIDIAccessResolver.cpp
@@ -23,17 +23,13 @@
void MIDIAccessResolver::resolve(MIDIAccess* access, ExecutionContext* executionContext)
{
- v8::HandleScope handleScope(toIsolate(executionContext));
- v8::Context::Scope contextScope(m_scriptState->context());
-
+ NewScriptState::Scope scope(m_scriptState.get());
m_resolver->resolve(access, executionContext);
}
void MIDIAccessResolver::reject(DOMError* error, ExecutionContext* executionContext)
{
- v8::HandleScope handleScope(toIsolate(executionContext));
- v8::Context::Scope contextScope(m_scriptState->context());
-
+ NewScriptState::Scope scope(m_scriptState.get());
m_resolver->reject(error, executionContext);
}
diff --git a/Source/bindings/v8/NPV8Object.cpp b/Source/bindings/v8/NPV8Object.cpp
index 080e0d0..1c432fe 100644
--- a/Source/bindings/v8/NPV8Object.cpp
+++ b/Source/bindings/v8/NPV8Object.cpp
@@ -53,7 +53,7 @@
const WrapperTypeInfo* npObjectTypeInfo()
{
- static const WrapperTypeInfo typeInfo = { gin::kEmbedderBlink, 0, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, false };
+ static const WrapperTypeInfo typeInfo = { gin::kEmbedderBlink, 0, 0, 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, RefCountedObject };
return &typeInfo;
}
@@ -597,7 +597,7 @@
LocalFrame* frame = object->rootObject->frame();
ASSERT(frame);
OwnPtr<v8::Handle<v8::Value>[]> argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
- resultObject = V8ObjectConstructor::newInstanceInDocument(ctor, argumentCount, argv.get(), frame ? frame->document() : 0);
+ resultObject = V8ObjectConstructor::newInstanceInDocument(isolate, ctor, argumentCount, argv.get(), frame ? frame->document() : 0);
}
if (resultObject.IsEmpty())
diff --git a/Source/bindings/v8/NewScriptState.cpp b/Source/bindings/v8/NewScriptState.cpp
index 421ba28..1bba46f 100644
--- a/Source/bindings/v8/NewScriptState.cpp
+++ b/Source/bindings/v8/NewScriptState.cpp
@@ -9,10 +9,13 @@
namespace WebCore {
-void NewScriptState::install(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
+PassRefPtr<NewScriptState> NewScriptState::create(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
{
RefPtr<NewScriptState> scriptState = adoptRef(new NewScriptState(context, world));
+ // This ref() is for keeping this NewScriptState alive as long as the v8::Context is alive.
+ // This is deref()ed in the weak callback of the v8::Context.
scriptState->ref();
+ return scriptState;
}
static void weakCallback(const v8::WeakCallbackData<v8::Context, NewScriptState>& data)
@@ -25,8 +28,8 @@
NewScriptState::NewScriptState(v8::Handle<v8::Context> context, PassRefPtr<DOMWrapperWorld> world)
: m_isolate(context->GetIsolate())
, m_context(m_isolate, context)
- , m_perContextData(0)
, m_world(world)
+ , m_perContextData(V8PerContextData::create(context, m_world))
{
ASSERT(m_world);
m_context.setWeak(this, &weakCallback);
diff --git a/Source/bindings/v8/NewScriptState.h b/Source/bindings/v8/NewScriptState.h
index 62536db..15207b3 100644
--- a/Source/bindings/v8/NewScriptState.h
+++ b/Source/bindings/v8/NewScriptState.h
@@ -21,7 +21,28 @@
class NewScriptState : public RefCounted<NewScriptState> {
WTF_MAKE_NONCOPYABLE(NewScriptState);
public:
- static void install(v8::Handle<v8::Context>, PassRefPtr<DOMWrapperWorld>);
+ class Scope {
+ public:
+ // You need to make sure that scriptState->context() is not empty before creating a Scope.
+ explicit Scope(NewScriptState* scriptState)
+ : m_handleScope(scriptState->isolate())
+ , m_context(scriptState->context())
+ {
+ ASSERT(!m_context.IsEmpty());
+ m_context->Enter();
+ }
+
+ ~Scope()
+ {
+ m_context->Exit();
+ }
+
+ private:
+ v8::HandleScope m_handleScope;
+ v8::Handle<v8::Context> m_context;
+ };
+
+ static PassRefPtr<NewScriptState> create(v8::Handle<v8::Context>, PassRefPtr<DOMWrapperWorld>);
~NewScriptState();
static NewScriptState* current(v8::Isolate* isolate)
@@ -44,19 +65,20 @@
DOMWrapperWorld& world() const { return *m_world; }
// This can return an empty handle if the v8::Context is gone.
v8::Handle<v8::Context> context() const { return m_context.newLocal(m_isolate); }
+ bool contextIsEmpty() const { return m_context.isEmpty(); }
void clearContext() { return m_context.clear(); }
ExecutionContext* executionContext() const;
- V8PerContextData* perContextData() const { return m_perContextData; }
- void setPerContextData(V8PerContextData* data) { m_perContextData = data; }
+ V8PerContextData* perContextData() const { return m_perContextData.get(); }
+ void disposePerContextData() { m_perContextData = nullptr; }
private:
NewScriptState(v8::Handle<v8::Context>, PassRefPtr<DOMWrapperWorld>);
v8::Isolate* m_isolate;
ScopedPersistent<v8::Context> m_context;
- V8PerContextData* m_perContextData;
// This RefPtr doesn't cause a cycle because all persistent handles that DOMWrapperWorld holds are weak.
RefPtr<DOMWrapperWorld> m_world;
+ OwnPtr<V8PerContextData> m_perContextData;
};
}
diff --git a/Source/bindings/v8/PageScriptDebugServer.cpp b/Source/bindings/v8/PageScriptDebugServer.cpp
index 8311d67..93ed3e9 100644
--- a/Source/bindings/v8/PageScriptDebugServer.cpp
+++ b/Source/bindings/v8/PageScriptDebugServer.cpp
@@ -89,12 +89,23 @@
return server;
}
+v8::Isolate* PageScriptDebugServer::s_mainThreadIsolate = 0;
+
+void PageScriptDebugServer::setMainThreadIsolate(v8::Isolate* isolate)
+{
+ s_mainThreadIsolate = isolate;
+}
+
PageScriptDebugServer::PageScriptDebugServer()
- : ScriptDebugServer(v8::Isolate::GetCurrent())
+ : ScriptDebugServer(s_mainThreadIsolate)
, m_pausedPage(0)
{
}
+PageScriptDebugServer::~PageScriptDebugServer()
+{
+}
+
void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
{
ScriptController& scriptController = page->mainFrame()->script();
@@ -143,6 +154,11 @@
// FIXME: Remove all breakpoints set by the agent.
}
+void PageScriptDebugServer::interruptAndRun(PassOwnPtr<Task> task)
+{
+ ScriptDebugServer::interruptAndRun(task, s_mainThreadIsolate);
+}
+
void PageScriptDebugServer::setClientMessageLoop(PassOwnPtr<ClientMessageLoop> clientMessageLoop)
{
m_clientMessageLoop = clientMessageLoop;
diff --git a/Source/bindings/v8/PageScriptDebugServer.h b/Source/bindings/v8/PageScriptDebugServer.h
index 6926c14..a305456 100644
--- a/Source/bindings/v8/PageScriptDebugServer.h
+++ b/Source/bindings/v8/PageScriptDebugServer.h
@@ -49,9 +49,13 @@
public:
static PageScriptDebugServer& shared();
+ static void setMainThreadIsolate(v8::Isolate*);
+
void addListener(ScriptDebugListener*, Page*);
void removeListener(ScriptDebugListener*, Page*);
+ static void interruptAndRun(PassOwnPtr<Task>);
+
class ClientMessageLoop {
public:
virtual ~ClientMessageLoop() { }
@@ -73,7 +77,7 @@
private:
PageScriptDebugServer();
- virtual ~PageScriptDebugServer() { }
+ virtual ~PageScriptDebugServer();
virtual ScriptDebugListener* getDebugListenerForContext(v8::Handle<v8::Context>) OVERRIDE;
virtual void runMessageLoopOnPause(v8::Handle<v8::Context>) OVERRIDE;
@@ -88,6 +92,7 @@
OwnPtr<ScriptSourceCode> m_preprocessorSourceCode;
OwnPtr<ScriptPreprocessor> m_scriptPreprocessor;
bool canPreprocess(LocalFrame*);
+ static v8::Isolate* s_mainThreadIsolate;
};
} // namespace WebCore
diff --git a/Source/bindings/v8/ScriptFunctionCall.cpp b/Source/bindings/v8/ScriptFunctionCall.cpp
index 830675f..2d81068 100644
--- a/Source/bindings/v8/ScriptFunctionCall.cpp
+++ b/Source/bindings/v8/ScriptFunctionCall.cpp
@@ -182,7 +182,7 @@
for (size_t i = 0; i < m_arguments.size(); ++i)
info[i] = m_arguments[i].v8Value();
- v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(constructor, m_arguments.size(), info.get());
+ v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptState->isolate(), constructor, m_arguments.size(), info.get());
if (!scope.success()) {
hadException = true;
return ScriptObject();
diff --git a/Source/bindings/v8/ScriptGCEvent.cpp b/Source/bindings/v8/ScriptGCEvent.cpp
index 361d8e3..9cc90eb 100644
--- a/Source/bindings/v8/ScriptGCEvent.cpp
+++ b/Source/bindings/v8/ScriptGCEvent.cpp
@@ -41,7 +41,7 @@
static GCEventData* isolateGCEventData()
{
- V8PerIsolateData* isolateData = V8PerIsolateData::current();
+ V8PerIsolateData* isolateData = V8PerIsolateData::from(v8::Isolate::GetCurrent());
ASSERT(isolateData);
return isolateData->gcEventData();
}
diff --git a/Source/bindings/v8/ScriptPreprocessor.cpp b/Source/bindings/v8/ScriptPreprocessor.cpp
index 8305ae4..7955a05 100644
--- a/Source/bindings/v8/ScriptPreprocessor.cpp
+++ b/Source/bindings/v8/ScriptPreprocessor.cpp
@@ -105,7 +105,7 @@
v8::TryCatch tryCatch;
tryCatch.SetVerbose(true);
TemporaryChange<bool> isPreprocessing(m_isPreprocessing, true);
- v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_preprocessorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_ARRAY_LENGTH(argv), argv);
+ v8::Handle<v8::Value> resultValue = V8ScriptRunner::callAsFunction(m_isolate, m_preprocessorFunction.newLocal(m_isolate), m_context.newLocal(m_isolate)->Global(), WTF_ARRAY_LENGTH(argv), argv);
if (!resultValue.IsEmpty() && resultValue->IsString())
return toCoreStringWithNullCheck(resultValue.As<v8::String>());
diff --git a/Source/bindings/v8/ScriptPromiseResolver.h b/Source/bindings/v8/ScriptPromiseResolver.h
index 9433d44..03b0d31 100644
--- a/Source/bindings/v8/ScriptPromiseResolver.h
+++ b/Source/bindings/v8/ScriptPromiseResolver.h
@@ -137,6 +137,8 @@
void resolve(ScriptValue);
void reject(ScriptValue);
+ v8::Isolate* isolate() const { return m_isolate; }
+
private:
ScriptPromiseResolver(ExecutionContext*);
ScriptPromiseResolver(v8::Isolate*);
diff --git a/Source/bindings/v8/ScriptState.h b/Source/bindings/v8/ScriptState.h
index b84c74b..7cf013f 100644
--- a/Source/bindings/v8/ScriptState.h
+++ b/Source/bindings/v8/ScriptState.h
@@ -47,14 +47,6 @@
class ScriptState {
WTF_MAKE_NONCOPYABLE(ScriptState);
public:
- bool hadException() { return !m_exception.isEmpty(); }
- void setException(v8::Local<v8::Value> exception)
- {
- m_exception.set(m_isolate, exception);
- }
- v8::Local<v8::Value> exception() { return m_exception.newLocal(m_isolate); }
- void clearException() { m_exception.clear(); }
-
v8::Local<v8::Context> context() const
{
return m_context.newLocal(m_isolate);
@@ -103,6 +95,9 @@
ScriptStateProtectedPtr(ScriptState* scriptState)
: m_scriptState(scriptState)
{
+ if (!scriptState)
+ return;
+
v8::HandleScope handleScope(scriptState->isolate());
// Keep the context from being GC'ed. ScriptState is guaranteed to be live while the context is live.
m_context.set(scriptState->isolate(), scriptState->context());
@@ -110,6 +105,15 @@
ScriptState* get() const { return m_scriptState; }
+ void clear()
+ {
+ if (!m_scriptState)
+ return;
+
+ m_context.clear();
+ m_scriptState = 0;
+ }
+
private:
ScriptState* m_scriptState;
ScopedPersistent<v8::Context> m_context;
diff --git a/Source/bindings/v8/SerializedScriptValue.cpp b/Source/bindings/v8/SerializedScriptValue.cpp
index d292d66..7de88cb 100644
--- a/Source/bindings/v8/SerializedScriptValue.cpp
+++ b/Source/bindings/v8/SerializedScriptValue.cpp
@@ -1900,7 +1900,7 @@
double numberValue;
if (!doReadNumber(&numberValue))
return false;
- *value = v8DateOrNull(numberValue, m_isolate);
+ *value = v8DateOrNaN(numberValue, m_isolate);
return true;
}
diff --git a/Source/bindings/v8/V8Binding.cpp b/Source/bindings/v8/V8Binding.cpp
index f60bf72..de8aadd 100644
--- a/Source/bindings/v8/V8Binding.cpp
+++ b/Source/bindings/v8/V8Binding.cpp
@@ -672,10 +672,8 @@
V8ExecutionScope::V8ExecutionScope(v8::Isolate* isolate)
: m_handleScope(isolate)
- , m_context(v8::Context::New(isolate))
- , m_contextScope(m_context)
- , m_world(DOMWrapperWorld::create())
- , m_perContextData(V8PerContextData::create(m_context, m_world))
+ , m_contextScope(v8::Context::New(isolate))
+ , m_scriptState(NewScriptState::create(isolate->GetCurrentContext(), DOMWrapperWorld::create()))
{
}
diff --git a/Source/bindings/v8/V8Binding.h b/Source/bindings/v8/V8Binding.h
index 182ffe0..d590fa9 100644
--- a/Source/bindings/v8/V8Binding.h
+++ b/Source/bindings/v8/V8Binding.h
@@ -39,7 +39,7 @@
#include "bindings/v8/V8StringResource.h"
#include "bindings/v8/V8ThrowException.h"
#include "bindings/v8/V8ValueCache.h"
-#include "heap/Heap.h"
+#include "platform/heap/Heap.h"
#include "wtf/MathExtras.h"
#include "wtf/text/AtomicString.h"
#include <v8.h>
@@ -54,7 +54,6 @@
class LocalFrame;
class NodeFilter;
class ScriptWrappable;
-class V8PerContextData;
class XPathNSResolver;
const int kMaxRecursionDepth = 22;
@@ -434,10 +433,10 @@
return std::numeric_limits<double>::quiet_NaN();
}
-inline v8::Handle<v8::Value> v8DateOrNull(double value, v8::Isolate* isolate)
+inline v8::Handle<v8::Value> v8DateOrNaN(double value, v8::Isolate* isolate)
{
ASSERT(isolate);
- return std::isfinite(value) ? v8::Date::New(isolate, value) : v8::Handle<v8::Value>::Cast(v8::Null(isolate));
+ return v8::Date::New(isolate, std::isfinite(value) ? value : std::numeric_limits<double>::quiet_NaN());
}
// FIXME: Remove the special casing for NodeFilter and XPathNSResolver.
@@ -547,7 +546,7 @@
}
template <class T, class V8T>
-HeapVector<Member<T> > toMemberNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
+HeapVector<Member<T> > toRefPtrWillBeMemberNativeArray(v8::Handle<v8::Value> value, int argumentIndex, v8::Isolate* isolate, bool* success = 0)
{
if (success)
*success = true;
@@ -558,10 +557,10 @@
length = v8::Local<v8::Array>::Cast(v8Value)->Length();
} else if (toV8Sequence(value, length, isolate).IsEmpty()) {
throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex), isolate);
- return HeapVector<Member<T> >();
+ return WillBeHeapVector<RefPtrWillBeMember<T> >();
}
- HeapVector<Member<T> > result;
+ WillBeHeapVector<RefPtrWillBeMember<T> > result;
result.reserveInitialCapacity(length);
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(v8Value);
for (uint32_t i = 0; i < length; ++i) {
@@ -573,7 +572,7 @@
if (success)
*success = false;
throwTypeError("Invalid Array element type", isolate);
- return HeapVector<Member<T> >();
+ return WillBeHeapVector<RefPtrWillBeMember<T> >();
}
}
return result;
@@ -760,10 +759,8 @@
private:
v8::HandleScope m_handleScope;
- v8::Handle<v8::Context> m_context;
v8::Context::Scope m_contextScope;
- RefPtr<DOMWrapperWorld> m_world;
- OwnPtr<V8PerContextData> m_perContextData;
+ RefPtr<NewScriptState> m_scriptState;
};
} // namespace WebCore
diff --git a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
index f31a3bd..c74b075 100644
--- a/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
+++ b/Source/bindings/v8/V8CustomElementLifecycleCallbacks.cpp
@@ -158,14 +158,11 @@
element->setCustomElementState(Element::Upgraded);
- v8::Isolate* isolate = m_scriptState->isolate();
- v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> context = m_scriptState->context();
- if (context.IsEmpty())
+ if (m_scriptState->contextIsEmpty())
return;
-
- v8::Context::Scope scope(context);
-
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Isolate* isolate = m_scriptState->isolate();
+ v8::Handle<v8::Context> context = m_scriptState->context();
v8::Handle<v8::Object> receiver = DOMDataStore::current(isolate).get<V8Element>(element, isolate);
if (!receiver.IsEmpty()) {
// Swizzle the prototype of the existing wrapper. We don't need to
@@ -211,14 +208,11 @@
if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
- v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> context = m_scriptState->context();
- if (context.IsEmpty())
+ if (m_scriptState->contextIsEmpty())
return;
-
- v8::Context::Scope scope(context);
-
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Isolate* isolate = m_scriptState->isolate();
+ v8::Handle<v8::Context> context = m_scriptState->context();
v8::Handle<v8::Object> receiver = toV8(element, context->Global(), isolate).As<v8::Object>();
ASSERT(!receiver.IsEmpty());
@@ -247,14 +241,11 @@
if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
return;
- v8::Isolate* isolate = m_scriptState->isolate();
- v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Context> context = m_scriptState->context();
- if (context.IsEmpty())
+ if (m_scriptState->contextIsEmpty())
return;
-
- v8::Context::Scope scope(context);
-
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Isolate* isolate = m_scriptState->isolate();
+ v8::Handle<v8::Context> context = m_scriptState->context();
v8::Handle<v8::Function> callback = weakCallback.newLocal(isolate);
if (callback.IsEmpty())
return;
diff --git a/Source/bindings/v8/V8DOMWrapper.cpp b/Source/bindings/v8/V8DOMWrapper.cpp
index ed73ce3..7efe637 100644
--- a/Source/bindings/v8/V8DOMWrapper.cpp
+++ b/Source/bindings/v8/V8DOMWrapper.cpp
@@ -60,7 +60,7 @@
if (shadowConstructor.IsEmpty())
return v8::Local<v8::Object>();
- v8::Local<v8::Object> shadow = V8ScriptRunner::instantiateObject(shadowConstructor);
+ v8::Local<v8::Object> shadow = V8ScriptRunner::instantiateObject(isolate, shadowConstructor);
if (shadow.IsEmpty())
return v8::Local<v8::Object>();
shadow->SetPrototype(wrapper);
@@ -73,7 +73,7 @@
V8WrapperInstantiationScope scope(creationContext, isolate);
V8PerContextData* perContextData = V8PerContextData::from(scope.context());
- v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->domTemplate(isolate)->GetFunction());
+ v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(isolate, type->domTemplate(isolate)->GetFunction());
if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty())
wrapper = wrapInShadowTemplate(wrapper, static_cast<Node*>(impl), isolate);
diff --git a/Source/bindings/v8/V8DOMWrapper.h b/Source/bindings/v8/V8DOMWrapper.h
index 5e8a0da..adc97b7 100644
--- a/Source/bindings/v8/V8DOMWrapper.h
+++ b/Source/bindings/v8/V8DOMWrapper.h
@@ -48,7 +48,10 @@
template<typename V8T, typename T>
static inline v8::Handle<v8::Object> associateObjectWithWrapper(PassRefPtr<T>, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime);
template<typename V8T, typename T>
- static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime) { return associateObjectWithWrapper<V8T, T>(object.get(), type, wrapper, isolate, lifetime); }
+ static inline v8::Handle<v8::Object> associateObjectWithWrapper(RawPtr<T> object, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
+ {
+ return associateObjectWithWrapper<V8T, T>(object.get(), wrapperTypeInfo, wrapper, isolate, lifetime);
+ }
template<typename V8T, typename T>
static inline v8::Handle<v8::Object> associateObjectWithWrapper(T*, const WrapperTypeInfo*, v8::Handle<v8::Object>, v8::Isolate*, WrapperConfiguration::Lifetime);
static inline void setNativeInfo(v8::Handle<v8::Object>, const WrapperTypeInfo*, void*);
@@ -59,60 +62,63 @@
static bool isDOMWrapper(v8::Handle<v8::Value>);
};
- inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* type, void* object)
+ inline void V8DOMWrapper::setNativeInfo(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* wrapperTypeInfo, void* object)
{
ASSERT(wrapper->InternalFieldCount() >= 2);
ASSERT(object);
- ASSERT(type);
+ ASSERT(wrapperTypeInfo);
#if ENABLE(OILPAN)
- ASSERT(!type->isGarbageCollected);
+ ASSERT(wrapperTypeInfo->gcType == RefCountedObject);
+#else
+ ASSERT(wrapperTypeInfo->gcType == RefCountedObject || wrapperTypeInfo->gcType == WillBeGarbageCollectedObject);
#endif
wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, object);
- wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(type));
+ wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(wrapperTypeInfo));
}
- inline void V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* type, void* object)
+ inline void V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* wrapperTypeInfo, void* object)
{
// see V8WindowShell::installDOMWindow() comment for why this version is needed and safe.
ASSERT(wrapper->InternalFieldCount() >= 2);
ASSERT(object);
- ASSERT(type);
+ ASSERT(wrapperTypeInfo);
#if ENABLE(OILPAN)
- ASSERT(type->isGarbageCollected);
+ ASSERT(wrapperTypeInfo->gcType != RefCountedObject);
+#else
+ ASSERT(wrapperTypeInfo->gcType == RefCountedObject || wrapperTypeInfo->gcType == WillBeGarbageCollectedObject);
#endif
wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, object);
- wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(type));
+ wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(wrapperTypeInfo));
// Clear out the last internal field, which is assumed to contain a valid persistent pointer value.
wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount() - 1, 0);
}
-
- inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* type, void* object, PersistentNode* handle)
+ inline void V8DOMWrapper::setNativeInfoWithPersistentHandle(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* wrapperTypeInfo, void* object, PersistentNode* handle)
{
ASSERT(wrapper->InternalFieldCount() >= 3);
ASSERT(object);
- ASSERT(type);
- ASSERT(type->isGarbageCollected);
+ ASSERT(wrapperTypeInfo);
+ ASSERT(wrapperTypeInfo->gcType != RefCountedObject);
wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, object);
- wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(type));
+ wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(wrapperTypeInfo));
// Persistent handle is stored in the last internal field.
wrapper->SetAlignedPointerInInternalField(wrapper->InternalFieldCount() - 1, handle);
}
- inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* type)
+ inline void V8DOMWrapper::clearNativeInfo(v8::Handle<v8::Object> wrapper, const WrapperTypeInfo* wrapperTypeInfo)
{
ASSERT(wrapper->InternalFieldCount() >= 2);
- ASSERT(type);
+ ASSERT(wrapperTypeInfo);
// clearNativeInfo() is used only by NP objects, which are not garbage collected.
- ASSERT(!type->isGarbageCollected);
- wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(type));
+ ASSERT(wrapperTypeInfo->gcType == RefCountedObject);
+ wrapper->SetAlignedPointerInInternalField(v8DOMWrapperTypeIndex, const_cast<WrapperTypeInfo*>(wrapperTypeInfo));
wrapper->SetAlignedPointerInInternalField(v8DOMWrapperObjectIndex, 0);
}
template<typename V8T, typename T>
- inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<T> object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
+ inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(PassRefPtr<T> object, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
{
- setNativeInfo(wrapper, type, V8T::toInternalPointer(object.get()));
+ setNativeInfo(wrapper, wrapperTypeInfo, V8T::toInternalPointer(object.get()));
ASSERT(isDOMWrapper(wrapper));
WrapperConfiguration configuration = buildWrapperConfiguration(object.get(), lifetime);
DOMDataStore::setWrapper<V8T>(object.leakRef(), wrapper, isolate, configuration);
@@ -120,9 +126,9 @@
}
template<typename V8T, typename T>
- inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(T* object, const WrapperTypeInfo* type, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
+ inline v8::Handle<v8::Object> V8DOMWrapper::associateObjectWithWrapper(T* object, const WrapperTypeInfo* wrapperTypeInfo, v8::Handle<v8::Object> wrapper, v8::Isolate* isolate, WrapperConfiguration::Lifetime lifetime)
{
- setNativeInfoWithPersistentHandle(wrapper, type, V8T::toInternalPointer(object), new Persistent<T>(object));
+ setNativeInfoWithPersistentHandle(wrapper, wrapperTypeInfo, V8T::toInternalPointer(object), new Persistent<T>(object));
ASSERT(isDOMWrapper(wrapper));
WrapperConfiguration configuration = buildWrapperConfiguration(object, lifetime);
DOMDataStore::setWrapper<V8T>(object, wrapper, isolate, configuration);
diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp
index bffb6fc..563be2f 100644
--- a/Source/bindings/v8/V8GCController.cpp
+++ b/Source/bindings/v8/V8GCController.cpp
@@ -368,11 +368,25 @@
else if (type == v8::kGCTypeMarkSweepCompact)
majorGCEpilogue(isolate);
- // Force a Blink heap garbage collection when a garbage collection
+ // Forces a Blink heap garbage collection when a garbage collection
// was forced from V8. This is used for tests that force GCs from
// JavaScript to verify that objects die when expected.
- if (flags & v8::kGCCallbackFlagForced)
- Heap::collectGarbage(ThreadState::HeapPointersOnStack, Heap::ForcedForTesting);
+ if (flags & v8::kGCCallbackFlagForced) {
+ // This single GC is not enough for two reasons:
+ // (1) The GC is not precise because the GC scans on-stack pointers conservatively.
+ // (2) One GC is not enough to break a chain of persistent handles. It's possible that
+ // some heap allocated objects own objects that contain persistent handles
+ // pointing to other heap allocated objects. To break the chain, we need multiple GCs.
+ //
+ // Regarding (1), we force a precise GC at the end of the current event loop. So if you want
+ // to collect all garbage, you need to wait until the next event loop.
+ // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because
+ // GCController.collectAll() forces 7 V8's GC.
+ Heap::collectGarbage(ThreadState::HeapPointersOnStack);
+
+ // Forces a precise GC at the end of the current event loop.
+ Heap::setForcePreciseGCForTesting();
+ }
}
void V8GCController::minorGCEpilogue(v8::Isolate* isolate)
diff --git a/Source/bindings/v8/V8Initializer.cpp b/Source/bindings/v8/V8Initializer.cpp
index 1cd0262..b0f4dba 100644
--- a/Source/bindings/v8/V8Initializer.cpp
+++ b/Source/bindings/v8/V8Initializer.cpp
@@ -112,7 +112,7 @@
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
- RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn() + 1, &world);
+ RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, resource, message->GetLineNumber(), message->GetStartColumn() + 1, &world);
if (V8DOMWrapper::isDOMWrapper(data)) {
v8::Handle<v8::Object> obj = v8::Handle<v8::Object>::Cast(data);
const WrapperTypeInfo* type = toWrapperTypeInfo(obj);
@@ -219,7 +219,7 @@
String errorMessage = toCoreString(message->Get());
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, sourceURL, message->GetScriptResourceName());
- RefPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperWorld::current(isolate));
+ RefPtrWillBeRawPtr<ErrorEvent> event = ErrorEvent::create(errorMessage, sourceURL, message->GetLineNumber(), message->GetStartColumn() + 1, &DOMWrapperWorld::current(isolate));
AccessControlStatus corsStatus = message->IsSharedCrossOrigin() ? SharableCrossOrigin : NotSharableCrossOrigin;
V8ErrorHandler::storeExceptionOnErrorEventWrapper(event.get(), data, isolate);
diff --git a/Source/bindings/v8/V8NPObject.cpp b/Source/bindings/v8/V8NPObject.cpp
index a3f8ab7..2062e8c 100644
--- a/Source/bindings/v8/V8NPObject.cpp
+++ b/Source/bindings/v8/V8NPObject.cpp
@@ -36,7 +36,6 @@
#include "V8HTMLEmbedElement.h"
#include "V8HTMLObjectElement.h"
#include "bindings/v8/NPV8Object.h"
-#include "bindings/v8/UnsafePersistent.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8NPUtils.h"
#include "bindings/v8/V8ObjectConstructor.h"
@@ -404,18 +403,13 @@
return npObjectMap;
}
-template<>
-inline void DOMWrapperMap<NPObject>::setWeakCallback(const v8::WeakCallbackData<v8::Object, DOMWrapperMap<NPObject> >& data)
+template <>
+inline void DOMWrapperMap<NPObject>::PersistentValueMapTraits::Dispose(
+ v8::Isolate* isolate,
+ v8::UniquePersistent<v8::Object> value,
+ NPObject* npObject)
{
- NPObject* npObject = static_cast<NPObject*>(toNative(data.GetValue()));
-
ASSERT(npObject);
- ASSERT(staticNPObjectMap().containsKeyAndValue(npObject, data.GetValue()));
-
- // Must remove from our map before calling _NPN_ReleaseObject(). _NPN_ReleaseObject can
- // call forgetV8ObjectForNPObject, which uses the table as well.
- staticNPObjectMap().removeAndDispose(npObject);
-
if (_NPN_IsAlive(npObject))
_NPN_ReleaseObject(npObject);
}
@@ -453,7 +447,7 @@
// V8DOMWrapper::associateObjectWithWrapper()
// to create a wrapper object.
v8::Handle<v8::Function> v8Function = npObjectDesc.Get(isolate)->GetFunction();
- v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(v8Function);
+ v8::Local<v8::Object> value = V8ObjectConstructor::newInstance(isolate, v8Function);
if (value.IsEmpty())
return value;
diff --git a/Source/bindings/v8/V8NodeFilterCondition.cpp b/Source/bindings/v8/V8NodeFilterCondition.cpp
index 77ec3a1..b7e032a 100644
--- a/Source/bindings/v8/V8NodeFilterCondition.cpp
+++ b/Source/bindings/v8/V8NodeFilterCondition.cpp
@@ -33,7 +33,6 @@
#include "V8Node.h"
#include "bindings/v8/ScriptController.h"
-#include "bindings/v8/ScriptState.h"
#include "bindings/v8/V8HiddenValue.h"
#include "core/dom/Node.h"
#include "core/dom/NodeFilter.h"
@@ -42,7 +41,8 @@
namespace WebCore {
V8NodeFilterCondition::V8NodeFilterCondition(v8::Handle<v8::Value> filter, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
- : m_filter(isolate, filter)
+ : m_scriptState(NewScriptState::current(isolate))
+ , m_filter(isolate, filter)
{
V8HiddenValue::setHiddenValue(isolate, owner, V8HiddenValue::condition(isolate), filter);
m_filter.setWeak(this, &setWeakCallback);
@@ -52,14 +52,16 @@
{
}
-short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
+short V8NodeFilterCondition::acceptNode(Node* node, ExceptionState& exceptionState) const
{
- v8::Isolate* isolate = state->isolate();
- ASSERT(isolate->InContext());
+ v8::Isolate* isolate = m_scriptState->isolate();
+ ASSERT(!m_scriptState->context().IsEmpty());
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Value> filter = m_filter.newLocal(isolate);
ASSERT(!filter.IsEmpty());
- if (!filter->IsObject())
+ // FIXME: Remove the filter.IsEmpty() check because |filter| must not be empty.
+ // See crbug.com/358858 for more details.
+ if (filter.IsEmpty() || !filter->IsObject())
return NodeFilter::FILTER_ACCEPT;
v8::TryCatch exceptionCatcher;
@@ -70,20 +72,20 @@
else {
v8::Local<v8::Value> value = filter->ToObject()->Get(v8AtomicString(isolate, "acceptNode"));
if (value.IsEmpty() || !value->IsFunction()) {
- throwTypeError("NodeFilter object does not have an acceptNode function", state->isolate());
+ throwTypeError("NodeFilter object does not have an acceptNode function", isolate);
return NodeFilter::FILTER_REJECT;
}
callback = v8::Handle<v8::Function>::Cast(value);
}
OwnPtr<v8::Handle<v8::Value>[]> info = adoptArrayPtr(new v8::Handle<v8::Value>[1]);
- info[0] = toV8(node, v8::Handle<v8::Object>(), state->isolate());
+ info[0] = toV8(node, v8::Handle<v8::Object>(), isolate);
- v8::Handle<v8::Object> object = isolate->GetCurrentContext()->Global();
- v8::Handle<v8::Value> result = ScriptController::callFunction(state->executionContext(), callback, object, 1, info.get(), isolate);
+ v8::Handle<v8::Object> object = m_scriptState->context()->Global();
+ v8::Handle<v8::Value> result = ScriptController::callFunction(m_scriptState->executionContext(), callback, object, 1, info.get(), isolate);
if (exceptionCatcher.HasCaught()) {
- state->setException(exceptionCatcher.Exception());
+ exceptionState.rethrowV8Exception(exceptionCatcher.Exception());
return NodeFilter::FILTER_REJECT;
}
diff --git a/Source/bindings/v8/V8NodeFilterCondition.h b/Source/bindings/v8/V8NodeFilterCondition.h
index abff9e3..1689c14 100644
--- a/Source/bindings/v8/V8NodeFilterCondition.h
+++ b/Source/bindings/v8/V8NodeFilterCondition.h
@@ -31,6 +31,7 @@
#ifndef V8NodeFilterCondition_h
#define V8NodeFilterCondition_h
+#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScopedPersistent.h"
#include "core/dom/NodeFilterCondition.h"
#include <v8.h>
@@ -39,7 +40,7 @@
namespace WebCore {
class Node;
-class ScriptState;
+class ExceptionState;
// V8NodeFilterCondition maintains a Javascript implemented callback for
// filtering Node returned by NodeIterator/TreeWalker.
@@ -67,7 +68,7 @@
virtual ~V8NodeFilterCondition();
- virtual short acceptNode(ScriptState*, Node*) const OVERRIDE;
+ virtual short acceptNode(Node*, ExceptionState&) const OVERRIDE;
private:
// As the value |filter| is maintained by V8GC, the |owner| which references
@@ -77,6 +78,7 @@
static void setWeakCallback(const v8::WeakCallbackData<v8::Value, V8NodeFilterCondition>&);
+ RefPtr<NewScriptState> m_scriptState;
ScopedPersistent<v8::Value> m_filter;
};
diff --git a/Source/bindings/v8/V8ObjectConstructor.cpp b/Source/bindings/v8/V8ObjectConstructor.cpp
index b94cb53..d52bdc1 100644
--- a/Source/bindings/v8/V8ObjectConstructor.cpp
+++ b/Source/bindings/v8/V8ObjectConstructor.cpp
@@ -34,40 +34,32 @@
namespace WebCore {
-v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function)
+v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Isolate* isolate, v8::Handle<v8::Function> function)
{
if (function.IsEmpty())
return v8::Local<v8::Object>();
- ConstructorMode constructorMode;
- return V8ScriptRunner::instantiateObject(function);
+ ConstructorMode constructorMode(isolate);
+ return V8ScriptRunner::instantiateObject(isolate, function);
}
-v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::ObjectTemplate> objectTemplate)
-{
- if (objectTemplate.IsEmpty())
- return v8::Local<v8::Object>();
- ConstructorMode constructorMode;
- return V8ScriptRunner::instantiateObject(objectTemplate);
-}
-
-v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
+v8::Local<v8::Object> V8ObjectConstructor::newInstance(v8::Isolate* isolate, v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
{
if (function.IsEmpty())
return v8::Local<v8::Object>();
- ConstructorMode constructorMode;
- return V8ScriptRunner::instantiateObject(function, argc, argv);
+ ConstructorMode constructorMode(isolate);
+ return V8ScriptRunner::instantiateObject(isolate, function, argc, argv);
}
-v8::Local<v8::Object> V8ObjectConstructor::newInstanceInDocument(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[], Document* document)
+v8::Local<v8::Object> V8ObjectConstructor::newInstanceInDocument(v8::Isolate* isolate, v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[], Document* document)
{
if (function.IsEmpty())
return v8::Local<v8::Object>();
- return V8ScriptRunner::instantiateObjectInDocument(function, document, argc, argv);
+ return V8ScriptRunner::instantiateObjectInDocument(isolate, function, document, argc, argv);
}
void V8ObjectConstructor::isValidConstructorMode(const v8::FunctionCallbackInfo<v8::Value>& info)
{
- if (ConstructorMode::current() == ConstructorMode::CreateNewObject) {
+ if (ConstructorMode::current(info.GetIsolate()) == ConstructorMode::CreateNewObject) {
throwTypeError("Illegal constructor", info.GetIsolate());
return;
}
diff --git a/Source/bindings/v8/V8ObjectConstructor.h b/Source/bindings/v8/V8ObjectConstructor.h
index 2c9f6a2..5719a7e 100644
--- a/Source/bindings/v8/V8ObjectConstructor.h
+++ b/Source/bindings/v8/V8ObjectConstructor.h
@@ -46,31 +46,35 @@
CreateNewObject
};
- ConstructorMode()
+ ConstructorMode(v8::Isolate* isolate)
+ : m_isolate(isolate)
{
- V8PerIsolateData* data = V8PerIsolateData::current();
+ V8PerIsolateData* data = V8PerIsolateData::from(m_isolate);
m_previous = data->m_constructorMode;
data->m_constructorMode = WrapExistingObject;
}
~ConstructorMode()
{
- V8PerIsolateData* data = V8PerIsolateData::current();
+ V8PerIsolateData* data = V8PerIsolateData::from(m_isolate);
data->m_constructorMode = m_previous;
}
- static bool current() { return V8PerIsolateData::current()->m_constructorMode; }
+ static bool current(v8::Isolate* isolate)
+ {
+ return V8PerIsolateData::from(isolate)->m_constructorMode;
+ }
private:
+ v8::Isolate* m_isolate;
bool m_previous;
};
class V8ObjectConstructor {
public:
- static v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>);
- static v8::Local<v8::Object> newInstance(v8::Handle<v8::ObjectTemplate>);
- static v8::Local<v8::Object> newInstance(v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[]);
- static v8::Local<v8::Object> newInstanceInDocument(v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[], Document*);
+ static v8::Local<v8::Object> newInstance(v8::Isolate*, v8::Handle<v8::Function>);
+ static v8::Local<v8::Object> newInstance(v8::Isolate*, v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[]);
+ static v8::Local<v8::Object> newInstanceInDocument(v8::Isolate*, v8::Handle<v8::Function>, int, v8::Handle<v8::Value> argv[], Document*);
static void isValidConstructorMode(const v8::FunctionCallbackInfo<v8::Value>&);
};
diff --git a/Source/bindings/v8/V8PerContextData.cpp b/Source/bindings/v8/V8PerContextData.cpp
index e8b1cb9..817ea8b 100644
--- a/Source/bindings/v8/V8PerContextData.cpp
+++ b/Source/bindings/v8/V8PerContextData.cpp
@@ -57,8 +57,6 @@
, m_customElementBindings(adoptPtr(new CustomElementBindingMap()))
{
m_contextHolder->SetContext(context);
- NewScriptState::install(context, world);
- NewScriptState::from(context)->setPerContextData(this);
v8::Context::Scope contextScope(context);
ASSERT(m_errorPrototype.isEmpty());
@@ -71,9 +69,6 @@
V8PerContextData::~V8PerContextData()
{
- v8::HandleScope handleScope(m_isolate);
- NewScriptState::from(m_context.newLocal(m_isolate))->setPerContextData(0);
-
disposeMapWithUnsafePersistentValues(&m_wrapperBoilerplates);
disposeMapWithUnsafePersistentValues(&m_constructorMap);
}
@@ -94,7 +89,7 @@
v8::Context::Scope scope(context());
v8::Local<v8::Function> function = constructorForType(type);
- v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(function);
+ v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(m_isolate, function);
if (!instanceTemplate.IsEmpty()) {
m_wrapperBoilerplates.set(type, UnsafePersistent<v8::Object>(m_isolate, instanceTemplate));
return instanceTemplate->Clone();
diff --git a/Source/bindings/v8/V8PerIsolateData.cpp b/Source/bindings/v8/V8PerIsolateData.cpp
index 2de1168..b19b2fb 100644
--- a/Source/bindings/v8/V8PerIsolateData.cpp
+++ b/Source/bindings/v8/V8PerIsolateData.cpp
@@ -27,12 +27,12 @@
#include "bindings/v8/V8PerIsolateData.h"
#include "bindings/v8/DOMDataStore.h"
+#include "bindings/v8/PageScriptDebugServer.h"
#include "bindings/v8/ScriptGCEvent.h"
#include "bindings/v8/ScriptProfiler.h"
#include "bindings/v8/V8Binding.h"
#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8ObjectConstructor.h"
-#include "bindings/v8/V8PerContextData.h"
#include "bindings/v8/V8ScriptRunner.h"
#include "wtf/MainThread.h"
@@ -53,8 +53,10 @@
, m_gcEventData(adoptPtr(new GCEventData()))
, m_performingMicrotaskCheckpoint(false)
{
- if (isMainThread())
+ if (isMainThread()) {
mainThreadPerIsolateData = this;
+ PageScriptDebugServer::setMainThreadIsolate(isolate);
+ }
}
V8PerIsolateData::~V8PerIsolateData()
@@ -128,9 +130,9 @@
v8::Local<v8::Context> V8PerIsolateData::ensureDomInJSContext()
{
- if (!m_domInJSPerContextData)
- m_domInJSPerContextData = V8PerContextData::create(v8::Context::New(m_isolate), DOMWrapperWorld::create());
- return m_domInJSPerContextData->context();
+ if (!m_blinkInJSScriptState)
+ m_blinkInJSScriptState = NewScriptState::create(v8::Context::New(m_isolate), DOMWrapperWorld::create());
+ return m_blinkInJSScriptState->context();
}
bool V8PerIsolateData::hasInstance(const WrapperTypeInfo* info, v8::Handle<v8::Value> value)
@@ -182,7 +184,7 @@
v8SetReturnValue(info, v8::String::Empty(info.GetIsolate()));
return;
}
- v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function>::Cast(value), info.This(), 0, 0, v8::Isolate::GetCurrent()));
+ v8SetReturnValue(info, V8ScriptRunner::callInternalFunction(v8::Handle<v8::Function>::Cast(value), info.This(), 0, 0, info.GetIsolate()));
}
v8::Handle<v8::FunctionTemplate> V8PerIsolateData::toStringTemplate()
diff --git a/Source/bindings/v8/V8PerIsolateData.h b/Source/bindings/v8/V8PerIsolateData.h
index d938340..51490c2 100644
--- a/Source/bindings/v8/V8PerIsolateData.h
+++ b/Source/bindings/v8/V8PerIsolateData.h
@@ -26,6 +26,7 @@
#ifndef V8PerIsolateData_h
#define V8PerIsolateData_h
+#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScopedPersistent.h"
#include "bindings/v8/UnsafePersistent.h"
#include "bindings/v8/V8HiddenValue.h"
@@ -43,7 +44,6 @@
class DOMDataStore;
class GCEventData;
class StringCache;
-class V8PerContextData;
struct WrapperTypeInfo;
class ExternalStringVisitor;
@@ -53,10 +53,6 @@
class V8PerIsolateData {
public:
static void ensureInitialized(v8::Isolate*);
- static V8PerIsolateData* current()
- {
- return from(v8::Isolate::GetCurrent());
- }
static V8PerIsolateData* from(v8::Isolate* isolate)
{
ASSERT(isolate);
@@ -119,7 +115,7 @@
OwnPtr<StringCache> m_stringCache;
OwnPtr<V8HiddenValue> m_hiddenValue;
ScopedPersistent<v8::Value> m_liveRoot;
- OwnPtr<V8PerContextData> m_domInJSPerContextData;
+ RefPtr<NewScriptState> m_blinkInJSScriptState;
const char* m_previousSamplingState;
diff --git a/Source/bindings/v8/V8RecursionScope.h b/Source/bindings/v8/V8RecursionScope.h
index 3bc3da7..7dc1bc1 100644
--- a/Source/bindings/v8/V8RecursionScope.h
+++ b/Source/bindings/v8/V8RecursionScope.h
@@ -57,50 +57,60 @@
class V8RecursionScope {
WTF_MAKE_NONCOPYABLE(V8RecursionScope);
public:
- explicit V8RecursionScope(ExecutionContext* context)
- : m_isDocumentContext(context && context->isDocument())
+ V8RecursionScope(v8::Isolate* isolate, ExecutionContext* context)
+ : m_isolate(isolate)
+ , m_isDocumentContext(context && context->isDocument())
{
- V8PerIsolateData::current()->incrementRecursionLevel();
+ V8PerIsolateData::from(m_isolate)->incrementRecursionLevel();
}
~V8RecursionScope()
{
- if (!V8PerIsolateData::current()->decrementRecursionLevel())
+ if (!V8PerIsolateData::from(m_isolate)->decrementRecursionLevel())
didLeaveScriptContext();
}
- static int recursionLevel()
+ static int recursionLevel(v8::Isolate* isolate)
{
- return V8PerIsolateData::current()->recursionLevel();
+ return V8PerIsolateData::from(isolate)->recursionLevel();
}
#ifndef NDEBUG
- static bool properlyUsed()
+ static bool properlyUsed(v8::Isolate* isolate)
{
- return recursionLevel() > 0 || V8PerIsolateData::current()->internalScriptRecursionLevel() > 0;
+ return recursionLevel(isolate) > 0 || V8PerIsolateData::from(isolate)->internalScriptRecursionLevel() > 0;
}
#endif
class MicrotaskSuppression {
public:
- MicrotaskSuppression()
+ MicrotaskSuppression(v8::Isolate* isolate)
+#ifndef NDEBUG
+ : m_isolate(isolate)
+#endif
{
#ifndef NDEBUG
- V8PerIsolateData::current()->incrementInternalScriptRecursionLevel();
+ V8PerIsolateData::from(m_isolate)->incrementInternalScriptRecursionLevel();
#endif
}
~MicrotaskSuppression()
{
#ifndef NDEBUG
- V8PerIsolateData::current()->decrementInternalScriptRecursionLevel();
+ V8PerIsolateData::from(m_isolate)->decrementInternalScriptRecursionLevel();
#endif
}
+
+ private:
+#ifndef NDEBUG
+ v8::Isolate* m_isolate;
+#endif
};
private:
void didLeaveScriptContext();
+ v8::Isolate* m_isolate;
bool m_isDocumentContext;
};
diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp
index 038d6fe..374132f 100644
--- a/Source/bindings/v8/V8ScriptRunner.cpp
+++ b/Source/bindings/v8/V8ScriptRunner.cpp
@@ -93,7 +93,7 @@
if (script.IsEmpty())
return v8::Local<v8::Value>();
- if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
+ if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
RELEASE_ASSERT(!context->isIteratingOverObservers());
@@ -101,7 +101,7 @@
// Run the script and keep track of the current recursion depth.
v8::Local<v8::Value> result;
{
- V8RecursionScope recursionScope(context);
+ V8RecursionScope recursionScope(isolate, context);
result = script->Run();
}
@@ -120,7 +120,7 @@
if (script.IsEmpty())
return v8::Local<v8::Value>();
- V8RecursionScope::MicrotaskSuppression recursionScope;
+ V8RecursionScope::MicrotaskSuppression recursionScope(isolate);
v8::Local<v8::Value> result = script->Run();
crashIfV8IsDead();
return result;
@@ -131,12 +131,12 @@
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- if (V8RecursionScope::recursionLevel() >= kMaxRecursionDepth)
+ if (V8RecursionScope::recursionLevel(isolate) >= kMaxRecursionDepth)
return handleMaxRecursionDepthExceeded(isolate);
RELEASE_ASSERT(!context->isIteratingOverObservers());
- V8RecursionScope recursionScope(context);
+ V8RecursionScope recursionScope(isolate, context);
v8::Local<v8::Value> result = function->Call(receiver, argc, args);
crashIfV8IsDead();
return result;
@@ -146,61 +146,50 @@
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- V8RecursionScope::MicrotaskSuppression recursionScope;
+ V8RecursionScope::MicrotaskSuppression recursionScope(isolate);
v8::Local<v8::Value> result = function->Call(receiver, argc, args);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callAsFunction(v8::Handle<v8::Object> object, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[])
+v8::Local<v8::Value> V8ScriptRunner::callAsFunction(v8::Isolate* isolate, v8::Handle<v8::Object> object, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> args[])
{
TRACE_EVENT0("v8", "v8.callFunction");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- V8RecursionScope::MicrotaskSuppression recursionScope;
+ V8RecursionScope::MicrotaskSuppression recursionScope(isolate);
v8::Local<v8::Value> result = object->CallAsFunction(receiver, argc, args);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Value> V8ScriptRunner::callAsConstructor(v8::Handle<v8::Object> object, int argc, v8::Handle<v8::Value> args[])
-{
- TRACE_EVENT0("v8", "v8.callFunction");
- TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
-
- V8RecursionScope::MicrotaskSuppression recursionScope;
- v8::Local<v8::Value> result = object->CallAsConstructor(argc, args);
- crashIfV8IsDead();
- return result;
-}
-
-v8::Local<v8::Object> V8ScriptRunner::instantiateObject(v8::Handle<v8::ObjectTemplate> objectTemplate)
+v8::Local<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolate, v8::Handle<v8::ObjectTemplate> objectTemplate)
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- V8RecursionScope::MicrotaskSuppression scope;
+ V8RecursionScope::MicrotaskSuppression scope(isolate);
v8::Local<v8::Object> result = objectTemplate->NewInstance();
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Object> V8ScriptRunner::instantiateObject(v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
+v8::Local<v8::Object> V8ScriptRunner::instantiateObject(v8::Isolate* isolate, v8::Handle<v8::Function> function, int argc, v8::Handle<v8::Value> argv[])
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- V8RecursionScope::MicrotaskSuppression scope;
+ V8RecursionScope::MicrotaskSuppression scope(isolate);
v8::Local<v8::Object> result = function->NewInstance(argc, argv);
crashIfV8IsDead();
return result;
}
-v8::Local<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Handle<v8::Function> function, ExecutionContext* context, int argc, v8::Handle<v8::Value> argv[])
+v8::Local<v8::Object> V8ScriptRunner::instantiateObjectInDocument(v8::Isolate* isolate, v8::Handle<v8::Function> function, ExecutionContext* context, int argc, v8::Handle<v8::Value> argv[])
{
TRACE_EVENT0("v8", "v8.newInstance");
TRACE_EVENT_SCOPED_SAMPLING_STATE("V8", "V8Execution");
- V8RecursionScope scope(context);
+ V8RecursionScope scope(isolate, context);
v8::Local<v8::Object> result = function->NewInstance(argc, argv);
crashIfV8IsDead();
return result;
diff --git a/Source/bindings/v8/V8ScriptRunner.h b/Source/bindings/v8/V8ScriptRunner.h
index 5bd36da..368401b 100644
--- a/Source/bindings/v8/V8ScriptRunner.h
+++ b/Source/bindings/v8/V8ScriptRunner.h
@@ -48,11 +48,10 @@
static v8::Local<v8::Value> compileAndRunInternalScript(v8::Handle<v8::String>, v8::Isolate*, const String& = String(), const TextPosition& = TextPosition());
static v8::Local<v8::Value> callInternalFunction(v8::Handle<v8::Function>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate*);
static v8::Local<v8::Value> callFunction(v8::Handle<v8::Function>, ExecutionContext*, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[], v8::Isolate*);
- static v8::Local<v8::Value> callAsFunction(v8::Handle<v8::Object>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]);
- static v8::Local<v8::Value> callAsConstructor(v8::Handle<v8::Object>, int argc, v8::Handle<v8::Value> info[]);
- static v8::Local<v8::Object> instantiateObject(v8::Handle<v8::ObjectTemplate>);
- static v8::Local<v8::Object> instantiateObject(v8::Handle<v8::Function>, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
- static v8::Local<v8::Object> instantiateObjectInDocument(v8::Handle<v8::Function>, ExecutionContext*, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
+ static v8::Local<v8::Value> callAsFunction(v8::Isolate*, v8::Handle<v8::Object>, v8::Handle<v8::Value> receiver, int argc, v8::Handle<v8::Value> info[]);
+ static v8::Local<v8::Object> instantiateObject(v8::Isolate*, v8::Handle<v8::ObjectTemplate>);
+ static v8::Local<v8::Object> instantiateObject(v8::Isolate*, v8::Handle<v8::Function>, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
+ static v8::Local<v8::Object> instantiateObjectInDocument(v8::Isolate*, v8::Handle<v8::Function>, ExecutionContext*, int argc = 0, v8::Handle<v8::Value> argv[] = 0);
};
diff --git a/Source/bindings/v8/V8WindowShell.cpp b/Source/bindings/v8/V8WindowShell.cpp
index 5e742fe..27e8aed 100644
--- a/Source/bindings/v8/V8WindowShell.cpp
+++ b/Source/bindings/v8/V8WindowShell.cpp
@@ -43,7 +43,6 @@
#include "bindings/v8/V8HiddenValue.h"
#include "bindings/v8/V8Initializer.h"
#include "bindings/v8/V8ObjectConstructor.h"
-#include "bindings/v8/V8PerContextData.h"
#include "core/html/HTMLCollection.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/inspector/InspectorInstrumentation.h"
@@ -85,24 +84,24 @@
V8WindowShell::V8WindowShell(LocalFrame* frame, PassRefPtr<DOMWrapperWorld> world, v8::Isolate* isolate)
: m_frame(frame)
- , m_world(world)
, m_isolate(isolate)
+ , m_world(world)
{
}
void V8WindowShell::disposeContext(GlobalDetachmentBehavior behavior)
{
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_perContextData->context();
+ v8::Handle<v8::Context> context = m_scriptState->context();
m_frame->loader().client()->willReleaseScriptContext(context, m_world->worldId());
if (behavior == DetachGlobal)
context->DetachGlobal();
- m_perContextData.clear();
+ m_scriptState->disposePerContextData();
// It's likely that disposing the context has created a lot of
// garbage. Notify V8 about this so it'll have a chance of cleaning
@@ -112,7 +111,7 @@
void V8WindowShell::clearForClose()
{
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
m_document.clear();
@@ -121,14 +120,12 @@
void V8WindowShell::clearForNavigation()
{
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
- v8::HandleScope handleScope(m_isolate);
- m_document.clear();
+ NewScriptState::Scope scope(m_scriptState.get());
- v8::Handle<v8::Context> context = m_perContextData->context();
- v8::Context::Scope contextScope(context);
+ m_document.clear();
// Clear the document wrapper cache before turning on access checks on
// the old DOMWindow wrapper. This way, access to the document wrapper
@@ -178,7 +175,7 @@
// it won't be able to reach the outer window via its global object.
bool V8WindowShell::initializeIfNeeded()
{
- if (m_perContextData)
+ if (isContextInitialized())
return true;
DOMWrapperWorld::setWorldOfInitializingWindow(m_world.get());
@@ -196,12 +193,11 @@
createContext();
- if (!m_perContextData)
+ if (!isContextInitialized())
return false;
- v8::Handle<v8::Context> context = m_perContextData->context();
- v8::Context::Scope contextScope(context);
-
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Handle<v8::Context> context = m_scriptState->context();
if (m_global.isEmpty()) {
m_global.set(m_isolate, context->Global());
if (m_global.isEmpty()) {
@@ -216,7 +212,7 @@
setInjectedScriptContextDebugId(context, m_frame->script().contextDebugId(mainWindow->context()));
}
- m_perContextData->setActivityLogger(V8DOMActivityLogger::activityLogger(m_world->worldId()));
+ m_scriptState->perContextData()->setActivityLogger(V8DOMActivityLogger::activityLogger(m_world->worldId()));
if (!installDOMWindow()) {
disposeContext(DoNotDetachGlobal);
return false;
@@ -281,7 +277,7 @@
v8::Handle<v8::Context> context = v8::Context::New(m_isolate, &extensionConfiguration, globalTemplate, m_global.newLocal(m_isolate));
if (context.IsEmpty())
return;
- m_perContextData = V8PerContextData::create(context, m_world);
+ m_scriptState = NewScriptState::create(context, m_world);
double contextCreationDurationInMilliseconds = (currentTime() - contextCreationStartInSeconds) * 1000;
const char* histogramName = "WebCore.V8WindowShell.createContext.MainWorld";
@@ -298,7 +294,7 @@
bool V8WindowShell::installDOMWindow()
{
DOMWindow* window = m_frame->domWindow();
- v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_perContextData->context())->constructorForType(&V8Window::wrapperTypeInfo));
+ v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(m_isolate, m_scriptState->perContextData()->constructorForType(&V8Window::wrapperTypeInfo));
if (windowWrapper.IsEmpty())
return false;
@@ -326,7 +322,7 @@
// already keeps a persistent reference, and it along with the inner global object
// views of the DOMWindow will die together once that wrapper clears the persistent
// reference.
- v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_perContextData->context());
+ v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_scriptState->context());
V8DOMWrapper::setNativeInfoForHiddenWrapper(innerGlobalObject, &V8Window::wrapperTypeInfo, window);
innerGlobalObject->SetPrototype(windowWrapper);
V8DOMWrapper::associateObjectWithWrapper<V8Window>(PassRefPtrWillBeRawPtr<DOMWindow>(window), &V8Window::wrapperTypeInfo, windowWrapper, m_isolate, WrapperConfiguration::Dependent);
@@ -344,10 +340,8 @@
if (!m_world->isMainWorld())
return;
- v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_perContextData->context();
- v8::Context::Scope contextScope(context);
-
+ NewScriptState::Scope scope(m_scriptState.get());
+ v8::Handle<v8::Context> context = m_scriptState->context();
v8::Handle<v8::Value> documentWrapper = toV8(m_frame->document(), v8::Handle<v8::Object>(), context->GetIsolate());
ASSERT(documentWrapper == m_document.newLocal(m_isolate) || m_document.isEmpty());
if (m_document.isEmpty())
@@ -371,11 +365,11 @@
void V8WindowShell::clearDocumentProperty()
{
- ASSERT(m_perContextData);
+ ASSERT(isContextInitialized());
if (!m_world->isMainWorld())
return;
v8::HandleScope handleScope(m_isolate);
- m_perContextData->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "document"));
+ m_scriptState->context()->Global()->ForceDelete(v8AtomicString(m_isolate, "document"));
}
void V8WindowShell::setSecurityToken(SecurityOrigin* origin)
@@ -399,7 +393,7 @@
// case, we use the global object as the security token to avoid
// calling canAccess when a script accesses its own objects.
v8::HandleScope handleScope(m_isolate);
- v8::Handle<v8::Context> context = m_perContextData->context();
+ v8::Handle<v8::Context> context = m_scriptState->context();
if (token.isEmpty() || token == "null") {
context->UseDefaultSecurityToken();
return;
@@ -414,9 +408,9 @@
void V8WindowShell::updateDocument()
{
ASSERT(m_world->isMainWorld());
- if (m_global.isEmpty())
+ if (!isGlobalInitialized())
return;
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
updateDocumentProperty();
updateSecurityOrigin(m_frame->document()->securityOrigin());
@@ -464,12 +458,10 @@
{
ASSERT(m_world->isMainWorld());
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
- v8::HandleScope handleScope(m_isolate);
- v8::Context::Scope contextScope(m_perContextData->context());
-
+ NewScriptState::Scope scope(m_scriptState.get());
ASSERT(!m_document.isEmpty());
v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
checkDocumentWrapper(documentHandle, document);
@@ -480,15 +472,13 @@
{
ASSERT(m_world->isMainWorld());
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
if (document->hasNamedItem(name) || document->hasExtraNamedItem(name))
return;
- v8::HandleScope handleScope(m_isolate);
- v8::Context::Scope contextScope(m_perContextData->context());
-
+ NewScriptState::Scope scope(m_scriptState.get());
ASSERT(!m_document.isEmpty());
v8::Handle<v8::Object> documentHandle = m_document.newLocal(m_isolate);
checkDocumentWrapper(documentHandle, document);
@@ -498,9 +488,8 @@
void V8WindowShell::updateSecurityOrigin(SecurityOrigin* origin)
{
ASSERT(m_world->isMainWorld());
- if (!m_perContextData)
+ if (!isContextInitialized())
return;
- v8::HandleScope handleScope(m_isolate);
setSecurityToken(origin);
}
diff --git a/Source/bindings/v8/V8WindowShell.h b/Source/bindings/v8/V8WindowShell.h
index de6c901..3e61d13 100644
--- a/Source/bindings/v8/V8WindowShell.h
+++ b/Source/bindings/v8/V8WindowShell.h
@@ -32,8 +32,8 @@
#define V8WindowShell_h
#include "bindings/v8/DOMWrapperWorld.h"
+#include "bindings/v8/NewScriptState.h"
#include "bindings/v8/ScopedPersistent.h"
-#include "bindings/v8/V8PerContextData.h"
#include "bindings/v8/WrapperTypeInfo.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "wtf/Forward.h"
@@ -57,7 +57,7 @@
public:
static PassOwnPtr<V8WindowShell> create(LocalFrame*, DOMWrapperWorld&, v8::Isolate*);
- v8::Local<v8::Context> context() const { return m_perContextData ? m_perContextData->context() : v8::Local<v8::Context>(); }
+ v8::Local<v8::Context> context() const { return m_scriptState ? m_scriptState->context() : v8::Local<v8::Context>(); }
// Update document object of the frame.
void updateDocument();
@@ -69,7 +69,7 @@
// (e.g., after setting docoument.domain).
void updateSecurityOrigin(SecurityOrigin*);
- bool isContextInitialized() { return m_perContextData; }
+ bool isContextInitialized() { return m_scriptState && !!m_scriptState->perContextData(); }
bool isGlobalInitialized() { return !m_global.isEmpty(); }
bool initializeIfNeeded();
@@ -105,9 +105,9 @@
static V8WindowShell* enteredIsolatedWorldContext();
LocalFrame* m_frame;
- RefPtr<DOMWrapperWorld> m_world;
v8::Isolate* m_isolate;
- OwnPtr<V8PerContextData> m_perContextData;
+ RefPtr<NewScriptState> m_scriptState;
+ RefPtr<DOMWrapperWorld> m_world;
ScopedPersistent<v8::Object> m_global;
ScopedPersistent<v8::Object> m_document;
};
diff --git a/Source/bindings/v8/WorkerScriptController.cpp b/Source/bindings/v8/WorkerScriptController.cpp
index 6127764..8262de9 100644
--- a/Source/bindings/v8/WorkerScriptController.cpp
+++ b/Source/bindings/v8/WorkerScriptController.cpp
@@ -50,7 +50,7 @@
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerObjectProxy.h"
#include "core/workers/WorkerThread.h"
-#include "heap/ThreadState.h"
+#include "platform/heap/ThreadState.h"
#include <v8.h>
#include "public/platform/Platform.h"
@@ -107,26 +107,24 @@
// See http://webkit.org/b/83104#c14 for why this is here.
blink::Platform::current()->didStopWorkerRunLoop(blink::WebWorkerRunLoop(&m_workerGlobalScope.thread()->runLoop()));
- disposeContext();
+ if (isContextInitialized())
+ m_scriptState->disposePerContextData();
ThreadState::current()->addCleanupTask(IsolateCleanupTask::create(m_isolate));
}
-void WorkerScriptController::disposeContext()
-{
- m_perContextData.clear();
-}
-
bool WorkerScriptController::initializeContextIfNeeded()
{
- if (m_perContextData)
+ v8::HandleScope handleScope(m_isolate);
+
+ if (isContextInitialized())
return true;
v8::Handle<v8::Context> context = v8::Context::New(m_isolate);
if (context.IsEmpty())
return false;
- m_perContextData = V8PerContextData::create(context, m_world);
+ m_scriptState = NewScriptState::create(context, m_world);
v8::Context::Scope scope(context);
@@ -139,17 +137,17 @@
contextType = &V8ServiceWorkerGlobalScope::wrapperTypeInfo;
else if (!m_workerGlobalScope.isDedicatedWorkerGlobalScope())
contextType = &V8SharedWorkerGlobalScope::wrapperTypeInfo;
- v8::Handle<v8::Function> workerGlobalScopeConstructor = m_perContextData->constructorForType(contextType);
- v8::Local<v8::Object> jsWorkerGlobalScope = V8ObjectConstructor::newInstance(workerGlobalScopeConstructor);
+ v8::Handle<v8::Function> workerGlobalScopeConstructor = m_scriptState->perContextData()->constructorForType(contextType);
+ v8::Local<v8::Object> jsWorkerGlobalScope = V8ObjectConstructor::newInstance(m_isolate, workerGlobalScopeConstructor);
if (jsWorkerGlobalScope.IsEmpty()) {
- disposeContext();
+ m_scriptState->disposePerContextData();
return false;
}
V8DOMWrapper::associateObjectWithWrapper<V8WorkerGlobalScope>(PassRefPtrWillBeRawPtr<WorkerGlobalScope>(&m_workerGlobalScope), contextType, jsWorkerGlobalScope, m_isolate, WrapperConfiguration::Dependent);
// Insert the object instance as the prototype of the shadow object.
- v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_perContextData->context()->Global()->GetPrototype());
+ v8::Handle<v8::Object> globalObject = v8::Handle<v8::Object>::Cast(m_scriptState->context()->Global()->GetPrototype());
globalObject->SetPrototype(jsWorkerGlobalScope);
return true;
@@ -157,20 +155,17 @@
ScriptValue WorkerScriptController::evaluate(const String& script, const String& fileName, const TextPosition& scriptStartPosition, WorkerGlobalScopeExecutionState* state)
{
- v8::HandleScope handleScope(m_isolate);
-
if (!initializeContextIfNeeded())
return ScriptValue();
- v8::Handle<v8::Context> context = m_perContextData->context();
+ NewScriptState::Scope scope(m_scriptState.get());
+
if (!m_disableEvalPending.isEmpty()) {
- context->AllowCodeGenerationFromStrings(false);
- context->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, m_disableEvalPending));
+ m_scriptState->context()->AllowCodeGenerationFromStrings(false);
+ m_scriptState->context()->SetErrorMessageForCodeGenerationFromStrings(v8String(m_isolate, m_disableEvalPending));
m_disableEvalPending = String();
}
- v8::Context::Scope scope(context);
-
v8::TryCatch block;
v8::Handle<v8::String> scriptString = v8String(m_isolate, script);
@@ -201,7 +196,7 @@
return ScriptValue(result, m_isolate);
}
-void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtr<ErrorEvent>* errorEvent)
+void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode, RefPtrWillBeRawPtr<ErrorEvent>* errorEvent)
{
if (isExecutionForbidden())
return;
@@ -215,7 +210,12 @@
V8ErrorHandler::storeExceptionOnErrorEventWrapper(errorEvent->get(), state.exception.v8Value(), m_isolate);
} else {
ASSERT(!m_workerGlobalScope.shouldSanitizeScriptError(state.sourceURL, NotSharableCrossOrigin));
- RefPtr<ErrorEvent> event = m_errorEventFromImportedScript ? m_errorEventFromImportedScript.release() : ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get());
+ RefPtrWillBeRawPtr<ErrorEvent> event = nullptr;
+ if (m_errorEventFromImportedScript) {
+ event = m_errorEventFromImportedScript.release();
+ } else {
+ event = ErrorEvent::create(state.errorMessage, state.sourceURL, state.lineNumber, state.columnNumber, m_world.get());
+ }
m_workerGlobalScope.reportException(event, nullptr, NotSharableCrossOrigin);
}
}
@@ -257,7 +257,7 @@
m_disableEvalPending = errorMessage;
}
-void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtr<ErrorEvent> errorEvent)
+void WorkerScriptController::rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEvent> errorEvent)
{
m_errorEventFromImportedScript = errorEvent;
throwError(V8ThrowException::createError(v8GeneralError, m_errorEventFromImportedScript->message(), m_isolate), m_isolate);
diff --git a/Source/bindings/v8/WorkerScriptController.h b/Source/bindings/v8/WorkerScriptController.h
index 5b46cf9..40b03df 100644
--- a/Source/bindings/v8/WorkerScriptController.h
+++ b/Source/bindings/v8/WorkerScriptController.h
@@ -68,9 +68,9 @@
WorkerGlobalScope& workerGlobalScope() { return m_workerGlobalScope; }
- void evaluate(const ScriptSourceCode&, RefPtr<ErrorEvent>* = 0);
+ void evaluate(const ScriptSourceCode&, RefPtrWillBeRawPtr<ErrorEvent>* = 0);
- void rethrowExceptionFromImportedScript(PassRefPtr<ErrorEvent>);
+ void rethrowExceptionFromImportedScript(PassRefPtrWillBeRawPtr<ErrorEvent>);
// Async request to terminate a future JS execution. Eventually causes termination
// exception raised during JS execution, if the worker thread happens to run JS.
@@ -92,7 +92,8 @@
v8::Isolate* isolate() const { return m_isolate; }
DOMWrapperWorld& world() const { return *m_world; }
- v8::Local<v8::Context> context() { return m_perContextData ? m_perContextData->context() : v8::Local<v8::Context>(); }
+ v8::Local<v8::Context> context() { return m_scriptState ? m_scriptState->context() : v8::Local<v8::Context>(); }
+ bool isContextInitialized() { return m_scriptState && !!m_scriptState->perContextData(); }
// Send a notification about current thread is going to be idle.
// Returns true if the embedder should stop calling idleNotification
@@ -101,17 +102,16 @@
private:
bool initializeContextIfNeeded();
- void disposeContext();
v8::Isolate* m_isolate;
WorkerGlobalScope& m_workerGlobalScope;
- OwnPtr<V8PerContextData> m_perContextData;
- String m_disableEvalPending;
+ RefPtr<NewScriptState> m_scriptState;
RefPtr<DOMWrapperWorld> m_world;
+ String m_disableEvalPending;
bool m_executionForbidden;
bool m_executionScheduledToTerminate;
mutable Mutex m_scheduledTerminationMutex;
- RefPtr<ErrorEvent> m_errorEventFromImportedScript;
+ RefPtrWillBePersistent<ErrorEvent> m_errorEventFromImportedScript;
OwnPtr<V8IsolateInterruptor> m_interruptor;
};
diff --git a/Source/bindings/v8/WrapperTypeInfo.h b/Source/bindings/v8/WrapperTypeInfo.h
index dbba09e..313c45c 100644
--- a/Source/bindings/v8/WrapperTypeInfo.h
+++ b/Source/bindings/v8/WrapperTypeInfo.h
@@ -63,6 +63,12 @@
WrapperTypeExceptionPrototype
};
+ enum GCType {
+ GarbageCollectedObject,
+ WillBeGarbageCollectedObject,
+ RefCountedObject,
+ };
+
inline void setObjectGroup(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate)
{
isolate->SetObjectGroupId(wrapper, v8::UniqueId(reinterpret_cast<intptr_t>(object)));
@@ -138,7 +144,7 @@
const InstallPerContextEnabledPrototypePropertiesFunction installPerContextEnabledMethodsFunction;
const WrapperTypeInfo* parentClass;
const WrapperTypePrototype wrapperTypePrototype;
- const bool isGarbageCollected;
+ const GCType gcType;
};
@@ -189,20 +195,25 @@
inline void releaseObject(v8::Handle<v8::Object> wrapper)
{
const WrapperTypeInfo* typeInfo = toWrapperTypeInfo(wrapper);
-#if ENABLE(OILPAN)
- if (typeInfo->isGarbageCollected) {
+ if (typeInfo->gcType == GarbageCollectedObject) {
const PersistentNode* handle = toPersistentHandle(wrapper);
// This will be null iff a wrapper for a hidden wrapper object,
// see V8DOMWrapper::setNativeInfoForHiddenWrapper().
delete handle;
+ } else if (typeInfo->gcType == WillBeGarbageCollectedObject) {
+#if ENABLE(OILPAN)
+ const PersistentNode* handle = toPersistentHandle(wrapper);
+ // This will be null iff a wrapper for a hidden wrapper object,
+ // see V8DOMWrapper::setNativeInfoForHiddenWrapper().
+ delete handle;
+#else
+ ASSERT(typeInfo->derefObjectFunction);
+ typeInfo->derefObjectFunction(toNative(wrapper));
+#endif
} else {
ASSERT(typeInfo->derefObjectFunction);
typeInfo->derefObjectFunction(toNative(wrapper));
}
-#else
- ASSERT(typeInfo->derefObjectFunction);
- typeInfo->derefObjectFunction(toNative(wrapper));
-#endif
}
struct WrapperConfiguration {
@@ -211,7 +222,7 @@
Dependent, Independent
};
- void configureWrapper(v8::Persistent<v8::Object>* wrapper) const
+ void configureWrapper(v8::PersistentBase<v8::Object>* wrapper) const
{
wrapper->SetWrapperClassId(classId);
if (lifetime == Independent)
diff --git a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
index bc02218..f3494cf 100644
--- a/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
+++ b/Source/bindings/v8/custom/V8ArrayBufferCustom.cpp
@@ -48,7 +48,7 @@
const WrapperTypeInfo V8ArrayBuffer::wrapperTypeInfo = {
gin::kEmbedderBlink,
0, V8ArrayBuffer::derefObject,
- 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, false
+ 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, RefCountedObject
};
bool V8ArrayBuffer::hasInstance(v8::Handle<v8::Value> value, v8::Isolate*)
diff --git a/Source/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp b/Source/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp
deleted file mode 100644
index 77916a7..0000000
--- a/Source/bindings/v8/custom/V8BiquadFilterNodeCustom.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(WEB_AUDIO)
-#include "V8BiquadFilterNode.h"
-
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/V8Binding.h"
-#include "modules/webaudio/BiquadFilterNode.h"
-
-namespace WebCore {
-
-void V8BiquadFilterNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- ExceptionState exceptionState(ExceptionState::SetterContext, "type", "BiquadFilterNode", info.Holder(), info.GetIsolate());
- BiquadFilterNode* impl = V8BiquadFilterNode::toNative(info.Holder());
-
- if (value->IsNumber()) {
- uint32_t type = toUInt32(value, exceptionState);
- if (exceptionState.throwIfNeeded())
- return;
- if (!impl->setType(type)) {
- exceptionState.throwTypeError("Illegal BiquadFilterNode type");
- exceptionState.throwIfNeeded();
- }
- return;
- }
-
- if (value->IsString()) {
- String type = toCoreString(value.As<v8::String>());
- if (type == "lowpass" || type == "highpass" || type == "bandpass" || type == "lowshelf" || type == "highshelf" || type == "peaking" || type == "notch" || type == "allpass") {
- impl->setType(type);
- return;
- }
- }
-
- exceptionState.throwTypeError("Illegal BiquadFilterNode type");
- exceptionState.throwIfNeeded();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/bindings/v8/custom/V8CryptoCustom.cpp b/Source/bindings/v8/custom/V8CryptoCustom.cpp
index f43b552..ac7e1be 100644
--- a/Source/bindings/v8/custom/V8CryptoCustom.cpp
+++ b/Source/bindings/v8/custom/V8CryptoCustom.cpp
@@ -35,9 +35,6 @@
namespace WebCore {
-// This custom binding is shared by V8WorkerCrypto. As such:
-// * Do not call V8Crypto::toNative()
-// * Must be threadsafe
void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomValues", "Crypto", info.Holder(), info.GetIsolate());
@@ -54,7 +51,8 @@
ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handle<v8::Object>::Cast(buffer));
ASSERT(arrayBufferView);
- Crypto::getRandomValues(arrayBufferView, exceptionState);
+ Crypto* crypto = V8Crypto::toNative(info.Holder());
+ crypto->getRandomValues(arrayBufferView, exceptionState);
}
if (exceptionState.throwIfNeeded())
diff --git a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
index 473515e..0b63453 100644
--- a/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
+++ b/Source/bindings/v8/custom/V8InjectedScriptManager.cpp
@@ -58,7 +58,7 @@
// Return if allocation failed.
return v8::Local<v8::Object>();
}
- v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(function);
+ v8::Local<v8::Object> instanceTemplate = V8ObjectConstructor::newInstance(isolate, function);
if (instanceTemplate.IsEmpty()) {
// Avoid setting the wrapper if allocation failed.
return v8::Local<v8::Object>();
diff --git a/Source/bindings/v8/custom/V8OscillatorNodeCustom.cpp b/Source/bindings/v8/custom/V8OscillatorNodeCustom.cpp
deleted file mode 100644
index ca00520..0000000
--- a/Source/bindings/v8/custom/V8OscillatorNodeCustom.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(WEB_AUDIO)
-#include "V8OscillatorNode.h"
-
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/V8Binding.h"
-#include "modules/webaudio/OscillatorNode.h"
-
-namespace WebCore {
-
-void V8OscillatorNode::typeAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- ExceptionState exceptionState(ExceptionState::SetterContext, "type", "OscillatorNode", info.Holder(), info.GetIsolate());
- v8::Handle<v8::Object> holder = info.Holder();
- OscillatorNode* impl = V8OscillatorNode::toNative(holder);
-
- if (value->IsNumber()) {
- uint32_t type = toUInt32(value, exceptionState);
- if (exceptionState.throwIfNeeded())
- return;
- if (!impl->setType(type)) {
- exceptionState.throwTypeError("Illegal OscillatorNode type");
- exceptionState.throwIfNeeded();
- }
- return;
- }
-
- if (value->IsString()) {
- String type = toCoreString(value.As<v8::String>());
- if (type == "sine" || type == "square" || type == "sawtooth" || type == "triangle") {
- impl->setType(type);
- return;
- }
- }
-
- exceptionState.throwTypeError("Illegal OscillatorNode type");
- exceptionState.throwIfNeeded();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/bindings/v8/custom/V8PannerNodeCustom.cpp b/Source/bindings/v8/custom/V8PannerNodeCustom.cpp
deleted file mode 100644
index c9e2f2d..0000000
--- a/Source/bindings/v8/custom/V8PannerNodeCustom.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2012, Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(WEB_AUDIO)
-#include "V8PannerNode.h"
-
-#include "bindings/v8/ExceptionState.h"
-#include "bindings/v8/V8Binding.h"
-#include "modules/webaudio/PannerNode.h"
-
-namespace WebCore {
-
-void V8PannerNode::panningModelAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- ExceptionState exceptionState(ExceptionState::SetterContext, "panningModel", "PannerNode", info.Holder(), info.GetIsolate());
- PannerNode* impl = V8PannerNode::toNative(info.Holder());
-
- if (value->IsNumber()) {
- uint32_t model = toUInt32(value, exceptionState);
- if (exceptionState.throwIfNeeded())
- return;
- if (!impl->setPanningModel(model)) {
- exceptionState.throwTypeError("Illegal panningModel");
- exceptionState.throwIfNeeded();
- }
- return;
- }
-
- if (value->IsString()) {
- String model = toCoreString(value.As<v8::String>());
- if (model == "equalpower" || model == "HRTF") {
- impl->setPanningModel(model);
- return;
- }
- }
-
- exceptionState.throwTypeError("Illegal panningModel");
- exceptionState.throwIfNeeded();
-}
-
-void V8PannerNode::distanceModelAttributeSetterCustom(v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
-{
- ExceptionState exceptionState(ExceptionState::SetterContext, "distanceModel", "PannerNode", info.Holder(), info.GetIsolate());
- PannerNode* impl = V8PannerNode::toNative(info.Holder());
-
- if (value->IsNumber()) {
- uint32_t model = toUInt32(value, exceptionState);
- if (exceptionState.throwIfNeeded())
- return;
- if (!impl->setDistanceModel(model)) {
- exceptionState.throwTypeError("Illegal distanceModel");
- exceptionState.throwIfNeeded();
- }
- return;
- }
-
- if (value->IsString()) {
- String model = toCoreString(value.As<v8::String>());
- if (model == "linear" || model == "inverse" || model == "exponential") {
- impl->setDistanceModel(model);
- return;
- }
- }
-
- exceptionState.throwTypeError("Illegal distanceModel");
- exceptionState.throwIfNeeded();
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(WEB_AUDIO)
diff --git a/Source/bindings/v8/custom/V8PromiseCustom.cpp b/Source/bindings/v8/custom/V8PromiseCustom.cpp
index e1eabac..c6c8fb5 100644
--- a/Source/bindings/v8/custom/V8PromiseCustom.cpp
+++ b/Source/bindings/v8/custom/V8PromiseCustom.cpp
@@ -236,7 +236,7 @@
: m_promise(isolate, promise)
, m_handler(isolate, handler)
, m_argument(isolate, argument)
- , m_requestState(context)
+ , m_requestState(isolate)
{
ASSERT(!m_promise.isEmpty());
ASSERT(!m_handler.isEmpty());
@@ -281,7 +281,7 @@
, m_onFulfilled(isolate, onFulfilled)
, m_onRejected(isolate, onRejected)
, m_originatorValueObject(isolate, originatorValueObject)
- , m_requestState(context)
+ , m_requestState(isolate)
{
ASSERT(!m_promise.isEmpty());
ASSERT(!m_originatorValueObject.isEmpty());
diff --git a/Source/bindings/v8/custom/V8TypedArrayCustom.h b/Source/bindings/v8/custom/V8TypedArrayCustom.h
index 09076a6..fac7a11 100644
--- a/Source/bindings/v8/custom/V8TypedArrayCustom.h
+++ b/Source/bindings/v8/custom/V8TypedArrayCustom.h
@@ -180,7 +180,7 @@
const WrapperTypeInfo V8TypedArray<TypedArray>::wrapperTypeInfo = {
gin::kEmbedderBlink,
0, V8TypedArray<TypedArray>::derefObject,
- 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, false
+ 0, 0, 0, 0, 0, WrapperTypeObjectPrototype, RefCountedObject
};
template <typename TypedArray>
diff --git a/Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp b/Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp
deleted file mode 100644
index acf7a11..0000000
--- a/Source/bindings/v8/custom/V8WorkerCryptoCustom.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "V8WorkerCrypto.h"
-
-#include "V8Crypto.h"
-
-namespace WebCore {
-
-void V8WorkerCrypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
-{
- V8Crypto::getRandomValuesMethodCustom(info);
-}
-
-} // namespace WebCore