// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stdlib.h> #include "src/base/vector.h" #include "src/codegen/code-factory.h" #include "src/codegen/macro-assembler.h" #include "src/debug/debug.h" #include "src/diagnostics/disasm.h" #include "src/diagnostics/disassembler.h" #include "src/execution/frames-inl.h" #include "src/init/v8.h" #include "src/objects/objects-inl.h" #include "src/utils/ostreams.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" namespace v8 { namespace internal { using DisasmX64Test = TestWithIsolate; #define __ … namespace { Handle<Code> CreateDummyCode(Isolate* isolate) { … } } // namespace TEST_F(DisasmX64Test, DisasmX64) { … } constexpr int kAssemblerBufferSize = …; // Helper to package up all the required classes for disassembling into a // buffer using |InstructionDecode|. struct DisassemblerTester { … }; // Helper macro to compare the disassembly of an assembler function call with // the expected disassembly output. We reuse |Assembler|, so we need to keep // track of the offset into |buffer| which the Assembler has used, and // disassemble the instruction at that offset. // Requires a DisassemblerTester named t. #define COMPARE(str, ASM) … // Tests that compares the checks the disassembly output with an expected // string. TEST_F(DisasmX64Test, DisasmX64CheckOutput) { … } // This compares just the disassemble instruction (without the hex). // Requires a |std::string actual| to be in scope. // Hard coded offset of 21, the hex part is 20 bytes, plus a space. If and when // the padding changes, this should be adjusted. constexpr int kHexOffset = …; #define COMPARE_INSTR(str, ASM) … TEST_F(DisasmX64Test, DisasmX64CheckOutputSSE) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputSSE2) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputSSE3) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputSSSE3) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputSSE4_1) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputSSE4_2) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputAVX) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputVNNI) { … } TEST_F(DisasmX64Test, DisasmX64CheckOutputF16C) { … } TEST_F(DisasmX64Test, DisasmX64YMMRegister) { … } #undef __ } // namespace internal } // namespace v8