OLD | NEW |
---|---|
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 v8::TryCatch catcher(reinterpret_cast<v8::Isolate*>(isolate)); | |
24 MaybeHandle<String> maybe_specifier = Object::ToString(isolate, specifier); | |
25 if (!maybe_specifier.ToHandle(&specifier_str)) { | |
26 DCHECK(catcher.HasCaught()); | |
27 MaybeHandle<Object> reason = v8::Utils::OpenHandle(*catcher.Exception()); | |
28 isolate->OptionalRescheduleException(true); | |
29 | |
30 Handle<Object> argv[] = {promise, reason.ToHandleChecked(), | |
31 isolate->factory()->ToBoolean(false)}; | |
32 | |
33 RETURN_FAILURE_ON_EXCEPTION( | |
34 isolate, Execution::Call(isolate, isolate->promise_internal_reject(), | |
35 isolate->factory()->undefined_value(), | |
36 arraysize(argv), argv)) | |
37 return *promise; | |
38 } | |
neis
2017/03/17 10:36:32
Please add DCHECK(!catcher.HasCaught()) here.
gsathya
2017/03/17 21:47:59
Done.
| |
39 | |
neis
2017/03/17 10:36:32
This comment is about the spec, not your implement
gsathya
2017/03/17 21:47:59
Yeah, I found this weird too.
| |
40 Handle<String> source_url = isolate->factory()->empty_string(); | |
41 Handle<Script> script(Script::cast(function->shared()->script())); | |
42 if (script->name()->IsString()) { | |
43 source_url = handle(String::cast(script->name()), isolate); | |
44 } | |
45 | |
neis
2017/03/17 10:36:32
Do we understand in which situations the name is n
gsathya
2017/03/17 21:48:00
I had this because I thought the D8 shell didn't p
| |
46 isolate->RunHostImportModuleDynamicallyCallback(source_url, specifier_str, | |
47 promise); | |
48 return *promise; | |
19 } | 49 } |
20 | 50 |
21 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) { | 51 RUNTIME_FUNCTION(Runtime_GetModuleNamespace) { |
22 HandleScope scope(isolate); | 52 HandleScope scope(isolate); |
23 DCHECK_EQ(1, args.length()); | 53 DCHECK_EQ(1, args.length()); |
24 CONVERT_SMI_ARG_CHECKED(module_request, 0); | 54 CONVERT_SMI_ARG_CHECKED(module_request, 0); |
25 Handle<Module> module(isolate->context()->module()); | 55 Handle<Module> module(isolate->context()->module()); |
26 return *Module::GetModuleNamespace(module, module_request); | 56 return *Module::GetModuleNamespace(module, module_request); |
27 } | 57 } |
28 | 58 |
(...skipping 10 matching lines...) Expand all Loading... | |
39 DCHECK_EQ(2, args.length()); | 69 DCHECK_EQ(2, args.length()); |
40 CONVERT_SMI_ARG_CHECKED(index, 0); | 70 CONVERT_SMI_ARG_CHECKED(index, 0); |
41 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); | 71 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); |
42 Handle<Module> module(isolate->context()->module()); | 72 Handle<Module> module(isolate->context()->module()); |
43 Module::StoreVariable(module, index, value); | 73 Module::StoreVariable(module, index, value); |
44 return isolate->heap()->undefined_value(); | 74 return isolate->heap()->undefined_value(); |
45 } | 75 } |
46 | 76 |
47 } // namespace internal | 77 } // namespace internal |
48 } // namespace v8 | 78 } // namespace v8 |
OLD | NEW |