tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit f8b6234c5cc8c0d31b6087b7f03d4de42ef242bf
parent aa614a6af4a7e122deef9317f518d400dfed7ec2
Author: André Bargull <andre.bargull@gmail.com>
Date:   Mon, 20 Oct 2025 12:27:40 +0000

Bug 1991402 - Part 1: Share more code in GetPropIRGenerator::tryAttachPrimitive. r=jandem

Avoid duplicate code for guards and loading the object.

Differential Revision: https://phabricator.services.mozilla.com/D266593

Diffstat:
Mjs/src/jit/CacheIR.cpp | 57++++++++++++++++++++++++++-------------------------------
1 file changed, 26 insertions(+), 31 deletions(-)

diff --git a/js/src/jit/CacheIR.cpp b/js/src/jit/CacheIR.cpp @@ -3016,49 +3016,44 @@ AttachDecision GetPropIRGenerator::tryAttachPrimitive(ValOperandId valId, Maybe<PropertyInfo> prop; NativeGetPropKind kind = CanAttachNativeGetProp(cx_, proto, id, &holder, &prop, pc_); + if (kind == NativeGetPropKind::None) { + return AttachDecision::NoAction; + } + + if (val_.isNumber()) { + writer.guardIsNumber(valId); + } else { + writer.guardNonDoubleType(valId, val_.type()); + } + maybeEmitIdGuard(id); + + auto* nproto = &proto->as<NativeObject>(); + ObjOperandId protoId = writer.loadObject(nproto); + switch (kind) { - case NativeGetPropKind::None: - return AttachDecision::NoAction; - case NativeGetPropKind::Missing: - case NativeGetPropKind::Slot: { - auto* nproto = &proto->as<NativeObject>(); + case NativeGetPropKind::Missing: { + EmitMissingPropResult(writer, nproto, protoId); + writer.returnFromIC(); - if (val_.isNumber()) { - writer.guardIsNumber(valId); - } else { - writer.guardNonDoubleType(valId, val_.type()); - } - maybeEmitIdGuard(id); + trackAttached("GetProp.PrimitiveMissing"); + return AttachDecision::Attach; + } + case NativeGetPropKind::Slot: { + emitLoadDataPropertyResult(nproto, holder, id, *prop, protoId); + writer.returnFromIC(); - ObjOperandId protoId = writer.loadObject(nproto); - if (kind == NativeGetPropKind::Slot) { - emitLoadDataPropertyResult(nproto, holder, id, *prop, protoId); - writer.returnFromIC(); - trackAttached("GetProp.PrimitiveSlot"); - } else { - EmitMissingPropResult(writer, nproto, protoId); - writer.returnFromIC(); - trackAttached("GetProp.PrimitiveMissing"); - } + trackAttached("GetProp.PrimitiveSlot"); return AttachDecision::Attach; } case NativeGetPropKind::ScriptedGetter: case NativeGetPropKind::NativeGetter: { - auto* nproto = &proto->as<NativeObject>(); - - if (val_.isNumber()) { - writer.guardIsNumber(valId); - } else { - writer.guardNonDoubleType(valId, val_.type()); - } - maybeEmitIdGuard(id); - - ObjOperandId protoId = writer.loadObject(nproto); emitCallGetterResult(kind, nproto, holder, id, *prop, protoId, valId); trackAttached("GetProp.PrimitiveGetter"); return AttachDecision::Attach; } + case NativeGetPropKind::None: + break; } MOZ_CRASH("Bad NativeGetPropKind");