Chromium Code Reviews| 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-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
| 6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
| 7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
| 9 #include "test/unittests/compiler/graph-unittest.h" | 9 #include "test/unittests/compiler/graph-unittest.h" |
| 10 #include "test/unittests/compiler/node-test-utils.h" | 10 #include "test/unittests/compiler/node-test-utils.h" |
| 11 #include "testing/gmock-support.h" | 11 #include "testing/gmock-support.h" |
| 12 | 12 |
| 13 using testing::BitEq; | 13 using testing::BitEq; |
| 14 using testing::Capture; | 14 using testing::Capture; |
| 15 | 15 |
| 16 namespace v8 { | 16 namespace v8 { |
| 17 namespace internal { | 17 namespace internal { |
| 18 namespace compiler { | 18 namespace compiler { |
| 19 | 19 |
| 20 class JSBuiltinReducerTest : public TypedGraphTest { | 20 class JSBuiltinReducerTest : public TypedGraphTest { |
| 21 public: | 21 public: |
| 22 JSBuiltinReducerTest() : javascript_(zone()) {} | 22 JSBuiltinReducerTest() : javascript_(zone()) {} |
| 23 | 23 |
| 24 protected: | 24 protected: |
| 25 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = | 25 Reduction Reduce(Node* node, MachineOperatorBuilder::Flags flags = |
| 26 MachineOperatorBuilder::Flag::kNoFlags) { | 26 MachineOperatorBuilder::Flag::kNoFlags) { |
| 27 MachineOperatorBuilder machine(zone(), kMachPtr, flags); | 27 MachineOperatorBuilder machine(zone(), kMachPtr, flags); |
| 28 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); | 28 JSGraph jsgraph(isolate(), graph(), common(), javascript(), &machine); |
| 29 JSBuiltinReducer reducer(&jsgraph); | 29 // TODO(titzer): mock the GraphReducer here for better unit testing. |
|
titzer
2015/06/05 12:30:50
u wot m8?
| |
| 30 GraphReducer graph_reducer(zone(), graph()); | |
| 31 JSBuiltinReducer reducer(&graph_reducer, &jsgraph); | |
| 30 return reducer.Reduce(node); | 32 return reducer.Reduce(node); |
| 31 } | 33 } |
| 32 | 34 |
| 33 Node* MathFunction(const char* name) { | 35 Node* MathFunction(const char* name) { |
| 34 Handle<Object> m = | 36 Handle<Object> m = |
| 35 JSObject::GetProperty(isolate()->global_object(), | 37 JSObject::GetProperty(isolate()->global_object(), |
| 36 isolate()->factory()->NewStringFromAsciiChecked( | 38 isolate()->factory()->NewStringFromAsciiChecked( |
| 37 "Math")).ToHandleChecked(); | 39 "Math")).ToHandleChecked(); |
| 38 Handle<JSFunction> f = Handle<JSFunction>::cast( | 40 Handle<JSFunction> f = Handle<JSFunction>::cast( |
| 39 JSObject::GetProperty( | 41 JSObject::GetProperty( |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 | 195 |
| 194 ASSERT_TRUE(r.Changed()); | 196 ASSERT_TRUE(r.Changed()); |
| 195 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); | 197 EXPECT_THAT(r.replacement(), IsTruncateFloat64ToFloat32(p0)); |
| 196 } | 198 } |
| 197 } | 199 } |
| 198 } | 200 } |
| 199 | 201 |
| 200 } // namespace compiler | 202 } // namespace compiler |
| 201 } // namespace internal | 203 } // namespace internal |
| 202 } // namespace v8 | 204 } // namespace v8 |
| OLD | NEW |