blob: f46ccfd582d3b7b772a224d425f7961afc0b9cb7 [file] [log] [blame]
fpizlo@apple.com602f4c02014-02-10 07:21:09 +00001/*
fpizlo@apple.comdd9f62b2016-05-15 23:08:21 +00002 * Copyright (C) 2014, 2016 Apple Inc. All rights reserved.
fpizlo@apple.com602f4c02014-02-10 07:21:09 +00003 *
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
ryanhaddad@apple.com22104f52016-09-28 17:08:17 +000026#pragma once
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000027
28#if ENABLE(DFG_JIT)
29
30#include <wtf/Vector.h>
31
32namespace JSC {
33
34class SlotVisitor;
mhahnenberg@apple.com4d2e1692014-02-19 18:41:27 +000035class VM;
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000036
37namespace DFG {
38
39class Scannable;
40struct Plan;
41
42class Safepoint {
43public:
fpizlo@apple.com04a048c2014-04-28 19:01:07 +000044 class Result {
45 public:
46 Result()
47 : m_didGetCancelled(false)
48 , m_wasChecked(true)
49 {
50 }
51
52 ~Result();
53
54 bool didGetCancelled();
55
56 private:
57 friend class Safepoint;
58
59 bool m_didGetCancelled;
60 bool m_wasChecked;
61 };
62
63 Safepoint(Plan&, Result&);
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000064 ~Safepoint();
65
66 void add(Scannable*);
67
68 void begin();
69
fpizlo@apple.com04a048c2014-04-28 19:01:07 +000070 void checkLivenessAndVisitChildren(SlotVisitor&);
71 bool isKnownToBeLiveDuringGC();
72 void cancel();
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000073
fpizlo@apple.comdd9f62b2016-05-15 23:08:21 +000074 VM* vm() const; // May return null if we've been cancelled.
mhahnenberg@apple.com4d2e1692014-02-19 18:41:27 +000075
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000076private:
fpizlo@apple.comdd9f62b2016-05-15 23:08:21 +000077 VM* m_vm;
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000078 Plan& m_plan;
79 Vector<Scannable*> m_scannables;
80 bool m_didCallBegin;
fpizlo@apple.com04a048c2014-04-28 19:01:07 +000081 Result& m_result;
fpizlo@apple.com602f4c02014-02-10 07:21:09 +000082};
83
84} } // namespace JSC::DFG
85
86#endif // ENABLE(DFG_JIT)