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

Remove slice_to_array_buffer_view and update_array_buffer_view #15427

Merged
merged 1 commit into from Feb 11, 2017

Conversation

@yysung1123
Copy link
Contributor

yysung1123 commented Feb 7, 2017

Remove slice_to_array_buffer_view and update_array_buffer_view


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #15350
  • These changes do not require tests

This change is Reviewable

@highfive
Copy link

highfive commented Feb 7, 2017

Heads up! This PR modifies the following files:

  • @fitzgen: components/script/dom/vreyeparameters.rs, components/script/dom/vrframedata.rs, components/script/dom/vrpose.rs, components/script/dom/bindings/conversions.rs, components/script/dom/vrstageparameters.rs
  • @KiChjang: components/script/dom/vreyeparameters.rs, components/script/dom/vrframedata.rs, components/script/dom/vrpose.rs, components/script/dom/bindings/conversions.rs, components/script/dom/vrstageparameters.rs
@highfive
Copy link

highfive commented Feb 7, 2017

warning Warning warning

  • These commits modify script code, but no tests are modified. Please consider adding a test!
let _ = TypedArray::<Float32>::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
MutableHandleObject::from_marked_location(framedata.right_proj.get_unsafe()));
let _ = TypedArray::<Float32>::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
MutableHandleObject::from_marked_location(framedata.right_view.get_unsafe()));

This comment has been minimized.

@jdm

jdm Feb 7, 2017

Member

We should add a handle_mut() method to Heap instead of using from_marked_location everywhere.

This comment has been minimized.

@yysung1123

yysung1123 Feb 7, 2017

Author Contributor

Yes, the code is too long.
I can add handle_mut() and fix the code in this PR.

@yysung1123 yysung1123 force-pushed the yysung1123:rewrite-webvr branch 2 times, most recently from 3085939 to d58082c Feb 7, 2017
@yysung1123
Copy link
Contributor Author

yysung1123 commented Feb 8, 2017

Change all MutableHandleObject::from_marked_location to handle_mut().

@jdm jdm assigned jdm and unassigned wafflespeanut Feb 9, 2017
Copy link
Member

jdm left a comment

Looks good! I just have some stylistic comments to make it easier to read.

@@ -39,7 +39,8 @@ impl VREyeParameters {
};

unsafe {
result.offset.set(slice_to_array_buffer_view(global.get_cx(), &result.parameters.borrow().offset));
let _ = TypedArray::<Float32>::create(global.get_cx(), result.parameters.borrow().offset.len() as u32,
Some(&result.parameters.borrow().offset), result.offset.handle_mut());

This comment has been minimized.

@jdm

jdm Feb 9, 2017

Member

Let format this like:

let _ = Float32Array::create(global.get_cx(),
                             result.parameters.borrow().offset.len() as u32,
                             Some(&result.parameters.borrow().offset),
                             result.offset.handle_mut());
let _ = TypedArray::<Float32>::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
framedata.right_proj.handle_mut());
let _ = TypedArray::<Float32>::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
framedata.right_view.handle_mut());

This comment has been minimized.

@jdm

jdm Feb 9, 2017

Member

nit: use Float32Array::create and indent the second line to match global.get_cx().

@@ -33,9 +33,13 @@ unsafe fn update_or_create_typed_array(cx: *mut JSContext,
match src {
Some(ref data) => {
if dst.get().is_null() {
dst.set(slice_to_array_buffer_view(cx, &data));
let _ = TypedArray::<Float32>::create(cx, data.len() as u32, src,
dst.handle_mut());

This comment has been minimized.

@jdm

jdm Feb 9, 2017

Member

nit: Float32Array::create, and move dst.handle_mut() into the previous line.

let _ = TypedArray::<Float32>::create(global.get_cx(),
stage.parameters.borrow().sitting_to_standing_transform.len() as u32,
Some(&stage.parameters.borrow().sitting_to_standing_transform),
stage.transform.handle_mut());

This comment has been minimized.

@jdm

jdm Feb 9, 2017

Member

nit: Float32Array::create, and indent each line to match global.get_cx().

@yysung1123 yysung1123 force-pushed the yysung1123:rewrite-webvr branch from d58082c to 3ca2332 Feb 10, 2017
@yysung1123
Copy link
Contributor Author

yysung1123 commented Feb 10, 2017

Fixed changes requested.

Copy link
Member

jdm left a comment

Sorry, one last issue that I noticed.

let _ = Float32Array::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
framedata.right_proj.handle_mut());
let _ = Float32Array::create(global.get_cx(), matrix.len() as u32, Some(&matrix),
framedata.right_view.handle_mut());

This comment has been minimized.

@jdm

jdm Feb 10, 2017

Member

This is a GC hazard right now - the GC does not know about framedata yet, so if any of the Float32Array::create calls trigger a GC, the existing typed arrays will be GCed and framedata will store invalid pointers. We should call reflect_dom_object first before creating the arrays.

@yysung1123 yysung1123 force-pushed the yysung1123:rewrite-webvr branch from c670d3b to 2d99f7f Feb 11, 2017
@jdm
Copy link
Member

jdm commented Feb 11, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2017

📌 Commit 2d99f7f has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2017

Testing commit 2d99f7f with merge 1ab3c34...

bors-servo added a commit that referenced this pull request Feb 11, 2017
Remove slice_to_array_buffer_view and update_array_buffer_view

<!-- Please describe your changes on the following line: -->
Remove slice_to_array_buffer_view and update_array_buffer_view

---
<!-- 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 #15350
- [X] These changes do not require tests

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

<!-- 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/15427)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Feb 11, 2017

@bors-servo bors-servo merged commit 2d99f7f into servo:master Feb 11, 2017
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
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.