OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdarg.h> | 5 #include <stdarg.h> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 | 8 |
9 #include "src/ast-value-factory.h" | 9 #include "src/ast-value-factory.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { | 412 void CallPrinter::PrintLiteral(const AstRawString* value, bool quote) { |
413 PrintLiteral(value->string(), quote); | 413 PrintLiteral(value->string(), quote); |
414 } | 414 } |
415 | 415 |
416 | 416 |
417 //----------------------------------------------------------------------------- | 417 //----------------------------------------------------------------------------- |
418 | 418 |
419 | 419 |
420 #ifdef DEBUG | 420 #ifdef DEBUG |
421 | 421 |
| 422 // A helper for ast nodes that use FeedbackVectorICSlots. |
| 423 static int FormatICSlotNode(Vector<char>* buf, Expression* node, |
| 424 const char* node_name, FeedbackVectorICSlot slot) { |
| 425 int pos = SNPrintF(*buf, "%s", node_name); |
| 426 if (!slot.IsInvalid()) { |
| 427 const char* str = Code::Kind2String(node->FeedbackICSlotKind(0)); |
| 428 pos = SNPrintF(*buf + pos, " ICSlot(%d, %s)", slot.ToInt(), str); |
| 429 } |
| 430 return pos; |
| 431 } |
| 432 |
| 433 |
422 PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) { | 434 PrettyPrinter::PrettyPrinter(Isolate* isolate, Zone* zone) { |
423 output_ = NULL; | 435 output_ = NULL; |
424 size_ = 0; | 436 size_ = 0; |
425 pos_ = 0; | 437 pos_ = 0; |
426 InitializeAstVisitor(isolate, zone); | 438 InitializeAstVisitor(isolate, zone); |
427 } | 439 } |
428 | 440 |
429 | 441 |
430 PrettyPrinter::~PrettyPrinter() { | 442 PrettyPrinter::~PrettyPrinter() { |
431 DeleteArray(output_); | 443 DeleteArray(output_); |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 PrintIndented(buf.start()); | 1435 PrintIndented(buf.start()); |
1424 if (node->values()->length() > 0) { | 1436 if (node->values()->length() > 0) { |
1425 IndentedScope indent(this, "VALUES"); | 1437 IndentedScope indent(this, "VALUES"); |
1426 for (int i = 0; i < node->values()->length(); i++) { | 1438 for (int i = 0; i < node->values()->length(); i++) { |
1427 Visit(node->values()->at(i)); | 1439 Visit(node->values()->at(i)); |
1428 } | 1440 } |
1429 } | 1441 } |
1430 } | 1442 } |
1431 | 1443 |
1432 | 1444 |
1433 // TODO(svenpanne) Start with IndentedScope. | |
1434 void AstPrinter::VisitVariableProxy(VariableProxy* node) { | 1445 void AstPrinter::VisitVariableProxy(VariableProxy* node) { |
1435 Variable* var = node->var(); | 1446 Variable* var = node->var(); |
1436 EmbeddedVector<char, 128> buf; | 1447 EmbeddedVector<char, 128> buf; |
1437 int pos = SNPrintF(buf, "VAR PROXY"); | 1448 int pos = |
| 1449 FormatICSlotNode(&buf, node, "VAR PROXY", node->VariableFeedbackSlot()); |
| 1450 |
1438 switch (var->location()) { | 1451 switch (var->location()) { |
1439 case VariableLocation::UNALLOCATED: | 1452 case VariableLocation::UNALLOCATED: |
1440 break; | 1453 break; |
1441 case VariableLocation::PARAMETER: | 1454 case VariableLocation::PARAMETER: |
1442 SNPrintF(buf + pos, " parameter[%d]", var->index()); | 1455 SNPrintF(buf + pos, " parameter[%d]", var->index()); |
1443 break; | 1456 break; |
1444 case VariableLocation::LOCAL: | 1457 case VariableLocation::LOCAL: |
1445 SNPrintF(buf + pos, " local[%d]", var->index()); | 1458 SNPrintF(buf + pos, " local[%d]", var->index()); |
1446 break; | 1459 break; |
1447 case VariableLocation::CONTEXT: | 1460 case VariableLocation::CONTEXT: |
(...skipping 23 matching lines...) Expand all Loading... |
1471 } | 1484 } |
1472 | 1485 |
1473 | 1486 |
1474 void AstPrinter::VisitThrow(Throw* node) { | 1487 void AstPrinter::VisitThrow(Throw* node) { |
1475 IndentedScope indent(this, "THROW"); | 1488 IndentedScope indent(this, "THROW"); |
1476 Visit(node->exception()); | 1489 Visit(node->exception()); |
1477 } | 1490 } |
1478 | 1491 |
1479 | 1492 |
1480 void AstPrinter::VisitProperty(Property* node) { | 1493 void AstPrinter::VisitProperty(Property* node) { |
1481 IndentedScope indent(this, "PROPERTY"); | 1494 EmbeddedVector<char, 128> buf; |
| 1495 FormatICSlotNode(&buf, node, "PROPERTY", node->PropertyFeedbackSlot()); |
| 1496 IndentedScope indent(this, buf.start()); |
| 1497 |
1482 Visit(node->obj()); | 1498 Visit(node->obj()); |
1483 Literal* literal = node->key()->AsLiteral(); | 1499 Literal* literal = node->key()->AsLiteral(); |
1484 if (literal != NULL && literal->value()->IsInternalizedString()) { | 1500 if (literal != NULL && literal->value()->IsInternalizedString()) { |
1485 PrintLiteralIndented("NAME", literal->value(), false); | 1501 PrintLiteralIndented("NAME", literal->value(), false); |
1486 } else { | 1502 } else { |
1487 PrintIndentedVisit("KEY", node->key()); | 1503 PrintIndentedVisit("KEY", node->key()); |
1488 } | 1504 } |
1489 } | 1505 } |
1490 | 1506 |
1491 | 1507 |
1492 void AstPrinter::VisitCall(Call* node) { | 1508 void AstPrinter::VisitCall(Call* node) { |
1493 IndentedScope indent(this, "CALL"); | 1509 EmbeddedVector<char, 128> buf; |
| 1510 FormatICSlotNode(&buf, node, "CALL", node->CallFeedbackICSlot()); |
| 1511 IndentedScope indent(this, buf.start()); |
| 1512 |
1494 Visit(node->expression()); | 1513 Visit(node->expression()); |
1495 PrintArguments(node->arguments()); | 1514 PrintArguments(node->arguments()); |
1496 } | 1515 } |
1497 | 1516 |
1498 | 1517 |
1499 void AstPrinter::VisitCallNew(CallNew* node) { | 1518 void AstPrinter::VisitCallNew(CallNew* node) { |
1500 IndentedScope indent(this, "CALL NEW"); | 1519 IndentedScope indent(this, "CALL NEW"); |
1501 Visit(node->expression()); | 1520 Visit(node->expression()); |
1502 PrintArguments(node->arguments()); | 1521 PrintArguments(node->arguments()); |
1503 } | 1522 } |
1504 | 1523 |
1505 | 1524 |
1506 void AstPrinter::VisitCallRuntime(CallRuntime* node) { | 1525 void AstPrinter::VisitCallRuntime(CallRuntime* node) { |
1507 IndentedScope indent(this, "CALL RUNTIME"); | 1526 EmbeddedVector<char, 128> buf; |
| 1527 FormatICSlotNode(&buf, node, "CALL RUNTIME", node->CallRuntimeFeedbackSlot()); |
| 1528 IndentedScope indent(this, buf.start()); |
1508 PrintLiteralIndented("NAME", node->name(), false); | 1529 PrintLiteralIndented("NAME", node->name(), false); |
1509 PrintArguments(node->arguments()); | 1530 PrintArguments(node->arguments()); |
1510 } | 1531 } |
1511 | 1532 |
1512 | 1533 |
1513 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { | 1534 void AstPrinter::VisitUnaryOperation(UnaryOperation* node) { |
1514 IndentedScope indent(this, Token::Name(node->op())); | 1535 IndentedScope indent(this, Token::Name(node->op())); |
1515 Visit(node->expression()); | 1536 Visit(node->expression()); |
1516 } | 1537 } |
1517 | 1538 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1557 | 1578 |
1558 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { | 1579 void AstPrinter::VisitSuperCallReference(SuperCallReference* node) { |
1559 IndentedScope indent(this, "SUPER-CALL-REFERENCE"); | 1580 IndentedScope indent(this, "SUPER-CALL-REFERENCE"); |
1560 } | 1581 } |
1561 | 1582 |
1562 | 1583 |
1563 #endif // DEBUG | 1584 #endif // DEBUG |
1564 | 1585 |
1565 } // namespace internal | 1586 } // namespace internal |
1566 } // namespace v8 | 1587 } // namespace v8 |
OLD | NEW |