Source code

Revision control

Other Tools

1
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
* vim: set ts=8 sts=2 et sw=2 tw=80:
3
*
4
* Copyright 2017 Mozilla Foundation
5
*
6
* Licensed under the Apache License, Version 2.0 (the "License");
7
* you may not use this file except in compliance with the License.
8
* You may obtain a copy of the License at
9
*
11
*
12
* Unless required by applicable law or agreed to in writing, software
13
* distributed under the License is distributed on an "AS IS" BASIS,
14
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
* See the License for the specific language governing permissions and
16
* limitations under the License.
17
*/
18
19
#ifndef wasm_builtins_h
20
#define wasm_builtins_h
21
22
#include "wasm/WasmTypes.h"
23
24
namespace js {
25
namespace wasm {
26
27
class WasmFrameIter;
28
29
// These provide argument type information for a subset of the SymbolicAddress
30
// targets, for which type info is needed to generate correct stackmaps.
31
32
extern const SymbolicAddressSignature SASigSinD;
33
extern const SymbolicAddressSignature SASigCosD;
34
extern const SymbolicAddressSignature SASigTanD;
35
extern const SymbolicAddressSignature SASigASinD;
36
extern const SymbolicAddressSignature SASigACosD;
37
extern const SymbolicAddressSignature SASigATanD;
38
extern const SymbolicAddressSignature SASigCeilD;
39
extern const SymbolicAddressSignature SASigCeilF;
40
extern const SymbolicAddressSignature SASigFloorD;
41
extern const SymbolicAddressSignature SASigFloorF;
42
extern const SymbolicAddressSignature SASigTruncD;
43
extern const SymbolicAddressSignature SASigTruncF;
44
extern const SymbolicAddressSignature SASigNearbyIntD;
45
extern const SymbolicAddressSignature SASigNearbyIntF;
46
extern const SymbolicAddressSignature SASigExpD;
47
extern const SymbolicAddressSignature SASigLogD;
48
extern const SymbolicAddressSignature SASigPowD;
49
extern const SymbolicAddressSignature SASigATan2D;
50
extern const SymbolicAddressSignature SASigMemoryGrow;
51
extern const SymbolicAddressSignature SASigMemorySize;
52
extern const SymbolicAddressSignature SASigWaitI32;
53
extern const SymbolicAddressSignature SASigWaitI64;
54
extern const SymbolicAddressSignature SASigWake;
55
extern const SymbolicAddressSignature SASigMemCopy;
56
extern const SymbolicAddressSignature SASigMemCopyShared;
57
extern const SymbolicAddressSignature SASigDataDrop;
58
extern const SymbolicAddressSignature SASigMemFill;
59
extern const SymbolicAddressSignature SASigMemFillShared;
60
extern const SymbolicAddressSignature SASigMemInit;
61
extern const SymbolicAddressSignature SASigTableCopy;
62
extern const SymbolicAddressSignature SASigElemDrop;
63
extern const SymbolicAddressSignature SASigTableFill;
64
extern const SymbolicAddressSignature SASigTableGet;
65
extern const SymbolicAddressSignature SASigTableGrow;
66
extern const SymbolicAddressSignature SASigTableInit;
67
extern const SymbolicAddressSignature SASigTableSet;
68
extern const SymbolicAddressSignature SASigTableSize;
69
extern const SymbolicAddressSignature SASigFuncRef;
70
extern const SymbolicAddressSignature SASigPostBarrier;
71
extern const SymbolicAddressSignature SASigPostBarrierFiltering;
72
extern const SymbolicAddressSignature SASigStructNew;
73
extern const SymbolicAddressSignature SASigStructNarrow;
74
75
// A SymbolicAddress that NeedsBuiltinThunk() will call through a thunk to the
76
// C++ function. This will be true for all normal calls from normal wasm
77
// function code. Only calls to C++ from other exits/thunks do not need a thunk.
78
79
bool NeedsBuiltinThunk(SymbolicAddress sym);
80
81
// This function queries whether pc is in one of the process's builtin thunks
82
// and, if so, returns the CodeRange and pointer to the code segment that the
83
// CodeRange is relative to.
84
85
bool LookupBuiltinThunk(void* pc, const CodeRange** codeRange,
86
uint8_t** codeBase);
87
88
// EnsureBuiltinThunksInitialized() must be called, and must succeed, before
89
// SymbolicAddressTarget() or MaybeGetBuiltinThunk(). This function creates all
90
// thunks for the process. ReleaseBuiltinThunks() should be called before
91
// ReleaseProcessExecutableMemory() so that the latter can assert that all
92
// executable code has been released.
93
94
bool EnsureBuiltinThunksInitialized();
95
96
void* HandleThrow(JSContext* cx, WasmFrameIter& iter);
97
98
void* SymbolicAddressTarget(SymbolicAddress sym);
99
100
void* MaybeGetBuiltinThunk(JSFunction* f, const FuncType& funcType);
101
102
void ReleaseBuiltinThunks();
103
104
void* AddressOf(SymbolicAddress imm, jit::ABIFunctionType* abiType);
105
106
#ifdef WASM_CODEGEN_DEBUG
107
void PrintI32(int32_t val);
108
void PrintF32(float val);
109
void PrintF64(double val);
110
void PrintPtr(uint8_t* val);
111
void PrintText(const char* out);
112
#endif
113
114
} // namespace wasm
115
} // namespace js
116
117
#endif // wasm_builtins_h