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

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

Issue 771713002: [turbofan] Make context specialization into a reducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/compiler/pipeline.cc ('k') | no next file » | 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/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 "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); 196 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
197 const int slot = Context::GLOBAL_OBJECT_INDEX; 197 const int slot = Context::GLOBAL_OBJECT_INDEX;
198 native->set(slot, *expected); 198 native->set(slot, *expected);
199 t.info()->SetContext(native); 199 t.info()->SetContext(native);
200 200
201 Node* const_context = t.jsgraph()->Constant(native); 201 Node* const_context = t.jsgraph()->Constant(native);
202 Node* param_context = t.NewNode(t.common()->Parameter(0), start); 202 Node* param_context = t.NewNode(t.common()->Parameter(0), start);
203 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); 203 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
204 204
205 { 205 {
206 // Check that SpecializeToContext() replaces values and forwards effects 206 // Check that specialization replaces values and forwards effects
207 // correctly, and folds values from constant and non-constant contexts 207 // correctly, and folds values from constant and non-constant contexts
208 Node* effect_in = start; 208 Node* effect_in = start;
209 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 209 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
210 const_context, const_context, effect_in); 210 const_context, const_context, effect_in);
211 211
212 212
213 Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load); 213 Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load);
214 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 214 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
215 param_context, param_context, load); 215 param_context, param_context, load);
216 Node* effect_use = other_load; 216 Node* effect_use = other_load;
217 Node* other_use = 217 Node* other_use =
218 t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load); 218 t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load);
219 219
220 Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use, 220 Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use,
221 param_context, other_load, start); 221 param_context, other_load, start);
222 222
223 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start); 223 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start);
224 Node* end = t.NewNode(t.common()->End(), ret); 224 Node* end = t.NewNode(t.common()->End(), ret);
225 USE(end); 225 USE(end);
226 t.graph()->SetEnd(end); 226 t.graph()->SetEnd(end);
227 227
228 // Double check the above graph is what we expect, or the test is broken. 228 // Double check the above graph is what we expect, or the test is broken.
229 CheckEffectInput(effect_in, load); 229 CheckEffectInput(effect_in, load);
230 CheckEffectInput(load, effect_use); 230 CheckEffectInput(load, effect_use);
231 231
232 // Perform the substitution on the entire graph. 232 // Perform the reduction on the entire graph.
233 spec.SpecializeToContext(); 233 GraphReducer graph_reducer(t.graph(), t.main_zone());
234 graph_reducer.AddReducer(&spec);
235 graph_reducer.ReduceGraph();
234 236
235 // Effects should have been forwarded (not replaced with a value). 237 // Effects should have been forwarded (not replaced with a value).
236 CheckEffectInput(effect_in, effect_use); 238 CheckEffectInput(effect_in, effect_use);
237 239
238 // Use of {other_load} should not have been replaced. 240 // Use of {other_load} should not have been replaced.
239 CHECK_EQ(other_load, other_use->InputAt(0)); 241 CHECK_EQ(other_load, other_use->InputAt(0));
240 242
241 Node* replacement = value_use->InputAt(0); 243 Node* replacement = value_use->InputAt(0);
242 HeapObjectMatcher<Object> match(replacement); 244 HeapObjectMatcher<Object> match(replacement);
243 CHECK(match.HasValue()); 245 CHECK(match.HasValue());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 { 297 {
296 FunctionTester T( 298 FunctionTester T(
297 "(function() { if (false) { var x = 1; } function inc(a)" 299 "(function() { if (false) { var x = 1; } function inc(a)"
298 " { return a + x; } return inc; })()"); // x is undefined! 300 " { return a + x; } return inc; })()"); // x is undefined!
299 301
300 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 302 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
301 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 303 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
302 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); 304 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN());
303 } 305 }
304 } 306 }
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698