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 // TODO(srdjan): Zone-allocate this array instead? | |
179 GrowableObjectArray::New(Heap::kOld))), | |
180 is_optimizing_(is_optimizing), | 178 is_optimizing_(is_optimizing), |
181 may_reoptimize_(false), | 179 may_reoptimize_(false), |
182 intrinsic_mode_(false), | 180 intrinsic_mode_(false), |
183 double_class_(Class::ZoneHandle( | 181 double_class_(Class::ZoneHandle( |
184 isolate_->object_store()->double_class())), | 182 isolate_->object_store()->double_class())), |
185 mint_class_(Class::ZoneHandle( | 183 mint_class_(Class::ZoneHandle( |
186 isolate_->object_store()->mint_class())), | 184 isolate_->object_store()->mint_class())), |
187 float32x4_class_(Class::ZoneHandle( | 185 float32x4_class_(Class::ZoneHandle( |
188 isolate_->object_store()->float32x4_class())), | 186 isolate_->object_store()->float32x4_class())), |
189 float64x2_class_(Class::ZoneHandle( | 187 float64x2_class_(Class::ZoneHandle( |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 if (!CanOptimize() && (kind == RawPcDescriptors::kDeopt)) return; | 709 if (!CanOptimize() && (kind == RawPcDescriptors::kDeopt)) return; |
712 pc_descriptors_list()->AddDescriptor(kind, | 710 pc_descriptors_list()->AddDescriptor(kind, |
713 assembler()->CodeSize(), | 711 assembler()->CodeSize(), |
714 deopt_id, | 712 deopt_id, |
715 token_pos, | 713 token_pos, |
716 CurrentTryIndex()); | 714 CurrentTryIndex()); |
717 } | 715 } |
718 | 716 |
719 | 717 |
720 void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { | 718 void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { |
721 ASSERT(Code::kSCallTableEntryLength == 3); | 719 ASSERT(func.IsZoneHandle()); |
722 ASSERT(Code::kSCallTableOffsetEntry == 0); | |
723 static_calls_target_table_.Add( | 720 static_calls_target_table_.Add( |
724 Smi::Handle(Smi::New(assembler()->CodeSize()))); | 721 StaticCallsStruct(assembler()->CodeSize(), &func, NULL)); |
725 ASSERT(Code::kSCallTableFunctionEntry == 1); | |
726 static_calls_target_table_.Add(func); | |
727 ASSERT(Code::kSCallTableCodeEntry == 2); | |
728 static_calls_target_table_.Add(Code::Handle()); | |
729 } | 722 } |
730 | 723 |
731 | 724 |
732 void FlowGraphCompiler::AddStubCallTarget(const Code& code) { | 725 void FlowGraphCompiler::AddStubCallTarget(const Code& code) { |
733 ASSERT(Code::kSCallTableEntryLength == 3); | 726 ASSERT(code.IsZoneHandle()); |
734 ASSERT(Code::kSCallTableOffsetEntry == 0); | |
735 static_calls_target_table_.Add( | 727 static_calls_target_table_.Add( |
736 Smi::Handle(Smi::New(assembler()->CodeSize()))); | 728 StaticCallsStruct(assembler()->CodeSize(), NULL, &code)); |
737 ASSERT(Code::kSCallTableFunctionEntry == 1); | |
738 static_calls_target_table_.Add(Function::Handle()); | |
739 ASSERT(Code::kSCallTableCodeEntry == 2); | |
740 static_calls_target_table_.Add(code); | |
741 } | 729 } |
742 | 730 |
743 | 731 |
744 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, | 732 void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, |
745 intptr_t token_pos) { | 733 intptr_t token_pos) { |
746 ASSERT(is_optimizing()); | 734 ASSERT(is_optimizing()); |
747 ASSERT(!intrinsic_mode()); | 735 ASSERT(!intrinsic_mode()); |
748 CompilerDeoptInfo* info = | 736 CompilerDeoptInfo* info = |
749 new CompilerDeoptInfo(deopt_id, | 737 new CompilerDeoptInfo(deopt_id, |
750 ICData::kDeoptAtCall, | 738 ICData::kDeoptAtCall, |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 info.end_pos = 0; | 982 info.end_pos = 0; |
995 info.set_index(parsed_function().current_context_var()->index()); | 983 info.set_index(parsed_function().current_context_var()->index()); |
996 var_descs.SetVar(0, Symbols::CurrentContextVar(), &info); | 984 var_descs.SetVar(0, Symbols::CurrentContextVar(), &info); |
997 } | 985 } |
998 code.set_var_descriptors(var_descs); | 986 code.set_var_descriptors(var_descs); |
999 } | 987 } |
1000 | 988 |
1001 | 989 |
1002 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { | 990 void FlowGraphCompiler::FinalizeStaticCallTargetsTable(const Code& code) { |
1003 ASSERT(code.static_calls_target_table() == Array::null()); | 991 ASSERT(code.static_calls_target_table() == Array::null()); |
1004 const Array& targets = | 992 const Array& targets = Array::Handle(zone(), Array::New( |
1005 Array::Handle(Array::MakeArray(static_calls_target_table_)); | 993 (static_calls_target_table_.length() * Code::kSCallTableEntryLength), |
| 994 Heap::kOld)); |
| 995 Smi& smi_offset = Smi::Handle(zone()); |
| 996 for (intptr_t i = 0; i < static_calls_target_table_.length(); i++) { |
| 997 const intptr_t target_ix = Code::kSCallTableEntryLength * i; |
| 998 smi_offset = Smi::New(static_calls_target_table_[i].offset); |
| 999 targets.SetAt(target_ix + Code::kSCallTableOffsetEntry, smi_offset); |
| 1000 if (static_calls_target_table_[i].function != NULL) { |
| 1001 targets.SetAt(target_ix + Code::kSCallTableFunctionEntry, |
| 1002 *static_calls_target_table_[i].function); |
| 1003 } |
| 1004 if (static_calls_target_table_[i].code != NULL) { |
| 1005 targets.SetAt(target_ix + Code::kSCallTableCodeEntry, |
| 1006 *static_calls_target_table_[i].code); |
| 1007 } |
| 1008 } |
1006 code.set_static_calls_target_table(targets); | 1009 code.set_static_calls_target_table(targets); |
1007 INC_STAT(isolate(), total_code_size, targets.Length() * sizeof(uword)); | 1010 INC_STAT(isolate(), total_code_size, targets.Length() * sizeof(uword)); |
1008 } | 1011 } |
1009 | 1012 |
1010 | 1013 |
1011 // Returns 'true' if code generation for this function is complete, i.e., | 1014 // Returns 'true' if code generation for this function is complete, i.e., |
1012 // no fall-through to regular code is needed. | 1015 // no fall-through to regular code is needed. |
1013 void FlowGraphCompiler::TryIntrinsify() { | 1016 void FlowGraphCompiler::TryIntrinsify() { |
1014 // Intrinsification skips arguments checks, therefore disable if in checked | 1017 // Intrinsification skips arguments checks, therefore disable if in checked |
1015 // mode. | 1018 // mode. |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1819 | 1822 |
1820 | 1823 |
1821 void FlowGraphCompiler::FrameStateClear() { | 1824 void FlowGraphCompiler::FrameStateClear() { |
1822 ASSERT(!is_optimizing()); | 1825 ASSERT(!is_optimizing()); |
1823 frame_state_.TruncateTo(0); | 1826 frame_state_.TruncateTo(0); |
1824 } | 1827 } |
1825 #endif | 1828 #endif |
1826 | 1829 |
1827 | 1830 |
1828 } // namespace dart | 1831 } // namespace dart |
OLD | NEW |