Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/cha.h" | 10 #include "vm/cha.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 assembler_(assembler), | 167 assembler_(assembler), |
| 168 parsed_function_(parsed_function), | 168 parsed_function_(parsed_function), |
| 169 flow_graph_(*flow_graph), | 169 flow_graph_(*flow_graph), |
| 170 block_order_(*flow_graph->CodegenBlockOrder(is_optimizing)), | 170 block_order_(*flow_graph->CodegenBlockOrder(is_optimizing)), |
| 171 current_block_(NULL), | 171 current_block_(NULL), |
| 172 exception_handlers_list_(NULL), | 172 exception_handlers_list_(NULL), |
| 173 pc_descriptors_list_(NULL), | 173 pc_descriptors_list_(NULL), |
| 174 stackmap_table_builder_(NULL), | 174 stackmap_table_builder_(NULL), |
| 175 block_info_(block_order_.length()), | 175 block_info_(block_order_.length()), |
| 176 deopt_infos_(), | 176 deopt_infos_(), |
| 177 static_calls_target_table_(GrowableObjectArray::ZoneHandle( | 177 static_calls_target_table_(), |
| 178 GrowableObjectArray::New())), | |
| 179 is_optimizing_(is_optimizing), | 178 is_optimizing_(is_optimizing), |
| 180 may_reoptimize_(false), | 179 may_reoptimize_(false), |
| 181 intrinsic_mode_(false), | 180 intrinsic_mode_(false), |
| 182 double_class_(Class::ZoneHandle( | 181 double_class_(Class::ZoneHandle( |
| 183 isolate_->object_store()->double_class())), | 182 isolate_->object_store()->double_class())), |
| 184 mint_class_(Class::ZoneHandle( | 183 mint_class_(Class::ZoneHandle( |
| 185 isolate_->object_store()->mint_class())), | 184 isolate_->object_store()->mint_class())), |
| 186 float32x4_class_(Class::ZoneHandle( | 185 float32x4_class_(Class::ZoneHandle( |
| 187 isolate_->object_store()->float32x4_class())), | 186 isolate_->object_store()->float32x4_class())), |
| 188 float64x2_class_(Class::ZoneHandle( | 187 float64x2_class_(Class::ZoneHandle( |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 if (!CanOptimize() && (kind == RawPcDescriptors::kDeopt)) return; | 709 if (!CanOptimize() && (kind == RawPcDescriptors::kDeopt)) return; |
| 711 pc_descriptors_list()->AddDescriptor(kind, | 710 pc_descriptors_list()->AddDescriptor(kind, |
| 712 assembler()->CodeSize(), | 711 assembler()->CodeSize(), |
| 713 deopt_id, | 712 deopt_id, |
| 714 token_pos, | 713 token_pos, |
| 715 CurrentTryIndex()); | 714 CurrentTryIndex()); |
| 716 } | 715 } |
| 717 | 716 |
| 718 | 717 |
| 719 void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { | 718 void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { |
| 720 ASSERT(Code::kSCallTableEntryLength == 3); | 719 ASSERT(func.IsZoneHandle()); |
| 721 ASSERT(Code::kSCallTableOffsetEntry == 0); | |
| 722 static_calls_target_table_.Add( | 720 static_calls_target_table_.Add( |
| 723 Smi::Handle(Smi::New(assembler()->CodeSize()))); | 721 StaticCallsStruct(assembler()->CodeSize(), |
| 724 ASSERT(Code::kSCallTableFunctionEntry == 1); | 722 &func, |
| 725 static_calls_target_table_.Add(func); | 723 &Code::ZoneHandle(zone()))); |
| 726 ASSERT(Code::kSCallTableCodeEntry == 2); | |
| 727 static_calls_target_table_.Add(Code::Handle()); | |
| 728 } | 724 } |
| 729 | 725 |
| 730 | 726 |
| 731 void FlowGraphCompiler::AddStubCallTarget(const Code& code) { | 727 void FlowGraphCompiler::AddStubCallTarget(const Code& code) { |
| 732 ASSERT(Code::kSCallTableEntryLength == 3); | 728 ASSERT(code.IsZoneHandle()); |
| 733 ASSERT(Code::kSCallTableOffsetEntry == 0); | |
| 734 static_calls_target_table_.Add( | 729 static_calls_target_table_.Add( |
| 735 Smi::Handle(Smi::New(assembler()->CodeSize()))); | 730 StaticCallsStruct(assembler()->CodeSize(), |
| 736 ASSERT(Code::kSCallTableFunctionEntry == 1); | 731 &Function::ZoneHandle(zone()), |
|
koda
2015/08/20 14:14:14
As I understand it, exactly one of the 'code' and
srdjan
2015/08/20 16:25:39
Using (C++) NULL instead of creating Null handles.
| |
| 737 static_calls_target_table_.Add(Function::Handle()); | 732 &code)); |
| 738 ASSERT(Code::kSCallTableCodeEntry == 2); | |
| 739 static_calls_target_table_.Add(code); | |
| 740 } | 733 } |
| 741 | 734 |
| 742 | 735 |
| 743 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, | 736 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, |
| 744 intptr_t token_pos) { | 737 intptr_t token_pos) { |
| 745 ASSERT(is_optimizing()); | 738 ASSERT(is_optimizing()); |
| 746 ASSERT(!intrinsic_mode()); | 739 ASSERT(!intrinsic_mode()); |
| 747 CompilerDeoptInfo* info = | 740 CompilerDeoptInfo* info = |
| 748 new CompilerDeoptInfo(deopt_id, | 741 new CompilerDeoptInfo(deopt_id, |
| 749 ICData::kDeoptAtCall, | 742 ICData::kDeoptAtCall, |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 993 info.end_pos = 0; | 986 info.end_pos = 0; |
| 994 info.set_index(parsed_function().current_context_var()->index()); | 987 info.set_index(parsed_function().current_context_var()->index()); |
| 995 var_descs.SetVar(0, Symbols::CurrentContextVar(), &info); | 988 var_descs.SetVar(0, Symbols::CurrentContextVar(), &info); |
| 996 } | 989 } |
| 997 code.set_var_descriptors(var_descs); | 990 code.set_var_descriptors(var_descs); |
| 998 } | 991 } |
| 999 | 992 |
| 1000 | 993 |
| 1001 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { | 994 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { |
| 1002 ASSERT(code.static_calls_target_table() == Array::null()); | 995 ASSERT(code.static_calls_target_table() == Array::null()); |
| 1003 const Array& targets = | 996 const Array& targets = Array::Handle(zone(), Array::New( |
| 1004 Array::Handle(Array::MakeArray(static_calls_target_table_)); | 997 static_calls_target_table_.length() * Code::kSCallTableEntryLength)); |
| 998 Smi& smi_offset = Smi::Handle(zone()); | |
| 999 for (intptr_t i = 0; i < static_calls_target_table_.length(); i++) { | |
| 1000 const intptr_t target_ix = Code::kSCallTableEntryLength * i; | |
| 1001 smi_offset = Smi::New(static_calls_target_table_[i].offset); | |
| 1002 targets.SetAt(target_ix + Code::kSCallTableOffsetEntry, smi_offset); | |
| 1003 targets.SetAt(target_ix + Code::kSCallTableFunctionEntry, | |
| 1004 *static_calls_target_table_[i].function); | |
| 1005 targets.SetAt(target_ix + Code::kSCallTableCodeEntry, | |
| 1006 *static_calls_target_table_[i].code); | |
| 1007 } | |
| 1005 code.set_static_calls_target_table(targets); | 1008 code.set_static_calls_target_table(targets); |
| 1006 INC_STAT(isolate(), total_code_size, targets.Length() * sizeof(uword)); | 1009 INC_STAT(isolate(), total_code_size, targets.Length() * sizeof(uword)); |
| 1007 } | 1010 } |
| 1008 | 1011 |
| 1009 | 1012 |
| 1010 // Returns 'true' if code generation for this function is complete, i.e., | 1013 // Returns 'true' if code generation for this function is complete, i.e., |
| 1011 // no fall-through to regular code is needed. | 1014 // no fall-through to regular code is needed. |
| 1012 void FlowGraphCompiler::TryIntrinsify() { | 1015 void FlowGraphCompiler::TryIntrinsify() { |
| 1013 // Intrinsification skips arguments checks, therefore disable if in checked | 1016 // Intrinsification skips arguments checks, therefore disable if in checked |
| 1014 // mode. | 1017 // mode. |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1818 | 1821 |
| 1819 | 1822 |
| 1820 void FlowGraphCompiler::FrameStateClear() { | 1823 void FlowGraphCompiler::FrameStateClear() { |
| 1821 ASSERT(!is_optimizing()); | 1824 ASSERT(!is_optimizing()); |
| 1822 frame_state_.TruncateTo(0); | 1825 frame_state_.TruncateTo(0); |
| 1823 } | 1826 } |
| 1824 #endif | 1827 #endif |
| 1825 | 1828 |
| 1826 | 1829 |
| 1827 } // namespace dart | 1830 } // namespace dart |
| OLD | NEW |