| 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/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 Do(store); | 848 Do(store); |
| 849 return ExitTempLocalScope(tmp_var); | 849 return ExitTempLocalScope(tmp_var); |
| 850 } else { | 850 } else { |
| 851 return new(Z) StoreLocalInstr(local, value); | 851 return new(Z) StoreLocalInstr(local, value); |
| 852 } | 852 } |
| 853 } | 853 } |
| 854 | 854 |
| 855 | 855 |
| 856 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { | 856 Definition* EffectGraphVisitor::BuildLoadLocal(const LocalVariable& local) { |
| 857 if (local.IsConst()) { | 857 if (local.IsConst()) { |
| 858 return new(Z) ConstantInstr(*local.ConstValue()); | 858 return new(Z) ConstantInstr(*local.ConstValue(), local.token_pos()); |
| 859 } else if (local.is_captured()) { | 859 } else if (local.is_captured()) { |
| 860 intptr_t delta = | 860 intptr_t delta = |
| 861 owner()->context_level() - local.owner()->context_level(); | 861 owner()->context_level() - local.owner()->context_level(); |
| 862 ASSERT(delta >= 0); | 862 ASSERT(delta >= 0); |
| 863 Value* context = Bind(BuildCurrentContext()); | 863 Value* context = Bind(BuildCurrentContext()); |
| 864 while (delta-- > 0) { | 864 while (delta-- > 0) { |
| 865 context = Bind(new(Z) LoadFieldInstr( | 865 context = Bind(new(Z) LoadFieldInstr( |
| 866 context, Context::parent_offset(), Type::ZoneHandle(Z, Type::null()), | 866 context, Context::parent_offset(), Type::ZoneHandle(Z, Type::null()), |
| 867 Scanner::kNoSourcePos)); | 867 Scanner::kNoSourcePos)); |
| 868 } | 868 } |
| 869 return new(Z) LoadFieldInstr(context, | 869 return new(Z) LoadFieldInstr(context, |
| 870 Context::variable_offset(local.index()), | 870 Context::variable_offset(local.index()), |
| 871 local.type(), | 871 local.type(), |
| 872 Scanner::kNoSourcePos); | 872 Scanner::kNoSourcePos); |
| 873 } else { | 873 } else { |
| 874 return new(Z) LoadLocalInstr(local); | 874 return new(Z) LoadLocalInstr(local); |
| 875 } | 875 } |
| 876 } | 876 } |
| 877 | 877 |
| 878 | 878 |
| 879 // Stores current context into the 'variable' | 879 // Stores current context into the 'variable' |
| 880 void EffectGraphVisitor::BuildSaveContext(const LocalVariable& variable) { | 880 void EffectGraphVisitor::BuildSaveContext(const LocalVariable& variable) { |
| 881 Value* context = Bind(BuildCurrentContext()); | 881 Value* context = Bind(BuildCurrentContext()); |
| 882 Do(BuildStoreLocal(variable, context)); | 882 Do(BuildStoreLocal(variable, context)); |
| (...skipping 3167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4050 } | 4050 } |
| 4051 | 4051 |
| 4052 // This check may be deleted if the generated code is leaf. | 4052 // This check may be deleted if the generated code is leaf. |
| 4053 // Native functions don't need a stack check at entry. | 4053 // Native functions don't need a stack check at entry. |
| 4054 if (is_top_level_sequence && !function.is_native()) { | 4054 if (is_top_level_sequence && !function.is_native()) { |
| 4055 // Always allocate CheckOverflowInstr so that deopt-ids match regardless | 4055 // Always allocate CheckOverflowInstr so that deopt-ids match regardless |
| 4056 // if we inline or not. | 4056 // if we inline or not. |
| 4057 if (!function.IsImplicitGetterFunction() && | 4057 if (!function.IsImplicitGetterFunction() && |
| 4058 !function.IsImplicitSetterFunction()) { | 4058 !function.IsImplicitSetterFunction()) { |
| 4059 CheckStackOverflowInstr* check = | 4059 CheckStackOverflowInstr* check = |
| 4060 new(Z) CheckStackOverflowInstr(function.token_pos(), 0); | 4060 new(Z) CheckStackOverflowInstr(node->token_pos(), 0); |
| 4061 // If we are inlining don't actually attach the stack check. We must still | 4061 // If we are inlining don't actually attach the stack check. We must still |
| 4062 // create the stack check in order to allocate a deopt id. | 4062 // create the stack check in order to allocate a deopt id. |
| 4063 if (!owner()->IsInlining()) { | 4063 if (!owner()->IsInlining()) { |
| 4064 AddInstruction(check); | 4064 AddInstruction(check); |
| 4065 } | 4065 } |
| 4066 } | 4066 } |
| 4067 } | 4067 } |
| 4068 | 4068 |
| 4069 if (Isolate::Current()->flags().type_checks() && is_top_level_sequence) { | 4069 if (Isolate::Current()->flags().type_checks() && is_top_level_sequence) { |
| 4070 const int num_params = function.NumParameters(); | 4070 const int num_params = function.NumParameters(); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4582 Report::MessageF(Report::kBailout, | 4582 Report::MessageF(Report::kBailout, |
| 4583 Script::Handle(function.script()), | 4583 Script::Handle(function.script()), |
| 4584 function.token_pos(), | 4584 function.token_pos(), |
| 4585 "FlowGraphBuilder Bailout: %s %s", | 4585 "FlowGraphBuilder Bailout: %s %s", |
| 4586 String::Handle(function.name()).ToCString(), | 4586 String::Handle(function.name()).ToCString(), |
| 4587 reason); | 4587 reason); |
| 4588 UNREACHABLE(); | 4588 UNREACHABLE(); |
| 4589 } | 4589 } |
| 4590 | 4590 |
| 4591 } // namespace dart | 4591 } // namespace dart |
| OLD | NEW |