LCOV - code coverage report
Current view: top level - src/builtins - builtins-boolean.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 10 10 100.0 %
Date: 2019-03-21 Functions: 3 4 75.0 %

          Line data    Source code
       1             : // Copyright 2016 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-inl.h"
       6             : #include "src/builtins/builtins.h"
       7             : #include "src/counters.h"
       8             : #include "src/heap/heap-inl.h"  // For ToBoolean. TODO(jkummerow): Drop.
       9             : #include "src/objects-inl.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14             : // -----------------------------------------------------------------------------
      15             : // ES #sec-boolean-objects
      16             : 
      17             : // ES #sec-boolean-constructor
      18       12910 : BUILTIN(BooleanConstructor) {
      19             :   HandleScope scope(isolate);
      20        2582 :   if (args.new_target()->IsUndefined(isolate)) {  // [[Call]]
      21             :     Handle<Object> value = args.atOrUndefined(isolate, 1);
      22        2888 :     return isolate->heap()->ToBoolean(value->BooleanValue(isolate));
      23             :   }
      24             :   // [[Construct]]
      25             :   Handle<Object> value = args.atOrUndefined(isolate, 1);
      26        1138 :   Handle<JSFunction> target = args.target();
      27        1138 :   Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target());
      28             :   DCHECK(*target == target->native_context()->boolean_function());
      29             :   Handle<JSObject> result;
      30        2276 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      31             :       isolate, result,
      32             :       JSObject::New(target, new_target, Handle<AllocationSite>::null()));
      33        2276 :   Handle<JSValue>::cast(result)->set_value(
      34        4552 :       isolate->heap()->ToBoolean(value->BooleanValue(isolate)));
      35        1138 :   return *result;
      36             : }
      37             : 
      38             : }  // namespace internal
      39      120216 : }  // namespace v8

Generated by: LCOV version 1.10