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

Side by Side Diff: src/elements.cc

Issue 1372533002: [elements.cc] Clean up CopyDoubleToObjectElements (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/elements.h" 5 #include "src/elements.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/conversions.h" 8 #include "src/conversions.h"
9 #include "src/factory.h" 9 #include "src/factory.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 } 204 }
205 205
206 206
207 // NOTE: this method violates the handlified function signature convention: 207 // NOTE: this method violates the handlified function signature convention:
208 // raw pointer parameters in the function that allocates. 208 // raw pointer parameters in the function that allocates.
209 // See ElementsAccessorBase::CopyElements() for details. 209 // See ElementsAccessorBase::CopyElements() for details.
210 static void CopyDoubleToObjectElements(FixedArrayBase* from_base, 210 static void CopyDoubleToObjectElements(FixedArrayBase* from_base,
211 uint32_t from_start, 211 uint32_t from_start,
212 FixedArrayBase* to_base, 212 FixedArrayBase* to_base,
213 ElementsKind to_kind, uint32_t to_start, 213 uint32_t to_start, int raw_copy_size) {
214 int raw_copy_size) {
215 DCHECK(IsFastSmiOrObjectElementsKind(to_kind));
216 int copy_size = raw_copy_size; 214 int copy_size = raw_copy_size;
217 if (raw_copy_size < 0) { 215 if (raw_copy_size < 0) {
218 DisallowHeapAllocation no_allocation; 216 DisallowHeapAllocation no_allocation;
219 DCHECK(raw_copy_size == ElementsAccessor::kCopyToEnd || 217 DCHECK(raw_copy_size == ElementsAccessor::kCopyToEnd ||
220 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole); 218 raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole);
221 copy_size = Min(from_base->length() - from_start, 219 copy_size = Min(from_base->length() - from_start,
222 to_base->length() - to_start); 220 to_base->length() - to_start);
223 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) { 221 if (raw_copy_size == ElementsAccessor::kCopyToEndAndInitializeToHole) {
224 // Also initialize the area that will be copied over since HeapNumber 222 // Also initialize the area that will be copied over since HeapNumber
225 // allocation below can cause an incremental marking step, requiring all 223 // allocation below can cause an incremental marking step, requiring all
(...skipping 19 matching lines...) Expand all
245 Handle<FixedArray> to(FixedArray::cast(to_base), isolate); 243 Handle<FixedArray> to(FixedArray::cast(to_base), isolate);
246 244
247 // create an outer loop to not waste too much time on creating HandleScopes 245 // create an outer loop to not waste too much time on creating HandleScopes
248 // on the other hand we might overflow a single handle scope depending on 246 // on the other hand we might overflow a single handle scope depending on
249 // the copy_size 247 // the copy_size
250 int offset = 0; 248 int offset = 0;
251 while (offset < copy_size) { 249 while (offset < copy_size) {
252 HandleScope scope(isolate); 250 HandleScope scope(isolate);
253 offset += 100; 251 offset += 100;
254 for (int i = offset - 100; i < offset && i < copy_size; ++i) { 252 for (int i = offset - 100; i < offset && i < copy_size; ++i) {
255 if (IsFastSmiElementsKind(to_kind)) { 253 Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
256 UNIMPLEMENTED(); 254 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
257 } else {
258 DCHECK(IsFastObjectElementsKind(to_kind));
259 Handle<Object> value = FixedDoubleArray::get(from, i + from_start);
260 to->set(i + to_start, *value, UPDATE_WRITE_BARRIER);
261 }
262 } 255 }
263 } 256 }
264 } 257 }
265 258
266 259
267 static void CopyDoubleToDoubleElements(FixedArrayBase* from_base, 260 static void CopyDoubleToDoubleElements(FixedArrayBase* from_base,
268 uint32_t from_start, 261 uint32_t from_start,
269 FixedArrayBase* to_base, 262 FixedArrayBase* to_base,
270 uint32_t to_start, int raw_copy_size) { 263 uint32_t to_start, int raw_copy_size) {
271 DisallowHeapAllocation no_allocation; 264 DisallowHeapAllocation no_allocation;
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 case FAST_SMI_ELEMENTS: 1536 case FAST_SMI_ELEMENTS:
1544 case FAST_HOLEY_SMI_ELEMENTS: 1537 case FAST_HOLEY_SMI_ELEMENTS:
1545 case FAST_ELEMENTS: 1538 case FAST_ELEMENTS:
1546 case FAST_HOLEY_ELEMENTS: 1539 case FAST_HOLEY_ELEMENTS:
1547 CopyObjectToObjectElements(from, from_kind, from_start, to, to_kind, 1540 CopyObjectToObjectElements(from, from_kind, from_start, to, to_kind,
1548 to_start, copy_size); 1541 to_start, copy_size);
1549 break; 1542 break;
1550 case FAST_DOUBLE_ELEMENTS: 1543 case FAST_DOUBLE_ELEMENTS:
1551 case FAST_HOLEY_DOUBLE_ELEMENTS: { 1544 case FAST_HOLEY_DOUBLE_ELEMENTS: {
1552 AllowHeapAllocation allow_allocation; 1545 AllowHeapAllocation allow_allocation;
1553 CopyDoubleToObjectElements( 1546 DCHECK(IsFastObjectElementsKind(to_kind));
1554 from, from_start, to, to_kind, to_start, copy_size); 1547 CopyDoubleToObjectElements(from, from_start, to, to_start, copy_size);
1555 break; 1548 break;
1556 } 1549 }
1557 case DICTIONARY_ELEMENTS: 1550 case DICTIONARY_ELEMENTS:
1558 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start, 1551 CopyDictionaryToObjectElements(from, from_start, to, to_kind, to_start,
1559 copy_size); 1552 copy_size);
1560 break; 1553 break;
1561 case FAST_SLOPPY_ARGUMENTS_ELEMENTS: 1554 case FAST_SLOPPY_ARGUMENTS_ELEMENTS:
1562 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS: 1555 case SLOW_SLOPPY_ARGUMENTS_ELEMENTS:
1563 UNREACHABLE(); 1556 UNREACHABLE();
1564 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ 1557 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
2333 } 2326 }
2334 } 2327 }
2335 2328
2336 DCHECK(j == result_len); 2329 DCHECK(j == result_len);
2337 return result_array; 2330 return result_array;
2338 } 2331 }
2339 2332
2340 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL; 2333 ElementsAccessor** ElementsAccessor::elements_accessors_ = NULL;
2341 } // namespace internal 2334 } // namespace internal
2342 } // namespace v8 2335 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698