Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrote websocket array buffer handling to typed array API #14718

Merged
merged 1 commit into from Dec 28, 2016

Conversation

@dpyro
Copy link
Contributor

dpyro commented Dec 24, 2016

  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #14675 (github issue number if applicable).
  • These changes do not require tests because they replace an existing implementation

I am not certain the test suite will adequately verify my implementation as I am not familiar with the architecture. It compiles and passes the current tests.


This change is Reviewable

@KiChjang
Copy link
Member

KiChjang commented Dec 24, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Dec 24, 2016

Trying commit 68d64da with merge c8078fb...

bors-servo added a commit that referenced this pull request Dec 24, 2016
Rewrote websocket array buffer handling to typed array API

<!-- Please describe your changes on the following line: -➜
Replaced existing code for handling `BinaryType::Arraybuffer` from `JS_NewArrayBuffer` to `Uint8Array::create`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14675 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because they replace an existing implementation

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

I am not certain the test suite will adequately verify my implementation as I am not familiar with the architecture. It compiles and passes the current tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14718)
<!-- Reviewable:end -->
@jdm jdm self-assigned this Dec 24, 2016
let len = data.len() as u32;
rooted!(in(cx) let mut array_buffer = ptr::null_mut());
assert!(Uint8Array::create(cx, len, Some(data.as_slice()),
array_buffer.handle_mut()).is_ok());

This comment has been minimized.

@jdm

jdm Dec 24, 2016

Member

This should be using ArrayBuffer::create instead.

let mut is_shared = false;
let buf_data: *mut uint8_t = JS_GetArrayBufferData(buf, &mut is_shared, ptr::null());
let buf_data: *mut uint8_t =
JS_GetUint8ArrayData(*array_buffer, &mut is_shared, ptr::null());
assert!(!is_shared);
ptr::copy_nonoverlapping(data.as_ptr(), buf_data, len as usize);

This comment has been minimized.

@jdm

jdm Dec 24, 2016

Member

All of the code to fill the buffer here is now unnecessary, since that's handled in by the create method.

assert!(!is_shared);
ptr::copy_nonoverlapping(data.as_ptr(), buf_data, len as usize);
buf.to_jsval(cx, message.handle_mut());
data.to_jsval(cx, message.handle_mut());

This comment has been minimized.

@jdm

jdm Dec 24, 2016

Member

This change means that we return the original string value, instead of the new array buffer. I'm actually rather concerned that this passes tests ;)

@dpyro dpyro force-pushed the dpyro:websocket-typed-arrays branch from 68d64da to a137806 Dec 25, 2016
@dpyro dpyro force-pushed the dpyro:websocket-typed-arrays branch from a137806 to 4623b5f Dec 26, 2016
@jdm
Copy link
Member

jdm commented Dec 28, 2016

It turns out that our websocket arraybuffer tests are all failing because of #14761, hence why the bits in the original PR that worried me didn't cause any new test failures.

@jdm
Copy link
Member

jdm commented Dec 28, 2016

I'd like to try to fix that issue first, so that we can be confident that these changes don't regress anything.

@jdm
Copy link
Member

jdm commented Dec 28, 2016

Nevermind, I figured out why #14761 is broken and we can't fix it yet. These changes look fine to me, in that case :)

@jdm
Copy link
Member

jdm commented Dec 28, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Dec 28, 2016

📌 Commit 4623b5f has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Dec 28, 2016

Testing commit 4623b5f with merge 0f600db...

bors-servo added a commit that referenced this pull request Dec 28, 2016
Rewrote websocket array buffer handling to typed array API

<!-- Please describe your changes on the following line: -➜
Replaced existing code for handling `BinaryType::Arraybuffer` from `JS_NewArrayBuffer` to `Uint8Array::create`.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix #14675 (github issue number if applicable).

<!-- Either: -->
- [X] These changes do not require tests because they replace an existing implementation

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

I am not certain the test suite will adequately verify my implementation as I am not familiar with the architecture. It compiles and passes the current tests.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14718)
<!-- Reviewable:end -->
@bors-servo bors-servo merged commit 4623b5f into servo:master Dec 28, 2016
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build failed
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.