OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1546 int header_id = block->parent_loop_header()->block_id(); | 1546 int header_id = block->parent_loop_header()->block_id(); |
1547 loop_side_effects_[header_id].Add(block->IsLoopHeader() | 1547 loop_side_effects_[header_id].Add(block->IsLoopHeader() |
1548 ? loop_side_effects_[id] | 1548 ? loop_side_effects_[id] |
1549 : side_effects); | 1549 : side_effects); |
1550 } | 1550 } |
1551 } | 1551 } |
1552 } | 1552 } |
1553 | 1553 |
1554 | 1554 |
1555 SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { | 1555 SmartArrayPointer<char> GetGVNFlagsString(GVNFlagSet flags) { |
1556 char underlying_buffer[kLastFlag * 128]; | |
1557 Vector<char> buffer(underlying_buffer, sizeof(underlying_buffer)); | |
1556 #if DEBUG | 1558 #if DEBUG |
1557 char buffer[kLastFlag * 128]; | 1559 int offset = 0; |
1558 const char* separator = ""; | 1560 const char* separator = ""; |
1559 const char* comma = ", "; | 1561 const char* comma = ", "; |
1560 buffer[0] = 0; | 1562 buffer[0] = 0; |
1561 uint32_t set_depends_on = 0; | 1563 uint32_t set_depends_on = 0; |
1562 uint32_t set_changes = 0; | 1564 uint32_t set_changes = 0; |
1563 for (int bit = 0; bit < kLastFlag; ++bit) { | 1565 for (int bit = 0; bit < kLastFlag; ++bit) { |
1564 if ((flags.ToIntegral() & (1 << bit)) != 0) { | 1566 if ((flags.ToIntegral() & (1 << bit)) != 0) { |
1565 if (bit % 2 == 0) { | 1567 if (bit % 2 == 0) { |
1566 set_changes++; | 1568 set_changes++; |
1567 } else { | 1569 } else { |
1568 set_depends_on++; | 1570 set_depends_on++; |
1569 } | 1571 } |
1570 } | 1572 } |
1571 } | 1573 } |
1572 bool positive_changes = set_changes < (kLastFlag / 2); | 1574 bool positive_changes = set_changes < (kLastFlag / 2); |
1573 bool positive_depends_on = set_depends_on < (kLastFlag / 2); | 1575 bool positive_depends_on = set_depends_on < (kLastFlag / 2); |
1574 if (set_changes > 0) { | 1576 if (set_changes > 0) { |
1575 if (positive_changes) { | 1577 if (positive_changes) { |
1576 strcat(buffer, "changes ["); | 1578 offset += OS::SNPrintF(buffer + offset, "changes ["); |
1577 } else { | 1579 } else { |
1578 strcat(buffer, "changes all except ["); | 1580 offset += OS::SNPrintF(buffer + offset, "changes all except ["); |
1579 } | 1581 } |
1580 for (int bit = 0; bit < kLastFlag; ++bit) { | 1582 for (int bit = 0; bit < kLastFlag; ++bit) { |
1581 if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_changes) { | 1583 if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_changes) { |
1582 switch (static_cast<GVNFlag>(bit)) { | 1584 switch (static_cast<GVNFlag>(bit)) { |
1583 #define DECLARE_FLAG(type) \ | 1585 #define DECLARE_FLAG(type) \ |
1584 case kChanges##type: \ | 1586 case kChanges##type: \ |
1585 strcat(buffer, separator); \ | 1587 offset += OS::SNPrintF(buffer + offset, separator); \ |
1586 strcat(buffer, #type); \ | 1588 offset += OS::SNPrintF(buffer + offset, #type); \ |
1587 separator = comma; \ | 1589 separator = comma; \ |
1588 break; | 1590 break; |
1589 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) | 1591 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) |
1590 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) | 1592 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
1591 #undef DECLARE_FLAG | 1593 #undef DECLARE_FLAG |
1592 default: | 1594 default: |
1593 break; | 1595 break; |
1594 } | 1596 } |
1595 } | 1597 } |
1596 } | 1598 } |
1597 strcat(buffer, "]"); | 1599 offset += OS::SNPrintF(buffer + offset, "]"); |
1598 } | 1600 } |
1599 if (set_depends_on > 0) { | 1601 if (set_depends_on > 0) { |
1600 separator = ""; | 1602 separator = ""; |
1601 if (set_changes > 0) { | 1603 if (set_changes > 0) { |
1602 strcat(buffer, ", "); | 1604 offset += OS::SNPrintF(buffer + offset, ", "); |
1603 } | 1605 } |
1604 if (positive_depends_on) { | 1606 if (positive_depends_on) { |
1605 strcat(buffer, "depends on ["); | 1607 offset += OS::SNPrintF(buffer + offset, "depends on ["); |
1606 } else { | 1608 } else { |
1607 strcat(buffer, "depends on all except ["); | 1609 offset += OS::SNPrintF(buffer + offset, "depends on all except ["); |
1608 } | 1610 } |
1609 for (int bit = 0; bit < kLastFlag; ++bit) { | 1611 for (int bit = 0; bit < kLastFlag; ++bit) { |
1610 if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_depends_on) { | 1612 if (((flags.ToIntegral() & (1 << bit)) != 0) == positive_depends_on) { |
1611 switch (static_cast<GVNFlag>(bit)) { | 1613 switch (static_cast<GVNFlag>(bit)) { |
1612 #define DECLARE_FLAG(type) \ | 1614 #define DECLARE_FLAG(type) \ |
1613 case kDependsOn##type: \ | 1615 case kDependsOn##type: \ |
1614 strcat(buffer, separator); \ | 1616 offset += OS::SNPrintF(buffer + offset, separator); \ |
1615 strcat(buffer, #type); \ | 1617 offset += OS::SNPrintF(buffer + offset, #type); \ |
1616 separator = comma; \ | 1618 separator = comma; \ |
1617 break; | 1619 break; |
1618 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) | 1620 GVN_TRACKED_FLAG_LIST(DECLARE_FLAG) |
1619 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) | 1621 GVN_UNTRACKED_FLAG_LIST(DECLARE_FLAG) |
1620 #undef DECLARE_FLAG | 1622 #undef DECLARE_FLAG |
1621 default: | 1623 default: |
1622 break; | 1624 break; |
1623 } | 1625 } |
1624 } | 1626 } |
1625 } | 1627 } |
1626 strcat(buffer, "]"); | 1628 offset += OS::SNPrintF(buffer + offset, "]"); |
1627 } | 1629 } |
1628 #else | 1630 #else |
1629 char buffer[128]; | 1631 OS::SNPrintF(buffer, "0x%08X", flags.ToIntegral()); |
1630 snprintf(buffer, 128, "0x%08X", flags.ToIntegral()); | |
1631 #endif | 1632 #endif |
1632 char* result = new char[strlen(buffer) + 1]; | 1633 uint32_t string_len = strlen(underlying_buffer) + 1; |
1633 strcpy(result, buffer); | 1634 if (string_len > sizeof(underlying_buffer)) { |
Michael Starzinger
2012/04/25 13:09:53
I think this condition can never be true. Can we d
danno
2012/04/25 15:40:34
Done.
| |
1635 string_len = sizeof(underlying_buffer); | |
1636 } | |
1637 char* result = new char[strlen(underlying_buffer) + 1]; | |
1638 memcpy(result, underlying_buffer, string_len); | |
1634 return SmartArrayPointer<char>(result); | 1639 return SmartArrayPointer<char>(result); |
1635 } | 1640 } |
1636 | 1641 |
1637 | 1642 |
1638 void HGlobalValueNumberer::LoopInvariantCodeMotion() { | 1643 void HGlobalValueNumberer::LoopInvariantCodeMotion() { |
1639 for (int i = graph_->blocks()->length() - 1; i >= 0; --i) { | 1644 for (int i = graph_->blocks()->length() - 1; i >= 0; --i) { |
1640 HBasicBlock* block = graph_->blocks()->at(i); | 1645 HBasicBlock* block = graph_->blocks()->at(i); |
1641 if (block->IsLoopHeader()) { | 1646 if (block->IsLoopHeader()) { |
1642 GVNFlagSet side_effects = loop_side_effects_[block->block_id()]; | 1647 GVNFlagSet side_effects = loop_side_effects_[block->block_id()]; |
1643 TraceGVN("Try loop invariant motion for block B%d %s\n", | 1648 TraceGVN("Try loop invariant motion for block B%d %s\n", |
(...skipping 6814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8458 } | 8463 } |
8459 } | 8464 } |
8460 | 8465 |
8461 #ifdef DEBUG | 8466 #ifdef DEBUG |
8462 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 8467 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
8463 if (allocator_ != NULL) allocator_->Verify(); | 8468 if (allocator_ != NULL) allocator_->Verify(); |
8464 #endif | 8469 #endif |
8465 } | 8470 } |
8466 | 8471 |
8467 } } // namespace v8::internal | 8472 } } // namespace v8::internal |
OLD | NEW |