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

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

Issue 1073053006: Revert of 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( 110 layout_descriptor->DataSize());
111 FixedTypedArrayBase::cast(layout_descriptor->elements()));
112 Handle<FixedTypedArrayBase> new_elements(
113 FixedTypedArrayBase::cast(new_layout_descriptor->elements()));
114 memcpy(new_elements->DataPtr(), elements->DataPtr(), elements->DataSize());
115 return new_layout_descriptor; 111 return new_layout_descriptor;
116 } else { 112 } else {
117 // Fast layout. 113 // Fast layout.
118 uint32_t value = 114 uint32_t value =
119 static_cast<uint32_t>(Smi::cast(*layout_descriptor)->value()); 115 static_cast<uint32_t>(Smi::cast(*layout_descriptor)->value());
120 new_layout_descriptor->set(0, value); 116 new_layout_descriptor->set(0, value);
121 return new_layout_descriptor; 117 return new_layout_descriptor;
122 } 118 }
123 } 119 }
124 120
(...skipping 22 matching lines...) Expand all
147 143
148 bool is_tagged = (value & layout_mask) == 0; 144 bool is_tagged = (value & layout_mask) == 0;
149 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.
150 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.
151 int sequence_length = CountTrailingZeros32(value) - layout_bit_index; 147 int sequence_length = CountTrailingZeros32(value) - layout_bit_index;
152 148
153 if (layout_bit_index + sequence_length == kNumberOfBits) { 149 if (layout_bit_index + sequence_length == kNumberOfBits) {
154 // 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
155 // counting in the subsequent words. 151 // counting in the subsequent words.
156 if (IsSlowLayout()) { 152 if (IsSlowLayout()) {
157 int len = Smi::cast(length())->value(); 153 int len = length();
158 ++layout_word_index; 154 ++layout_word_index;
159 for (; layout_word_index < len; layout_word_index++) { 155 for (; layout_word_index < len; layout_word_index++) {
160 value = get_scalar(layout_word_index); 156 value = get_scalar(layout_word_index);
161 bool cur_is_tagged = (value & 1) == 0; 157 bool cur_is_tagged = (value & 1) == 0;
162 if (cur_is_tagged != is_tagged) break; 158 if (cur_is_tagged != is_tagged) break;
163 if (!is_tagged) value = ~value; // Count set bits instead. 159 if (!is_tagged) value = ~value; // Count set bits instead.
164 int cur_sequence_length = CountTrailingZeros32(value); 160 int cur_sequence_length = CountTrailingZeros32(value);
165 sequence_length += cur_sequence_length; 161 sequence_length += cur_sequence_length;
166 if (sequence_length >= max_sequence_length) break; 162 if (sequence_length >= max_sequence_length) break;
167 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
238 if (!IsSlowLayout()) return this; 234 if (!IsSlowLayout()) return this;
239 235
240 int layout_descriptor_length = 236 int layout_descriptor_length =
241 CalculateCapacity(map, descriptors, num_descriptors); 237 CalculateCapacity(map, descriptors, num_descriptors);
242 // 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
243 // 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.
244 DCHECK_LT(kSmiValueSize, layout_descriptor_length); 240 DCHECK_LT(kSmiValueSize, layout_descriptor_length);
245 241
246 // Trim, clean and reinitialize this slow-mode layout descriptor. 242 // Trim, clean and reinitialize this slow-mode layout descriptor.
247 int array_length = GetSlowModeBackingStoreLength(layout_descriptor_length); 243 int array_length = GetSlowModeBackingStoreLength(layout_descriptor_length);
248 int current_length = Smi::cast(length())->value(); 244 int current_length = length();
249 if (current_length != array_length) { 245 if (current_length != array_length) {
250 DCHECK_LT(array_length, current_length); 246 DCHECK_LT(array_length, current_length);
251 int delta = current_length - array_length; 247 int delta = current_length - array_length;
252 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(elements(), delta); 248 heap->RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(this, delta);
253 set_byte_length(Smi::FromInt(array_length * 4));
254 set_length(Smi::FromInt(array_length));
255 } 249 }
256 { 250 memset(DataPtr(), 0, DataSize());
257 DisallowHeapAllocation no_gc;
258 Handle<FixedTypedArrayBase> fixed_array(
259 FixedTypedArrayBase::cast(elements()));
260 memset(fixed_array->DataPtr(), 0, fixed_array->DataSize());
261 }
262 LayoutDescriptor* layout_descriptor = 251 LayoutDescriptor* layout_descriptor =
263 Initialize(this, map, descriptors, num_descriptors); 252 Initialize(this, map, descriptors, num_descriptors);
264 DCHECK_EQ(this, layout_descriptor); 253 DCHECK_EQ(this, layout_descriptor);
265 return layout_descriptor; 254 return layout_descriptor;
266 } 255 }
267 256
268 257
269 bool LayoutDescriptor::IsConsistentWithMap(Map* map, bool check_tail) { 258 bool LayoutDescriptor::IsConsistentWithMap(Map* map, bool check_tail) {
270 if (FLAG_unbox_double_fields) { 259 if (FLAG_unbox_double_fields) {
271 DescriptorArray* descriptors = map->instance_descriptors(); 260 DescriptorArray* descriptors = map->instance_descriptors();
(...skipping 18 matching lines...) Expand all
290 int n = capacity(); 279 int n = capacity();
291 for (int i = last_field_index; i < n; i++) { 280 for (int i = last_field_index; i < n; i++) {
292 DCHECK(IsTagged(i)); 281 DCHECK(IsTagged(i));
293 } 282 }
294 } 283 }
295 } 284 }
296 return true; 285 return true;
297 } 286 }
298 } 287 }
299 } // 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