MIPS: [turbofan] Remove the no-context hack for JSToNumber.
Port d211608a3e
Original commit message:
The ToNumberStub is now able to handle all plain primitives (Numbers,
Booleans, Null, Undefined and Strings) without context access.
TEST=cctest,mjsunit,unittests
BUG=
Review URL: https://codereview.chromium.org/803973002
Cr-Commit-Position: refs/heads/master@{#25824}
This commit is contained in:
parent
ed6e1735b6
commit
9167c996d3
@ -3340,20 +3340,43 @@ 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);
|
||||
Label not_smi;
|
||||
__ JumpIfNotSmi(a0, ¬_smi);
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(¬_smi);
|
||||
|
||||
__ bind(&check_heap_number);
|
||||
Label not_heap_number;
|
||||
__ lw(a1, FieldMemOperand(a0, HeapObject::kMapOffset));
|
||||
__ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
|
||||
__ Branch(&call_builtin, ne, a1, Operand(at));
|
||||
__ lbu(a1, FieldMemOperand(a1, Map::kInstanceTypeOffset));
|
||||
// a0: object
|
||||
// a1: instance type.
|
||||
__ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE));
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(¬_heap_number);
|
||||
|
||||
__ bind(&call_builtin);
|
||||
__ push(a0);
|
||||
Label not_string, slow_string;
|
||||
__ Branch(¬_string, hs, a1, Operand(FIRST_NONSTRING_TYPE));
|
||||
// Check if string has a cached array index.
|
||||
__ lw(a2, FieldMemOperand(a0, String::kHashFieldOffset));
|
||||
__ And(at, a2, Operand(String::kContainsCachedArrayIndexMask));
|
||||
__ Branch(&slow_string, ne, at, Operand(zero_reg));
|
||||
__ IndexFromHash(a2, a0);
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(&slow_string);
|
||||
__ push(a0); // Push argument.
|
||||
__ TailCallRuntime(Runtime::kStringToNumber, 1, 1);
|
||||
__ bind(¬_string);
|
||||
|
||||
Label not_oddball;
|
||||
__ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE));
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ lw(v0, FieldMemOperand(a0, Oddball::kToNumberOffset));
|
||||
__ bind(¬_oddball);
|
||||
|
||||
__ push(a0); // Push argument.
|
||||
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
|
||||
}
|
||||
|
||||
|
@ -3379,20 +3379,43 @@ 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);
|
||||
Label not_smi;
|
||||
__ JumpIfNotSmi(a0, ¬_smi);
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(¬_smi);
|
||||
|
||||
__ bind(&check_heap_number);
|
||||
Label not_heap_number;
|
||||
__ ld(a1, FieldMemOperand(a0, HeapObject::kMapOffset));
|
||||
__ LoadRoot(at, Heap::kHeapNumberMapRootIndex);
|
||||
__ Branch(&call_builtin, ne, a1, Operand(at));
|
||||
__ lbu(a1, FieldMemOperand(a1, Map::kInstanceTypeOffset));
|
||||
// a0: object
|
||||
// a1: instance type.
|
||||
__ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE));
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(¬_heap_number);
|
||||
|
||||
__ bind(&call_builtin);
|
||||
__ push(a0);
|
||||
Label not_string, slow_string;
|
||||
__ Branch(¬_string, hs, a1, Operand(FIRST_NONSTRING_TYPE));
|
||||
// Check if string has a cached array index.
|
||||
__ ld(a2, FieldMemOperand(a0, String::kHashFieldOffset));
|
||||
__ And(at, a2, Operand(String::kContainsCachedArrayIndexMask));
|
||||
__ Branch(&slow_string, ne, at, Operand(zero_reg));
|
||||
__ IndexFromHash(a2, a0);
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ mov(v0, a0);
|
||||
__ bind(&slow_string);
|
||||
__ push(a0); // Push argument.
|
||||
__ TailCallRuntime(Runtime::kStringToNumber, 1, 1);
|
||||
__ bind(¬_string);
|
||||
|
||||
Label not_oddball;
|
||||
__ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE));
|
||||
__ Ret(USE_DELAY_SLOT);
|
||||
__ ld(v0, FieldMemOperand(a0, Oddball::kToNumberOffset));
|
||||
__ bind(¬_oddball);
|
||||
|
||||
__ push(a0); // Push argument.
|
||||
__ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user