From 700d7a2de577a8d540f32f6330ac4e29b9ea2936 Mon Sep 17 00:00:00 2001 From: "balazs.kilvady@imgtec.com" Date: Thu, 6 Nov 2014 16:26:42 +0000 Subject: [PATCH] MIPS: Turn ToNumberStub into a PlatformCodeStub again. Port 724a15e8bf3fb8697a950c8e0f96158c8e56ec71 Port r25187 The HydrogenCodeStub is too expensive and there's no easy way to reduce this cost, so turning it into a PlatformCodeStub solves that problem until we can use TurboFan for code stubs. TEST=mjsunit BUG= R=dusan.milosavljevic@imgtec.com Review URL: https://codereview.chromium.org/707863002 Cr-Commit-Position: refs/heads/master@{#25202} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25202 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/code-stubs-mips.cc | 20 ++++++++++++++++++++ src/mips64/code-stubs-mips64.cc | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index e827d77..c8db844 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -3351,6 +3351,26 @@ void SubStringStub::Generate(MacroAssembler* masm) { } +void ToNumberStub::Generate(MacroAssembler* masm) { + // The ToNumber stub takes one argument in a0. + Label check_heap_number, call_builtin; + __ JumpIfNotSmi(a0, &check_heap_number); + __ Ret(USE_DELAY_SLOT); + __ mov(v0, a0); + + __ bind(&check_heap_number); + __ lw(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); + __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); + __ Branch(&call_builtin, ne, a1, Operand(at)); + __ Ret(USE_DELAY_SLOT); + __ mov(v0, a0); + + __ bind(&call_builtin); + __ push(a0); + __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); +} + + void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3) { diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index beb83e9..ef812c7 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -3376,6 +3376,26 @@ void SubStringStub::Generate(MacroAssembler* masm) { } +void ToNumberStub::Generate(MacroAssembler* masm) { + // The ToNumber stub takes one argument in a0. + Label check_heap_number, call_builtin; + __ JumpIfNotSmi(a0, &check_heap_number); + __ Ret(USE_DELAY_SLOT); + __ mov(v0, a0); + + __ bind(&check_heap_number); + __ ld(a1, FieldMemOperand(a0, HeapObject::kMapOffset)); + __ LoadRoot(at, Heap::kHeapNumberMapRootIndex); + __ Branch(&call_builtin, ne, a1, Operand(at)); + __ Ret(USE_DELAY_SLOT); + __ mov(v0, a0); + + __ bind(&call_builtin); + __ push(a0); + __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION); +} + + void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, Register scratch2, Register scratch3) { -- 2.7.4