[Courgette] Using LabelManager to reduce Courgette-apply peak RAM by 25%.

AssemblyProgram previously allocates new Label instances as it parses
an executable and emits instructions. This CL replaces the flow by using
LabelManager to precompute Labels in one array. This allows us to reduce
Courgette-apply peak RAM by 25%, measured by "choke RAM until failure"
method. Details:
- We precompute Labels in AssemblyProgram::PrecomputeLabels(), which
  relies on RvaVisitor inherited classes for architecture-specific
  extraction of abs32 and rel32 targets.
- TrimLabel()'s complex post-processing flow is simplified using
  PrecomputeLabels(), which runs before main file parse.
  - This requires RemoveUnusedRel32Locations() to update rel32.
  - Deprecating C_TRIM_FAILED error message.
- Moving more common functionality to Disassembler, but duplicating
  some code for win32-x86 and win32-x64 to follow existing pattern.

BUG=613216

Review-Url: https://codereview.chromium.org/1935203002
Cr-Original-Commit-Position: refs/heads/master@{#394815}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: c803763b7f4ee725717839b679cadeb1637b6be5
24 files changed
tree: b841352f18c999d0525f70c1442ac387d055ccc8
  1. testdata/
  2. third_party/
  3. adjustment_method.cc
  4. adjustment_method.h
  5. adjustment_method_2.cc
  6. adjustment_method_unittest.cc
  7. analyze_mem_test
  8. analyze_stress_test
  9. assembly_program.cc
  10. assembly_program.h
  11. base_test_unittest.cc
  12. base_test_unittest.h
  13. bsdiff_memory_unittest.cc
  14. BUILD.gn
  15. consecutive_range_visitor.h
  16. consecutive_range_visitor_unittest.cc
  17. courgette.gyp
  18. courgette.h
  19. courgette_application.png
  20. courgette_generation.png
  21. courgette_minimal_tool.cc
  22. courgette_tool.cc
  23. courgette_unittests.isolate
  24. crc.cc
  25. crc.h
  26. DEPS
  27. description.html
  28. description.md
  29. difference_estimator.cc
  30. difference_estimator.h
  31. difference_estimator_unittest.cc
  32. disassembler.cc
  33. disassembler.h
  34. disassembler_elf_32.cc
  35. disassembler_elf_32.h
  36. disassembler_elf_32_arm.cc
  37. disassembler_elf_32_arm.h
  38. disassembler_elf_32_x86.cc
  39. disassembler_elf_32_x86.h
  40. disassembler_elf_32_x86_unittest.cc
  41. disassembler_win32_x64.cc
  42. disassembler_win32_x64.h
  43. disassembler_win32_x64_unittest.cc
  44. disassembler_win32_x86.cc
  45. disassembler_win32_x86.h
  46. disassembler_win32_x86_unittest.cc
  47. encode_decode_unittest.cc
  48. encoded_program.cc
  49. encoded_program.h
  50. encoded_program_fuzz_unittest.cc
  51. encoded_program_unittest.cc
  52. ensemble.cc
  53. ensemble.h
  54. ensemble_apply.cc
  55. ensemble_create.cc
  56. ensemble_unittest.cc
  57. image_utils.h
  58. image_utils_unittest.cc
  59. label_manager.cc
  60. label_manager.h
  61. label_manager_unittest.cc
  62. memory_allocator.cc
  63. memory_allocator.h
  64. memory_allocator_unittest.cc
  65. memory_monitor.cc
  66. OWNERS
  67. patch_generator_x86_32.h
  68. patcher_x86_32.h
  69. program_detector.cc
  70. program_detector.h
  71. region.h
  72. rel32_finder_win32_x86.cc
  73. rel32_finder_win32_x86.h
  74. rel32_finder_win32_x86_unittest.cc
  75. run_mem_test
  76. run_stress_test
  77. simple_delta.cc
  78. simple_delta.h
  79. streams.cc
  80. streams.h
  81. streams_unittest.cc
  82. stress_test_common
  83. typedrva_unittest.cc
  84. types_elf.h
  85. types_win_pe.h
  86. versioning_unittest.cc