LCOV - code coverage report
Current view: top level - test/unittests - code-stub-assembler-unittest.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 23 25 92.0 %
Date: 2017-10-20 Functions: 15 15 100.0 %

          Line data    Source code
       1             : // Copyright 2017 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 "test/unittests/code-stub-assembler-unittest.h"
       6             : 
       7             : #include "src/code-factory.h"
       8             : #include "src/compiler/node.h"
       9             : #include "src/interface-descriptors.h"
      10             : #include "src/isolate.h"
      11             : #include "src/objects-inl.h"
      12             : #include "test/unittests/compiler/compiler-test-utils.h"
      13             : #include "test/unittests/compiler/node-test-utils.h"
      14             : 
      15             : using ::testing::_;
      16             : using v8::internal::compiler::Node;
      17             : 
      18             : namespace c = v8::internal::compiler;
      19             : 
      20             : namespace v8 {
      21             : namespace internal {
      22             : 
      23             : #ifdef ENABLE_VERIFY_CSA
      24             : #define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) IsBitcastWordToTaggedSigned(x)
      25             : #define IS_BITCAST_TAGGED_TO_WORD(x) IsBitcastTaggedToWord(x)
      26             : #else
      27             : #define IS_BITCAST_WORD_TO_TAGGED_SIGNED(x) (x)
      28             : #define IS_BITCAST_TAGGED_TO_WORD(x) (x)
      29             : #endif
      30             : 
      31           3 : CodeStubAssemblerTestState::CodeStubAssemblerTestState(
      32             :     CodeStubAssemblerTest* test)
      33             :     : compiler::CodeAssemblerState(test->isolate(), test->zone(),
      34             :                                    VoidDescriptor(test->isolate()), Code::STUB,
      35           6 :                                    "test") {}
      36             : 
      37       13160 : TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) {
      38           1 :   CodeStubAssemblerTestState state(this);
      39             :   CodeStubAssemblerForTest m(&state);
      40           2 :   Node* value = m.Int32Constant(44);
      41           3 :   EXPECT_THAT(m.SmiTag(value),
      42             :               IS_BITCAST_WORD_TO_TAGGED_SIGNED(c::IsIntPtrConstant(
      43           0 :                   static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
      44           3 :   EXPECT_THAT(m.SmiUntag(value),
      45             :               c::IsIntPtrConstant(static_cast<intptr_t>(44) >>
      46           0 :                                   (kSmiShiftSize + kSmiTagSize)));
      47           1 : }
      48             : 
      49       13160 : TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) {
      50           1 :   CodeStubAssemblerTestState state(this);
      51             :   CodeStubAssemblerForTest m(&state);
      52             :   {
      53           2 :     Node* a = m.IntPtrConstant(100);
      54           2 :     Node* b = m.IntPtrConstant(1);
      55           2 :     Node* z = m.IntPtrMax(a, b);
      56           3 :     EXPECT_THAT(z, c::IsIntPtrConstant(100));
      57             :   }
      58           1 : }
      59             : 
      60       13160 : TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) {
      61           1 :   CodeStubAssemblerTestState state(this);
      62             :   CodeStubAssemblerForTest m(&state);
      63             :   {
      64           2 :     Node* a = m.IntPtrConstant(100);
      65           2 :     Node* b = m.IntPtrConstant(1);
      66           2 :     Node* z = m.IntPtrMin(a, b);
      67           3 :     EXPECT_THAT(z, c::IsIntPtrConstant(1));
      68             :   }
      69           1 : }
      70             : 
      71             : }  // namespace internal
      72        7893 : }  // namespace v8

Generated by: LCOV version 1.10