IntOverflowDoesNotMatterRange.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. class IntOverflowDoesNotMatterRange
  7. {
  8. private:
  9. IR::Instr *firstInstr;
  10. IR::Instr *const lastInstr;
  11. // These syms are required to have int values before the first instruction (before we start ignoring int overflows in this
  12. // on instructions in this range). Any bailouts necessary to force them to ints need to be inserted before the range.
  13. BVSparse<JitArenaAllocator> symsRequiredToBeInt;
  14. BVSparse<JitArenaAllocator> symsRequiredToBeLossyInt; // these are a subset of the above bit-vector
  15. IntOverflowDoesNotMatterRange *const next;
  16. public:
  17. IntOverflowDoesNotMatterRange(
  18. JitArenaAllocator *const allocator,
  19. IR::Instr *const firstInstr,
  20. IR::Instr *const lastInstr,
  21. IntOverflowDoesNotMatterRange *const next)
  22. : firstInstr(firstInstr),
  23. lastInstr(lastInstr),
  24. symsRequiredToBeInt(allocator),
  25. symsRequiredToBeLossyInt(allocator),
  26. next(next)
  27. {
  28. Assert(firstInstr);
  29. Assert(lastInstr);
  30. Assert(lastInstr->m_opcode == Js::OpCode::NoIntOverflowBoundary);
  31. }
  32. static IntOverflowDoesNotMatterRange *New(
  33. JitArenaAllocator *const allocator,
  34. IR::Instr *const firstInstr,
  35. IR::Instr *const lastInstr,
  36. IntOverflowDoesNotMatterRange *const next)
  37. {
  38. return JitAnew(allocator, IntOverflowDoesNotMatterRange, allocator, firstInstr, lastInstr, next);
  39. }
  40. void Delete(JitArenaAllocator *const allocator)
  41. {
  42. JitAdelete(allocator, this);
  43. }
  44. public:
  45. IR::Instr *FirstInstr() const
  46. {
  47. return firstInstr;
  48. }
  49. void SetFirstInstr(IR::Instr *const firstInstr)
  50. {
  51. Assert(firstInstr);
  52. this->firstInstr = firstInstr;
  53. }
  54. IR::Instr *LastInstr() const
  55. {
  56. return lastInstr;
  57. }
  58. BVSparse<JitArenaAllocator> *SymsRequiredToBeInt()
  59. {
  60. return &symsRequiredToBeInt;
  61. }
  62. BVSparse<JitArenaAllocator> *SymsRequiredToBeLossyInt()
  63. {
  64. return &symsRequiredToBeLossyInt;
  65. }
  66. IntOverflowDoesNotMatterRange *Next() const
  67. {
  68. return next;
  69. }
  70. PREVENT_COPY(IntOverflowDoesNotMatterRange)
  71. };