| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/constant_propagator.h" | 10 #include "vm/constant_propagator.h" |
| (...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2020 // For fixed length arrays if the array is the result of a known constructor | 2020 // For fixed length arrays if the array is the result of a known constructor |
| 2021 // call we can replace the length load with the length argument passed to | 2021 // call we can replace the length load with the length argument passed to |
| 2022 // the constructor. | 2022 // the constructor. |
| 2023 StaticCallInstr* call = | 2023 StaticCallInstr* call = |
| 2024 instance()->definition()->OriginalDefinition()->AsStaticCall(); | 2024 instance()->definition()->OriginalDefinition()->AsStaticCall(); |
| 2025 if (call != NULL) { | 2025 if (call != NULL) { |
| 2026 if (call->is_known_list_constructor() && | 2026 if (call->is_known_list_constructor() && |
| 2027 IsFixedLengthArrayCid(call->Type()->ToCid())) { | 2027 IsFixedLengthArrayCid(call->Type()->ToCid())) { |
| 2028 return call->ArgumentAt(1); | 2028 return call->ArgumentAt(1); |
| 2029 } | 2029 } |
| 2030 if (call->is_native_list_factory()) { | |
| 2031 return call->ArgumentAt(0); | |
| 2032 } | |
| 2033 } | 2030 } |
| 2034 | 2031 |
| 2035 CreateArrayInstr* create_array = | 2032 CreateArrayInstr* create_array = |
| 2036 instance()->definition()->OriginalDefinition()->AsCreateArray(); | 2033 instance()->definition()->OriginalDefinition()->AsCreateArray(); |
| 2037 if ((create_array != NULL) && | 2034 if ((create_array != NULL) && |
| 2038 (recognized_kind() == MethodRecognizer::kObjectArrayLength)) { | 2035 (recognized_kind() == MethodRecognizer::kObjectArrayLength)) { |
| 2039 return create_array->num_elements()->definition(); | 2036 return create_array->num_elements()->definition(); |
| 2040 } | 2037 } |
| 2041 | 2038 |
| 2042 // For arrays with guarded lengths, replace the length load | 2039 // For arrays with guarded lengths, replace the length load |
| (...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2659 StaticCallInstr* call = value()->definition()->AsStaticCall(); | 2656 StaticCallInstr* call = value()->definition()->AsStaticCall(); |
| 2660 if (call == NULL) { | 2657 if (call == NULL) { |
| 2661 return this; | 2658 return this; |
| 2662 } | 2659 } |
| 2663 | 2660 |
| 2664 ConstantInstr* length = NULL; | 2661 ConstantInstr* length = NULL; |
| 2665 if (call->is_known_list_constructor() && | 2662 if (call->is_known_list_constructor() && |
| 2666 LoadFieldInstr::IsFixedLengthArrayCid(call->Type()->ToCid())) { | 2663 LoadFieldInstr::IsFixedLengthArrayCid(call->Type()->ToCid())) { |
| 2667 length = call->ArgumentAt(1)->AsConstant(); | 2664 length = call->ArgumentAt(1)->AsConstant(); |
| 2668 } | 2665 } |
| 2669 if (call->is_native_list_factory()) { | |
| 2670 length = call->ArgumentAt(0)->AsConstant(); | |
| 2671 } | |
| 2672 if ((length != NULL) && | 2666 if ((length != NULL) && |
| 2673 length->value().IsSmi() && | 2667 length->value().IsSmi() && |
| 2674 Smi::Cast(length->value()).Value() == expected_length) { | 2668 Smi::Cast(length->value()).Value() == expected_length) { |
| 2675 return NULL; // Expected length matched. | 2669 return NULL; // Expected length matched. |
| 2676 } | 2670 } |
| 2677 | 2671 |
| 2678 return this; | 2672 return this; |
| 2679 } | 2673 } |
| 2680 | 2674 |
| 2681 | 2675 |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3877 set_native_c_function(native_function); | 3871 set_native_c_function(native_function); |
| 3878 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3872 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
| 3879 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3873 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
| 3880 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3874 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
| 3881 set_is_bootstrap_native(is_bootstrap_native); | 3875 set_is_bootstrap_native(is_bootstrap_native); |
| 3882 } | 3876 } |
| 3883 | 3877 |
| 3884 #undef __ | 3878 #undef __ |
| 3885 | 3879 |
| 3886 } // namespace dart | 3880 } // namespace dart |
| OLD | NEW |