You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem: the JS_HasProperty + JS_GetProperty pattern shows up quite a bit and it's fairly expensive when the property exists on the prototype chain because it walks the prototype chain twice. Even when the property is on the this object, it still does double work.
Solution: add a JS_TryGetProperty that combines both operations, a la JS_TryGetPropertyInt64.
(JS_TryGetPropertyInt64 could be optimized the same way as well, by the way.)
The text was updated successfully, but these errors were encountered:
Hi, I'm looking into this and I'm wondering if we couldn't just check if JS_GetProperty (JS_GetPropertyInternal2) returns JS_UNDEFINED as building a JS_TryGetProperty would basicly be a copy of of JS_GetPropertyInternal2 and return FALSE where JS_GetPropertyInternal2 returns JS_UNDEFINED
so e.g. JS_TryGetPropertyInt64
turn this
JSValueval=JS_UNDEFINED;
JSAtomprop;
intpresent;
if (likely((uint64_t)idx <= JS_ATOM_MAX_INT)) {
/* fast path */present=JS_HasProperty(ctx, obj, __JS_AtomFromUInt32(idx));
if (present>0) {
val=JS_GetPropertyValue(ctx, obj, js_int32(idx));
if (unlikely(JS_IsException(val)))
present=-1;
}
} else {
check if JS_GetProperty (JS_GetPropertyInternal2) returns JS_UNDEFINED
Assuming I understand your suggestion correctly: JS_UNDEFINED is a legitimate return value (property with value undefined) so that wouldn't work. JS_UNINITIALIZED or some other sentinel that's never a valid property value perhaps could.
Problem: the JS_HasProperty + JS_GetProperty pattern shows up quite a bit and it's fairly expensive when the property exists on the prototype chain because it walks the prototype chain twice. Even when the property is on the
this
object, it still does double work.Solution: add a JS_TryGetProperty that combines both operations, a la JS_TryGetPropertyInt64.
(JS_TryGetPropertyInt64 could be optimized the same way as well, by the way.)
The text was updated successfully, but these errors were encountered: