Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 : * vim: set ts=8 sts=4 et sw=4 tw=99:
3 : *
4 : * Copyright 2015 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 : *
10 : * http://www.apache.org/licenses/LICENSE-2.0
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_compile_h
20 : #define wasm_compile_h
21 :
22 : #include "wasm/WasmModule.h"
23 :
24 : namespace js {
25 : namespace wasm {
26 :
27 : // Describes the JS scripted caller of a request to compile a wasm module.
28 :
29 0 : struct ScriptedCaller
30 : {
31 : UniqueChars filename;
32 : unsigned line;
33 : unsigned column;
34 : };
35 :
36 : // Describes all the parameters that control wasm compilation.
37 :
38 0 : struct CompileArgs
39 : {
40 : Assumptions assumptions;
41 : ScriptedCaller scriptedCaller;
42 : bool alwaysBaseline;
43 : bool debugEnabled;
44 :
45 0 : CompileArgs(Assumptions&& assumptions, ScriptedCaller&& scriptedCaller)
46 0 : : assumptions(Move(assumptions)),
47 0 : scriptedCaller(Move(scriptedCaller)),
48 : alwaysBaseline(false),
49 0 : debugEnabled(false)
50 0 : {}
51 :
52 : // If CompileArgs is constructed without arguments, initFromContext() must
53 : // be called to complete initialization.
54 0 : CompileArgs() = default;
55 : bool initFromContext(JSContext* cx, ScriptedCaller&& scriptedCaller);
56 : };
57 :
58 : // Compile the given WebAssembly bytecode with the given arguments into a
59 : // wasm::Module. On success, the Module is returned. On failure, the returned
60 : // SharedModule pointer is null and either:
61 : // - *error points to a string description of the error
62 : // - *error is null and the caller should report out-of-memory.
63 :
64 : SharedModule
65 : Compile(const ShareableBytes& bytecode, const CompileArgs& args, UniqueChars* error);
66 :
67 : } // namespace wasm
68 : } // namespace js
69 :
70 : #endif // namespace wasm_compile_h
|