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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1023 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1024 | 1024 |
1025 // We are storing the new map using release store after creating a filler for | 1025 // We are storing the new map using release store after creating a filler for |
1026 // the left-over space to avoid races with the sweeper thread. | 1026 // the left-over space to avoid races with the sweeper thread. |
1027 this->synchronized_set_map(new_map); | 1027 this->synchronized_set_map(new_map); |
1028 | 1028 |
1029 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); | 1029 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); |
1030 self->set_resource(resource); | 1030 self->set_resource(resource); |
1031 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1031 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1032 | 1032 |
1033 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); | 1033 heap->AdjustLiveBytes(this->address(), new_size - size, |
| 1034 Heap::CONCURRENT_TO_SWEEPER); |
1034 return true; | 1035 return true; |
1035 } | 1036 } |
1036 | 1037 |
1037 | 1038 |
1038 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { | 1039 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { |
1039 // Externalizing twice leaks the external resource, so it's | 1040 // Externalizing twice leaks the external resource, so it's |
1040 // prohibited by the API. | 1041 // prohibited by the API. |
1041 DCHECK(!this->IsExternalString()); | 1042 DCHECK(!this->IsExternalString()); |
1042 #ifdef ENABLE_SLOW_DCHECKS | 1043 #ifdef ENABLE_SLOW_DCHECKS |
1043 if (FLAG_enable_slow_asserts) { | 1044 if (FLAG_enable_slow_asserts) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 1084 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
1084 | 1085 |
1085 // We are storing the new map using release store after creating a filler for | 1086 // We are storing the new map using release store after creating a filler for |
1086 // the left-over space to avoid races with the sweeper thread. | 1087 // the left-over space to avoid races with the sweeper thread. |
1087 this->synchronized_set_map(new_map); | 1088 this->synchronized_set_map(new_map); |
1088 | 1089 |
1089 ExternalOneByteString* self = ExternalOneByteString::cast(this); | 1090 ExternalOneByteString* self = ExternalOneByteString::cast(this); |
1090 self->set_resource(resource); | 1091 self->set_resource(resource); |
1091 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 1092 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
1092 | 1093 |
1093 heap->AdjustLiveBytes(this->address(), new_size - size, Heap::FROM_MUTATOR); | 1094 heap->AdjustLiveBytes(this->address(), new_size - size, |
| 1095 Heap::CONCURRENT_TO_SWEEPER); |
1094 return true; | 1096 return true; |
1095 } | 1097 } |
1096 | 1098 |
1097 | 1099 |
1098 void String::StringShortPrint(StringStream* accumulator) { | 1100 void String::StringShortPrint(StringStream* accumulator) { |
1099 int len = length(); | 1101 int len = length(); |
1100 if (len > kMaxShortPrintLength) { | 1102 if (len > kMaxShortPrintLength) { |
1101 accumulator->Add("<Very long string[%u]>", len); | 1103 accumulator->Add("<Very long string[%u]>", len); |
1102 return; | 1104 return; |
1103 } | 1105 } |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2106 } else { | 2108 } else { |
2107 object->RawFastPropertyAtPut(index, value); | 2109 object->RawFastPropertyAtPut(index, value); |
2108 } | 2110 } |
2109 } | 2111 } |
2110 | 2112 |
2111 Heap* heap = isolate->heap(); | 2113 Heap* heap = isolate->heap(); |
2112 | 2114 |
2113 // If there are properties in the new backing store, trim it to the correct | 2115 // If there are properties in the new backing store, trim it to the correct |
2114 // size and install the backing store into the object. | 2116 // size and install the backing store into the object. |
2115 if (external > 0) { | 2117 if (external > 0) { |
2116 heap->RightTrimFixedArray<Heap::FROM_MUTATOR>(*array, inobject); | 2118 heap->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(*array, inobject); |
2117 object->set_properties(*array); | 2119 object->set_properties(*array); |
2118 } | 2120 } |
2119 | 2121 |
2120 // Create filler object past the new instance size. | 2122 // Create filler object past the new instance size. |
2121 int new_instance_size = new_map->instance_size(); | 2123 int new_instance_size = new_map->instance_size(); |
2122 int instance_size_delta = old_map->instance_size() - new_instance_size; | 2124 int instance_size_delta = old_map->instance_size() - new_instance_size; |
2123 DCHECK(instance_size_delta >= 0); | 2125 DCHECK(instance_size_delta >= 0); |
2124 | 2126 |
2125 if (instance_size_delta > 0) { | 2127 if (instance_size_delta > 0) { |
2126 Address address = object->address(); | 2128 Address address = object->address(); |
2127 heap->CreateFillerObjectAt( | 2129 heap->CreateFillerObjectAt( |
2128 address + new_instance_size, instance_size_delta); | 2130 address + new_instance_size, instance_size_delta); |
2129 heap->AdjustLiveBytes(address, -instance_size_delta, Heap::FROM_MUTATOR); | 2131 heap->AdjustLiveBytes(address, -instance_size_delta, |
| 2132 Heap::CONCURRENT_TO_SWEEPER); |
2130 } | 2133 } |
2131 | 2134 |
2132 // We are storing the new map using release store after creating a filler for | 2135 // We are storing the new map using release store after creating a filler for |
2133 // the left-over space to avoid races with the sweeper thread. | 2136 // the left-over space to avoid races with the sweeper thread. |
2134 object->synchronized_set_map(*new_map); | 2137 object->synchronized_set_map(*new_map); |
2135 } | 2138 } |
2136 | 2139 |
2137 | 2140 |
2138 int Map::NumberOfFields() { | 2141 int Map::NumberOfFields() { |
2139 DescriptorArray* descriptors = instance_descriptors(); | 2142 DescriptorArray* descriptors = instance_descriptors(); |
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4631 // Resize the object in the heap if necessary. | 4634 // Resize the object in the heap if necessary. |
4632 int new_instance_size = new_map->instance_size(); | 4635 int new_instance_size = new_map->instance_size(); |
4633 int instance_size_delta = map->instance_size() - new_instance_size; | 4636 int instance_size_delta = map->instance_size() - new_instance_size; |
4634 DCHECK(instance_size_delta >= 0); | 4637 DCHECK(instance_size_delta >= 0); |
4635 | 4638 |
4636 if (instance_size_delta > 0) { | 4639 if (instance_size_delta > 0) { |
4637 Heap* heap = isolate->heap(); | 4640 Heap* heap = isolate->heap(); |
4638 heap->CreateFillerObjectAt(object->address() + new_instance_size, | 4641 heap->CreateFillerObjectAt(object->address() + new_instance_size, |
4639 instance_size_delta); | 4642 instance_size_delta); |
4640 heap->AdjustLiveBytes(object->address(), -instance_size_delta, | 4643 heap->AdjustLiveBytes(object->address(), -instance_size_delta, |
4641 Heap::FROM_MUTATOR); | 4644 Heap::CONCURRENT_TO_SWEEPER); |
4642 } | 4645 } |
4643 | 4646 |
4644 // We are storing the new map using release store after creating a filler for | 4647 // We are storing the new map using release store after creating a filler for |
4645 // the left-over space to avoid races with the sweeper thread. | 4648 // the left-over space to avoid races with the sweeper thread. |
4646 object->synchronized_set_map(*new_map); | 4649 object->synchronized_set_map(*new_map); |
4647 | 4650 |
4648 object->set_properties(*dictionary); | 4651 object->set_properties(*dictionary); |
4649 | 4652 |
4650 // Ensure that in-object space of slow-mode object does not contain random | 4653 // Ensure that in-object space of slow-mode object does not contain random |
4651 // garbage. | 4654 // garbage. |
(...skipping 3446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8098 cache->set(EntryToIndex(entry), *obj); | 8101 cache->set(EntryToIndex(entry), *obj); |
8099 cache->set(EntryToIndex(entry) + 1, *code); | 8102 cache->set(EntryToIndex(entry) + 1, *code); |
8100 cache->ElementAdded(); | 8103 cache->ElementAdded(); |
8101 return cache; | 8104 return cache; |
8102 } | 8105 } |
8103 | 8106 |
8104 | 8107 |
8105 void FixedArray::Shrink(int new_length) { | 8108 void FixedArray::Shrink(int new_length) { |
8106 DCHECK(0 <= new_length && new_length <= length()); | 8109 DCHECK(0 <= new_length && new_length <= length()); |
8107 if (new_length < length()) { | 8110 if (new_length < length()) { |
8108 GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>( | 8111 GetHeap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( |
8109 this, length() - new_length); | 8112 this, length() - new_length); |
8110 } | 8113 } |
8111 } | 8114 } |
8112 | 8115 |
8113 | 8116 |
8114 MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike( | 8117 MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike( |
8115 Handle<FixedArray> content, Handle<JSObject> array, KeyFilter filter) { | 8118 Handle<FixedArray> content, Handle<JSObject> array, KeyFilter filter) { |
8116 DCHECK(array->IsJSArray() || array->HasSloppyArgumentsElements()); | 8119 DCHECK(array->IsJSArray() || array->HasSloppyArgumentsElements()); |
8117 ElementsAccessor* accessor = array->GetElementsAccessor(); | 8120 ElementsAccessor* accessor = array->GetElementsAccessor(); |
8118 Handle<FixedArray> result; | 8121 Handle<FixedArray> result; |
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9461 NewSpace* newspace = heap->new_space(); | 9464 NewSpace* newspace = heap->new_space(); |
9462 if (newspace->Contains(start_of_string) && | 9465 if (newspace->Contains(start_of_string) && |
9463 newspace->top() == start_of_string + old_size) { | 9466 newspace->top() == start_of_string + old_size) { |
9464 // Last allocated object in new space. Simply lower allocation top. | 9467 // Last allocated object in new space. Simply lower allocation top. |
9465 newspace->set_top(start_of_string + new_size); | 9468 newspace->set_top(start_of_string + new_size); |
9466 } else { | 9469 } else { |
9467 // Sizes are pointer size aligned, so that we can use filler objects | 9470 // Sizes are pointer size aligned, so that we can use filler objects |
9468 // that are a multiple of pointer size. | 9471 // that are a multiple of pointer size. |
9469 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | 9472 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
9470 } | 9473 } |
9471 heap->AdjustLiveBytes(start_of_string, -delta, Heap::FROM_MUTATOR); | 9474 heap->AdjustLiveBytes(start_of_string, -delta, Heap::CONCURRENT_TO_SWEEPER); |
9472 | 9475 |
9473 // We are storing the new length using release store after creating a filler | 9476 // We are storing the new length using release store after creating a filler |
9474 // for the left-over space to avoid races with the sweeper thread. | 9477 // for the left-over space to avoid races with the sweeper thread. |
9475 string->synchronized_set_length(new_length); | 9478 string->synchronized_set_length(new_length); |
9476 | 9479 |
9477 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9480 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9478 return string; | 9481 return string; |
9479 } | 9482 } |
9480 | 9483 |
9481 | 9484 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9881 code_map->set(dst + kLiteralsOffset, | 9884 code_map->set(dst + kLiteralsOffset, |
9882 code_map->get(src + kLiteralsOffset)); | 9885 code_map->get(src + kLiteralsOffset)); |
9883 code_map->set(dst + kOsrAstIdOffset, | 9886 code_map->set(dst + kOsrAstIdOffset, |
9884 code_map->get(src + kOsrAstIdOffset)); | 9887 code_map->get(src + kOsrAstIdOffset)); |
9885 } | 9888 } |
9886 dst += kEntryLength; | 9889 dst += kEntryLength; |
9887 } | 9890 } |
9888 } | 9891 } |
9889 if (dst != length) { | 9892 if (dst != length) { |
9890 // Always trim even when array is cleared because of heap verifier. | 9893 // Always trim even when array is cleared because of heap verifier. |
9891 GetHeap()->RightTrimFixedArray<Heap::FROM_MUTATOR>(code_map, length - dst); | 9894 GetHeap()->RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>(code_map, |
| 9895 length - dst); |
9892 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); | 9896 if (code_map->length() == kEntriesStart) ClearOptimizedCodeMap(); |
9893 } | 9897 } |
9894 } | 9898 } |
9895 | 9899 |
9896 | 9900 |
9897 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { | 9901 void SharedFunctionInfo::TrimOptimizedCodeMap(int shrink_by) { |
9898 FixedArray* code_map = FixedArray::cast(optimized_code_map()); | 9902 FixedArray* code_map = FixedArray::cast(optimized_code_map()); |
9899 DCHECK(shrink_by % kEntryLength == 0); | 9903 DCHECK(shrink_by % kEntryLength == 0); |
9900 DCHECK(shrink_by <= code_map->length() - kEntriesStart); | 9904 DCHECK(shrink_by <= code_map->length() - kEntriesStart); |
9901 // Always trim even when array is cleared because of heap verifier. | 9905 // Always trim even when array is cleared because of heap verifier. |
9902 GetHeap()->RightTrimFixedArray<Heap::FROM_GC>(code_map, shrink_by); | 9906 GetHeap()->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(code_map, |
| 9907 shrink_by); |
9903 if (code_map->length() == kEntriesStart) { | 9908 if (code_map->length() == kEntriesStart) { |
9904 ClearOptimizedCodeMap(); | 9909 ClearOptimizedCodeMap(); |
9905 } | 9910 } |
9906 } | 9911 } |
9907 | 9912 |
9908 | 9913 |
9909 static void GetMinInobjectSlack(Map* map, void* data) { | 9914 static void GetMinInobjectSlack(Map* map, void* data) { |
9910 int slack = map->unused_property_fields(); | 9915 int slack = map->unused_property_fields(); |
9911 if (*reinterpret_cast<int*>(data) > slack) { | 9916 if (*reinterpret_cast<int*>(data) > slack) { |
9912 *reinterpret_cast<int*>(data) = slack; | 9917 *reinterpret_cast<int*>(data) = slack; |
(...skipping 7145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
17058 CompilationInfo* info) { | 17063 CompilationInfo* info) { |
17059 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( | 17064 Handle<DependentCode> codes = DependentCode::InsertCompilationInfo( |
17060 handle(cell->dependent_code(), info->isolate()), | 17065 handle(cell->dependent_code(), info->isolate()), |
17061 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); | 17066 DependentCode::kPropertyCellChangedGroup, info->object_wrapper()); |
17062 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); | 17067 if (*codes != cell->dependent_code()) cell->set_dependent_code(*codes); |
17063 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( | 17068 info->dependencies(DependentCode::kPropertyCellChangedGroup)->Add( |
17064 cell, info->zone()); | 17069 cell, info->zone()); |
17065 } | 17070 } |
17066 | 17071 |
17067 } } // namespace v8::internal | 17072 } } // namespace v8::internal |
OLD | NEW |