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
const ArgTypeVector& args_;
44
jit::ABIArgIter<ArgTypeVector> argsIter_;
45
size_t index_;
46
int32_t localSize_;
47
int32_t reservedSize_;
48
int32_t frameOffset_;
49
int32_t stackResultPointerOffset_;
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, const ArgTypeVector& args,
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
MOZ_ASSERT(frameOffset_ != INT32_MAX);
69
return frameOffset_;
70
}
71
size_t index() const {
72
MOZ_ASSERT(!done_);
73
return index_;
74
}
75
int32_t currentLocalSize() const { return localSize_; }
76
int32_t reservedSize() const { return reservedSize_; }
77
78
int32_t stackResultPointerOffset() const {
79
MOZ_ASSERT(args_.hasSyntheticStackResultPointerArg());
80
MOZ_ASSERT(stackResultPointerOffset_ != INT32_MAX);
81
return stackResultPointerOffset_;
82
}
83
84
#ifdef DEBUG
85
bool isArg() const {
86
MOZ_ASSERT(!done_);
87
return !argsIter_.done();
88
}
89
#endif
90
};
91
92
#ifdef DEBUG
93
// Check whether |nextPC| is a valid code address for a stackmap created by
94
// this compiler.
95
bool IsValidStackMapKey(bool debugEnabled, const uint8_t* nextPC);
96
#endif
97
98
} // namespace wasm
99
} // namespace js
100
101
#endif // asmjs_wasm_baseline_compile_h