Disable aggressive optimizations on the last optimization attempt.

Only has effect on the loop invariant code motion and Check instructions
for now.

Review URL: http://codereview.chromium.org/6321007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6363 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
vitalyr@chromium.org 2011-01-18 13:43:48 +00:00
parent 2729e09caf
commit c919bb7d4a
5 changed files with 41 additions and 6 deletions

View File

@ -207,7 +207,8 @@ static bool MakeCrankshaftCode(CompilationInfo* info) {
// Limit the number of times we re-compile a functions with
// the optimizing compiler.
const int kMaxOptCount = FLAG_deopt_every_n_times == 0 ? 10 : 1000;
const int kMaxOptCount =
FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000;
if (info->shared_info()->opt_count() > kMaxOptCount) {
AbortAndDisable(info);
// True indicates the compilation pipeline is still going, not

View File

@ -209,9 +209,13 @@ class CompilationInfo BASE_EMBEDDED {
class Compiler : public AllStatic {
public:
// All routines return a JSFunction.
// If an error occurs an exception is raised and
// the return handle contains NULL.
// Default maximum number of function optimization attempts before we
// give up.
static const int kDefaultMaxOptCount = 10;
// All routines return a SharedFunctionInfo.
// If an error occurs an exception is raised and the return handle
// contains NULL.
// Compile a String source within a context.
static Handle<SharedFunctionInfo> Compile(Handle<String> source,

View File

@ -773,6 +773,10 @@ class HInstruction: public HValue {
virtual void Verify() const;
#endif
// Returns whether this is some kind of deoptimizing check
// instruction.
virtual bool IsCheckInstruction() const { return false; }
DECLARE_INSTRUCTION(Instruction)
protected:
@ -1504,6 +1508,8 @@ class HCheckMap: public HUnaryOperation {
SetFlag(kDependsOnMaps);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@ -1537,6 +1543,8 @@ class HCheckFunction: public HUnaryOperation {
SetFlag(kUseGVN);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@ -1573,6 +1581,8 @@ class HCheckInstanceType: public HUnaryOperation {
SetFlag(kUseGVN);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@ -1610,6 +1620,8 @@ class HCheckNonSmi: public HUnaryOperation {
SetFlag(kUseGVN);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@ -1632,6 +1644,8 @@ class HCheckPrototypeMaps: public HInstruction {
SetFlag(kDependsOnMaps);
}
virtual bool IsCheckInstruction() const { return true; }
#ifdef DEBUG
virtual void Verify() const;
#endif
@ -1668,6 +1682,8 @@ class HCheckSmi: public HUnaryOperation {
SetFlag(kUseGVN);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Tagged();
}
@ -1996,6 +2012,8 @@ class HBoundsCheck: public HBinaryOperation {
SetFlag(kUseGVN);
}
virtual bool IsCheckInstruction() const { return true; }
virtual Representation RequiredInputRepresentation(int index) const {
return Representation::Integer32();
}

View File

@ -687,6 +687,11 @@ HGraph::HGraph(CompilationInfo* info)
}
bool HGraph::AllowAggressiveOptimizations() const {
return info()->shared_info()->opt_count() + 1 < Compiler::kDefaultMaxOptCount;
}
Handle<Code> HGraph::Compile() {
int values = GetMaximumValueID();
if (values > LAllocator::max_initial_value_ids()) {
@ -1453,8 +1458,12 @@ void HGlobalValueNumberer::ProcessLoopBlock(HBasicBlock* block,
// about code that was never executed.
bool HGlobalValueNumberer::ShouldMove(HInstruction* instr,
HBasicBlock* loop_header) {
if (!instr->IsChange() &&
FLAG_aggressive_loop_invariant_motion) return true;
if (FLAG_aggressive_loop_invariant_motion &&
!instr->IsChange() &&
(!instr->IsCheckInstruction() ||
graph_->AllowAggressiveOptimizations())) {
return true;
}
HBasicBlock* block = instr->block();
bool result = true;
if (block != loop_header) {

View File

@ -296,6 +296,9 @@ class HGraph: public HSubgraph {
explicit HGraph(CompilationInfo* info);
CompilationInfo* info() const { return info_; }
bool AllowAggressiveOptimizations() const;
const ZoneList<HBasicBlock*>* blocks() const { return &blocks_; }
const ZoneList<HPhi*>* phi_list() const { return phi_list_; }
Handle<String> debug_name() const { return info_->function()->debug_name(); }