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); | |
erikcorry
2012/11/02 12:02:58
Please add a blank line here between the class def
| |
1602 external_string_table_.Iterate(&external_string_table_visitor); | |
1603 | |
1604 class SymbolTableVisitorAdapter : public ObjectVisitor { | |
1605 public: | |
1606 explicit SymbolTableVisitorAdapter( | |
1607 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} | |
1583 virtual void VisitPointers(Object** start, Object** end) { | 1608 virtual void VisitPointers(Object** start, Object** end) { |
1584 for (Object** p = start; p < end; p++) { | 1609 for (Object** p = start; p < end; p++) { |
1585 if ((*p)->IsExternalString()) { | 1610 if ((*p)->IsExternalString()) { |
1611 ASSERT((*p)->IsSymbol()); | |
1586 visitor_->VisitExternalString(Utils::ToLocal( | 1612 visitor_->VisitExternalString(Utils::ToLocal( |
1587 Handle<String>(String::cast(*p)))); | 1613 Handle<String>(String::cast(*p)))); |
1588 } | 1614 } |
1589 } | 1615 } |
1590 } | 1616 } |
1591 private: | 1617 private: |
1592 v8::ExternalResourceVisitor* visitor_; | 1618 v8::ExternalResourceVisitor* visitor_; |
1593 } visitor_adapter(visitor); | 1619 } symbol_table_visitor(visitor); |
erikcorry
2012/11/02 12:02:58
Blank line here please.
| |
1594 external_string_table_.Iterate(&visitor_adapter); | 1620 symbol_table()->IterateElements(&symbol_table_visitor); |
1595 } | 1621 } |
1596 | 1622 |
1597 | 1623 |
1598 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { | 1624 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { |
1599 public: | 1625 public: |
1600 static inline void VisitPointer(Heap* heap, Object** p) { | 1626 static inline void VisitPointer(Heap* heap, Object** p) { |
1601 Object* object = *p; | 1627 Object* object = *p; |
1602 if (!heap->InNewSpace(object)) return; | 1628 if (!heap->InNewSpace(object)) return; |
1603 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 1629 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
1604 reinterpret_cast<HeapObject*>(object)); | 1630 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])); | 7393 static_cast<int>(object_sizes_last_time_[index])); |
7368 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) | 7394 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) |
7369 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7395 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
7370 | 7396 |
7371 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7397 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
7372 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7398 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
7373 ClearObjectStats(); | 7399 ClearObjectStats(); |
7374 } | 7400 } |
7375 | 7401 |
7376 } } // namespace v8::internal | 7402 } } // namespace v8::internal |
OLD | NEW |