mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-24 02:01:35 +00:00
Optimize shim generation for structural
items
This commit removes shims, where possible, for `structural` items. Instead of generating code that looks like: const target = function() { this.foo(); }; exports.__wbg_thing = function(a) { target.call(getObject(a)); }; we now instead generate: exports.__wbg_thing = function(a) { getObject(a).foo(); }; Note that this only applies to `structural` bindings, all default bindings (as of this commit) are still using imported targets to ensure that their binding can't change after instantiation. This change was [detailed in RFC #5][link] as an important optimization for `structural` bindings to ensure they've got performance parity with today's non-`structural` default bindings. [link]: https://rustwasm.github.io/rfcs/005-structural-and-deref.html#why-is-it-ok-to-make-structural-the-default
This commit is contained in:
@ -129,7 +129,7 @@ fn get_own_property_descriptor() {
|
||||
let desc = Object::get_own_property_descriptor(&foo, &"foo".into());
|
||||
assert_eq!(PropertyDescriptor::from(desc).value(), 42);
|
||||
let desc = Object::get_own_property_descriptor(&foo, &"bar".into());
|
||||
assert!(PropertyDescriptor::from(desc).value().is_undefined());
|
||||
assert!(desc.is_undefined());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
|
@ -114,7 +114,7 @@ fn get_own_property_descriptor() {
|
||||
let desc = Reflect::get_own_property_descriptor(&obj, &"x".into()).unwrap();
|
||||
assert_eq!(PropertyDescriptor::from(desc).value(), 10);
|
||||
let desc = Reflect::get_own_property_descriptor(&obj, &"foo".into()).unwrap();
|
||||
assert!(PropertyDescriptor::from(desc).value().is_undefined());
|
||||
assert!(desc.is_undefined());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
|
Reference in New Issue
Block a user