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. Usually you do *not* want to call this, you want
29
// BaselineAvailable().
30
MOZ_MUST_USE bool BaselinePlatformSupport();
31
32
// Generate adequate code quickly.
33
MOZ_MUST_USE bool BaselineCompileFunctions(const ModuleEnvironment& env,
34
LifoAlloc& lifo,
35
const FuncCompileInputVector& inputs,
36
CompiledCode* code,
37
UniqueChars* error);
38
39
class BaseLocalIter {
40
private:
41
using ConstValTypeRange = mozilla::Range<const ValType>;
42
43
const ValTypeVector& locals_;
44
const ArgTypeVector& args_;
45
jit::ABIArgIter<ArgTypeVector> argsIter_;
46
size_t index_;
47
int32_t frameSize_;
48
int32_t nextFrameSize_;
49
int32_t frameOffset_;
50
int32_t stackResultPointerOffset_;
51
jit::MIRType mirType_;
52
bool done_;
53
54
void settle();
55
int32_t pushLocal(size_t nbytes);
56
57
public:
58
BaseLocalIter(const ValTypeVector& locals, const ArgTypeVector& args,
59
bool debugEnabled);
60
void operator++(int);
61
bool done() const { return done_; }
62
63
jit::MIRType mirType() const {
64
MOZ_ASSERT(!done_);
65
return mirType_;
66
}
67
int32_t frameOffset() const {
68
MOZ_ASSERT(!done_);
69
MOZ_ASSERT(frameOffset_ != INT32_MAX);
70
return frameOffset_;
71
}
72
size_t index() const {
73
MOZ_ASSERT(!done_);
74
return index_;
75
}
76
// The size in bytes taken up by the previous `index_` locals, also including
77
// fixed allocations like the DebugFrame and "hidden" locals like a spilled
78
// stack results pointer.
79
int32_t frameSize() const { return frameSize_; }
80
81
int32_t stackResultPointerOffset() const {
82
MOZ_ASSERT(args_.hasSyntheticStackResultPointerArg());
83
MOZ_ASSERT(stackResultPointerOffset_ != INT32_MAX);
84
return stackResultPointerOffset_;
85
}
86
87
#ifdef DEBUG
88
bool isArg() const {
89
MOZ_ASSERT(!done_);
90
return !argsIter_.done();
91
}
92
#endif
93
};
94
95
#ifdef DEBUG
96
// Check whether |nextPC| is a valid code address for a stackmap created by
97
// this compiler.
98
bool IsValidStackMapKey(bool debugEnabled, const uint8_t* nextPC);
99
#endif
100
101
} // namespace wasm
102
} // namespace js
103
104
#endif // asmjs_wasm_baseline_compile_h