11cb0ef41Sopenharmony_ci// Copyright 2019 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include "src/builtins/builtins-utils-inl.h" 61cb0ef41Sopenharmony_ci#include "src/objects/module-inl.h" 71cb0ef41Sopenharmony_ci#include "src/objects/objects-inl.h" 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_cinamespace v8 { 101cb0ef41Sopenharmony_cinamespace internal { 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_ciBUILTIN(CallAsyncModuleFulfilled) { 131cb0ef41Sopenharmony_ci HandleScope handle_scope(isolate); 141cb0ef41Sopenharmony_ci Handle<SourceTextModule> module(args.at<SourceTextModule>(0)); 151cb0ef41Sopenharmony_ci if (SourceTextModule::AsyncModuleExecutionFulfilled(isolate, module) 161cb0ef41Sopenharmony_ci .IsNothing()) { 171cb0ef41Sopenharmony_ci // The evaluation of async module can not throwing a JavaScript observable 181cb0ef41Sopenharmony_ci // exception. 191cb0ef41Sopenharmony_ci DCHECK(isolate->has_pending_exception()); 201cb0ef41Sopenharmony_ci DCHECK_EQ(isolate->pending_exception(), 211cb0ef41Sopenharmony_ci ReadOnlyRoots(isolate).termination_exception()); 221cb0ef41Sopenharmony_ci return ReadOnlyRoots(isolate).exception(); 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci return ReadOnlyRoots(isolate).undefined_value(); 251cb0ef41Sopenharmony_ci} 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ciBUILTIN(CallAsyncModuleRejected) { 281cb0ef41Sopenharmony_ci HandleScope handle_scope(isolate); 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci // Arguments should be a SourceTextModule and an exception object. 311cb0ef41Sopenharmony_ci DCHECK_EQ(args.length(), 2); 321cb0ef41Sopenharmony_ci Handle<SourceTextModule> module(args.at<SourceTextModule>(0)); 331cb0ef41Sopenharmony_ci Handle<Object> exception(args.at(1)); 341cb0ef41Sopenharmony_ci SourceTextModule::AsyncModuleExecutionRejected(isolate, module, exception); 351cb0ef41Sopenharmony_ci return ReadOnlyRoots(isolate).undefined_value(); 361cb0ef41Sopenharmony_ci} 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci} // namespace internal 391cb0ef41Sopenharmony_ci} // namespace v8 40