forked from rubinius/rubinius
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbytecode_verification.hpp
58 lines (45 loc) · 1017 Bytes
/
bytecode_verification.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef RBX_BYTECODE_VERIFICATION
#define RBX_BYTECODE_VERIFICATION
#include <stdint.h>
#include <list>
namespace rubinius {
class CompiledCode;
class State;
class VM;
class Tuple;
class BytecodeVerification {
CompiledCode* method_;
Tuple* ops_;
native_int total_;
int max_stack_allowed_;
int max_stack_seen_;
int32_t* stack_;
native_int locals_;
int max_stack_local_;
const char* fail_reason_;
int fail_ip_;
void fail(const char* reason, int ip) {
fail_reason_ = reason;
fail_ip_ = ip;
}
struct Section {
int sp;
int ip;
Section(int sp, int ip)
: sp(sp), ip(ip)
{}
};
public:
BytecodeVerification(CompiledCode* code);
~BytecodeVerification();
bool verify(STATE);
bool verify_from(STATE, int sp, int ip, std::list<Section>& ips);
const char* failure_reason() const {
return fail_reason_;
}
int failure_ip() const {
return fail_ip_;
}
};
}
#endif