V8 Project
value-numbering-reducer.cc
Go to the documentation of this file.
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 #include "src/compiler/node.h"
8 
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12 
13 namespace {
14 
15 size_t HashCode(Node* node) { return node->op()->HashCode(); }
16 
17 
18 bool Equals(Node* a, Node* b) {
19  DCHECK_NOT_NULL(a);
20  DCHECK_NOT_NULL(b);
21  DCHECK_NOT_NULL(a->op());
22  DCHECK_NOT_NULL(b->op());
23  if (!a->op()->Equals(b->op())) return false;
24  if (a->InputCount() != b->InputCount()) return false;
25  for (int j = 0; j < a->InputCount(); ++j) {
26  DCHECK_NOT_NULL(a->InputAt(j));
27  DCHECK_NOT_NULL(b->InputAt(j));
28  if (a->InputAt(j)->id() != b->InputAt(j)->id()) return false;
29  }
30  return true;
31 }
32 
33 } // namespace
34 
35 
36 class ValueNumberingReducer::Entry FINAL : public ZoneObject {
37  public:
38  Entry(Node* node, Entry* next) : node_(node), next_(next) {}
39 
40  Node* node() const { return node_; }
41  Entry* next() const { return next_; }
42 
43  private:
44  Node* node_;
45  Entry* next_;
46 };
47 
48 
49 ValueNumberingReducer::ValueNumberingReducer(Zone* zone) : zone_(zone) {
50  for (size_t i = 0; i < arraysize(buckets_); ++i) {
51  buckets_[i] = NULL;
52  }
53 }
54 
55 
56 ValueNumberingReducer::~ValueNumberingReducer() {}
57 
58 
59 Reduction ValueNumberingReducer::Reduce(Node* node) {
60  Entry** head = &buckets_[HashCode(node) % arraysize(buckets_)];
61  for (Entry* entry = *head; entry; entry = entry->next()) {
62  if (entry->node()->IsDead()) continue;
63  if (entry->node() == node) return NoChange();
64  if (Equals(node, entry->node())) {
65  return Replace(entry->node());
66  }
67  }
68  *head = new (zone()) Entry(node, *head);
69  return NoChange();
70 }
71 
72 } // namespace compiler
73 } // namespace internal
74 } // namespace v8
Source to read snapshot and builtins files from.
Definition: lithium-arm.h:372
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL
#define DCHECK_NOT_NULL(p)
Definition: logging.h:213
#define arraysize(array)
Definition: macros.h:86
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20