node-properties.cc 20.8 KB
Newer Older
1 2 3 4
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
#include "src/compiler/node-properties.h"
6
#include "src/compiler/common-operator.h"
7
#include "src/compiler/graph.h"
8
#include "src/compiler/js-heap-broker.h"
9
#include "src/compiler/js-operator.h"
10
#include "src/compiler/linkage.h"
11
#include "src/compiler/map-inference.h"
12
#include "src/compiler/node-matchers.h"
13
#include "src/compiler/operator-properties.h"
14
#include "src/compiler/simplified-operator.h"
15
#include "src/compiler/verifier.h"
16
#include "src/handles/handles-inl.h"
17
#include "src/objects/objects-inl.h"
18

19 20 21 22
namespace v8 {
namespace internal {
namespace compiler {

23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
// static

// static
bool NodeProperties::IsValueEdge(Edge edge) {
  Node* const node = edge.from();
  return IsInputRange(edge, FirstValueIndex(node),
                      node->op()->ValueInputCount());
}


// static
bool NodeProperties::IsContextEdge(Edge edge) {
  Node* const node = edge.from();
  return IsInputRange(edge, FirstContextIndex(node),
                      OperatorProperties::GetContextInputCount(node->op()));
}


// static
bool NodeProperties::IsFrameStateEdge(Edge edge) {
  Node* const node = edge.from();
  return IsInputRange(edge, FirstFrameStateIndex(node),
                      OperatorProperties::GetFrameStateInputCount(node->op()));
}


// static
bool NodeProperties::IsEffectEdge(Edge edge) {
  Node* const node = edge.from();
  return IsInputRange(edge, FirstEffectIndex(node),
                      node->op()->EffectInputCount());
}


// static
bool NodeProperties::IsControlEdge(Edge edge) {
  Node* const node = edge.from();
  return IsInputRange(edge, FirstControlIndex(node),
                      node->op()->ControlInputCount());
}


svenpanne's avatar
svenpanne committed
65
// static
66
bool NodeProperties::IsExceptionalCall(Node* node, Node** out_exception) {
67
  if (node->op()->HasProperty(Operator::kNoThrow)) return false;
68 69
  for (Edge const edge : node->use_edges()) {
    if (!NodeProperties::IsControlEdge(edge)) continue;
70 71 72 73
    if (edge.from()->opcode() == IrOpcode::kIfException) {
      if (out_exception != nullptr) *out_exception = edge.from();
      return true;
    }
svenpanne's avatar
svenpanne committed
74 75 76 77
  }
  return false;
}

78 79
// static
Node* NodeProperties::FindSuccessfulControlProjection(Node* node) {
80
  CHECK_GT(node->op()->ControlOutputCount(), 0);
81 82 83 84 85 86 87 88 89
  if (node->op()->HasProperty(Operator::kNoThrow)) return node;
  for (Edge const edge : node->use_edges()) {
    if (!NodeProperties::IsControlEdge(edge)) continue;
    if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
      return edge.from();
    }
  }
  return node;
}
svenpanne's avatar
svenpanne committed
90

91 92
// static
void NodeProperties::ReplaceValueInput(Node* node, Node* value, int index) {
93 94
  CHECK_LE(0, index);
  CHECK_LT(index, node->op()->ValueInputCount());
95 96 97 98
  node->ReplaceInput(FirstValueIndex(node) + index, value);
}


99 100 101
// static
void NodeProperties::ReplaceValueInputs(Node* node, Node* value) {
  int value_input_count = node->op()->ValueInputCount();
102
  CHECK_GT(value_input_count, 0);
103 104 105 106 107 108 109
  node->ReplaceInput(0, value);
  while (--value_input_count > 0) {
    node->RemoveInput(value_input_count);
  }
}


110 111
// static
void NodeProperties::ReplaceContextInput(Node* node, Node* context) {
112
  CHECK(OperatorProperties::HasContextInput(node->op()));
113 114 115 116 117
  node->ReplaceInput(FirstContextIndex(node), context);
}


// static
118
void NodeProperties::ReplaceControlInput(Node* node, Node* control, int index) {
119 120
  CHECK_LE(0, index);
  CHECK_LT(index, node->op()->ControlInputCount());
121
  node->ReplaceInput(FirstControlIndex(node) + index, control);
122 123 124 125 126
}


// static
void NodeProperties::ReplaceEffectInput(Node* node, Node* effect, int index) {
127 128
  CHECK_LE(0, index);
  CHECK_LT(index, node->op()->EffectInputCount());
129 130 131 132 133
  return node->ReplaceInput(FirstEffectIndex(node) + index, effect);
}


// static
134
void NodeProperties::ReplaceFrameStateInput(Node* node, Node* frame_state) {
135
  CHECK(OperatorProperties::HasFrameStateInput(node->op()));
136
  node->ReplaceInput(FirstFrameStateIndex(node), frame_state);
137 138 139 140 141 142 143 144
}

// static
void NodeProperties::RemoveNonValueInputs(Node* node) {
  node->TrimInputCount(node->op()->ValueInputCount());
}


145 146 147 148 149 150 151 152 153
// static
void NodeProperties::RemoveValueInputs(Node* node) {
  int value_input_count = node->op()->ValueInputCount();
  while (--value_input_count >= 0) {
    node->RemoveInput(value_input_count);
  }
}


154 155 156
void NodeProperties::MergeControlToEnd(Graph* graph,
                                       CommonOperatorBuilder* common,
                                       Node* node) {
157 158
  graph->end()->AppendInput(graph->zone(), node);
  graph->end()->set_op(common->End(graph->end()->InputCount()));
159 160
}

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
void NodeProperties::RemoveControlFromEnd(Graph* graph,
                                          CommonOperatorBuilder* common,
                                          Node* node) {
  int index_to_remove = -1;
  for (int i = 0; i < graph->end()->op()->ControlInputCount(); i++) {
    int index = NodeProperties::FirstControlIndex(graph->end()) + i;
    if (graph->end()->InputAt(index) == node) {
      index_to_remove = index;
      break;
    }
  }
  CHECK_NE(-1, index_to_remove);
  graph->end()->RemoveInput(index_to_remove);
  graph->end()->set_op(common->End(graph->end()->InputCount()));
}
176

177
// static
178 179
void NodeProperties::ReplaceUses(Node* node, Node* value, Node* effect,
                                 Node* success, Node* exception) {
180
  // Requires distinguishing between value, effect and control edges.
181
  for (Edge edge : node->use_edges()) {
182
    if (IsControlEdge(edge)) {
183 184 185 186 187 188 189
      if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
        DCHECK_NOT_NULL(success);
        edge.UpdateTo(success);
      } else if (edge.from()->opcode() == IrOpcode::kIfException) {
        DCHECK_NOT_NULL(exception);
        edge.UpdateTo(exception);
      } else {
190 191
        DCHECK_NOT_NULL(success);
        edge.UpdateTo(success);
192
      }
193
    } else if (IsEffectEdge(edge)) {
194 195 196
      DCHECK_NOT_NULL(effect);
      edge.UpdateTo(effect);
    } else {
197
      DCHECK_NOT_NULL(value);
198 199 200 201 202 203
      edge.UpdateTo(value);
    }
  }
}


204 205 206
// static
void NodeProperties::ChangeOp(Node* node, const Operator* new_op) {
  node->set_op(new_op);
207
  Verifier::VerifyNode(node);
208 209 210
}


211
// static
212 213
Node* NodeProperties::FindFrameStateBefore(Node* node,
                                           Node* unreachable_sentinel) {
214 215
  Node* effect = NodeProperties::GetEffectInput(node);
  while (effect->opcode() != IrOpcode::kCheckpoint) {
216 217 218 219 220
    if (effect->opcode() == IrOpcode::kDead ||
        effect->opcode() == IrOpcode::kUnreachable) {
      return unreachable_sentinel;
    }
    DCHECK(effect->op()->HasProperty(Operator::kNoWrite));
221 222 223
    DCHECK_EQ(1, effect->op()->EffectInputCount());
    effect = NodeProperties::GetEffectInput(effect);
  }
224
  Node* frame_state = GetFrameStateInput(effect);
225 226 227
  return frame_state;
}

228
// static
229 230 231 232 233 234 235 236 237 238
Node* NodeProperties::FindProjection(Node* node, size_t projection_index) {
  for (auto use : node->uses()) {
    if (use->opcode() == IrOpcode::kProjection &&
        ProjectionIndexOf(use->op()) == projection_index) {
      return use;
    }
  }
  return nullptr;
}

239

240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
// static
void NodeProperties::CollectValueProjections(Node* node, Node** projections,
                                             size_t projection_count) {
#ifdef DEBUG
  for (size_t index = 0; index < projection_count; ++index) {
    DCHECK_NULL(projections[index]);
  }
#endif
  for (Edge const edge : node->use_edges()) {
    if (!IsValueEdge(edge)) continue;
    Node* use = edge.from();
    DCHECK_EQ(IrOpcode::kProjection, use->opcode());
    projections[ProjectionIndexOf(use->op())] = use;
  }
}


257 258 259 260
// static
void NodeProperties::CollectControlProjections(Node* node, Node** projections,
                                               size_t projection_count) {
#ifdef DEBUG
261
  DCHECK_LE(static_cast<int>(projection_count), node->UseCount());
262 263 264
  std::memset(projections, 0, sizeof(*projections) * projection_count);
#endif
  size_t if_value_index = 0;
265 266 267
  for (Edge const edge : node->use_edges()) {
    if (!IsControlEdge(edge)) continue;
    Node* use = edge.from();
268 269 270 271 272 273 274 275 276 277
    size_t index;
    switch (use->opcode()) {
      case IrOpcode::kIfTrue:
        DCHECK_EQ(IrOpcode::kBranch, node->opcode());
        index = 0;
        break;
      case IrOpcode::kIfFalse:
        DCHECK_EQ(IrOpcode::kBranch, node->opcode());
        index = 1;
        break;
278
      case IrOpcode::kIfSuccess:
279
        DCHECK(!node->op()->HasProperty(Operator::kNoThrow));
280 281 282
        index = 0;
        break;
      case IrOpcode::kIfException:
283
        DCHECK(!node->op()->HasProperty(Operator::kNoThrow));
284 285
        index = 1;
        break;
286 287 288 289 290 291 292 293
      case IrOpcode::kIfValue:
        DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
        index = if_value_index++;
        break;
      case IrOpcode::kIfDefault:
        DCHECK_EQ(IrOpcode::kSwitch, node->opcode());
        index = projection_count - 1;
        break;
294 295
      default:
        continue;
296 297 298 299 300 301 302 303 304 305 306 307 308
    }
    DCHECK_LT(if_value_index, projection_count);
    DCHECK_LT(index, projection_count);
    DCHECK_NULL(projections[index]);
    projections[index] = use;
  }
#ifdef DEBUG
  for (size_t index = 0; index < projection_count; ++index) {
    DCHECK_NOT_NULL(projections[index]);
  }
#endif
}

309 310 311 312 313 314 315 316 317 318 319 320 321 322
// static
bool NodeProperties::IsSame(Node* a, Node* b) {
  for (;;) {
    if (a->opcode() == IrOpcode::kCheckHeapObject) {
      a = GetValueInput(a, 0);
      continue;
    }
    if (b->opcode() == IrOpcode::kCheckHeapObject) {
      b = GetValueInput(b, 0);
      continue;
    }
    return a == b;
  }
}
323

324 325 326 327 328 329 330
// static
base::Optional<MapRef> NodeProperties::GetJSCreateMap(JSHeapBroker* broker,
                                                      Node* receiver) {
  DCHECK(receiver->opcode() == IrOpcode::kJSCreate ||
         receiver->opcode() == IrOpcode::kJSCreateArray);
  HeapObjectMatcher mtarget(GetValueInput(receiver, 0));
  HeapObjectMatcher mnewtarget(GetValueInput(receiver, 1));
331
  if (mtarget.HasResolvedValue() && mnewtarget.HasResolvedValue() &&
332 333 334 335
      mnewtarget.Ref(broker).IsJSFunction()) {
    ObjectRef target = mtarget.Ref(broker);
    JSFunctionRef newtarget = mnewtarget.Ref(broker).AsJSFunction();
    if (newtarget.map().has_prototype_slot() && newtarget.has_initial_map()) {
336 337 338 339
      if (!newtarget.serialized()) {
        TRACE_BROKER_MISSING(broker, "initial map on " << newtarget);
        return base::nullopt;
      }
340 341 342 343 344 345 346 347 348 349 350
      MapRef initial_map = newtarget.initial_map();
      if (initial_map.GetConstructor().equals(target)) {
        DCHECK(target.AsJSFunction().map().is_constructor());
        DCHECK(newtarget.map().is_constructor());
        return initial_map;
      }
    }
  }
  return base::nullopt;
}

351
// static
352
NodeProperties::InferMapsResult NodeProperties::InferMapsUnsafe(
353
    JSHeapBroker* broker, Node* receiver, Node* effect,
354
    ZoneHandleSet<Map>* maps_return) {
355
  HeapObjectMatcher m(receiver);
356
  if (m.HasResolvedValue()) {
357
    HeapObjectRef receiver = m.Ref(broker);
358 359 360 361 362 363 364
    // We don't use ICs for the Array.prototype and the Object.prototype
    // because the runtime has to be able to intercept them properly, so
    // we better make sure that TurboFan doesn't outsmart the system here
    // by storing to elements of either prototype directly.
    //
    // TODO(bmeurer): This can be removed once the Array.prototype and
    // Object.prototype have NO_ELEMENTS elements kind.
365 366 367
    if (!receiver.IsJSObject() ||
        !broker->IsArrayOrObjectPrototype(receiver.AsJSObject())) {
      if (receiver.map().is_stable()) {
368 369
        // The {receiver_map} is only reliable when we install a stability
        // code dependency.
370
        *maps_return = ZoneHandleSet<Map>(receiver.map().object());
371
        return kUnreliableMaps;
372
      }
373 374
    }
  }
375
  InferMapsResult result = kReliableMaps;
376 377
  while (true) {
    switch (effect->opcode()) {
378 379 380
      case IrOpcode::kMapGuard: {
        Node* const object = GetValueInput(effect, 0);
        if (IsSame(receiver, object)) {
381
          *maps_return = MapGuardMapsOf(effect->op());
382 383 384 385
          return result;
        }
        break;
      }
386 387 388 389
      case IrOpcode::kCheckMaps: {
        Node* const object = GetValueInput(effect, 0);
        if (IsSame(receiver, object)) {
          *maps_return = CheckMapsParametersOf(effect->op()).maps();
390
          return result;
391 392 393 394 395
        }
        break;
      }
      case IrOpcode::kJSCreate: {
        if (IsSame(receiver, effect)) {
396 397 398 399
          base::Optional<MapRef> initial_map = GetJSCreateMap(broker, receiver);
          if (initial_map.has_value()) {
            *maps_return = ZoneHandleSet<Map>(initial_map->object());
            return result;
400 401
          }
          // We reached the allocation of the {receiver}.
402
          return kNoMaps;
403
        }
404
        result = kUnreliableMaps;  // JSCreate can have side-effect.
405 406
        break;
      }
407 408
      case IrOpcode::kJSCreatePromise: {
        if (IsSame(receiver, effect)) {
409
          *maps_return = ZoneHandleSet<Map>(broker->target_native_context()
410 411 412 413 414 415 416
                                                .promise_function()
                                                .initial_map()
                                                .object());
          return result;
        }
        break;
      }
417 418 419 420 421 422 423 424 425
      case IrOpcode::kStoreField: {
        // We only care about StoreField of maps.
        Node* const object = GetValueInput(effect, 0);
        FieldAccess const& access = FieldAccessOf(effect->op());
        if (access.base_is_tagged == kTaggedBase &&
            access.offset == HeapObject::kMapOffset) {
          if (IsSame(receiver, object)) {
            Node* const value = GetValueInput(effect, 1);
            HeapObjectMatcher m(value);
426
            if (m.HasResolvedValue()) {
427
              *maps_return = ZoneHandleSet<Map>(m.Ref(broker).AsMap().object());
428
              return result;
429 430 431 432
            }
          }
          // Without alias analysis we cannot tell whether this
          // StoreField[map] affects {receiver} or not.
433
          result = kUnreliableMaps;
434 435 436 437 438 439 440 441 442 443
        }
        break;
      }
      case IrOpcode::kJSStoreMessage:
      case IrOpcode::kJSStoreModule:
      case IrOpcode::kStoreElement:
      case IrOpcode::kStoreTypedElement: {
        // These never change the map of objects.
        break;
      }
444 445 446 447 448 449 450
      case IrOpcode::kFinishRegion: {
        // FinishRegion renames the output of allocations, so we need
        // to update the {receiver} that we are looking for, if the
        // {receiver} matches the current {effect}.
        if (IsSame(receiver, effect)) receiver = GetValueInput(effect, 0);
        break;
      }
451 452 453
      case IrOpcode::kEffectPhi: {
        Node* control = GetControlInput(effect);
        if (control->opcode() != IrOpcode::kLoop) {
454 455
          DCHECK(control->opcode() == IrOpcode::kDead ||
                 control->opcode() == IrOpcode::kMerge);
456
          return kNoMaps;
457 458 459 460 461
        }

        // Continue search for receiver map outside the loop. Since operations
        // inside the loop may change the map, the result is unreliable.
        effect = GetEffectInput(effect, 0);
462
        result = kUnreliableMaps;
463 464
        continue;
      }
465 466
      default: {
        DCHECK_EQ(1, effect->op()->EffectOutputCount());
467
        if (effect->op()->EffectInputCount() != 1) {
468
          // Didn't find any appropriate CheckMaps node.
469
          return kNoMaps;
470 471 472 473
        }
        if (!effect->op()->HasProperty(Operator::kNoWrite)) {
          // Without alias/escape analysis we cannot tell whether this
          // {effect} affects {receiver} or not.
474
          result = kUnreliableMaps;
475 476 477 478
        }
        break;
      }
    }
479 480 481

    // Stop walking the effect chain once we hit the definition of
    // the {receiver} along the {effect}s.
482
    if (IsSame(receiver, effect)) return kNoMaps;
483 484

    // Continue with the next {effect}.
485 486 487 488 489
    DCHECK_EQ(1, effect->op()->EffectInputCount());
    effect = NodeProperties::GetEffectInput(effect);
  }
}

490 491 492 493 494 495 496 497 498 499 500 501 502 503
// static
bool NodeProperties::NoObservableSideEffectBetween(Node* effect,
                                                   Node* dominator) {
  while (effect != dominator) {
    if (effect->op()->EffectInputCount() == 1 &&
        effect->op()->properties() & Operator::kNoWrite) {
      effect = NodeProperties::GetEffectInput(effect);
    } else {
      return false;
    }
  }
  return true;
}

504
// static
505
bool NodeProperties::CanBePrimitive(JSHeapBroker* broker, Node* receiver,
506
                                    Node* effect) {
507 508 509 510 511 512 513 514 515 516 517
  switch (receiver->opcode()) {
#define CASE(Opcode) case IrOpcode::k##Opcode:
    JS_CONSTRUCT_OP_LIST(CASE)
    JS_CREATE_OP_LIST(CASE)
#undef CASE
    case IrOpcode::kCheckReceiver:
    case IrOpcode::kConvertReceiver:
    case IrOpcode::kJSGetSuperConstructor:
    case IrOpcode::kJSToObject:
      return false;
    case IrOpcode::kHeapConstant: {
518
      HeapObjectRef value = HeapObjectMatcher(receiver).Ref(broker);
519
      return value.map().IsPrimitiveMap();
520 521
    }
    default: {
522 523 524
      MapInference inference(broker, receiver, effect);
      return !inference.HaveMaps() ||
             !inference.AllOfInstanceTypesAreJSReceiver();
525 526 527 528 529
    }
  }
}

// static
530
bool NodeProperties::CanBeNullOrUndefined(JSHeapBroker* broker, Node* receiver,
531
                                          Node* effect) {
532
  if (CanBePrimitive(broker, receiver, effect)) {
533
    switch (receiver->opcode()) {
534
      case IrOpcode::kCheckInternalizedString:
535
      case IrOpcode::kCheckNumber:
536 537 538
      case IrOpcode::kCheckSmi:
      case IrOpcode::kCheckString:
      case IrOpcode::kCheckSymbol:
539 540 541
      case IrOpcode::kJSToLength:
      case IrOpcode::kJSToName:
      case IrOpcode::kJSToNumber:
542
      case IrOpcode::kJSToNumberConvertBigInt:
543 544
      case IrOpcode::kJSToNumeric:
      case IrOpcode::kJSToString:
545
      case IrOpcode::kToBoolean:
546 547
        return false;
      case IrOpcode::kHeapConstant: {
548
        HeapObjectRef value = HeapObjectMatcher(receiver).Ref(broker);
549 550
        OddballType type = value.map().oddball_type();
        return type == OddballType::kNull || type == OddballType::kUndefined;
551 552 553 554 555 556 557 558
      }
      default:
        return true;
    }
  }
  return false;
}

559 560 561 562 563 564 565 566 567 568 569
// static
Node* NodeProperties::GetOuterContext(Node* node, size_t* depth) {
  Node* context = NodeProperties::GetContextInput(node);
  while (*depth > 0 &&
         IrOpcode::IsContextChainExtendingOpcode(context->opcode())) {
    context = NodeProperties::GetContextInput(context);
    (*depth)--;
  }
  return context;
}

570
// static
571
Type NodeProperties::GetTypeOrAny(const Node* node) {
572 573 574
  return IsTyped(node) ? node->type() : Type::Any();
}

575 576 577 578 579 580 581 582 583
// static
bool NodeProperties::AllValueInputsAreTyped(Node* node) {
  int input_count = node->op()->ValueInputCount();
  for (int index = 0; index < input_count; ++index) {
    if (!IsTyped(GetValueInput(node, index))) return false;
  }
  return true;
}

584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
// static
bool NodeProperties::IsFreshObject(Node* node) {
  if (node->opcode() == IrOpcode::kAllocate ||
      node->opcode() == IrOpcode::kAllocateRaw)
    return true;
#if V8_ENABLE_WEBASSEMBLY
  if (node->opcode() == IrOpcode::kCall) {
    // TODO(manoskouk): Currently, some wasm builtins are called with in
    // CallDescriptor::kCallWasmFunction mode. Make sure this is synced if the
    // calling mechanism is refactored.
    if (CallDescriptorOf(node->op())->kind() !=
        CallDescriptor::kCallBuiltinPointer) {
      return false;
    }
    NumberMatcher matcher(node->InputAt(0));
    if (matcher.HasResolvedValue()) {
600
      Builtin callee = static_cast<Builtin>(matcher.ResolvedValue());
601 602 603
      // Note: Make sure to only add builtins which are guaranteed to return a
      // fresh object. E.g. kWasmAllocateFixedArray may return the canonical
      // empty array, and kWasmAllocateRtt may return a cached rtt.
604 605 606
      return callee == Builtin::kWasmAllocateArray_Uninitialized ||
             callee == Builtin::kWasmAllocateArray_InitNull ||
             callee == Builtin::kWasmAllocateArray_InitZero ||
607 608 609
             callee == Builtin::kWasmAllocateStructWithRtt ||
             callee == Builtin::kWasmAllocateObjectWrapper ||
             callee == Builtin::kWasmAllocatePair;
610 611 612 613 614
    }
  }
#endif  // V8_ENABLE_WEBASSEMBLY
  return false;
}
615 616 617 618 619 620 621 622

// static
bool NodeProperties::IsInputRange(Edge edge, int first, int num) {
  if (num == 0) return false;
  int const index = edge.index();
  return first <= index && index < first + num;
}

623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
// static
size_t NodeProperties::HashCode(Node* node) {
  size_t h = base::hash_combine(node->op()->HashCode(), node->InputCount());
  for (Node* input : node->inputs()) {
    h = base::hash_combine(h, input->id());
  }
  return h;
}

// static
bool NodeProperties::Equals(Node* a, Node* b) {
  DCHECK_NOT_NULL(a);
  DCHECK_NOT_NULL(b);
  DCHECK_NOT_NULL(a->op());
  DCHECK_NOT_NULL(b->op());
  if (!a->op()->Equals(b->op())) return false;
  if (a->InputCount() != b->InputCount()) return false;
  Node::Inputs aInputs = a->inputs();
  Node::Inputs bInputs = b->inputs();

  auto aIt = aInputs.begin();
  auto bIt = bInputs.begin();
  auto aEnd = aInputs.end();

  for (; aIt != aEnd; ++aIt, ++bIt) {
    DCHECK_NOT_NULL(*aIt);
    DCHECK_NOT_NULL(*bIt);
    if ((*aIt)->id() != (*bIt)->id()) return false;
  }
  return true;
}

655 656 657
}  // namespace compiler
}  // namespace internal
}  // namespace v8