Skip to content

WebIDL: use FLoat32Array - #30990

Merged
mrobinson merged 18 commits into
servo:mainfrom
gterzian:use_float_32_array
Jan 11, 2024
Merged

mrobinson merged 18 commits into
servo:mainfrom
gterzian:use_float_32_array

Conversation

@gterzian

@gterzian gterzian commented Jan 3, 2024 •

Copy link
Copy Markdown
Member

First part of #30889: applying to Float32Array.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because ___

@gterzian gterzian changed the title inital WebIDL: use FLoat32Array Jan 3, 2024
@gterzian
gterzian force-pushed the use_float_32_array branch from d9cdf47 to 24b18d1 Compare January 4, 2024 09:20
@gterzian

gterzian commented Jan 4, 2024

Copy link
Copy Markdown
Member Author

@jdm Here is a prototype(that compiles), could you please tell me what you think?

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual AudioBuffer code feels more clear with these changes, so I'm a fan!

@gterzian
gterzian force-pushed the use_float_32_array branch from 277f577 to 62a51ef Compare January 9, 2024 08:18
@gterzian
gterzian marked this pull request as ready for review January 10, 2024 06:01
IDLType.Tags.unrestricted_double: 'f64',
IDLType.Tags.double: 'Finite<f64>'
IDLType.Tags.double: 'Finite<f64>',
IDLBuiltinType.Tags.float32array: 'Float32Array'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this to use IDLType

@gterzian

gterzian commented Jan 10, 2024 •

Copy link
Copy Markdown
Member Author

@jdm Could you please review 5716fbf? I realized the dom matrix used the array without a backing heap, so added a util func and also used it iniside HeapFloat32Array. Not 100% sure of the rooting safety.

By the way I am aware of

pub fn create_typed_array(cx: SafeJSContext, src: &[f32], dst: &Heap<*mut JSObject>) {
, but it assumes a heap and I think it should remove once HeapFloat32Array is used everywhere else.

@gterzian
gterzian requested a review from jdm January 10, 2024 08:11

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and should be safely rooted!


#[derive(Default, JSTraceable)]
pub struct HeapFloat32Array {
internal: Heap<*mut JSObject>,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that the existing audio buffer code is unsafe, because storing Heapin a Vec means the values can be moved in memory when the vec resizes. Let's make this a Box<Heap<...>> instead so it's impossible to misuse?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@gterzian
gterzian added this pull request to the merge queue Jan 11, 2024
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 11, 2024
@mrobinson
mrobinson added this pull request to the merge queue Jan 11, 2024
Merged via the queue into servo:main with commit e145c51 Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants