v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
runtime-shadow-realm.cc
Go to the documentation of this file.
1// Copyright 2022 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
7
8namespace v8 {
9namespace internal {
10
11RUNTIME_FUNCTION(Runtime_ShadowRealmWrappedFunctionCreate) {
12 DCHECK_EQ(2, args.length());
13 HandleScope scope(isolate);
16
18 isolate, JSWrappedFunction::Create(isolate, native_context, value));
19}
20
21// https://tc39.es/proposal-shadowrealm/#sec-shadowrealm.prototype.importvalue
22RUNTIME_FUNCTION(Runtime_ShadowRealmImportValue) {
23 DCHECK_EQ(1, args.length());
24 HandleScope scope(isolate);
25 Handle<String> specifier = args.at<String>(0);
26
27 DirectHandle<JSPromise> inner_capability;
28
29 MaybeDirectHandle<Object> import_options;
32 isolate, inner_capability,
33 isolate->RunHostImportModuleDynamicallyCallback(
34 referrer, specifier, ModuleImportPhase::kEvaluation, import_options));
35 // Check that the promise is created in the eval_context.
36 DCHECK_EQ(inner_capability->GetCreationContext().value(),
37 isolate->raw_native_context());
38
39 return *inner_capability;
40}
41
42RUNTIME_FUNCTION(Runtime_ShadowRealmThrow) {
43 DCHECK_EQ(2, args.length());
44 HandleScope scope(isolate);
45 int message_id_smi = args.smi_value_at(0);
46 DirectHandle<Object> value = args.at(1);
47
48 MessageTemplate message_id = MessageTemplateFromInt(message_id_smi);
49
52 isolate, ShadowRealmNewTypeErrorCopy(value, message_id, string));
53}
54
55} // namespace internal
56} // namespace v8
static MaybeDirectHandle< Object > Create(Isolate *isolate, DirectHandle< NativeContext > creation_context, DirectHandle< JSReceiver > value)
static V8_EXPORT_PRIVATE DirectHandle< String > NoSideEffectsToString(Isolate *isolate, DirectHandle< Object > input)
Definition objects.cc:687
#define RUNTIME_FUNCTION(Name)
Definition arguments.h:162
#define ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, dst, call)
Definition isolate.h:284
#define THROW_NEW_ERROR_RETURN_FAILURE(isolate, call)
Definition isolate.h:294
#define RETURN_RESULT_OR_FAILURE(isolate, call)
Definition isolate.h:264
base::Vector< const DirectHandle< Object > > args
Definition execution.cc:74
MessageTemplate MessageTemplateFromInt(int message_id)
!IsContextMap !IsContextMap native_context
Definition map-inl.h:877
#define DCHECK_EQ(v1, v2)
Definition logging.h:485