| 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 17 matching lines...) Expand all Loading... |
| 28 "Eliminate type checks when allowed by static type analysis."); | 28 "Eliminate type checks when allowed by static type analysis."); |
| 29 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 29 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 30 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); | 30 DEFINE_FLAG(bool, print_flow_graph, false, "Print the IR flow graph."); |
| 31 DEFINE_FLAG(bool, print_flow_graph_optimized, false, | 31 DEFINE_FLAG(bool, print_flow_graph_optimized, false, |
| 32 "Print the IR flow graph when optimizing."); | 32 "Print the IR flow graph when optimizing."); |
| 33 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 33 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 34 "Trace type check elimination at compile time."); | 34 "Trace type check elimination at compile time."); |
| 35 DECLARE_FLAG(bool, enable_type_checks); | 35 DECLARE_FLAG(bool, enable_type_checks); |
| 36 | 36 |
| 37 | 37 |
| 38 static const String& PrivateCoreLibName(const String& str) { | |
| 39 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | |
| 40 const String& private_name = String::ZoneHandle(core_lib.PrivateName(str)); | |
| 41 return private_name; | |
| 42 } | |
| 43 | |
| 44 | |
| 45 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, | 38 FlowGraphBuilder::FlowGraphBuilder(ParsedFunction* parsed_function, |
| 46 const Array& ic_data_array, | 39 const Array& ic_data_array, |
| 47 InlineExitCollector* exit_collector, | 40 InlineExitCollector* exit_collector, |
| 48 intptr_t osr_id) | 41 intptr_t osr_id) |
| 49 : parsed_function_(parsed_function), | 42 : parsed_function_(parsed_function), |
| 50 ic_data_array_(ic_data_array), | 43 ic_data_array_(ic_data_array), |
| 51 num_copied_params_(parsed_function->num_copied_params()), | 44 num_copied_params_(parsed_function->num_copied_params()), |
| 52 // All parameters are copied if any parameter is. | 45 // All parameters are copied if any parameter is. |
| 53 num_non_copied_params_((num_copied_params_ == 0) | 46 num_non_copied_params_((num_copied_params_ == 0) |
| 54 ? parsed_function->function().num_fixed_parameters() | 47 ? parsed_function->function().num_fixed_parameters() |
| (...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 } | 1059 } |
| 1067 ReturnDefinition(BuildLoadExprTemp()); | 1060 ReturnDefinition(BuildLoadExprTemp()); |
| 1068 return; | 1061 return; |
| 1069 } | 1062 } |
| 1070 EffectGraphVisitor::VisitBinaryOpNode(node); | 1063 EffectGraphVisitor::VisitBinaryOpNode(node); |
| 1071 } | 1064 } |
| 1072 | 1065 |
| 1073 | 1066 |
| 1074 static const String& BinaryOpAndMaskName(BinaryOpNode* node) { | 1067 static const String& BinaryOpAndMaskName(BinaryOpNode* node) { |
| 1075 if (node->kind() == Token::kSHL) { | 1068 if (node->kind() == Token::kSHL) { |
| 1076 return PrivateCoreLibName(Symbols::_leftShiftWithMask32()); | 1069 return Library::PrivateCoreLibName(Symbols::_leftShiftWithMask32()); |
| 1077 } | 1070 } |
| 1078 UNIMPLEMENTED(); | 1071 UNIMPLEMENTED(); |
| 1079 return String::ZoneHandle(); | 1072 return String::ZoneHandle(); |
| 1080 } | 1073 } |
| 1081 | 1074 |
| 1082 | 1075 |
| 1083 // <Expression> :: BinaryOp { kind: Token::Kind | 1076 // <Expression> :: BinaryOp { kind: Token::Kind |
| 1084 // left: <Expression> | 1077 // left: <Expression> |
| 1085 // right: <Expression> | 1078 // right: <Expression> |
| 1086 // mask32: constant } | 1079 // mask32: constant } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); | 1278 ASSERT(!node->right()->AsTypeNode()->type().IsNull()); |
| 1286 Value* type_arg = Bind( | 1279 Value* type_arg = Bind( |
| 1287 new ConstantInstr(node->right()->AsTypeNode()->type())); | 1280 new ConstantInstr(node->right()->AsTypeNode()->type())); |
| 1288 arguments->Add(PushArgument(type_arg)); | 1281 arguments->Add(PushArgument(type_arg)); |
| 1289 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); | 1282 const Bool& negate = Bool::Get(node->kind() == Token::kISNOT); |
| 1290 Value* negate_arg = Bind(new ConstantInstr(negate)); | 1283 Value* negate_arg = Bind(new ConstantInstr(negate)); |
| 1291 arguments->Add(PushArgument(negate_arg)); | 1284 arguments->Add(PushArgument(negate_arg)); |
| 1292 const intptr_t kNumArgsChecked = 1; | 1285 const intptr_t kNumArgsChecked = 1; |
| 1293 InstanceCallInstr* call = new InstanceCallInstr( | 1286 InstanceCallInstr* call = new InstanceCallInstr( |
| 1294 node->token_pos(), | 1287 node->token_pos(), |
| 1295 PrivateCoreLibName(Symbols::_instanceOf()), | 1288 Library::PrivateCoreLibName(Symbols::_instanceOf()), |
| 1296 node->kind(), | 1289 node->kind(), |
| 1297 arguments, | 1290 arguments, |
| 1298 Object::null_array(), // No argument names. | 1291 Object::null_array(), // No argument names. |
| 1299 kNumArgsChecked, | 1292 kNumArgsChecked, |
| 1300 owner()->ic_data_array()); | 1293 owner()->ic_data_array()); |
| 1301 ReturnDefinition(call); | 1294 ReturnDefinition(call); |
| 1302 } | 1295 } |
| 1303 | 1296 |
| 1304 | 1297 |
| 1305 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { | 1298 void EffectGraphVisitor::BuildTypeCast(ComparisonNode* node) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 ZoneGrowableArray<PushArgumentInstr*>* arguments = | 1348 ZoneGrowableArray<PushArgumentInstr*>* arguments = |
| 1356 new ZoneGrowableArray<PushArgumentInstr*>(4); | 1349 new ZoneGrowableArray<PushArgumentInstr*>(4); |
| 1357 arguments->Add(push_left); | 1350 arguments->Add(push_left); |
| 1358 arguments->Add(push_instantiator); | 1351 arguments->Add(push_instantiator); |
| 1359 arguments->Add(push_type_args); | 1352 arguments->Add(push_type_args); |
| 1360 Value* type_arg = Bind(new ConstantInstr(type)); | 1353 Value* type_arg = Bind(new ConstantInstr(type)); |
| 1361 arguments->Add(PushArgument(type_arg)); | 1354 arguments->Add(PushArgument(type_arg)); |
| 1362 const intptr_t kNumArgsChecked = 1; | 1355 const intptr_t kNumArgsChecked = 1; |
| 1363 InstanceCallInstr* call = new InstanceCallInstr( | 1356 InstanceCallInstr* call = new InstanceCallInstr( |
| 1364 node->token_pos(), | 1357 node->token_pos(), |
| 1365 PrivateCoreLibName(Symbols::_as()), | 1358 Library::PrivateCoreLibName(Symbols::_as()), |
| 1366 node->kind(), | 1359 node->kind(), |
| 1367 arguments, | 1360 arguments, |
| 1368 Object::null_array(), // No argument names. | 1361 Object::null_array(), // No argument names. |
| 1369 kNumArgsChecked, | 1362 kNumArgsChecked, |
| 1370 owner()->ic_data_array()); | 1363 owner()->ic_data_array()); |
| 1371 ReturnDefinition(call); | 1364 ReturnDefinition(call); |
| 1372 } | 1365 } |
| 1373 } | 1366 } |
| 1374 | 1367 |
| 1375 | 1368 |
| (...skipping 2327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3703 Value* existing_argument_names_value = | 3696 Value* existing_argument_names_value = |
| 3704 Bind(new ConstantInstr(Array::ZoneHandle())); | 3697 Bind(new ConstantInstr(Array::ZoneHandle())); |
| 3705 arguments->Add(PushArgument(existing_argument_names_value)); | 3698 arguments->Add(PushArgument(existing_argument_names_value)); |
| 3706 // Resolve and call NoSuchMethodError._throwNew. | 3699 // Resolve and call NoSuchMethodError._throwNew. |
| 3707 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 3700 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 3708 const Class& cls = Class::Handle( | 3701 const Class& cls = Class::Handle( |
| 3709 core_lib.LookupClass(Symbols::NoSuchMethodError())); | 3702 core_lib.LookupClass(Symbols::NoSuchMethodError())); |
| 3710 ASSERT(!cls.IsNull()); | 3703 ASSERT(!cls.IsNull()); |
| 3711 const Function& func = Function::ZoneHandle( | 3704 const Function& func = Function::ZoneHandle( |
| 3712 Resolver::ResolveStatic(cls, | 3705 Resolver::ResolveStatic(cls, |
| 3713 PrivateCoreLibName(Symbols::ThrowNew()), | 3706 Library::PrivateCoreLibName(Symbols::ThrowNew()), |
| 3714 arguments->length(), | 3707 arguments->length(), |
| 3715 Object::null_array(), | 3708 Object::null_array(), |
| 3716 Resolver::kIsQualified)); | 3709 Resolver::kIsQualified)); |
| 3717 ASSERT(!func.IsNull()); | 3710 ASSERT(!func.IsNull()); |
| 3718 return new StaticCallInstr(token_pos, | 3711 return new StaticCallInstr(token_pos, |
| 3719 func, | 3712 func, |
| 3720 Object::null_array(), // No names. | 3713 Object::null_array(), // No names. |
| 3721 arguments, | 3714 arguments, |
| 3722 owner()->ic_data_array()); | 3715 owner()->ic_data_array()); |
| 3723 } | 3716 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3846 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3839 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3847 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3840 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3848 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3841 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3849 const Error& error = Error::Handle( | 3842 const Error& error = Error::Handle( |
| 3850 LanguageError::New(String::Handle(String::New(chars)))); | 3843 LanguageError::New(String::Handle(String::New(chars)))); |
| 3851 Isolate::Current()->long_jump_base()->Jump(1, error); | 3844 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3852 } | 3845 } |
| 3853 | 3846 |
| 3854 | 3847 |
| 3855 } // namespace dart | 3848 } // namespace dart |
| OLD | NEW |