-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkrgc.cc
78 lines (65 loc) · 2.45 KB
/
krgc.cc
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "src/krgc/krgc.h"
#include <cstdio>
#include "src/utils/allocation.h"
#include "src/utils/memcopy.h"
// last 2 bits are the instruction
const int krgc::loc_shift = 2;
const int krgc::insn_mask = 0x03;
const int krgc::int_flag = 0;
//const int krgc::int_flag = (static_cast<int>(krgc::location::LdaKeyedProperty) << krgc::loc_shift) | static_cast<int>(krgc::instruction::rdtscp);
//const int krgc::int_flag = (static_cast<int>(krgc::location::LdaKeyedProperty) << krgc::loc_shift) | static_cast<int>(krgc::instruction::rdpmc);
//const int krgc::int_flag = (static_cast<int>(krgc::location::overhead) << krgc::loc_shift) | static_cast<int>(krgc::instruction::rdpmc);
uint32_t operator | (krgc::check lhs, krgc::check rhs) {
using T = std::underlying_type_t <krgc::check>;
return static_cast<T>(lhs) | static_cast<T>(rhs);
}
uint32_t operator | (uint32_t lhs, krgc::check rhs) {
using T = std::underlying_type_t<krgc::check>;
return lhs | static_cast<T>(rhs);
}
//const uint32_t krgc::jit_flag = static_cast<uint32_t>(krgc::check::none);
//const uint32_t krgc::jit_flag = static_cast<uint32_t>(krgc::check::smi);
//const uint32_t krgc::jit_flag = static_cast<uint32_t>(krgc::check::shape);
//const uint32_t krgc::jit_flag = static_cast<uint32_t>(krgc::check::array_length);
//const uint32_t krgc::jit_flag = static_cast<uint32_t>(krgc::check::array_hole);
const uint32_t krgc::jit_flag = krgc::check::smi | krgc::check::shape | krgc::check::array_length | krgc::check::array_hole;
static thread_local bool skrilla = false;
void krgc::make_rich(bool b) {
//printf("[hottub3] cash money records %d\n", b);
skrilla = b;
}
bool krgc::has_money() {
return skrilla;
}
static std::vector<const char*> bank;
void krgc::count_cash(const char* function) {
for (const char* filter : bank) {
if (strcmp(function, filter) == 0) {
// printf("[hottub3] CreateGraph %s\n", function);
krgc::make_rich(true);
}
}
}
void krgc::make_bank(const char* functions) {
if (functions == nullptr) {
return;
}
const char* start = functions;
const char* end = functions;
auto get_name = [](const char* start, const char* end) {
size_t n = end - start;
char* func = v8::internal::NewArray<char>(n + 1);
v8::internal::MemCopy(func, start, n);
func[n] = '\0';
bank.push_back(func);
};
for (; *end != '\0'; end++) {
if (*end == ',') {
get_name(start, end);
start = end + 1;
}
}
if (start != end) {
get_name(start, end);
}
}