Chromium Code Reviews| Index: Source/bindings/v8/V8ScriptRunner.cpp |
| diff --git a/Source/bindings/v8/V8ScriptRunner.cpp b/Source/bindings/v8/V8ScriptRunner.cpp |
| index c4ddf18073efa8e4b7a8f09c38325c19449bc3a1..042183342f9ce6bc974218e895bbb294875d24a2 100644 |
| --- a/Source/bindings/v8/V8ScriptRunner.cpp |
| +++ b/Source/bindings/v8/V8ScriptRunner.cpp |
| @@ -26,6 +26,7 @@ |
| #include "config.h" |
| #include "bindings/v8/V8ScriptRunner.h" |
| +#include "bindings/v8/ScopedPersistent.h" |
| #include "bindings/v8/V8Binding.h" |
| #include "bindings/v8/V8GCController.h" |
| #include "bindings/v8/V8RecursionScope.h" |
| @@ -62,4 +63,30 @@ v8::Local<v8::Value> V8ScriptRunner::runCompiledScript(v8::Handle<v8::Script> sc |
| return result; |
| } |
| +v8::Local<v8::Value> V8ScriptRunner::compileAndRunInternalScript(v8::Handle<v8::String> source, v8::Isolate* isolate) |
| +{ |
| + v8::HandleScope handleScope; |
|
abarth-chromium
2013/05/17 16:21:12
There's a HandleScope here.
|
| + ScopedPersistent<v8::Context> context; |
| + v8::Local<v8::Value> result; |
|
abarth-chromium
2013/05/17 16:21:12
result is a local handle.
|
| + context.set(v8::Context::New(isolate)); |
| + if (context.isEmpty()) |
| + return result; |
| + |
| + { |
| + v8::Context::Scope scope(context.get()); |
| + v8::TryCatch tryCatch; |
| + v8::Handle<v8::Script> script = v8::Script::Compile(source); |
| + if (script.IsEmpty() || tryCatch.HasCaught()) |
| + return result; |
| + |
| + V8RecursionScope::MicrotaskSuppression recursionScope; |
| + result = script->Run(); |
| + if (tryCatch.HasCaught()) |
| + return result; |
|
abarth-chromium
2013/05/17 16:21:12
... and we return it.... Isn't that a memory corr
haraken
2013/05/17 16:23:41
Great catch... I have to use HandleScope::Close().
haraken
2013/05/20 00:32:59
Fixed the stale handlescope issue.
|
| + } |
| + |
| + context.clear(); |
| + return result; |
| +} |
| + |
| } // namespace WebCore |