LCOV - code coverage report
Current view: top level - src/builtins - builtins-bigint-gen.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 12 14 85.7 %
Date: 2019-01-20 Functions: 6 6 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 "src/builtins/builtins-utils-gen.h"
       6             : #include "src/builtins/builtins.h"
       7             : #include "src/code-stub-assembler.h"
       8             : 
       9             : namespace v8 {
      10             : namespace internal {
      11             : 
      12             : // https://tc39.github.io/proposal-bigint/#sec-to-big-int64
      13         224 : TF_BUILTIN(BigIntToI64, CodeStubAssembler) {
      14          56 :   if (!Is64()) {
      15           0 :     Unreachable();
      16          56 :     return;
      17             :   }
      18             : 
      19             :   TNode<Object> value = CAST(Parameter(Descriptor::kArgument));
      20             :   TNode<Context> context = CAST(Parameter(Descriptor::kContext));
      21          56 :   TNode<BigInt> bigint = ToBigInt(context, value);
      22             : 
      23             :   TVARIABLE(UintPtrT, var_low);
      24             :   TVARIABLE(UintPtrT, var_high);
      25             : 
      26             :   // 2. Let int64bit be n modulo 2^64.
      27             :   // 3. If int64bit ≥ 2^63, return int64bit - 2^64;
      28          56 :   BigIntToRawBytes(bigint, &var_low, &var_high);
      29          56 :   ReturnRaw(var_low.value());
      30             : }
      31             : 
      32             : // https://tc39.github.io/proposal-bigint/#sec-bigint-constructor-number-value
      33         224 : TF_BUILTIN(I64ToBigInt, CodeStubAssembler) {
      34          56 :   if (!Is64()) {
      35           0 :     Unreachable();
      36          56 :     return;
      37             :   }
      38             : 
      39             :   TNode<IntPtrT> argument =
      40          56 :       UncheckedCast<IntPtrT>(Parameter(Descriptor::kArgument));
      41             : 
      42         112 :   Return(BigIntFromInt64(argument));
      43             : }
      44             : 
      45             : }  // namespace internal
      46       94089 : }  // namespace v8

Generated by: LCOV version 1.10