61 VisitLocalLoads(classLoader.
Context, ma, method, locals, localByStoreSite, localStoreReaders[i], i, classLoader.EmitSymbols);
180 var lvt = method.LocalVariableTableAttribute;
183 var pc = method.Instructions[instructionIndex].PC;
184 var nextPC = method.Instructions[instructionIndex + 1].PC;
185 var isStore =
IsStoreLocal(method.Instructions[instructionIndex].NormalizedOpCode);
187 foreach (var e
in lvt)
190 if (e.index == lv.local && (e.start_pc <= pc || (e.start_pc == nextPC && isStore)) && e.start_pc + e.length > pc)
193 lv.start_pc = e.start_pc;
194 lv.end_pc = e.start_pc + e.length;
345 state[0].changed =
true;
348 var parameters = mw.GetParameters();
351 state[0].sites[argpos++].Add(-1);
353 for (
int i = 0; i < parameters.Length; i++)
355 state[0].sites[argpos++].Add(-1);
356 if (parameters[i].IsWidePrimitive)
365 var instructions = method.Instructions;
366 var exceptions = method.ExceptionTable;
367 var maxLocals = method.MaxLocals;
368 var localStoreReaders =
new Dictionary<int, string>[instructions.Length];
374 for (
int i = 0; i < instructions.Length; i++)
376 if (state[i].changed)
379 state[i].changed =
false;
381 var curr = state[i].Copy();
383 for (
int j = 0; j < exceptions.Length; j++)
384 if (exceptions[j].startIndex <= i && i < exceptions[j].endIndex)
385 state[exceptions[j].handlerIndex].Merge(curr);
389 localStoreReaders[i] ??=
new Dictionary<int, string>();
391 for (
int j = 0; j < curr.sites[instructions[i].NormalizedArg1].Count; j++)
392 localStoreReaders[i][curr.sites[instructions[i].NormalizedArg1][j]] =
"";
397 curr.Store(i, instructions[i].NormalizedArg1);
401 for (
int j = 0; j < exceptions.Length; j++)
402 if (exceptions[j].endIndex == i + 1)
403 state[exceptions[j].handlerIndex].Merge(curr);
408 var cpi = classFile.GetMethodref(instructions[i].Arg1);
411 var type = codeInfo.GetRawStackTypeWrapper(i, cpi.GetArgTypes().Length);
414 for (
int j = 0; j < maxLocals; j++)
415 if (codeInfo.GetLocalTypeWrapper(i, j) == type)
421 int handler = instructions[i].HandlerIndex;
426 state[handler].Merge(curr);
430 handlerState[handler].Merge(curr);
435 for (
int j = 0; j < handlerState.Length; j++)
438 && codeInfo.HasState(j)
442 curr.Merge(handlerState[j]);
451 for (
int j = 0; j < instructions[i].SwitchEntryCount; j++)
452 state[instructions[i].GetSwitchTargetIndex(j)].Merge(curr);
454 state[instructions[i].DefaultTarget].Merge(curr);
458 state[instructions[i].TargetIndex].Merge(curr);
461 state[instructions[i].TargetIndex].Merge(curr);
462 state[i + 1].Merge(curr);
468 state[i + 1].Merge(curr);
471 throw new InvalidOperationException();
477 return localStoreReaders;
482 Debug.Assert(
IsLoadLocal(method.Instructions[instructionIndex].NormalizedOpCode));
486 var localIndex = method.Instructions[instructionIndex].NormalizedArg1;
488 foreach (
int store
in storeSites.Keys)
493 type =
InstructionState.FindCommonBaseType(context, type, codeInfo.GetLocalTypeWrapper(0, localIndex));
498 if (method.Instructions[store].NormalizedOpCode ==
NormalizedByteCode.__invokespecial)
500 type =
InstructionState.FindCommonBaseType(context, type, codeInfo.GetLocalTypeWrapper(store + 1, localIndex));
502 else if (method.Instructions[store].NormalizedOpCode ==
NormalizedByteCode.__static_error)
509 Debug.Assert(
IsStoreLocal(method.Instructions[store].NormalizedOpCode));
510 type =
InstructionState.FindCommonBaseType(context, type, codeInfo.GetStackTypeWrapper(store, 0));
514 Debug.Assert(type != context.VerifierJavaTypeFactory.Invalid);
516 if (localByStoreSite.TryGetValue(
MakeKey(store, localIndex), out var l))
533 local =
MergeLocals(context, locals, localByStoreSite, local, l);
541 local.local = localIndex;
552 local.isArg |= isArg;
553 local.type =
InstructionState.FindCommonBaseType(context, local.type, type);
554 Debug.Assert(local.type != context.VerifierJavaTypeFactory.Invalid);
557 foreach (
int store
in storeSites.Keys)
559 if (!localByStoreSite.TryGetValue(
MakeKey(store, localIndex), out var v))
561 localByStoreSite[
MakeKey(store, localIndex)] = local;
565 local =
MergeLocals(context, locals, localByStoreSite, local, v);
577 Debug.Assert(l1 != l2);
578 Debug.Assert(l1.local == l2.local);
580 for (
int i = 0; i < locals.Count; i++)
589 var temp =
new Dictionary<long, LocalVar>(localByStoreSite);
590 localByStoreSite.Clear();
591 foreach (var kv
in temp)
592 localByStoreSite[kv.Key] = kv.Value == l2 ? l1 : kv.Value;
594 l1.isArg |= l2.isArg;
596 Debug.Assert(l1.type != context.VerifierJavaTypeFactory.Invalid);