OLD | NEW |
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" |
11 #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 |
20 : public HandleAndZoneScope, | 19 : public HandleAndZoneScope, |
21 public DirectGraphBuilder, | 20 public DirectGraphBuilder, |
22 public SimplifiedNodeFactory<ContextSpecializationTester> { | 21 public SimplifiedNodeFactory<ContextSpecializationTester> { |
23 public: | 22 public: |
24 ContextSpecializationTester() | 23 ContextSpecializationTester() |
25 : DirectGraphBuilder(new (main_zone()) Graph(main_zone())), | 24 : DirectGraphBuilder(new (main_zone()) Graph(main_zone())), |
26 common_(main_zone()), | 25 common_(main_zone()), |
27 javascript_(main_zone()), | 26 javascript_(main_zone()), |
28 simplified_(main_zone()), | 27 simplified_(main_zone()), |
29 typer_(main_zone()), | 28 jsgraph_(graph(), common()), |
30 jsgraph_(graph(), common(), &typer_), | |
31 info_(main_isolate(), main_zone()) {} | 29 info_(main_isolate(), main_zone()) {} |
32 | 30 |
33 Factory* factory() { return main_isolate()->factory(); } | 31 Factory* factory() { return main_isolate()->factory(); } |
34 CommonOperatorBuilder* common() { return &common_; } | 32 CommonOperatorBuilder* common() { return &common_; } |
35 JSOperatorBuilder* javascript() { return &javascript_; } | 33 JSOperatorBuilder* javascript() { return &javascript_; } |
36 SimplifiedOperatorBuilder* simplified() { return &simplified_; } | 34 SimplifiedOperatorBuilder* simplified() { return &simplified_; } |
37 JSGraph* jsgraph() { return &jsgraph_; } | 35 JSGraph* jsgraph() { return &jsgraph_; } |
38 CompilationInfo* info() { return &info_; } | 36 CompilationInfo* info() { return &info_; } |
39 | 37 |
40 private: | 38 private: |
41 CommonOperatorBuilder common_; | 39 CommonOperatorBuilder common_; |
42 JSOperatorBuilder javascript_; | 40 JSOperatorBuilder javascript_; |
43 SimplifiedOperatorBuilder simplified_; | 41 SimplifiedOperatorBuilder simplified_; |
44 Typer typer_; | |
45 JSGraph jsgraph_; | 42 JSGraph jsgraph_; |
46 CompilationInfo info_; | 43 CompilationInfo info_; |
47 }; | 44 }; |
48 | 45 |
49 | 46 |
50 TEST(ReduceJSLoadContext) { | 47 TEST(ReduceJSLoadContext) { |
51 ContextSpecializationTester t; | 48 ContextSpecializationTester t; |
52 | 49 |
53 Node* start = t.NewNode(t.common()->Start(0)); | 50 Node* start = t.NewNode(t.common()->Start(0)); |
54 t.graph()->SetStart(start); | 51 t.graph()->SetStart(start); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 { | 297 { |
301 FunctionTester T( | 298 FunctionTester T( |
302 "(function() { if (false) { var x = 1; } function inc(a)" | 299 "(function() { if (false) { var x = 1; } function inc(a)" |
303 " { return a + x; } return inc; })()"); // x is undefined! | 300 " { return a + x; } return inc; })()"); // x is undefined! |
304 | 301 |
305 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()); |
306 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()); |
307 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()); |
308 } | 305 } |
309 } | 306 } |
OLD | NEW |