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

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

Issue 437183002: Make start node a value input to parameter nodes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add start node as input to parameter nodes. Created 6 years, 4 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/simplified-node-factory.h" 9 #include "src/compiler/simplified-node-factory.h"
10 #include "src/compiler/source-position.h" 10 #include "src/compiler/source-position.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 SimplifiedOperatorBuilder simplified_; 43 SimplifiedOperatorBuilder simplified_;
44 Typer typer_; 44 Typer typer_;
45 JSGraph jsgraph_; 45 JSGraph jsgraph_;
46 CompilationInfo info_; 46 CompilationInfo info_;
47 }; 47 };
48 48
49 49
50 TEST(ReduceJSLoadContext) { 50 TEST(ReduceJSLoadContext) {
51 ContextSpecializationTester t; 51 ContextSpecializationTester t;
52 52
53 Node* start = t.NewNode(t.common()->Start()); 53 Node* start = t.NewNode(t.common()->Start(0));
54 t.graph()->SetStart(start); 54 t.graph()->SetStart(start);
55 55
56 // Make a context and initialize it a bit for this test. 56 // Make a context and initialize it a bit for this test.
57 Handle<Context> native = t.factory()->NewNativeContext(); 57 Handle<Context> native = t.factory()->NewNativeContext();
58 Handle<Context> ctx1 = t.factory()->NewNativeContext(); 58 Handle<Context> ctx1 = t.factory()->NewNativeContext();
59 Handle<Context> ctx2 = t.factory()->NewNativeContext(); 59 Handle<Context> ctx2 = t.factory()->NewNativeContext();
60 ctx2->set_previous(*ctx1); 60 ctx2->set_previous(*ctx1);
61 ctx1->set_previous(*native); 61 ctx1->set_previous(*native);
62 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); 62 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
63 const int slot = Context::GLOBAL_OBJECT_INDEX; 63 const int slot = Context::GLOBAL_OBJECT_INDEX;
64 native->set(slot, *expected); 64 native->set(slot, *expected);
65 65
66 Node* const_context = t.jsgraph()->Constant(native); 66 Node* const_context = t.jsgraph()->Constant(native);
67 Node* param_context = t.NewNode(t.common()->Parameter(0)); 67 Node* param_context = t.NewNode(t.common()->Parameter(0), start);
68 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); 68 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
69 69
70 { 70 {
71 // Mutable slot, constant context, depth = 0 => do nothing. 71 // Mutable slot, constant context, depth = 0 => do nothing.
72 t.info()->SetContext(native); 72 t.info()->SetContext(native);
73 Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false), 73 Node* load = t.NewNode(t.javascript()->LoadContext(0, 0, false),
74 const_context, start, start); 74 const_context, start, start);
75 Reduction r = spec.ReduceJSLoadContext(load); 75 Reduction r = spec.ReduceJSLoadContext(load);
76 CHECK(!r.Changed()); 76 CHECK(!r.Changed());
77 } 77 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 // TODO(titzer): factor out common code with effects checking in typed lowering. 139 // TODO(titzer): factor out common code with effects checking in typed lowering.
140 static void CheckEffectInput(Node* effect, Node* use) { 140 static void CheckEffectInput(Node* effect, Node* use) {
141 CHECK_EQ(effect, NodeProperties::GetEffectInput(use)); 141 CHECK_EQ(effect, NodeProperties::GetEffectInput(use));
142 } 142 }
143 143
144 144
145 TEST(SpecializeToContext) { 145 TEST(SpecializeToContext) {
146 ContextSpecializationTester t; 146 ContextSpecializationTester t;
147 147
148 Node* start = t.NewNode(t.common()->Start()); 148 Node* start = t.NewNode(t.common()->Start(0));
149 t.graph()->SetStart(start); 149 t.graph()->SetStart(start);
150 150
151 // Make a context and initialize it a bit for this test. 151 // Make a context and initialize it a bit for this test.
152 Handle<Context> native = t.factory()->NewNativeContext(); 152 Handle<Context> native = t.factory()->NewNativeContext();
153 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!"); 153 Handle<Object> expected = t.factory()->InternalizeUtf8String("gboy!");
154 const int slot = Context::GLOBAL_OBJECT_INDEX; 154 const int slot = Context::GLOBAL_OBJECT_INDEX;
155 native->set(slot, *expected); 155 native->set(slot, *expected);
156 t.info()->SetContext(native); 156 t.info()->SetContext(native);
157 157
158 Node* const_context = t.jsgraph()->Constant(native); 158 Node* const_context = t.jsgraph()->Constant(native);
159 Node* param_context = t.NewNode(t.common()->Parameter(0)); 159 Node* param_context = t.NewNode(t.common()->Parameter(0), start);
160 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); 160 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
161 161
162 { 162 {
163 // Check that SpecializeToContext() replaces values and forwards effects 163 // Check that SpecializeToContext() replaces values and forwards effects
164 // correctly, and folds values from constant and non-constant contexts 164 // correctly, and folds values from constant and non-constant contexts
165 Node* effect_in = t.NewNode(t.common()->Start()); 165 Node* effect_in = t.NewNode(t.common()->Start(0));
166 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 166 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
167 const_context, const_context, effect_in, start); 167 const_context, const_context, effect_in, start);
168 168
169 169
170 Node* value_use = t.ChangeTaggedToInt32(load); 170 Node* value_use = t.ChangeTaggedToInt32(load);
171 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 171 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
172 param_context, param_context, load, start); 172 param_context, param_context, load, start);
173 Node* effect_use = other_load; 173 Node* effect_use = other_load;
174 Node* other_use = t.ChangeTaggedToInt32(other_load); 174 Node* other_use = t.ChangeTaggedToInt32(other_load);
175 175
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 { 243 {
244 FunctionTester T( 244 FunctionTester T(
245 "(function() { if (false) { var x = 1; } function inc(a)" 245 "(function() { if (false) { var x = 1; } function inc(a)"
246 " { return a + x; } return inc; })()"); // x is undefined! 246 " { return a + x; } return inc; })()"); // x is undefined!
247 247
248 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 248 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
249 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 249 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
250 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); 250 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN());
251 } 251 }
252 } 252 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/simplified-graph-builder.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