Reviewers: dstence, michael_dawson, mvstanton,
Description:
PPC: Optimize the typeof operator.
Port 7798548a8f2ef14e8320cc42effa86f0eb8e4294
Original commit message:
typeof was implemented as a runtime function. Calling it in
optimized code with a non-constant input becomes burdensome.
[email protected], [email protected], [email protected]
BUG=
Please review this at https://codereview.chromium.org/1124243002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+24, -6 lines):
M src/ppc/code-stubs-ppc.cc
M src/ppc/full-codegen-ppc.cc
M src/ppc/interface-descriptors-ppc.cc
M src/ppc/lithium-codegen-ppc.cc
M src/ppc/lithium-ppc.cc
Index: src/ppc/code-stubs-ppc.cc
diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc
index
abcad08f35160815a94ecf827a02e46432dbd5b2..2d76856077667af2b084df8f9a82f17f7305edab
100644
--- a/src/ppc/code-stubs-ppc.cc
+++ b/src/ppc/code-stubs-ppc.cc
@@ -971,6 +971,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate*
isolate) {
RestoreRegistersStateStub::GenerateAheadOfTime(isolate);
BinaryOpICWithAllocationSiteStub::GenerateAheadOfTime(isolate);
StoreFastElementStub::GenerateAheadOfTime(isolate);
+ TypeofStub::GenerateAheadOfTime(isolate);
}
Index: src/ppc/full-codegen-ppc.cc
diff --git a/src/ppc/full-codegen-ppc.cc b/src/ppc/full-codegen-ppc.cc
index
27de1dcecb39cabe0595b73a8e6b16c8a872f7e5..39d6dae918abcad8d62e61f5fc55883a3f214722
100644
--- a/src/ppc/full-codegen-ppc.cc
+++ b/src/ppc/full-codegen-ppc.cc
@@ -4811,10 +4811,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;
}
Index: src/ppc/interface-descriptors-ppc.cc
diff --git a/src/ppc/interface-descriptors-ppc.cc
b/src/ppc/interface-descriptors-ppc.cc
index
0fe70f27317afdcb1cac0774885088e04a0bdf83..f42da49202a988cbca7f372a7ee678b5412a5597
100644
--- a/src/ppc/interface-descriptors-ppc.cc
+++ b/src/ppc/interface-descriptors-ppc.cc
@@ -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};
Index: src/ppc/lithium-codegen-ppc.cc
diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc
index
2ddb658c35c6c765b35fe31c4afccf2d88f7ed74..2977da5ebc79a8d9fd04b5e1f55363ff8faeda6d
100644
--- a/src/ppc/lithium-codegen-ppc.cc
+++ b/src/ppc/lithium-codegen-ppc.cc
@@ -5823,9 +5823,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);
}
Index: src/ppc/lithium-ppc.cc
diff --git a/src/ppc/lithium-ppc.cc b/src/ppc/lithium-ppc.cc
index
fd2cc44cec08aaebfa8aa094f146e08c017acecf..db6cfb20515ac9be56ccf8ac86247a4f543c0ccc
100644
--- a/src/ppc/lithium-ppc.cc
+++ b/src/ppc/lithium-ppc.cc
@@ -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);
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.