LCOV - code coverage report
Current view: top level - src - diy-fp.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 15 15 100.0 %
Date: 2019-04-17 Functions: 1 1 100.0 %

          Line data    Source code
       1             : // Copyright 2011 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/diy-fp.h"
       6             : 
       7             : #include <stdint.h>
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : 
      12     7494799 : void DiyFp::Multiply(const DiyFp& other) {
      13             :   // Simply "emulates" a 128 bit multiplication.
      14             :   // However: the resulting number only contains 64 bits. The least
      15             :   // significant 64 bits are only used for rounding the most significant 64
      16             :   // bits.
      17             :   const uint64_t kM32 = 0xFFFFFFFFu;
      18     7494799 :   uint64_t a = f_ >> 32;
      19     7494799 :   uint64_t b = f_ & kM32;
      20     7494799 :   uint64_t c = other.f_ >> 32;
      21     7494799 :   uint64_t d = other.f_ & kM32;
      22     7494799 :   uint64_t ac = a * c;
      23     7494799 :   uint64_t bc = b * c;
      24     7494799 :   uint64_t ad = a * d;
      25     7494799 :   uint64_t bd = b * d;
      26     7494799 :   uint64_t tmp = (bd >> 32) + (ad & kM32) + (bc & kM32);
      27             :   // By adding 1U << 31 to tmp we round the final result.
      28             :   // Halfway cases will be round up.
      29     7494799 :   tmp += 1U << 31;
      30     7494799 :   uint64_t result_f = ac + (ad >> 32) + (bc >> 32) + (tmp >> 32);
      31     7494799 :   e_ += other.e_ + 64;
      32     7494799 :   f_ = result_f;
      33     7494799 : }
      34             : 
      35             : }  // namespace internal
      36             : }  // namespace v8

Generated by: LCOV version 1.10