Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: sky/engine/bindings/core/v8/V8ScriptRunner.cpp

Issue 688033003: Fix line numbers in JavaScript stack traces (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove unnecessary Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/bindings/core/v8/V8ScriptRunner.h ('k') | sky/engine/core/html/parser/HTMLScriptRunner.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/bindings/core/v8/V8ScriptRunner.cpp
diff --git a/sky/engine/bindings/core/v8/V8ScriptRunner.cpp b/sky/engine/bindings/core/v8/V8ScriptRunner.cpp
index 3eea6afadfe2aa7c40bb4ce93e5767d53bc21238..33e8faef7ed871bb79f7789ff72c77a7c799b8e1 100644
--- a/sky/engine/bindings/core/v8/V8ScriptRunner.cpp
+++ b/sky/engine/bindings/core/v8/V8ScriptRunner.cpp
@@ -201,16 +201,34 @@ void V8ScriptRunner::runModule(v8::Isolate* isolate, ExecutionContext* context,
TRACE_EVENT_SCOPED_SAMPLING_STATE("v8", "V8Execution");
V8RecursionScope scope(isolate, context);
- v8::Handle<v8::Function> constructor = V8PerContextData::from(
- isolate->GetCurrentContext())->functionConstructor();
- v8::Handle<v8::Object> function = v8::Handle<v8::Object>::Cast(
- constructor->CallAsConstructor(module.formalDependenciesAndSource.size(),
- module.formalDependenciesAndSource.data()));
- if (!function.IsEmpty()) {
- function->CallAsFunction(module.receiver,
- module.resolvedDependencies.size(),
- module.resolvedDependencies.data());
+ StringBuilder hackedSource;
+ hackedSource.append("(function(");
+ for (String& formal : module.formalDependencies) {
+ hackedSource.append(formal);
+ hackedSource.append(", ");
}
+ hackedSource.append("module) {");
+ hackedSource.append(module.source);
+ hackedSource.append("\n/**/})");
+
+ v8::Handle<v8::Script> script = compileScript(
+ v8String(isolate, hackedSource.toString()),
+ module.resourceName,
+ module.textPosition,
+ isolate,
+ V8CacheOptionsOff);
+
+ if (script.IsEmpty())
+ return;
+
+ v8::Handle<v8::Value> scriptResult = script->Run();
+
+ auto arguments = module.resolvedDependencies;
+ arguments.append(module.receiver);
+
+ RELEASE_ASSERT(scriptResult->IsObject());
+ scriptResult.As<v8::Object>()->CallAsFunction(
+ module.receiver, arguments.size(), arguments.data());
crashIfV8IsDead();
}
« no previous file with comments | « sky/engine/bindings/core/v8/V8ScriptRunner.h ('k') | sky/engine/core/html/parser/HTMLScriptRunner.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698