Index: src/compiler/js-builtin-reducer.cc |
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc |
index 51772fcc802390a4e83feeb2473fe014b878c6f8..16c626792441bcc5ae23b536a1a99a41522cb09b 100644 |
--- a/src/compiler/js-builtin-reducer.cc |
+++ b/src/compiler/js-builtin-reducer.cc |
@@ -314,6 +314,67 @@ Reduction JSBuiltinReducer::ReduceArrayPush(Node* node) { |
return NoChange(); |
} |
+namespace { |
+ |
+bool HasInstanceTypeWitness(Node* receiver, Node* effect, |
+ InstanceType instance_type) { |
+ for (Node* dominator = effect;;) { |
+ if (dominator->opcode() == IrOpcode::kCheckMaps && |
+ dominator->InputAt(0) == receiver) { |
+ // Check if all maps have the given {instance_type}. |
+ for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { |
+ Node* const map = NodeProperties::GetValueInput(dominator, i); |
+ Type* const map_type = NodeProperties::GetType(map); |
+ if (!map_type->IsConstant()) return false; |
+ Handle<Map> const map_value = |
+ Handle<Map>::cast(map_type->AsConstant()->Value()); |
+ if (map_value->instance_type() != instance_type) return false; |
+ } |
+ return true; |
+ } |
+ switch (dominator->opcode()) { |
+ case IrOpcode::kStoreField: { |
+ FieldAccess const& access = FieldAccessOf(dominator->op()); |
+ if (access.base_is_tagged == kTaggedBase && |
+ access.offset == HeapObject::kMapOffset) { |
+ return false; |
+ } |
+ break; |
+ } |
+ case IrOpcode::kStoreElement: |
+ case IrOpcode::kStoreTypedElement: |
+ break; |
+ default: { |
+ DCHECK_EQ(1, dominator->op()->EffectOutputCount()); |
+ if (dominator->op()->EffectInputCount() != 1 || |
+ !dominator->op()->HasProperty(Operator::kNoWrite)) { |
+ // Didn't find any appropriate CheckMaps node. |
+ return false; |
+ } |
+ break; |
+ } |
+ } |
+ dominator = NodeProperties::GetEffectInput(dominator); |
+ } |
+} |
+ |
+} // namespace |
+ |
+// ES6 section 20.3.4.10 Date.prototype.getTime ( ) |
+Reduction JSBuiltinReducer::ReduceDateGetTime(Node* node) { |
+ Node* receiver = NodeProperties::GetValueInput(node, 1); |
+ Node* effect = NodeProperties::GetEffectInput(node); |
+ Node* control = NodeProperties::GetControlInput(node); |
+ if (HasInstanceTypeWitness(receiver, effect, JS_DATE_TYPE)) { |
+ Node* value = effect = graph()->NewNode( |
+ simplified()->LoadField(AccessBuilder::ForJSDateValue()), receiver, |
+ effect, control); |
+ ReplaceWithValue(node, value, effect, control); |
+ return Replace(value); |
+ } |
+ return NoChange(); |
+} |
+ |
// ES6 section 20.2.2.1 Math.abs ( x ) |
Reduction JSBuiltinReducer::ReduceMathAbs(Node* node) { |
JSCallReduction r(node); |
@@ -878,51 +939,6 @@ Reduction JSBuiltinReducer::ReduceStringCharCodeAt(Node* node) { |
return NoChange(); |
} |
-namespace { |
- |
-bool HasInstanceTypeWitness(Node* receiver, Node* effect, |
- InstanceType instance_type) { |
- for (Node* dominator = effect;;) { |
- if (dominator->opcode() == IrOpcode::kCheckMaps && |
- dominator->InputAt(0) == receiver) { |
- // Check if all maps have the given {instance_type}. |
- for (int i = 1; i < dominator->op()->ValueInputCount(); ++i) { |
- Node* const map = NodeProperties::GetValueInput(dominator, i); |
- Type* const map_type = NodeProperties::GetType(map); |
- if (!map_type->IsConstant()) return false; |
- Handle<Map> const map_value = |
- Handle<Map>::cast(map_type->AsConstant()->Value()); |
- if (map_value->instance_type() != instance_type) return false; |
- } |
- return true; |
- } |
- switch (dominator->opcode()) { |
- case IrOpcode::kStoreField: { |
- FieldAccess const& access = FieldAccessOf(dominator->op()); |
- if (access.base_is_tagged == kTaggedBase && |
- access.offset == HeapObject::kMapOffset) { |
- return false; |
- } |
- break; |
- } |
- case IrOpcode::kStoreElement: |
- break; |
- default: { |
- DCHECK_EQ(1, dominator->op()->EffectOutputCount()); |
- if (dominator->op()->EffectInputCount() != 1 || |
- !dominator->op()->HasProperty(Operator::kNoWrite)) { |
- // Didn't find any appropriate CheckMaps node. |
- return false; |
- } |
- break; |
- } |
- } |
- dominator = NodeProperties::GetEffectInput(dominator); |
- } |
-} |
- |
-} // namespace |
- |
Reduction JSBuiltinReducer::ReduceArrayBufferViewAccessor( |
Node* node, InstanceType instance_type, FieldAccess const& access) { |
Node* receiver = NodeProperties::GetValueInput(node, 1); |
@@ -963,6 +979,8 @@ Reduction JSBuiltinReducer::Reduce(Node* node) { |
return ReduceArrayPop(node); |
case kArrayPush: |
return ReduceArrayPush(node); |
+ case kDateGetTime: |
+ return ReduceDateGetTime(node); |
case kMathAbs: |
reduction = ReduceMathAbs(node); |
break; |