source: webkit/trunk/Source/JavaScriptCore/jit/CachedRecovery.h

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

[JSC] Compress miscelaneous JIT related data structures with Packed<>
https://bugs.webkit.org/show_bug.cgi?id=197830

Reviewed by Saam Barati.

Source/JavaScriptCore:

This patch leverages Packed<> to compress miscelaneous data structures related to JIT.

  1. JIT IC data structures
  1. ValueRecovery

We use Packed<> for EncodedJSValue in ValueRecovery. This means that conservative GC cannot find
these values. But this is OK anyway since ValueRecovery's constant should be already registered
in DFG graph. From 16 (alignment 8) to 9 (alignment 1).

  1. FTL::ExitValue

We use Packed<> for EncodedJSValue in FTL::ExitValue. This is also OK since this constant should
be already registered by DFG/FTL graph. From 16 (alignment 8) to 9 (alignment 1).

  • assembler/CodeLocation.h:
  • bytecode/ByValInfo.h:
  • bytecode/CallLinkInfo.cpp:

(JSC::CallLinkInfo::CallLinkInfo):
(JSC::CallLinkInfo::callReturnLocation):

  • bytecode/CallLinkInfo.h:

(JSC::CallLinkInfo::nearCallMode const):

  • bytecode/CodeBlock.cpp:

(JSC::CodeBlock::addJITAddIC):
(JSC::CodeBlock::addJITMulIC):
(JSC::CodeBlock::addJITSubIC):
(JSC::CodeBlock::addJITNegIC):

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::addMathIC):

  • bytecode/InlineCallFrame.h:

(JSC::InlineCallFrame::InlineCallFrame):

  • bytecode/ValueRecovery.h:

(JSC::ValueRecovery::inGPR):
(JSC::ValueRecovery::inPair):
(JSC::ValueRecovery::inFPR):
(JSC::ValueRecovery::displacedInJSStack):
(JSC::ValueRecovery::constant):
(JSC::ValueRecovery::directArgumentsThatWereNotCreated):
(JSC::ValueRecovery::clonedArgumentsThatWereNotCreated):
(JSC::ValueRecovery::gpr const):
(JSC::ValueRecovery::tagGPR const):
(JSC::ValueRecovery::payloadGPR const):
(JSC::ValueRecovery::fpr const):
(JSC::ValueRecovery::virtualRegister const):
(JSC::ValueRecovery::withLocalsOffset const):
(JSC::ValueRecovery::constant const):
(JSC::ValueRecovery::nodeID const):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileValueAdd):
(JSC::DFG::SpeculativeJIT::compileValueSub):
(JSC::DFG::SpeculativeJIT::compileValueNegate):
(JSC::DFG::SpeculativeJIT::compileValueMul):

  • ftl/FTLExitValue.cpp:

(JSC::FTL::ExitValue::materializeNewObject):

  • ftl/FTLExitValue.h:

(JSC::FTL::ExitValue::inJSStack):
(JSC::FTL::ExitValue::inJSStackAsInt32):
(JSC::FTL::ExitValue::inJSStackAsInt52):
(JSC::FTL::ExitValue::inJSStackAsDouble):
(JSC::FTL::ExitValue::constant):
(JSC::FTL::ExitValue::exitArgument):
(JSC::FTL::ExitValue::exitArgument const):
(JSC::FTL::ExitValue::adjustStackmapLocationsIndexByOffset):
(JSC::FTL::ExitValue::constant const):
(JSC::FTL::ExitValue::virtualRegister const):
(JSC::FTL::ExitValue::objectMaterialization const):
(JSC::FTL::ExitValue::withVirtualRegister const):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileValueAdd):
(JSC::FTL::DFG::LowerDFGToB3::compileValueSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueMul):
(JSC::FTL::DFG::LowerDFGToB3::compileUnaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileBinaryMathIC):
(JSC::FTL::DFG::LowerDFGToB3::compileArithAddOrSub):
(JSC::FTL::DFG::LowerDFGToB3::compileValueNegate):

  • jit/CachedRecovery.h:
  • jit/CallFrameShuffleData.h:
  • jit/JITArithmetic.cpp:

(JSC::JIT::emit_op_negate):
(JSC::JIT::emit_op_add):
(JSC::JIT::emit_op_mul):
(JSC::JIT::emit_op_sub):

  • jit/JITMathIC.h:

(JSC::isProfileEmpty):
(JSC::JITBinaryMathIC::JITBinaryMathIC):
(JSC::JITUnaryMathIC::JITUnaryMathIC):

  • jit/PolymorphicCallStubRoutine.h:

(JSC::PolymorphicCallNode::hasCallLinkInfo):

  • jit/SnippetOperand.h:

(JSC::SnippetOperand::asRawBits const):
(JSC::SnippetOperand::asConstInt32 const):
(JSC::SnippetOperand::asConstDouble const):
(JSC::SnippetOperand::setConstInt32):
(JSC::SnippetOperand::setConstDouble):

Source/WTF:

  • wtf/Packed.h:

(WTF::alignof):

File size: 4.1 KB
Line 
1/*
2 * Copyright (C) 2015 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
26#pragma once
27
28#if ENABLE(JIT)
29
30#include "ValueRecovery.h"
31#include "VirtualRegister.h"
32#include <wtf/Vector.h>
33
34namespace JSC {
35
36// A CachedRecovery is a wrapper around a ValueRecovery that records where said
37// value should go on the stack and/or in registers. Whenever we perform an
38// operation changing the ValueRecovery, we update the CachedRecovery's member
39// in place.
40class CachedRecovery {
41public:
42 CachedRecovery(ValueRecovery recovery)
43 : m_recovery { recovery }
44 {
45 }
46
47 CachedRecovery(CachedRecovery&) = delete;
48 CachedRecovery(CachedRecovery&&) = delete;
49 CachedRecovery& operator=(CachedRecovery&) = delete;
50 CachedRecovery& operator=(CachedRecovery&&) = delete;
51
52 const Vector<VirtualRegister, 1>& targets() const { return m_targets; }
53
54 void addTarget(VirtualRegister reg)
55 {
56 ASSERT(m_targets.isEmpty() || m_targets.last() < reg);
57 m_targets.append(reg);
58 }
59
60 void removeTarget(VirtualRegister reg)
61 {
62 ASSERT_UNUSED(reg, m_targets.last() == reg);
63 m_targets.shrink(m_targets.size() - 1);
64 }
65
66 void clearTargets()
67 {
68 m_targets.clear();
69 }
70
71 void setWantedJSValueRegs(JSValueRegs jsValueRegs)
72 {
73 ASSERT(m_wantedFPR == InvalidFPRReg);
74 m_wantedJSValueRegs = jsValueRegs;
75 }
76
77 void setWantedFPR(FPRReg fpr)
78 {
79 ASSERT(!m_wantedJSValueRegs);
80 m_wantedFPR = fpr;
81 }
82
83 // Determine whether converting this recovery into a JSValue will
84 // require additional GPRs and/or FPRs.
85 // This is guaranteed to only depend on the DataFormat, and the
86 // result of these calls will stay valid after loads and/or stores.
87 bool boxingRequiresGPR() const
88 {
89#if USE(JSVALUE64)
90 return recovery().dataFormat() == DataFormatDouble;
91#else
92 return false;
93#endif
94 }
95 bool boxingRequiresFPR() const
96 {
97#if USE(JSVALUE64)
98 switch (recovery().dataFormat()) {
99 case DataFormatInt52:
100 case DataFormatStrictInt52:
101 return true;
102
103 default:
104 return false;
105 }
106#else
107 return false;
108#endif
109 }
110
111 // This is used to determine what kind of register we need to be
112 // able to load a recovery. We only use it when a direct load is
113 // currently impossible, to determine whether we should spill a
114 // GPR or an FPR for loading this value.
115 bool loadsIntoGPR() const;
116 bool loadsIntoFPR() const;
117
118 ValueRecovery recovery() const { return m_recovery; }
119
120 void setRecovery(ValueRecovery recovery) { m_recovery = recovery; }
121
122 JSValueRegs wantedJSValueRegs() const { return m_wantedJSValueRegs; }
123
124 FPRReg wantedFPR() const { return m_wantedFPR; }
125private:
126 Vector<VirtualRegister, 1> m_targets;
127 ValueRecovery m_recovery;
128 JSValueRegs m_wantedJSValueRegs;
129 FPRReg m_wantedFPR { InvalidFPRReg };
130};
131
132} // namespace JSC
133
134#endif // ENABLE(JIT)
Note: See TracBrowser for help on using the repository browser.