Commit 9b72f14c authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

Turn ToNumberStub into a PlatformCodeStub again.

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
R=mvstanton@chromium.org

Review URL: https://codereview.chromium.org/683913008

Cr-Commit-Position: refs/heads/master@{#25187}
git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25187 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d04038bd
......@@ -3187,6 +3187,24 @@ void SubStringStub::Generate(MacroAssembler* masm) {
}
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in r0.
Label check_heap_number, call_builtin;
__ JumpIfNotSmi(r0, &check_heap_number);
__ Ret();
__ bind(&check_heap_number);
__ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset));
__ CompareRoot(r1, Heap::kHeapNumberMapRootIndex);
__ b(ne, &call_builtin);
__ Ret();
__ bind(&call_builtin);
__ push(r0);
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
}
void StringHelper::GenerateFlatOneByteStringEquals(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3) {
......
......@@ -3833,6 +3833,22 @@ void SubStringStub::Generate(MacroAssembler* masm) {
}
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in x0.
Label check_heap_number, call_builtin;
__ JumpIfNotSmi(x0, &check_heap_number);
__ Ret();
__ bind(&check_heap_number);
__ JumpIfNotHeapNumber(x0, &call_builtin);
__ Ret();
__ bind(&call_builtin);
__ push(x0);
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
}
void StringHelper::GenerateFlatOneByteStringEquals(
MacroAssembler* masm, Register left, Register right, Register scratch1,
Register scratch2, Register scratch3) {
......
......@@ -283,37 +283,6 @@ static Handle<Code> DoGenerateCode(Stub* stub) {
}
template <>
HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
HValue* value = GetParameter(0);
// Check if the parameter is already a SMI or heap number.
IfBuilder if_number(this);
if_number.If<HIsSmiAndBranch>(value);
if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map());
if_number.Then();
// Return the number.
Push(value);
if_number.Else();
// Convert the parameter to number using the builtin.
HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER);
Add<HPushArguments>(value);
Push(Add<HInvokeFunction>(function, 1));
if_number.End();
return Pop();
}
Handle<Code> ToNumberStub::GenerateCode() {
return DoGenerateCode(this);
}
template <>
HValue* CodeStubGraphBuilder<NumberToStringStub>::BuildCodeStub() {
info()->MarkAsSavesCallerDoubles();
......
......@@ -654,9 +654,6 @@ void FastNewClosureStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
void FastNewContextStub::InitializeDescriptor(CodeStubDescriptor* d) {}
void ToNumberStub::InitializeDescriptor(CodeStubDescriptor* d) {}
void NumberToStringStub::InitializeDescriptor(CodeStubDescriptor* descriptor) {
NumberToStringDescriptor call_descriptor(isolate());
descriptor->Initialize(
......
......@@ -50,6 +50,7 @@ namespace internal {
V(StringCompare) \
V(StubFailureTrampoline) \
V(SubString) \
V(ToNumber) \
/* HydrogenCodeStubs */ \
V(AllocateHeapNumber) \
V(ArrayNArgumentsConstructor) \
......@@ -77,7 +78,6 @@ namespace internal {
V(StoreFastElement) \
V(StringAdd) \
V(ToBoolean) \
V(ToNumber) \
V(TransitionElementsKind) \
V(VectorKeyedLoad) \
V(VectorLoad) \
......@@ -545,15 +545,6 @@ class NopRuntimeCallHelper : public RuntimeCallHelper {
};
class ToNumberStub: public HydrogenCodeStub {
public:
explicit ToNumberStub(Isolate* isolate) : HydrogenCodeStub(isolate) { }
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToNumber);
DEFINE_HYDROGEN_CODE_STUB(ToNumber, HydrogenCodeStub);
};
class NumberToStringStub FINAL : public HydrogenCodeStub {
public:
explicit NumberToStringStub(Isolate* isolate) : HydrogenCodeStub(isolate) {}
......@@ -2537,6 +2528,15 @@ class SubStringStub : public PlatformCodeStub {
};
class ToNumberStub FINAL : public PlatformCodeStub {
public:
explicit ToNumberStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
DEFINE_CALL_INTERFACE_DESCRIPTOR(ToNumber);
DEFINE_PLATFORM_CODE_STUB(ToNumber, PlatformCodeStub);
};
class StringCompareStub : public PlatformCodeStub {
public:
explicit StringCompareStub(Isolate* isolate) : PlatformCodeStub(isolate) {}
......
......@@ -3173,6 +3173,25 @@ void SubStringStub::Generate(MacroAssembler* masm) {
}
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in eax.
Label check_heap_number, call_builtin;
__ JumpIfNotSmi(eax, &check_heap_number, Label::kNear);
__ Ret();
__ bind(&check_heap_number);
__ CompareMap(eax, masm->isolate()->factory()->heap_number_map());
__ j(not_equal, &call_builtin, Label::kNear);
__ Ret();
__ bind(&call_builtin);
__ pop(ecx); // Pop return address.
__ push(eax);
__ push(ecx); // Push return address.
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
}
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
Register left,
Register right,
......
......@@ -3122,6 +3122,26 @@ void SubStringStub::Generate(MacroAssembler* masm) {
}
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in rax.
Label check_heap_number, call_builtin;
__ JumpIfNotSmi(rax, &check_heap_number, Label::kNear);
__ Ret();
__ bind(&check_heap_number);
__ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
Heap::kHeapNumberMapRootIndex);
__ j(not_equal, &call_builtin, Label::kNear);
__ Ret();
__ bind(&call_builtin);
__ popq(rcx); // Pop return address.
__ pushq(rax);
__ pushq(rcx); // Push return address.
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
}
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm,
Register left,
Register right,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment