X87: Optimize the typeof operator.
port 7798548a8f
(r28260)
original commit message:
typeof was implemented as a runtime function. Calling it in
optimized code with a non-constant input becomes burdensome.
BUG=
Review URL: https://codereview.chromium.org/1124263005
Cr-Commit-Position: refs/heads/master@{#28279}
This commit is contained in:
parent
c3529ce501
commit
4b0565262a
@ -2144,6 +2144,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
|
||||
BinaryOpICStub::GenerateAheadOfTime(isolate);
|
||||
BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate);
|
||||
StoreFastElementStub::GenerateAheadOfTime(isolate);
|
||||
TypeofStub::GenerateAheadOfTime(isolate);
|
||||
}
|
||||
|
||||
|
||||
|
@ -4716,10 +4716,13 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
|
||||
|
||||
case Token::TYPEOF: {
|
||||
Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)");
|
||||
{ StackValueContext context(this);
|
||||
{
|
||||
AccumulatorValueContext context(this);
|
||||
VisitForTypeofValue(expr->expression());
|
||||
}
|
||||
__ CallRuntime(Runtime::kTypeof, 1);
|
||||
__ mov(ebx, eax);
|
||||
TypeofStub typeof_stub(isolate());
|
||||
__ CallStub(&typeof_stub);
|
||||
context()->Plug(eax);
|
||||
break;
|
||||
}
|
||||
|
@ -86,6 +86,12 @@ void NumberToStringDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
}
|
||||
|
||||
|
||||
void TypeofDescriptor::Initialize(CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {esi, ebx};
|
||||
data->Initialize(arraysize(registers), registers, NULL);
|
||||
}
|
||||
|
||||
|
||||
void FastCloneShallowArrayDescriptor::Initialize(
|
||||
CallInterfaceDescriptorData* data) {
|
||||
Register registers[] = {esi, eax, ebx, ecx};
|
||||
|
@ -5992,9 +5992,16 @@ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
|
||||
|
||||
void LCodeGen::DoTypeof(LTypeof* instr) {
|
||||
DCHECK(ToRegister(instr->context()).is(esi));
|
||||
LOperand* input = instr->value();
|
||||
EmitPushTaggedOperand(input);
|
||||
CallRuntime(Runtime::kTypeof, 1, instr);
|
||||
DCHECK(ToRegister(instr->value()).is(ebx));
|
||||
Label end, do_call;
|
||||
Register value_register = ToRegister(instr->value());
|
||||
__ JumpIfNotSmi(value_register, &do_call);
|
||||
__ mov(eax, Immediate(isolate()->factory()->number_string()));
|
||||
__ jmp(&end);
|
||||
__ bind(&do_call);
|
||||
TypeofStub stub(isolate());
|
||||
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
|
||||
__ bind(&end);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2615,7 +2615,7 @@ LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
|
||||
|
||||
LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
|
||||
LOperand* context = UseFixed(instr->context(), esi);
|
||||
LOperand* value = UseAtStart(instr->value());
|
||||
LOperand* value = UseFixed(instr->value(), ebx);
|
||||
LTypeof* result = new(zone()) LTypeof(context, value);
|
||||
return MarkAsCall(DefineFixed(result, eax), instr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user