111 auto context = Parameter<Context>(Descriptor::kContext);
112 auto creation_context = Parameter<Context>(Descriptor::kCreationContext);
113 auto target_context = Parameter<Context>(Descriptor::kTargetContext);
114 auto value = Parameter<Object>(Descriptor::kValue);
116 Label if_primitive(
this), if_callable(
this), unwrap(
this), wrap(
this),
117 slow_wrap(
this, Label::kDeferred), bailout(
this, Label::kDeferred);
120 GotoIf(TaggedIsSmi(value), &if_primitive);
121 GotoIfNot(JSAnyIsNotPrimitive(
CAST(value)), &if_primitive);
126 Branch(IsCallable(
CAST(value)), &if_callable, &bailout);
136 Branch(IsJSWrappedFunction(
CAST(value)), &unwrap, &wrap);
143 target = LoadObjectField(target_wrapped_function,
144 JSWrappedFunction::kWrappedTargetFunctionOffset);
151 GotoIf(IsDictionaryMap(map), &slow_wrap);
158 DecodeWordFromWord32<Map::Bits3::NumberOfOwnDescriptorsBits>(
bit_field3));
159 GotoIf(IntPtrLessThan(
160 number_of_own_descriptors,
167#if V8_ENABLE_WEBASSEMBLY
176 LengthStringConstant(), &slow_wrap);
181 NameStringConstant(), &slow_wrap);
187 LoadContextElement(target_context, Context::WRAPPED_FUNCTION_MAP_INDEX);
189 GotoIf(TaggedNotEqual(prototype, function_prototype), &slow_wrap);
203 AllocateJSWrappedFunction(creation_context, target.value());
210 Return(
CallRuntime(Runtime::kShadowRealmWrappedFunctionCreate, context,
211 creation_context, target.value()));
215 ThrowTypeError(context, MessageTemplate::kNotCallable, value);
220 auto argc = UncheckedParameter<Int32T>(Descriptor::kActualArgumentsCount);
222 auto wrapped_function = Parameter<JSWrappedFunction>(Descriptor::kFunction);
223 auto context = Parameter<Context>(Descriptor::kContext);
225 PerformStackCheck(context);
227 Label call_exception(
this, Label::kDeferred),
228 target_not_callable(
this, Label::kDeferred);
232 wrapped_function, JSWrappedFunction::kWrappedTargetFunctionOffset));
238 wrapped_function, JSWrappedFunction::kContextOffset);
241 GetFunctionRealm(caller_context, target, &target_not_callable);
253 IntPtrConstant(0), argc_ptr,
254 RootIndex::kUndefinedValue);
259 CallBuiltin(Builtin::kShadowRealmGetWrappedValue, caller_context,
260 target_context, caller_context,
receiver);
261 StoreFixedArrayElement(wrapped_args, 0, wrapped_receiver);
263 BuildFastLoop<IntPtrT>(
264 IntPtrConstant(0),
args.GetLengthWithoutReceiver(),
268 TNode<Object> wrapped_value =
269 CallBuiltin(Builtin::kShadowRealmGetWrappedValue, caller_context,
270 target_context, caller_context, args.AtIndex(index));
272 StoreFixedArrayElement(
273 wrapped_args, IntPtrAdd(index, IntPtrConstant(1)), wrapped_value);
275 1, LoopUnrollingMode::kNo, IndexAdvanceMode::kPost);
286 result = CallBuiltin(Builtin::kCallVarargs, target_context, target,
287 args_count, argc, wrapped_args);
293 CallBuiltin<JSAny>(Builtin::kShadowRealmGetWrappedValue, caller_context,
294 caller_context, target_context,
result);
295 args.PopAndReturn(wrapped_result);
298 BIND(&call_exception);
300 ShadowRealmThrow(context, MessageTemplate::kCallWrappedFunctionThrew,
301 var_exception.value());
303 BIND(&target_not_callable);
310 const char*
const kMethodName =
"ShadowRealm.prototype.importValue";
311 TNode<Context> context = Parameter<Context>(Descriptor::kContext);
315 ThrowIfNotInstanceType(context, O, JS_SHADOW_REALM_TYPE, kMethodName);
318 TNode<Object> specifier = Parameter<Object>(Descriptor::kSpecifier);
319 TNode<String> specifier_string = ToString_Inline(context, specifier);
321 TNode<Object> export_name = Parameter<Object>(Descriptor::kExportName);
322 TNode<String> export_name_string = ToString_Inline(context, export_name);
328 CAST(LoadObjectField(
CAST(O), JSShadowRealm::kNativeContextOffset));
332 specifier_string, export_name_string);
353 CallRuntime(Runtime::kShadowRealmImportValue, eval_context, specifier);
360 caller_context, eval_context, specifier, export_name);
363 caller_context, Context::SHADOW_REALM_IMPORT_VALUE_REJECTED_INDEX));
368 return CallBuiltin(Builtin::kPerformPromiseThen, caller_context,
369 inner_capability, on_fulfilled, on_rejected, promise);
379 TNode<Context> context = Parameter<Context>(Descriptor::kContext);
381 context, ImportValueFulfilledFunctionContextSlot::kEvalContextSlot));
383 Label get_export_exception(
this, Label::kDeferred);
389 context, ImportValueFulfilledFunctionContextSlot::kExportNameSlot));
393 Parameter<JSModuleNamespace>(Descriptor::kExports);
406 value =
CallRuntime(Runtime::kGetModuleNamespaceExport, eval_context,
407 exports, export_name_string);
413 CallBuiltin(Builtin::kShadowRealmGetWrappedValue, caller_context,
414 caller_context, eval_context, value);
415 Return(wrapped_result);
417 BIND(&get_export_exception);
420 context, ImportValueFulfilledFunctionContextSlot::kSpecifierSlot));
421 ThrowTypeError(context, MessageTemplate::kUnresolvableExport,
422 specifier_string, export_name_string);
TNode< JSObject > AllocateJSObjectFromMap(TNode< Map > map, std::optional< TNode< HeapObject > > properties=std::nullopt, std::optional< TNode< FixedArray > > elements=std::nullopt, AllocationFlags flags=AllocationFlag::kNone, SlackTrackingMode slack_tracking_mode=kNoSlackTracking)