LCOV - code coverage report
Current view: top level - src/builtins - builtins-global-gen.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 47 47 100.0 %
Date: 2017-10-20 Functions: 4 4 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             : // ES #sec-isfinite-number
      13         124 : TF_BUILTIN(GlobalIsFinite, CodeStubAssembler) {
      14             :   Node* context = Parameter(Descriptor::kContext);
      15             : 
      16          31 :   Label return_true(this), return_false(this);
      17             : 
      18             :   // We might need to loop once for ToNumber conversion.
      19          62 :   VARIABLE(var_num, MachineRepresentation::kTagged);
      20          31 :   Label loop(this, &var_num);
      21          31 :   var_num.Bind(Parameter(Descriptor::kNumber));
      22          31 :   Goto(&loop);
      23          31 :   BIND(&loop);
      24             :   {
      25          31 :     Node* num = var_num.value();
      26             : 
      27             :     // Check if {num} is a Smi or a HeapObject.
      28          62 :     GotoIf(TaggedIsSmi(num), &return_true);
      29             : 
      30             :     // Check if {num} is a HeapNumber.
      31             :     Label if_numisheapnumber(this),
      32          31 :         if_numisnotheapnumber(this, Label::kDeferred);
      33          62 :     Branch(IsHeapNumber(num), &if_numisheapnumber, &if_numisnotheapnumber);
      34             : 
      35          31 :     BIND(&if_numisheapnumber);
      36             :     {
      37             :       // Check if {num} contains a finite, non-NaN value.
      38          62 :       Node* num_value = LoadHeapNumberValue(num);
      39          31 :       BranchIfFloat64IsNaN(Float64Sub(num_value, num_value), &return_false,
      40          62 :                            &return_true);
      41             :     }
      42             : 
      43          31 :     BIND(&if_numisnotheapnumber);
      44             :     {
      45             :       // Need to convert {num} to a Number first.
      46          31 :       var_num.Bind(CallBuiltin(Builtins::kNonNumberToNumber, context, num));
      47          31 :       Goto(&loop);
      48          31 :     }
      49             :   }
      50             : 
      51          31 :   BIND(&return_true);
      52          62 :   Return(TrueConstant());
      53             : 
      54          31 :   BIND(&return_false);
      55          93 :   Return(FalseConstant());
      56          31 : }
      57             : 
      58             : // ES6 #sec-isnan-number
      59         124 : TF_BUILTIN(GlobalIsNaN, CodeStubAssembler) {
      60             :   Node* context = Parameter(Descriptor::kContext);
      61             : 
      62          31 :   Label return_true(this), return_false(this);
      63             : 
      64             :   // We might need to loop once for ToNumber conversion.
      65          62 :   VARIABLE(var_num, MachineRepresentation::kTagged);
      66          31 :   Label loop(this, &var_num);
      67          31 :   var_num.Bind(Parameter(Descriptor::kNumber));
      68          31 :   Goto(&loop);
      69          31 :   BIND(&loop);
      70             :   {
      71          31 :     Node* num = var_num.value();
      72             : 
      73             :     // Check if {num} is a Smi or a HeapObject.
      74          62 :     GotoIf(TaggedIsSmi(num), &return_false);
      75             : 
      76             :     // Check if {num} is a HeapNumber.
      77             :     Label if_numisheapnumber(this),
      78          31 :         if_numisnotheapnumber(this, Label::kDeferred);
      79          62 :     Branch(IsHeapNumber(num), &if_numisheapnumber, &if_numisnotheapnumber);
      80             : 
      81          31 :     BIND(&if_numisheapnumber);
      82             :     {
      83             :       // Check if {num} contains a NaN.
      84          62 :       Node* num_value = LoadHeapNumberValue(num);
      85          31 :       BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
      86             :     }
      87             : 
      88          31 :     BIND(&if_numisnotheapnumber);
      89             :     {
      90             :       // Need to convert {num} to a Number first.
      91          31 :       var_num.Bind(CallBuiltin(Builtins::kNonNumberToNumber, context, num));
      92          31 :       Goto(&loop);
      93          31 :     }
      94             :   }
      95             : 
      96          31 :   BIND(&return_true);
      97          62 :   Return(TrueConstant());
      98             : 
      99          31 :   BIND(&return_false);
     100          93 :   Return(FalseConstant());
     101          31 : }
     102             : 
     103             : }  // namespace internal
     104             : }  // namespace v8

Generated by: LCOV version 1.10