Commit 04b0a96b authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: Optimize the typeof operator.

Port 7798548a

Original commit message:
typeof was implemented as a runtime function. Calling it in
optimized code with a non-constant input becomes burdensome.

R=mvstanton@chromium.org, dstence@us.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1124243002

Cr-Commit-Position: refs/heads/master@{#28273}
parent e0ec097b
......@@ -971,6 +971,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate* isolate) {
RestoreRegistersStateStub::GenerateAheadOfTime(isolate);
BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate);
StoreFastElementStub::GenerateAheadOfTime(isolate);
TypeofStub::GenerateAheadOfTime(isolate);
}
......
......@@ -4813,10 +4813,12 @@ 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);
__ mr(r6, r3);
TypeofStub typeof_stub(isolate());
__ CallStub(&typeof_stub);
context()->Plug(r3);
break;
}
......
......@@ -83,6 +83,12 @@ void NumberToStringDescriptor::Initialize(CallInterfaceDescriptorData* data) {
}
void TypeofDescriptor::Initialize(CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6};
data->Initialize(arraysize(registers), registers, NULL);
}
void FastCloneShallowArrayDescriptor::Initialize(
CallInterfaceDescriptorData* data) {
Register registers[] = {cp, r6, r5, r4};
......
......@@ -5824,9 +5824,17 @@ void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
void LCodeGen::DoTypeof(LTypeof* instr) {
Register input = ToRegister(instr->value());
__ push(input);
CallRuntime(Runtime::kTypeof, 1, instr);
DCHECK(ToRegister(instr->value()).is(r6));
DCHECK(ToRegister(instr->result()).is(r3));
Label end, do_call;
Register value_register = ToRegister(instr->value());
__ JumpIfNotSmi(value_register, &do_call);
__ mov(r3, Operand(isolate()->factory()->number_string()));
__ b(&end);
__ bind(&do_call);
TypeofStub stub(isolate());
CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
__ bind(&end);
}
......
......@@ -2500,7 +2500,8 @@ LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
LOperand* context = UseFixed(instr->context(), cp);
LTypeof* result = new (zone()) LTypeof(context, UseFixed(instr->value(), r3));
LOperand* value = UseFixed(instr->value(), r6);
LTypeof* result = new (zone()) LTypeof(context, value);
return MarkAsCall(DefineFixed(result, r3), instr);
}
......
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