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

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

Issue 1491923003: Improve rendering of callsite with non-function target. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests Created 5 years 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/parsing/preparser.h ('k') | test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js » ('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 a2933e5bedd2ae0f5b6312433d757e4a8bccd2dc..3c78ce276f7ffb5158aca08dc2abe753423d36c7 100644
--- a/src/runtime/runtime-internal.cc
+++ b/src/runtime/runtime-internal.cc
@@ -412,18 +412,44 @@ RUNTIME_FUNCTION(Runtime_GetCodeStubExportsObject) {
namespace {
+bool ComputeLocation(Isolate* isolate, MessageLocation* target) {
+ JavaScriptFrameIterator it(isolate);
+ if (!it.done()) {
+ JavaScriptFrame* frame = it.frame();
+ JSFunction* fun = frame->function();
+ Object* script = fun->shared()->script();
+ if (script->IsScript() &&
+ !(Script::cast(script)->source()->IsUndefined())) {
+ Handle<Script> casted_script(Script::cast(script));
+ // Compute the location from the function and the relocation info of the
+ // baseline code. For optimized code this will use the deoptimization
+ // information to get canonical location information.
+ List<FrameSummary> frames(FLAG_max_inlining_levels + 1);
+ it.frame()->Summarize(&frames);
+ FrameSummary& summary = frames.last();
+ int pos = summary.code()->SourcePosition(summary.pc());
+ *target = MessageLocation(casted_script, pos, pos + 1, handle(fun));
+ return true;
+ }
+ }
+ return false;
+}
+
+
Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) {
MessageLocation location;
- if (isolate->ComputeLocation(&location)) {
+ if (ComputeLocation(isolate, &location)) {
Zone zone;
base::SmartPointer<ParseInfo> info(
location.function()->shared()->is_function()
? new ParseInfo(&zone, location.function())
: new ParseInfo(&zone, location.script()));
if (Parser::ParseStatic(info.get())) {
- CallPrinter printer(isolate);
+ CallPrinter printer(isolate, location.function()->shared()->IsBuiltin());
const char* string = printer.Print(info->literal(), location.start_pos());
- return isolate->factory()->NewStringFromAsciiChecked(string);
+ if (strlen(string) > 0) {
+ return isolate->factory()->NewStringFromAsciiChecked(string);
+ }
} else {
isolate->clear_pending_exception();
}
« no previous file with comments | « src/parsing/preparser.h ('k') | test/mjsunit/es6/debug-promises/throw-with-undefined-reject.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698