From da5ab75a762e950f4ebe111446c74cb37bfd1f3e Mon Sep 17 00:00:00 2001 From: "sgjesse@chromium.org" Date: Mon, 28 Feb 2011 11:52:06 +0000 Subject: [PATCH] ARM: Fix the use of the ToBooleanStub when VFP3 is not available Review URL: http://codereview.chromium.org/6594045 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6963 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/code-stubs-arm.cc | 3 +++ src/arm/full-codegen-arm.cc | 46 +++++++++++++++++++++++++++------------------ 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index fe963a2..7d374ee 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -1296,6 +1296,9 @@ void CompareStub::Generate(MacroAssembler* masm) { // This stub does not handle the inlined cases (Smis, Booleans, undefined). // The stub returns zero for false, and a non-zero value for true. void ToBooleanStub::Generate(MacroAssembler* masm) { + // This stub uses VFP3 instructions. + ASSERT(CpuFeatures::IsEnabled(VFP3)); + Label false_result; Label not_heap_number; Register scratch = r9.is(tos_) ? r7 : r9; diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 254fd18..9f521fb 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -574,25 +574,35 @@ void FullCodeGenerator::TestContext::Plug(bool flag) const { void FullCodeGenerator::DoTest(Label* if_true, Label* if_false, Label* fall_through) { - // Emit the inlined tests assumed by the stub. - __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); - __ cmp(result_register(), ip); - __ b(eq, if_false); - __ LoadRoot(ip, Heap::kTrueValueRootIndex); - __ cmp(result_register(), ip); - __ b(eq, if_true); - __ LoadRoot(ip, Heap::kFalseValueRootIndex); - __ cmp(result_register(), ip); - __ b(eq, if_false); - STATIC_ASSERT(kSmiTag == 0); - __ tst(result_register(), result_register()); - __ b(eq, if_false); - __ JumpIfSmi(result_register(), if_true); + if (CpuFeatures::IsSupported(VFP3)) { + CpuFeatures::Scope scope(VFP3); + // Emit the inlined tests assumed by the stub. + __ LoadRoot(ip, Heap::kUndefinedValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_false); + __ LoadRoot(ip, Heap::kTrueValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_true); + __ LoadRoot(ip, Heap::kFalseValueRootIndex); + __ cmp(result_register(), ip); + __ b(eq, if_false); + STATIC_ASSERT(kSmiTag == 0); + __ tst(result_register(), result_register()); + __ b(eq, if_false); + __ JumpIfSmi(result_register(), if_true); - // Call the ToBoolean stub for all other cases. - ToBooleanStub stub(result_register()); - __ CallStub(&stub); - __ tst(result_register(), result_register()); + // Call the ToBoolean stub for all other cases. + ToBooleanStub stub(result_register()); + __ CallStub(&stub); + __ tst(result_register(), result_register()); + } else { + // Call the runtime to find the boolean value of the source and then + // translate it into control flow to the pair of labels. + __ push(result_register()); + __ CallRuntime(Runtime::kToBool, 1); + __ LoadRoot(ip, Heap::kFalseValueRootIndex); + __ cmp(r0, ip); + } // The stub returns nonzero for true. Split(ne, if_true, if_false, fall_through); -- 2.7.4