| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this | 1 // Copyright 2014 the V8 project authors. All rights reserved. Use of this |
| 2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 #include <cmath> | 5 #include <cmath> |
| 6 #include <functional> | 6 #include <functional> |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 3515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3526 CHECK_EQ(constant, m.Call(1, 1)); | 3526 CHECK_EQ(constant, m.Call(1, 1)); |
| 3527 } | 3527 } |
| 3528 } | 3528 } |
| 3529 | 3529 |
| 3530 | 3530 |
| 3531 template <typename Type> | 3531 template <typename Type> |
| 3532 static void RunLoadImmIndex(MachineType rep) { | 3532 static void RunLoadImmIndex(MachineType rep) { |
| 3533 const int kNumElems = 3; | 3533 const int kNumElems = 3; |
| 3534 Type buffer[kNumElems]; | 3534 Type buffer[kNumElems]; |
| 3535 | 3535 |
| 3536 // initialize the buffer with raw data. | 3536 // initialize the buffer with some raw data. |
| 3537 byte* raw = reinterpret_cast<byte*>(buffer); | 3537 byte* raw = reinterpret_cast<byte*>(buffer); |
| 3538 for (size_t i = 0; i < sizeof(buffer); i++) { | 3538 for (size_t i = 0; i < sizeof(buffer); i++) { |
| 3539 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); | 3539 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); |
| 3540 } | 3540 } |
| 3541 | 3541 |
| 3542 // Test with various large and small offsets. | 3542 // Test with various large and small offsets. |
| 3543 for (int offset = -1; offset <= 200000; offset *= -5) { | 3543 for (int offset = -1; offset <= 200000; offset *= -5) { |
| 3544 for (int i = 0; i < kNumElems; i++) { | 3544 for (int i = 0; i < kNumElems; i++) { |
| 3545 RawMachineAssemblerTester<Type> m; | 3545 BufferedRawMachineAssemblerTester<Type> m; |
| 3546 Node* base = m.PointerConstant(buffer - offset); | 3546 Node* base = m.PointerConstant(buffer - offset); |
| 3547 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); | 3547 Node* index = m.Int32Constant((offset + i) * sizeof(buffer[0])); |
| 3548 m.Return(m.Load(rep, base, index)); | 3548 m.Return(m.Load(rep, base, index)); |
| 3549 | 3549 |
| 3550 Type expected = buffer[i]; | 3550 volatile Type expected = buffer[i]; |
| 3551 Type actual = m.Call(); | 3551 volatile Type actual = m.Call(); |
| 3552 CHECK(expected == actual); | 3552 CHECK_EQ(expected, actual); |
| 3553 } | 3553 } |
| 3554 } | 3554 } |
| 3555 } | 3555 } |
| 3556 | 3556 |
| 3557 | 3557 |
| 3558 TEST(RunLoadImmIndex) { | 3558 TEST(RunLoadImmIndex) { |
| 3559 RunLoadImmIndex<int8_t>(MachineType::Int8()); | 3559 RunLoadImmIndex<int8_t>(MachineType::Int8()); |
| 3560 RunLoadImmIndex<uint8_t>(MachineType::Uint8()); | 3560 RunLoadImmIndex<uint8_t>(MachineType::Uint8()); |
| 3561 RunLoadImmIndex<int16_t>(MachineType::Int16()); | 3561 RunLoadImmIndex<int16_t>(MachineType::Int16()); |
| 3562 RunLoadImmIndex<uint16_t>(MachineType::Uint16()); | 3562 RunLoadImmIndex<uint16_t>(MachineType::Uint16()); |
| 3563 RunLoadImmIndex<int32_t>(MachineType::Int32()); | 3563 RunLoadImmIndex<int32_t>(MachineType::Int32()); |
| 3564 RunLoadImmIndex<uint32_t>(MachineType::Uint32()); | 3564 RunLoadImmIndex<uint32_t>(MachineType::Uint32()); |
| 3565 RunLoadImmIndex<int32_t*>(MachineType::AnyTagged()); | 3565 RunLoadImmIndex<int32_t*>(MachineType::AnyTagged()); |
| 3566 | 3566 RunLoadImmIndex<float>(MachineType::Float32()); |
| 3567 // TODO(titzer): test kRepBit loads | 3567 RunLoadImmIndex<double>(MachineType::Float64()); |
| 3568 // TODO(titzer): test MachineType::Float64() loads | 3568 if (kPointerSize == 8) { |
| 3569 RunLoadImmIndex<int64_t>(MachineType::Int64()); |
| 3570 } |
| 3569 // TODO(titzer): test various indexing modes. | 3571 // TODO(titzer): test various indexing modes. |
| 3570 } | 3572 } |
| 3571 | 3573 |
| 3572 | 3574 |
| 3573 template <typename CType> | 3575 template <typename CType> |
| 3574 static void RunLoadStore(MachineType rep) { | 3576 static void RunLoadStore(MachineType rep) { |
| 3575 const int kNumElems = 4; | 3577 const int kNumElems = 4; |
| 3576 CType buffer[kNumElems]; | 3578 CType buffer[kNumElems]; |
| 3577 | 3579 |
| 3578 for (int32_t x = 0; x < kNumElems; x++) { | 3580 for (int32_t x = 0; x < kNumElems; x++) { |
| (...skipping 2611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6190 Node* call = r.AddNode(r.common()->Call(desc), phi); | 6192 Node* call = r.AddNode(r.common()->Call(desc), phi); |
| 6191 r.Return(call); | 6193 r.Return(call); |
| 6192 | 6194 |
| 6193 CHECK_EQ(33, r.Call(1)); | 6195 CHECK_EQ(33, r.Call(1)); |
| 6194 CHECK_EQ(44, r.Call(0)); | 6196 CHECK_EQ(44, r.Call(0)); |
| 6195 } | 6197 } |
| 6196 | 6198 |
| 6197 } // namespace compiler | 6199 } // namespace compiler |
| 6198 } // namespace internal | 6200 } // namespace internal |
| 6199 } // namespace v8 | 6201 } // namespace v8 |
| OLD | NEW |