| Index: src/compiler/js-typed-lowering.cc
|
| diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
|
| index e45bcaee4b616e085a014674b1a7a513c0a8a960..6272a6e717a333cb7836ad3cb174fcf2c0748ea6 100644
|
| --- a/src/compiler/js-typed-lowering.cc
|
| +++ b/src/compiler/js-typed-lowering.cc
|
| @@ -430,8 +430,6 @@ JSTypedLowering::JSTypedLowering(Editor* editor,
|
| dependencies_(dependencies),
|
| flags_(flags),
|
| jsgraph_(jsgraph),
|
| - true_type_(Type::Constant(factory()->true_value(), graph()->zone())),
|
| - false_type_(Type::Constant(factory()->false_value(), graph()->zone())),
|
| the_hole_type_(
|
| Type::Constant(factory()->the_hole_value(), graph()->zone())),
|
| type_cache_(TypeCache::Get()) {
|
| @@ -1927,194 +1925,7 @@ Reduction JSTypedLowering::ReduceJSGeneratorRestoreRegister(Node* node) {
|
| return Changed(element);
|
| }
|
|
|
| -Reduction JSTypedLowering::ReducePhi(Node* node) {
|
| - // Try to narrow the type of the Phi {node}, which might be more precise now
|
| - // after lowering based on types, i.e. a SpeculativeNumberAdd has a more
|
| - // precise type than the JSAdd that was in the graph when the Typer was run.
|
| - DCHECK_EQ(IrOpcode::kPhi, node->opcode());
|
| - int arity = node->op()->ValueInputCount();
|
| - Type* type = NodeProperties::GetType(node->InputAt(0));
|
| - for (int i = 1; i < arity; ++i) {
|
| - type = Type::Union(type, NodeProperties::GetType(node->InputAt(i)),
|
| - graph()->zone());
|
| - }
|
| - Type* const node_type = NodeProperties::GetType(node);
|
| - if (!node_type->Is(type)) {
|
| - type = Type::Intersect(node_type, type, graph()->zone());
|
| - NodeProperties::SetType(node, type);
|
| - return Changed(node);
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| -Reduction JSTypedLowering::ReduceSelect(Node* node) {
|
| - DCHECK_EQ(IrOpcode::kSelect, node->opcode());
|
| - Node* const condition = NodeProperties::GetValueInput(node, 0);
|
| - Type* const condition_type = NodeProperties::GetType(condition);
|
| - Node* const vtrue = NodeProperties::GetValueInput(node, 1);
|
| - Type* const vtrue_type = NodeProperties::GetType(vtrue);
|
| - Node* const vfalse = NodeProperties::GetValueInput(node, 2);
|
| - Type* const vfalse_type = NodeProperties::GetType(vfalse);
|
| - if (condition_type->Is(true_type_)) {
|
| - // Select(condition:true, vtrue, vfalse) => vtrue
|
| - return Replace(vtrue);
|
| - }
|
| - if (condition_type->Is(false_type_)) {
|
| - // Select(condition:false, vtrue, vfalse) => vfalse
|
| - return Replace(vfalse);
|
| - }
|
| - if (vtrue_type->Is(true_type_) && vfalse_type->Is(false_type_)) {
|
| - // Select(condition, vtrue:true, vfalse:false) => condition
|
| - return Replace(condition);
|
| - }
|
| - if (vtrue_type->Is(false_type_) && vfalse_type->Is(true_type_)) {
|
| - // Select(condition, vtrue:false, vfalse:true) => BooleanNot(condition)
|
| - node->TrimInputCount(1);
|
| - NodeProperties::ChangeOp(node, simplified()->BooleanNot());
|
| - return Changed(node);
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| -namespace {
|
| -
|
| -MaybeHandle<Map> GetStableMapFromObjectType(Type* object_type) {
|
| - if (object_type->IsConstant() &&
|
| - object_type->AsConstant()->Value()->IsHeapObject()) {
|
| - Handle<Map> object_map(
|
| - Handle<HeapObject>::cast(object_type->AsConstant()->Value())->map());
|
| - if (object_map->is_stable()) return object_map;
|
| - } else if (object_type->IsClass()) {
|
| - Handle<Map> object_map = object_type->AsClass()->Map();
|
| - if (object_map->is_stable()) return object_map;
|
| - }
|
| - return MaybeHandle<Map>();
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| -Reduction JSTypedLowering::ReduceCheckMaps(Node* node) {
|
| - // TODO(bmeurer): Find a better home for this thing!
|
| - // The CheckMaps(o, ...map...) can be eliminated if map is stable and
|
| - // either
|
| - // (a) o has type Constant(object) and map == object->map, or
|
| - // (b) o has type Class(map),
|
| - // and either
|
| - // (1) map cannot transition further, or
|
| - // (2) we can add a code dependency on the stability of map
|
| - // (to guard the Constant type information).
|
| - Node* const object = NodeProperties::GetValueInput(node, 0);
|
| - Type* const object_type = NodeProperties::GetType(object);
|
| - Node* const effect = NodeProperties::GetEffectInput(node);
|
| - Handle<Map> object_map;
|
| - if (GetStableMapFromObjectType(object_type).ToHandle(&object_map)) {
|
| - for (int i = 1; i < node->op()->ValueInputCount(); ++i) {
|
| - Node* const map = NodeProperties::GetValueInput(node, i);
|
| - Type* const map_type = NodeProperties::GetType(map);
|
| - if (map_type->IsConstant() &&
|
| - map_type->AsConstant()->Value().is_identical_to(object_map)) {
|
| - if (object_map->CanTransition()) {
|
| - DCHECK(flags() & kDeoptimizationEnabled);
|
| - dependencies()->AssumeMapStable(object_map);
|
| - }
|
| - return Replace(effect);
|
| - }
|
| - }
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| -Reduction JSTypedLowering::ReduceCheckString(Node* node) {
|
| - // TODO(bmeurer): Find a better home for this thing!
|
| - Node* const input = NodeProperties::GetValueInput(node, 0);
|
| - Type* const input_type = NodeProperties::GetType(input);
|
| - if (input_type->Is(Type::String())) {
|
| - ReplaceWithValue(node, input);
|
| - return Replace(input);
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| -Reduction JSTypedLowering::ReduceLoadField(Node* node) {
|
| - // TODO(bmeurer): Find a better home for this thing!
|
| - Node* const object = NodeProperties::GetValueInput(node, 0);
|
| - Type* const object_type = NodeProperties::GetType(object);
|
| - FieldAccess const& access = FieldAccessOf(node->op());
|
| - if (access.base_is_tagged == kTaggedBase &&
|
| - access.offset == HeapObject::kMapOffset) {
|
| - // We can replace LoadField[Map](o) with map if is stable and either
|
| - // (a) o has type Constant(object) and map == object->map, or
|
| - // (b) o has type Class(map),
|
| - // and either
|
| - // (1) map cannot transition further, or
|
| - // (2) deoptimization is enabled and we can add a code dependency on the
|
| - // stability of map (to guard the Constant type information).
|
| - Handle<Map> object_map;
|
| - if (GetStableMapFromObjectType(object_type).ToHandle(&object_map)) {
|
| - if (object_map->CanTransition()) {
|
| - if (flags() & kDeoptimizationEnabled) {
|
| - dependencies()->AssumeMapStable(object_map);
|
| - } else {
|
| - return NoChange();
|
| - }
|
| - }
|
| - Node* const value = jsgraph()->HeapConstant(object_map);
|
| - ReplaceWithValue(node, value);
|
| - return Replace(value);
|
| - }
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| -Reduction JSTypedLowering::ReduceNumberRoundop(Node* node) {
|
| - // TODO(bmeurer): Find a better home for this thing!
|
| - Node* const input = NodeProperties::GetValueInput(node, 0);
|
| - Type* const input_type = NodeProperties::GetType(input);
|
| - if (input_type->Is(type_cache_.kIntegerOrMinusZeroOrNaN)) {
|
| - return Replace(input);
|
| - }
|
| - return NoChange();
|
| -}
|
| -
|
| Reduction JSTypedLowering::Reduce(Node* node) {
|
| - // Check if the output type is a singleton. In that case we already know the
|
| - // result value and can simply replace the node if it's eliminable.
|
| - if (!NodeProperties::IsConstant(node) && NodeProperties::IsTyped(node) &&
|
| - node->op()->HasProperty(Operator::kEliminatable)) {
|
| - // We can only constant-fold nodes here, that are known to not cause any
|
| - // side-effect, may it be a JavaScript observable side-effect or a possible
|
| - // eager deoptimization exit (i.e. {node} has an operator that doesn't have
|
| - // the Operator::kNoDeopt property).
|
| - Type* upper = NodeProperties::GetType(node);
|
| - if (upper->IsInhabited()) {
|
| - if (upper->IsConstant()) {
|
| - Node* replacement = jsgraph()->Constant(upper->AsConstant()->Value());
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - } else if (upper->Is(Type::MinusZero())) {
|
| - Node* replacement = jsgraph()->Constant(factory()->minus_zero_value());
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - } else if (upper->Is(Type::NaN())) {
|
| - Node* replacement = jsgraph()->NaNConstant();
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - } else if (upper->Is(Type::Null())) {
|
| - Node* replacement = jsgraph()->NullConstant();
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - } else if (upper->Is(Type::PlainNumber()) &&
|
| - upper->Min() == upper->Max()) {
|
| - Node* replacement = jsgraph()->Constant(upper->Min());
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - } else if (upper->Is(Type::Undefined())) {
|
| - Node* replacement = jsgraph()->UndefinedConstant();
|
| - ReplaceWithValue(node, replacement);
|
| - return Changed(replacement);
|
| - }
|
| - }
|
| - }
|
| switch (node->opcode()) {
|
| case IrOpcode::kJSEqual:
|
| return ReduceJSEqual(node, false);
|
| @@ -2187,21 +1998,6 @@ Reduction JSTypedLowering::Reduce(Node* node) {
|
| return ReduceJSGeneratorRestoreContinuation(node);
|
| case IrOpcode::kJSGeneratorRestoreRegister:
|
| return ReduceJSGeneratorRestoreRegister(node);
|
| - case IrOpcode::kPhi:
|
| - return ReducePhi(node);
|
| - case IrOpcode::kSelect:
|
| - return ReduceSelect(node);
|
| - case IrOpcode::kCheckMaps:
|
| - return ReduceCheckMaps(node);
|
| - case IrOpcode::kCheckString:
|
| - return ReduceCheckString(node);
|
| - case IrOpcode::kNumberCeil:
|
| - case IrOpcode::kNumberFloor:
|
| - case IrOpcode::kNumberRound:
|
| - case IrOpcode::kNumberTrunc:
|
| - return ReduceNumberRoundop(node);
|
| - case IrOpcode::kLoadField:
|
| - return ReduceLoadField(node);
|
| default:
|
| break;
|
| }
|
|
|