Mark promise creation methods with CanGc (#33928)

* Add CanGc annotations to promise constructor.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc arguments for Promise::new_in_current_realm.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Fix out-of-order entries.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Propagate CanGc from Promise::new.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Suppress clippy warning.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

* Formatting.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
Josh Matthews 2024-10-22 05:35:20 -04:00 committed by GitHub
parent edc304854f
commit 575e885529
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
50 changed files with 422 additions and 221 deletions

View file

@ -20,41 +20,46 @@ DOMInterfaces = {
'AudioContext': {
'inRealms': ['Close', 'Suspend'],
'canGc':['CreateMediaStreamDestination', 'CreateMediaElementSource', 'CreateMediaStreamSource', 'CreateMediaStreamTrackSource'],
'canGc':['CreateMediaStreamDestination', 'CreateMediaElementSource', 'CreateMediaStreamSource', 'CreateMediaStreamTrackSource', 'Suspend', 'Close'],
},
'BaseAudioContext': {
'inRealms': ['DecodeAudioData', 'Resume', 'ParseFromString', 'GetBounds', 'GetClientRects'],
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter', 'CreateBuffer', 'CreateConstantSource'],
'canGc': ['CreateChannelMerger', 'CreateOscillator', 'CreateStereoPanner', 'CreateGain', 'CreateIIRFilter', 'CreateBiquadFilter', 'CreateBufferSource', 'CreateAnalyser', 'CreatePanner', 'CreateChannelSplitter', 'CreateBuffer', 'CreateConstantSource', 'Resume', 'DecodeAudioData'],
},
'Blob': {
'weakReferenceable': True,
'canGc': ['Slice'],
'canGc': ['Slice', 'Text', 'ArrayBuffer'],
},
'Bluetooth': {
'inRealms': ['GetAvailability', 'RequestDevice'],
'canGc': ['RequestDevice', 'GetAvailability'],
},
'BluetoothDevice': {
'inRealms': ['WatchAdvertisements'],
'canGc': ['WatchAdvertisements'],
},
'BluetoothRemoteGATTCharacteristic': {
'inRealms': ['ReadValue', 'StartNotifications', 'StopNotifications', 'WriteValue'],
'canGc': ['GetDescriptor', 'GetDescriptors', 'ReadValue', 'StartNotifications', 'StopNotifications', 'WriteValue'],
},
'BluetoothRemoteGATTDescriptor': {
'inRealms': ['ReadValue', 'WriteValue'],
'canGc': ['ReadValue', 'WriteValue'],
},
'BluetoothRemoteGATTServer': {
'inRealms': ['Connect'],
'canGc': ['GetPrimaryService', 'GetPrimaryServices', 'Connect'],
},
'CustomElementRegistry': {
'inRealms': ['WhenDefined'],
'BluetoothRemoteGATTService': {
'canGc': ['GetCharacteristic', 'GetCharacteristics', 'GetIncludedService', 'GetIncludedServices'],
},
'CanvasRenderingContext2D': {
@ -65,20 +70,25 @@ DOMInterfaces = {
'canGc': ['AddColorStop'],
},
'DOMImplementation': {
'canGc': ['CreateDocument', 'CreateHTMLDocument'],
'CustomElementRegistry': {
'inRealms': ['WhenDefined'],
'canGc': ['WhenDefined'],
},
'DOMParser': {
'canGc': ['ParseFromString'],
'DOMImplementation': {
'canGc': ['CreateDocument', 'CreateHTMLDocument'],
},
'DOMMatrix': {
'canGc': ['FromMatrix', 'FromFloat32Array', 'FromFloat64Array'],
},
'DOMQuad': {
'canGc': ['FromRect', 'FromQuad', 'GetBounds'],
'DOMMatrixReadOnly': {
'canGc': ['Multiply', 'Inverse', 'Scale', 'Translate', 'Rotate', 'RotateFromVector','FlipY', 'ScaleNonUniform', 'Scale3d', 'RotateAxisAngle', 'SkewX', 'SkewY', 'FlipX', 'TransformPoint', 'FromFloat32Array', 'FromFloat64Array','FromMatrix'],
},
'DOMParser': {
'canGc': ['ParseFromString'],
},
'DOMPoint': {
@ -89,12 +99,12 @@ DOMInterfaces = {
'canGc': ['FromPoint'],
},
'DOMMatrixReadOnly': {
'canGc': ['Multiply', 'Inverse', 'Scale', 'Translate', 'Rotate', 'RotateFromVector','FlipY', 'ScaleNonUniform', 'Scale3d', 'RotateAxisAngle', 'SkewX', 'SkewY', 'FlipX', 'TransformPoint', 'FromFloat32Array', 'FromFloat64Array','FromMatrix'],
'DOMQuad': {
'canGc': ['FromRect', 'FromQuad', 'GetBounds'],
},
'Document': {
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_', 'Fonts', 'ElementFromPoint', 'ElementsFromPoint'],
'canGc': ['Close', 'CreateElement', 'CreateElementNS', 'ImportNode', 'SetTitle', 'Write', 'Writeln', 'CreateEvent', 'CreateRange', 'Open', 'Open_', 'Fonts', 'ElementFromPoint', 'ElementsFromPoint', 'ExitFullscreen'],
},
'DynamicModuleOwner': {
@ -102,7 +112,7 @@ DOMInterfaces = {
},
'Element': {
'canGc': ['SetInnerHTML', 'SetOuterHTML', 'InsertAdjacentHTML', 'GetClientRects', 'GetBoundingClientRect', 'SetScrollTop', 'SetScrollLeft', 'Scroll', 'Scroll_', 'ScrollBy', 'ScrollBy_', 'ScrollWidth', 'ScrollHeight', 'ScrollTop', 'ScrollLeft', 'ClientTop', 'ClientLeft', 'ClientWidth', 'ClientHeight'],
'canGc': ['SetInnerHTML', 'SetOuterHTML', 'InsertAdjacentHTML', 'GetClientRects', 'GetBoundingClientRect', 'SetScrollTop', 'SetScrollLeft', 'Scroll', 'Scroll_', 'ScrollBy', 'ScrollBy_', 'ScrollWidth', 'ScrollHeight', 'ScrollTop', 'ScrollLeft', 'ClientTop', 'ClientLeft', 'ClientWidth', 'ClientHeight', 'RequestFullscreen'],
},
'ElementInternals': {
@ -117,6 +127,10 @@ DOMInterfaces = {
'canGc': ['DispatchEvent'],
},
'FakeXRDevice': {
'canGc': ['Disconnect'],
},
'File': {
'weakReferenceable': True,
},
@ -127,14 +141,17 @@ DOMInterfaces = {
'GPU': {
'inRealms': ['RequestAdapter'],
'canGc': ['RequestAdapter'],
},
'GPUAdapter': {
'inRealms': ['RequestAdapterInfo', 'RequestDevice'],
'canGc': ['RequestAdapterInfo', 'RequestDevice'],
},
'GPUBuffer': {
'inRealms': ['MapAsync'],
'canGc': ['MapAsync'],
},
'GPUDevice': {
@ -144,11 +161,22 @@ DOMInterfaces = {
'CreateShaderModule', # Creates promise for compilation info
'PopErrorScope'
],
'canGc': [
'CreateComputePipelineAsync',
'CreateRenderPipelineAsync',
'CreateShaderModule',
'PopErrorScope'
],
'weakReferenceable': True, # for usage in GlobalScope https://github.com/servo/servo/issues/32519
},
'GPUQueue': {
'canGc': ['OnSubmittedWorkDone'],
},
'GamepadHapticActuator': {
'inRealms': ['PlayEffect', 'Reset']
'inRealms': ['PlayEffect', 'Reset'],
'canGc': ['PlayEffect', 'Reset'],
},
'History': {
@ -159,8 +187,12 @@ DOMInterfaces = {
'canGc': ['ReportValidity'],
},
'HTMLCanvasElement': {
'canGc': ['CaptureStream', 'GetContext'],
},
'HTMLElement': {
'canGc': ['Focus', 'Blur', 'Click'],
'canGc': ['GetOffsetParent', 'OffsetTop', 'OffsetLeft', 'OffsetWidth', 'OffsetHeight', 'InnerText', 'GetOuterText', 'Focus', 'Blur', 'Click'],
},
'HTMLFieldSetElement': {
@ -175,6 +207,10 @@ DOMInterfaces = {
'canGc': ['ReportValidity', 'SelectFiles'],
},
'HTMLImageElement': {
'canGc': ['Width', 'Height', 'Decode'],
},
'HTMLMediaElement': {
'canGc': ['Load', 'Pause', 'Play', 'SetSrcObject'],
'inRealms': ['Play'],
@ -188,10 +224,6 @@ DOMInterfaces = {
'canGc': ['ReportValidity'],
},
'HTMLCanvasElement': {
'canGc': ['CaptureStream', 'GetContext'],
},
'HTMLSelectElement': {
'canGc': ['ReportValidity'],
},
@ -200,14 +232,6 @@ DOMInterfaces = {
'canGc': ['Content'],
},
'HTMLElement': {
'canGc': ['GetOffsetParent', 'OffsetTop', 'OffsetLeft', 'OffsetWidth', 'OffsetHeight', 'InnerText', 'GetOuterText', 'Focus', 'Blur', 'Click'],
},
'HTMLImageElement': {
'canGc': ['Width', 'Height'],
},
'HTMLTextAreaElement': {
'canGc': ['ReportValidity'],
},
@ -217,7 +241,7 @@ DOMInterfaces = {
},
'MediaDevices': {
'canGc': ['GetUserMedia'],
'canGc': ['GetUserMedia', 'EnumerateDevices'],
'inRealms': ['GetUserMedia', 'GetClientRects', 'GetBoundingClientRect'],
},
@ -243,6 +267,7 @@ DOMInterfaces = {
'NavigationPreloadManager': {
'inRealms': ['Disable', 'Enable', 'GetState', 'SetHeaderValue'],
'canGc': ['Disable', 'Enable', 'GetState', 'SetHeaderValue'],
},
'Navigator': {
@ -255,6 +280,7 @@ DOMInterfaces = {
'OfflineAudioContext': {
'inRealms': ['StartRendering'],
'canGc': ['StartRendering'],
},
'OffscreenCanvasRenderingContext2D': {
@ -265,13 +291,21 @@ DOMInterfaces = {
'canGc': ['GetTransform', 'SetStrokeStyle', 'SetFillStyle', 'SetShadowColor'],
},
'Permissions': {
'canGc': ['Query', 'Request', 'Revoke'],
},
'Promise': {
'spiderMonkeyInterface': True,
},
'RTCPeerConnection': {
'inRealms': ['AddIceCandidate', 'CreateAnswer', 'CreateOffer', 'SetLocalDescription', 'SetRemoteDescription'],
'canGc': ['Close'],
'canGc': ['Close', 'AddIceCandidate', 'CreateAnswer', 'CreateOffer', 'SetLocalDescription', 'SetRemoteDescription'],
},
'RTCRtpSender': {
'canGc': ['SetParameters'],
},
'Range': {
@ -279,42 +313,46 @@ DOMInterfaces = {
'weakReferenceable': True,
},
'Response': {
'canGc': ['Error', 'Redirect', 'Clone', 'Text', 'Blob', 'FormData', 'Json', 'ArrayBuffer', 'Headers'],
},
'Request': {
'canGc': ['Headers', 'Text', 'Blob', 'FormData', 'Json', 'ArrayBuffer', 'Clone'],
},
'Response': {
'canGc': ['Error', 'Redirect', 'Clone', 'Text', 'Blob', 'FormData', 'Json', 'ArrayBuffer', 'Headers'],
},
'Selection': {
'canGc': ['Collapse', 'CollapseToEnd', 'CollapseToStart', 'Extend', 'SelectAllChildren', 'SetBaseAndExtent', 'SetPosition'],
},
'ServiceWorkerContainer': {
'inRealms': ['Register'],
},
'StaticRange': {
'weakReferenceable': True,
'canGc': ['Register'],
},
'ShadowRoot': {
'canGc': ['ElementFromPoint', 'ElementsFromPoint'],
},
'StaticRange': {
'weakReferenceable': True,
},
'SubtleCrypto': {
'inRealms': ['Encrypt', 'Decrypt', 'GenerateKey', 'ImportKey', 'ExportKey']
'inRealms': ['Encrypt', 'Decrypt', 'GenerateKey', 'ImportKey', 'ExportKey'],
'canGc': ['Encrypt', 'Decrypt', 'GenerateKey', 'ImportKey', 'ExportKey'],
},
#FIXME(jdm): This should be 'register': False, but then we don't generate enum types
'TestBinding': {
'inRealms': ['PromiseAttribute', 'PromiseNativeHandler'],
'canGc': ['InterfaceAttribute', 'GetInterfaceAttributeNullable', 'ReceiveInterface', 'ReceiveInterfaceSequence', 'ReceiveNullableInterface'],
'canGc': ['InterfaceAttribute', 'GetInterfaceAttributeNullable', 'ReceiveInterface', 'ReceiveInterfaceSequence', 'ReceiveNullableInterface', 'PromiseAttribute', 'PromiseNativeHandler'],
},
'TestWorklet': {
'inRealms': ['AddModule'],
'canGc': ['AddModule'],
},
'URL': {
@ -322,12 +360,16 @@ DOMInterfaces = {
'canGc': ['Parse', 'SearchParams'],
},
'VRDisplay': {
'inRealms': ['ExitPresent', 'RequestPresent'],
'WebGLRenderingContext': {
'canGc': ['MakeXRCompatible'],
},
'WebGL2RenderingContext': {
'canGc': ['MakeXRCompatible'],
},
'Window': {
'canGc': ['Stop', 'Fetch', 'Scroll', 'Scroll_','ScrollBy', 'ScrollBy_', 'Stop', 'Fetch', 'Open'],
'canGc': ['Stop', 'Fetch', 'Scroll', 'Scroll_','ScrollBy', 'ScrollBy_', 'Stop', 'Fetch', 'Open', 'CreateImageBitmap'],
'inRealms': ['Fetch', 'GetOpener'],
},
@ -338,11 +380,12 @@ DOMInterfaces = {
'WorkerGlobalScope': {
'inRealms': ['Fetch'],
'canGc': ['Fetch'],
'canGc': ['Fetch', 'CreateImageBitmap'],
},
'Worklet': {
'inRealms': ['AddModule'],
'canGc': ['AddModule'],
},
'XMLHttpRequest': {
@ -375,11 +418,16 @@ DOMInterfaces = {
'XRSession': {
'inRealms': ['RequestReferenceSpace', 'UpdateRenderState', 'UpdateTargetFrameRate'],
'canGc': ['End', 'RequestReferenceSpace'],
'canGc': ['End', 'RequestReferenceSpace', 'UpdateTargetFrameRate', 'RequestHitTestSource'],
},
'XRSystem': {
'inRealms': ['RequestSession', 'SupportsSessionMode'],
'inRealms': ['RequestSession'],
'canGc': ['RequestSession', 'IsSessionSupported'],
},
'XRTest': {
'canGc': ['SimulateDeviceConnection', 'DisconnectAllDevices'],
},
}