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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
878 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 878 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
879 | 879 |
880 // We are storing the new map using release store after creating a filler for | 880 // We are storing the new map using release store after creating a filler for |
881 // the left-over space to avoid races with the sweeper thread. | 881 // the left-over space to avoid races with the sweeper thread. |
882 this->synchronized_set_map(new_map); | 882 this->synchronized_set_map(new_map); |
883 | 883 |
884 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); | 884 ExternalTwoByteString* self = ExternalTwoByteString::cast(this); |
885 self->set_resource(resource); | 885 self->set_resource(resource); |
886 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 886 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
887 | 887 |
888 heap->AdjustLiveBytes(this->address(), new_size - size, | 888 heap->AdjustLiveBytes(this, new_size - size, Heap::CONCURRENT_TO_SWEEPER); |
889 Heap::CONCURRENT_TO_SWEEPER); | |
890 return true; | 889 return true; |
891 } | 890 } |
892 | 891 |
893 | 892 |
894 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { | 893 bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { |
895 // Externalizing twice leaks the external resource, so it's | 894 // Externalizing twice leaks the external resource, so it's |
896 // prohibited by the API. | 895 // prohibited by the API. |
897 DCHECK(!this->IsExternalString()); | 896 DCHECK(!this->IsExternalString()); |
898 #ifdef ENABLE_SLOW_DCHECKS | 897 #ifdef ENABLE_SLOW_DCHECKS |
899 if (FLAG_enable_slow_asserts) { | 898 if (FLAG_enable_slow_asserts) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); | 938 heap->CreateFillerObjectAt(this->address() + new_size, size - new_size); |
940 | 939 |
941 // We are storing the new map using release store after creating a filler for | 940 // We are storing the new map using release store after creating a filler for |
942 // the left-over space to avoid races with the sweeper thread. | 941 // the left-over space to avoid races with the sweeper thread. |
943 this->synchronized_set_map(new_map); | 942 this->synchronized_set_map(new_map); |
944 | 943 |
945 ExternalOneByteString* self = ExternalOneByteString::cast(this); | 944 ExternalOneByteString* self = ExternalOneByteString::cast(this); |
946 self->set_resource(resource); | 945 self->set_resource(resource); |
947 if (is_internalized) self->Hash(); // Force regeneration of the hash value. | 946 if (is_internalized) self->Hash(); // Force regeneration of the hash value. |
948 | 947 |
949 heap->AdjustLiveBytes(this->address(), new_size - size, | 948 heap->AdjustLiveBytes(this, new_size - size, Heap::CONCURRENT_TO_SWEEPER); |
950 Heap::CONCURRENT_TO_SWEEPER); | |
951 return true; | 949 return true; |
952 } | 950 } |
953 | 951 |
954 | 952 |
955 void String::StringShortPrint(StringStream* accumulator) { | 953 void String::StringShortPrint(StringStream* accumulator) { |
956 int len = length(); | 954 int len = length(); |
957 if (len > kMaxShortPrintLength) { | 955 if (len > kMaxShortPrintLength) { |
958 accumulator->Add("<Very long string[%u]>", len); | 956 accumulator->Add("<Very long string[%u]>", len); |
959 return; | 957 return; |
960 } | 958 } |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 | 2036 |
2039 // Create filler object past the new instance size. | 2037 // Create filler object past the new instance size. |
2040 int new_instance_size = new_map->instance_size(); | 2038 int new_instance_size = new_map->instance_size(); |
2041 int instance_size_delta = old_map->instance_size() - new_instance_size; | 2039 int instance_size_delta = old_map->instance_size() - new_instance_size; |
2042 DCHECK(instance_size_delta >= 0); | 2040 DCHECK(instance_size_delta >= 0); |
2043 | 2041 |
2044 if (instance_size_delta > 0) { | 2042 if (instance_size_delta > 0) { |
2045 Address address = object->address(); | 2043 Address address = object->address(); |
2046 heap->CreateFillerObjectAt( | 2044 heap->CreateFillerObjectAt( |
2047 address + new_instance_size, instance_size_delta); | 2045 address + new_instance_size, instance_size_delta); |
2048 heap->AdjustLiveBytes(address, -instance_size_delta, | 2046 heap->AdjustLiveBytes(*object, -instance_size_delta, |
2049 Heap::CONCURRENT_TO_SWEEPER); | 2047 Heap::CONCURRENT_TO_SWEEPER); |
2050 } | 2048 } |
2051 | 2049 |
2052 // We are storing the new map using release store after creating a filler for | 2050 // We are storing the new map using release store after creating a filler for |
2053 // the left-over space to avoid races with the sweeper thread. | 2051 // the left-over space to avoid races with the sweeper thread. |
2054 object->synchronized_set_map(*new_map); | 2052 object->synchronized_set_map(*new_map); |
2055 } | 2053 } |
2056 | 2054 |
2057 | 2055 |
2058 int Map::NumberOfFields() { | 2056 int Map::NumberOfFields() { |
(...skipping 2511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4570 | 4568 |
4571 // Resize the object in the heap if necessary. | 4569 // Resize the object in the heap if necessary. |
4572 int new_instance_size = new_map->instance_size(); | 4570 int new_instance_size = new_map->instance_size(); |
4573 int instance_size_delta = map->instance_size() - new_instance_size; | 4571 int instance_size_delta = map->instance_size() - new_instance_size; |
4574 DCHECK(instance_size_delta >= 0); | 4572 DCHECK(instance_size_delta >= 0); |
4575 | 4573 |
4576 if (instance_size_delta > 0) { | 4574 if (instance_size_delta > 0) { |
4577 Heap* heap = isolate->heap(); | 4575 Heap* heap = isolate->heap(); |
4578 heap->CreateFillerObjectAt(object->address() + new_instance_size, | 4576 heap->CreateFillerObjectAt(object->address() + new_instance_size, |
4579 instance_size_delta); | 4577 instance_size_delta); |
4580 heap->AdjustLiveBytes(object->address(), -instance_size_delta, | 4578 heap->AdjustLiveBytes(*object, -instance_size_delta, |
4581 Heap::CONCURRENT_TO_SWEEPER); | 4579 Heap::CONCURRENT_TO_SWEEPER); |
4582 } | 4580 } |
4583 | 4581 |
4584 // We are storing the new map using release store after creating a filler for | 4582 // We are storing the new map using release store after creating a filler for |
4585 // the left-over space to avoid races with the sweeper thread. | 4583 // the left-over space to avoid races with the sweeper thread. |
4586 object->synchronized_set_map(*new_map); | 4584 object->synchronized_set_map(*new_map); |
4587 | 4585 |
4588 object->set_properties(*dictionary); | 4586 object->set_properties(*dictionary); |
4589 | 4587 |
4590 // Ensure that in-object space of slow-mode object does not contain random | 4588 // Ensure that in-object space of slow-mode object does not contain random |
(...skipping 4526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9117 NewSpace* newspace = heap->new_space(); | 9115 NewSpace* newspace = heap->new_space(); |
9118 if (newspace->Contains(start_of_string) && | 9116 if (newspace->Contains(start_of_string) && |
9119 newspace->top() == start_of_string + old_size) { | 9117 newspace->top() == start_of_string + old_size) { |
9120 // Last allocated object in new space. Simply lower allocation top. | 9118 // Last allocated object in new space. Simply lower allocation top. |
9121 newspace->set_top(start_of_string + new_size); | 9119 newspace->set_top(start_of_string + new_size); |
9122 } else { | 9120 } else { |
9123 // Sizes are pointer size aligned, so that we can use filler objects | 9121 // Sizes are pointer size aligned, so that we can use filler objects |
9124 // that are a multiple of pointer size. | 9122 // that are a multiple of pointer size. |
9125 heap->CreateFillerObjectAt(start_of_string + new_size, delta); | 9123 heap->CreateFillerObjectAt(start_of_string + new_size, delta); |
9126 } | 9124 } |
9127 heap->AdjustLiveBytes(start_of_string, -delta, Heap::CONCURRENT_TO_SWEEPER); | 9125 heap->AdjustLiveBytes(*string, -delta, Heap::CONCURRENT_TO_SWEEPER); |
9128 | 9126 |
9129 // We are storing the new length using release store after creating a filler | 9127 // We are storing the new length using release store after creating a filler |
9130 // for the left-over space to avoid races with the sweeper thread. | 9128 // for the left-over space to avoid races with the sweeper thread. |
9131 string->synchronized_set_length(new_length); | 9129 string->synchronized_set_length(new_length); |
9132 | 9130 |
9133 if (new_length == 0) return heap->isolate()->factory()->empty_string(); | 9131 if (new_length == 0) return heap->isolate()->factory()->empty_string(); |
9134 return string; | 9132 return string; |
9135 } | 9133 } |
9136 | 9134 |
9137 | 9135 |
(...skipping 6634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15772 if (cell->value() != *new_value) { | 15770 if (cell->value() != *new_value) { |
15773 cell->set_value(*new_value); | 15771 cell->set_value(*new_value); |
15774 Isolate* isolate = cell->GetIsolate(); | 15772 Isolate* isolate = cell->GetIsolate(); |
15775 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 15773 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
15776 isolate, DependentCode::kPropertyCellChangedGroup); | 15774 isolate, DependentCode::kPropertyCellChangedGroup); |
15777 } | 15775 } |
15778 } | 15776 } |
15779 | 15777 |
15780 } // namespace internal | 15778 } // namespace internal |
15781 } // namespace v8 | 15779 } // namespace v8 |
OLD | NEW |