WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Proposed fix
62345.patch (text/plain), 8.31 KB, created by
Dmitry Lomov
on 2011-06-08 18:16:57 PDT
(
hide
)
Description:
Proposed fix
Filename:
MIME Type:
Creator:
Dmitry Lomov
Created:
2011-06-08 18:16:57 PDT
Size:
8.31 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 76398c1..c36c1a7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,31 @@ >+2011-06-08 Dmitry Lomov <dslomov@google.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ https://bugs.webkit.org/show_bug.cgi?id=62345 >+ Use per-isolate embedder data instead of statics for caches in bindings. >+ This is a prerequisite for more than one v8 isolate per process. >+ >+ * bindings/scripts/CodeGeneratorV8.pm: >+ * bindings/v8/V8Binding.cpp: >+ (WebCore::V8BindingPerIsolateData::V8BindingPerIsolateData): >+ (WebCore::V8BindingPerIsolateData::~V8BindingPerIsolateData): >+ (WebCore::V8BindingPerIsolateData::create): >+ (WebCore::V8BindingPerIsolateData::dispose): >+ (WebCore::getToStringName): >+ (WebCore::getToStringTemplate): >+ * bindings/v8/V8Binding.h: >+ (WebCore::V8BindingPerIsolateData::get): >+ (WebCore::V8BindingPerIsolateData::current): >+ (WebCore::V8BindingPerIsolateData::rawTemplateMap): >+ (WebCore::V8BindingPerIsolateData::templateMap): >+ (WebCore::V8BindingPerIsolateData::toStringName): >+ (WebCore::V8BindingPerIsolateData::toStringTemplate): >+ * bindings/v8/V8DOMWindowShell.cpp: >+ (WebCore::V8DOMWindowShell::initContextIfNeeded): >+ * bindings/v8/WorkerContextExecutionProxy.cpp: >+ (WebCore::WorkerContextExecutionProxy::initV8IfNeeded): >+ > 2011-06-08 James Simonsen <simonjam@chromium.org> > > Reviewed by Tony Gentilcore. >diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >index 3a5d866..ab971d3 100644 >--- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >+++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm >@@ -2201,14 +2201,30 @@ END > > v8::Persistent<v8::FunctionTemplate> ${className}::GetRawTemplate() > { >- static v8::Persistent<v8::FunctionTemplate> ${className}RawCache = createRawTemplate(); >- return ${className}RawCache; >+ V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); >+ V8BindingPerIsolateData::TemplateMap::iterator result = >+ data->rawTemplateMap().find(&info); >+ if (result != data->rawTemplateMap().end()) { >+ return result->second; >+ } >+ v8::HandleScope handle_scope; >+ v8::Persistent<v8::FunctionTemplate> templ = createRawTemplate(); >+ data->rawTemplateMap().add(&info, templ); >+ return templ; > } > >-v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate()\ >+v8::Persistent<v8::FunctionTemplate> ${className}::GetTemplate() > { >- static v8::Persistent<v8::FunctionTemplate> ${className}Cache = Configure${className}Template(GetRawTemplate()); >- return ${className}Cache; >+ V8BindingPerIsolateData* data = V8BindingPerIsolateData::current(); >+ V8BindingPerIsolateData::TemplateMap::iterator result = >+ data->templateMap().find(&info); >+ if (result != data->templateMap().end()) { >+ return result->second; >+ } >+ v8::Persistent<v8::FunctionTemplate> templ = >+ Configure${className}Template(GetRawTemplate()); >+ data->templateMap().add(&info, templ); >+ return templ; > } > > bool ${className}::HasInstance(v8::Handle<v8::Value> value) >diff --git a/Source/WebCore/bindings/v8/V8Binding.cpp b/Source/WebCore/bindings/v8/V8Binding.cpp >index 2acd29a..66858a6 100644 >--- a/Source/WebCore/bindings/v8/V8Binding.cpp >+++ b/Source/WebCore/bindings/v8/V8Binding.cpp >@@ -47,6 +47,33 @@ > > namespace WebCore { > >+ >+V8BindingPerIsolateData::V8BindingPerIsolateData(v8::Isolate* isolate) >+{ >+} >+ >+V8BindingPerIsolateData::~V8BindingPerIsolateData() >+{ >+} >+ >+V8BindingPerIsolateData* V8BindingPerIsolateData::create(v8::Isolate* isolate) >+{ >+ ASSERT(isolate); >+ ASSERT(!isolate->GetData()); >+ V8BindingPerIsolateData* data = new V8BindingPerIsolateData(isolate); >+ isolate->SetData(data); >+ return data; >+} >+ >+void V8BindingPerIsolateData::dispose(v8::Isolate* isolate) >+{ >+ void* data = isolate->GetData(); >+ if (data) >+ delete static_cast<V8BindingPerIsolateData*>(data); >+} >+ >+ >+ > // WebCoreStringResource is a helper class for v8ExternalString. It is used > // to manage the life-cycle of the underlying buffer of the external string. > class WebCoreStringResource : public v8::String::ExternalStringResource { >@@ -540,10 +567,11 @@ v8::Local<v8::Signature> configureTemplate(v8::Persistent<v8::FunctionTemplate> > > v8::Persistent<v8::String> getToStringName() > { >- DEFINE_STATIC_LOCAL(v8::Persistent<v8::String>, value, ()); >- if (value.IsEmpty()) >- value = v8::Persistent<v8::String>::New(v8::String::New("toString")); >- return value; >+ v8::Persistent<v8::String>& toStringName = V8BindingPerIsolateData::current()->toStringName(); >+ if (toStringName.IsEmpty()) >+ toStringName = v8::Persistent<v8::String>::New(v8::String::New("toString")); >+ return *toStringName; >+ > } > > static v8::Handle<v8::Value> constructorToString(const v8::Arguments& args) >@@ -564,7 +592,7 @@ static v8::Handle<v8::Value> constructorToString(const v8::Arguments& args) > > v8::Persistent<v8::FunctionTemplate> getToStringTemplate() > { >- DEFINE_STATIC_LOCAL(v8::Persistent<v8::FunctionTemplate>, toStringTemplate, ()); >+ v8::Persistent<v8::FunctionTemplate>& toStringTemplate = V8BindingPerIsolateData::current()->toStringTemplate(); > if (toStringTemplate.IsEmpty()) > toStringTemplate = v8::Persistent<v8::FunctionTemplate>::New(v8::FunctionTemplate::New(constructorToString)); > return toStringTemplate; >diff --git a/Source/WebCore/bindings/v8/V8Binding.h b/Source/WebCore/bindings/v8/V8Binding.h >index 7873b54..371cc8b 100644 >--- a/Source/WebCore/bindings/v8/V8Binding.h >+++ b/Source/WebCore/bindings/v8/V8Binding.h >@@ -50,6 +50,39 @@ namespace WebCore { > }; > typedef BindingSecurity<V8Binding> V8BindingSecurity; > >+ class V8BindingPerIsolateData { >+ public: >+ static V8BindingPerIsolateData* create(v8::Isolate*); >+ static V8BindingPerIsolateData* get(v8::Isolate* isolate) >+ { >+ ASSERT(isolate->GetData()); >+ return static_cast<V8BindingPerIsolateData*>(isolate->GetData()); >+ } >+ >+ static V8BindingPerIsolateData* current() >+ { >+ return get(v8::Isolate::GetCurrent()); >+ } >+ static void dispose(v8::Isolate*); >+ >+ typedef HashMap<WrapperTypeInfo*, v8::Persistent<v8::FunctionTemplate> > TemplateMap; >+ >+ TemplateMap& rawTemplateMap() { return m_rawTemplates; } >+ TemplateMap& templateMap() { return m_templates; } >+ v8::Persistent<v8::String>& toStringName() { return m_toStringName; } >+ v8::Persistent<v8::FunctionTemplate>& toStringTemplate() { return m_toStringTemplate; } >+ >+ private: >+ V8BindingPerIsolateData(v8::Isolate*); >+ ~V8BindingPerIsolateData(); >+ >+ TemplateMap m_rawTemplates; >+ TemplateMap m_templates; >+ v8::Persistent<v8::String> m_toStringName; >+ v8::Persistent<v8::FunctionTemplate> m_toStringTemplate; >+ }; >+ >+ > enum ExternalMode { > Externalize, > DoNotExternalize >diff --git a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp >index 5831641..95017f2 100644 >--- a/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp >+++ b/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp >@@ -299,11 +299,12 @@ bool V8DOMWindowShell::initContextIfNeeded() > v8::V8::SetFailedAccessCheckCallbackFunction(reportUnsafeJavaScriptAccess); > > ScriptProfiler::initialize(); >- >+ >+ V8BindingPerIsolateData::create(v8::Isolate::GetCurrent()); >+ > isV8Initialized = true; > } > >- > m_context = createNewContext(m_global, 0); > if (m_context.IsEmpty()) > return false; >diff --git a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >index 42259d5..9752b73 100644 >--- a/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >+++ b/Source/WebCore/bindings/v8/WorkerContextExecutionProxy.cpp >@@ -124,6 +124,8 @@ void WorkerContextExecutionProxy::initV8IfNeeded() > resource_constraints.set_stack_limit(&here - kWorkerMaxStackSize / sizeof(uint32_t*)); > v8::SetResourceConstraints(&resource_constraints); > >+ V8BindingPerIsolateData::create(v8::Isolate::GetCurrent()); >+ > v8Initialized = true; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 62345
:
96525
|
96747
|
96765
|
96803
|
97008
|
97010