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

Unified Diff: src/runtime/runtime-internal.cc

Issue 861623002: Add a pretty printer to improve the error message non-function calls (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 5 years, 11 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 | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-internal.cc
diff --git a/src/runtime/runtime-internal.cc b/src/runtime/runtime-internal.cc
index 79dfaced96ca90c502deb46ae23c7d1afb42745e..38f238b1cdd76e7fc90f21b7689c33b7201ac268 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -7,6 +7,9 @@
#include "src/arguments.h"
#include "src/bootstrapper.h"
#include "src/debug.h"
+#include "src/messages.h"
+#include "src/parser.h"
+#include "src/prettyprinter.h"
#include "src/runtime/runtime-utils.h"
namespace v8 {
@@ -153,6 +156,30 @@ RUNTIME_FUNCTION(Runtime_CollectStackTrace) {
}
+RUNTIME_FUNCTION(Runtime_RenderCallSite) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 0);
+ MessageLocation location;
+ isolate->ComputeLocation(&location);
+ if (location.start_pos() == -1) return isolate->heap()->empty_string();
+
+ Zone zone(isolate);
+ if (location.function()->shared()->is_function()) {
+ CompilationInfo info(location.function(), &zone);
+ if (!Parser::Parse(&info)) return isolate->heap()->empty_string();
+ CallPrinter printer(&zone);
+ const char* string = printer.Print(info.function(), location.start_pos());
+ return *isolate->factory()->NewStringFromAsciiChecked(string);
+ }
+
+ CompilationInfo info(location.script(), &zone);
+ if (!Parser::Parse(&info)) return isolate->heap()->empty_string();
+ CallPrinter printer(&zone);
+ const char* string = printer.Print(info.function(), location.start_pos());
+ return *isolate->factory()->NewStringFromAsciiChecked(string);
+}
+
+
RUNTIME_FUNCTION(Runtime_GetFromCache) {
SealHandleScope shs(isolate);
// This is only called from codegen, so checks might be more lax.
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698