OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <iomanip> | 5 #include <iomanip> |
6 #include <sstream> | 6 #include <sstream> |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/accessors.h" | 10 #include "src/accessors.h" |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1006 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1007 | 1007 |
1008 // We are storing the new map using release store after creating a filler for | 1008 // We are storing the new map using release store after creating a filler for |
1009 // the left-over space to avoid races with the sweeper thread. | 1009 // the left-over space to avoid races with the sweeper thread. |
1010 this->synchronized_set_map(new_map); | 1010 this->synchronized_set_map(new_map); |
1011 | 1011 |
1012 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); | 1012 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); |
1013 self->set_resource(resource); | 1013 self->set_resource(resource); |
1014 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1014 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1015 | 1015 |
1016 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); | 1016 heap->AdjustLiveBytes(this->address(), new_size - size, |
| 1017 Heap::SWEEPING_STARTED); |
1017 return true; | 1018 return true; |
1018 } | 1019 } |
1019 | 1020 |
1020 | 1021 |
1021 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { | 1022 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { |
1022 // Externalizing twice leaks the external resource, so it's | 1023 // Externalizing twice leaks the external resource, so it's |
1023 // prohibited by the API. | 1024 // prohibited by the API. |
1024 DCHECK(!this->IsExternalString()); | 1025 DCHECK(!this->IsExternalString()); |
1025 #ifdef ENABLE_SLOW_DCHECKS | 1026 #ifdef ENABLE_SLOW_DCHECKS |
1026 if (FLAG_enable_slow_asserts) { | 1027 if (FLAG_enable_slow_asserts) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1067 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1067 | 1068 |
1068 // We are storing the new map using release store after creating a filler for | 1069 // We are storing the new map using release store after creating a filler for |
1069 // the left-over space to avoid races with the sweeper thread. | 1070 // the left-over space to avoid races with the sweeper thread. |
1070 this->synchronized_set_map(new_map); | 1071 this->synchronized_set_map(new_map); |
1071 | 1072 |
1072 ExternalOneByteString* self = ExternalOneByteString::cast(this); | 1073 ExternalOneByteString* self = ExternalOneByteString::cast(this); |
1073 self->set_resource(resource); | 1074 self->set_resource(resource); |
1074 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1075 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1075 | 1076 |
1076 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); | 1077 heap->AdjustLiveBytes(this->address(), new_size - size, |
| 1078 Heap::SWEEPING_STARTED); |
1077 return true; | 1079 return true; |
1078 } | 1080 } |
1079 | 1081 |
1080 | 1082 |
1081 void String::StringShortPrint(StringStream* accumulator) { | 1083 void String::StringShortPrint(StringStream* accumulator) { |
1082 int len = length(); | 1084 int len = length(); |
1083 if (len > kMaxShortPrintLength) { | 1085 if (len > kMaxShortPrintLength) { |
1084 accumulator->Add("<Very long string[%u]>", len); | 1086 accumulator->Add("<Very long string[%u]>", len); |
1085 return; | 1087 return; |
1086 } | 1088 } |
(...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2084 } else { | 2086 } else { |
2085 object->RawFastPropertyAtPut(index, value); | 2087 object->RawFastPropertyAtPut(index, value); |
2086 } | 2088 } |
2087 } | 2089 } |
2088 | 2090 |
2089 Heap* heap = isolate->heap(); | 2091 Heap* heap = isolate->heap(); |
2090 | 2092 |
2091 // If there are properties in the new backing store, trim it to the correct | 2093 // If there are properties in the new backing store, trim it to the correct |
2092 // size and install the backing store into the object. | 2094 // size and install the backing store into the object. |
2093 if (external > 0) { | 2095 if (external > 0) { |
2094 heap->RightTrimFixedArray<Heap::FROM_MUTATOR>(*array, inobject); | 2096 heap->RightTrimFixedArray<Heap::SWEEPING_STARTED>(*array, inobject); |
2095 object->set_properties(*array); | 2097 object->set_properties(*array); |
2096 } | 2098 } |
2097 | 2099 |
2098 // Create filler object past the new instance size. | 2100 // Create filler object past the new instance size. |
2099 int new_instance_size = new_map->instance_size(); | 2101 int new_instance_size = new_map->instance_size(); |
2100 int instance_size_delta = old_map->instance_size() - new_instance_size; | 2102 int instance_size_delta = old_map->instance_size() - new_instance_size; |
2101 DCHECK(instance_size_delta >= 0); | 2103 DCHECK(instance_size_delta >= 0); |
2102 | 2104 |
2103 if (instance_size_delta > 0) { | 2105 if (instance_size_delta > 0) { |
2104 Address address = object->address(); | 2106 Address address = object->address(); |
2105 heap->CreateFillerObjectAt( | 2107 heap->CreateFillerObjectAt( |
2106 address + new_instance_size, instance_size_delta); | 2108 address + new_instance_size, instance_size_delta); |
2107 heap->AdjustLiveBytes(address, -instance_size_delta, Heap::FROM_MUTATOR); | 2109 heap->AdjustLiveBytes(address, -instance_size_delta, |
| 2110 Heap::SWEEPING_STARTED); |
2108 } | 2111 } |
2109 | 2112 |
2110 // We are storing the new map using release store after creating a filler for | 2113 // We are storing the new map using release store after creating a filler for |
2111 // the left-over space to avoid races with the sweeper thread. | 2114 // the left-over space to avoid races with the sweeper thread. |
2112 object->synchronized_set_map(*new_map); | 2115 object->synchronized_set_map(*new_map); |
2113 } | 2116 } |
2114 | 2117 |
2115 | 2118 |
2116 int Map::NumberOfFields() { | 2119 int Map::NumberOfFields() { |
2117 DescriptorArray* descriptors = instance_descriptors(); | 2120 DescriptorArray* descriptors = instance_descriptors(); |
(...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4600 // Resize the object in the heap if necessary. | 4603 // Resize the object in the heap if necessary. |
4601 int new_instance_size = new_map->instance_size(); | 4604 int new_instance_size = new_map->instance_size(); |
4602 int instance_size_delta = map->instance_size() - new_instance_size; | 4605 int instance_size_delta = map->instance_size() - new_instance_size; |
4603 DCHECK(instance_size_delta >= 0); | 4606 DCHECK(instance_size_delta >= 0); |
4604 | 4607 |
4605 if (instance_size_delta > 0) { | 4608 if (instance_size_delta > 0) { |
4606 Heap* heap = isolate->heap(); | 4609 Heap* heap = isolate->heap(); |
4607 heap->CreateFillerObjectAt(object->address() + new_instance_size, | 4610 heap->CreateFillerObjectAt(object->address() + new_instance_size, |
4608 instance_size_delta); | 4611 instance_size_delta); |
4609 heap->AdjustLiveBytes(object->address(), -instance_size_delta, | 4612 heap->AdjustLiveBytes(object->address(), -instance_size_delta, |
4610 Heap::FROM_MUTATOR); | 4613 Heap::SWEEPING_STARTED); |
4611 } | 4614 } |
4612 | 4615 |
4613 // We are storing the new map using release store after creating a filler for | 4616 // We are storing the new map using release store after creating a filler for |
4614 // the left-over space to avoid races with the sweeper thread. | 4617 // the left-over space to avoid races with the sweeper thread. |
4615 object->synchronized_set_map(*new_map); | 4618 object->synchronized_set_map(*new_map); |
4616 | 4619 |
4617 object->set_properties(*dictionary); | 4620 object->set_properties(*dictionary); |
4618 | 4621 |
4619 // Ensure that in-object space of slow-mode object does not contain random | 4622 // Ensure that in-object space of slow-mode object does not contain random |
4620 // garbage. | 4623 // garbage. |
(...skipping 3444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8065 cache->set(EntryToIndex(entry), *obj); | 8068 cache->set(EntryToIndex(entry), *obj); |
8066 cache->set(EntryToIndex(entry) + 1, *code); | 8069 cache->set(EntryToIndex(entry) + 1, *code); |
8067 cache->ElementAdded(); | 8070 cache->ElementAdded(); |
8068 return cache; | 8071 return cache; |
8069 } | 8072 } |
8070 | 8073 |
8071 | 8074 |
8072 void FixedArray::Shrink(int new_length) { | 8075 void FixedArray::Shrink(int new_length) { |
8073 DCHECK(0 <= new_length && new_length <= length()); | 8076 DCHECK(0 <= new_length && new_length <= length()); |
8074 if (new_length < length()) { | 8077 if (new_length < length()) { |
8075 GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>( | 8078 GetHeap()->RightTrimFixedArray<Heap::SWEEPING_STARTED>( |
8076 this, length() - new_length); | 8079 this, length() - new_length); |
8077 } | 8080 } |
8078 } | 8081 } |
8079 | 8082 |
8080 | 8083 |
8081 MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike( | 8084 MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike( |
8082 Handle<FixedArray> content, Handle<JSObject> array, KeyFilter filter) { | 8085 Handle<FixedArray> content, Handle<JSObject> array, KeyFilter filter) { |
8083 DCHECK(array->IsJSArray() || array->HasSloppyArgumentsElements()); | 8086 DCHECK(array->IsJSArray() || array->HasSloppyArgumentsElements()); |
8084 ElementsAccessor* accessor = array->GetElementsAccessor(); | 8087 ElementsAccessor* accessor = array->GetElementsAccessor(); |
8085 Handle<FixedArray> result; | 8088 Handle<FixedArray> result; |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9428 NewSpace* newspace = heap->new_space(); | 9431 NewSpace* newspace = heap->new_space(); |
9429 if (newspace->Contains(start_of_string) && | 9432 if (newspace->Contains(start_of_string) && |
9430 newspace->top() == start_of_string + old_size) { | 9433 newspace->top() == start_of_string + old_size) { |
9431 // Last allocated object in new space. Simply lower allocation top. | 9434 // Last allocated object in new space. Simply lower allocation top. |
9432 newspace->set_top(start_of_string + new_size); | 9435 newspace->set_top(start_of_string + new_size); |
9433 } else { | 9436 } else { |
9434 // Sizes are pointer size aligned, so that we can use filler objects | 9437 // Sizes are pointer size aligned, so that we can use filler objects |
9435 // that are a multiple of pointer size. | 9438 // that are a multiple of pointer size. |
9436 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | 9439 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
9437 } | 9440 } |
9438 heap->AdjustLiveBytes(start_of_string, -delta, Heap::FROM_MUTATOR); | 9441 heap->AdjustLiveBytes(start_of_string, -delta, Heap::SWEEPING_STARTED); |
9439 | 9442 |
9440 // We are storing the new length using release store after creating a filler | 9443 // We are storing the new length using release store after creating a filler |
9441 // for the left-over space to avoid races with the sweeper thread. | 9444 // for the left-over space to avoid races with the sweeper thread. |
9442 string->synchronized_set_length(new_length); | 9445 string->synchronized_set_length(new_length); |
9443 | 9446 |
9444 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9447 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9445 return string; | 9448 return string; |
9446 } | 9449 } |
9447 | 9450 |
9448 | 9451 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9849 code_map->set(dst + kLiteralsOffset, | 9852 code_map->set(dst + kLiteralsOffset, |
9850 code_map->get(src + kLiteralsOffset)); | 9853 code_map->get(src + kLiteralsOffset)); |
9851 code_map->set(dst + kOsrAstIdOffset, | 9854 code_map->set(dst + kOsrAstIdOffset, |
9852 code_map->get(src + kOsrAstIdOffset)); | 9855 code_map->get(src + kOsrAstIdOffset)); |
9853 } | 9856 } |
9854 dst += kEntryLength; | 9857 dst += kEntryLength; |
9855 } | 9858 } |
9856 } | 9859 } |
9857 if (dst != length) { | 9860 if (dst != length) { |
9858 // Always trim even when array is cleared because of heap verifier. | 9861 // Always trim even when array is cleared because of heap verifier. |
9859 GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(code_map, length - dst); | 9862 GetHeap()->RightTrimFixedArray<Heap::SWEEPING_STARTED>(code_map, |
| 9863 length - dst); |
9860 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); | 9864 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); |
9861 } | 9865 } |
9862 } | 9866 } |
9863 | 9867 |
9864 | 9868 |
9865 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 9869 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
9866 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9870 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
9867 DCHECK(shrink_by % kEntryLength == 0); | 9871 DCHECK(shrink_by % kEntryLength == 0); |
9868 DCHECK(shrink_by <= code_map->length() - kEntriesStart); | 9872 DCHECK(shrink_by <= code_map->length() - kEntriesStart); |
9869 // Always trim even when array is cleared because of heap verifier. | 9873 // Always trim even when array is cleared because of heap verifier. |
9870 GetHeap()->RightTrimFixedArray<Heap::FROM_GC>(code_map, shrink_by); | 9874 GetHeap()->RightTrimFixedArray<Heap::SWEEPING_IS_OFF>(code_map, shrink_by); |
9871 if (code_map->length() == kEntriesStart) { | 9875 if (code_map->length() == kEntriesStart) { |
9872 ClearOptimizedCodeMap(); | 9876 ClearOptimizedCodeMap(); |
9873 } | 9877 } |
9874 } | 9878 } |
9875 | 9879 |
9876 | 9880 |
9877 static void GetMinInobjectSlack(Map* map, void* data) { | 9881 static void GetMinInobjectSlack(Map* map, void* data) { |
9878 int slack = map->unused_property_fields(); | 9882 int slack = map->unused_property_fields(); |
9879 if (*reinterpret_cast<int*>(data) > slack) { | 9883 if (*reinterpret_cast<int*>(data) > slack) { |
9880 *reinterpret_cast<int*>(data) = slack; | 9884 *reinterpret_cast<int*>(data) = slack; |
(...skipping 7288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17169 CompilationInfo* info) { | 17173 CompilationInfo* info) { |
17170 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17174 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17171 handle(cell->dependent_code(), info->isolate()), | 17175 handle(cell->dependent_code(), info->isolate()), |
17172 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17176 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17173 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17177 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17174 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17178 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17175 cell, info->zone()); | 17179 cell, info->zone()); |
17176 } | 17180 } |
17177 | 17181 |
17178 } } // namespace v8::internal | 17182 } } // namespace v8::internal |
OLD | NEW |