Changeset 289417 in webkit for trunk/Source/JavaScriptCore/builtins
- Timestamp:
- Feb 8, 2022, 12:42:04 PM (3 years ago)
- Location:
- trunk/Source/JavaScriptCore/builtins
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/builtins/BuiltinNames.h
r287136 r289417 190 190 macro(emptyPropertyNameEnumerator) \ 191 191 macro(sentinelString) \ 192 macro(createRemoteFunction) \ 193 macro(isRemoteFunction) \ 192 194 193 195 -
trunk/Source/JavaScriptCore/builtins/ShadowRealmPrototype.js
r287109 r289417 33 33 34 34 if (@isCallable(target)) { 35 var wrapped = function(/* args... */) { 36 var length = arguments.length; 37 var wrappedArgs = @newArrayWithSize(length); 38 for (var index = 0; index < length; ++index) 39 // Note that for arguments, we flip `fromShadowRealm` since to 40 // wrap a function from realm A to work in realm B, we need to 41 // wrap the arguments (from realm B) to work in realm A before 42 // calling the wrapped function 43 @putByValDirect(wrappedArgs, index, @wrap(!fromShadowRealm, shadowRealm, arguments[index])); 44 45 try { 46 var result = target.@apply(@undefined, wrappedArgs); 47 } catch (e) { 48 const msg = "wrapped function threw: " + e.toString(); 49 if (fromShadowRealm) 50 @throwTypeError(msg); 51 else { 52 const mkTypeError = @evalInRealm(shadowRealm, "(msg) => new TypeError(msg)"); 53 const err = mkTypeError.@apply(msg); 54 throw err; 55 } 56 } 57 return @wrap(fromShadowRealm, shadowRealm, result); 58 }; 59 delete wrapped['name']; 60 delete wrapped['length']; 61 62 // Because this function (wrap) will run with the incubating realm 63 // active, we only need to fix the prototype on `wrapped` if we are 64 // moving the function from the incubating realm to the shadow realm 65 if (!fromShadowRealm) 66 @moveFunctionToRealm(wrapped, shadowRealm); 67 return wrapped; 35 return @createRemoteFunction(target, fromShadowRealm ? null : shadowRealm); 68 36 } else if (@isObject(target)) { 69 37 @throwTypeError("value passing between realms must be callable or primitive");
Note:
See TracChangeset
for help on using the changeset viewer.