| 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 <functional> | 5 #include <functional> |
| 6 #include <limits> | 6 #include <limits> |
| 7 | 7 |
| 8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
| 9 #include "test/cctest/compiler/codegen-tester.h" | 9 #include "test/cctest/compiler/codegen-tester.h" |
| 10 #include "test/cctest/compiler/value-helper.h" | 10 #include "test/cctest/compiler/value-helper.h" |
| (...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2485 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 2485 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); |
| 2486 int constant = 0x55555 + i; | 2486 int constant = 0x55555 + i; |
| 2487 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); | 2487 m.NewNode(ops[i], m.Parameter(0), m.Parameter(1)); |
| 2488 m.Return(m.Int32Constant(constant)); | 2488 m.Return(m.Int32Constant(constant)); |
| 2489 | 2489 |
| 2490 CHECK_EQ(constant, m.Call(1, 1)); | 2490 CHECK_EQ(constant, m.Call(1, 1)); |
| 2491 } | 2491 } |
| 2492 } | 2492 } |
| 2493 | 2493 |
| 2494 | 2494 |
| 2495 template <typename CType> | 2495 template <typename Type, typename CType> |
| 2496 static void RunLoadImmIndex(MachineRepresentation rep) { | 2496 static void RunLoadImmIndex(MachineRepresentation rep) { |
| 2497 const int kNumElems = 3; | 2497 const int kNumElems = 3; |
| 2498 CType buffer[kNumElems]; | 2498 CType buffer[kNumElems]; |
| 2499 | 2499 |
| 2500 // initialize the buffer with raw data. | 2500 // initialize the buffer with raw data. |
| 2501 byte* raw = reinterpret_cast<byte*>(buffer); | 2501 byte* raw = reinterpret_cast<byte*>(buffer); |
| 2502 for (size_t i = 0; i < sizeof(buffer); i++) { | 2502 for (size_t i = 0; i < sizeof(buffer); i++) { |
| 2503 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); | 2503 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); |
| 2504 } | 2504 } |
| 2505 | 2505 |
| 2506 // Test with various large and small offsets. | 2506 // Test with various large and small offsets. |
| 2507 for (int offset = -1; offset <= 200000; offset *= -5) { | 2507 for (int offset = -1; offset <= 200000; offset *= -5) { |
| 2508 for (int i = 0; i < kNumElems; i++) { | 2508 for (int i = 0; i < kNumElems; i++) { |
| 2509 RawMachineAssemblerTester<CType> m; | 2509 RawMachineAssemblerTester<Type> m; |
| 2510 Node* base = m.PointerConstant(buffer - offset); | 2510 Node* base = m.PointerConstant(buffer - offset); |
| 2511 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); | 2511 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); |
| 2512 m.Return(m.Load(rep, base, index)); | 2512 m.Return(m.Load(rep, base, index)); |
| 2513 | 2513 |
| 2514 CHECK_EQ(buffer[i], m.Call()); | 2514 CHECK_EQ(static_cast<Type>(buffer[i]), m.Call()); |
| 2515 printf("XXX\n"); | 2515 printf("XXX\n"); |
| 2516 } | 2516 } |
| 2517 } | 2517 } |
| 2518 } | 2518 } |
| 2519 | 2519 |
| 2520 | 2520 |
| 2521 TEST(RunLoadImmIndex) { | 2521 TEST(RunLoadImmIndex) { |
| 2522 RunLoadImmIndex<int8_t>(kMachineWord8); | 2522 RunLoadImmIndex<int8_t, uint8_t>(kMachineWord8); |
| 2523 RunLoadImmIndex<int16_t>(kMachineWord16); | 2523 RunLoadImmIndex<int16_t, uint16_t>(kMachineWord16); |
| 2524 RunLoadImmIndex<int32_t>(kMachineWord32); | 2524 RunLoadImmIndex<int32_t, uint32_t>(kMachineWord32); |
| 2525 RunLoadImmIndex<int32_t*>(kMachineTagged); | 2525 RunLoadImmIndex<int32_t*, int32_t*>(kMachineTagged); |
| 2526 | 2526 |
| 2527 // TODO(titzer): test kMachineFloat64 loads | 2527 // TODO(titzer): test kMachineFloat64 loads |
| 2528 // TODO(titzer): test various indexing modes. | 2528 // TODO(titzer): test various indexing modes. |
| 2529 } | 2529 } |
| 2530 | 2530 |
| 2531 | 2531 |
| 2532 template <typename CType> | 2532 template <typename CType> |
| 2533 static void RunLoadStore(MachineRepresentation rep) { | 2533 static void RunLoadStore(MachineRepresentation rep) { |
| 2534 const int kNumElems = 4; | 2534 const int kNumElems = 4; |
| 2535 CType buffer[kNumElems]; | 2535 CType buffer[kNumElems]; |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3836 m.Return(one); | 3836 m.Return(one); |
| 3837 m.Call(); | 3837 m.Call(); |
| 3838 for (int i = 0; i < kInputSize; i++) { | 3838 for (int i = 0; i < kInputSize; i++) { |
| 3839 CHECK_EQ(outputs[i], i + 2); | 3839 CHECK_EQ(outputs[i], i + 2); |
| 3840 } | 3840 } |
| 3841 } | 3841 } |
| 3842 | 3842 |
| 3843 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C | 3843 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C |
| 3844 | 3844 |
| 3845 #endif | 3845 #endif |
| OLD | NEW |