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

Side by Side Diff: test/cctest/compiler/test-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
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/js-context-specialization.h" 5 #include "src/compiler/js-context-specialization.h"
6 #include "src/compiler/js-operator.h" 6 #include "src/compiler/js-operator.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties-inl.h" 8 #include "src/compiler/node-properties-inl.h"
9 #include "src/compiler/source-position.h" 9 #include "src/compiler/source-position.h"
10 #include "src/compiler/typer.h" 10 #include "src/compiler/typer.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 { 84 {
85 // Mutable slot, constant context, depth > 0 => fold-in parent context. 85 // Mutable slot, constant context, depth > 0 => fold-in parent context.
86 Node* load = t.NewNode( 86 Node* load = t.NewNode(
87 t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false), 87 t.javascript()->LoadContext(2, Context::GLOBAL_EVAL_FUN_INDEX, false),
88 deep_const_context, deep_const_context, start); 88 deep_const_context, deep_const_context, start);
89 Reduction r = spec.ReduceJSLoadContext(load); 89 Reduction r = spec.ReduceJSLoadContext(load);
90 CHECK(r.Changed()); 90 CHECK(r.Changed());
91 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); 91 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
92 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); 92 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
93 ValueMatcher<Handle<Context> > match(new_context_input); 93 HeapObjectMatcher<Context> match(new_context_input);
94 CHECK_EQ(*native, *match.Value()); 94 CHECK_EQ(*native, *match.Value().handle());
95 ContextAccess access = OpParameter<ContextAccess>(r.replacement()); 95 ContextAccess access = OpParameter<ContextAccess>(r.replacement());
96 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); 96 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index());
97 CHECK_EQ(0, access.depth()); 97 CHECK_EQ(0, access.depth());
98 CHECK_EQ(false, access.immutable()); 98 CHECK_EQ(false, access.immutable());
99 } 99 }
100 100
101 { 101 {
102 // Immutable slot, constant context, depth = 0 => specialize. 102 // Immutable slot, constant context, depth = 0 => specialize.
103 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 103 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
104 const_context, const_context, start); 104 const_context, const_context, start);
105 Reduction r = spec.ReduceJSLoadContext(load); 105 Reduction r = spec.ReduceJSLoadContext(load);
106 CHECK(r.Changed()); 106 CHECK(r.Changed());
107 CHECK(r.replacement() != load); 107 CHECK(r.replacement() != load);
108 108
109 ValueMatcher<Handle<Object> > match(r.replacement()); 109 HeapObjectMatcher<Object> match(r.replacement());
110 CHECK(match.HasValue()); 110 CHECK(match.HasValue());
111 CHECK_EQ(*expected, *match.Value()); 111 CHECK_EQ(*expected, *match.Value().handle());
112 } 112 }
113 113
114 // TODO(titzer): test with other kinds of contexts, e.g. a function context. 114 // TODO(titzer): test with other kinds of contexts, e.g. a function context.
115 // TODO(sigurds): test that loads below create context are not optimized 115 // TODO(sigurds): test that loads below create context are not optimized
116 } 116 }
117 117
118 118
119 TEST(ReduceJSStoreContext) { 119 TEST(ReduceJSStoreContext) {
120 ContextSpecializationTester t; 120 ContextSpecializationTester t;
121 121
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 { 164 {
165 // Mutable slot, constant context, depth > 0 => fold-in parent context. 165 // Mutable slot, constant context, depth > 0 => fold-in parent context.
166 Node* load = t.NewNode( 166 Node* load = t.NewNode(
167 t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX), 167 t.javascript()->StoreContext(2, Context::GLOBAL_EVAL_FUN_INDEX),
168 deep_const_context, deep_const_context, start); 168 deep_const_context, deep_const_context, start);
169 Reduction r = spec.ReduceJSStoreContext(load); 169 Reduction r = spec.ReduceJSStoreContext(load);
170 CHECK(r.Changed()); 170 CHECK(r.Changed());
171 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0); 171 Node* new_context_input = NodeProperties::GetValueInput(r.replacement(), 0);
172 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode()); 172 CHECK_EQ(IrOpcode::kHeapConstant, new_context_input->opcode());
173 ValueMatcher<Handle<Context> > match(new_context_input); 173 HeapObjectMatcher<Context> match(new_context_input);
174 CHECK_EQ(*native, *match.Value()); 174 CHECK_EQ(*native, *match.Value().handle());
175 ContextAccess access = OpParameter<ContextAccess>(r.replacement()); 175 ContextAccess access = OpParameter<ContextAccess>(r.replacement());
176 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index()); 176 CHECK_EQ(Context::GLOBAL_EVAL_FUN_INDEX, access.index());
177 CHECK_EQ(0, access.depth()); 177 CHECK_EQ(0, access.depth());
178 CHECK_EQ(false, access.immutable()); 178 CHECK_EQ(false, access.immutable());
179 } 179 }
180 } 180 }
181 181
182 182
183 // TODO(titzer): factor out common code with effects checking in typed lowering. 183 // TODO(titzer): factor out common code with effects checking in typed lowering.
184 static void CheckEffectInput(Node* effect, Node* use) { 184 static void CheckEffectInput(Node* effect, Node* use) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 // Perform the substitution on the entire graph. 233 // Perform the substitution on the entire graph.
234 spec.SpecializeToContext(); 234 spec.SpecializeToContext();
235 235
236 // Effects should have been forwarded (not replaced with a value). 236 // Effects should have been forwarded (not replaced with a value).
237 CheckEffectInput(effect_in, effect_use); 237 CheckEffectInput(effect_in, effect_use);
238 238
239 // Use of {other_load} should not have been replaced. 239 // Use of {other_load} should not have been replaced.
240 CHECK_EQ(other_load, other_use->InputAt(0)); 240 CHECK_EQ(other_load, other_use->InputAt(0));
241 241
242 Node* replacement = value_use->InputAt(0); 242 Node* replacement = value_use->InputAt(0);
243 ValueMatcher<Handle<Object> > match(replacement); 243 HeapObjectMatcher<Object> match(replacement);
244 CHECK(match.HasValue()); 244 CHECK(match.HasValue());
245 CHECK_EQ(*expected, *match.Value()); 245 CHECK_EQ(*expected, *match.Value().handle());
246 } 246 }
247 // TODO(titzer): clean up above test and test more complicated effects. 247 // TODO(titzer): clean up above test and test more complicated effects.
248 } 248 }
249 249
250 250
251 TEST(SpecializeJSFunction_ToConstant1) { 251 TEST(SpecializeJSFunction_ToConstant1) {
252 FunctionTester T( 252 FunctionTester T(
253 "(function() { var x = 1; function inc(a)" 253 "(function() { var x = 1; function inc(a)"
254 " { return a + x; } return inc; })()"); 254 " { return a + x; } return inc; })()");
255 255
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 { 296 {
297 FunctionTester T( 297 FunctionTester T(
298 "(function() { if (false) { var x = 1; } function inc(a)" 298 "(function() { if (false) { var x = 1; } function inc(a)"
299 " { return a + x; } return inc; })()"); // x is undefined! 299 " { return a + x; } return inc; })()"); // x is undefined!
300 300
301 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 301 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
302 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 302 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
303 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); 303 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN());
304 } 304 }
305 } 305 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-js-constant-cache.cc ('k') | test/cctest/compiler/test-js-typed-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698