LCOV - code coverage report
Current view: top level - src/builtins - builtins-global.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 27 27 100.0 %
Date: 2019-03-21 Functions: 15 22 68.2 %

          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/code-factory.h"
       8             : #include "src/compiler.h"
       9             : #include "src/counters.h"
      10             : #include "src/objects-inl.h"
      11             : #include "src/uri.h"
      12             : 
      13             : namespace v8 {
      14             : namespace internal {
      15             : 
      16             : // ES6 section 18.2.6.2 decodeURI (encodedURI)
      17       14625 : BUILTIN(GlobalDecodeURI) {
      18             :   HandleScope scope(isolate);
      19             :   Handle<String> encoded_uri;
      20        5850 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      21             :       isolate, encoded_uri,
      22             :       Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      23             : 
      24        3087 :   RETURN_RESULT_OR_FAILURE(isolate, Uri::DecodeUri(isolate, encoded_uri));
      25             : }
      26             : 
      27             : // ES6 section 18.2.6.3 decodeURIComponent (encodedURIComponent)
      28       13725 : BUILTIN(GlobalDecodeURIComponent) {
      29             :   HandleScope scope(isolate);
      30             :   Handle<String> encoded_uri_component;
      31        5490 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      32             :       isolate, encoded_uri_component,
      33             :       Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      34             : 
      35        2895 :   RETURN_RESULT_OR_FAILURE(
      36             :       isolate, Uri::DecodeUriComponent(isolate, encoded_uri_component));
      37             : }
      38             : 
      39             : // ES6 section 18.2.6.4 encodeURI (uri)
      40       26550 : BUILTIN(GlobalEncodeURI) {
      41             :   HandleScope scope(isolate);
      42             :   Handle<String> uri;
      43       10620 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      44             :       isolate, uri, Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      45             : 
      46        7776 :   RETURN_RESULT_OR_FAILURE(isolate, Uri::EncodeUri(isolate, uri));
      47             : }
      48             : 
      49             : // ES6 section 18.2.6.5 encodeURIComponenet (uriComponent)
      50      704014 : BUILTIN(GlobalEncodeURIComponent) {
      51             :   HandleScope scope(isolate);
      52             :   Handle<String> uri_component;
      53      281615 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      54             :       isolate, uri_component,
      55             :       Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      56             : 
      57      143279 :   RETURN_RESULT_OR_FAILURE(isolate,
      58             :                            Uri::EncodeUriComponent(isolate, uri_component));
      59             : }
      60             : 
      61             : // ES6 section B.2.1.1 escape (string)
      62      186435 : BUILTIN(GlobalEscape) {
      63             :   HandleScope scope(isolate);
      64             :   Handle<String> string;
      65       74574 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      66             :       isolate, string,
      67             :       Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      68             : 
      69       74574 :   RETURN_RESULT_OR_FAILURE(isolate, Uri::Escape(isolate, string));
      70             : }
      71             : 
      72             : // ES6 section B.2.1.2 unescape (string)
      73      955311 : BUILTIN(GlobalUnescape) {
      74             :   HandleScope scope(isolate);
      75             :   Handle<String> string;
      76      382127 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      77             :       isolate, string,
      78             :       Object::ToString(isolate, args.atOrUndefined(isolate, 1)));
      79             : 
      80      382120 :   RETURN_RESULT_OR_FAILURE(isolate, Uri::Unescape(isolate, string));
      81             : }
      82             : 
      83             : // ES6 section 18.2.1 eval (x)
      84        9650 : BUILTIN(GlobalEval) {
      85             :   HandleScope scope(isolate);
      86             :   Handle<Object> x = args.atOrUndefined(isolate, 1);
      87             :   Handle<JSFunction> target = args.target();
      88        3860 :   Handle<JSObject> target_global_proxy(target->global_proxy(), isolate);
      89        1930 :   if (!x->IsString()) return *x;
      90        1492 :   if (!Builtins::AllowDynamicFunction(isolate, target, target_global_proxy)) {
      91           6 :     isolate->CountUsage(v8::Isolate::kFunctionConstructorReturnedUndefined);
      92           6 :     return ReadOnlyRoots(isolate).undefined_value();
      93             :   }
      94             :   Handle<JSFunction> function;
      95        4479 :   ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
      96             :       isolate, function,
      97             :       Compiler::GetFunctionFromString(handle(target->native_context(), isolate),
      98             :                                       Handle<String>::cast(x),
      99             :                                       NO_PARSE_RESTRICTION, kNoSourcePosition));
     100        2972 :   RETURN_RESULT_OR_FAILURE(
     101             :       isolate,
     102             :       Execution::Call(isolate, function, target_global_proxy, 0, nullptr));
     103             : }
     104             : 
     105             : }  // namespace internal
     106      120216 : }  // namespace v8

Generated by: LCOV version 1.10