fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 1 | /* |
mark.lam@apple.com | 001f25c | 2017-05-20 00:59:31 +0000 | [diff] [blame] | 2 | * Copyright (C) 2012-2017 Apple Inc. All rights reserved. |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 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 | |
ryanhaddad@apple.com | 22104f5 | 2016-09-28 17:08:17 +0000 | [diff] [blame] | 26 | #pragma once |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 27 | |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 28 | #if ENABLE(DFG_JIT) |
| 29 | |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 30 | #include "DFGSlowPathGenerator.h" |
fpizlo@apple.com | 0bef2a1 | 2014-02-10 19:26:29 +0000 | [diff] [blame] | 31 | #include "DFGSpeculativeJIT.h" |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 32 | #include <wtf/Vector.h> |
| 33 | |
| 34 | namespace JSC { namespace DFG { |
| 35 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 36 | class CallArrayAllocatorSlowPathGenerator final : public JumpingSlowPathGenerator<MacroAssembler::JumpList> { |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 37 | public: |
| 38 | CallArrayAllocatorSlowPathGenerator( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 39 | MacroAssembler::JumpList from, SpeculativeJIT* jit, P_JITOperation_VmStZB function, |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 40 | GPRReg resultGPR, GPRReg storageGPR, RegisteredStructure structure, size_t size) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 41 | : JumpingSlowPathGenerator<MacroAssembler::JumpList>(from, jit) |
| 42 | , m_function(function) |
| 43 | , m_resultGPR(resultGPR) |
| 44 | , m_storageGPR(storageGPR) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 45 | , m_size(size) |
rmorisset@apple.com | 4ccbcf1 | 2019-03-12 19:07:04 +0000 | [diff] [blame] | 46 | , m_structure(structure) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 47 | { |
| 48 | ASSERT(size < static_cast<size_t>(std::numeric_limits<int32_t>::max())); |
| 49 | jit->silentSpillAllRegistersImpl(false, m_plans, resultGPR); |
| 50 | } |
| 51 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 52 | private: |
| 53 | void generateInternal(SpeculativeJIT* jit) final |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 54 | { |
| 55 | linkFrom(jit); |
| 56 | for (unsigned i = 0; i < m_plans.size(); ++i) |
| 57 | jit->silentSpill(m_plans[i]); |
ysuzuki@apple.com | 5aa5884 | 2022-04-06 00:54:05 +0000 | [diff] [blame] | 58 | jit->callOperation(m_function, m_resultGPR, SpeculativeJIT::TrustedImmPtr(&jit->vm()), m_structure, m_size, m_storageGPR); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 59 | for (unsigned i = m_plans.size(); i--;) |
mark.lam@apple.com | 001f25c | 2017-05-20 00:59:31 +0000 | [diff] [blame] | 60 | jit->silentFill(m_plans[i]); |
saambarati1@gmail.com | aa599f6 | 2015-08-21 19:11:36 +0000 | [diff] [blame] | 61 | jit->m_jit.exceptionCheck(); |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 62 | jit->m_jit.loadPtr(MacroAssembler::Address(m_resultGPR, JSObject::butterflyOffset()), m_storageGPR); |
| 63 | jumpTo(jit); |
| 64 | } |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 65 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 66 | P_JITOperation_VmStZB m_function; |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 67 | GPRReg m_resultGPR; |
| 68 | GPRReg m_storageGPR; |
keith_miller@apple.com | 6c2ac2e | 2018-03-08 02:26:55 +0000 | [diff] [blame] | 69 | int m_size; |
rmorisset@apple.com | 4ccbcf1 | 2019-03-12 19:07:04 +0000 | [diff] [blame] | 70 | RegisteredStructure m_structure; |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 71 | Vector<SilentRegisterSavePlan, 2> m_plans; |
| 72 | }; |
| 73 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 74 | class CallArrayAllocatorWithVariableSizeSlowPathGenerator final : public JumpingSlowPathGenerator<MacroAssembler::JumpList> { |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 75 | public: |
| 76 | CallArrayAllocatorWithVariableSizeSlowPathGenerator( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 77 | MacroAssembler::JumpList from, SpeculativeJIT* jit, P_JITOperation_GStZB function, |
ysuzuki@apple.com | 6866de17 | 2022-04-19 08:06:44 +0000 | [diff] [blame] | 78 | GPRReg resultGPR, JITCompiler::LinkableConstant globalObject, RegisteredStructure contiguousStructure, RegisteredStructure arrayStorageStructure, GPRReg sizeGPR, GPRReg storageGPR) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 79 | : JumpingSlowPathGenerator<MacroAssembler::JumpList>(from, jit) |
| 80 | , m_function(function) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 81 | , m_contiguousStructure(contiguousStructure) |
sbarati@apple.com | 6cfefd8 | 2016-08-13 02:14:42 +0000 | [diff] [blame] | 82 | , m_arrayStorageOrContiguousStructure(arrayStorageStructure) |
rmorisset@apple.com | 4ccbcf1 | 2019-03-12 19:07:04 +0000 | [diff] [blame] | 83 | , m_resultGPR(resultGPR) |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 84 | , m_globalObject(globalObject) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 85 | , m_sizeGPR(sizeGPR) |
fpizlo@apple.com | bc16ddb | 2016-09-06 01:02:22 +0000 | [diff] [blame] | 86 | , m_storageGPR(storageGPR) |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 87 | { |
| 88 | jit->silentSpillAllRegistersImpl(false, m_plans, resultGPR); |
| 89 | } |
| 90 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 91 | private: |
| 92 | void generateInternal(SpeculativeJIT* jit) final |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 93 | { |
| 94 | linkFrom(jit); |
| 95 | for (unsigned i = 0; i < m_plans.size(); ++i) |
| 96 | jit->silentSpill(m_plans[i]); |
fpizlo@apple.com | bc16ddb | 2016-09-06 01:02:22 +0000 | [diff] [blame] | 97 | GPRReg scratchGPR = AssemblyHelpers::selectScratchGPR(m_sizeGPR, m_storageGPR); |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 98 | if (m_contiguousStructure.get() != m_arrayStorageOrContiguousStructure.get()) { |
sbarati@apple.com | 6cfefd8 | 2016-08-13 02:14:42 +0000 | [diff] [blame] | 99 | MacroAssembler::Jump bigLength = jit->m_jit.branch32(MacroAssembler::AboveOrEqual, m_sizeGPR, MacroAssembler::TrustedImm32(MIN_ARRAY_STORAGE_CONSTRUCTION_LENGTH)); |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 100 | jit->m_jit.move(SpeculativeJIT::TrustedImmPtr(m_contiguousStructure), scratchGPR); |
sbarati@apple.com | 6cfefd8 | 2016-08-13 02:14:42 +0000 | [diff] [blame] | 101 | MacroAssembler::Jump done = jit->m_jit.jump(); |
| 102 | bigLength.link(&jit->m_jit); |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 103 | jit->m_jit.move(SpeculativeJIT::TrustedImmPtr(m_arrayStorageOrContiguousStructure), scratchGPR); |
sbarati@apple.com | 6cfefd8 | 2016-08-13 02:14:42 +0000 | [diff] [blame] | 104 | done.link(&jit->m_jit); |
| 105 | } else |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 106 | jit->m_jit.move(SpeculativeJIT::TrustedImmPtr(m_contiguousStructure), scratchGPR); |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 107 | jit->callOperation(m_function, m_resultGPR, m_globalObject, scratchGPR, m_sizeGPR, m_storageGPR); |
fpizlo@apple.com | 75c91a7 | 2012-11-08 22:28:25 +0000 | [diff] [blame] | 108 | for (unsigned i = m_plans.size(); i--;) |
mark.lam@apple.com | 001f25c | 2017-05-20 00:59:31 +0000 | [diff] [blame] | 109 | jit->silentFill(m_plans[i]); |
saambarati1@gmail.com | aa599f6 | 2015-08-21 19:11:36 +0000 | [diff] [blame] | 110 | jit->m_jit.exceptionCheck(); |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 111 | jumpTo(jit); |
| 112 | } |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 113 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 114 | P_JITOperation_GStZB m_function; |
sbarati@apple.com | 239d20b | 2017-01-26 23:50:58 +0000 | [diff] [blame] | 115 | RegisteredStructure m_contiguousStructure; |
| 116 | RegisteredStructure m_arrayStorageOrContiguousStructure; |
rmorisset@apple.com | 4ccbcf1 | 2019-03-12 19:07:04 +0000 | [diff] [blame] | 117 | GPRReg m_resultGPR; |
ysuzuki@apple.com | 6866de17 | 2022-04-19 08:06:44 +0000 | [diff] [blame] | 118 | JITCompiler::LinkableConstant m_globalObject; |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 119 | GPRReg m_sizeGPR; |
fpizlo@apple.com | bc16ddb | 2016-09-06 01:02:22 +0000 | [diff] [blame] | 120 | GPRReg m_storageGPR; |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 121 | Vector<SilentRegisterSavePlan, 2> m_plans; |
| 122 | }; |
| 123 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 124 | class CallArrayAllocatorWithVariableStructureVariableSizeSlowPathGenerator final : public JumpingSlowPathGenerator<MacroAssembler::JumpList> { |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 125 | public: |
| 126 | CallArrayAllocatorWithVariableStructureVariableSizeSlowPathGenerator( |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 127 | MacroAssembler::JumpList from, SpeculativeJIT* jit, P_JITOperation_GStZB function, |
ysuzuki@apple.com | 6866de17 | 2022-04-19 08:06:44 +0000 | [diff] [blame] | 128 | GPRReg resultGPR, JITCompiler::LinkableConstant globalObject, GPRReg structureGPR, GPRReg sizeGPR, GPRReg storageGPR) |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 129 | : JumpingSlowPathGenerator<MacroAssembler::JumpList>(from, jit) |
| 130 | , m_function(function) |
| 131 | , m_resultGPR(resultGPR) |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 132 | , m_globalObject(globalObject) |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 133 | , m_structureGPR(structureGPR) |
| 134 | , m_sizeGPR(sizeGPR) |
| 135 | , m_storageGPR(storageGPR) |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 136 | { |
mark.lam@apple.com | 001f25c | 2017-05-20 00:59:31 +0000 | [diff] [blame] | 137 | jit->silentSpillAllRegistersImpl(false, m_plans, resultGPR); |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 138 | } |
| 139 | |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 140 | private: |
| 141 | void generateInternal(SpeculativeJIT* jit) final |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 142 | { |
| 143 | linkFrom(jit); |
| 144 | for (unsigned i = 0; i < m_plans.size(); ++i) |
| 145 | jit->silentSpill(m_plans[i]); |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 146 | jit->callOperation(m_function, m_resultGPR, m_globalObject, m_structureGPR, m_sizeGPR, m_storageGPR); |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 147 | for (unsigned i = m_plans.size(); i--;) |
mark.lam@apple.com | 001f25c | 2017-05-20 00:59:31 +0000 | [diff] [blame] | 148 | jit->silentFill(m_plans[i]); |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 149 | jit->m_jit.exceptionCheck(); |
| 150 | jumpTo(jit); |
| 151 | } |
ross.kirsling@sony.com | 4ddd5ef | 2020-05-12 19:13:18 +0000 | [diff] [blame] | 152 | |
ysuzuki@apple.com | 52e98bb | 2019-10-22 09:24:48 +0000 | [diff] [blame] | 153 | P_JITOperation_GStZB m_function; |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 154 | GPRReg m_resultGPR; |
ysuzuki@apple.com | 6866de17 | 2022-04-19 08:06:44 +0000 | [diff] [blame] | 155 | JITCompiler::LinkableConstant m_globalObject; |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 156 | GPRReg m_structureGPR; |
| 157 | GPRReg m_sizeGPR; |
| 158 | GPRReg m_storageGPR; |
sbarati@apple.com | fd407a5 | 2017-01-13 04:03:47 +0000 | [diff] [blame] | 159 | Vector<SilentRegisterSavePlan, 2> m_plans; |
| 160 | }; |
| 161 | |
fpizlo@apple.com | 1bc6848 | 2012-10-13 03:56:09 +0000 | [diff] [blame] | 162 | } } // namespace JSC::DFG |
| 163 | |
| 164 | #endif // ENABLE(DFG_JIT) |