LCOV - code coverage report
Current view: top level - test/unittests/assembler - turbo-assembler-x64-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 17 17 100.0 %
Date: 2019-02-19 Functions: 6 8 75.0 %

          Line data    Source code
       1             : // Copyright 2018 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/macro-assembler.h"
       6             : #include "src/simulator.h"
       7             : #include "test/common/assembler-tester.h"
       8             : #include "testing/gtest-support.h"
       9             : 
      10             : namespace v8 {
      11             : namespace internal {
      12             : 
      13             : #define __ tasm.
      14             : 
      15             : // Test the x64 assembler by compiling some simple functions into
      16             : // a buffer and executing them.  These tests do not initialize the
      17             : // V8 library, create a context, or use any V8 objects.
      18             : 
      19       15188 : TEST(TurboAssemblerTest, TestHardAbort) {
      20             :   auto buffer = AllocateAssemblerBuffer();
      21             :   TurboAssembler tasm(nullptr, AssemblerOptions{}, CodeObjectRequired::kNo,
      22           4 :                       buffer->CreateView());
      23             :   __ set_abort_hard(true);
      24             : 
      25           1 :   __ Abort(AbortReason::kNoReason);
      26             : 
      27           1 :   CodeDesc desc;
      28             :   tasm.GetCode(nullptr, &desc);
      29           1 :   buffer->MakeExecutable();
      30           1 :   auto f = GeneratedCode<void>::FromBuffer(nullptr, buffer->start());
      31             : 
      32           3 :   ASSERT_DEATH_IF_SUPPORTED({ f.Call(); }, "abort: no reason");
      33             : }
      34             : 
      35       15188 : TEST(TurboAssemblerTest, TestCheck) {
      36             :   auto buffer = AllocateAssemblerBuffer();
      37             :   TurboAssembler tasm(nullptr, AssemblerOptions{}, CodeObjectRequired::kNo,
      38           4 :                       buffer->CreateView());
      39             :   __ set_abort_hard(true);
      40             : 
      41             :   // Fail if the first parameter is 17.
      42             :   __ movl(rax, Immediate(17));
      43           1 :   __ cmpl(rax, arg_reg_1);
      44           1 :   __ Check(Condition::not_equal, AbortReason::kNoReason);
      45           1 :   __ ret(0);
      46             : 
      47           1 :   CodeDesc desc;
      48             :   tasm.GetCode(nullptr, &desc);
      49           1 :   buffer->MakeExecutable();
      50           1 :   auto f = GeneratedCode<void, int>::FromBuffer(nullptr, buffer->start());
      51             : 
      52             :   f.Call(0);
      53             :   f.Call(18);
      54           3 :   ASSERT_DEATH_IF_SUPPORTED({ f.Call(17); }, "abort: no reason");
      55             : }
      56             : 
      57             : #undef __
      58             : 
      59             : }  // namespace internal
      60        9111 : }  // namespace v8

Generated by: LCOV version 1.10