blob: 9a4174563a44bebacffe6df058d528348c8a8c31 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// Copyright 2022 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/execution/arguments-inl.h"
#include "src/objects/js-function.h"
namespace v8 {
namespace internal {
RUNTIME_FUNCTION(Runtime_ShadowRealmWrappedFunctionCreate) {
DCHECK_EQ(2, args.length());
HandleScope scope(isolate);
Handle<NativeContext> native_context = args.at<NativeContext>(0);
Handle<JSReceiver> value = args.at<JSReceiver>(1);
RETURN_RESULT_OR_FAILURE(
isolate, JSWrappedFunction::Create(isolate, native_context, value));
}
// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
RUNTIME_FUNCTION(Runtime_ShadowRealmImportValue) {
DCHECK_EQ(1, args.length());
HandleScope scope(isolate);
Handle<String> specifier = args.at<String>(0);
Handle<JSPromise> inner_capability;
MaybeHandle<Object> import_assertions;
MaybeHandle<Script> referrer;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, inner_capability,
isolate->RunHostImportModuleDynamicallyCallback(referrer, specifier,
import_assertions));
// Check that the promise is created in the eval_context.
DCHECK(
inner_capability->GetCreationContext().ToHandleChecked().is_identical_to(
isolate->native_context()));
return *inner_capability;
}
RUNTIME_FUNCTION(Runtime_ShadowRealmThrow) {
DCHECK_EQ(2, args.length());
HandleScope scope(isolate);
int message_id_smi = args.smi_value_at(0);
Handle<Object> value = args.at(1);
MessageTemplate message_id = MessageTemplateFromInt(message_id_smi);
Handle<String> string = Object::NoSideEffectsToString(isolate, value);
THROW_NEW_ERROR_RETURN_FAILURE(isolate, NewTypeError(message_id, string));
}
} // namespace internal
} // namespace v8
|