Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(483)

Side by Side Diff: src/layout-descriptor.cc

Issue 1080403004: Revert of Reland "LayoutDescriptor should inherit from JSTypedArray" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/layout-descriptor.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 <sstream> 5 #include <sstream>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/layout-descriptor.h" 10 #include "src/layout-descriptor.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 int new_capacity) { 99 int new_capacity) {
100 int old_capacity = layout_descriptor->capacity(); 100 int old_capacity = layout_descriptor->capacity();
101 if (new_capacity <= old_capacity) { 101 if (new_capacity <= old_capacity) {
102 return layout_descriptor; 102 return layout_descriptor;
103 } 103 }
104 Handle<LayoutDescriptor> new_layout_descriptor = 104 Handle<LayoutDescriptor> new_layout_descriptor =
105 LayoutDescriptor::New(isolate, new_capacity); 105 LayoutDescriptor::New(isolate, new_capacity);
106 DCHECK(new_layout_descriptor->IsSlowLayout()); 106 DCHECK(new_layout_descriptor->IsSlowLayout());
107 107
108 if (layout_descriptor->IsSlowLayout()) { 108 if (layout_descriptor->IsSlowLayout()) {
109 DisallowHeapAllocation no_gc; 109 memcpy(new_layout_descriptor->DataPtr(), layout_descriptor->DataPtr(),
110 Handle<FixedTypedArrayBase> elements(layout_descriptor->GcSafeElements()); 110 layout_descriptor->DataSize());
111 Handle<FixedTypedArrayBase> new_elements(
112 new_layout_descriptor->GcSafeElements());
113 memcpy(new_elements->DataPtr(), elements->DataPtr(), elements->DataSize());
114 return new_layout_descriptor; 111 return new_layout_descriptor;
115 } else { 112 } else {
116 // Fast layout. 113 // Fast layout.
117 uint32_t value = 114 uint32_t value =
118 static_cast<uint32_t>(Smi::cast(*layout_descriptor)->value()); 115 static_cast<uint32_t>(Smi::cast(*layout_descriptor)->value());
119 new_layout_descriptor->set(0, value); 116 new_layout_descriptor->set(0, value);
120 return new_layout_descriptor; 117 return new_layout_descriptor;
121 } 118 }
122 } 119 }
123 120
(...skipping 22 matching lines...) Expand all
146 143
147 bool is_tagged = (value & layout_mask) == 0; 144 bool is_tagged = (value & layout_mask) == 0;
148 if (!is_tagged) value = ~value; // Count set bits instead of cleared bits. 145 if (!is_tagged) value = ~value; // Count set bits instead of cleared bits.
149 value = value & ~(layout_mask - 1); // Clear bits we are not interested in. 146 value = value & ~(layout_mask - 1); // Clear bits we are not interested in.
150 int sequence_length = CountTrailingZeros32(value) - layout_bit_index; 147 int sequence_length = CountTrailingZeros32(value) - layout_bit_index;
151 148
152 if (layout_bit_index + sequence_length == kNumberOfBits) { 149 if (layout_bit_index + sequence_length == kNumberOfBits) {
153 // This is a contiguous sequence till the end of current word, proceed 150 // This is a contiguous sequence till the end of current word, proceed
154 // counting in the subsequent words. 151 // counting in the subsequent words.
155 if (IsSlowLayout()) { 152 if (IsSlowLayout()) {
156 int len = Smi::cast(length())->value(); 153 int len = length();
157 ++layout_word_index; 154 ++layout_word_index;
158 for (; layout_word_index < len; layout_word_index++) { 155 for (; layout_word_index < len; layout_word_index++) {
159 value = get_scalar(layout_word_index); 156 value = get_scalar(layout_word_index);
160 bool cur_is_tagged = (value & 1) == 0; 157 bool cur_is_tagged = (value & 1) == 0;
161 if (cur_is_tagged != is_tagged) break; 158 if (cur_is_tagged != is_tagged) break;
162 if (!is_tagged) value = ~value; // Count set bits instead. 159 if (!is_tagged) value = ~value; // Count set bits instead.
163 int cur_sequence_length = CountTrailingZeros32(value); 160 int cur_sequence_length = CountTrailingZeros32(value);
164 sequence_length += cur_sequence_length; 161 sequence_length += cur_sequence_length;
165 if (sequence_length >= max_sequence_length) break; 162 if (sequence_length >= max_sequence_length) break;
166 if (cur_sequence_length != kNumberOfBits) break; 163 if (cur_sequence_length != kNumberOfBits) break;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 if (!IsSlowLayout()) return this; 234 if (!IsSlowLayout()) return this;
238 235
239 int layout_descriptor_length = 236 int layout_descriptor_length =
240 CalculateCapacity(map, descriptors, num_descriptors); 237 CalculateCapacity(map, descriptors, num_descriptors);
241 // It must not become fast-mode descriptor here, because otherwise it has to 238 // It must not become fast-mode descriptor here, because otherwise it has to
242 // be fast pointer layout descriptor already but it's is slow mode now. 239 // be fast pointer layout descriptor already but it's is slow mode now.
243 DCHECK_LT(kSmiValueSize, layout_descriptor_length); 240 DCHECK_LT(kSmiValueSize, layout_descriptor_length);
244 241
245 // Trim, clean and reinitialize this slow-mode layout descriptor. 242 // Trim, clean and reinitialize this slow-mode layout descriptor.
246 int array_length = GetSlowModeBackingStoreLength(layout_descriptor_length); 243 int array_length = GetSlowModeBackingStoreLength(layout_descriptor_length);
247 int current_length = Smi::cast(length())->value(); 244 int current_length = length();
248 if (current_length != array_length) { 245 if (current_length != array_length) {
249 DCHECK_LT(array_length, current_length); 246 DCHECK_LT(array_length, current_length);
250 int delta = current_length - array_length; 247 int delta = current_length - array_length;
251 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(elements(), delta); 248 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(this, delta);
252 set_byte_length(Smi::FromInt(array_length * 4));
253 set_length(Smi::FromInt(array_length));
254 } 249 }
255 { 250 memset(DataPtr(), 0, DataSize());
256 DisallowHeapAllocation no_gc;
257 Handle<FixedTypedArrayBase> fixed_array(
258 FixedTypedArrayBase::cast(elements()));
259 memset(fixed_array->DataPtr(), 0, fixed_array->DataSize());
260 }
261 LayoutDescriptor* layout_descriptor = 251 LayoutDescriptor* layout_descriptor =
262 Initialize(this, map, descriptors, num_descriptors); 252 Initialize(this, map, descriptors, num_descriptors);
263 DCHECK_EQ(this, layout_descriptor); 253 DCHECK_EQ(this, layout_descriptor);
264 return layout_descriptor; 254 return layout_descriptor;
265 } 255 }
266 256
267 257
268 bool LayoutDescriptor::IsConsistentWithMap(Map* map, bool check_tail) { 258 bool LayoutDescriptor::IsConsistentWithMap(Map* map, bool check_tail) {
269 if (FLAG_unbox_double_fields) { 259 if (FLAG_unbox_double_fields) {
270 DescriptorArray* descriptors = map->instance_descriptors(); 260 DescriptorArray* descriptors = map->instance_descriptors();
(...skipping 18 matching lines...) Expand all
289 int n = capacity(); 279 int n = capacity();
290 for (int i = last_field_index; i < n; i++) { 280 for (int i = last_field_index; i < n; i++) {
291 DCHECK(IsTagged(i)); 281 DCHECK(IsTagged(i));
292 } 282 }
293 } 283 }
294 } 284 }
295 return true; 285 return true;
296 } 286 }
297 } 287 }
298 } // namespace v8::internal 288 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/layout-descriptor.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698