diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 27eb2fc40c..f3d31cec20 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -2144,6 +2144,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) { BinaryOpICStub::GenerateAheadOfTime(isolate); BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate); StoreFastElementStub::GenerateAheadOfTime(isolate); + TypeofStub::GenerateAheadOfTime(isolate); } diff --git a/src/x87/full-codegen-x87.cc b/src/x87/full-codegen-x87.cc index 4f980a766a..877f91c508 100644 --- a/src/x87/full-codegen-x87.cc +++ b/src/x87/full-codegen-x87.cc @@ -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; } diff --git a/src/x87/interface-descriptors-x87.cc b/src/x87/interface-descriptors-x87.cc index 8a6b55e2d3..515d56c659 100644 --- a/src/x87/interface-descriptors-x87.cc +++ b/src/x87/interface-descriptors-x87.cc @@ -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}; diff --git a/src/x87/lithium-codegen-x87.cc b/src/x87/lithium-codegen-x87.cc index f2eb67c3d0..86beee008d 100644 --- a/src/x87/lithium-codegen-x87.cc +++ b/src/x87/lithium-codegen-x87.cc @@ -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); } diff --git a/src/x87/lithium-x87.cc b/src/x87/lithium-x87.cc index 83aa33cec5..1b4aa1a7bb 100644 --- a/src/x87/lithium-x87.cc +++ b/src/x87/lithium-x87.cc @@ -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); }