| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/int64-lowering.h" | 5 #include "src/compiler/int64-lowering.h" |
| 6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/machine-operator.h" | 8 #include "src/compiler/machine-operator.h" |
| 9 #include "src/compiler/node.h" | 9 #include "src/compiler/node.h" |
| 10 #include "src/compiler/wasm-compiler.h" |
| 10 | 11 |
| 11 #include "src/compiler/node-properties.h" | 12 #include "src/compiler/node-properties.h" |
| 12 | 13 |
| 13 #include "src/objects-inl.h" | 14 #include "src/objects-inl.h" |
| 14 #include "src/signature.h" | 15 #include "src/signature.h" |
| 15 | 16 |
| 16 #include "src/wasm/wasm-module.h" | 17 #include "src/wasm/wasm-module.h" |
| 17 | 18 |
| 18 #include "test/unittests/compiler/graph-unittest.h" | 19 #include "test/unittests/compiler/graph-unittest.h" |
| 19 #include "test/unittests/compiler/node-test-utils.h" | 20 #include "test/unittests/compiler/node-test-utils.h" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 EXPECT_THAT(start()->op()->ValueOutputCount(), start_parameter + 2); | 325 EXPECT_THAT(start()->op()->ValueOutputCount(), start_parameter + 2); |
| 325 } | 326 } |
| 326 | 327 |
| 327 TEST_F(Int64LoweringTest, CallI64Return) { | 328 TEST_F(Int64LoweringTest, CallI64Return) { |
| 328 int32_t function = 0x9999; | 329 int32_t function = 0x9999; |
| 329 | 330 |
| 330 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); | 331 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 0); |
| 331 sig_builder.AddReturn(MachineRepresentation::kWord64); | 332 sig_builder.AddReturn(MachineRepresentation::kWord64); |
| 332 | 333 |
| 333 compiler::CallDescriptor* desc = | 334 compiler::CallDescriptor* desc = |
| 334 wasm::ModuleEnv::GetWasmCallDescriptor(zone(), sig_builder.Build()); | 335 compiler::GetWasmCallDescriptor(zone(), sig_builder.Build()); |
| 335 | 336 |
| 336 LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), | 337 LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), |
| 337 start(), start()), | 338 start(), start()), |
| 338 MachineRepresentation::kWord64); | 339 MachineRepresentation::kWord64); |
| 339 | 340 |
| 340 Capture<Node*> call; | 341 Capture<Node*> call; |
| 341 Matcher<Node*> call_matcher = | 342 Matcher<Node*> call_matcher = |
| 342 IsCall(testing::_, IsInt32Constant(function), start(), start()); | 343 IsCall(testing::_, IsInt32Constant(function), start(), start()); |
| 343 | 344 |
| 344 EXPECT_THAT(graph()->end()->InputAt(1), | 345 EXPECT_THAT(graph()->end()->InputAt(1), |
| 345 IsReturn2(IsProjection(0, AllOf(CaptureEq(&call), call_matcher)), | 346 IsReturn2(IsProjection(0, AllOf(CaptureEq(&call), call_matcher)), |
| 346 IsProjection(1, AllOf(CaptureEq(&call), call_matcher)), | 347 IsProjection(1, AllOf(CaptureEq(&call), call_matcher)), |
| 347 start(), start())); | 348 start(), start())); |
| 348 | 349 |
| 349 CompareCallDescriptors( | 350 CompareCallDescriptors( |
| 350 OpParameter<const CallDescriptor*>( | 351 OpParameter<const CallDescriptor*>( |
| 351 graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)), | 352 graph()->end()->InputAt(1)->InputAt(1)->InputAt(0)), |
| 352 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); | 353 compiler::GetI32WasmCallDescriptor(zone(), desc)); |
| 353 } | 354 } |
| 354 | 355 |
| 355 TEST_F(Int64LoweringTest, CallI64Parameter) { | 356 TEST_F(Int64LoweringTest, CallI64Parameter) { |
| 356 int32_t function = 0x9999; | 357 int32_t function = 0x9999; |
| 357 | 358 |
| 358 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 3); | 359 Signature<MachineRepresentation>::Builder sig_builder(zone(), 1, 3); |
| 359 sig_builder.AddReturn(MachineRepresentation::kWord32); | 360 sig_builder.AddReturn(MachineRepresentation::kWord32); |
| 360 sig_builder.AddParam(MachineRepresentation::kWord64); | 361 sig_builder.AddParam(MachineRepresentation::kWord64); |
| 361 sig_builder.AddParam(MachineRepresentation::kWord32); | 362 sig_builder.AddParam(MachineRepresentation::kWord32); |
| 362 sig_builder.AddParam(MachineRepresentation::kWord64); | 363 sig_builder.AddParam(MachineRepresentation::kWord64); |
| 363 | 364 |
| 364 compiler::CallDescriptor* desc = | 365 compiler::CallDescriptor* desc = |
| 365 wasm::ModuleEnv::GetWasmCallDescriptor(zone(), sig_builder.Build()); | 366 compiler::GetWasmCallDescriptor(zone(), sig_builder.Build()); |
| 366 | 367 |
| 367 LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), | 368 LowerGraph(graph()->NewNode(common()->Call(desc), Int32Constant(function), |
| 368 Int64Constant(value(0)), | 369 Int64Constant(value(0)), |
| 369 Int32Constant(low_word_value(1)), | 370 Int32Constant(low_word_value(1)), |
| 370 Int64Constant(value(2)), start(), start()), | 371 Int64Constant(value(2)), start(), start()), |
| 371 MachineRepresentation::kWord32); | 372 MachineRepresentation::kWord32); |
| 372 | 373 |
| 373 EXPECT_THAT( | 374 EXPECT_THAT( |
| 374 graph()->end()->InputAt(1), | 375 graph()->end()->InputAt(1), |
| 375 IsReturn(IsCall(testing::_, IsInt32Constant(function), | 376 IsReturn(IsCall(testing::_, IsInt32Constant(function), |
| 376 IsInt32Constant(low_word_value(0)), | 377 IsInt32Constant(low_word_value(0)), |
| 377 IsInt32Constant(high_word_value(0)), | 378 IsInt32Constant(high_word_value(0)), |
| 378 IsInt32Constant(low_word_value(1)), | 379 IsInt32Constant(low_word_value(1)), |
| 379 IsInt32Constant(low_word_value(2)), | 380 IsInt32Constant(low_word_value(2)), |
| 380 IsInt32Constant(high_word_value(2)), start(), start()), | 381 IsInt32Constant(high_word_value(2)), start(), start()), |
| 381 start(), start())); | 382 start(), start())); |
| 382 | 383 |
| 383 CompareCallDescriptors( | 384 CompareCallDescriptors(OpParameter<const CallDescriptor*>( |
| 384 OpParameter<const CallDescriptor*>( | 385 graph()->end()->InputAt(1)->InputAt(1)), |
| 385 graph()->end()->InputAt(1)->InputAt(1)), | 386 compiler::GetI32WasmCallDescriptor(zone(), desc)); |
| 386 wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc)); | |
| 387 } | 387 } |
| 388 | 388 |
| 389 TEST_F(Int64LoweringTest, Int64Add) { | 389 TEST_F(Int64LoweringTest, Int64Add) { |
| 390 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), | 390 LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)), |
| 391 Int64Constant(value(1))), | 391 Int64Constant(value(1))), |
| 392 MachineRepresentation::kWord64); | 392 MachineRepresentation::kWord64); |
| 393 | 393 |
| 394 Capture<Node*> add; | 394 Capture<Node*> add; |
| 395 Matcher<Node*> add_matcher = IsInt32PairAdd( | 395 Matcher<Node*> add_matcher = IsInt32PairAdd( |
| 396 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), | 396 IsInt32Constant(low_word_value(0)), IsInt32Constant(high_word_value(0)), |
| (...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 graph()->NewNode(common()->Branch(), compare, | 923 graph()->NewNode(common()->Branch(), compare, |
| 924 graph()->start())))); | 924 graph()->start())))); |
| 925 | 925 |
| 926 NodeProperties::ReplaceValueInput(compare, load, 0); | 926 NodeProperties::ReplaceValueInput(compare, load, 0); |
| 927 | 927 |
| 928 LowerGraph(load, MachineRepresentation::kWord64); | 928 LowerGraph(load, MachineRepresentation::kWord64); |
| 929 } | 929 } |
| 930 } // namespace compiler | 930 } // namespace compiler |
| 931 } // namespace internal | 931 } // namespace internal |
| 932 } // namespace v8 | 932 } // namespace v8 |
| OLD | NEW |