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

Unified Diff: runtime/vm/flow_graph_compiler_ia32.cc

Issue 11783066: Optimize function at its entry instead of at exit. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.h ('k') | runtime/vm/flow_graph_compiler_x64.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler_ia32.cc
===================================================================
--- runtime/vm/flow_graph_compiler_ia32.cc (revision 16874)
+++ runtime/vm/flow_graph_compiler_ia32.cc (working copy)
@@ -19,10 +19,11 @@
namespace dart {
+DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
+DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic.");
+DECLARE_FLAG(int, optimization_counter_threshold);
DECLARE_FLAG(bool, print_ast);
DECLARE_FLAG(bool, print_scopes);
-DEFINE_FLAG(bool, trap_on_deoptimization, false, "Trap on deoptimization.");
-DEFINE_FLAG(bool, unbox_mints, true, "Optimize 64-bit integer arithmetic.");
bool FlowGraphCompiler::SupportsUnboxedMints() {
@@ -863,6 +864,39 @@
}
+void FlowGraphCompiler::EmitFrameEntry() {
+ const Function& function = parsed_function().function();
+ if (CanOptimizeFunction() && function.is_optimizable()) {
+ const bool can_optimize = !is_optimizing() || may_reoptimize();
+ const Register function_reg = EDI;
+ if (can_optimize) {
+ __ LoadObject(function_reg, function);
+ }
+ // Patch point is after the eventually inlined function object.
+ AddCurrentDescriptor(PcDescriptors::kEntryPatch,
+ Isolate::kNoDeoptId,
+ 0); // No token position.
+ if (can_optimize) {
+ // Reoptimization of optimized function is triggered by counting in
+ // IC stubs, but not at the entry of the function.
+ if (!is_optimizing()) {
+ __ incl(FieldAddress(function_reg, Function::usage_counter_offset()));
+ }
+ __ cmpl(FieldAddress(function_reg, Function::usage_counter_offset()),
+ Immediate(FLAG_optimization_counter_threshold));
+ ASSERT(function_reg == EDI);
+ __ j(GREATER_EQUAL, &StubCode::OptimizeFunctionLabel());
+ }
+ } else {
+ AddCurrentDescriptor(PcDescriptors::kEntryPatch,
+ Isolate::kNoDeoptId,
+ 0); // No token position.
+ }
+ __ Comment("Enter frame");
+ AssemblerMacros::EnterDartFrame(assembler(), (StackSize() * kWordSize));
+}
+
+
void FlowGraphCompiler::CompileGraph() {
InitCompiler();
if (TryIntrinsify()) {
@@ -873,14 +907,14 @@
__ jmp(&StubCode::FixCallersTargetLabel());
return;
}
- // Specialized version of entry code from CodeGenerator::GenerateEntryCode.
+
+ EmitFrameEntry();
+
const Function& function = parsed_function().function();
const int num_fixed_params = function.num_fixed_parameters();
const int num_copied_params = parsed_function().num_copied_params();
const int num_locals = parsed_function().num_stack_locals();
- __ Comment("Enter frame");
- AssemblerMacros::EnterDartFrame(assembler(), (StackSize() * kWordSize));
// For optimized code, keep a bitmap of the frame in order to build
// stackmaps for GC safepoints in the prologue.
@@ -1068,7 +1102,7 @@
// to inlining in optimized code, that function may not correspond to the
// top-level function (parsed_function().function()) which could be
// reoptimized and which counter needs to be incremented.
- // Pass the function explicitly.
+ // Pass the function explicitly, it is used in IC stub.
__ LoadObject(EDI, parsed_function().function());
__ LoadObject(ECX, ic_data);
__ LoadObject(EDX, arguments_descriptor);
« no previous file with comments | « runtime/vm/flow_graph_compiler_ia32.h ('k') | runtime/vm/flow_graph_compiler_x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698