1 | /*
|
---|
2 | * Copyright (C) 2012-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 "MacroAssemblerCodeRef.h"
|
---|
29 | #include "OpcodeSize.h"
|
---|
30 | #include "VM.h"
|
---|
31 | #include <wtf/Scope.h>
|
---|
32 |
|
---|
33 | namespace JSC {
|
---|
34 |
|
---|
35 | struct ProtoCallFrame;
|
---|
36 | typedef int64_t EncodedJSValue;
|
---|
37 |
|
---|
38 | extern "C" {
|
---|
39 | EncodedJSValue vmEntryToJavaScript(void*, VM*, ProtoCallFrame*);
|
---|
40 | EncodedJSValue vmEntryToNative(void*, VM*, ProtoCallFrame*);
|
---|
41 | EncodedJSValue vmEntryCustomGetter(CPURegister, CPURegister, CPURegister, CPURegister);
|
---|
42 | EncodedJSValue vmEntryCustomSetter(CPURegister, CPURegister, CPURegister, CPURegister, CPURegister);
|
---|
43 | EncodedJSValue vmEntryHostFunction(JSGlobalObject*, CallFrame*, void*);
|
---|
44 | }
|
---|
45 |
|
---|
46 | #if CPU(ARM64E)
|
---|
47 | extern "C" {
|
---|
48 | void jitCagePtrGateAfter(void);
|
---|
49 | void vmEntryToJavaScriptGateAfter(void);
|
---|
50 |
|
---|
51 | void llint_function_for_call_arity_checkUntagGateAfter(void);
|
---|
52 | void llint_function_for_call_arity_checkTagGateAfter(void);
|
---|
53 | void llint_function_for_construct_arity_checkUntagGateAfter(void);
|
---|
54 | void llint_function_for_construct_arity_checkTagGateAfter(void);
|
---|
55 | }
|
---|
56 | #endif
|
---|
57 |
|
---|
58 | inline EncodedJSValue vmEntryToWasm(void* code, VM* vm, ProtoCallFrame* frame)
|
---|
59 | {
|
---|
60 | auto clobberizeValidator = makeScopeExit([&] {
|
---|
61 | vm->didEnterVM = true;
|
---|
62 | });
|
---|
63 | code = retagCodePtr<WasmEntryPtrTag, JSEntryPtrTag>(code);
|
---|
64 | return vmEntryToJavaScript(code, vm, frame);
|
---|
65 | }
|
---|
66 |
|
---|
67 | namespace LLInt {
|
---|
68 |
|
---|
69 | MacroAssemblerCodeRef<JSEntryPtrTag> functionForCallEntryThunk();
|
---|
70 | MacroAssemblerCodeRef<JSEntryPtrTag> functionForConstructEntryThunk();
|
---|
71 | MacroAssemblerCodeRef<JSEntryPtrTag> functionForCallArityCheckThunk();
|
---|
72 | MacroAssemblerCodeRef<JSEntryPtrTag> functionForConstructArityCheckThunk();
|
---|
73 | MacroAssemblerCodeRef<JSEntryPtrTag> evalEntryThunk();
|
---|
74 | MacroAssemblerCodeRef<JSEntryPtrTag> programEntryThunk();
|
---|
75 | MacroAssemblerCodeRef<JSEntryPtrTag> moduleProgramEntryThunk();
|
---|
76 | MacroAssemblerCodeRef<JSEntryPtrTag> getHostCallReturnValueThunk();
|
---|
77 | MacroAssemblerCodeRef<JSEntryPtrTag> genericReturnPointThunk(OpcodeSize);
|
---|
78 | MacroAssemblerCodeRef<JSEntryPtrTag> fuzzerReturnEarlyFromLoopHintThunk();
|
---|
79 |
|
---|
80 | MacroAssemblerCodeRef<ExceptionHandlerPtrTag> callToThrowThunk();
|
---|
81 | MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleUncaughtExceptionThunk();
|
---|
82 | MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleCatchThunk(OpcodeSize);
|
---|
83 |
|
---|
84 | #if ENABLE(WEBASSEMBLY)
|
---|
85 | MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleWasmCatchThunk(OpcodeSize);
|
---|
86 | MacroAssemblerCodeRef<ExceptionHandlerPtrTag> handleWasmCatchAllThunk(OpcodeSize);
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | #if ENABLE(JIT_CAGE)
|
---|
90 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> jitCagePtrThunk();
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | #if CPU(ARM64E)
|
---|
94 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> createJSGateThunk(void*, PtrTag, const char*);
|
---|
95 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> createWasmGateThunk(void*, PtrTag, const char*);
|
---|
96 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> createTailCallGate(PtrTag, bool);
|
---|
97 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> loopOSREntryGateThunk();
|
---|
98 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> entryOSREntryGateThunk();
|
---|
99 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> wasmOSREntryGateThunk();
|
---|
100 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> exceptionHandlerGateThunk();
|
---|
101 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> returnFromLLIntGateThunk();
|
---|
102 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> untagGateThunk(void*);
|
---|
103 | MacroAssemblerCodeRef<NativeToJITGatePtrTag> tagGateThunk(void*);
|
---|
104 | #endif
|
---|
105 |
|
---|
106 | MacroAssemblerCodeRef<JSEntryPtrTag> normalOSRExitTrampolineThunk();
|
---|
107 | #if ENABLE(DFG_JIT)
|
---|
108 | MacroAssemblerCodeRef<JSEntryPtrTag> checkpointOSRExitTrampolineThunk();
|
---|
109 | MacroAssemblerCodeRef<JSEntryPtrTag> checkpointOSRExitFromInlinedCallTrampolineThunk();
|
---|
110 | MacroAssemblerCodeRef<JSEntryPtrTag> returnLocationThunk(OpcodeID, OpcodeSize);
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #if ENABLE(WEBASSEMBLY)
|
---|
114 | MacroAssemblerCodeRef<JITThunkPtrTag> wasmFunctionEntryThunk();
|
---|
115 | #endif // ENABLE(WEBASSEMBLY)
|
---|
116 |
|
---|
117 | } } // namespace JSC::LLInt
|
---|