StructureStubClearingWatchpoint.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright (C) 2012 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 StructureStubClearingWatchpoint_h
  26. #define StructureStubClearingWatchpoint_h
  27. #include "Watchpoint.h"
  28. #include <wtf/Platform.h>
  29. #if ENABLE(JIT)
  30. #include <wtf/FastAllocBase.h>
  31. #include <wtf/Noncopyable.h>
  32. #include <wtf/OwnPtr.h>
  33. #include <wtf/PassOwnPtr.h>
  34. #include <wtf/RefCounted.h>
  35. #include <wtf/RefPtr.h>
  36. namespace JSC {
  37. class CodeBlock;
  38. class WatchpointsOnStructureStubInfo;
  39. struct StructureStubInfo;
  40. class StructureStubClearingWatchpoint : public Watchpoint {
  41. WTF_MAKE_NONCOPYABLE(StructureStubClearingWatchpoint);
  42. #if ENABLE(JIT) && ENABLE(DETACHED_JIT)
  43. DETACHED_JIT_MAKE_SHARED_DATA_ALLOCATED;
  44. friend class Watchpoint;
  45. #else
  46. WTF_MAKE_FAST_ALLOCATED;
  47. #endif
  48. public:
  49. StructureStubClearingWatchpoint(
  50. WatchpointsOnStructureStubInfo& holder)
  51. :
  52. #if ENABLE(DETACHED_JIT)
  53. Watchpoint(e_StrutureStubClearingType),
  54. #endif
  55. m_holder(holder)
  56. {
  57. }
  58. StructureStubClearingWatchpoint(
  59. WatchpointsOnStructureStubInfo& holder,
  60. PassOwnPtr<StructureStubClearingWatchpoint> next)
  61. :
  62. #if ENABLE(DETACHED_JIT)
  63. Watchpoint(e_StrutureStubClearingType),
  64. #endif
  65. m_holder(holder)
  66. , m_next(next)
  67. {
  68. }
  69. #if ENABLE(DETACHED_JIT)
  70. ~StructureStubClearingWatchpoint();
  71. #else
  72. virtual ~StructureStubClearingWatchpoint();
  73. #endif
  74. static StructureStubClearingWatchpoint* push(
  75. WatchpointsOnStructureStubInfo& holder,
  76. OwnPtr<StructureStubClearingWatchpoint>& head);
  77. protected:
  78. void fireInternal();
  79. private:
  80. WatchpointsOnStructureStubInfo& m_holder;
  81. OwnPtr<StructureStubClearingWatchpoint> m_next;
  82. };
  83. class WatchpointsOnStructureStubInfo : public RefCounted_shared<WatchpointsOnStructureStubInfo> {
  84. public:
  85. WatchpointsOnStructureStubInfo(CodeBlock* codeBlock, StructureStubInfo* stubInfo)
  86. : m_codeBlock(codeBlock)
  87. , m_stubInfo(stubInfo)
  88. {
  89. }
  90. ~WatchpointsOnStructureStubInfo();
  91. StructureStubClearingWatchpoint* addWatchpoint();
  92. static StructureStubClearingWatchpoint* ensureReferenceAndAddWatchpoint(
  93. RefPtr<WatchpointsOnStructureStubInfo>& holderRef,
  94. CodeBlock*, StructureStubInfo*);
  95. CodeBlock* codeBlock() const { return m_codeBlock; }
  96. StructureStubInfo* stubInfo() const { return m_stubInfo; }
  97. private:
  98. CodeBlock* m_codeBlock;
  99. StructureStubInfo* m_stubInfo;
  100. OwnPtr<StructureStubClearingWatchpoint> m_head;
  101. };
  102. } // namespace JSC
  103. #endif // ENABLE(JIT)
  104. #endif // StructureStubClearingWatchpoint_h