fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 1 | /* |
mark.lam@apple.com | 97d3f45 | 2019-01-16 18:44:25 +0000 | [diff] [blame] | 2 | * Copyright (C) 2013-2019 Apple Inc. All rights reserved. |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +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. 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 | |
ryanhaddad@apple.com | 22104f5 | 2016-09-28 17:08:17 +0000 | [diff] [blame] | 26 | #pragma once |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 27 | |
ross.kirsling@sony.com | 848a138 | 2019-04-09 18:50:00 +0000 | [diff] [blame] | 28 | #include "BytecodeStructs.h" |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 29 | #include "CodeBlock.h" |
tzagallo@apple.com | 3474dd0 | 2018-10-29 13:16:03 +0000 | [diff] [blame] | 30 | #include "Instruction.h" |
| 31 | #include <wtf/Forward.h> |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 32 | |
| 33 | namespace JSC { |
| 34 | |
tzagallo@apple.com | 59ae72b | 2019-12-10 19:41:40 +0000 | [diff] [blame] | 35 | void computeUsesForBytecodeIndexImpl(VirtualRegister, const Instruction*, const Function<void(VirtualRegister)>&); |
| 36 | void computeDefsForBytecodeIndexImpl(unsigned, const Instruction*, const Function<void(VirtualRegister)>&); |
tzagallo@apple.com | 3474dd0 | 2018-10-29 13:16:03 +0000 | [diff] [blame] | 37 | |
tzagallo@apple.com | 59ae72b | 2019-12-10 19:41:40 +0000 | [diff] [blame] | 38 | template<typename Block> |
| 39 | void computeUsesForBytecodeIndex(Block* codeBlock, const Instruction* instruction, const Function<void(VirtualRegister)>& functor) |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 40 | { |
ysuzuki@apple.com | 86dae44 | 2019-11-22 19:55:27 +0000 | [diff] [blame] | 41 | OpcodeID opcodeID = instruction->opcodeID(); |
sbarati@apple.com | 60a3be7 | 2017-08-25 18:26:15 +0000 | [diff] [blame] | 42 | if (opcodeID != op_enter && (codeBlock->wasCompiledWithDebuggingOpcodes() || codeBlock->usesEval()) && codeBlock->scopeRegister().isValid()) |
tzagallo@apple.com | 3474dd0 | 2018-10-29 13:16:03 +0000 | [diff] [blame] | 43 | functor(codeBlock->scopeRegister()); |
| 44 | |
tzagallo@apple.com | 59ae72b | 2019-12-10 19:41:40 +0000 | [diff] [blame] | 45 | computeUsesForBytecodeIndexImpl(codeBlock->scopeRegister(), instruction, functor); |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 46 | } |
| 47 | |
tzagallo@apple.com | 59ae72b | 2019-12-10 19:41:40 +0000 | [diff] [blame] | 48 | template<typename Block> |
| 49 | void computeDefsForBytecodeIndex(Block* codeBlock, const Instruction* instruction, const Function<void(VirtualRegister)>& functor) |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 50 | { |
tzagallo@apple.com | 59ae72b | 2019-12-10 19:41:40 +0000 | [diff] [blame] | 51 | computeDefsForBytecodeIndexImpl(codeBlock->numVars(), instruction, functor); |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 52 | } |
| 53 | |
tzagallo@apple.com | 3474dd0 | 2018-10-29 13:16:03 +0000 | [diff] [blame] | 54 | #undef CALL_FUNCTOR |
| 55 | #undef USES_OR_DEFS |
| 56 | #undef USES |
| 57 | #undef DEFS |
fpizlo@apple.com | 0309686b | 2013-12-02 19:49:43 +0000 | [diff] [blame] | 58 | } // namespace JSC |