1 | /* |
2 | * Copyright (C) 2011-2018 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 | #include "DFGAbstractValue.h" |
29 | #include "DFGFlushFormat.h" |
30 | #include "MacroAssemblerCodeRef.h" |
31 | #include "Operands.h" |
32 | #include <wtf/BitVector.h> |
33 | |
34 | namespace JSC { |
35 | |
36 | class CallFrame; |
37 | class CodeBlock; |
38 | |
39 | namespace DFG { |
40 | |
41 | #if ENABLE(DFG_JIT) |
42 | struct OSREntryReshuffling { |
43 | OSREntryReshuffling() { } |
44 | |
45 | OSREntryReshuffling(int fromOffset, int toOffset) |
46 | : fromOffset(fromOffset) |
47 | , toOffset(toOffset) |
48 | { |
49 | } |
50 | |
51 | int fromOffset; |
52 | int toOffset; |
53 | }; |
54 | |
55 | struct OSREntryData { |
56 | BytecodeIndex m_bytecodeIndex; |
57 | CodeLocationLabel<OSREntryPtrTag> m_machineCode; |
58 | Operands<AbstractValue> m_expectedValues; |
59 | // Use bitvectors here because they tend to only require one word. |
60 | BitVector m_localsForcedDouble; |
61 | BitVector m_localsForcedAnyInt; |
62 | Vector<OSREntryReshuffling> m_reshufflings; |
63 | BitVector m_machineStackUsed; |
64 | |
65 | void dumpInContext(PrintStream&, DumpContext*) const; |
66 | void dump(PrintStream&) const; |
67 | }; |
68 | |
69 | inline BytecodeIndex getOSREntryDataBytecodeIndex(OSREntryData* osrEntryData) |
70 | { |
71 | return osrEntryData->m_bytecodeIndex; |
72 | } |
73 | |
74 | struct CatchEntrypointData { |
75 | // We use this when doing OSR entry at catch. We prove the arguments |
76 | // are of the expected type before entering at a catch block. |
77 | MacroAssemblerCodePtr<ExceptionHandlerPtrTag> machineCode; |
78 | Vector<FlushFormat> argumentFormats; |
79 | BytecodeIndex bytecodeIndex; |
80 | }; |
81 | |
82 | // Returns a pointer to a data buffer that the OSR entry thunk will recognize and |
83 | // parse. If this returns null, it means |
84 | void* prepareOSREntry(VM&, CallFrame*, CodeBlock*, BytecodeIndex); |
85 | |
86 | // If null is returned, we can't OSR enter. If it's not null, it's the PC to jump to. |
87 | MacroAssemblerCodePtr<ExceptionHandlerPtrTag> prepareCatchOSREntry(VM&, CallFrame*, CodeBlock* baselineCodeBlock, CodeBlock* optimizedCodeBlock, BytecodeIndex); |
88 | #else |
89 | inline MacroAssemblerCodePtr<ExceptionHandlerPtrTag> prepareOSREntry(VM&, CallFrame*, CodeBlock*, BytecodeIndex) { return nullptr; } |
90 | #endif |
91 | |
92 | } } // namespace JSC::DFG |
93 | |