| 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), | 20 : main_graph_(zone), |
| 21 main_common_(zone), | 21 main_common_(zone), |
| 22 main_javascript_(zone), | 22 main_javascript_(zone), |
| 23 main_typer_(zone), | 23 main_typer_(&main_graph_, MaybeHandle<Context>()), |
| 24 main_machine_() {} | 24 main_machine_() {} |
| 25 Graph main_graph_; | 25 Graph main_graph_; |
| 26 CommonOperatorBuilder main_common_; | 26 CommonOperatorBuilder main_common_; |
| 27 JSOperatorBuilder main_javascript_; | 27 JSOperatorBuilder main_javascript_; |
| 28 Typer main_typer_; | 28 Typer main_typer_; |
| 29 MachineOperatorBuilder main_machine_; | 29 MachineOperatorBuilder main_machine_; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 | 32 |
| 33 class JSConstantCacheTester : public HandleAndZoneScope, | 33 class JSConstantCacheTester : public HandleAndZoneScope, |
| 34 public JSCacheTesterHelper, | 34 public JSCacheTesterHelper, |
| 35 public JSGraph { | 35 public JSGraph { |
| 36 public: | 36 public: |
| 37 JSConstantCacheTester() | 37 JSConstantCacheTester() |
| 38 : JSCacheTesterHelper(main_zone()), | 38 : JSCacheTesterHelper(main_zone()), |
| 39 JSGraph(&main_graph_, &main_common_, &main_javascript_, &main_typer_, | 39 JSGraph(&main_graph_, &main_common_, &main_javascript_, |
| 40 &main_machine_) {} | 40 &main_machine_) { |
| 41 main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); |
| 42 main_graph_.SetEnd(main_graph_.NewNode(common()->End())); |
| 43 main_typer_.Run(); |
| 44 } |
| 41 | 45 |
| 42 Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } | 46 Type* upper(Node* node) { return NodeProperties::GetBounds(node).upper; } |
| 43 | 47 |
| 44 Handle<Object> handle(Node* node) { | 48 Handle<Object> handle(Node* node) { |
| 45 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); | 49 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); |
| 46 return OpParameter<Unique<Object> >(node).handle(); | 50 return OpParameter<Unique<Object> >(node).handle(); |
| 47 } | 51 } |
| 48 | 52 |
| 49 Factory* factory() { return main_isolate()->factory(); } | 53 Factory* factory() { return main_isolate()->factory(); } |
| 50 }; | 54 }; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 CHECK(T.upper(T.NullConstant())->Is(Type::Null())); | 286 CHECK(T.upper(T.NullConstant())->Is(Type::Null())); |
| 283 CHECK(T.upper(T.ZeroConstant())->Is(Type::Number())); | 287 CHECK(T.upper(T.ZeroConstant())->Is(Type::Number())); |
| 284 CHECK(T.upper(T.OneConstant())->Is(Type::Number())); | 288 CHECK(T.upper(T.OneConstant())->Is(Type::Number())); |
| 285 CHECK(T.upper(T.NaNConstant())->Is(Type::NaN())); | 289 CHECK(T.upper(T.NaNConstant())->Is(Type::NaN())); |
| 286 } | 290 } |
| 287 | 291 |
| 288 | 292 |
| 289 TEST(ExternalReferences) { | 293 TEST(ExternalReferences) { |
| 290 // TODO(titzer): test canonicalization of external references. | 294 // TODO(titzer): test canonicalization of external references. |
| 291 } | 295 } |
| OLD | NEW |