From 7a172d54ba1e17fc12cb3a54ca83e39dd3b60ef8 Mon Sep 17 00:00:00 2001 From: mvstanton Date: Thu, 30 Jul 2015 04:09:42 -0700 Subject: [PATCH] VectorICs: --print-ast now prints allocated vector slots Looks like this: --- AST --- FUNC . NAME "foo" . INFERRED NAME "" . RETURN . . PROPERTY ICSlot(0, LOAD_IC) . . . VAR PROXY ICSlot(1, LOAD_IC) (mode = DYNAMIC_GLOBAL) "a" . . . NAME x BUG= R=rossberg@chromium.org Review URL: https://codereview.chromium.org/1264823003 Cr-Commit-Position: refs/heads/master@{#29928} --- src/prettyprinter.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc index 6a7718a..9bc4e6a 100644 --- a/src/prettyprinter.cc +++ b/src/prettyprinter.cc @@ -419,6 +419,18 @@ void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { #ifdef DEBUG +// A helper for ast nodes that use FeedbackVectorICSlots. +static int FormatICSlotNode(Vector* buf, Expression* node, + const char* node_name, FeedbackVectorICSlot slot) { + int pos = SNPrintF(*buf, "%s", node_name); + if (!slot.IsInvalid()) { + const char* str = Code::Kind2String(node->FeedbackICSlotKind(0)); + pos = SNPrintF(*buf + pos, " ICSlot(%d, %s)", slot.ToInt(), str); + } + return pos; +} + + PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) { output_ = NULL; size_ = 0; @@ -1430,11 +1442,12 @@ void AstPrinter::VisitArrayLiteral(ArrayLiteral* node) { } -// TODO(svenpanne) Start with IndentedScope. void AstPrinter::VisitVariableProxy(VariableProxy* node) { Variable* var = node->var(); EmbeddedVector buf; - int pos = SNPrintF(buf, "VAR PROXY"); + int pos = + FormatICSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot()); + switch (var->location()) { case VariableLocation::UNALLOCATED: break; @@ -1478,7 +1491,10 @@ void AstPrinter::VisitThrow(Throw* node) { void AstPrinter::VisitProperty(Property* node) { - IndentedScope indent(this, "PROPERTY"); + EmbeddedVector buf; + FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot()); + IndentedScope indent(this, buf.start()); + Visit(node->obj()); Literal* literal = node->key()->AsLiteral(); if (literal != NULL && literal->value()->IsInternalizedString()) { @@ -1490,7 +1506,10 @@ void AstPrinter::VisitProperty(Property* node) { void AstPrinter::VisitCall(Call* node) { - IndentedScope indent(this, "CALL"); + EmbeddedVector buf; + FormatICSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot()); + IndentedScope indent(this, buf.start()); + Visit(node->expression()); PrintArguments(node->arguments()); } @@ -1504,7 +1523,9 @@ void AstPrinter::VisitCallNew(CallNew* node) { void AstPrinter::VisitCallRuntime(CallRuntime* node) { - IndentedScope indent(this, "CALL RUNTIME"); + EmbeddedVector buf; + FormatICSlotNode(&buf, node, "CALL RUNTIME", node->CallRuntimeFeedbackSlot()); + IndentedScope indent(this, buf.start()); PrintLiteralIndented("NAME", node->name(), false); PrintArguments(node->arguments()); } -- 2.7.4