| 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| 11 #include "vm/deopt_instructions.h" | 11 #include "vm/deopt_instructions.h" |
| 12 #include "vm/flow_graph_allocator.h" | 12 #include "vm/flow_graph_allocator.h" |
| 13 #include "vm/il_printer.h" | 13 #include "vm/il_printer.h" |
| 14 #include "vm/intrinsifier.h" | 14 #include "vm/intrinsifier.h" |
| 15 #include "vm/locations.h" | 15 #include "vm/locations.h" |
| 16 #include "vm/longjump.h" | 16 #include "vm/longjump.h" |
| 17 #include "vm/object_store.h" | 17 #include "vm/object_store.h" |
| 18 #include "vm/parser.h" | 18 #include "vm/parser.h" |
| 19 #include "vm/stub_code.h" | 19 #include "vm/stub_code.h" |
| 20 #include "vm/symbols.h" | 20 #include "vm/symbols.h" |
| 21 | 21 |
| 22 namespace dart { | 22 namespace dart { |
| 23 | 23 |
| 24 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 24 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 25 DEFINE_FLAG(bool, trace_functions, false, "Trace entry of each function."); | |
| 26 DECLARE_FLAG(bool, code_comments); | 25 DECLARE_FLAG(bool, code_comments); |
| 27 DECLARE_FLAG(bool, enable_type_checks); | 26 DECLARE_FLAG(bool, enable_type_checks); |
| 28 DECLARE_FLAG(bool, intrinsify); | 27 DECLARE_FLAG(bool, intrinsify); |
| 29 DECLARE_FLAG(bool, propagate_ic_data); | 28 DECLARE_FLAG(bool, propagate_ic_data); |
| 30 DECLARE_FLAG(bool, report_usage_count); | 29 DECLARE_FLAG(bool, report_usage_count); |
| 31 DECLARE_FLAG(bool, trace_functions); | |
| 32 DECLARE_FLAG(int, optimization_counter_threshold); | 30 DECLARE_FLAG(int, optimization_counter_threshold); |
| 33 | 31 |
| 34 void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder, | 32 void CompilerDeoptInfo::BuildReturnAddress(DeoptInfoBuilder* builder, |
| 35 const Function& function, | 33 const Function& function, |
| 36 intptr_t slot_ix) { | 34 intptr_t slot_ix) { |
| 37 builder->AddReturnAddressAfter(function, deopt_id(), slot_ix); | 35 builder->AddReturnAddressAfter(function, deopt_id(), slot_ix); |
| 38 } | 36 } |
| 39 | 37 |
| 40 | 38 |
| 41 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, | 39 void CompilerDeoptInfoWithStub::BuildReturnAddress(DeoptInfoBuilder* builder, |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 code.set_comments(assembler()->GetCodeComments()); | 424 code.set_comments(assembler()->GetCodeComments()); |
| 427 } | 425 } |
| 428 | 426 |
| 429 | 427 |
| 430 // Returns 'true' if code generation for this function is complete, i.e., | 428 // Returns 'true' if code generation for this function is complete, i.e., |
| 431 // no fall-through to regular code is needed. | 429 // no fall-through to regular code is needed. |
| 432 bool FlowGraphCompiler::TryIntrinsify() { | 430 bool FlowGraphCompiler::TryIntrinsify() { |
| 433 if (!CanOptimize()) return false; | 431 if (!CanOptimize()) return false; |
| 434 // Intrinsification skips arguments checks, therefore disable if in checked | 432 // Intrinsification skips arguments checks, therefore disable if in checked |
| 435 // mode. | 433 // mode. |
| 436 if (FLAG_intrinsify && !FLAG_trace_functions && !FLAG_enable_type_checks) { | 434 if (FLAG_intrinsify && !FLAG_enable_type_checks) { |
| 437 if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) { | 435 if ((parsed_function().function().kind() == RawFunction::kImplicitGetter)) { |
| 438 // An implicit getter must have a specific AST structure. | 436 // An implicit getter must have a specific AST structure. |
| 439 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 437 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| 440 ASSERT(sequence_node.length() == 1); | 438 ASSERT(sequence_node.length() == 1); |
| 441 ASSERT(sequence_node.NodeAt(0)->IsReturnNode()); | 439 ASSERT(sequence_node.NodeAt(0)->IsReturnNode()); |
| 442 const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode(); | 440 const ReturnNode& return_node = *sequence_node.NodeAt(0)->AsReturnNode(); |
| 443 ASSERT(return_node.value()->IsLoadInstanceFieldNode()); | 441 ASSERT(return_node.value()->IsLoadInstanceFieldNode()); |
| 444 const LoadInstanceFieldNode& load_node = | 442 const LoadInstanceFieldNode& load_node = |
| 445 *return_node.value()->AsLoadInstanceFieldNode(); | 443 *return_node.value()->AsLoadInstanceFieldNode(); |
| 446 GenerateInlinedGetter(load_node.field().Offset()); | 444 GenerateInlinedGetter(load_node.field().Offset()); |
| 447 return true; | 445 return true; |
| 448 } | 446 } |
| 449 if ((parsed_function().function().kind() == RawFunction::kImplicitSetter)) { | 447 if ((parsed_function().function().kind() == RawFunction::kImplicitSetter)) { |
| 450 // An implicit setter must have a specific AST structure. | 448 // An implicit setter must have a specific AST structure. |
| 451 // Sequence node has one store node and one return NULL node. | 449 // Sequence node has one store node and one return NULL node. |
| 452 const SequenceNode& sequence_node = *parsed_function().node_sequence(); | 450 const SequenceNode& sequence_node = *parsed_function().node_sequence(); |
| 453 ASSERT(sequence_node.length() == 2); | 451 ASSERT(sequence_node.length() == 2); |
| 454 ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode()); | 452 ASSERT(sequence_node.NodeAt(0)->IsStoreInstanceFieldNode()); |
| 455 ASSERT(sequence_node.NodeAt(1)->IsReturnNode()); | 453 ASSERT(sequence_node.NodeAt(1)->IsReturnNode()); |
| 456 const StoreInstanceFieldNode& store_node = | 454 const StoreInstanceFieldNode& store_node = |
| 457 *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode(); | 455 *sequence_node.NodeAt(0)->AsStoreInstanceFieldNode(); |
| 458 GenerateInlinedSetter(store_node.field().Offset()); | 456 GenerateInlinedSetter(store_node.field().Offset()); |
| 459 return true; | 457 return true; |
| 460 } | 458 } |
| 461 } | 459 } |
| 462 // Even if an intrinsified version of the function was successfully | 460 // Even if an intrinsified version of the function was successfully |
| 463 // generated, it may fall through to the non-intrinsified method body. | 461 // generated, it may fall through to the non-intrinsified method body. |
| 464 if (!FLAG_trace_functions) { | 462 return Intrinsifier::Intrinsify(parsed_function().function(), assembler()); |
| 465 return Intrinsifier::Intrinsify(parsed_function().function(), assembler()); | |
| 466 } | |
| 467 return false; | |
| 468 } | 463 } |
| 469 | 464 |
| 470 | 465 |
| 471 void FlowGraphCompiler::GenerateInstanceCall( | 466 void FlowGraphCompiler::GenerateInstanceCall( |
| 472 intptr_t deopt_id, | 467 intptr_t deopt_id, |
| 473 intptr_t token_pos, | 468 intptr_t token_pos, |
| 474 intptr_t argument_count, | 469 intptr_t argument_count, |
| 475 const Array& argument_names, | 470 const Array& argument_names, |
| 476 LocationSummary* locs, | 471 LocationSummary* locs, |
| 477 const ICData& ic_data) { | 472 const ICData& ic_data) { |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 ASSERT(Utils::IsInt(31, disp)); | 917 ASSERT(Utils::IsInt(31, disp)); |
| 923 return FieldAddress(array, disp); | 918 return FieldAddress(array, disp); |
| 924 } | 919 } |
| 925 default: | 920 default: |
| 926 UNIMPLEMENTED(); | 921 UNIMPLEMENTED(); |
| 927 return FieldAddress(SPREG, 0); | 922 return FieldAddress(SPREG, 0); |
| 928 } | 923 } |
| 929 } | 924 } |
| 930 | 925 |
| 931 } // namespace dart | 926 } // namespace dart |
| OLD | NEW |