| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 | 683 |
| 684 void Heap::MarkCompactPrologue(bool is_compacting) { | 684 void Heap::MarkCompactPrologue(bool is_compacting) { |
| 685 // At any old GC clear the keyed lookup cache to enable collection of unused | 685 // At any old GC clear the keyed lookup cache to enable collection of unused |
| 686 // maps. | 686 // maps. |
| 687 isolate_->keyed_lookup_cache()->Clear(); | 687 isolate_->keyed_lookup_cache()->Clear(); |
| 688 isolate_->context_slot_cache()->Clear(); | 688 isolate_->context_slot_cache()->Clear(); |
| 689 isolate_->descriptor_lookup_cache()->Clear(); | 689 isolate_->descriptor_lookup_cache()->Clear(); |
| 690 | 690 |
| 691 isolate_->compilation_cache()->MarkCompactPrologue(); | 691 isolate_->compilation_cache()->MarkCompactPrologue(); |
| 692 | 692 |
| 693 Top::MarkCompactPrologue(is_compacting); | 693 Isolate::Current()->MarkCompactPrologue(is_compacting); |
| 694 ThreadManager::MarkCompactPrologue(is_compacting); | 694 ThreadManager::MarkCompactPrologue(is_compacting); |
| 695 | 695 |
| 696 CompletelyClearInstanceofCache(); | 696 CompletelyClearInstanceofCache(); |
| 697 | 697 |
| 698 if (is_compacting) THIS->FlushNumberStringCache(); | 698 if (is_compacting) THIS->FlushNumberStringCache(); |
| 699 } | 699 } |
| 700 | 700 |
| 701 | 701 |
| 702 void Heap::MarkCompactEpilogue(bool is_compacting) { | 702 void Heap::MarkCompactEpilogue(bool is_compacting) { |
| 703 Top::MarkCompactEpilogue(is_compacting); | 703 Isolate::Current()->MarkCompactEpilogue(is_compacting); |
| 704 ThreadManager::MarkCompactEpilogue(is_compacting); | 704 ThreadManager::MarkCompactEpilogue(is_compacting); |
| 705 } | 705 } |
| 706 | 706 |
| 707 | 707 |
| 708 Object* Heap::FindCodeObject(Address a) { | 708 Object* Heap::FindCodeObject(Address a) { |
| 709 Object* obj = code_space_->FindObject(a); | 709 Object* obj = code_space_->FindObject(a); |
| 710 if (obj->IsFailure()) { | 710 if (obj->IsFailure()) { |
| 711 obj = lo_space_->FindObject(a); | 711 obj = lo_space_->FindObject(a); |
| 712 } | 712 } |
| 713 ASSERT(!obj->IsFailure()); | 713 ASSERT(!obj->IsFailure()); |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1909 return MakeOrFindTwoCharacterString(this, c1, c2); | 1909 return MakeOrFindTwoCharacterString(this, c1, c2); |
| 1910 } | 1910 } |
| 1911 | 1911 |
| 1912 bool first_is_ascii = first->IsAsciiRepresentation(); | 1912 bool first_is_ascii = first->IsAsciiRepresentation(); |
| 1913 bool second_is_ascii = second->IsAsciiRepresentation(); | 1913 bool second_is_ascii = second->IsAsciiRepresentation(); |
| 1914 bool is_ascii = first_is_ascii && second_is_ascii; | 1914 bool is_ascii = first_is_ascii && second_is_ascii; |
| 1915 | 1915 |
| 1916 // Make sure that an out of memory exception is thrown if the length | 1916 // Make sure that an out of memory exception is thrown if the length |
| 1917 // of the new cons string is too large. | 1917 // of the new cons string is too large. |
| 1918 if (length > String::kMaxLength || length < 0) { | 1918 if (length > String::kMaxLength || length < 0) { |
| 1919 Top::context()->mark_out_of_memory(); | 1919 Isolate::Current()->context()->mark_out_of_memory(); |
| 1920 return Failure::OutOfMemoryException(); | 1920 return Failure::OutOfMemoryException(); |
| 1921 } | 1921 } |
| 1922 | 1922 |
| 1923 // If the resulting string is small make a flat string. | 1923 // If the resulting string is small make a flat string. |
| 1924 if (length < String::kMinNonFlatLength) { | 1924 if (length < String::kMinNonFlatLength) { |
| 1925 ASSERT(first->IsFlat()); | 1925 ASSERT(first->IsFlat()); |
| 1926 ASSERT(second->IsFlat()); | 1926 ASSERT(second->IsFlat()); |
| 1927 if (is_ascii) { | 1927 if (is_ascii) { |
| 1928 Object* result = AllocateRawAsciiString(length); | 1928 Object* result = AllocateRawAsciiString(length); |
| 1929 if (result->IsFailure()) return result; | 1929 if (result->IsFailure()) return result; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 return result; | 2030 return result; |
| 2031 } | 2031 } |
| 2032 | 2032 |
| 2033 | 2033 |
| 2034 Object* Heap::AllocateExternalStringFromAscii( | 2034 Object* Heap::AllocateExternalStringFromAscii( |
| 2035 ExternalAsciiString::Resource* resource) { | 2035 ExternalAsciiString::Resource* resource) { |
| 2036 size_t length = resource->length(); | 2036 size_t length = resource->length(); |
| 2037 if (length > static_cast<size_t>(String::kMaxLength)) { | 2037 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2038 Top::context()->mark_out_of_memory(); | 2038 Isolate::Current()->context()->mark_out_of_memory(); |
| 2039 return Failure::OutOfMemoryException(); | 2039 return Failure::OutOfMemoryException(); |
| 2040 } | 2040 } |
| 2041 | 2041 |
| 2042 Map* map = THIS->external_ascii_string_map(); | 2042 Map* map = THIS->external_ascii_string_map(); |
| 2043 Object* result = Allocate(map, NEW_SPACE); | 2043 Object* result = Allocate(map, NEW_SPACE); |
| 2044 if (result->IsFailure()) return result; | 2044 if (result->IsFailure()) return result; |
| 2045 | 2045 |
| 2046 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); | 2046 ExternalAsciiString* external_string = ExternalAsciiString::cast(result); |
| 2047 external_string->set_length(static_cast<int>(length)); | 2047 external_string->set_length(static_cast<int>(length)); |
| 2048 external_string->set_hash_field(String::kEmptyHashField); | 2048 external_string->set_hash_field(String::kEmptyHashField); |
| 2049 external_string->set_resource(resource); | 2049 external_string->set_resource(resource); |
| 2050 | 2050 |
| 2051 return result; | 2051 return result; |
| 2052 } | 2052 } |
| 2053 | 2053 |
| 2054 | 2054 |
| 2055 Object* Heap::AllocateExternalStringFromTwoByte( | 2055 Object* Heap::AllocateExternalStringFromTwoByte( |
| 2056 ExternalTwoByteString::Resource* resource) { | 2056 ExternalTwoByteString::Resource* resource) { |
| 2057 size_t length = resource->length(); | 2057 size_t length = resource->length(); |
| 2058 if (length > static_cast<size_t>(String::kMaxLength)) { | 2058 if (length > static_cast<size_t>(String::kMaxLength)) { |
| 2059 Top::context()->mark_out_of_memory(); | 2059 Isolate::Current()->context()->mark_out_of_memory(); |
| 2060 return Failure::OutOfMemoryException(); | 2060 return Failure::OutOfMemoryException(); |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 Map* map = HEAP->external_string_map(); | 2063 Map* map = HEAP->external_string_map(); |
| 2064 Object* result = Allocate(map, NEW_SPACE); | 2064 Object* result = Allocate(map, NEW_SPACE); |
| 2065 if (result->IsFailure()) return result; | 2065 if (result->IsFailure()) return result; |
| 2066 | 2066 |
| 2067 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); | 2067 ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); |
| 2068 external_string->set_length(static_cast<int>(length)); | 2068 external_string->set_length(static_cast<int>(length)); |
| 2069 external_string->set_hash_field(String::kEmptyHashField); | 2069 external_string->set_hash_field(String::kEmptyHashField); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2447 | 2447 |
| 2448 Object* Heap::AllocateArgumentsObject(Object* callee, int length) { | 2448 Object* Heap::AllocateArgumentsObject(Object* callee, int length) { |
| 2449 // To get fast allocation and map sharing for arguments objects we | 2449 // To get fast allocation and map sharing for arguments objects we |
| 2450 // allocate them based on an arguments boilerplate. | 2450 // allocate them based on an arguments boilerplate. |
| 2451 | 2451 |
| 2452 // This calls Copy directly rather than using Heap::AllocateRaw so we | 2452 // This calls Copy directly rather than using Heap::AllocateRaw so we |
| 2453 // duplicate the check here. | 2453 // duplicate the check here. |
| 2454 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); | 2454 ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); |
| 2455 | 2455 |
| 2456 JSObject* boilerplate = | 2456 JSObject* boilerplate = |
| 2457 Top::context()->global_context()->arguments_boilerplate(); | 2457 Isolate::Current()->context()->global_context()->arguments_boilerplate(); |
| 2458 | 2458 |
| 2459 // Check that the size of the boilerplate matches our | 2459 // Check that the size of the boilerplate matches our |
| 2460 // expectations. The ArgumentsAccessStub::GenerateNewObject relies | 2460 // expectations. The ArgumentsAccessStub::GenerateNewObject relies |
| 2461 // on the size being a known constant. | 2461 // on the size being a known constant. |
| 2462 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); | 2462 ASSERT(kArgumentsObjectSize == boilerplate->map()->instance_size()); |
| 2463 | 2463 |
| 2464 // Do the allocation. | 2464 // Do the allocation. |
| 2465 Object* result = | 2465 Object* result = |
| 2466 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); | 2466 AllocateRaw(kArgumentsObjectSize, NEW_SPACE, OLD_POINTER_SPACE); |
| 2467 if (result->IsFailure()) return result; | 2467 if (result->IsFailure()) return result; |
| (...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3261 ASSERT(contexts_disposed_ == 0); | 3261 ASSERT(contexts_disposed_ == 0); |
| 3262 if (uncommit) UncommitFromSpace(); | 3262 if (uncommit) UncommitFromSpace(); |
| 3263 return finished; | 3263 return finished; |
| 3264 } | 3264 } |
| 3265 | 3265 |
| 3266 | 3266 |
| 3267 #ifdef DEBUG | 3267 #ifdef DEBUG |
| 3268 | 3268 |
| 3269 void Heap::Print() { | 3269 void Heap::Print() { |
| 3270 if (!HasBeenSetup()) return; | 3270 if (!HasBeenSetup()) return; |
| 3271 Top::PrintStack(); | 3271 Isolate::Current()->PrintStack(); |
| 3272 AllSpaces spaces; | 3272 AllSpaces spaces; |
| 3273 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) | 3273 for (Space* space = spaces.next(); space != NULL; space = spaces.next()) |
| 3274 space->Print(); | 3274 space->Print(); |
| 3275 } | 3275 } |
| 3276 | 3276 |
| 3277 | 3277 |
| 3278 void Heap::ReportCodeStatistics(const char* title) { | 3278 void Heap::ReportCodeStatistics(const char* title) { |
| 3279 PrintF(">>>>>> Code Stats (%s) >>>>>>\n", title); | 3279 PrintF(">>>>>> Code Stats (%s) >>>>>>\n", title); |
| 3280 PagedSpace::ResetCodeStatistics(); | 3280 PagedSpace::ResetCodeStatistics(); |
| 3281 // We do not look for code in new space, map space, or old space. If code | 3281 // We do not look for code in new space, map space, or old space. If code |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3762 | 3762 |
| 3763 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { | 3763 void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { |
| 3764 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); | 3764 v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); |
| 3765 v->Synchronize("strong_root_list"); | 3765 v->Synchronize("strong_root_list"); |
| 3766 | 3766 |
| 3767 v->VisitPointer(BitCast<Object**, String**>(&hidden_symbol_)); | 3767 v->VisitPointer(BitCast<Object**, String**>(&hidden_symbol_)); |
| 3768 v->Synchronize("symbol"); | 3768 v->Synchronize("symbol"); |
| 3769 | 3769 |
| 3770 isolate_->bootstrapper()->Iterate(v); | 3770 isolate_->bootstrapper()->Iterate(v); |
| 3771 v->Synchronize("bootstrapper"); | 3771 v->Synchronize("bootstrapper"); |
| 3772 Top::Iterate(v); | 3772 isolate_->Iterate(v); |
| 3773 v->Synchronize("top"); | 3773 v->Synchronize("top"); |
| 3774 Relocatable::Iterate(v); | 3774 Relocatable::Iterate(v); |
| 3775 v->Synchronize("relocatable"); | 3775 v->Synchronize("relocatable"); |
| 3776 | 3776 |
| 3777 #ifdef ENABLE_DEBUGGER_SUPPORT | 3777 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 3778 Debug::Iterate(v); | 3778 Debug::Iterate(v); |
| 3779 #endif | 3779 #endif |
| 3780 v->Synchronize("debug"); | 3780 v->Synchronize("debug"); |
| 3781 isolate_->compilation_cache()->Iterate(v); | 3781 isolate_->compilation_cache()->Iterate(v); |
| 3782 v->Synchronize("compilationcache"); | 3782 v->Synchronize("compilationcache"); |
| (...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4736 void ExternalStringTable::TearDown() { | 4736 void ExternalStringTable::TearDown() { |
| 4737 new_space_strings_.Free(); | 4737 new_space_strings_.Free(); |
| 4738 old_space_strings_.Free(); | 4738 old_space_strings_.Free(); |
| 4739 } | 4739 } |
| 4740 | 4740 |
| 4741 | 4741 |
| 4742 List<Object*> ExternalStringTable::new_space_strings_; | 4742 List<Object*> ExternalStringTable::new_space_strings_; |
| 4743 List<Object*> ExternalStringTable::old_space_strings_; | 4743 List<Object*> ExternalStringTable::old_space_strings_; |
| 4744 | 4744 |
| 4745 } } // namespace v8::internal | 4745 } } // namespace v8::internal |
| OLD | NEW |