blob: b18b976dbec1c78bde32bf9dab27727d59f72924 [file] [log] [blame]
oliver@apple.comea771492013-07-25 03:58:38 +00001/*
fpizlo@apple.com93398892015-07-10 21:19:51 +00002 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
oliver@apple.comea771492013-07-25 03:58:38 +00003 *
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.comea771492013-07-25 03:58:38 +000029#if ENABLE(FTL_JIT)
30
fpizlo@apple.come362fbc2015-12-03 20:01:57 +000031#include "B3OpaqueByproducts.h"
oliver@apple.comea771492013-07-25 03:58:38 +000032#include "DFGCommonData.h"
fpizlo@apple.com6b668092014-02-19 23:11:06 +000033#include "FTLDataSection.h"
fpizlo@apple.com6e697962015-10-12 17:56:26 +000034#include "FTLLazySlowPath.h"
oliver@apple.comea771492013-07-25 03:58:38 +000035#include "FTLOSRExit.h"
fpizlo@apple.comea92c202013-10-10 04:24:57 +000036#include "FTLStackMaps.h"
msaboff@apple.com95894332014-01-29 19:18:54 +000037#include "FTLUnwindInfo.h"
oliver@apple.comea771492013-07-25 03:58:38 +000038#include "JITCode.h"
fpizlo@apple.comef8dbf82013-10-10 22:19:00 +000039#include "LLVMAPI.h"
fpizlo@apple.com708586d2013-10-07 22:46:54 +000040#include <wtf/RefCountedArray.h>
oliver@apple.comea771492013-07-25 03:58:38 +000041
llango.u-szeged@partner.samsung.com885437c2014-09-11 08:52:22 +000042#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.com93398892015-07-10 21:19:51 +000052namespace JSC {
53
54class TrackedReferences;
55
56namespace FTL {
oliver@apple.comea771492013-07-25 03:58:38 +000057
58class JITCode : public JSC::JITCode {
59public:
60 JITCode();
61 ~JITCode();
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000062
msaboff@apple.com21bd7372015-09-18 16:21:08 +000063 CodePtr addressForCall(ArityCheckMode) override;
msaboff@apple.com95894332014-01-29 19:18:54 +000064 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.comf74e4ae2015-11-18 23:05:34 +000069
70#if FTL_USES_B3
71 void initializeB3Code(CodeRef);
fpizlo@apple.come362fbc2015-12-03 20:01:57 +000072 void initializeB3Byproducts(std::unique_ptr<B3::OpaqueByproducts>);
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000073#else
oliver@apple.comea771492013-07-25 03:58:38 +000074 void initializeExitThunks(CodeRef);
oliver@apple.comd28101d2013-07-25 04:00:41 +000075 void addHandle(PassRefPtr<ExecutableMemoryHandle>);
fpizlo@apple.com6b668092014-02-19 23:11:06 +000076 void addDataSection(PassRefPtr<DataSection>);
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000077#endif
msaboff@apple.com95894332014-01-29 19:18:54 +000078 void initializeAddressForCall(CodePtr);
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000079 void initializeArityCheckEntrypoint(CodeRef);
oliver@apple.comd28101d2013-07-25 04:00:41 +000080
fpizlo@apple.com93398892015-07-10 21:19:51 +000081 void validateReferences(const TrackedReferences&) override;
sbarati@apple.com9aacac42015-10-08 19:37:28 +000082
83 RegisterSet liveRegistersToPreserveAtExceptionHandlingCallSite(CodeBlock*, CallSiteIndex) override;
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000084
sbarati@apple.comd3d0c002016-01-30 01:11:05 +000085 Optional<CodeOrigin> findPC(CodeBlock*, void* pc) override;
86
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000087#if FTL_USES_B3
88 CodeRef b3Code() const { return m_b3Code; }
89#else
fpizlo@apple.com708586d2013-10-07 22:46:54 +000090 const Vector<RefPtr<ExecutableMemoryHandle>>& handles() const { return m_handles; }
fpizlo@apple.com6b668092014-02-19 23:11:06 +000091 const Vector<RefPtr<DataSection>>& dataSections() const { return m_dataSections; }
oliver@apple.comea771492013-07-25 03:58:38 +000092
93 CodePtr exitThunks();
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +000094#endif
oliver@apple.comea771492013-07-25 03:58:38 +000095
andersca@apple.come782bf12014-12-06 21:04:31 +000096 JITCode* ftl() override;
97 DFG::CommonData* dfgCommon() override;
sbarati@apple.coma582c182015-12-05 00:04:01 +000098 static ptrdiff_t commonDataOffset() { return OBJECT_OFFSETOF(JITCode, common); }
oliver@apple.comea771492013-07-25 03:58:38 +000099
100 DFG::CommonData common;
101 SegmentedVector<OSRExit, 8> osrExit;
sbarati@apple.comcda241d2015-10-19 20:29:45 +0000102 SegmentedVector<OSRExitDescriptor, 8> osrExitDescriptors;
fpizlo@apple.come362fbc2015-12-03 20:01:57 +0000103#if !FTL_USES_B3
fpizlo@apple.comea92c202013-10-10 04:24:57 +0000104 StackMaps stackmaps;
fpizlo@apple.come362fbc2015-12-03 20:01:57 +0000105#endif // !FTL_USES_B3
fpizlo@apple.com6e697962015-10-12 17:56:26 +0000106 Vector<std::unique_ptr<LazySlowPath>> lazySlowPaths;
sbarati@apple.coma582c182015-12-05 00:04:01 +0000107 int32_t osrExitFromGenericUnwindStackSpillSlot;
oliver@apple.comea771492013-07-25 03:58:38 +0000108
109private:
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +0000110 CodePtr m_addressForCall;
111#if FTL_USES_B3
112 CodeRef m_b3Code;
fpizlo@apple.come362fbc2015-12-03 20:01:57 +0000113 std::unique_ptr<B3::OpaqueByproducts> m_b3Byproducts;
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +0000114#else
fpizlo@apple.com6b668092014-02-19 23:11:06 +0000115 Vector<RefPtr<DataSection>> m_dataSections;
fpizlo@apple.com708586d2013-10-07 22:46:54 +0000116 Vector<RefPtr<ExecutableMemoryHandle>> m_handles;
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +0000117#endif
msaboff@apple.com95894332014-01-29 19:18:54 +0000118 CodeRef m_arityCheckEntrypoint;
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +0000119#if !FTL_USES_B3
oliver@apple.comea771492013-07-25 03:58:38 +0000120 CodeRef m_exitThunks;
fpizlo@apple.comf74e4ae2015-11-18 23:05:34 +0000121#endif
oliver@apple.comea771492013-07-25 03:58:38 +0000122};
123
124} } // namespace JSC::FTL
125
126#endif // ENABLE(FLT_JIT)
127
128#endif // FTLJITCode_h
129