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

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

Issue 2703563002: [ESNext] Implement DynamicImportCall (Closed)
Patch Set: use function_closure Created 3 years, 9 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
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<String> specifier_str;
21 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, specifier_str,
22 Object::ToString(isolate, specifier));
23
24 Handle<String> source_url;
25 Handle<Script> script(Script::cast(function->shared()->script()));
26 if (script->name()->IsUndefined(isolate)) {
27 source_url = isolate->factory()->empty_string();
28 } else {
29 source_url = handle(String::cast(script->name()), isolate);
30 }
31
32 Handle<JSPromise> promise = isolate->factory()->NewJSPromise();
33 isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str,
34 promise);
35 return *promise;
19 } 36 }
20 37
21 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) { 38 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) {
22 HandleScope scope(isolate); 39 HandleScope scope(isolate);
23 DCHECK_EQ(1, args.length()); 40 DCHECK_EQ(1, args.length());
24 CONVERT_SMI_ARG_CHECKED(module_request, 0); 41 CONVERT_SMI_ARG_CHECKED(module_request, 0);
25 Handle<Module> module(isolate->context()->module()); 42 Handle<Module> module(isolate->context()->module());
26 return *Module::GetModuleNamespace(module, module_request); 43 return *Module::GetModuleNamespace(module, module_request);
27 } 44 }
28 45
(...skipping 10 matching lines...) Expand all
39 DCHECK_EQ(2, args.length()); 56 DCHECK_EQ(2, args.length());
40 CONVERT_SMI_ARG_CHECKED(index, 0); 57 CONVERT_SMI_ARG_CHECKED(index, 0);
41 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 58 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
42 Handle<Module> module(isolate->context()->module()); 59 Handle<Module> module(isolate->context()->module());
43 Module::StoreVariable(module, index, value); 60 Module::StoreVariable(module, index, value);
44 return isolate->heap()->undefined_value(); 61 return isolate->heap()->undefined_value();
45 } 62 }
46 63
47 } // namespace internal 64 } // namespace internal
48 } // namespace v8 65 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698