port
7798548a8f2ef14e8320cc42effa86f0eb8e4294 (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}
BinaryOpICStub::GenerateAheadOfTime(isolate);
BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate);
StoreFastElementStub::GenerateAheadOfTime(isolate);
+ TypeofStub::GenerateAheadOfTime(isolate);
}
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;
}
}
+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};
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);
}
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);
}