From 8aafc7320198b3b625cb453ceb883947b55a6d88 Mon Sep 17 00:00:00 2001 From: Jan de Mooij Date: Tue, 9 Mar 2021 14:28:23 +0000 Subject: [PATCH] Bug 1696861 part 4 - Simplify some code in GeneratePrototypeGuards. r=tcampbell We already peeled off the receiver for non-delegates (= most objects) but we can do this for delegates too. Depends on D107418 Differential Revision: https://phabricator.services.mozilla.com/D107419 --- js/src/jit/CacheIR.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp index 38e6ac5363b8..5dfd02105c8c 100644 --- a/js/src/jit/CacheIR.cpp +++ b/js/src/jit/CacheIR.cpp @@ -643,8 +643,8 @@ static void TestMatchingProxyReceiver(CacheIRWriter& writer, ProxyObject* obj, } static bool ProtoChainSupportsTeleporting(JSObject* obj, JSObject* holder) { - // Any non-delegate should already have been handled since its checks are - // always required. + // The receiver should already have been handled since its checks are always + // required. MOZ_ASSERT(obj->isDelegate()); // Prototype chain must have cacheable prototypes to ensure the cached @@ -711,12 +711,9 @@ static void GeneratePrototypeGuards(CacheIRWriter& writer, JSObject* obj, MOZ_ASSERT(holder); MOZ_ASSERT(obj != holder); - // Only Delegate objects participate in teleporting so peel off the first - // object in the chain if needed and handle it directly. - JSObject* pobj = obj; - if (!obj->isDelegate()) { - pobj = obj->staticPrototype(); - } + // Receiver guards (see TestMatchingReceiver) ensure the receiver's proto is + // unchanged so peel off the receiver. + JSObject* pobj = obj->staticPrototype(); MOZ_ASSERT(pobj->isDelegate()); // If teleporting is supported for this prototype chain, we are done. @@ -730,8 +727,8 @@ static void GeneratePrototypeGuards(CacheIRWriter& writer, JSObject* obj, } // Synchronize pobj and protoId. - MOZ_ASSERT(pobj == obj || pobj == obj->staticPrototype()); - ObjOperandId protoId = (pobj == obj) ? objId : writer.loadProto(objId); + MOZ_ASSERT(pobj == obj->staticPrototype()); + ObjOperandId protoId = writer.loadProto(objId); // Guard prototype links from |pobj| to |holder|. while (pobj != holder) {