| 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
| 6 | 6 |
| 7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
| 8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
| 9 #include "src/elements.h" | 9 #include "src/elements.h" |
| 10 #include "src/factory.h" | 10 #include "src/factory.h" |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 uint32_t estimate_nof_elements = 0; | 723 uint32_t estimate_nof_elements = 0; |
| 724 for (int i = 0; i < argument_count; i++) { | 724 for (int i = 0; i < argument_count; i++) { |
| 725 HandleScope loop_scope(isolate); | 725 HandleScope loop_scope(isolate); |
| 726 Handle<Object> obj(elements->get(i), isolate); | 726 Handle<Object> obj(elements->get(i), isolate); |
| 727 uint32_t length_estimate; | 727 uint32_t length_estimate; |
| 728 uint32_t element_estimate; | 728 uint32_t element_estimate; |
| 729 if (obj->IsJSArray()) { | 729 if (obj->IsJSArray()) { |
| 730 Handle<JSArray> array(Handle<JSArray>::cast(obj)); | 730 Handle<JSArray> array(Handle<JSArray>::cast(obj)); |
| 731 length_estimate = static_cast<uint32_t>(array->length()->Number()); | 731 length_estimate = static_cast<uint32_t>(array->length()->Number()); |
| 732 if (length_estimate != 0) { | 732 if (length_estimate != 0) { |
| 733 ElementsKind array_kind = | 733 kind = GetMoreGeneralElementsKind( |
| 734 GetPackedElementsKind(array->map()->elements_kind()); | 734 kind, GetPackedElementsKind(array->map()->elements_kind())); |
| 735 if (IsMoreGeneralElementsKindTransition(kind, array_kind)) { | |
| 736 kind = array_kind; | |
| 737 } | |
| 738 } | 735 } |
| 739 element_estimate = EstimateElementCount(array); | 736 element_estimate = EstimateElementCount(array); |
| 740 } else { | 737 } else { |
| 741 if (obj->IsHeapObject()) { | 738 if (obj->IsHeapObject()) { |
| 742 if (obj->IsNumber()) { | 739 if (obj->IsNumber()) { |
| 743 if (IsMoreGeneralElementsKindTransition(kind, FAST_DOUBLE_ELEMENTS)) { | 740 kind = GetMoreGeneralElementsKind(kind, FAST_DOUBLE_ELEMENTS); |
| 744 kind = FAST_DOUBLE_ELEMENTS; | 741 } else { |
| 745 } | 742 kind = GetMoreGeneralElementsKind(kind, FAST_ELEMENTS); |
| 746 } else if (IsMoreGeneralElementsKindTransition(kind, FAST_ELEMENTS)) { | |
| 747 kind = FAST_ELEMENTS; | |
| 748 } | 743 } |
| 749 } | 744 } |
| 750 length_estimate = 1; | 745 length_estimate = 1; |
| 751 element_estimate = 1; | 746 element_estimate = 1; |
| 752 } | 747 } |
| 753 // Avoid overflows by capping at kMaxElementCount. | 748 // Avoid overflows by capping at kMaxElementCount. |
| 754 if (JSObject::kMaxElementCount - estimate_result_length < length_estimate) { | 749 if (JSObject::kMaxElementCount - estimate_result_length < length_estimate) { |
| 755 estimate_result_length = JSObject::kMaxElementCount; | 750 estimate_result_length = JSObject::kMaxElementCount; |
| 756 } else { | 751 } else { |
| 757 estimate_result_length += length_estimate; | 752 estimate_result_length += length_estimate; |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 | 1267 |
| 1273 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { | 1268 RUNTIME_FUNCTION(Runtime_FastOneByteArrayJoin) { |
| 1274 SealHandleScope shs(isolate); | 1269 SealHandleScope shs(isolate); |
| 1275 DCHECK(args.length() == 2); | 1270 DCHECK(args.length() == 2); |
| 1276 // Returning undefined means that this fast path fails and one has to resort | 1271 // Returning undefined means that this fast path fails and one has to resort |
| 1277 // to a slow path. | 1272 // to a slow path. |
| 1278 return isolate->heap()->undefined_value(); | 1273 return isolate->heap()->undefined_value(); |
| 1279 } | 1274 } |
| 1280 } // namespace internal | 1275 } // namespace internal |
| 1281 } // namespace v8 | 1276 } // namespace v8 |
| OLD | NEW |