Index: src/ia32/full-codegen-ia32.cc |
diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc |
index 135db06ac84d556ce78a01abeb74993282587a6a..9f9636580e49803300ba083266ff78ca20b029af 100644 |
--- a/src/ia32/full-codegen-ia32.cc |
+++ b/src/ia32/full-codegen-ia32.cc |
@@ -1,4 +1,4 @@ |
-// Copyright 2011 the V8 project authors. All rights reserved. |
+// Copyright 2012 the V8 project authors. All rights reserved. |
// Redistribution and use in source and binary forms, with or without |
// modification, are permitted provided that the following conditions are |
// met: |
@@ -129,6 +129,32 @@ void FullCodeGenerator::Generate(CompilationInfo* info) { |
} |
#endif |
+ // Primitive functions are unlikely to be picked up by the stack-walking |
+ // profiler, so they trigger their own optimization when they're called |
+ // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time. |
+ if (FLAG_counting_profiler && |
Erik Corry
2012/02/08 14:09:23
These two flags can be tested inside ShouldSelfOpt
Jakob Kummerow
2012/02/08 15:24:08
Good idea to clean this up. I've moved ShouldSelfO
|
+ FLAG_crankshaft && |
+ info->function()->ShouldSelfOptimize() && |
+ !Serializer::enabled() && |
+ !(!info->shared_info().is_null() && |
+ info->shared_info()->optimization_disabled())) { |
+ if (FLAG_trace_opt) { |
+ PrintF("[adding self-optimization header to %s]\n", |
+ *info->function()->debug_name()->ToCString()); |
+ } |
+ MaybeObject* maybe_cell = isolate()->heap()->AllocateJSGlobalPropertyCell( |
+ Smi::FromInt(Compiler::kCallsUntilPrimitiveOpt)); |
+ JSGlobalPropertyCell* cell; |
+ if (maybe_cell->To(&cell)) { |
+ __ mov(eax, Immediate(Handle<JSGlobalPropertyCell>(cell))); |
+ __ sub(FieldOperand(eax, JSGlobalPropertyCell::kValueOffset), |
+ Immediate(Smi::FromInt(1))); |
Erik Corry
2012/02/08 14:09:23
It seems you can do:
__ sub(Operand::Cell(Handle<
Jakob Kummerow
2012/02/08 15:24:08
Done.
|
+ Handle<Code> compile_stub( |
+ isolate()->builtins()->builtin(Builtins::kLazyRecompile)); |
+ __ j(zero, compile_stub); |
Erik Corry
2012/02/08 14:09:23
There is an assumption here that the Smi tag is ze
Jakob Kummerow
2012/02/08 15:24:08
I've added an ASSERT for the Smi tag.
I can't easi
|
+ } |
+ } |
+ |
// Strict mode functions and builtins need to replace the receiver |
// with undefined when called as functions (without an explicit |
// receiver object). ecx is zero for method calls and non-zero for |