source: webkit/trunk/Source/JavaScriptCore/dfg/DFGDesiredTransitions.cpp

Last change on this file was 276005, checked in by [email protected], 4 years ago

[JSC] Change Vector<> to FixedVector<> in DFG::CommonData if possible
https://bugs.webkit.org/show_bug.cgi?id=224588

Reviewed by Mark Lam.

DFG::CommonData is kept alive so long as DFG code exists. It includes a lot of Vectors while they are not mutable after the DFG code compilation.
This patch changes Vector<> to FixedVector<> if possible to shrink sizeof(DFG::CommonData). And this also removes the need of calling shrinkToFit
explicitly for them.

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::propagateTransitions):
(JSC::CodeBlock::determineLiveness):
(JSC::CodeBlock::stronglyVisitWeakReferences):
(JSC::CodeBlock::jettison):
(JSC::CodeBlock::numberOfDFGIdentifiers const):
(JSC::CodeBlock::identifier const):

  • bytecode/CodeBlock.h:
  • dfg/DFGCommonData.cpp:

(JSC::DFG::CommonData::shrinkToFit):
(JSC::DFG::CommonData::invalidate):
(JSC::DFG::CommonData::~CommonData):
(JSC::DFG::CommonData::installVMTrapBreakpoints):
(JSC::DFG::CommonData::isVMTrapBreakpoint):
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
(JSC::DFG::CommonData::notifyCompilingStructureTransition): Deleted.

  • dfg/DFGCommonData.h:

(JSC::DFG::CommonData::catchOSREntryDataForBytecodeIndex):
(JSC::DFG::CommonData::appendCatchEntrypoint): Deleted.

  • dfg/DFGDesiredIdentifiers.cpp:

(JSC::DFG::DesiredIdentifiers::reallyAdd):

  • dfg/DFGDesiredTransitions.cpp:

(JSC::DFG::DesiredTransition::DesiredTransition):
(JSC::DFG::DesiredTransitions::DesiredTransitions):
(JSC::DFG::DesiredTransitions::addLazily):
(JSC::DFG::DesiredTransitions::reallyAdd):
(JSC::DFG::DesiredTransition::reallyAdd): Deleted.

  • dfg/DFGDesiredTransitions.h:
  • dfg/DFGDesiredWeakReferences.cpp:

(JSC::DFG::DesiredWeakReferences::reallyAdd):

  • dfg/DFGGraph.h:
  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::noticeCatchEntrypoint):

  • dfg/DFGOSREntry.h:
  • dfg/DFGPlan.cpp:

(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::finalizeWithoutNotifyingCallback):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::linkOSREntries):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(JSC::DFG::SpeculativeJIT::compile):

  • ftl/FTLCompile.cpp:

(JSC::FTL::compile):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compilePutStructure):
(JSC::FTL::DFG::LowerDFGToB3::compileMultiPutByOffset):
(JSC::FTL::DFG::LowerDFGToB3::compileInvalidationPoint):

File size: 3.5 KB
Line 
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
36namespace JSC { namespace DFG {
37
38DesiredTransition::DesiredTransition(CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
39 : m_codeOriginOwner(codeOriginOwner)
40 , m_oldStructure(oldStructure)
41 , m_newStructure(newStructure)
42{
43}
44
45template<typename Visitor>
46void DesiredTransition::visitChildren(Visitor& visitor)
47{
48 visitor.appendUnbarriered(m_codeOriginOwner);
49 visitor.appendUnbarriered(m_oldStructure);
50 visitor.appendUnbarriered(m_newStructure);
51}
52
53template void DesiredTransition::visitChildren(AbstractSlotVisitor&);
54template void DesiredTransition::visitChildren(SlotVisitor&);
55
56DesiredTransitions::DesiredTransitions(CodeBlock* codeBlock)
57 : m_codeBlock(codeBlock)
58{
59}
60
61DesiredTransitions::~DesiredTransitions()
62{
63}
64
65void DesiredTransitions::addLazily(CodeBlock* codeOriginOwner, Structure* oldStructure, Structure* newStructure)
66{
67 m_transitions.append(DesiredTransition(codeOriginOwner, oldStructure, newStructure));
68}
69
70void 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
84template<typename Visitor>
85void DesiredTransitions::visitChildren(Visitor& visitor)
86{
87 for (unsigned i = 0; i < m_transitions.size(); i++)
88 m_transitions[i].visitChildren(visitor);
89}
90
91template void DesiredTransitions::visitChildren(AbstractSlotVisitor&);
92template void DesiredTransitions::visitChildren(SlotVisitor&);
93
94} } // namespace JSC::DFG
95
96#endif // ENABLE(DFG_JIT)
Note: See TracBrowser for help on using the repository browser.