| 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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
| 8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
| (...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 const AbstractType& type = node->right()->AsTypeNode()->type(); | 1206 const AbstractType& type = node->right()->AsTypeNode()->type(); |
| 1207 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); | 1207 ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded()); |
| 1208 const bool negate_result = (node->kind() == Token::kISNOT); | 1208 const bool negate_result = (node->kind() == Token::kISNOT); |
| 1209 // All objects are instances of type T if Object type is a subtype of type T. | 1209 // All objects are instances of type T if Object type is a subtype of type T. |
| 1210 const Type& object_type = Type::Handle(Type::ObjectType()); | 1210 const Type& object_type = Type::Handle(Type::ObjectType()); |
| 1211 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { | 1211 if (type.IsInstantiated() && object_type.IsSubtypeOf(type, NULL)) { |
| 1212 // Must evaluate left side. | 1212 // Must evaluate left side. |
| 1213 EffectGraphVisitor for_left_value(owner(), temp_index()); | 1213 EffectGraphVisitor for_left_value(owner(), temp_index()); |
| 1214 node->left()->Visit(&for_left_value); | 1214 node->left()->Visit(&for_left_value); |
| 1215 Append(for_left_value); | 1215 Append(for_left_value); |
| 1216 ReturnDefinition(new ConstantInstr(negate_result ? | 1216 ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result))); |
| 1217 Bool::False() : Bool::True())); | |
| 1218 return; | 1217 return; |
| 1219 } | 1218 } |
| 1220 | 1219 |
| 1221 // Eliminate the test if it can be performed successfully at compile time. | 1220 // Eliminate the test if it can be performed successfully at compile time. |
| 1222 if ((node->left() != NULL) && | 1221 if ((node->left() != NULL) && |
| 1223 node->left()->IsLiteralNode() && | 1222 node->left()->IsLiteralNode() && |
| 1224 type.IsInstantiated()) { | 1223 type.IsInstantiated()) { |
| 1225 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); | 1224 const Instance& literal_value = node->left()->AsLiteralNode()->literal(); |
| 1226 ConstantInstr* result = NULL; | 1225 ConstantInstr* result = NULL; |
| 1227 | 1226 |
| 1228 Error& malformed_error = Error::Handle(); | 1227 Error& malformed_error = Error::Handle(); |
| 1229 if (literal_value.IsInstanceOf(type, | 1228 if (literal_value.IsInstanceOf(type, |
| 1230 TypeArguments::Handle(), | 1229 TypeArguments::Handle(), |
| 1231 &malformed_error)) { | 1230 &malformed_error)) { |
| 1232 result = new ConstantInstr(negate_result ? | 1231 result = new ConstantInstr(Bool::Get(!negate_result)); |
| 1233 Bool::False() : Bool::True()); | |
| 1234 } else { | 1232 } else { |
| 1235 result = new ConstantInstr(negate_result ? | 1233 result = new ConstantInstr(Bool::Get(negate_result)); |
| 1236 Bool::True() : Bool::False()); | |
| 1237 } | 1234 } |
| 1238 ASSERT(malformed_error.IsNull()); | 1235 ASSERT(malformed_error.IsNull()); |
| 1239 | 1236 |
| 1240 ReturnDefinition(result); | 1237 ReturnDefinition(result); |
| 1241 return; | 1238 return; |
| 1242 } | 1239 } |
| 1243 | 1240 |
| 1244 ValueGraphVisitor for_left_value(owner(), temp_index()); | 1241 ValueGraphVisitor for_left_value(owner(), temp_index()); |
| 1245 node->left()->Visit(&for_left_value); | 1242 node->left()->Visit(&for_left_value); |
| 1246 Append(for_left_value); | 1243 Append(for_left_value); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1257 } | 1254 } |
| 1258 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1255 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1259 new ZoneGrowableArray<PushArgumentInstr*>(5); | 1256 new ZoneGrowableArray<PushArgumentInstr*>(5); |
| 1260 arguments->Add(push_left); | 1257 arguments->Add(push_left); |
| 1261 arguments->Add(push_instantiator); | 1258 arguments->Add(push_instantiator); |
| 1262 arguments->Add(push_type_args); | 1259 arguments->Add(push_type_args); |
| 1263 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1260 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1264 Value* type_arg = Bind( | 1261 Value* type_arg = Bind( |
| 1265 new ConstantInstr(node->right()->AsTypeNode()->type())); | 1262 new ConstantInstr(node->right()->AsTypeNode()->type())); |
| 1266 arguments->Add(PushArgument(type_arg)); | 1263 arguments->Add(PushArgument(type_arg)); |
| 1267 const Bool& negate = (node->kind() == Token::kISNOT) ? Bool::True() : | 1264 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); |
| 1268 Bool::False(); | |
| 1269 Value* negate_arg = Bind(new ConstantInstr(negate)); | 1265 Value* negate_arg = Bind(new ConstantInstr(negate)); |
| 1270 arguments->Add(PushArgument(negate_arg)); | 1266 arguments->Add(PushArgument(negate_arg)); |
| 1271 const intptr_t kNumArgsChecked = 1; | 1267 const intptr_t kNumArgsChecked = 1; |
| 1272 InstanceCallInstr* call = new InstanceCallInstr( | 1268 InstanceCallInstr* call = new InstanceCallInstr( |
| 1273 node->token_pos(), | 1269 node->token_pos(), |
| 1274 PrivateCoreLibName(Symbols::_instanceOf()), | 1270 PrivateCoreLibName(Symbols::_instanceOf()), |
| 1275 node->kind(), | 1271 node->kind(), |
| 1276 arguments, | 1272 arguments, |
| 1277 Object::null_array(), // No argument names. | 1273 Object::null_array(), // No argument names. |
| 1278 kNumArgsChecked, | 1274 kNumArgsChecked, |
| (...skipping 2465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3744 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3740 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3745 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3741 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3746 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3742 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3747 const Error& error = Error::Handle( | 3743 const Error& error = Error::Handle( |
| 3748 LanguageError::New(String::Handle(String::New(chars)))); | 3744 LanguageError::New(String::Handle(String::New(chars)))); |
| 3749 Isolate::Current()->long_jump_base()->Jump(1, error); | 3745 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3750 } | 3746 } |
| 3751 | 3747 |
| 3752 | 3748 |
| 3753 } // namespace dart | 3749 } // namespace dart |
| OLD | NEW |