364 {
365 var instructions = method.Instructions;
366 var exceptions = method.ExceptionTable;
367 var maxLocals = method.MaxLocals;
368 var localStoreReaders = new Dictionary<int, string>[instructions.Length];
369
370 var done = false;
371 while (!done)
372 {
373 done = true;
374 for (int i = 0; i < instructions.Length; i++)
375 {
376 if (state[i].changed)
377 {
378 done = false;
379 state[i].changed = false;
380
381 var curr = state[i].Copy();
382
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);
386
387 if (
IsLoadLocal(instructions[i].NormalizedOpCode) && (instructions[i].NormalizedOpCode !=
NormalizedByteCode.__aload || !RuntimeVerifierJavaType.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(i + 1, 0))))
388 {
389 localStoreReaders[i] ??= new Dictionary<int, string>();
390
391 for (int j = 0; j < curr.sites[instructions[i].NormalizedArg1].Count; j++)
392 localStoreReaders[i][curr.sites[instructions[i].NormalizedArg1][j]] = "";
393 }
394
395 if (
IsStoreLocal(instructions[i].NormalizedOpCode) && (instructions[i].NormalizedOpCode !=
NormalizedByteCode.__astore || !RuntimeVerifierJavaType.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(i, 0))))
396 {
397 curr.Store(i, instructions[i].NormalizedArg1);
398
399
400
401 for (int j = 0; j < exceptions.Length; j++)
402 if (exceptions[j].endIndex == i + 1)
403 state[exceptions[j].handlerIndex].Merge(curr);
404 }
405
407 {
408 var cpi = classFile.GetMethodref(instructions[i].Arg1);
409 if (ReferenceEquals(cpi.Name, StringConstants.INIT))
410 {
411 var type = codeInfo.GetRawStackTypeWrapper(i, cpi.GetArgTypes().Length);
412
413 if (type == context.VerifierJavaTypeFactory.UninitializedThis || RuntimeVerifierJavaType.IsNew(type))
414 for (int j = 0; j < maxLocals; j++)
415 if (codeInfo.GetLocalTypeWrapper(i, j) == type)
416 curr.Store(i, j);
417 }
418 }
420 {
421 int handler = instructions[i].HandlerIndex;
422
423
424
425
426 state[handler].Merge(curr);
427
428
429 FindLocalVarState[] handlerState = new FindLocalVarState[instructions.Length];
430 handlerState[handler].Merge(curr);
431 curr = new FindLocalVarState();
433
434
435 for (int j = 0; j < handlerState.Length; j++)
436 {
438 && codeInfo.HasState(j)
439 && RuntimeVerifierJavaType.IsFaultBlockException(codeInfo.GetRawStackTypeWrapper(j, 0))
440 && ((RuntimeVerifierJavaType)codeInfo.GetRawStackTypeWrapper(j, 0)).Index == handler)
441 {
442 curr.Merge(handlerState[j]);
443 }
444 }
445 }
446
447 switch (ByteCodeMetaData.GetFlowControl(instructions[i].NormalizedOpCode))
448 {
450 {
451 for (int j = 0; j < instructions[i].SwitchEntryCount; j++)
452 state[instructions[i].GetSwitchTargetIndex(j)].Merge(curr);
453
454 state[instructions[i].DefaultTarget].Merge(curr);
455 break;
456 }
458 state[instructions[i].TargetIndex].Merge(curr);
459 break;
461 state[instructions[i].TargetIndex].Merge(curr);
462 state[i + 1].Merge(curr);
463 break;
466 break;
468 state[i + 1].Merge(curr);
469 break;
470 default:
471 throw new InvalidOperationException();
472 }
473 }
474 }
475 }
476
477 return localStoreReaders;
478 }
static bool IsStoreLocal(NormalizedByteCode bc)
static bool IsLoadLocal(NormalizedByteCode bc)