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 "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 9910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9921 new_size = SeqTwoByteString::SizeFor(new_length); | 9921 new_size = SeqTwoByteString::SizeFor(new_length); |
9922 } | 9922 } |
9923 | 9923 |
9924 int delta = old_size - new_size; | 9924 int delta = old_size - new_size; |
9925 | 9925 |
9926 Address start_of_string = string->address(); | 9926 Address start_of_string = string->address(); |
9927 DCHECK_OBJECT_ALIGNED(start_of_string); | 9927 DCHECK_OBJECT_ALIGNED(start_of_string); |
9928 DCHECK_OBJECT_ALIGNED(start_of_string + new_size); | 9928 DCHECK_OBJECT_ALIGNED(start_of_string + new_size); |
9929 | 9929 |
9930 Heap* heap = string->GetHeap(); | 9930 Heap* heap = string->GetHeap(); |
9931 NewSpace* newspace = heap->new_space(); | 9931 // Sizes are pointer size aligned, so that we can use filler objects |
9932 if (newspace->Contains(start_of_string) && | 9932 // that are a multiple of pointer size. |
9933 newspace->top() == start_of_string + old_size) { | 9933 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
9934 // Last allocated object in new space. Simply lower allocation top. | |
9935 newspace->set_top(start_of_string + new_size); | |
9936 } else { | |
9937 // Sizes are pointer size aligned, so that we can use filler objects | |
9938 // that are a multiple of pointer size. | |
9939 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | |
9940 } | |
9941 heap->AdjustLiveBytes(*string, -delta, Heap::CONCURRENT_TO_SWEEPER); | 9934 heap->AdjustLiveBytes(*string, -delta, Heap::CONCURRENT_TO_SWEEPER); |
9942 | 9935 |
9943 // We are storing the new length using release store after creating a filler | 9936 // We are storing the new length using release store after creating a filler |
9944 // for the left-over space to avoid races with the sweeper thread. | 9937 // for the left-over space to avoid races with the sweeper thread. |
9945 string->synchronized_set_length(new_length); | 9938 string->synchronized_set_length(new_length); |
9946 | 9939 |
9947 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9940 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9948 return string; | 9941 return string; |
9949 } | 9942 } |
9950 | 9943 |
(...skipping 6850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16801 if (cell->value() != *new_value) { | 16794 if (cell->value() != *new_value) { |
16802 cell->set_value(*new_value); | 16795 cell->set_value(*new_value); |
16803 Isolate* isolate = cell->GetIsolate(); | 16796 Isolate* isolate = cell->GetIsolate(); |
16804 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16797 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16805 isolate, DependentCode::kPropertyCellChangedGroup); | 16798 isolate, DependentCode::kPropertyCellChangedGroup); |
16806 } | 16799 } |
16807 } | 16800 } |
16808 | 16801 |
16809 } // namespace internal | 16802 } // namespace internal |
16810 } // namespace v8 | 16803 } // namespace v8 |
OLD | NEW |