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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "src/types.h" | 10 #include "src/types.h" |
11 #include "test/cctest/cctest.h" | 11 #include "test/cctest/cctest.h" |
12 #include "test/cctest/compiler/value-helper.h" | 12 #include "test/cctest/compiler/value-helper.h" |
13 | 13 |
14 using namespace v8::internal; | 14 using namespace v8::internal; |
15 using namespace v8::internal::compiler; | 15 using namespace v8::internal::compiler; |
16 | 16 |
17 class JSCacheTesterHelper { | 17 class JSCacheTesterHelper { |
18 protected: | 18 protected: |
19 explicit JSCacheTesterHelper(Zone* zone) | 19 explicit JSCacheTesterHelper(Zone* zone) |
20 : main_graph_(zone), main_common_(zone), main_typer_(zone) {} | 20 : main_graph_(zone), |
| 21 main_common_(zone), |
| 22 main_typer_(&main_graph_, MaybeHandle<Context>()) {} |
21 Graph main_graph_; | 23 Graph main_graph_; |
22 CommonOperatorBuilder main_common_; | 24 CommonOperatorBuilder main_common_; |
23 Typer main_typer_; | 25 Typer main_typer_; |
24 }; | 26 }; |
25 | 27 |
26 | 28 |
27 class JSConstantCacheTester : public HandleAndZoneScope, | 29 class JSConstantCacheTester : public HandleAndZoneScope, |
28 public JSCacheTesterHelper, | 30 public JSCacheTesterHelper, |
29 public JSGraph { | 31 public JSGraph { |
30 public: | 32 public: |
31 JSConstantCacheTester() | 33 JSConstantCacheTester() |
32 : JSCacheTesterHelper(main_zone()), | 34 : JSCacheTesterHelper(main_zone()), |
33 JSGraph(&main_graph_, &main_common_, &main_typer_) {} | 35 JSGraph(&main_graph_, &main_common_) { |
| 36 main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); |
| 37 main_graph_.SetEnd(main_graph_.NewNode(common()->End())); |
| 38 main_typer_.Run(); |
| 39 } |
34 | 40 |
35 Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } | 41 Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } |
36 | 42 |
37 Handle<Object> handle(Node* node) { | 43 Handle<Object> handle(Node* node) { |
38 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); | 44 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); |
39 return ValueOf<Handle<Object> >(node->op()); | 45 return ValueOf<Handle<Object> >(node->op()); |
40 } | 46 } |
41 | 47 |
42 Factory* factory() { return main_isolate()->factory(); } | 48 Factory* factory() { return main_isolate()->factory(); } |
43 }; | 49 }; |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 CHECK(T.upper(T.NullConstant())->Is(Type::Null())); | 281 CHECK(T.upper(T.NullConstant())->Is(Type::Null())); |
276 CHECK(T.upper(T.ZeroConstant())->Is(Type::Number())); | 282 CHECK(T.upper(T.ZeroConstant())->Is(Type::Number())); |
277 CHECK(T.upper(T.OneConstant())->Is(Type::Number())); | 283 CHECK(T.upper(T.OneConstant())->Is(Type::Number())); |
278 CHECK(T.upper(T.NaNConstant())->Is(Type::NaN())); | 284 CHECK(T.upper(T.NaNConstant())->Is(Type::NaN())); |
279 } | 285 } |
280 | 286 |
281 | 287 |
282 TEST(ExternalReferences) { | 288 TEST(ExternalReferences) { |
283 // TODO(titzer): test canonicalization of external references. | 289 // TODO(titzer): test canonicalization of external references. |
284 } | 290 } |
OLD | NEW |