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

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

Issue 539903002: Move StructuredMachineAssembler into cctest suite. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add a TODO. 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/simplified-node-factory.h"
10 #include "src/compiler/source-position.h" 9 #include "src/compiler/source-position.h"
11 #include "src/compiler/typer.h" 10 #include "src/compiler/typer.h"
12 #include "test/cctest/cctest.h" 11 #include "test/cctest/cctest.h"
13 #include "test/cctest/compiler/function-tester.h" 12 #include "test/cctest/compiler/function-tester.h"
14 #include "test/cctest/compiler/graph-builder-tester.h" 13 #include "test/cctest/compiler/graph-builder-tester.h"
15 14
16 using namespace v8::internal; 15 using namespace v8::internal;
17 using namespace v8::internal::compiler; 16 using namespace v8::internal::compiler;
18 17
19 class ContextSpecializationTester 18 class ContextSpecializationTester : public HandleAndZoneScope,
20 : public HandleAndZoneScope, 19 public DirectGraphBuilder {
21 public DirectGraphBuilder,
22 public SimplifiedNodeFactory<ContextSpecializationTester> {
23 public: 20 public:
24 ContextSpecializationTester() 21 ContextSpecializationTester()
25 : DirectGraphBuilder(new (main_zone()) Graph(main_zone())), 22 : DirectGraphBuilder(new (main_zone()) Graph(main_zone())),
26 common_(main_zone()), 23 common_(main_zone()),
27 javascript_(main_zone()), 24 javascript_(main_zone()),
28 simplified_(main_zone()), 25 simplified_(main_zone()),
29 typer_(main_zone()), 26 typer_(main_zone()),
30 jsgraph_(graph(), common(), &typer_), 27 jsgraph_(graph(), common(), &typer_),
31 info_(main_isolate(), main_zone()) {} 28 info_(main_isolate(), main_zone()) {}
32 29
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context); 206 JSContextSpecializer spec(t.info(), t.jsgraph(), const_context);
210 207
211 { 208 {
212 // Check that SpecializeToContext() replaces values and forwards effects 209 // Check that SpecializeToContext() replaces values and forwards effects
213 // correctly, and folds values from constant and non-constant contexts 210 // correctly, and folds values from constant and non-constant contexts
214 Node* effect_in = start; 211 Node* effect_in = start;
215 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 212 Node* load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
216 const_context, const_context, effect_in); 213 const_context, const_context, effect_in);
217 214
218 215
219 Node* value_use = t.ChangeTaggedToInt32(load); 216 Node* value_use = t.NewNode(t.simplified()->ChangeTaggedToInt32(), load);
220 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true), 217 Node* other_load = t.NewNode(t.javascript()->LoadContext(0, slot, true),
221 param_context, param_context, load); 218 param_context, param_context, load);
222 Node* effect_use = other_load; 219 Node* effect_use = other_load;
223 Node* other_use = t.ChangeTaggedToInt32(other_load); 220 Node* other_use =
221 t.NewNode(t.simplified()->ChangeTaggedToInt32(), other_load);
224 222
225 Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use, 223 Node* add = t.NewNode(t.javascript()->Add(), value_use, other_use,
226 param_context, other_load, start); 224 param_context, other_load, start);
227 225
228 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start); 226 Node* ret = t.NewNode(t.common()->Return(), add, effect_use, start);
229 Node* end = t.NewNode(t.common()->End(), ret); 227 Node* end = t.NewNode(t.common()->End(), ret);
230 USE(end); 228 USE(end);
231 t.graph()->SetEnd(end); 229 t.graph()->SetEnd(end);
232 230
233 // Double check the above graph is what we expect, or the test is broken. 231 // Double check the above graph is what we expect, or the test is broken.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 { 298 {
301 FunctionTester T( 299 FunctionTester T(
302 "(function() { if (false) { var x = 1; } function inc(a)" 300 "(function() { if (false) { var x = 1; } function inc(a)"
303 " { return a + x; } return inc; })()"); // x is undefined! 301 " { return a + x; } return inc; })()"); // x is undefined!
304 302
305 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 303 CHECK(T.Call(T.Val(0.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
306 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN()); 304 CHECK(T.Call(T.Val(2.0), T.Val(0.0)).ToHandleChecked()->IsNaN());
307 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN()); 305 CHECK(T.Call(T.Val(-2.1), T.Val(0.0)).ToHandleChecked()->IsNaN());
308 } 306 }
309 } 307 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-changes-lowering.cc ('k') | test/cctest/compiler/test-simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698