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 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
*
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
24
namespace js {
25
namespace wasm {
26
27
// Return whether BaselineCompileFunction can generate code on the current
28
// device.
29
bool BaselineCanCompile();
30
31
// Generate adequate code quickly.
32
MOZ_MUST_USE bool BaselineCompileFunctions(const ModuleEnvironment& env,
33
LifoAlloc& lifo,
34
const FuncCompileInputVector& inputs,
35
CompiledCode* code,
36
UniqueChars* error);
37
38
class BaseLocalIter {
39
private:
40
using ConstValTypeRange = mozilla::Range<const ValType>;
41
42
const ValTypeVector& locals_;
43
size_t argsLength_;
44
ConstValTypeRange argsRange_; // range struct cache for ABIArgIter
45
jit::ABIArgIter<ConstValTypeRange> argsIter_;
46
size_t index_;
47
int32_t localSize_;
48
int32_t reservedSize_;
49
int32_t frameOffset_;
50
jit::MIRType mirType_;
51
bool done_;
52
53
void settle();
54
int32_t pushLocal(size_t nbytes);
55
56
public:
57
BaseLocalIter(const ValTypeVector& locals, size_t argsLength,
58
bool debugEnabled);
59
void operator++(int);
60
bool done() const { return done_; }
61
62
jit::MIRType mirType() const {
63
MOZ_ASSERT(!done_);
64
return mirType_;
65
}
66
int32_t frameOffset() const {
67
MOZ_ASSERT(!done_);
68
return frameOffset_;
69
}
70
size_t index() const {
71
MOZ_ASSERT(!done_);
72
return index_;
73
}
74
int32_t currentLocalSize() const { return localSize_; }
75
int32_t reservedSize() const { return reservedSize_; }
76
77
#ifdef DEBUG
78
bool isArg() const {
79
MOZ_ASSERT(!done_);
80
return !argsIter_.done();
81
}
82
#endif
83
};
84
85
#ifdef DEBUG
86
// Check whether |nextPC| is a valid code address for a stackmap created by
87
// this compiler.
88
bool IsValidStackMapKey(bool debugEnabled, const uint8_t* nextPC);
89
#endif
90
91
} // namespace wasm
92
} // namespace js
93
94
#endif // asmjs_wasm_baseline_compile_h