Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: src/compiler/js-context-specialization.cc

Issue 552653003: [turbofan] Fix the node matchers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/generic-node-inl.h" 6 #include "src/compiler/generic-node-inl.h"
7 #include "src/compiler/graph-inl.h" 7 #include "src/compiler/graph-inl.h"
8 #include "src/compiler/js-context-specialization.h" 8 #include "src/compiler/js-context-specialization.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "src/compiler/node-aux-data-inl.h" 10 #include "src/compiler/node-aux-data-inl.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 jsgraph_->Constant(info_->context())); 54 jsgraph_->Constant(info_->context()));
55 55
56 ContextSpecializationVisitor visitor(this); 56 ContextSpecializationVisitor visitor(this);
57 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor); 57 jsgraph_->graph()->VisitNodeInputsFromEnd(&visitor);
58 } 58 }
59 59
60 60
61 Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) { 61 Reduction JSContextSpecializer::ReduceJSLoadContext(Node* node) {
62 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode()); 62 DCHECK_EQ(IrOpcode::kJSLoadContext, node->opcode());
63 63
64 ValueMatcher<Handle<Context> > match(NodeProperties::GetValueInput(node, 0)); 64 HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0));
65 // If the context is not constant, no reduction can occur. 65 // If the context is not constant, no reduction can occur.
66 if (!match.HasValue()) { 66 if (!m.HasValue()) {
67 return Reducer::NoChange(); 67 return Reducer::NoChange();
68 } 68 }
69 69
70 ContextAccess access = OpParameter<ContextAccess>(node); 70 ContextAccess access = OpParameter<ContextAccess>(node);
71 71
72 // Find the right parent context. 72 // Find the right parent context.
73 Context* context = *match.Value(); 73 Context* context = *m.Value().handle();
74 for (int i = access.depth(); i > 0; --i) { 74 for (int i = access.depth(); i > 0; --i) {
75 context = context->previous(); 75 context = context->previous();
76 } 76 }
77 77
78 // If the access itself is mutable, only fold-in the parent. 78 // If the access itself is mutable, only fold-in the parent.
79 if (!access.immutable()) { 79 if (!access.immutable()) {
80 // The access does not have to look up a parent, nothing to fold. 80 // The access does not have to look up a parent, nothing to fold.
81 if (access.depth() == 0) { 81 if (access.depth() == 0) {
82 return Reducer::NoChange(); 82 return Reducer::NoChange();
83 } 83 }
(...skipping 18 matching lines...) Expand all
102 // Success. The context load can be replaced with the constant. 102 // Success. The context load can be replaced with the constant.
103 // TODO(titzer): record the specialization for sharing code across multiple 103 // TODO(titzer): record the specialization for sharing code across multiple
104 // contexts that have the same value in the corresponding context slot. 104 // contexts that have the same value in the corresponding context slot.
105 return Reducer::Replace(jsgraph_->Constant(value)); 105 return Reducer::Replace(jsgraph_->Constant(value));
106 } 106 }
107 107
108 108
109 Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) { 109 Reduction JSContextSpecializer::ReduceJSStoreContext(Node* node) {
110 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode()); 110 DCHECK_EQ(IrOpcode::kJSStoreContext, node->opcode());
111 111
112 ValueMatcher<Handle<Context> > match(NodeProperties::GetValueInput(node, 0)); 112 HeapObjectMatcher<Context> m(NodeProperties::GetValueInput(node, 0));
113 // If the context is not constant, no reduction can occur. 113 // If the context is not constant, no reduction can occur.
114 if (!match.HasValue()) { 114 if (!m.HasValue()) {
115 return Reducer::NoChange(); 115 return Reducer::NoChange();
116 } 116 }
117 117
118 ContextAccess access = OpParameter<ContextAccess>(node); 118 ContextAccess access = OpParameter<ContextAccess>(node);
119 119
120 // The access does not have to look up a parent, nothing to fold. 120 // The access does not have to look up a parent, nothing to fold.
121 if (access.depth() == 0) { 121 if (access.depth() == 0) {
122 return Reducer::NoChange(); 122 return Reducer::NoChange();
123 } 123 }
124 124
125 // Find the right parent context. 125 // Find the right parent context.
126 Context* context = *match.Value(); 126 Context* context = *m.Value().handle();
127 for (int i = access.depth(); i > 0; --i) { 127 for (int i = access.depth(); i > 0; --i) {
128 context = context->previous(); 128 context = context->previous();
129 } 129 }
130 130
131 Operator* op = jsgraph_->javascript()->StoreContext(0, access.index()); 131 Operator* op = jsgraph_->javascript()->StoreContext(0, access.index());
132 node->set_op(op); 132 node->set_op(op);
133 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate()); 133 Handle<Object> new_context_handle = Handle<Object>(context, info_->isolate());
134 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle)); 134 node->ReplaceInput(0, jsgraph_->Constant(new_context_handle));
135 135
136 return Reducer::Changed(node); 136 return Reducer::Changed(node);
137 } 137 }
138 } 138 }
139 } 139 }
140 } // namespace v8::internal::compiler 140 } // namespace v8::internal::compiler
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector-impl.h ('k') | src/compiler/js-inlining.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698