Reviewers: Benedikt Meurer, dstence, michael_dawson,
Description:
PPC: [date] Refactor the %_DateField intrinsic to be optimizable.
Port e4782a9b468258344d512a5f7dadbf1584928849
Original commit message:
Previously the %_DateField intrinsic would also check the object and
throw an exception if you happen to pass something that is not a valid
JSDate, which (a) violates our policy for instrinsics and (b) is hard to
optimize in TurboFan (even Crankshaft has a hard time, but there we will
never inline the relevant builtins, so it doesn't show up). The throwing
part is now a separate intrinsics %_ThrowIfNotADate that throws an
exception in full codegen and deoptimizes in Crankshaft, which means the
code for the current use cases is roughly the same (modulo some register
renamings/gap moves).
[email protected], [email protected], [email protected]
BUG=
Please review this at https://codereview.chromium.org/1170463002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+27, -18 lines):
M src/ppc/full-codegen-ppc.cc
M src/ppc/lithium-codegen-ppc.cc
M src/ppc/lithium-ppc.cc
Index: src/ppc/full-codegen-ppc.cc
diff --git a/src/ppc/full-codegen-ppc.cc b/src/ppc/full-codegen-ppc.cc
index
78132a06ccfc0050543db143d1e9a9d2b29a05b8..21345e406786aa030028cf39b3bdf7b1dd87385c
100644
--- a/src/ppc/full-codegen-ppc.cc
+++ b/src/ppc/full-codegen-ppc.cc
@@ -3897,6 +3897,28 @@ void FullCodeGenerator::EmitValueOf(CallRuntime*
expr) {
}
+void FullCodeGenerator::EmitThrowIfNotADate(CallRuntime* expr) {
+ ZoneList<Expression*>* args = expr->arguments();
+ DCHECK_EQ(1, args->length());
+
+ VisitForAccumulatorValue(args->at(0)); // Load the object.
+
+ Label done, not_date_object;
+ Register object = r3;
+ Register result = r3;
+ Register scratch0 = r4;
+
+ __ JumpIfSmi(object, ¬_date_object);
+ __ CompareObjectType(object, scratch0, scratch0, JS_DATE_TYPE);
+ __ beq(&done);
+ __ bind(¬_date_object);
+ __ CallRuntime(Runtime::kThrowNotDateError, 0);
+
+ __ bind(&done);
+ context()->Plug(result);
+}
+
+
void FullCodeGenerator::EmitDateField(CallRuntime* expr) {
ZoneList<Expression*>* args = expr->arguments();
DCHECK(args->length() == 2);
@@ -3905,20 +3927,15 @@ void FullCodeGenerator::EmitDateField(CallRuntime*
expr) {
VisitForAccumulatorValue(args->at(0)); // Load the object.
- Label runtime, done, not_date_object;
Register object = r3;
Register result = r3;
Register scratch0 = r11;
Register scratch1 = r4;
- __ JumpIfSmi(object, ¬_date_object);
- __ CompareObjectType(object, scratch1, scratch1, JS_DATE_TYPE);
- __ bne(¬_date_object);
-
if (index->value() == 0) {
__ LoadP(result, FieldMemOperand(object, JSDate::kValueOffset));
- __ b(&done);
} else {
+ Label runtime, done;
if (index->value() < JSDate::kFirstUncachedField) {
ExternalReference stamp =
ExternalReference::date_cache_stamp(isolate());
__ mov(scratch1, Operand(stamp));
@@ -3936,13 +3953,10 @@ void FullCodeGenerator::EmitDateField(CallRuntime*
expr) {
__ PrepareCallCFunction(2, scratch1);
__ LoadSmiLiteral(r4, index);
__
CallCFunction(ExternalReference::get_date_field_function(isolate()), 2);
- __ b(&done);
+ __ bind(&done);
}
- __ bind(¬_date_object);
- __ CallRuntime(Runtime::kThrowNotDateError, 0);
- __ bind(&done);
- context()->Plug(r3);
+ context()->Plug(result);
}
Index: src/ppc/lithium-codegen-ppc.cc
diff --git a/src/ppc/lithium-codegen-ppc.cc b/src/ppc/lithium-codegen-ppc.cc
index
716486ec4e28d161cafd0bc667d4fa98f9941732..11ea4bd0495bbb8ea76ac5655453c07dfceb7bd1
100644
--- a/src/ppc/lithium-codegen-ppc.cc
+++ b/src/ppc/lithium-codegen-ppc.cc
@@ -1923,20 +1923,15 @@ void LCodeGen::DoDateField(LDateField* instr) {
Register result = ToRegister(instr->result());
Register scratch = ToRegister(instr->temp());
Smi* index = instr->index();
- Label runtime, done;
DCHECK(object.is(result));
DCHECK(object.is(r3));
DCHECK(!scratch.is(scratch0()));
DCHECK(!scratch.is(object));
- __ TestIfSmi(object, r0);
- DeoptimizeIf(eq, instr, Deoptimizer::kSmi, cr0);
- __ CompareObjectType(object, scratch, scratch, JS_DATE_TYPE);
- DeoptimizeIf(ne, instr, Deoptimizer::kNotADateObject);
-
if (index->value() == 0) {
__ LoadP(result, FieldMemOperand(object, JSDate::kValueOffset));
} else {
+ Label runtime, done;
if (index->value() < JSDate::kFirstUncachedField) {
ExternalReference stamp =
ExternalReference::date_cache_stamp(isolate());
__ mov(scratch, Operand(stamp));
Index: src/ppc/lithium-ppc.cc
diff --git a/src/ppc/lithium-ppc.cc b/src/ppc/lithium-ppc.cc
index
ffe3d2c654fd5a3c0aec5d55171332aed50b0d38..35b09f9973a9f15d397fc29b8522a40cfb621f1f
100644
--- a/src/ppc/lithium-ppc.cc
+++ b/src/ppc/lithium-ppc.cc
@@ -1815,7 +1815,7 @@ LInstruction* LChunkBuilder::DoDateField(HDateField*
instr) {
LOperand* object = UseFixed(instr->value(), r3);
LDateField* result =
new (zone()) LDateField(object, FixedTemp(r4), instr->index());
- return MarkAsCall(DefineFixed(result, r3), instr,
CAN_DEOPTIMIZE_EAGERLY);
+ return MarkAsCall(DefineFixed(result, r3), instr,
CANNOT_DEOPTIMIZE_EAGERLY);
}
--
--
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.