LCOV - code coverage report
Current view: top level - src/runtime - runtime-module.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 20 32 62.5 %
Date: 2017-04-26 Functions: 2 8 25.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/runtime/runtime-utils.h"
       6             : 
       7             : #include "src/arguments.h"
       8             : #include "src/counters.h"
       9             : #include "src/objects-inl.h"
      10             : 
      11             : namespace v8 {
      12             : namespace internal {
      13             : 
      14         896 : RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
      15         406 :   HandleScope scope(isolate);
      16             :   DCHECK_EQ(2, args.length());
      17         812 :   CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
      18         406 :   CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
      19             : 
      20         406 :   Handle<JSPromise> promise = isolate->factory()->NewJSPromise();
      21             : 
      22             :   Handle<String> specifier_str;
      23         406 :   MaybeHandle<String> maybe_specifier = Object::ToString(isolate, specifier);
      24         406 :   if (!maybe_specifier.ToHandle(&specifier_str)) {
      25             :     DCHECK(isolate->has_pending_exception());
      26          84 :     Handle<Object> reason(isolate->pending_exception(), isolate);
      27          84 :     isolate->clear_pending_exception();
      28             : 
      29             :     Handle<Object> argv[] = {promise, reason,
      30          84 :                              isolate->factory()->ToBoolean(false)};
      31             : 
      32         252 :     RETURN_FAILURE_ON_EXCEPTION(
      33             :         isolate, Execution::Call(isolate, isolate->promise_internal_reject(),
      34             :                                  isolate->factory()->undefined_value(),
      35             :                                  arraysize(argv), argv))
      36             :     return *promise;
      37             :   }
      38             :   DCHECK(!isolate->has_pending_exception());
      39             : 
      40         322 :   Handle<Script> script(Script::cast(function->shared()->script()));
      41         322 :   Handle<String> source_url(String::cast(script->name()));
      42             : 
      43             :   isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
      44         322 :                                                   promise);
      45         406 :   return *promise;
      46             : }
      47             : 
      48         483 : RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
      49         161 :   HandleScope scope(isolate);
      50             :   DCHECK_EQ(1, args.length());
      51         322 :   CONVERT_SMI_ARG_CHECKED(module_request, 0);
      52         161 :   Handle<Module> module(isolate->context()->module());
      53         322 :   return *Module::GetModuleNamespace(module, module_request);
      54             : }
      55             : 
      56           0 : RUNTIME_FUNCTION(Runtime_LoadModuleVariable) {
      57           0 :   HandleScope scope(isolate);
      58             :   DCHECK_EQ(1, args.length());
      59           0 :   CONVERT_SMI_ARG_CHECKED(index, 0);
      60           0 :   Handle<Module> module(isolate->context()->module());
      61           0 :   return *Module::LoadVariable(module, index);
      62             : }
      63             : 
      64           0 : RUNTIME_FUNCTION(Runtime_StoreModuleVariable) {
      65           0 :   HandleScope scope(isolate);
      66             :   DCHECK_EQ(2, args.length());
      67           0 :   CONVERT_SMI_ARG_CHECKED(index, 0);
      68           0 :   CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
      69           0 :   Handle<Module> module(isolate->context()->module());
      70           0 :   Module::StoreVariable(module, index, value);
      71           0 :   return isolate->heap()->undefined_value();
      72             : }
      73             : 
      74             : }  // namespace internal
      75             : }  // namespace v8

Generated by: LCOV version 1.10