DFGOSRExit.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. * Copyright (C) 2011 Apple Inc. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * 1. Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * 2. Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  16. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
  17. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  18. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  20. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef DFGOSRExit_h
  26. #define DFGOSRExit_h
  27. #include <wtf/Platform.h>
  28. #if ENABLE(DFG_JIT)
  29. #include "CodeOrigin.h"
  30. #include "DFGCommon.h"
  31. #include "DFGExitProfile.h"
  32. #include "DFGGPRInfo.h"
  33. #include "DFGValueRecoveryOverride.h"
  34. #include "MacroAssembler.h"
  35. #include "MethodOfGettingAValueProfile.h"
  36. #include "Operands.h"
  37. #include "ValueProfile.h"
  38. #include "ValueRecovery.h"
  39. #include <wtf/Vector.h>
  40. namespace JSC { namespace DFG {
  41. class SpeculativeJIT;
  42. // This enum describes the types of additional recovery that
  43. // may need be performed should a speculation check fail.
  44. enum SpeculationRecoveryType {
  45. SpeculativeAdd,
  46. BooleanSpeculationCheck
  47. };
  48. // === SpeculationRecovery ===
  49. //
  50. // This class provides additional information that may be associated with a
  51. // speculation check - for example
  52. class SpeculationRecovery {
  53. public:
  54. SpeculationRecovery(SpeculationRecoveryType type, GPRReg dest, GPRReg src)
  55. : m_type(type)
  56. , m_dest(dest)
  57. , m_src(src)
  58. {
  59. }
  60. SpeculationRecoveryType type() { return m_type; }
  61. GPRReg dest() { return m_dest; }
  62. GPRReg src() { return m_src; }
  63. private:
  64. // Indicates the type of additional recovery to be performed.
  65. SpeculationRecoveryType m_type;
  66. // different recovery types may required different additional information here.
  67. GPRReg m_dest;
  68. GPRReg m_src;
  69. };
  70. // === OSRExit ===
  71. //
  72. // This structure describes how to exit the speculative path by
  73. // going into baseline code.
  74. struct OSRExit {
  75. OSRExit(ExitKind, JSValueSource, MethodOfGettingAValueProfile, SpeculativeJIT*, unsigned streamIndex, unsigned recoveryIndex = 0);
  76. MacroAssemblerCodeRef m_code;
  77. JSValueSource m_jsValueSource;
  78. MethodOfGettingAValueProfile m_valueProfile;
  79. unsigned m_patchableCodeOffset;
  80. CodeOrigin m_codeOrigin;
  81. CodeOrigin m_codeOriginForExitProfile;
  82. unsigned m_recoveryIndex;
  83. unsigned m_watchpointIndex;
  84. ExitKind m_kind;
  85. uint32_t m_count;
  86. #if !(ENABLE(DETACHED_JIT) && BUILDING_DETACHED_JIT)
  87. bool considerAddingAsFrequentExitSite(CodeBlock* profiledCodeBlock)
  88. {
  89. if (!m_count || !exitKindIsCountable(m_kind))
  90. return false;
  91. return considerAddingAsFrequentExitSiteSlow(profiledCodeBlock);
  92. }
  93. #endif
  94. void setPatchableCodeOffset(MacroAssembler::PatchableJump);
  95. MacroAssembler::Jump getPatchableCodeOffsetAsJump() const;
  96. CodeLocationJump codeLocationForRepatch(CodeBlock*) const;
  97. void correctJump(LinkBuffer&);
  98. unsigned m_streamIndex;
  99. int m_lastSetOperand;
  100. RefPtr<ValueRecoveryOverride> m_valueRecoveryOverride;
  101. private:
  102. bool considerAddingAsFrequentExitSiteSlow(CodeBlock* profiledCodeBlock);
  103. };
  104. struct SpeculationFailureDebugInfo {
  105. CodeBlock* codeBlock;
  106. };
  107. } } // namespace JSC::DFG
  108. #endif // ENABLE(DFG_JIT)
  109. #endif // DFGOSRExit_h