@@ -305,6 +305,9 @@ Maybe<InlinableGetterData> FindInlinableGetterData(ICCacheIRStub* stub) {
305305 const CacheIRStubInfo* stubInfo = stub->stubInfo ();
306306 const uint8_t * stubData = stub->stubDataStart ();
307307
308+ ObjOperandId maybeCalleeOperand;
309+ uintptr_t maybeRawCallee = 0 ;
310+
308311 CacheIRReader reader (stubInfo);
309312 while (reader.more ()) {
310313 const uint8_t * opStart = reader.currentPosition ();
@@ -315,37 +318,47 @@ Maybe<InlinableGetterData> FindInlinableGetterData(ICCacheIRStub* stub) {
315318 mozilla::DebugOnly<const uint8_t *> argStart = reader.currentPosition ();
316319
317320 switch (op) {
321+ case CacheOp::LoadObject: {
322+ // If we load a constant object, remember it in case it's the callee.
323+ maybeCalleeOperand = reader.objOperandId ();
324+ uint32_t maybeCalleeOffset = reader.stubOffset ();
325+ maybeRawCallee = stubInfo->getStubRawWord (stubData, maybeCalleeOffset);
326+ break ;
327+ }
318328 case CacheOp::CallScriptedGetterResult: {
319- data.emplace ();
320- data->receiverOperand = reader.valOperandId ();
321-
322- uint32_t getterOffset = reader.stubOffset ();
323- uintptr_t rawTarget = stubInfo->getStubRawWord (stubData, getterOffset);
324- data->target = reinterpret_cast <JSFunction*>(rawTarget);
325-
326- data->sameRealm = reader.readBool ();
329+ ValOperandId receiverOperand = reader.valOperandId ();
330+ ObjOperandId calleeOperand = reader.objOperandId ();
331+ bool sameRealm = reader.readBool ();
327332 (void )reader.stubOffset (); // nargsAndFlags
328333
329- data->endOfSharedPrefix = opStart;
334+ if (maybeCalleeOperand == calleeOperand) {
335+ data.emplace ();
336+ data->target = reinterpret_cast <JSFunction*>(maybeRawCallee);
337+ data->receiverOperand = receiverOperand;
338+ data->calleeOperand = calleeOperand;
339+ data->sameRealm = sameRealm;
340+ data->endOfSharedPrefix = opStart;
341+ }
330342 break ;
331343 }
332344 case CacheOp::CallInlinedGetterResult: {
333- data.emplace ();
334- data->receiverOperand = reader.valOperandId ();
335-
336- uint32_t getterOffset = reader.stubOffset ();
337- uintptr_t rawTarget = stubInfo->getStubRawWord (stubData, getterOffset);
338- data->target = reinterpret_cast <JSFunction*>(rawTarget);
339-
345+ ValOperandId receiverOperand = reader.valOperandId ();
346+ ObjOperandId calleeOperand = reader.objOperandId ();
340347 uint32_t icScriptOffset = reader.stubOffset ();
341348 uintptr_t rawICScript =
342349 stubInfo->getStubRawWord (stubData, icScriptOffset);
343- data->icScript = reinterpret_cast <ICScript*>(rawICScript);
344-
345- data->sameRealm = reader.readBool ();
350+ bool sameRealm = reader.readBool ();
346351 (void )reader.stubOffset (); // nargsAndFlags
347352
348- data->endOfSharedPrefix = opStart;
353+ if (maybeCalleeOperand == calleeOperand) {
354+ data.emplace ();
355+ data->target = reinterpret_cast <JSFunction*>(maybeRawCallee);
356+ data->receiverOperand = receiverOperand;
357+ data->calleeOperand = calleeOperand;
358+ data->icScript = reinterpret_cast <ICScript*>(rawICScript);
359+ data->sameRealm = sameRealm;
360+ data->endOfSharedPrefix = opStart;
361+ }
349362 break ;
350363 }
351364 default :
@@ -829,8 +842,8 @@ bool TrialInliner::maybeInlineGetter(ICEntry& entry, ICFallbackStub* fallback,
829842 }
830843 cloneSharedPrefix (stub, data->endOfSharedPrefix , writer);
831844
832- writer.callInlinedGetterResult (data->receiverOperand , data->target ,
833- newICScript, data->sameRealm );
845+ writer.callInlinedGetterResult (data->receiverOperand , data->calleeOperand ,
846+ data-> target , newICScript, data->sameRealm );
834847 writer.returnFromIC ();
835848
836849 return replaceICStub (entry, fallback, writer, kind);
0 commit comments