| 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 "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 2918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2929 inlining_context_ = context; | 2929 inlining_context_ = context; |
| 2930 if (InInliningContext()) exits_ = new ZoneGrowableArray<ReturnInstr*>(); | 2930 if (InInliningContext()) exits_ = new ZoneGrowableArray<ReturnInstr*>(); |
| 2931 // Compilation can be nested, preserve the computation-id. | 2931 // Compilation can be nested, preserve the computation-id. |
| 2932 const Function& function = parsed_function().function(); | 2932 const Function& function = parsed_function().function(); |
| 2933 TargetEntryInstr* normal_entry = | 2933 TargetEntryInstr* normal_entry = |
| 2934 new TargetEntryInstr(AllocateBlockId(), | 2934 new TargetEntryInstr(AllocateBlockId(), |
| 2935 CatchClauseNode::kInvalidTryIndex, | 2935 CatchClauseNode::kInvalidTryIndex, |
| 2936 initial_loop_depth); | 2936 initial_loop_depth); |
| 2937 graph_entry_ = new GraphEntryInstr(normal_entry); | 2937 graph_entry_ = new GraphEntryInstr(normal_entry); |
| 2938 EffectGraphVisitor for_effect(this, 0, initial_loop_depth); | 2938 EffectGraphVisitor for_effect(this, 0, initial_loop_depth); |
| 2939 if (InInliningContext()) { | |
| 2940 exits_ = new ZoneGrowableArray<ReturnInstr*>(); | |
| 2941 } | |
| 2942 // TODO(kmillikin): We can eliminate stack checks in some cases (e.g., the | 2939 // TODO(kmillikin): We can eliminate stack checks in some cases (e.g., the |
| 2943 // stack check on entry for leaf routines). | 2940 // stack check on entry for leaf routines). |
| 2944 Instruction* check = new CheckStackOverflowInstr(function.token_pos()); | 2941 Instruction* check = new CheckStackOverflowInstr(function.token_pos()); |
| 2945 // If we are inlining don't actually attach the stack check. We must still | 2942 // If we are inlining don't actually attach the stack check. We must still |
| 2946 // create the stack check inorder to allocate a deopt id. | 2943 // create the stack check inorder to allocate a deopt id. |
| 2947 if (!InInliningContext()) for_effect.AddInstruction(check); | 2944 if (!InInliningContext()) for_effect.AddInstruction(check); |
| 2948 parsed_function().node_sequence()->Visit(&for_effect); | 2945 parsed_function().node_sequence()->Visit(&for_effect); |
| 2949 AppendFragment(normal_entry, for_effect); | 2946 AppendFragment(normal_entry, for_effect); |
| 2950 // Check that the graph is properly terminated. | 2947 // Check that the graph is properly terminated. |
| 2951 ASSERT(!for_effect.is_open()); | 2948 ASSERT(!for_effect.is_open()); |
| 2952 FlowGraph* graph = new FlowGraph(*this, graph_entry_, last_used_block_id_); | 2949 FlowGraph* graph = new FlowGraph(*this, graph_entry_, last_used_block_id_); |
| 2953 if (InInliningContext()) graph->set_exits(exits_); | 2950 if (InInliningContext()) graph->set_exits(exits_); |
| 2954 return graph; | 2951 return graph; |
| 2955 } | 2952 } |
| 2956 | 2953 |
| 2957 | 2954 |
| 2958 void FlowGraphBuilder::Bailout(const char* reason) { | 2955 void FlowGraphBuilder::Bailout(const char* reason) { |
| 2959 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; | 2956 const char* kFormat = "FlowGraphBuilder Bailout: %s %s"; |
| 2960 const char* function_name = parsed_function_.function().ToCString(); | 2957 const char* function_name = parsed_function_.function().ToCString(); |
| 2961 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 2958 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 2962 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 2959 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 2963 OS::SNPrint(chars, len, kFormat, function_name, reason); | 2960 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 2964 const Error& error = Error::Handle( | 2961 const Error& error = Error::Handle( |
| 2965 LanguageError::New(String::Handle(String::New(chars)))); | 2962 LanguageError::New(String::Handle(String::New(chars)))); |
| 2966 Isolate::Current()->long_jump_base()->Jump(1, error); | 2963 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 2967 } | 2964 } |
| 2968 | 2965 |
| 2969 | 2966 |
| 2970 } // namespace dart | 2967 } // namespace dart |
| OLD | NEW |