Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: runtime/vm/flow_graph_compiler_x64.cc

Issue 10356051: First steps toward a two stages new compiler. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_compiler_x64.cc
===================================================================
--- runtime/vm/flow_graph_compiler_x64.cc (revision 7399)
+++ runtime/vm/flow_graph_compiler_x64.cc (working copy)
@@ -33,14 +33,16 @@
FlowGraphCompiler::FlowGraphCompiler(
Assembler* assembler,
const ParsedFunction& parsed_function,
- const GrowableArray<BlockEntryInstr*>& block_order)
+ const GrowableArray<BlockEntryInstr*>& block_order,
+ bool is_optimizing)
: FlowGraphVisitor(block_order),
assembler_(assembler),
parsed_function_(parsed_function),
block_info_(block_order.length()),
current_block_(NULL),
pc_descriptors_list_(new DescriptorList()),
- exception_handlers_list_(new ExceptionHandlerList()) {
+ exception_handlers_list_(new ExceptionHandlerList()),
+ is_optimizing_(is_optimizing) {
for (int i = 0; i < block_order.length(); ++i) {
block_info_.Add(new BlockInfo());
}
@@ -1222,6 +1224,28 @@
void FlowGraphCompiler::VisitReturn(ReturnInstr* instr) {
LoadValue(RAX, instr->value());
+ if (!is_optimizing()) {
+ // Count only in unoptimized code.
+ // TODO(srdjan): Replace the counting code with a type feedback
+ // collection and counting stub.
+ const Function& function =
+ Function::ZoneHandle(parsed_function_.function().raw());
+ __ LoadObject(RCX, function);
+ __ incq(FieldAddress(RCX, Function::usage_counter_offset()));
+ if (CodeGenerator::CanOptimize()) {
+ // Do not optimize if usage count must be reported.
+ __ cmpl(FieldAddress(RCX, Function::usage_counter_offset()),
+ Immediate(FLAG_optimization_counter_threshold));
+ Label not_yet_hot;
+ __ j(LESS_EQUAL, &not_yet_hot, Assembler::kNearJump);
+ __ pushq(RAX); // Preserve result.
+ __ pushq(RCX); // Argument for runtime: function to optimize.
+ __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry);
+ __ popq(RCX); // Remove argument.
+ __ popq(RAX); // Restore result.
+ __ Bind(&not_yet_hot);
+ }
+ }
if (FLAG_trace_functions) {
__ pushq(RAX); // Preserve result.

Powered by Google App Engine
This is Rietveld 408576698