Commit 565a8f94 authored by jyan's avatar jyan Committed by Commit bot

S390: [stubs] ToNumberStub --> ToNumber builtin.

port 406146ff

Original Commit Message:
  This makes sure we do not compile ToNumber stub on demand. This makes it
  easier to use during concurrent compilation.

R=jarin@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, mbrandy@us.ibm.com, bjaideep@ca.ibm.com
BUG=

Review-Url: https://codereview.chromium.org/2052963003
Cr-Commit-Position: refs/heads/master@{#36874}
parent 2fd55667
......@@ -3242,8 +3242,7 @@ void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
}
// Convert old value into a number.
ToNumberStub convert_stub(isolate());
__ CallStub(&convert_stub);
__ Call(isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
PrepareForBailoutForId(expr->ToNumberId(), BailoutState::TOS_REGISTER);
// Save result for postfix expressions.
......
......@@ -166,19 +166,18 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
__ LoadP(r2, MemOperand(r4));
// Load the double value of the parameter into d2, maybe converting the
// parameter to a number first using the ToNumberStub if necessary.
// parameter to a number first using the ToNumber builtin if necessary.
Label convert, convert_smi, convert_number, done_convert;
__ bind(&convert);
__ JumpIfSmi(r2, &convert_smi);
__ LoadP(r6, FieldMemOperand(r2, HeapObject::kMapOffset));
__ JumpIfRoot(r6, Heap::kHeapNumberMapRootIndex, &convert_number);
{
// Parameter is not a Number, use the ToNumberStub to convert it.
// Parameter is not a Number, use the ToNumber builtin to convert it.
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ SmiTag(r5);
__ Push(r3, r4, r5);
ToNumberStub stub(masm->isolate());
__ CallStub(&stub);
__ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
__ Pop(r3, r4, r5);
__ SmiUntag(r5);
{
......@@ -254,8 +253,7 @@ void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
}
// 2a. Convert the first argument to a number.
ToNumberStub stub(masm->isolate());
__ TailCallStub(&stub);
__ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
// 2b. No arguments, return +0.
__ bind(&no_arguments);
......@@ -305,8 +303,7 @@ void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) {
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL);
__ Push(r3, r5);
__ LoadRR(r2, r4);
ToNumberStub stub(masm->isolate());
__ CallStub(&stub);
__ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
__ LoadRR(r4, r2);
__ Pop(r3, r5);
}
......@@ -2735,6 +2732,44 @@ void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
__ TailCallRuntime(Runtime::kStringToNumber);
}
// static
void Builtins::Generate_ToNumber(MacroAssembler* masm) {
// The ToNumber stub takes one argument in r2.
STATIC_ASSERT(kSmiTag == 0);
__ TestIfSmi(r2);
__ Ret(eq);
__ CompareObjectType(r2, r3, r3, HEAP_NUMBER_TYPE);
// r2: receiver
// r3: receiver instance type
__ Ret(eq);
__ Jump(masm->isolate()->builtins()->NonNumberToNumber(),
RelocInfo::CODE_TARGET);
}
// static
void Builtins::Generate_NonNumberToNumber(MacroAssembler* masm) {
// The NonNumberToNumber stub takes one argument in r2.
__ AssertNotNumber(r2);
__ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE);
// r2: receiver
// r3: receiver instance type
__ Jump(masm->isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET,
lt);
Label not_oddball;
__ CmpP(r3, Operand(ODDBALL_TYPE));
__ bne(&not_oddball);
__ LoadP(r2, FieldMemOperand(r2, Oddball::kToNumberOffset));
__ Ret();
__ bind(&not_oddball);
__ push(r2); // Push argument.
__ TailCallRuntime(Runtime::kToNumber);
}
void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
// ----------- S t a t e -------------
// -- r2 : actual number of arguments
......
......@@ -2566,44 +2566,6 @@ void SubStringStub::Generate(MacroAssembler* masm) {
generator.SkipSlow(masm, &runtime);
}
void ToNumberStub::Generate(MacroAssembler* masm) {
// The ToNumber stub takes one argument in r2.
STATIC_ASSERT(kSmiTag == 0);
__ TestIfSmi(r2);
__ Ret(eq);
__ CompareObjectType(r2, r3, r3, HEAP_NUMBER_TYPE);
// r2: receiver
// r3: receiver instance type
Label not_heap_number;
__ bne(&not_heap_number);
__ Ret();
__ bind(&not_heap_number);
NonNumberToNumberStub stub(masm->isolate());
__ TailCallStub(&stub);
}
void NonNumberToNumberStub::Generate(MacroAssembler* masm) {
// The NonNumberToNumber stub takes one argument in r2.
__ AssertNotNumber(r2);
__ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE);
// r2: receiver
// r3: receiver instance type
__ Jump(isolate()->builtins()->StringToNumber(), RelocInfo::CODE_TARGET, lt);
Label not_oddball;
__ CmpP(r3, Operand(ODDBALL_TYPE));
__ bne(&not_oddball, Label::kNear);
__ LoadP(r2, FieldMemOperand(r2, Oddball::kToNumberOffset));
__ b(r14);
__ bind(&not_oddball);
__ push(r2); // Push argument.
__ TailCallRuntime(Runtime::kToNumber);
}
void ToStringStub::Generate(MacroAssembler* masm) {
// The ToString stub takes one argument in r2.
Label done;
......
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