| 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 1920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 Object* allocation_site_obj = | 1931 Object* allocation_site_obj = |
| 1932 VisitWeakList<AllocationSite>(this, | 1932 VisitWeakList<AllocationSite>(this, |
| 1933 allocation_sites_list(), | 1933 allocation_sites_list(), |
| 1934 retainer, record_slots); | 1934 retainer, record_slots); |
| 1935 set_allocation_sites_list(allocation_site_obj); | 1935 set_allocation_sites_list(allocation_site_obj); |
| 1936 } | 1936 } |
| 1937 | 1937 |
| 1938 | 1938 |
| 1939 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { | 1939 void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { |
| 1940 DisallowHeapAllocation no_allocation; | 1940 DisallowHeapAllocation no_allocation; |
| 1941 | 1941 // All external strings are listed in the external string table. |
| 1942 // Both the external string table and the string table may contain | |
| 1943 // external strings, but neither lists them exhaustively, nor is the | |
| 1944 // intersection set empty. Therefore we iterate over the external string | |
| 1945 // table first, ignoring internalized strings, and then over the | |
| 1946 // internalized string table. | |
| 1947 | 1942 |
| 1948 class ExternalStringTableVisitorAdapter : public ObjectVisitor { | 1943 class ExternalStringTableVisitorAdapter : public ObjectVisitor { |
| 1949 public: | 1944 public: |
| 1950 explicit ExternalStringTableVisitorAdapter( | 1945 explicit ExternalStringTableVisitorAdapter( |
| 1951 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} | 1946 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} |
| 1952 virtual void VisitPointers(Object** start, Object** end) { | 1947 virtual void VisitPointers(Object** start, Object** end) { |
| 1953 for (Object** p = start; p < end; p++) { | 1948 for (Object** p = start; p < end; p++) { |
| 1954 // Visit non-internalized external strings, | 1949 ASSERT((*p)->IsExternalString()); |
| 1955 // since internalized strings are listed in the string table. | 1950 visitor_->VisitExternalString(Utils::ToLocal( |
| 1956 if (!(*p)->IsInternalizedString()) { | 1951 Handle<String>(String::cast(*p)))); |
| 1957 ASSERT((*p)->IsExternalString()); | |
| 1958 visitor_->VisitExternalString(Utils::ToLocal( | |
| 1959 Handle<String>(String::cast(*p)))); | |
| 1960 } | |
| 1961 } | 1952 } |
| 1962 } | 1953 } |
| 1963 private: | 1954 private: |
| 1964 v8::ExternalResourceVisitor* visitor_; | 1955 v8::ExternalResourceVisitor* visitor_; |
| 1965 } external_string_table_visitor(visitor); | 1956 } external_string_table_visitor(visitor); |
| 1966 | 1957 |
| 1967 external_string_table_.Iterate(&external_string_table_visitor); | 1958 external_string_table_.Iterate(&external_string_table_visitor); |
| 1968 | |
| 1969 class StringTableVisitorAdapter : public ObjectVisitor { | |
| 1970 public: | |
| 1971 explicit StringTableVisitorAdapter( | |
| 1972 v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} | |
| 1973 virtual void VisitPointers(Object** start, Object** end) { | |
| 1974 for (Object** p = start; p < end; p++) { | |
| 1975 if ((*p)->IsExternalString()) { | |
| 1976 ASSERT((*p)->IsInternalizedString()); | |
| 1977 visitor_->VisitExternalString(Utils::ToLocal( | |
| 1978 Handle<String>(String::cast(*p)))); | |
| 1979 } | |
| 1980 } | |
| 1981 } | |
| 1982 private: | |
| 1983 v8::ExternalResourceVisitor* visitor_; | |
| 1984 } string_table_visitor(visitor); | |
| 1985 | |
| 1986 string_table()->IterateElements(&string_table_visitor); | |
| 1987 } | 1959 } |
| 1988 | 1960 |
| 1989 | 1961 |
| 1990 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { | 1962 class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { |
| 1991 public: | 1963 public: |
| 1992 static inline void VisitPointer(Heap* heap, Object** p) { | 1964 static inline void VisitPointer(Heap* heap, Object** p) { |
| 1993 Object* object = *p; | 1965 Object* object = *p; |
| 1994 if (!heap->InNewSpace(object)) return; | 1966 if (!heap->InNewSpace(object)) return; |
| 1995 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), | 1967 Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), |
| 1996 reinterpret_cast<HeapObject*>(object)); | 1968 reinterpret_cast<HeapObject*>(object)); |
| (...skipping 5988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7985 static_cast<int>(object_sizes_last_time_[index])); | 7957 static_cast<int>(object_sizes_last_time_[index])); |
| 7986 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 7958 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 7987 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 7959 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 7988 | 7960 |
| 7989 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 7961 OS::MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 7990 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 7962 OS::MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 7991 ClearObjectStats(); | 7963 ClearObjectStats(); |
| 7992 } | 7964 } |
| 7993 | 7965 |
| 7994 } } // namespace v8::internal | 7966 } } // namespace v8::internal |
| OLD | NEW |