OLD | NEW |
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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/runtime/runtime-utils.h" | 8 #include "src/runtime/runtime-utils.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 if (length == range) return; // All indices accounted for already. | 413 if (length == range) return; // All indices accounted for already. |
414 break; | 414 break; |
415 } | 415 } |
416 case SLOPPY_ARGUMENTS_ELEMENTS: { | 416 case SLOPPY_ARGUMENTS_ELEMENTS: { |
417 MaybeHandle<Object> length_obj = | 417 MaybeHandle<Object> length_obj = |
418 Object::GetProperty(object, isolate->factory()->length_string()); | 418 Object::GetProperty(object, isolate->factory()->length_string()); |
419 double length_num = length_obj.ToHandleChecked()->Number(); | 419 double length_num = length_obj.ToHandleChecked()->Number(); |
420 uint32_t length = static_cast<uint32_t>(DoubleToInt32(length_num)); | 420 uint32_t length = static_cast<uint32_t>(DoubleToInt32(length_num)); |
421 ElementsAccessor* accessor = object->GetElementsAccessor(); | 421 ElementsAccessor* accessor = object->GetElementsAccessor(); |
422 for (uint32_t i = 0; i < length; i++) { | 422 for (uint32_t i = 0; i < length; i++) { |
423 if (accessor->HasElement(object, object, i)) { | 423 if (accessor->HasElement(object, i)) { |
424 indices->Add(i); | 424 indices->Add(i); |
425 } | 425 } |
426 } | 426 } |
427 break; | 427 break; |
428 } | 428 } |
429 } | 429 } |
430 | 430 |
431 PrototypeIterator iter(isolate, object); | 431 PrototypeIterator iter(isolate, object); |
432 if (!iter.IsAtEnd()) { | 432 if (!iter.IsAtEnd()) { |
433 // The prototype will usually have no inherited element indices, | 433 // The prototype will usually have no inherited element indices, |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 } | 680 } |
681 case FLOAT64_ELEMENTS: { | 681 case FLOAT64_ELEMENTS: { |
682 IterateTypedArrayElements<FixedFloat64Array, double>( | 682 IterateTypedArrayElements<FixedFloat64Array, double>( |
683 isolate, receiver, false, false, visitor); | 683 isolate, receiver, false, false, visitor); |
684 break; | 684 break; |
685 } | 685 } |
686 case SLOPPY_ARGUMENTS_ELEMENTS: { | 686 case SLOPPY_ARGUMENTS_ELEMENTS: { |
687 ElementsAccessor* accessor = receiver->GetElementsAccessor(); | 687 ElementsAccessor* accessor = receiver->GetElementsAccessor(); |
688 for (uint32_t index = 0; index < length; index++) { | 688 for (uint32_t index = 0; index < length; index++) { |
689 HandleScope loop_scope(isolate); | 689 HandleScope loop_scope(isolate); |
690 if (accessor->HasElement(receiver, receiver, index)) { | 690 if (accessor->HasElement(receiver, index)) { |
691 Handle<Object> element; | 691 Handle<Object> element; |
692 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 692 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
693 isolate, element, accessor->Get(receiver, receiver, index), | 693 isolate, element, accessor->Get(receiver, receiver, index), |
694 false); | 694 false); |
695 visitor->visit(index, element); | 695 visitor->visit(index, element); |
696 } | 696 } |
697 } | 697 } |
698 break; | 698 break; |
699 } | 699 } |
700 } | 700 } |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
972 } | 972 } |
973 // For holey elements, take samples from the buffer checking for holes | 973 // For holey elements, take samples from the buffer checking for holes |
974 // to generate the estimate. | 974 // to generate the estimate. |
975 const int kNumberOfHoleCheckSamples = 97; | 975 const int kNumberOfHoleCheckSamples = 97; |
976 int increment = (length < kNumberOfHoleCheckSamples) | 976 int increment = (length < kNumberOfHoleCheckSamples) |
977 ? 1 | 977 ? 1 |
978 : static_cast<int>(length / kNumberOfHoleCheckSamples); | 978 : static_cast<int>(length / kNumberOfHoleCheckSamples); |
979 ElementsAccessor* accessor = array->GetElementsAccessor(); | 979 ElementsAccessor* accessor = array->GetElementsAccessor(); |
980 int holes = 0; | 980 int holes = 0; |
981 for (int i = 0; i < length; i += increment) { | 981 for (int i = 0; i < length; i += increment) { |
982 if (!accessor->HasElement(array, array, i, elements)) { | 982 if (!accessor->HasElement(array, i, elements)) { |
983 ++holes; | 983 ++holes; |
984 } | 984 } |
985 } | 985 } |
986 int estimate = static_cast<int>((kNumberOfHoleCheckSamples - holes) / | 986 int estimate = static_cast<int>((kNumberOfHoleCheckSamples - holes) / |
987 kNumberOfHoleCheckSamples * length); | 987 kNumberOfHoleCheckSamples * length); |
988 return Smi::FromInt(estimate); | 988 return Smi::FromInt(estimate); |
989 } | 989 } |
990 } | 990 } |
991 | 991 |
992 | 992 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 } | 1310 } |
1311 | 1311 |
1312 | 1312 |
1313 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { | 1313 RUNTIME_FUNCTION(RuntimeReference_FastOneByteArrayJoin) { |
1314 SealHandleScope shs(isolate); | 1314 SealHandleScope shs(isolate); |
1315 DCHECK(args.length() == 2); | 1315 DCHECK(args.length() == 2); |
1316 return isolate->heap()->undefined_value(); | 1316 return isolate->heap()->undefined_value(); |
1317 } | 1317 } |
1318 } | 1318 } |
1319 } // namespace v8::internal | 1319 } // namespace v8::internal |
OLD | NEW |