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 1558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1569 } | 1569 } |
1570 | 1570 |
1571 // Update the head of the list of contexts. | 1571 // Update the head of the list of contexts. |
1572 native_contexts_list_ = head; | 1572 native_contexts_list_ = head; |
1573 } | 1573 } |
1574 | 1574 |
1575 | 1575 |
1576 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { | 1576 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
1577 AssertNoAllocation no_allocation; | 1577 AssertNoAllocation no_allocation; |
1578 | 1578 |
1579 class VisitorAdapter : public ObjectVisitor { | 1579 // Both the external string table and the symbol table may contain |
| 1580 // external strings, but neither lists them exhaustively, nor is the |
| 1581 // intersection set empty. Therefore we iterate over the external string |
| 1582 // table first, ignoring symbols, and then over the symbol table. |
| 1583 |
| 1584 class ExternalStringTableVisitorAdapter : public ObjectVisitor { |
1580 public: | 1585 public: |
1581 explicit VisitorAdapter(v8::ExternalResourceVisitor* visitor) | 1586 explicit ExternalStringTableVisitorAdapter( |
1582 : visitor_(visitor) {} | 1587 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} |
| 1588 virtual void VisitPointers(Object** start, Object** end) { |
| 1589 for (Object** p = start; p < end; p++) { |
| 1590 // Visit non-symbol external strings, |
| 1591 // since symbols are listed in the symbol table. |
| 1592 if (!(*p)->IsSymbol()) { |
| 1593 ASSERT((*p)->IsExternalString()); |
| 1594 visitor_->VisitExternalString(Utils::ToLocal( |
| 1595 Handle<String>(String::cast(*p)))); |
| 1596 } |
| 1597 } |
| 1598 } |
| 1599 private: |
| 1600 v8::ExternalResourceVisitor* visitor_; |
| 1601 } external_string_table_visitor(visitor); |
| 1602 |
| 1603 external_string_table_.Iterate(&external_string_table_visitor); |
| 1604 |
| 1605 class SymbolTableVisitorAdapter : public ObjectVisitor { |
| 1606 public: |
| 1607 explicit SymbolTableVisitorAdapter( |
| 1608 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} |
1583 virtual void VisitPointers(Object** start, Object** end) { | 1609 virtual void VisitPointers(Object** start, Object** end) { |
1584 for (Object** p = start; p < end; p++) { | 1610 for (Object** p = start; p < end; p++) { |
1585 if ((*p)->IsExternalString()) { | 1611 if ((*p)->IsExternalString()) { |
| 1612 ASSERT((*p)->IsSymbol()); |
1586 visitor_->VisitExternalString(Utils::ToLocal( | 1613 visitor_->VisitExternalString(Utils::ToLocal( |
1587 Handle<String>(String::cast(*p)))); | 1614 Handle<String>(String::cast(*p)))); |
1588 } | 1615 } |
1589 } | 1616 } |
1590 } | 1617 } |
1591 private: | 1618 private: |
1592 v8::ExternalResourceVisitor* visitor_; | 1619 v8::ExternalResourceVisitor* visitor_; |
1593 } visitor_adapter(visitor); | 1620 } symbol_table_visitor(visitor); |
1594 external_string_table_.Iterate(&visitor_adapter); | 1621 |
| 1622 symbol_table()->IterateElements(&symbol_table_visitor); |
1595 } | 1623 } |
1596 | 1624 |
1597 | 1625 |
1598 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { | 1626 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { |
1599 public: | 1627 public: |
1600 static inline void VisitPointer(Heap* heap, Object** p) { | 1628 static inline void VisitPointer(Heap* heap, Object** p) { |
1601 Object* object = *p; | 1629 Object* object = *p; |
1602 if (!heap->InNewSpace(object)) return; | 1630 if (!heap->InNewSpace(object)) return; |
1603 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 1631 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
1604 reinterpret_cast<HeapObject*>(object)); | 1632 reinterpret_cast<HeapObject*>(object)); |
(...skipping 5762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7367 static_cast<int>(object_sizes_last_time_[index])); | 7395 static_cast<int>(object_sizes_last_time_[index])); |
7368 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7396 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7369 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7397 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7370 | 7398 |
7371 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7399 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7372 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7400 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7373 ClearObjectStats(); | 7401 ClearObjectStats(); |
7374 } | 7402 } |
7375 | 7403 |
7376 } } // namespace v8::internal | 7404 } } // namespace v8::internal |
OLD | NEW |