| 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/cha.h" | 9 #include "vm/cha.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 DECLARE_FLAG(int, optimization_counter_threshold); | 33 DECLARE_FLAG(int, optimization_counter_threshold); |
| 34 DECLARE_FLAG(bool, use_cha); | 34 DECLARE_FLAG(bool, use_cha); |
| 35 DECLARE_FLAG(bool, use_osr); | 35 DECLARE_FLAG(bool, use_osr); |
| 36 DECLARE_FLAG(int, stacktrace_every); | 36 DECLARE_FLAG(int, stacktrace_every); |
| 37 DECLARE_FLAG(charp, stacktrace_filter); | 37 DECLARE_FLAG(charp, stacktrace_filter); |
| 38 DECLARE_FLAG(int, deoptimize_every); | 38 DECLARE_FLAG(int, deoptimize_every); |
| 39 DECLARE_FLAG(charp, deoptimize_filter); | 39 DECLARE_FLAG(charp, deoptimize_filter); |
| 40 | 40 |
| 41 DEFINE_FLAG(bool, enable_simd_inline, true, | 41 DEFINE_FLAG(bool, enable_simd_inline, true, |
| 42 "Enable inlining of SIMD related method calls."); | 42 "Enable inlining of SIMD related method calls."); |
| 43 DEFINE_FLAG(bool, source_lines, false, "Emit source line as assembly comment."); |
| 43 | 44 |
| 44 // Assign locations to incoming arguments, i.e., values pushed above spill slots | 45 // Assign locations to incoming arguments, i.e., values pushed above spill slots |
| 45 // with PushArgument. Recursively allocates from outermost to innermost | 46 // with PushArgument. Recursively allocates from outermost to innermost |
| 46 // environment. | 47 // environment. |
| 47 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( | 48 void CompilerDeoptInfo::AllocateIncomingParametersRecursive( |
| 48 Environment* env, | 49 Environment* env, |
| 49 intptr_t* stack_height) { | 50 intptr_t* stack_height) { |
| 50 if (env == NULL) return; | 51 if (env == NULL) return; |
| 51 AllocateIncomingParametersRecursive(env->outer(), stack_height); | 52 AllocateIncomingParametersRecursive(env->outer(), stack_height); |
| 52 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { | 53 for (Environment::ShallowIterator it(env); !it.Done(); it.Advance()) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 } | 267 } |
| 267 AllocateRegistersLocally(instr); | 268 AllocateRegistersLocally(instr); |
| 268 } else if (instr->MayThrow() && | 269 } else if (instr->MayThrow() && |
| 269 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { | 270 (CurrentTryIndex() != CatchClauseNode::kInvalidTryIndex)) { |
| 270 // Optimized try-block: Sync locals to fixed stack locations. | 271 // Optimized try-block: Sync locals to fixed stack locations. |
| 271 EmitTrySync(instr, CurrentTryIndex()); | 272 EmitTrySync(instr, CurrentTryIndex()); |
| 272 } | 273 } |
| 273 } | 274 } |
| 274 | 275 |
| 275 | 276 |
| 277 |
| 278 void FlowGraphCompiler::EmitSourceLine(Instruction* instr) { |
| 279 if ((instr->token_pos() == Scanner::kNoSourcePos) || (instr->env() == NULL)) { |
| 280 return; |
| 281 } |
| 282 const Function& function = |
| 283 Function::Handle(instr->env()->code().function()); |
| 284 const Script& s = Script::Handle(function.script()); |
| 285 intptr_t line_nr; |
| 286 intptr_t column_nr; |
| 287 s.GetTokenLocation(instr->token_pos(), &line_nr, &column_nr); |
| 288 const String& line = String::Handle(s.GetLine(line_nr)); |
| 289 assembler()->Comment("Line %" Pd " in '%s':\n %s", |
| 290 line_nr, function.ToFullyQualifiedCString(), line.ToCString()); |
| 291 } |
| 292 |
| 293 |
| 276 void FlowGraphCompiler::VisitBlocks() { | 294 void FlowGraphCompiler::VisitBlocks() { |
| 277 CompactBlocks(); | 295 CompactBlocks(); |
| 278 | 296 |
| 279 for (intptr_t i = 0; i < block_order().length(); ++i) { | 297 for (intptr_t i = 0; i < block_order().length(); ++i) { |
| 280 // Compile the block entry. | 298 // Compile the block entry. |
| 281 BlockEntryInstr* entry = block_order()[i]; | 299 BlockEntryInstr* entry = block_order()[i]; |
| 282 assembler()->Comment("B%" Pd "", entry->block_id()); | 300 assembler()->Comment("B%" Pd "", entry->block_id()); |
| 283 set_current_block(entry); | 301 set_current_block(entry); |
| 284 | 302 |
| 285 if (WasCompacted(entry)) { | 303 if (WasCompacted(entry)) { |
| 286 continue; | 304 continue; |
| 287 } | 305 } |
| 288 | 306 |
| 289 entry->EmitNativeCode(this); | 307 entry->EmitNativeCode(this); |
| 290 // Compile all successors until an exit, branch, or a block entry. | 308 // Compile all successors until an exit, branch, or a block entry. |
| 291 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { | 309 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { |
| 292 Instruction* instr = it.Current(); | 310 Instruction* instr = it.Current(); |
| 293 if (FLAG_code_comments && | 311 if (FLAG_code_comments && |
| 294 (FLAG_disassemble || FLAG_disassemble_optimized)) { | 312 (FLAG_disassemble || FLAG_disassemble_optimized)) { |
| 313 if (FLAG_source_lines) { |
| 314 EmitSourceLine(instr); |
| 315 } |
| 295 EmitComment(instr); | 316 EmitComment(instr); |
| 296 } | 317 } |
| 297 if (instr->IsParallelMove()) { | 318 if (instr->IsParallelMove()) { |
| 298 parallel_move_resolver_.EmitNativeCode(instr->AsParallelMove()); | 319 parallel_move_resolver_.EmitNativeCode(instr->AsParallelMove()); |
| 299 } else { | 320 } else { |
| 300 EmitInstructionPrologue(instr); | 321 EmitInstructionPrologue(instr); |
| 301 ASSERT(pending_deoptimization_env_ == NULL); | 322 ASSERT(pending_deoptimization_env_ == NULL); |
| 302 pending_deoptimization_env_ = instr->env(); | 323 pending_deoptimization_env_ = instr->env(); |
| 303 instr->EmitNativeCode(this); | 324 instr->EmitNativeCode(this); |
| 304 pending_deoptimization_env_ = NULL; | 325 pending_deoptimization_env_ = NULL; |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 | 1316 |
| 1296 for (int i = 0; i < len; i++) { | 1317 for (int i = 0; i < len; i++) { |
| 1297 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), | 1318 sorted->Add(CidTarget(ic_data.GetReceiverClassIdAt(i), |
| 1298 &Function::ZoneHandle(ic_data.GetTargetAt(i)), | 1319 &Function::ZoneHandle(ic_data.GetTargetAt(i)), |
| 1299 ic_data.GetCountAt(i))); | 1320 ic_data.GetCountAt(i))); |
| 1300 } | 1321 } |
| 1301 sorted->Sort(HighestCountFirst); | 1322 sorted->Sort(HighestCountFirst); |
| 1302 } | 1323 } |
| 1303 | 1324 |
| 1304 } // namespace dart | 1325 } // namespace dart |
| OLD | NEW |