oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 9339889 | 2015-07-10 21:19:51 +0000 | [diff] [blame] | 2 | * Copyright (C) 2013, 2015 Apple Inc. All rights reserved. |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +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 | |
| 26 | #ifndef FTLJITCode_h |
| 27 | #define FTLJITCode_h |
| 28 | |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 29 | #if ENABLE(FTL_JIT) |
| 30 | |
fpizlo@apple.com | e362fbc | 2015-12-03 20:01:57 +0000 | [diff] [blame] | 31 | #include "B3OpaqueByproducts.h" |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 32 | #include "DFGCommonData.h" |
fpizlo@apple.com | 6b66809 | 2014-02-19 23:11:06 +0000 | [diff] [blame] | 33 | #include "FTLDataSection.h" |
fpizlo@apple.com | 6e69796 | 2015-10-12 17:56:26 +0000 | [diff] [blame] | 34 | #include "FTLLazySlowPath.h" |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 35 | #include "FTLOSRExit.h" |
fpizlo@apple.com | ea92c20 | 2013-10-10 04:24:57 +0000 | [diff] [blame] | 36 | #include "FTLStackMaps.h" |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 37 | #include "FTLUnwindInfo.h" |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 38 | #include "JITCode.h" |
fpizlo@apple.com | ef8dbf8 | 2013-10-10 22:19:00 +0000 | [diff] [blame] | 39 | #include "LLVMAPI.h" |
fpizlo@apple.com | 708586d | 2013-10-07 22:46:54 +0000 | [diff] [blame] | 40 | #include <wtf/RefCountedArray.h> |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 41 | |
llango.u-szeged@partner.samsung.com | 885437c | 2014-09-11 08:52:22 +0000 | [diff] [blame] | 42 | #if OS(DARWIN) |
| 43 | #define SECTION_NAME_PREFIX "__" |
| 44 | #elif OS(LINUX) |
| 45 | #define SECTION_NAME_PREFIX "." |
| 46 | #else |
| 47 | #error "Unsupported platform" |
| 48 | #endif |
| 49 | |
| 50 | #define SECTION_NAME(NAME) (SECTION_NAME_PREFIX NAME) |
| 51 | |
fpizlo@apple.com | 9339889 | 2015-07-10 21:19:51 +0000 | [diff] [blame] | 52 | namespace JSC { |
| 53 | |
| 54 | class TrackedReferences; |
| 55 | |
| 56 | namespace FTL { |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 57 | |
| 58 | class JITCode : public JSC::JITCode { |
| 59 | public: |
| 60 | JITCode(); |
| 61 | ~JITCode(); |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 62 | |
msaboff@apple.com | 21bd737 | 2015-09-18 16:21:08 +0000 | [diff] [blame] | 63 | CodePtr addressForCall(ArityCheckMode) override; |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 64 | void* executableAddressAtOffset(size_t offset) override; |
| 65 | void* dataAddressAtOffset(size_t offset) override; |
| 66 | unsigned offsetOf(void* pointerIntoCode) override; |
| 67 | size_t size() override; |
| 68 | bool contains(void*) override; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 69 | |
| 70 | #if FTL_USES_B3 |
| 71 | void initializeB3Code(CodeRef); |
fpizlo@apple.com | e362fbc | 2015-12-03 20:01:57 +0000 | [diff] [blame] | 72 | void initializeB3Byproducts(std::unique_ptr<B3::OpaqueByproducts>); |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 73 | #else |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 74 | void initializeExitThunks(CodeRef); |
oliver@apple.com | d28101d | 2013-07-25 04:00:41 +0000 | [diff] [blame] | 75 | void addHandle(PassRefPtr<ExecutableMemoryHandle>); |
fpizlo@apple.com | 6b66809 | 2014-02-19 23:11:06 +0000 | [diff] [blame] | 76 | void addDataSection(PassRefPtr<DataSection>); |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 77 | #endif |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 78 | void initializeAddressForCall(CodePtr); |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 79 | void initializeArityCheckEntrypoint(CodeRef); |
oliver@apple.com | d28101d | 2013-07-25 04:00:41 +0000 | [diff] [blame] | 80 | |
fpizlo@apple.com | 9339889 | 2015-07-10 21:19:51 +0000 | [diff] [blame] | 81 | void validateReferences(const TrackedReferences&) override; |
sbarati@apple.com | 9aacac4 | 2015-10-08 19:37:28 +0000 | [diff] [blame] | 82 | |
| 83 | RegisterSet liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex) override; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 84 | |
sbarati@apple.com | d3d0c00 | 2016-01-30 01:11:05 +0000 | [diff] [blame^] | 85 | Optional<CodeOrigin> findPC(CodeBlock*, void* pc) override; |
| 86 | |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 87 | #if FTL_USES_B3 |
| 88 | CodeRef b3Code() const { return m_b3Code; } |
| 89 | #else |
fpizlo@apple.com | 708586d | 2013-10-07 22:46:54 +0000 | [diff] [blame] | 90 | const Vector<RefPtr<ExecutableMemoryHandle>>& handles() const { return m_handles; } |
fpizlo@apple.com | 6b66809 | 2014-02-19 23:11:06 +0000 | [diff] [blame] | 91 | const Vector<RefPtr<DataSection>>& dataSections() const { return m_dataSections; } |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 92 | |
| 93 | CodePtr exitThunks(); |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 94 | #endif |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 95 | |
andersca@apple.com | e782bf1 | 2014-12-06 21:04:31 +0000 | [diff] [blame] | 96 | JITCode* ftl() override; |
| 97 | DFG::CommonData* dfgCommon() override; |
sbarati@apple.com | a582c18 | 2015-12-05 00:04:01 +0000 | [diff] [blame] | 98 | static ptrdiff_t commonDataOffset() { return OBJECT_OFFSETOF(JITCode, common); } |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 99 | |
| 100 | DFG::CommonData common; |
| 101 | SegmentedVector<OSRExit, 8> osrExit; |
sbarati@apple.com | cda241d | 2015-10-19 20:29:45 +0000 | [diff] [blame] | 102 | SegmentedVector<OSRExitDescriptor, 8> osrExitDescriptors; |
fpizlo@apple.com | e362fbc | 2015-12-03 20:01:57 +0000 | [diff] [blame] | 103 | #if !FTL_USES_B3 |
fpizlo@apple.com | ea92c20 | 2013-10-10 04:24:57 +0000 | [diff] [blame] | 104 | StackMaps stackmaps; |
fpizlo@apple.com | e362fbc | 2015-12-03 20:01:57 +0000 | [diff] [blame] | 105 | #endif // !FTL_USES_B3 |
fpizlo@apple.com | 6e69796 | 2015-10-12 17:56:26 +0000 | [diff] [blame] | 106 | Vector<std::unique_ptr<LazySlowPath>> lazySlowPaths; |
sbarati@apple.com | a582c18 | 2015-12-05 00:04:01 +0000 | [diff] [blame] | 107 | int32_t osrExitFromGenericUnwindStackSpillSlot; |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 108 | |
| 109 | private: |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 110 | CodePtr m_addressForCall; |
| 111 | #if FTL_USES_B3 |
| 112 | CodeRef m_b3Code; |
fpizlo@apple.com | e362fbc | 2015-12-03 20:01:57 +0000 | [diff] [blame] | 113 | std::unique_ptr<B3::OpaqueByproducts> m_b3Byproducts; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 114 | #else |
fpizlo@apple.com | 6b66809 | 2014-02-19 23:11:06 +0000 | [diff] [blame] | 115 | Vector<RefPtr<DataSection>> m_dataSections; |
fpizlo@apple.com | 708586d | 2013-10-07 22:46:54 +0000 | [diff] [blame] | 116 | Vector<RefPtr<ExecutableMemoryHandle>> m_handles; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 117 | #endif |
msaboff@apple.com | 9589433 | 2014-01-29 19:18:54 +0000 | [diff] [blame] | 118 | CodeRef m_arityCheckEntrypoint; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 119 | #if !FTL_USES_B3 |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 120 | CodeRef m_exitThunks; |
fpizlo@apple.com | f74e4ae | 2015-11-18 23:05:34 +0000 | [diff] [blame] | 121 | #endif |
oliver@apple.com | ea77149 | 2013-07-25 03:58:38 +0000 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | } } // namespace JSC::FTL |
| 125 | |
| 126 | #endif // ENABLE(FLT_JIT) |
| 127 | |
| 128 | #endif // FTLJITCode_h |
| 129 | |