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 2386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2397 return defn; | 2397 return defn; |
2398 } | 2398 } |
2399 return this; | 2399 return this; |
2400 } | 2400 } |
2401 | 2401 |
2402 | 2402 |
2403 static bool MayBeBoxableNumber(intptr_t cid) { | 2403 static bool MayBeBoxableNumber(intptr_t cid) { |
2404 return (cid == kDynamicCid) || | 2404 return (cid == kDynamicCid) || |
2405 (cid == kMintCid) || | 2405 (cid == kMintCid) || |
2406 (cid == kBigintCid) || | 2406 (cid == kBigintCid) || |
2407 (cid == kDoubleCid); | 2407 (cid == kDoubleCid) || |
| 2408 (cid == kPixelsCid); |
2408 } | 2409 } |
2409 | 2410 |
2410 | 2411 |
2411 static bool MaybeNumber(CompileType* type) { | 2412 static bool MaybeNumber(CompileType* type) { |
2412 ASSERT(Type::Handle(Type::Number()).IsMoreSpecificThan( | 2413 ASSERT(Type::Handle(Type::Number()).IsMoreSpecificThan( |
2413 Type::Handle(Type::Number()), NULL, NULL, Heap::kOld)); | 2414 Type::Handle(Type::Number()), NULL, NULL, Heap::kOld)); |
2414 return type->ToAbstractType()->IsDynamicType() | 2415 return type->ToAbstractType()->IsDynamicType() |
2415 || type->ToAbstractType()->IsObjectType() | 2416 || type->ToAbstractType()->IsObjectType() |
2416 || type->ToAbstractType()->IsTypeParameter() | 2417 || type->ToAbstractType()->IsTypeParameter() |
2417 || type->IsMoreSpecificThan(Type::Handle(Type::Number())); | 2418 || type->IsMoreSpecificThan(Type::Handle(Type::Number())); |
2418 } | 2419 } |
2419 | 2420 |
2420 | 2421 |
2421 // Returns a replacement for a strict comparison and signals if the result has | 2422 // Returns a replacement for a strict comparison and signals if the result has |
2422 // to be negated. | 2423 // to be negated. |
2423 static Definition* CanonicalizeStrictCompare(StrictCompareInstr* compare, | 2424 static Definition* CanonicalizeStrictCompare(StrictCompareInstr* compare, |
2424 bool* negated) { | 2425 bool* negated) { |
2425 // Use propagated cid and type information to eliminate number checks. | 2426 // Use propagated cid and type information to eliminate number checks. |
2426 // If one of the inputs is not a boxable number (Mint, Double, Bigint), or | 2427 // If one of the inputs is not a boxable number (Mint, Double, Bigint, |
2427 // is not a subtype of num, no need for number checks. | 2428 // Pixels), or is not a subtype of num, no need for number checks. |
2428 if (compare->needs_number_check()) { | 2429 if (compare->needs_number_check()) { |
2429 if (!MayBeBoxableNumber(compare->left()->Type()->ToCid()) || | 2430 if (!MayBeBoxableNumber(compare->left()->Type()->ToCid()) || |
2430 !MayBeBoxableNumber(compare->right()->Type()->ToCid())) { | 2431 !MayBeBoxableNumber(compare->right()->Type()->ToCid())) { |
2431 compare->set_needs_number_check(false); | 2432 compare->set_needs_number_check(false); |
2432 } else if (!MaybeNumber(compare->left()->Type()) || | 2433 } else if (!MaybeNumber(compare->left()->Type()) || |
2433 !MaybeNumber(compare->right()->Type())) { | 2434 !MaybeNumber(compare->right()->Type())) { |
2434 compare->set_needs_number_check(false); | 2435 compare->set_needs_number_check(false); |
2435 } | 2436 } |
2436 } | 2437 } |
2437 | 2438 |
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3919 set_native_c_function(native_function); | 3920 set_native_c_function(native_function); |
3920 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3921 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
3921 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3922 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
3922 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3923 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
3923 set_is_bootstrap_native(is_bootstrap_native); | 3924 set_is_bootstrap_native(is_bootstrap_native); |
3924 } | 3925 } |
3925 | 3926 |
3926 #undef __ | 3927 #undef __ |
3927 | 3928 |
3928 } // namespace dart | 3929 } // namespace dart |
OLD | NEW |