1 | /* |
2 | * Copyright (C) 2013-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 | #if ENABLE(FTL_JIT) |
29 | |
30 | #include "B3OpaqueByproducts.h" |
31 | #include "DFGCommonData.h" |
32 | #include "FTLLazySlowPath.h" |
33 | #include "FTLOSRExit.h" |
34 | #include "JITCode.h" |
35 | |
36 | namespace JSC { |
37 | |
38 | class TrackedReferences; |
39 | |
40 | namespace FTL { |
41 | |
42 | class JITCode : public JSC::JITCode { |
43 | public: |
44 | JITCode(); |
45 | ~JITCode(); |
46 | |
47 | CodePtr<JSEntryPtrTag> addressForCall(ArityCheckMode) override; |
48 | void* executableAddressAtOffset(size_t offset) override; |
49 | void* dataAddressAtOffset(size_t offset) override; |
50 | unsigned offsetOf(void* pointerIntoCode) override; |
51 | size_t size() override; |
52 | bool contains(void*) override; |
53 | |
54 | void initializeB3Code(CodeRef<JSEntryPtrTag>); |
55 | void initializeB3Byproducts(std::unique_ptr<B3::OpaqueByproducts>); |
56 | void initializeAddressForCall(CodePtr<JSEntryPtrTag>); |
57 | void initializeArityCheckEntrypoint(CodeRef<JSEntryPtrTag>); |
58 | |
59 | void validateReferences(const TrackedReferences&) override; |
60 | |
61 | RegisterSet liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex) override; |
62 | |
63 | Optional<CodeOrigin> findPC(CodeBlock*, void* pc) override; |
64 | |
65 | CodeRef<JSEntryPtrTag> b3Code() const { return m_b3Code; } |
66 | |
67 | JITCode* ftl() override; |
68 | DFG::CommonData* dfgCommon() override; |
69 | static ptrdiff_t commonDataOffset() { return OBJECT_OFFSETOF(JITCode, common); } |
70 | |
71 | DFG::CommonData common; |
72 | SegmentedVector<OSRExit, 8> osrExit; |
73 | SegmentedVector<OSRExitDescriptor, 8> osrExitDescriptors; |
74 | Vector<std::unique_ptr<LazySlowPath>> lazySlowPaths; |
75 | |
76 | private: |
77 | CodePtr<JSEntryPtrTag> m_addressForCall; |
78 | CodeRef<JSEntryPtrTag> m_b3Code; |
79 | std::unique_ptr<B3::OpaqueByproducts> m_b3Byproducts; |
80 | CodeRef<JSEntryPtrTag> m_arityCheckEntrypoint; |
81 | }; |
82 | |
83 | } } // namespace JSC::FTL |
84 | |
85 | #endif // ENABLE(FTL_JIT) |
86 | |