Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMozmap #20318
Mozmap #20318
Conversation
|
I resolved the issue as discussed with @jdm. Converting |
|
You should run |
| use std::ops::Deref; | ||
|
|
||
| pub trait MozMapKey : Eq + Hash + Sized { | ||
| unsafe fn to_utf16_vec(&self) -> Vec<u16>; |
This comment has been minimized.
This comment has been minimized.
|
|
||
| impl MozMapKey for ByteString { | ||
| unsafe fn to_utf16_vec(&self) -> Vec<u16> { | ||
| (*self).iter().map(|&x| x as u16).collect::<Vec<u16>>() |
This comment has been minimized.
This comment has been minimized.
| use std::ops::Deref; | ||
|
|
||
| pub trait MozMapKey : Eq + Hash + Sized { | ||
| unsafe fn to_utf16_vec(&self) -> Vec<u16>; | ||
| unsafe fn from_handle_id(cx: *mut JSContext, id: HandleId) -> Option<Self>; |
This comment has been minimized.
This comment has been minimized.
| use std::ops::Deref; | ||
|
|
||
| pub trait MozMapKey : Eq + Hash + Sized { |
This comment has been minimized.
This comment has been minimized.
| @@ -69,12 +122,12 @@ impl<T, C> FromJSValConvertible for MozMap<T> | |||
| return Err(()); | |||
| } | |||
|
|
|||
| let property = match T::from_jsval(cx, property.handle(), config.clone())? { | |||
| let property = match V::from_jsval(cx, property.handle(), config.clone())? { | |||
This comment has been minimized.
This comment has been minimized.
jdm
Mar 20, 2018
Member
The implementation of this method doesn't quite match https://heycam.github.io/webidl/#es-record. Before calling JS_GetPropertyId, we need to call JS_GetOwnPropertyDescriptor and verify that the result is not undefined and enumerable. We also need to convert the key before converting the value.
This comment has been minimized.
This comment has been minimized.
taki-jaro
Mar 20, 2018
Author
I have a problem with using JS_GetOwnPropertyDescriptorById. To call that function I should have MuableHandle and I am not sure how to obtain one in a way that will make the PropertyDescriptor rooted properly. AFAIK standard way to call such functions is doing sth like rooted!(in(cx) let mut desc = UndefinedValue()) and using desc.handle_mut() but it gives jsapi::MutableHandlejs::jsapi::Value instead of MutableHandle. I would appreciate some pointers
| /// The `MozMap` (open-ended dictionary) type. | ||
| #[derive(Clone, JSTraceable)] | ||
| pub struct MozMap<T> { | ||
| map: HashMap<DOMString, T>, | ||
| pub struct MozMap<K: MozMapKey, V> { |
This comment has been minimized.
This comment has been minimized.
|
Sorry for long delay. After review of GetOwnPropertyDescriptor from mozjs I don't think PropertyDescriptor needs rooting because there isn't created by this method. The method just uses structure given. PropertyDescriptor doesn't even have implemented traits for rooted! macro to work As for headers-record no new tests started passing. They fail because of bad log size. I don't really understand this. Should I add some logging? |
|
Could you paste the errors that you're referring to? |
|
"The method just uses structure given. PropertyDescriptor doesn't even have implemented traits for rooted! macro to work" |
|
As for errors I get:
From |
|
@taki-jaro I suspect that we're not implementing the right behaviour for duplicate keys. https://bugzilla.mozilla.org/attachment.cgi?id=8837012&action=diff was a patch for this in gecko. |
|
@taki-jaro More specifically, I bet our MozMap implementation does not have a defined iteration order because it relies on Rust's hashmap type. Gecko's record implementation uses an array instead, which is why the previous patch was important for it. |
|
@jdm: I mean most of the test fail with this or similiar error or from error from logger. I post the full tests logs below:
|
|
@jdm: As for rooting. I am looking into implementing it for PropertyDescriptor. But I don't exactly understand what is |
|
One other way in which our implementation differs: GetPropertyKeys only passes JSITER_OWN_ONLY, but Gecko passes other flags: https://searchfox.org/mozilla-central/source/dom/bindings/Codegen.py#5107-5108 |
|
@taki-jaro From my reading, the post_barrier implementation for JSPropertyDescriptor can be empty. |
|
@jdm I am having troubles with compiling servo with rust-mozjs version 0.5.1 with my commits for PropertyDescriptor. It turns out that rust-mozjs version 0.5 made not backward-compatbile changes in recent accepted PR (changed function CollectServoSizes to take 3 arguments instead of 2) and the servo PR to update servo to work with rust-mozjs 0.5.0 looks like it has some way to be merged. The change seem not too trivial and ignoring the additional parameter and passing I don't know how to proceed as my improved PR won't compile without my changes from mozjs. |
|
You can use the 0.5 version by passing None to CollectServoSizes. That should be enough to allow you to continue compiling locally. Once we understand the test failures better and have addressed the implementation issues you can look at rebasing your changes. |
|
|
|
@nox, are you able to shed some light? |
|
@nox Could you investigate the previous question? |
|
Yes, sorry that completely fell off my radar. |
|
@jdm I'm super lost thanks to the wrapper changes in mozjs. |
Given that there is a |
|
@jdm For the first question, this seems to be something deep in SpiderMonkey. I don't have anything more to say than @taki-jaro's own explanation. Do we miss a lot of |
|
I don't know the answer to that, unfortunately. |
|
I rebases it locally and am looking at the failures.
|
|
@nox ok, thank you. |
|
So the issue is that |
|
Tweaking that snippet a bit, I could make the test run but still fail, because |
|
Ok, that's probably error on my side. Would you mind pushing these changes, so I can look into it myself? |
|
I don't think we can commit it as is and land such a dumbing down of the test in WPT, but you can at least apply my changes to fix the rest sure. :) Once you are done, we can temporarily clone the dumbed down version as a --- i/tests/wpt/web-platform-tests/fetch/api/headers/headers-record.html
+++ w/tests/wpt/web-platform-tests/fetch/api/headers/headers-record.html
@@ -16,7 +16,8 @@ var loggingHandler = {
};
setup(function() {
- for (let prop of Object.getOwnPropertyNames(Reflect)) {
+ for (let prop_ of Object.getOwnPropertyNames(Reflect)) {
+ let prop = prop_;
loggingHandler[prop] = function(...args) {
addLogEntry(prop, args);
return Reflect[prop](...args); |
|
@nox, @jdm, sorry for the delay, but I am completely at lost as to why it happens. It seems like What is even more amusing, Gecko has it implemented in exactly the same way as in this PR i.e. first |
|
SpiderMonkey was updated since then, and I think that makes the code with |
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318 <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318. Possibly also closes #21463. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318. Possibly also closes #21463. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
|
Closing in favour of #24377. |
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318. Possibly also closes #21463. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
Support WebIDL `record<>` <!-- Please describe your changes on the following line: --> Rebased @taki-zaro's work (#20318). --- <!-- 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 #15012 and closes #20318. Possibly also closes #21463. <!-- Either: --> - [x] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/24377) <!-- Reviewable:end -->
taki-jaro commentedMar 16, 2018
•
edited
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsI am stuck on how to make it possible to have
ByteStringas record key. To be the key in current implementationByteStringneeds to be convertible from jsid and convertible toVec<u16>(for other types it is underlying raw representation of utf-16 string). I am not sure how the conversion should be handled. Should it just convert utf-16 jsid to utf-8 and back or maybe just convert utf-16 jsid to some kind of byte by byte representation (little-endian, big-endian?). Maybe the conversion should be handled differently altogether? I would appreciate some suggestionsThis change is