@@ -7,6 +7,7 @@ use crate::frame::This;
77use crate :: gc:: persistent:: Persistent ;
88use crate :: gc:: trace:: { Trace , TraceCtxt } ;
99use crate :: gc:: { ObjectId , ObjectVTable } ;
10+ use crate :: util:: cold_path;
1011use bitflags:: bitflags;
1112use dash_middle:: interner:: sym;
1213use dash_proc_macro:: Trace ;
@@ -229,28 +230,33 @@ pub struct PropertyValue {
229230}
230231
231232impl PropertyValue {
233+ #[ inline]
232234 pub fn new ( kind : PropertyValueKind , descriptor : PropertyDataDescriptor ) -> Self {
233235 Self { kind, descriptor }
234236 }
235237
236- /// Convenience function for creating a static property with a default descriptor (all bits set to 1)
238+ /// Convenience function for creating a static property with a default descriptor
239+ #[ inline]
237240 pub fn static_default ( value : Value ) -> Self {
238241 Self :: new ( PropertyValueKind :: Static ( value) , Default :: default ( ) )
239242 }
240243
241244 /// Convenience function for creating a static property with an empty descriptor (all bits set to 0)
245+ #[ inline]
242246 pub fn static_empty ( value : Value ) -> Self {
243247 Self :: new ( PropertyValueKind :: Static ( value) , PropertyDataDescriptor :: empty ( ) )
244248 }
245249
246250 /// Convenience function for creating a static, non-enumerable property
251+ #[ inline]
247252 pub fn static_non_enumerable ( value : Value ) -> Self {
248253 Self :: new (
249254 PropertyValueKind :: Static ( value) ,
250255 PropertyDataDescriptor :: WRITABLE | PropertyDataDescriptor :: CONFIGURABLE ,
251256 )
252257 }
253258
259+ #[ inline]
254260 pub fn getter_default ( value : ObjectId ) -> Self {
255261 Self :: new (
256262 PropertyValueKind :: Trap {
@@ -261,6 +267,7 @@ impl PropertyValue {
261267 )
262268 }
263269
270+ #[ inline]
264271 pub fn setter_default ( value : ObjectId ) -> Self {
265272 Self :: new (
266273 PropertyValueKind :: Trap {
@@ -271,22 +278,27 @@ impl PropertyValue {
271278 )
272279 }
273280
281+ #[ inline]
274282 pub fn kind ( & self ) -> & PropertyValueKind {
275283 & self . kind
276284 }
277285
286+ #[ inline]
278287 pub fn kind_mut ( & mut self ) -> & mut PropertyValueKind {
279288 & mut self . kind
280289 }
281290
291+ #[ inline]
282292 pub fn into_parts ( self ) -> ( PropertyValueKind , PropertyDataDescriptor ) {
283293 ( self . kind , self . descriptor )
284294 }
285295
296+ #[ inline]
286297 pub fn into_kind ( self ) -> PropertyValueKind {
287298 self . kind
288299 }
289300
301+ #[ inline]
290302 pub fn get_or_apply ( & self , sc : & mut LocalScope , this : This ) -> Result < Unrooted , Unrooted > {
291303 self . kind . get_or_apply ( sc, this)
292304 }
@@ -646,10 +658,20 @@ pub fn delegate_get_property<T: Object + ?Sized>(
646658 sc : & mut LocalScope ,
647659 key : PropertyKey ,
648660) -> Result < Unrooted , Unrooted > {
649- this. get_property_descriptor ( key, sc)
650- . map ( |x| x. unwrap_or_else ( || PropertyValue :: static_default ( Value :: undefined ( ) ) ) )
651- . and_then ( |x| x. get_or_apply ( sc, this_value) )
661+ let desc = match this. get_property_descriptor ( key, sc) {
662+ Ok ( Some ( desc) ) => desc,
663+ Ok ( None ) => {
664+ return Ok ( Value :: undefined ( ) . into ( ) ) ;
665+ }
666+ Err ( err) => {
667+ cold_path ( ) ;
668+ return Err ( err) ;
669+ }
670+ } ;
671+
672+ desc. get_or_apply ( sc, this_value)
652673}
674+
653675/// Delegates a get_property call to get_property_descriptor and converts the return value respectively
654676pub fn delegate_get_own_property < T : Object + ?Sized > (
655677 this : & T ,
0 commit comments