From b5c6dc35f9a6623c39e74b925087fa54ea1ca7fe Mon Sep 17 00:00:00 2001 From: "iposva@chromium.org" Date: Fri, 15 May 2009 22:36:26 +0000 Subject: [PATCH] - Fix numeric overflow handling when compiling count operations. In certain situations the overflow checking corrupted the value being calculated. Review URL: http://codereview.chromium.org/115423 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/ia32/codegen-ia32.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index dd14f1b..4a988fe 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -115,6 +115,14 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) { JumpTarget::set_compiling_deferred_code(false); +#ifdef DEBUG + if (strlen(FLAG_stop_at) > 0 && + fun->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { + frame_->SpillAll(); + __ int3(); + } +#endif + { HistogramTimerScope codegen_timer(&Counters::code_generation); CodeGenState state(this); @@ -128,14 +136,6 @@ void CodeGenerator::GenCode(FunctionLiteral* fun) { allocator_->Initialize(); frame_->Enter(); -#ifdef DEBUG - if (strlen(FLAG_stop_at) > 0 && - fun->name()->IsEqualTo(CStrVector(FLAG_stop_at))) { - frame_->SpillAll(); - __ int3(); - } -#endif - // Allocate space for locals and initialize them. frame_->AllocateStackSlots(scope_->num_stack_slots()); // Initialize the function return target after the locals are set @@ -4878,9 +4878,9 @@ void CodeGenerator::VisitCountOperation(CountOperation* node) { // successfully allocate a temporary byte register. if (tmp.is_valid()) { __ setcc(overflow, tmp.reg()); - __ or_(Operand(value.reg()), tmp.reg()); + __ or_(Operand(tmp.reg()), value.reg()); + __ test(tmp.reg(), Immediate(kSmiTagMask)); tmp.Unuse(); - __ test(value.reg(), Immediate(kSmiTagMask)); deferred->enter()->Branch(not_zero, &value, not_taken); } else { // Otherwise we test separately for overflow and smi check. deferred->enter()->Branch(overflow, &value, not_taken); -- 2.7.4