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 2016 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 asmjs_wasm_baseline_compile_h
20 : #define asmjs_wasm_baseline_compile_h
21 :
22 : #include "wasm/WasmGenerator.h"
23 : #include "wasm/WasmTypes.h"
24 :
25 : namespace js {
26 : namespace wasm {
27 :
28 : class CompileTask;
29 : class FuncCompileUnit;
30 :
31 : // Return whether BaselineCompileFunction can generate code on the current device.
32 : // Note: asm.js is also currently not supported due to Atomics and SIMD.
33 : bool
34 : BaselineCanCompile();
35 :
36 : // Generate adequate code quickly.
37 : bool
38 : BaselineCompileFunction(CompileTask* task, FuncCompileUnit* unit, UniqueChars* error);
39 :
40 : class BaseLocalIter
41 : {
42 : private:
43 : using ConstValTypeRange = mozilla::Range<const ValType>;
44 :
45 : const ValTypeVector& locals_;
46 : size_t argsLength_;
47 : ConstValTypeRange argsRange_; // range struct cache for ABIArgIter
48 : jit::ABIArgIter<ConstValTypeRange> argsIter_;
49 : size_t index_;
50 : int32_t localSize_;
51 : int32_t reservedSize_;
52 : int32_t frameOffset_;
53 : jit::MIRType mirType_;
54 : bool done_;
55 :
56 : void settle();
57 : int32_t pushLocal(size_t nbytes);
58 :
59 : public:
60 : BaseLocalIter(const ValTypeVector& locals, size_t argsLength, bool debugEnabled);
61 : void operator++(int);
62 0 : bool done() const { return done_; }
63 :
64 0 : jit::MIRType mirType() const { MOZ_ASSERT(!done_); return mirType_; }
65 0 : int32_t frameOffset() const { MOZ_ASSERT(!done_); return frameOffset_; }
66 0 : size_t index() const { MOZ_ASSERT(!done_); return index_; }
67 0 : int32_t currentLocalSize() const { return localSize_; }
68 0 : int32_t reservedSize() const { return reservedSize_; }
69 :
70 : #ifdef DEBUG
71 0 : bool isArg() const { MOZ_ASSERT(!done_); return !argsIter_.done(); }
72 : #endif
73 : };
74 :
75 : } // namespace wasm
76 : } // namespace js
77 :
78 : #endif // asmjs_wasm_baseline_compile_h
|