Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/runtime/runtime-module.cc

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/counters.h" 8 #include "src/counters.h"
9 #include "src/objects-inl.h" 9 #include "src/objects-inl.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 13
14 RUNTIME_FUNCTION(Runtime_DynamicImportCall) { 14 RUNTIME_FUNCTION(Runtime_DynamicImportCall) {
15 HandleScope scope(isolate); 15 HandleScope scope(isolate);
16 DCHECK_EQ(1, args.length()); 16 DCHECK_EQ(2, args.length());
17 // TODO(gsathya): Implement ImportCall. 17 CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0);
18 return isolate->heap()->undefined_value(); 18 CONVERT_ARG_HANDLE_CHECKED(Object, specifier, 1);
19
20 Handle<JSPromise> promise = isolate->factory()->NewJSPromise();
21
22 Handle<String> specifier_str;
23 MaybeHandle<String> maybe_specifier = Object::ToString(isolate, specifier);
24 if (!maybe_specifier.ToHandle(&specifier_str)) {
25 DCHECK(isolate->has_pending_exception());
26 Handle<Object> reason(isolate->pending_exception(), isolate);
27 isolate->clear_pending_exception();
28
29 Handle<Object> argv[] = {promise, reason,
30 isolate->factory()->ToBoolean(false)};
31
32 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 Handle<Script> script(Script::cast(function->shared()->script()));
41 Handle<String> source_url(String::cast(script->name()));
42
43 isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
44 promise);
45 return *promise;
19 } 46 }
20 47
21 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) { 48 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
22 HandleScope scope(isolate); 49 HandleScope scope(isolate);
23 DCHECK_EQ(1, args.length()); 50 DCHECK_EQ(1, args.length());
24 CONVERT_SMI_ARG_CHECKED(module_request, 0); 51 CONVERT_SMI_ARG_CHECKED(module_request, 0);
25 Handle<Module> module(isolate->context()->module()); 52 Handle<Module> module(isolate->context()->module());
26 return *Module::GetModuleNamespace(module, module_request); 53 return *Module::GetModuleNamespace(module, module_request);
27 } 54 }
28 55
(...skipping 10 matching lines...) Expand all
39 DCHECK_EQ(2, args.length()); 66 DCHECK_EQ(2, args.length());
40 CONVERT_SMI_ARG_CHECKED(index, 0); 67 CONVERT_SMI_ARG_CHECKED(index, 0);
41 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 68 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
42 Handle<Module> module(isolate->context()->module()); 69 Handle<Module> module(isolate->context()->module());
43 Module::StoreVariable(module, index, value); 70 Module::StoreVariable(module, index, value);
44 return isolate->heap()->undefined_value(); 71 return isolate->heap()->undefined_value();
45 } 72 }
46 73
47 } // namespace internal 74 } // namespace internal
48 } // namespace v8 75 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698