1 | /*
|
---|
2 | * Copyright (C) 2013-2021 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. AND ITS CONTRIBUTORS ``AS IS''
|
---|
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
---|
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
---|
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
|
---|
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
---|
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
---|
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
---|
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
---|
23 | * THE POSSIBILITY OF SUCH DAMAGE.
|
---|
24 | */
|
---|
25 |
|
---|
26 | #include "config.h"
|
---|
27 | #include "DFGDesiredTransitions.h"
|
---|
28 |
|
---|
29 | #if ENABLE(DFG_JIT)
|
---|
30 |
|
---|
31 | #include "CodeBlock.h"
|
---|
32 | #include "DFGCommonData.h"
|
---|
33 | #include "JSCellInlines.h"
|
---|
34 | #include "SlotVisitorInlines.h"
|
---|
35 |
|
---|
36 | namespace JSC { namespace DFG {
|
---|
37 |
|
---|
38 | DesiredTransition::DesiredTransition(CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
|
---|
39 | : m_codeOriginOwner(codeOriginOwner)
|
---|
40 | , m_oldStructure(oldStructure)
|
---|
41 | , m_newStructure(newStructure)
|
---|
42 | {
|
---|
43 | }
|
---|
44 |
|
---|
45 | template<typename Visitor>
|
---|
46 | void DesiredTransition::visitChildren(Visitor& visitor)
|
---|
47 | {
|
---|
48 | visitor.appendUnbarriered(m_codeOriginOwner);
|
---|
49 | visitor.appendUnbarriered(m_oldStructure);
|
---|
50 | visitor.appendUnbarriered(m_newStructure);
|
---|
51 | }
|
---|
52 |
|
---|
53 | template void DesiredTransition::visitChildren(AbstractSlotVisitor&);
|
---|
54 | template void DesiredTransition::visitChildren(SlotVisitor&);
|
---|
55 |
|
---|
56 | DesiredTransitions::DesiredTransitions(CodeBlock* codeBlock)
|
---|
57 | : m_codeBlock(codeBlock)
|
---|
58 | {
|
---|
59 | }
|
---|
60 |
|
---|
61 | DesiredTransitions::~DesiredTransitions()
|
---|
62 | {
|
---|
63 | }
|
---|
64 |
|
---|
65 | void DesiredTransitions::addLazily(CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
|
---|
66 | {
|
---|
67 | m_transitions.append(DesiredTransition(codeOriginOwner, oldStructure, newStructure));
|
---|
68 | }
|
---|
69 |
|
---|
70 | void DesiredTransitions::reallyAdd(VM& vm, CommonData* common)
|
---|
71 | {
|
---|
72 | FixedVector<WeakReferenceTransition> transitions(m_transitions.size());
|
---|
73 | for (unsigned i = 0; i < m_transitions.size(); i++) {
|
---|
74 | auto& desiredTransition = m_transitions[i];
|
---|
75 | transitions[i] = WeakReferenceTransition(vm, m_codeBlock, desiredTransition.m_codeOriginOwner, desiredTransition.m_oldStructure, desiredTransition.m_newStructure);
|
---|
76 | }
|
---|
77 | if (!transitions.isEmpty()) {
|
---|
78 | ConcurrentJSLocker locker(m_codeBlock->m_lock);
|
---|
79 | ASSERT(common->m_transitions.isEmpty());
|
---|
80 | common->m_transitions = WTFMove(transitions);
|
---|
81 | }
|
---|
82 | }
|
---|
83 |
|
---|
84 | template<typename Visitor>
|
---|
85 | void DesiredTransitions::visitChildren(Visitor& visitor)
|
---|
86 | {
|
---|
87 | for (unsigned i = 0; i < m_transitions.size(); i++)
|
---|
88 | m_transitions[i].visitChildren(visitor);
|
---|
89 | }
|
---|
90 |
|
---|
91 | template void DesiredTransitions::visitChildren(AbstractSlotVisitor&);
|
---|
92 | template void DesiredTransitions::visitChildren(SlotVisitor&);
|
---|
93 |
|
---|
94 | } } // namespace JSC::DFG
|
---|
95 |
|
---|
96 | #endif // ENABLE(DFG_JIT)
|
---|