OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 // If the compile type of the value is void, we are type checking the result | 371 // If the compile type of the value is void, we are type checking the result |
372 // of a void function, which was checked to be null at the return statement | 372 // of a void function, which was checked to be null at the return statement |
373 // inside the function. | 373 // inside the function. |
374 if (compile_type.IsVoidType()) { | 374 if (compile_type.IsVoidType()) { |
375 ASSERT(FLAG_enable_type_checks); | 375 ASSERT(FLAG_enable_type_checks); |
376 *is_instance = true; | 376 *is_instance = true; |
377 return true; | 377 return true; |
378 } | 378 } |
379 | 379 |
380 // The Null type is only a subtype of Object and of Dynamic. | 380 // The Null type is only a subtype of Object and of dynamic. |
381 // Functions that do not explicitly return a value, implicitly return null, | 381 // Functions that do not explicitly return a value, implicitly return null, |
382 // except generative constructors, which return the object being constructed. | 382 // except generative constructors, which return the object being constructed. |
383 // It is therefore acceptable for void functions to return null. | 383 // It is therefore acceptable for void functions to return null. |
384 if (compile_type.IsNullType()) { | 384 if (compile_type.IsNullType()) { |
385 *is_instance = | 385 *is_instance = |
386 type.IsObjectType() || type.IsDynamicType() || type.IsVoidType(); | 386 type.IsObjectType() || type.IsDynamicType() || type.IsVoidType(); |
387 return true; | 387 return true; |
388 } | 388 } |
389 | 389 |
390 // Until we support a set of compile types, we can only give answers for | 390 // Until we support a set of compile types, we can only give answers for |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 | 958 |
959 | 959 |
960 RawAbstractType* StoreContextInstr::CompileType() const { | 960 RawAbstractType* StoreContextInstr::CompileType() const { |
961 return AbstractType::null(); | 961 return AbstractType::null(); |
962 } | 962 } |
963 | 963 |
964 | 964 |
965 RawAbstractType* ClosureCallInstr::CompileType() const { | 965 RawAbstractType* ClosureCallInstr::CompileType() const { |
966 // Because of function subtyping rules, the declared return type of a closure | 966 // Because of function subtyping rules, the declared return type of a closure |
967 // call cannot be relied upon for compile type analysis. For example, a | 967 // call cannot be relied upon for compile type analysis. For example, a |
968 // function returning Dynamic can be assigned to a closure variable declared | 968 // function returning dynamic can be assigned to a closure variable declared |
969 // to return int and may actually return a double at run-time. | 969 // to return int and may actually return a double at run-time. |
970 return Type::DynamicType(); | 970 return Type::DynamicType(); |
971 } | 971 } |
972 | 972 |
973 | 973 |
974 RawAbstractType* InstanceCallInstr::CompileType() const { | 974 RawAbstractType* InstanceCallInstr::CompileType() const { |
975 // TODO(regis): Return a more specific type than Dynamic for recognized | 975 // TODO(regis): Return a more specific type than dynamic for recognized |
976 // combinations of receiver type and method name. | 976 // combinations of receiver type and method name. |
977 return Type::DynamicType(); | 977 return Type::DynamicType(); |
978 } | 978 } |
979 | 979 |
980 | 980 |
981 RawAbstractType* PolymorphicInstanceCallInstr::CompileType() const { | 981 RawAbstractType* PolymorphicInstanceCallInstr::CompileType() const { |
982 return Type::DynamicType(); | 982 return Type::DynamicType(); |
983 } | 983 } |
984 | 984 |
985 | 985 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1118 |
1119 | 1119 |
1120 RawAbstractType* AllocateObjectWithBoundsCheckInstr::CompileType() const { | 1120 RawAbstractType* AllocateObjectWithBoundsCheckInstr::CompileType() const { |
1121 // TODO(regis): Be more specific. | 1121 // TODO(regis): Be more specific. |
1122 return Type::DynamicType(); | 1122 return Type::DynamicType(); |
1123 } | 1123 } |
1124 | 1124 |
1125 | 1125 |
1126 RawAbstractType* LoadFieldInstr::CompileType() const { | 1126 RawAbstractType* LoadFieldInstr::CompileType() const { |
1127 // Type may be null if the field is a VM field, e.g. context parent. | 1127 // Type may be null if the field is a VM field, e.g. context parent. |
1128 // Keep it as null for debug purposes and do not return Dynamic in production | 1128 // Keep it as null for debug purposes and do not return dynamic in production |
1129 // mode, since misuse of the type would remain undetected. | 1129 // mode, since misuse of the type would remain undetected. |
1130 if (type().IsNull()) { | 1130 if (type().IsNull()) { |
1131 return AbstractType::null(); | 1131 return AbstractType::null(); |
1132 } | 1132 } |
1133 if (FLAG_enable_type_checks) { | 1133 if (FLAG_enable_type_checks) { |
1134 return type().raw(); | 1134 return type().raw(); |
1135 } | 1135 } |
1136 return Type::DynamicType(); | 1136 return Type::DynamicType(); |
1137 } | 1137 } |
1138 | 1138 |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 new_max = new_max.Clamp(); | 2086 new_max = new_max.Clamp(); |
2087 } | 2087 } |
2088 | 2088 |
2089 return Range::Update(&range_, new_min, new_max); | 2089 return Range::Update(&range_, new_min, new_max); |
2090 } | 2090 } |
2091 | 2091 |
2092 | 2092 |
2093 #undef __ | 2093 #undef __ |
2094 | 2094 |
2095 } // namespace dart | 2095 } // namespace dart |
OLD | NEW |