repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
|---|---|---|
sjbarigye/CPP_Primer
|
chap19/Page840_Screen.h
|
// Screen header from exercise 7.29. Fulfilment move operation.
#ifndef PAGE840_SCREEN_H
#define PAGE840_SCREEN_H
#include <iostream>
#include <sstream>
#include <string>
class Screen{
friend std::ostream& operator<<(std::ostream&, const Screen&);
public:
typedef std::string::size_type pos;
// Action is a pointer that can be assigned any of the cursor movement members
using Action = Screen& (Screen::*)();
// specify which direction to move
enum Directions { HOME, FORWARD, BACK, UP, DOWN };
Screen& move(Directions);
// other interface and implementation as in exercise 7.29
Screen() = default;
Screen(pos ht, pos wd, char c) : height(ht), width(wd), contents(ht * wd, c) {}
char get() const { return contents[cursor]; }
inline char get(pos ht, pos wd) const;
Screen& move(pos r, pos c);
Screen set(pos row, pos col, char c);
Screen set(char c);
Screen& display(std::ostream &os);
const Screen& display(std::ostream &os) const;
private:
// cursor movement functions
Screen& home();
Screen& forward();
Screen& back();
Screen& up();
Screen& down();
void do_display(std::ostream &os) const; // declare as const to apply to all cases
pos cursor = 0;
pos height = 0, width = 0;
std::string contents;
static Action Menu[]; // function table
};
inline char Screen::get(pos r, pos c) const
{
pos row = r * width;
return contents[row + c];
}
inline Screen& Screen::move(pos r, pos c)
{
pos row = r * width;
cursor = row + c;
return *this;
}
inline Screen Screen::set(pos row, pos col, char c)
{
contents[row * width + col] = c;
return *this;
}
inline Screen Screen::set(char c)
{
contents[cursor] = c;
return *this;
}
inline Screen& Screen::display(std::ostream &os)
{
do_display(os);
return *this;
}
inline const Screen& Screen::display(std::ostream &os) const
{
do_display(os);
return *this;
}
// enhance do_display to show a rectangle
inline void Screen::do_display(std::ostream &os) const
{
std::ostringstream scr_buff;
for (pos i = 0; i != height; ++i) {
// display the location of cursor
if (i * width <= cursor && cursor < (i + 1) * width) {
std::string line_str = contents.substr(i * width, width);
line_str[cursor - i * width] = '_';
scr_buff << line_str << "\n";
} else {
scr_buff << contents.substr(i * width ,width) << "\n";
}
}
os << scr_buff.str();
}
inline std::ostream& operator<<(std::ostream &os, const Screen &s)
{
s.do_display(os);
return os;
}
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_07_size.h
|
<filename>chap16/Exer16_07_size.h
#ifndef EXER16_07_SIZE_H
#define EXER16_07_SIZE_H
template <typename T, unsigned N>
inline constexpr unsigned size(const T(&arr)[N])
{
return N;
}
#endif
|
sjbarigye/CPP_Primer
|
chap13/Exer13_18.h
|
#include <iostream>
#include <string>
class Employee {
public:
Employee() : id(++count) {}
Employee(const std::string& s) : name(s), id(++count){}
Employee(const Employee& e) : name(e.name), id(++count) {}
Employee& operator=(const Employee&);
~Employee() { --count; }
private:
std::string name;
unsigned id;
static unsigned count;
};
Employee& Employee::operator=(const Employee& e)
{
name = e.name;
id = ++count;
}
|
sjbarigye/CPP_Primer
|
chap17/Exer17_03_TextQuery.h
|
<reponame>sjbarigye/CPP_Primer
// TextQuery class header from exercise 12.30
#ifndef TEXT_QUERY_H
#define TEXT_QUERY_H
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <memory>
#include <tuple>
std::string make_plural(size_t, const std::string&, const std::string&);
class QueryResult;
class TextQuery{
public:
using line_no = std::vector<std::string>::size_type;
// replace QueryResult with tuple, required by exercise 17.33
using QueryResult = std::tuple<std::string,
std::shared_ptr<std::set<line_no>>,
std::shared_ptr<std::vector<std::string>>>;
TextQuery(std::ifstream&);
QueryResult query(const std::string&) const;
private:
std::shared_ptr<std::vector<std::string>> file;
std::map<std::string, std::shared_ptr<std::set<line_no>>> wm;
};
std::ostream& print(std::ostream&, const TextQuery::QueryResult&);
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_18.h
|
<reponame>sjbarigye/CPP_Primer
template <typename T, typename U, typename V> void f1(T, U, V);
// every template parameter must be preceded by keyword typename or class
template <typename T> T f2(int &T);
// can not reuse the name that are declared as a template parameter name
inline template <typename T> T foo(T, unsigned int*);
// inline should be put between parameter list and return type
template <typename T> f4(T, T);
// no return type
typedef char Ctype();
template <typename Ctype> Ctype f5(Ctype a);
// ok; but Ctype in template is not an alias of char; it'll be instantiated when f5 is used
|
sjbarigye/CPP_Primer
|
chap13/Exer13_26_StrBlob.h
|
<filename>chap13/Exer13_26_StrBlob.h<gh_stars>10-100
#ifndef EXER13_26_H
#define EXER13_26_H
#include <string>
#include <vector>
#include <initializer_list>
#include <memory>
#include <stdexcept>
class StrBlobPtr;
class ConstStrBlobPtr;
class StrBlob {
friend class StrBlobPtr;
friend class ConstStrBlobPtr;
public:
typedef std::vector<std::string>::size_type size_type;
StrBlob();
StrBlob(std::initializer_list<std::string> il);
// because until now the whole class is not defined, we cannot use initializer list here
StrBlob(const StrBlob &rhs) : data(std::make_shared<std::vector<std::string>>(*rhs.data)) {}
StrBlob& operator=(const StrBlob&);
size_type size() const { return data->size(); }
// add and remove elements
void push_back(const std::string &t) { data->push_back(t); }
void pop_back();
// elements access
std::string& front();
std::string& back();
// const versions of front and back required by exercise 12.2
const std::string& front() const;
const std::string& back() const;
// return reference count
const size_type use_count() const { return data.use_count(); }
StrBlobPtr begin();
StrBlobPtr end();
ConstStrBlobPtr begin() const;
ConstStrBlobPtr end() const;
// access elements
std::string& at(size_type) const;
private:
std::shared_ptr<std::vector<std::string>> data;
// throws msg if data[i] isn't valid
void check(size_type i, const std::string &msg) const;
};
// constructor
StrBlob::StrBlob() : data(std::make_shared<std::vector<std::string>>()) {}
StrBlob::StrBlob(std::initializer_list<std::string> il) :
data(std::make_shared<std::vector<std::string>>(il)) {};
void StrBlob::check(size_type i, const std::string &msg) const
{
if(i >= data->size())
throw std::out_of_range(msg);
}
// copy-assignment operator
StrBlob& StrBlob::operator=(const StrBlob &rhs)
{
// we can use make_shared directly to make data point to new object
data = std::make_shared<std::vector<std::string>>(*rhs.data);
return *this;
}
// add and remove elements
void StrBlob::pop_back()
{
check(0, "pop_back on empty StrBlob");
data->pop_back();
}
// elements access
std::string& StrBlob::front()
{
check(0, "front on empty StrBlob");
data->front();
}
std::string& StrBlob::back()
{
check(0, "back on empty StrBlob");
data->back();
}
const std::string& StrBlob::front() const
{
check(0, "front on empty StrBlob");
data->front();
}
const std::string& StrBlob::back() const
{
check(0, "back on empty StrBlob");
data->back();
}
std::string& StrBlob::at(size_type n) const
{
check(n, "index out of range");
return data->at(n);
}
// ******************************
// nonconst version of StrBlobPtr
// ******************************
class StrBlobPtr{
public:
StrBlobPtr() : curr(0) {}
StrBlobPtr(StrBlob &a, size_t sz = 0) : curr(sz) {}
std::string& deref() const;
StrBlobPtr& incr();
private:
std::shared_ptr<std::vector<std::string>> check(size_t, const std::string&) const;
std::weak_ptr<std::vector<std::string>> wptr;
size_t curr;
};
std::shared_ptr<std::vector<std::string>> StrBlobPtr::check(size_t i, const std::string& msg) const
{
auto ret = wptr.lock();
if(!ret)
throw std::runtime_error("unbound StrBlobPtr");
if(i >= ret->size())
throw std::out_of_range(msg);
return ret;
}
std::string& StrBlobPtr::deref() const
{
auto p = check(curr, "dereference past end");
return (*p)[curr];
}
StrBlobPtr& StrBlobPtr::incr()
{
check(curr, "increment past end of StrBlobPtr");
++curr;
return *this;
}
// ***************************
// const version of StrBlobPtr
// ***************************
class ConstStrBlobPtr{
public:
ConstStrBlobPtr() : curr(0) {}
ConstStrBlobPtr(const StrBlob &a, size_t sz = 0) : wptr(a.data),curr(sz) {}
std::string& deref() const;
ConstStrBlobPtr& incr();
private:
std::shared_ptr<std::vector<std::string>> check(size_t, const std::string&) const;
std::weak_ptr<std::vector<std::string>> wptr;
size_t curr;
};
std::shared_ptr<std::vector<std::string>> ConstStrBlobPtr::check(size_t i, const std::string& msg) const
{
auto ret = wptr.lock();
if(!ret)
throw std::runtime_error("unbound StrBlobPtr");
if(i >= ret->size())
throw std::out_of_range(msg);
return ret;
}
std::string& ConstStrBlobPtr::deref() const
{
auto p = check(curr, "dereference past end");
return (*p)[curr];
}
ConstStrBlobPtr& ConstStrBlobPtr::incr()
{
check(curr, "increment past end of StrBlobPtr");
++curr;
return *this;
}
// we have to define these member functions here, after the definition of StrBlobPtr
StrBlobPtr StrBlob::begin()
{
return StrBlobPtr(*this);
}
StrBlobPtr StrBlob::end()
{
auto ret = StrBlobPtr(*this, data->size());
return ret;
}
ConstStrBlobPtr StrBlob::begin() const
{
return ConstStrBlobPtr(*this);
}
ConstStrBlobPtr StrBlob::end() const
{
auto ret = ConstStrBlobPtr(*this, data->size());
return ret;
}
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_02_compare.h
|
<filename>chap16/Exer16_02_compare.h<gh_stars>10-100
#ifndef EXER16_02_COMPARE_H
#define EXER16_02_COMPARE_H
template <typename T>
int compare(const T &v1, const T &v2)
{
if(v1 < v2) return -1;
if(v2 < v1) return 1;
return 0;
}
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_41.h
|
<gh_stars>10-100
#ifndef EXER16_41_SUM_H
#define EXER16_41_SUM_H
// using trailing return type, the return type is guaranteed to hold the result of sum
template <typename T1, typename T2>
auto sum(T1 lhs, T2 rhs) -> decltype(lhs + rhs)
{
return lhs + rhs;
}
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_63_64_count.h
|
#ifndef EXER16_63_COUNT_H
#define EXER16_63_COUNT_H
#include <cstring>
#include <iostream>
#include <vector>
// use two template arguments for compatible but different types
template <typename T1, typename T2>
typename std::vector<T1>::size_type count(const std::vector<T1> &v, const T2 &t)
{
typename std::vector<T1>::size_type cnt = 0;
for(auto b = v.begin(); b != v.end(); ++b)
{
if(*b == t)
++cnt;
}
return cnt;
}
template <>
std::vector<const char*>::size_type count(std::vector<const char*> const& v, const char* const &t)
{
std::cout << "count(const std::vector<const char*> &v, const char* const &t)" << std::endl;
std::vector<const char*>::size_type cnt = 0;
for(auto b = v.begin(); b != v.end(); ++b)
{
if(!strcmp(*b, t))
++cnt;
}
return cnt;
}
#endif
|
sjbarigye/CPP_Primer
|
chap14/Exer14_27_StrBlob.h
|
#ifndef STRBLOB_H
#define STRBLOB_H
#include <cstddef>
#include <string>
#include <vector>
#include <initializer_list>
#include <memory>
#include <stdexcept>
using std::size_t;
using std::string;
using std::vector;
using std::initializer_list;
using std::shared_ptr;
using std::make_shared;
using std::weak_ptr;
using std::runtime_error;
using std::out_of_range;
class StrBlobPtr;
class ConstStrBlobPtr;
class StrBlob {
friend class StrBlobPtr;
friend class ConstStrBlobPtr;
// overloaded equality operators required by exercise 14.16
friend bool operator==(const StrBlob&, const StrBlob&);
friend bool operator!=(const StrBlob&, const StrBlob&);
// overloaded relational operator required by exercise 14.18
friend bool operator<(const StrBlob&, const StrBlob&);
friend bool operator<=(const StrBlob&, const StrBlob&);
friend bool operator>(const StrBlob&, const StrBlob&);
friend bool operator>=(const StrBlob&, const StrBlob&);
public:
typedef vector<string>::size_type size_type;
StrBlob();
StrBlob(initializer_list<string> il);
size_type size() const { return data->size(); }
// add and remove elements
void push_back(const string &t) { data->push_back(t); }
void pop_back();
// elements access
string& front();
string& back();
// const versions of front and back required by exercise 12.2
const string& front() const;
const string& back() const;
// return reference count
const size_type use_count() const { return data.use_count(); }
StrBlobPtr begin();
StrBlobPtr end();
ConstStrBlobPtr begin() const;
ConstStrBlobPtr end() const;
// access elements
string& at(size_type) const;
// subscript operator required by exercise 14.26
// the difference between at and subscript is that subscript doesn't throw
// exception if the index is out of range.
string& operator[](size_t n)
{ return (*data)[n]; }
const string& operator[](size_t n) const
{ return (*data)[n]; }
private:
shared_ptr<vector<string>> data;
// throws msg if data[i] isn't valid
void check(size_type i, const string &msg) const;
};
// constructor
StrBlob::StrBlob() : data(make_shared<vector<string>>()) {}
StrBlob::StrBlob(initializer_list<string> il) :
data(make_shared<vector<string>>(il)) {};
void StrBlob::check(size_type i, const string &msg) const
{
if(i >= data->size())
throw out_of_range(msg);
}
// add and remove elements
void StrBlob::pop_back()
{
check(0, "pop_back on empty StrBlob");
data->pop_back();
}
// elements access
string& StrBlob::front()
{
check(0, "front on empty StrBlob");
data->front();
}
string& StrBlob::back()
{
check(0, "back on empty StrBlob");
data->back();
}
const string& StrBlob::front() const
{
check(0, "front on empty StrBlob");
data->front();
}
const string& StrBlob::back() const
{
check(0, "back on empty StrBlob");
data->back();
}
string& StrBlob::at(size_type n) const
{
check(n, "index out of range");
return data->at(n);
}
// friend definition
bool operator==(const StrBlob &lhs, const StrBlob &rhs)
{
return *lhs.data == *rhs.data;
}
bool operator!=(const StrBlob &lhs, const StrBlob &rhs)
{
return !(lhs == rhs);
}
bool operator<(const StrBlob &lhs, const StrBlob &rhs)
{
return *lhs.data < *rhs.data;
}
bool operator<=(const StrBlob &lhs, const StrBlob &rhs)
{
return (lhs < rhs || lhs == rhs);
}
bool operator>(const StrBlob &lhs, const StrBlob &rhs)
{
return !(lhs < rhs || lhs == rhs);
}
bool operator>=(const StrBlob &lhs, const StrBlob &rhs)
{
return !(lhs < rhs);
}
// ******************************
// nonconst version of StrBlobPtr
// ******************************
class StrBlobPtr{
// overloaded equality operators required by exercise 14.16
friend bool operator==(const StrBlobPtr&, const StrBlobPtr&);
friend bool operator!=(const StrBlobPtr&, const StrBlobPtr&);
// overloaded relational operators required by exercise 14.18
friend bool operator<(const StrBlobPtr&, const StrBlobPtr&);
friend bool operator<=(const StrBlobPtr&, const StrBlobPtr&);
friend bool operator>(const StrBlobPtr&, const StrBlobPtr&);
friend bool operator>=(const StrBlobPtr&, const StrBlobPtr&);
public:
StrBlobPtr() : curr(0) {}
StrBlobPtr(StrBlob &a, size_t sz = 0) : wptr(a.data), curr(sz) {}
string& deref() const;
StrBlobPtr& incr();
// subscript operator required by exercise 14.26
string& operator[](size_t n);
const string& operator[](size_t n) const;
// increment and decrement operator required by exercise 14.27
StrBlobPtr& operator++(); // prefix increment, return reference
StrBlobPtr& operator--(); // prefix decrement
StrBlobPtr operator++(int); // postfix increment, return value
StrBlobPtr operator--(int); // postfix decrement
private:
shared_ptr<vector<string>> check(size_t, const string&) const;
weak_ptr<vector<string>> wptr;
size_t curr;
};
shared_ptr<vector<string>> StrBlobPtr::check(size_t i, const string& msg) const
{
auto ret = wptr.lock();
if(!ret)
throw runtime_error("unbound StrBlobPtr");
if(i >= ret->size())
throw out_of_range(msg);
return ret;
}
string& StrBlobPtr::deref() const
{
auto p = check(curr, "dereference past end");
return (*p)[curr];
}
StrBlobPtr& StrBlobPtr::incr()
{
check(curr, "increment past end of StrBlobPtr");
++curr;
return *this;
}
// It should be curr + n, because this points to the position of index curr,
// if we dereference an element by index, we should get the element at the
// position of curr + n.
string& StrBlobPtr::operator[](size_t n)
{
auto p = check(curr + n, "deference past end");
return (*p)[curr + n];
}
const string& StrBlobPtr::operator[](size_t n) const
{
auto p = check(curr + n, "deference past end");
return (*p)[curr + n];
}
StrBlobPtr& StrBlobPtr::operator++()
{
check(curr, "increment past end of StrBlobStr");
++curr; // advance the current state
return *this;
}
StrBlobPtr& StrBlobPtr::operator--()
{
--curr; // move the current state back one element
check(curr, "decrement past begin of StrBlobPtr");
return *this;
}
StrBlobPtr StrBlobPtr::operator++(int)
{
auto ret = *this; // save the current value
++*this; // advance one element; prefix ++ checks the increment
return ret; // return the saved value
}
StrBlobPtr StrBlobPtr::operator--(int)
{
auto ret = *this; // save the current value
--*this; // move backward one element; prefix -- checks the decrement
return ret; // return the saved value
}
// definitions of friend operators
// shared_ptr has its overloaded version of equality and relational operators, but weak_ptr doesn't
// so we have to use lock() to compare
bool operator==(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return lhs.curr == rhs.curr;
}
bool operator!=(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return !(lhs == rhs);
}
bool operator<(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return lhs.curr < rhs.curr;
}
bool operator<=(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return (lhs < rhs || lhs == rhs);
}
bool operator>(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return !(lhs < rhs || lhs == rhs);
}
bool operator>=(const StrBlobPtr &lhs, const StrBlobPtr &rhs)
{
return !(lhs < rhs);
}
// ***************************
// const version of StrBlobPtr
// ***************************
class ConstStrBlobPtr{
// overloaded equality operators required by exercise 14.16
friend bool operator==(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
friend bool operator!=(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
// overloaded relational operators required by exercise 14.18
friend bool operator<(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
friend bool operator<=(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
friend bool operator>(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
friend bool operator>=(const ConstStrBlobPtr&, const ConstStrBlobPtr&);
public:
ConstStrBlobPtr() : curr(0) {}
ConstStrBlobPtr(const StrBlob &a, size_t sz = 0) : wptr(a.data),curr(sz) {}
string& deref() const;
ConstStrBlobPtr& incr();
// subscript operator required by exercise 14.26
// ConstStrBlobPtr should only have const version of subscript operator
string& operator[](size_t n) const;
private:
shared_ptr<vector<string>> check(size_t, const string&) const;
const weak_ptr<vector<string>> wptr;
size_t curr;
};
shared_ptr<vector<string>> ConstStrBlobPtr::check(size_t i, const string& msg) const
{
auto ret = wptr.lock();
if(!ret)
throw runtime_error("unbound StrBlobPtr");
if(i >= ret->size())
throw out_of_range(msg);
return ret;
}
string& ConstStrBlobPtr::deref() const
{
auto p = check(curr, "dereference past end");
return (*p)[curr];
}
ConstStrBlobPtr& ConstStrBlobPtr::incr()
{
check(curr, "increment past end of StrBlobPtr");
++curr;
return *this;
}
string& ConstStrBlobPtr::operator[](size_t n) const
{
auto p = check(curr + n, "deference past end");
return (*p)[curr + n];
}
// definitions of friend operators
bool operator==(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return lhs.wptr.lock() == rhs.wptr.lock() && lhs.curr == rhs.curr;
}
bool operator!=(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return !(lhs == rhs);
}
bool operator<(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return lhs.curr < rhs.curr;
}
bool operator<=(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return lhs.curr <= rhs.curr;
}
bool operator>(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return lhs.curr > rhs.curr;
}
bool operator>=(const ConstStrBlobPtr &lhs, const ConstStrBlobPtr &rhs)
{
return lhs.curr >= rhs.curr;
}
// we have to define these member functions here, after the definition of StrBlobPtr
StrBlobPtr StrBlob::begin()
{
return StrBlobPtr(*this);
}
StrBlobPtr StrBlob::end()
{
auto ret = StrBlobPtr(*this, data->size());
return ret;
}
ConstStrBlobPtr StrBlob::begin() const
{
return ConstStrBlobPtr(*this);
}
ConstStrBlobPtr StrBlob::end() const
{
auto ret = ConstStrBlobPtr(*this, data->size());
return ret;
}
#endif
// Note: If two pointers point to two unrelated objects, the result of comparison
// is undefined(See page 120). Here we assume that lhs and rhs point to the same
// object, thus StrBlobPtr has consistent behaviour with built-in pointer. On the
// other hand, we can compare two pointers with == regardless whether they point
// to the same object. Thus it seems that equality and relational operators are
// not consistent with each other.
|
sjbarigye/CPP_Primer
|
chap16/Exer16_61_shared_ptr.h
|
<filename>chap16/Exer16_61_shared_ptr.h
#ifndef EXER16_61_SP_H
#define EXER16_61_SP_H
#include <cstddef>
#include <iostream>
#include <utility>
#include <functional>
#include <utility>
#include <stdexcept>
#include "Exer16_28_unique_ptr.h"
template <typename T> class shared_ptr;
template <typename T>
void swap(shared_ptr<T>&, shared_ptr<T>&);
template <typename T>
class shared_ptr {
friend void swap<T>(shared_ptr&, shared_ptr&);
public:
typedef typename std::function<void(T*)> Deleter;
// constructors
shared_ptr() : p(nullptr), ref(new std::size_t(0)), del(nullptr) {}
// forbid implicit conversion
explicit shared_ptr(T *q) : p(q), ref(new std::size_t(1)), del(nullptr) {}
shared_ptr(T *q, Deleter d) : p(q), ref(new std::size_t(1)), del(d) {}
shared_ptr(const shared_ptr &sp, Deleter d) : p(sp.p), ref(sp.ref), del(d) { ++*ref; }
shared_ptr(unique_ptr<T>&);
// copy control operations
shared_ptr(const shared_ptr &sp) : p(sp.p), ref(sp.ref), del(sp.del) { ++*ref; }
shared_ptr(shared_ptr &&sp) noexcept : p(std::move(sp.p)), ref(std::move(sp.ref)), del(std::move(sp.del)) { sp.p = nullptr; }
shared_ptr& operator=(const shared_ptr&);
shared_ptr& operator=(shared_ptr&&) noexcept;
~shared_ptr();
// overloaded operators
T& operator*() const;
T* operator->() const;
explicit operator bool() const { return p; }
// other operations
std::size_t use_count() const { return *ref; };
bool unique() const { return (*ref == 1);}
T* get() const { return p; }
void swap(shared_ptr&);
void reset();
void reset(T* tq);
void reset(T*, const Deleter&);
private:
void free() const;
T* p; // pointer
std::size_t *ref; // reference count
Deleter del; // pointer that points to a callable object
};
template <typename T>
inline void shared_ptr<T>::free() const
{
if(*ref == 0 || --*ref == 0) {
del ? del(p) : delete p;
delete ref;
}
}
// copy-control members
template <typename T>
shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr &rhs)
{
++*rhs.ref;
free();
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
return *this;
}
template <typename T>
shared_ptr<T>& shared_ptr<T>::operator=(shared_ptr &&rhs) noexcept
{
if(this != &rhs) {
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
rhs.p = nullptr;
}
return *this;
}
template <typename T>
shared_ptr<T>::~shared_ptr()
{
free();
}
// overloaded operators
template <typename T>
inline T& shared_ptr<T>::operator*() const
{
if(!p)
throw std::runtime_error("deference null pointer");
return *p;
}
template <typename T>
inline T* shared_ptr<T>::operator->() const
{
return &this->operator*();
}
// swap
template <typename T>
inline void swap(shared_ptr<T> &lhs, shared_ptr<T> &rhs)
{
lhs.swap(rhs);
}
template <typename T>
inline void shared_ptr<T>::swap(shared_ptr &rhs)
{
using std::swap;
swap(this->p, rhs.p);
swap(this->ref, rhs.ref);
swap(this->del, rhs.del);
}
template <typename T>
void shared_ptr<T>::reset()
{
free();
p = nullptr;
ref = new std::size_t(0); // reset reference count
}
template <typename T>
void shared_ptr<T>::reset(T* tp)
{
free();
p = tp;
ref = new std::size_t(1); // reset reference count
}
template <typename T>
void shared_ptr<T>::reset(T* tp, const Deleter &d)
{
free();
p = tp;
ref = new std::size_t(1); // reset reference count
del = d;
}
// use variadic function template and forward to substitute const T&, see section 16.4, page 699
// compare this with Exer16_28_shared_ptr.h.
template <typename T, typename... Args>
inline shared_ptr<T> make_shared(Args&&... args)
{
// use forward to preserve constness and lvalue/rvalue property
return shared_ptr<T>(new T(std::forward<Args>(args)...));
}
#endif
// Note: in fact we could use allocator to substitute new/delete.
|
sjbarigye/CPP_Primer
|
tools/InsertAnswer.h
|
#ifndef TOOL_INSERT_ANSWER_H
#define TOOL_INSERT_ANSWER_H
#ifndef UNICODE
#define UNICODE
#endif
#ifndef _UNICODE
#define _UNICODE
#endif
#include <windows.h>
#include <cstddef>
#include <string>
#include <vector>
#include <map>
#pragma comment(lib, "User32.lib")
#ifndef UNICODE
typedef std::string String;
#else
typedef std::wstring String;
#endif
typedef std::map<std::size_t, std::vector<String>> ExerSet;
void DisplayErrorBox(LPTSTR lpszFunction);
bool iscpp(const String&);
int get_source(const TCHAR *path, ExerSet&);
std::vector<std::size_t> analyse_filename(const String&);
String format(const std::vector<String> &);
#endif
|
sjbarigye/CPP_Primer
|
chap13/Exer13_22_HasPtr.h
|
#ifndef HASPTR_H
#define HASPTR_H
#include <iostream>
#include <string>
class HasPtr{
public:
HasPtr(const std::string &s = std::string()) : ps(new std::string(s)), i(0) { i = ps->size(); }
// here, we can use private members directly! Because this is a member
// function of class HasPtr. They can access any member of the class. Review
// member functions, access control and class scope for more details.
HasPtr(const HasPtr& hp) : ps(new std::string(*(hp.ps))), i(hp.i) { }
// . has higher precedence, so the parenthesize could be ignored here
// copy-assignment operator required by exercise 13.8
HasPtr& operator=(const HasPtr&);
// destructor required by exercise 13.11
~HasPtr() { delete ps; }
private:
std::string *ps;
int i;
};
HasPtr& HasPtr::operator=(const HasPtr& hp)
{
// WARNING: ensure self assignment gets the correct result!!!
// Remember to free resources before deleting!!!
// WRONG way to write an assignment operator!
ps = new std::string(*hp.ps);
i = hp.i;
return *this; // return this object
}
#endif
// value-like copy and assign required by exercise 13.22
// Note: both copy and copy-assign member allocate new memory, so they make the
// class behave like a value.
|
sjbarigye/CPP_Primer
|
chap19/Exer19_26.h
|
<filename>chap19/Exer19_26.h
#ifndef EXER19_26_LINKAGE_H
#define EXER19_26_LINKAGE_H
int compute(int*, int);
#endif
|
sjbarigye/CPP_Primer
|
chap16/Exer16_28_shared_ptr.h
|
#ifndef EXER16_28_SP_H
#define EXER16_28_SP_H
#include <cstddef>
#include <iostream>
#include <utility>
#include <functional>
#include <stdexcept>
#include "Exer16_28_unique_ptr.h"
template <typename T> class shared_ptr;
template <typename T>
void swap(shared_ptr<T>&, shared_ptr<T>&);
template <typename T>
class shared_ptr {
friend void swap<T>(shared_ptr&, shared_ptr&);
public:
typedef typename std::function<void(T*)> Deleter;
// constructors
shared_ptr() : p(nullptr), ref(new std::size_t(0)), del(nullptr) {}
// forbid implicit conversion
template <typename U>
explicit shared_ptr(U *q) : p(q), ref(new std::size_t(1)), del(nullptr) {}
template <typename U>
shared_ptr(U *q, Deleter d) : p(q), ref(new std::size_t(1)), del(d) {}
template <typename U>
shared_ptr(const shared_ptr<U> &sp, Deleter d) : p(sp.p), ref(sp.ref), del(d) { ++*ref; }
template <typename U>
explicit shared_ptr(unique_ptr<U>&);
// copy control operations
// Warning: normal copy control members must be declared, or the compiler
// would synthesize a wrong version of them
shared_ptr(const shared_ptr &sp) : p(sp.p), ref(sp.ref), del(sp.del) { ++*ref; }
shared_ptr(shared_ptr &&sp) noexcept : p(std::move(sp.p)), ref(std::move(sp.ref)), del(std::move(sp.del)) { sp.p = nullptr; }
shared_ptr& operator=(const shared_ptr&);
shared_ptr& operator=(shared_ptr&&) noexcept;
// generic copy control members, thus supporting derived-to-base conversion,
// see Page630.
// reference: effective C++, 3rd edition, item 45
template <typename U>
shared_ptr(const shared_ptr<U> &sp) : p(sp.p), ref(sp.ref), del(sp.del) { ++*ref; }
template <typename U>
shared_ptr(shared_ptr<U> &&sp) noexcept : p(std::move(sp.p)), ref(std::move(sp.ref)), del(std::move(sp.del)) { sp.p = nullptr; }
template <typename U>
shared_ptr& operator=(const shared_ptr<U>&);
template <typename U>
shared_ptr& operator=(shared_ptr<U>&&) noexcept;
~shared_ptr();
// overloaded operators
T& operator*() const;
T* operator->() const;
explicit operator bool() const { return p; }
// other operations
std::size_t use_count() const { return *ref; };
bool unique() const { return (*ref == 1);}
T* get() const { return p; }
void swap(shared_ptr&);
void reset();
void reset(T* tq);
void reset(T*, const Deleter&);
private:
void free() const;
T* p; // pointer
std::size_t *ref; // reference count
Deleter del; // pointer that points to a callable object
};
template <typename T>
inline void shared_ptr<T>::free() const
{
if(*ref == 0 || --*ref == 0) {
del ? del(p) : delete p;
delete ref;
}
}
// copy-control members
// copy assignment
template <typename T>
shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr &rhs)
{
++*rhs.ref;
free();
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
return *this;
}
template <typename T>
template <typename U>
shared_ptr<T>& shared_ptr<T>::operator=(const shared_ptr<U> &rhs)
{
++*rhs.ref;
free();
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
return *this;
}
// move assignment
template <typename T>
shared_ptr<T>& shared_ptr<T>::operator=(shared_ptr &&rhs) noexcept
{
if(this != &rhs) {
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
rhs.p = nullptr;
}
return *this;
}
template <typename T>
template <typename U>
shared_ptr<T>& shared_ptr<T>::operator=(shared_ptr<U> &&rhs) noexcept
{
if(this != &rhs) {
p = rhs.p;
ref = rhs.ref;
del = rhs.del;
rhs.p = nullptr;
}
return *this;
}
template <typename T>
shared_ptr<T>::~shared_ptr()
{
free();
}
// overloaded operators
template <typename T>
inline T& shared_ptr<T>::operator*() const
{
if(!p)
throw std::runtime_error("deference null pointer");
return *p;
}
template <typename T>
inline T* shared_ptr<T>::operator->() const
{
return &this->operator*();
}
// swap
template <typename T>
inline void swap(shared_ptr<T> &lhs, shared_ptr<T> &rhs)
{
lhs.swap(rhs);
}
template <typename T>
inline void shared_ptr<T>::swap(shared_ptr &rhs)
{
using std::swap;
swap(this->p, rhs.p);
swap(this->ref, rhs.ref);
swap(this->del, rhs.del);
}
template <typename T>
void shared_ptr<T>::reset()
{
free();
p = nullptr;
ref = new std::size_t(0); // reset reference count
}
template <typename T>
void shared_ptr<T>::reset(T* tp)
{
free();
p = tp;
ref = new std::size_t(1); // reset reference count
}
template <typename T>
void shared_ptr<T>::reset(T* tp, const Deleter &d)
{
free();
p = tp;
ref = new std::size_t(1); // reset reference count
del = d;
}
// compare this with Exer16_61_shared_ptr.h
template <typename T>
inline shared_ptr<T> make_shared(const T &t)
{
return shared_ptr<T>(new T(t));
}
#endif
// Note #1: boundary case is when a shared_ptr doesn't point to any object. We must
// guarantee the resource is properly freed. If a shared_ptr points to null, then
// p = nullptr, but ref doesn't, and *ref = 0; when free is called, *ref is decremented
// and thus its value is the maximum of size_t. In free, we use
// *ref == 0 || --*ref == 0
// as condition. Because || guarantees the order of evaluation, when *ref == 0,
// --*ref won't be evaluated, and resources of both ref and p will be freed.
// Note #2: another thing to note: although the type of deleter is function<void(T*)>,
// we can initialize or assign deleter with a callable object whose return type
// is not void.
// Note #3: this version doesn't consider about dynamic array, because library
// version of shared_ptr provides no direct support for managing dynamic array.
// If we want to use shared_ptr to manage a dynamic array, we must provide our
// own deleter(section 12.2.1, page 480).
|
sjbarigye/CPP_Primer
|
chap14/String.h
|
<reponame>sjbarigye/CPP_Primer
// Inheritance: exercise 13.55.
// Note: see Exer19_18.cpp for the explanation of the problem issued in note.
#ifndef STRING_SIMPLE_H
#define STRING_SIMPLE_H
#include <iostream>
#include <cstddef>
#include <cstring>
#include <utility>
#include <memory>
#include <algorithm>
using std::ostream;
using std::size_t;
using std::pair;
using std::allocator;
class String {
// overloaded output operator required by exercise 14.7
friend ostream &operator<<(ostream&, const String&);
// overloaded equality operator required by exercise 14.16
friend bool operator==(const String&, const String&);
friend bool operator!=(const String&, const String&);
// overloaded relational operator required by exercise 14.18
friend bool operator<(const String&, const String&);
friend bool operator<=(const String&, const String&);
friend bool operator>(const String&, const String&);
friend bool operator>=(const String&, const String&);
public:
String();
String(const char*);
String(const String&);
String(String&&) noexcept; // move constructor
String& operator=(const String&);
String& operator=(String&&) noexcept; // move assignment
// subscript operator(const and nonconst version) required by exercise 14.26
char& operator[](size_t n)
{ return elements[n]; }
const char& operator[](size_t n) const
{ return elements[n]; }
~String();
void push_back(const char&);
void push_back(char&&);
size_t size() const { return first_free - elements;}
size_t capacity() const { return cap - elements; }
char* begin() const { return elements; }
char* end() const { return first_free; }
bool empty() const { return elements == first_free; }
void clear();
private:
void chk_n_alloc() { if(size() == capacity()) reallocate(); }
pair<char*, char*> alloc_n_copy(const char*, const char*);
void free();
void reallocate();
private:
static allocator<char> alloc;
static size_t ini_size;
char *elements;
char *first_free;
char *cap;
};
allocator<char> String::alloc;
// It seems both gcc and visual studio library allocates 15 space for a default
// initialized string.
size_t String::ini_size = 15;
// friend definition
ostream& operator<<(ostream &os, const String &s)
{
if(s.elements != s.first_free)
{
for(auto p = s.begin(); p != s.end(); ++p)
os << *p;
}
return os;
}
bool operator==(const String &lhs, const String &rhs)
{
if(lhs.size() != rhs.size())
return false;
else {
for(auto p = lhs.begin(), q = rhs.begin(); p != lhs.end(); ++p, ++q)
if(*p != *q)
return false;
return true;
}
}
bool operator!=(const String &lhs, const String &rhs)
{
return !(lhs == rhs);
}
bool operator<(const String &lhs, const String &rhs)
{
auto shorter = lhs.size() < rhs.size() ? lhs.size() : rhs.size();
auto p = lhs.begin(), q = rhs.begin();
for(size_t i = 0; p + i != lhs.end(); ++i)
{
if(*(p + i) == *(q + i))
continue;
else if(*(p + i) < *(q + i))
return true;
else
return false;
}
return lhs.size() < rhs.size();
}
bool operator<=(const String &lhs, const String &rhs)
{
return (lhs < rhs || lhs == rhs);
}
bool operator>(const String &lhs, const String &rhs)
{
return !(lhs < rhs || lhs == rhs);
}
bool operator>=(const String &lhs, const String &rhs)
{
return !(lhs < rhs);
}
String::String(): elements(nullptr), first_free(nullptr), cap(nullptr)
{
elements = alloc.allocate(ini_size);
first_free = elements;
cap = elements + ini_size;
}
String::String(const char *s)
{
auto newdata = alloc_n_copy(s, s + strlen(s));
elements = newdata.first;
first_free = newdata.second;
cap = (strlen(s) > ini_size) ? first_free : (elements + ini_size);
}
String::String(const String &s)
{
auto newdata = alloc_n_copy(s.begin(), s.end());
elements = newdata.first;
first_free = newdata.second;
cap = (s.size() > ini_size) ? first_free : (elements + ini_size);
// call identity required by exercise 13.47
std::cout << "String(const String&) is called" << std::endl;
}
// copy constructor required by exercise 13.49
String::String(String &&s) noexcept : elements(s.elements), first_free(s.first_free), cap(s.cap)
{
s.elements = s.first_free = s.cap = nullptr;
std::cout << "String(String&&) is called" << std::endl;
}
String& String::operator=(const String& rhs)
{
auto newdata = alloc_n_copy(rhs.begin(), rhs.end());
free();
elements = newdata.first;
first_free = newdata.second;
cap = (rhs.size() > ini_size) ? first_free : (elements + ini_size);
// call identity required by exercise 13.47
std::cout << "String& operator=(const String&) is called" << std::endl;
return *this;
}
// move assigment required by exercise 13.49
String& String::operator=(String &&rhs) noexcept
{
if(this != &rhs)
{
free();
elements = rhs.elements;
first_free = rhs.first_free;
cap = rhs.cap;
rhs.elements = rhs.first_free = rhs.cap = nullptr;
}
std::cout << "String& operator=(String&&) is called" << std::endl;
return *this;
}
String::~String()
{
free();
}
void String::push_back(const char &c)
{
chk_n_alloc();
alloc.construct(first_free++, c);
}
void String::push_back(char &&c)
{
chk_n_alloc();
alloc.construct(first_free++, std::move(c));
}
void String::clear()
{
for(auto p = first_free; p != elements; /* empty */)
alloc.destroy(--p);
first_free = elements;
}
pair<char*, char*> String::alloc_n_copy(const char *b, const char *e)
{
auto newcapacity = (e - b > ini_size) ? (e - b) : ini_size;
auto newdata = alloc.allocate(newcapacity);
return {newdata, std::uninitialized_copy(b, e, newdata)};
}
void String::reallocate()
{
auto newcapacity = (size() * 2 > ini_size) ? size() * 2 : ini_size;
auto newdata = alloc.allocate(newcapacity);
auto dest = newdata;
auto elem = elements;
for(size_t i = 0; i != size(); ++i)
alloc.construct(dest++, std::move(*elem++));
free();
elements = newdata;
first_free = dest;
cap = elements + newcapacity;
}
void String::free()
{
// std::for_each(elements, first_free, [](const char &c) {alloc.destroy(&c);});
for(auto p = first_free; p != elements; /* empty */)
alloc.destroy(--p);
alloc.deallocate(elements, cap - elements);
}
#endif
// Note #1: don't know why, but uninitialized_copy and for_each don't work if std::
// isn't prefixed. This remains to be solved.
// ADDITION: see Exer19_18.cpp for explanation, or see section 18.2.3, page 798
// for the reason.
// Note #2: here we can see the advantage of allocator compared to new/delete. If
// we use new/delete, we might have to use char array instead of raw and uninitialized
// memory.
|
sjbarigye/CPP_Primer
|
chap16/Exer16_28_unique_ptr.h
|
#ifndef EXER16_28_UP_H
#define EXER16_28_UP_H
#include <cstddef>
#include <utility>
#include <functional>
#include <stdexcept>
class DefaultDeleter {
public:
// as with any function template, the type of T is deduced by the compiler
template <typename T>
void operator()(T *p) const
{ delete p; }
};
// delete dynamic array
class DefaultDeleterArray {
public:
// as with any function template, the type of T is deduced by the compiler
template <typename T>
void operator()(T *p) const
{ delete []p; }
};
template <typename T, typename D = DefaultDeleter> class unique_ptr;
template <typename T>
void swap(unique_ptr<T>&, unique_ptr<T>&);
template <typename T, typename D>
class unique_ptr {
friend void swap<T>(unique_ptr<T>&, unique_ptr<T>&);
public:
// constructor
unique_ptr() : p(nullptr), del(D()) {}
// forbid implicit conversion
template <typename U>
explicit unique_ptr(U *t) : p(t), del(D()) {}
unique_ptr(const D &d) : p(nullptr), del(d) {}
// copy-control operations(copy version is deleted)
unique_ptr(const unique_ptr&) = delete;
unique_ptr(unique_ptr &&up) noexcept : p(std::move(up.p)), del(std::move(up.del)) {}
unique_ptr& operator=(const unique_ptr&) = delete;
unique_ptr& operator=(unique_ptr&&) noexcept;
// generic copy control members, see effective C++, 3rd edition, item 45
template <typename U, typename DU>
unique_ptr(unique_ptr<U, DU> &&up) noexcept : p(std::move(up.p)), del(std::move(up.del)) {}
template <typename U, typename DU>
unique_ptr& operator=(unique_ptr<U, DU> &&up) noexcept;
// std::nullptr_t is not covered in textbook, see http://en.cppreference.com/w/cpp/types/nullptr_t
unique_ptr& operator=(std::nullptr_t);
~unique_ptr();
// overloaded operators
T& operator*() const;
T* operator->() const;
explicit operator bool() const { return p; }
// other operations
T* get() const { return p; }
void swap(unique_ptr&);
T* release();
void reset();
void reset(T*);
void reset(std::nullptr_t);
private:
void free() const;
T *p;
D del;
};
template <typename T, typename D>
inline void unique_ptr<T, D>::free() const
{
if(p) {
del(p);
}
}
// move assignment
template <typename T, typename D>
unique_ptr<T, D>& unique_ptr<T, D>::operator=(unique_ptr &&rhs) noexcept
{
p = rhs.p;
del = rhs.del;
rhs.p = nullptr;
return *this;
}
template <typename T, typename D>
template <typename U, typename DU>
unique_ptr<T, D>& unique_ptr<T, D>::operator=(unique_ptr<U, DU> &&rhs) noexcept
{
p = rhs.p;
del = rhs.del;
rhs.p = nullptr;
return *this;
}
template <typename T, typename D>
unique_ptr<T, D>& unique_ptr<T, D>::operator=(std::nullptr_t)
{
free();
p = nullptr;
return *this;
}
template <typename T, typename D>
unique_ptr<T, D>::~unique_ptr()
{
free();
p = nullptr;
}
// overloaded operators
template <typename T, typename D>
inline T& unique_ptr<T, D>::operator*() const
{
if(!p)
throw std::runtime_error("dereference null pointer");
return *p;
}
template <typename T, typename D>
inline T* unique_ptr<T, D>::operator->() const
{
return &this->operator*();
}
// other operations
template <typename T>
void swap(unique_ptr<T> &lhs, unique_ptr<T> &rhs)
{
lhs.swap(rhs);
}
// non-member version calls member version, if we use member version call
// non-member version, we have to use ::swap for a hidden name
template <typename T, typename D>
inline void unique_ptr<T, D>::swap(unique_ptr &rhs)
{
using std::swap;
swap(this->p, rhs.p);
swap(this->del, rhs.del);
}
template <typename T, typename D>
T* unique_ptr<T, D>::release()
{
auto ret = p;
p = nullptr;
return ret;
}
template <typename T, typename D>
void unique_ptr<T, D>::reset()
{
free();
p = nullptr;
}
template <typename T, typename D>
void unique_ptr<T, D>::reset(T *t)
{
free();
p = t;
}
template <typename T, typename D>
void unique_ptr<T, D>::reset(std::nullptr_t)
{
free();
p = nullptr;
}
// dynamic array version
template <typename T, typename D> class unique_ptr<T[], D>;
template <typename T>
void swap(unique_ptr<T[]>&, unique_ptr<T[]>&);
template <typename T, typename D = DefaultDeleterArray>
class unique_ptr<T[], D> {
friend void swap<T>(unique_ptr<T>&, unique_ptr<T>&);
public:
// constructor
unique_ptr() : p(nullptr), del(D()) {}
// forbid implicit conversion
explicit unique_ptr(T *t) : p(t), del(D()) {}
unique_ptr(const D &d) : p(nullptr), del(d) {}
// copy-control operations(copy version is deleted)
unique_ptr(const unique_ptr&) = delete;
unique_ptr(unique_ptr &&up) noexcept : p(std::move(up.p)), del(std::move(del)) {}
unique_ptr& operator=(const unique_ptr&) = delete;
unique_ptr& operator=(unique_ptr&&) noexcept;
// std::nullptr_t is not covered in textbook, see http://en.cppreference.com/w/cpp/types/nullptr_t
unique_ptr& operator=(std::nullptr_t);
~unique_ptr();
// overloaded operators
T& operator[](std::size_t n) const { return p[n]; }
explicit operator bool() const { return p; }
// other operations
T* get() const { return p; }
void swap(unique_ptr&);
void release();
void reset();
void reset(T*);
void reset(std::nullptr_t);
private:
void free() const;
T *p;
D del;
};
template <typename T, typename D>
inline void unique_ptr<T[], D>::free() const
{
if(p) {
del(p);
}
}
// constructor
template <typename T, typename D>
unique_ptr<T[], D>& unique_ptr<T[], D>::operator=(unique_ptr &&rhs) noexcept
{
p = rhs.p;
del = rhs.del;
rhs.p = nullptr;
}
template <typename T, typename D>
unique_ptr<T[], D>& unique_ptr<T[], D>::operator=(std::nullptr_t)
{
free();
p = nullptr;
return *this;
}
template <typename T, typename D>
unique_ptr<T[], D>::~unique_ptr()
{
free();
}
// other operations
template <typename T>
void swap(unique_ptr<T[]> &lhs, unique_ptr<T> &rhs)
{
lhs.swap(rhs);
}
// non-member version calls member version, if we use member version call
// non-member version, we have to use ::swap for a hidden name
template <typename T, typename D>
inline void unique_ptr<T[], D>::swap(unique_ptr &rhs)
{
using std::swap;
swap(this->p, rhs.p);
swap(this->del, rhs.del);
}
template <typename T, typename D>
void unique_ptr<T[], D>::release()
{
free();
p = nullptr;
}
template <typename T, typename D>
void unique_ptr<T[], D>::reset()
{
free();
p = nullptr;
}
template <typename T, typename D>
void unique_ptr<T[], D>::reset(T *t)
{
free();
p = t;
}
template <typename T, typename D>
void unique_ptr<T[], D>::reset(std::nullptr_t)
{
free();
p = nullptr;
}
#endif
// Note: because release and reset might change the value of one object, they can't
// be applied to const unique_ptr. Because all of this functions call a private
// function free() to free resource, we can not write p = nullptr in free.
|
sjbarigye/CPP_Primer
|
chap16/Exer16_20_print_iter.h
|
<gh_stars>10-100
#ifndef EXER16_20_PRINT_ITER_H
#define EXER16_20_PRINT_ITER_H
#include <iostream>
template <typename C>
void print(const C &c)
{
for(auto iter = c.begin(); iter != c.end(); ++iter)
std::cout << *iter << " ";
}
#endif
|
sjbarigye/CPP_Primer
|
chap12/Exer12_27_TextQuery.h
|
// Warning: this header has inherent error. See notes in Exer12_27.cpp.
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <memory>
class QueryResult;
std::ostream& print(std::ostream&, const QueryResult&);
class TextQuery{
friend class QueryResult;
friend std::ostream& print(std::ostream&, const QueryResult&);
public:
using line_num = std::vector<std::string>::size_type;
explicit TextQuery(std::ifstream &infile);
QueryResult query(const std::string&);
private:
std::vector<std::string> text;
std::map<std::string, std::set<line_num>> word_line;
};
class QueryResult{
friend std::ostream& print(std::ostream&, const QueryResult&);
public:
QueryResult(const std::string& s, TextQuery::line_num cnt, TextQuery *text) : query_word(s), occurences(cnt), query_result(text) {}
private:
const std::string query_word;
TextQuery::line_num occurences = 0;
// This is wrong.
std::shared_ptr<TextQuery> query_result;
};
TextQuery::TextQuery(std::ifstream &infile)
{
std::string line, word;
line_num curr_line = 0;
while(getline(infile, line))
{
std::istringstream word_breakup(line);
text.push_back(line);
while(word_breakup >> word)
{
(word_line[word]).insert(curr_line);
}
++curr_line;
}
}
QueryResult TextQuery::query(const std::string& str)
{
line_num cnt = 0;
auto find_rst = word_line.find(str);
if(find_rst != word_line.end())
{
for(auto iter = find_rst->second.cbegin(); iter != find_rst->second.cend(); ++iter)
{
std::string output_line = text[*iter];
std::istringstream is(output_line);
std::vector<std::string> line_breakup;
std::string out_word;
while(is >> out_word)
line_breakup.push_back(out_word);
cnt += count(line_breakup.cbegin(), line_breakup.cend(), str);
}
}
return QueryResult(str, cnt, this);
}
std::ostream& print(std::ostream& os, const QueryResult& q_rst)
{
os << "element occurs " << q_rst.occurences << " times" << std::endl;
if(q_rst.query_result.use_count() > 0)
{
std::shared_ptr<TextQuery> query_ptr = q_rst.query_result;
auto iter = (query_ptr->word_line).find(q_rst.query_word);
for(auto it = iter->second.cbegin(); it != iter->second.cend(); ++it)
os << "(line " << *it << ") " << ((query_ptr->text)[*it]) << std::endl;
}
return os;
}
|
sjbarigye/CPP_Primer
|
chap16/Exer16_06_begin_end.h
|
<filename>chap16/Exer16_06_begin_end.h
#ifndef EXER16_06_H
#define EXER16_06_H
template <typename T, unsigned N>
inline T* begin(T (&arr)[N]) // the parameter cannot be const, or we cannot make T* bound to arr
{
return arr;
}
template <typename T, unsigned N>
inline T* end(T (&arr)[N]) // the parameter cannot be const, or we cannot make T* bound to arr
{
return arr + N;
}
#endif
|
sjbarigye/CPP_Primer
|
chap15/Exer15_11_Bulk_quote.h
|
#ifndef BULK_QUOTE_H
#define BULK_QUOTE_H
#include <cstddef>
#include <string>
#include "Exer15_11_Quote.h"
class Bulk_quote : public Quote { // Bulk_quote inherits from Quote
public:
Bulk_quote() = default;
Bulk_quote(const std::string&, double, std::size_t, double);
// overrides the base version in order to implement the bulk purchase discount policy
double net_price(std::size_t) const override;
void debug() const override;
private:
std::size_t min_qty = 0; // minimum purchase for the discount to apply
double discount = 0.0; // fraction discount to apply
};
inline Bulk_quote::Bulk_quote(const std::string &book, double p, std::size_t qty, double disc) :
Quote(book, p), min_qty(qty), discount(disc) {}
// if the specified number of items are purchased, use the discounted price
double Bulk_quote::net_price(std::size_t cnt) const
{
if (cnt >= min_qty)
return cnt * (1 - discount) * price;
else
return cnt * price;
}
inline void Bulk_quote::debug() const
{
std::cout << "std::string bookNo\n"
<< "double price\n"
<< "std::size_t min_qty\n"
<< "double discount\n"
<< std::endl;
}
#endif
|
sjbarigye/CPP_Primer
|
chap19/Exer19_06_07_08_Query.h
|
// Query class family from exercise 15.41 and 15.42.
// abstract class acts as a base for concrete query types; all members are private
#ifndef QUERY_BASE_H
#define QUERY_BASE_H
#include <cstddef>
#include <string>
#include <utility>
#include "Exer19_06_07_08_TextQuery.h"
class Query_base {
friend void cast_test();
friend class Query;
protected:
using line_no = TextQuery::line_no; // used in eval functions
virtual ~Query_base() = default;
private:
// eval returns the QueryResult that matches this Query
virtual QueryResult eval(const TextQuery&) const = 0;
// rep is a string representing of the query
virtual std::string rep() const = 0;
};
class WordQuery : public Query_base {
friend void cast_test();
friend class Query; // Query uses the WordQuery constructors
WordQuery(const std::string &s) : query_word(s) {}
// concrete class: WordQuery defines all inherited pure virtual functions
QueryResult eval(const TextQuery &t) const
{ return t.query(query_word); }
std::string rep() const { return query_word; }
std::string query_word; // word for which to search
};
class Query {
// these operators access to the shared_ptr constructor
friend Query operator~(const Query&);
friend Query operator|(const Query&, const Query&);
friend Query operator&(const Query&, const Query&);
public:
Query(const std::string &s) : q(new WordQuery(s)), cnt(new std::size_t(1)) {}; // builds a new WordQuery
// interface functions: call the corresponding Query_base operations
QueryResult eval(const TextQuery &t) const
{ return q->eval(t); }
std::string rep() const { return q->rep(); }
// copy-control operations
Query(const Query &query) : q(query.q), cnt(query.cnt) { ++*cnt; }
Query(Query &&query) noexcept : q(query.q), cnt(query.cnt) { query.q = 0; }
Query& operator=(const Query&);
Query& operator=(Query&&) noexcept;
~Query();
private:
// Query(std::shared_ptr<Query_base> query) : q(query) {}
Query(Query_base *query) : q(query), cnt(new std::size_t(1)) {}
Query_base *q;
std::size_t *cnt; // reference counter
// std::shared_ptr<Query_base> q;
};
inline
Query& Query::operator=(const Query &rhs)
{
++*rhs.cnt;
if(--*cnt == 0)
{
delete q;
delete cnt;
}
q = rhs.q;
cnt = rhs.cnt;
return *this;
}
inline
Query& Query::operator=(Query &&rhs) noexcept
{
if(this != &rhs) {
cnt = rhs.cnt;
q = rhs.q;
rhs.q = 0;
}
return *this;
}
inline
Query::~Query()
{
if(--*cnt == 0) {
delete q;
delete cnt;
}
}
inline std::ostream& operator<<(std::ostream &os, const Query &query)
{
// Query::rep makes a virtual call through its Query_base pointer to rep()
return os << query.rep();
}
class BinaryQuery : public Query_base {
friend void cast_test();
protected:
BinaryQuery(const Query &l, const Query &r, std::string s) :
lhs(l), rhs(r), opSym(s) {}
// abstract class: BinaryQuery doesn't define eval
std::string rep() const {
return "(" + lhs.rep() + " "
+ opSym + " "
+ rhs.rep() + ")";
}
Query lhs, rhs; // right and left-hand operand
std::string opSym; // name of the operator
};
class OrQuery : public BinaryQuery {
friend void cast_test();
friend Query operator|(const Query&, const Query&);
OrQuery(const Query &left, const Query &right) :
BinaryQuery(left, right, "|") {}
QueryResult eval(const TextQuery&) const;
};
class AndQuery : public BinaryQuery {
friend void cast_test();
friend Query operator&(const Query&, const Query&);
AndQuery(const Query &left, const Query &right) :
BinaryQuery(left, right, "&") {}
// concrete class: AndQuery inherits rep and defines the remaining pure virtual
QueryResult eval(const TextQuery&) const;
};
class NotQuery : public Query_base {
friend void cast_test();
friend Query operator~(const Query&);
NotQuery(const Query &q) : query(q) {}
// concrete class: NotQuery defines all inherited pure virtual functoins
std::string rep() const {}
QueryResult eval(const TextQuery&) const;
Query query;
};
inline Query operator|(const Query &lhs, const Query &rhs)
{
return (new OrQuery(lhs, rhs));
}
inline Query operator&(const Query &lhs, const Query &rhs)
{
return (new AndQuery(lhs, rhs));
}
inline Query operator~(const Query &operand)
{
return (new NotQuery(operand));
}
#endif
|
TernenceHsu/harfbuzz-icu-freetype
|
icu/common/locmap.c
|
/*
**********************************************************************
* Copyright (C) 1996-2013, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*
* Provides functionality for mapping between
* LCID and Posix IDs or ICU locale to codepage
*
* Note: All classes and code in this file are
* intended for internal use only.
*
* Methods of interest:
* unsigned long convertToLCID(const char*);
* const char* convertToPosix(unsigned long);
*
* <NAME>, 4/30/96
*
* Date Name Description
* 3/11/97 aliu Fixed off-by-one bug in assignment operator. Added
* setId() method and safety check against
* MAX_ID_LENGTH.
* 04/23/99 stephen Added C wrapper for convertToPosix.
* 09/18/00 george Removed the memory leaks.
* 08/23/01 george Convert to C
*/
#include "locmap.h"
#include "cstring.h"
#include "cmemory.h"
#if U_PLATFORM == U_PF_WINDOWS && defined(_MSC_VER) && (_MSC_VER >= 1500)
/*
* TODO: It seems like we should widen this to
* either U_PLATFORM_USES_ONLY_WIN32_API (includes MinGW)
* or U_PLATFORM_HAS_WIN32_API (includes MinGW and Cygwin)
* but those use gcc and won't have defined(_MSC_VER).
* We might need to #include some Windows header and test for some version macro from there.
* Or call some Windows function and see what it returns.
*/
#define USE_WINDOWS_LOCALE_API
#endif
#ifdef USE_WINDOWS_LOCALE_API
#include <windows.h>
#include <winnls.h>
#endif
/*
* Note:
* The mapping from Win32 locale ID numbers to POSIX locale strings should
* be the faster one.
*
* Many LCID values come from winnt.h
* Some also come from http://www.microsoft.com/globaldev/reference/lcid-all.mspx
*/
/*
////////////////////////////////////////////////
//
// Internal Classes for LCID <--> POSIX Mapping
//
/////////////////////////////////////////////////
*/
typedef struct ILcidPosixElement
{
const uint32_t hostID;
const char * const posixID;
} ILcidPosixElement;
typedef struct ILcidPosixMap
{
const uint32_t numRegions;
const struct ILcidPosixElement* const regionMaps;
} ILcidPosixMap;
/*
/////////////////////////////////////////////////
//
// Easy macros to make the LCID <--> POSIX Mapping
//
/////////////////////////////////////////////////
*/
/**
* The standard one language/one country mapping for LCID.
* The first element must be the language, and the following
* elements are the language with the country.
* @param hostID LCID in host format such as 0x044d
* @param languageID posix ID of just the language such as 'de'
* @param posixID posix ID of the language_TERRITORY such as 'de_CH'
*/
#define ILCID_POSIX_ELEMENT_ARRAY(hostID, languageID, posixID) \
static const ILcidPosixElement locmap_ ## languageID [] = { \
{LANGUAGE_LCID(hostID), #languageID}, /* parent locale */ \
{hostID, #posixID}, \
};
/**
* Define a subtable by ID
* @param id the POSIX ID, either a language or language_TERRITORY
*/
#define ILCID_POSIX_SUBTABLE(id) \
static const ILcidPosixElement locmap_ ## id [] =
/**
* Create the map for the posixID. This macro supposes that the language string
* name is the same as the global variable name, and that the first element
* in the ILcidPosixElement is just the language.
* @param _posixID the full POSIX ID for this entry.
*/
#define ILCID_POSIX_MAP(_posixID) \
{sizeof(locmap_ ## _posixID)/sizeof(ILcidPosixElement), locmap_ ## _posixID}
/*
////////////////////////////////////////////
//
// Create the table of LCID to POSIX Mapping
// None of it should be dynamically created.
//
// Keep static locale variables inside the function so that
// it can be created properly during static init.
//
// Note: This table should be updated periodically. Check the National Lanaguage Support API Reference Website.
// Microsoft is moving away from LCID in favor of locale name as of Vista. This table needs to be
// maintained for support of older Windows version.
// Update: Windows 7 (091130)
//
// Note: Microsoft assign a different LCID if a locale has a sorting variant. POSIX IDs below may contain
// @collation=XXX, but no other keywords are allowed (at least for now). When uprv_convertToLCID() is
// called from uloc_getLCID(), keywords other than collation are already removed. If we really need
// to support other keywords in this mapping data, we must update the implementation.
////////////////////////////////////////////
*/
ILCID_POSIX_ELEMENT_ARRAY(0x0436, af, af_ZA)
ILCID_POSIX_SUBTABLE(ar) {
{0x01, "ar"},
{0x3801, "ar_AE"},
{0x3c01, "ar_BH"},
{0x1401, "ar_DZ"},
{0x0c01, "ar_EG"},
{0x0801, "ar_IQ"},
{0x2c01, "ar_JO"},
{0x3401, "ar_KW"},
{0x3001, "ar_LB"},
{0x1001, "ar_LY"},
{0x1801, "ar_MA"},
{0x1801, "ar_MO"},
{0x2001, "ar_OM"},
{0x4001, "ar_QA"},
{0x0401, "ar_SA"},
{0x2801, "ar_SY"},
{0x1c01, "ar_TN"},
{0x2401, "ar_YE"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x044d, as, as_IN)
ILCID_POSIX_ELEMENT_ARRAY(0x045e, am, am_ET)
ILCID_POSIX_ELEMENT_ARRAY(0x047a, arn,arn_CL)
ILCID_POSIX_SUBTABLE(az) {
{0x2c, "az"},
{0x082c, "az_Cyrl_AZ"}, /* Cyrillic based */
{0x742c, "az_Cyrl"}, /* Cyrillic based */
{0x042c, "az_Latn_AZ"}, /* Latin based */
{0x782c, "az_Latn"}, /* Latin based */
{0x042c, "az_AZ"} /* Latin based */
};
ILCID_POSIX_ELEMENT_ARRAY(0x046d, ba, ba_RU)
ILCID_POSIX_ELEMENT_ARRAY(0x0423, be, be_BY)
/*ILCID_POSIX_SUBTABLE(ber) {
{0x5f, "ber"},
{0x045f, "ber_Arab_DZ"},
{0x045f, "ber_Arab"},
{0x085f, "ber_Latn_DZ"},
{0x085f, "ber_Latn"}
};*/
ILCID_POSIX_ELEMENT_ARRAY(0x0402, bg, bg_BG)
ILCID_POSIX_ELEMENT_ARRAY(0x0466, bin, bin_NG)
ILCID_POSIX_SUBTABLE(bn) {
{0x45, "bn"},
{0x0845, "bn_BD"},
{0x0445, "bn_IN"}
};
ILCID_POSIX_SUBTABLE(bo) {
{0x51, "bo"},
{0x0851, "bo_BT"},
{0x0451, "bo_CN"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x047e, br, br_FR)
ILCID_POSIX_SUBTABLE(ca) {
{0x03, "ca"},
{0x0403, "ca_ES"},
{0x0803, "ca_ES_VALENCIA"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0483, co, co_FR)
ILCID_POSIX_ELEMENT_ARRAY(0x045c, chr,chr_US)
ILCID_POSIX_SUBTABLE(ckb) {
{0x92, "ckb"},
{0x92, "ku"},
{0x7c92, "ckb_Arab"},
{0x7c92, "ku_Arab"},
{0x0492, "ckb_Arab_IQ"},
{0x0492, "ku_Arab_IQ"}
};
/* Declared as cs_CZ to get around compiler errors on z/OS, which defines cs as a function */
ILCID_POSIX_ELEMENT_ARRAY(0x0405, cs, cs_CZ)
ILCID_POSIX_ELEMENT_ARRAY(0x0452, cy, cy_GB)
ILCID_POSIX_ELEMENT_ARRAY(0x0406, da, da_DK)
ILCID_POSIX_SUBTABLE(de) {
{0x07, "de"},
{0x0c07, "de_AT"},
{0x0807, "de_CH"},
{0x0407, "de_DE"},
{0x1407, "de_LI"},
{0x1007, "de_LU"},
{0x10407,"de_DE@collation=phonebook"}, /*This is really de_DE_PHONEBOOK on Windows*/
{0x10407,"de@collation=phonebook"} /*This is really de_DE_PHONEBOOK on Windows*/
};
ILCID_POSIX_ELEMENT_ARRAY(0x0465, dv, dv_MV)
ILCID_POSIX_ELEMENT_ARRAY(0x0408, el, el_GR)
ILCID_POSIX_SUBTABLE(en) {
{0x09, "en"},
{0x0c09, "en_AU"},
{0x2809, "en_BZ"},
{0x1009, "en_CA"},
{0x0809, "en_GB"},
{0x3c09, "en_HK"},
{0x3809, "en_ID"},
{0x1809, "en_IE"},
{0x4009, "en_IN"},
{0x2009, "en_JM"},
{0x4409, "en_MY"},
{0x1409, "en_NZ"},
{0x3409, "en_PH"},
{0x4809, "en_SG"},
{0x2C09, "en_TT"},
{0x0409, "en_US"},
{0x007f, "en_US_POSIX"}, /* duplicate for roundtripping */
{0x2409, "en_VI"}, /* Virgin Islands AKA Caribbean Islands (en_CB). */
{0x1c09, "en_ZA"},
{0x3009, "en_ZW"},
{0x2409, "en_029"},
{0x0409, "en_AS"}, /* Alias for en_US. Leave last. */
{0x0409, "en_GU"}, /* Alias for en_US. Leave last. */
{0x0409, "en_MH"}, /* Alias for en_US. Leave last. */
{0x0409, "en_MP"}, /* Alias for en_US. Leave last. */
{0x0409, "en_UM"} /* Alias for en_US. Leave last. */
};
ILCID_POSIX_SUBTABLE(en_US_POSIX) {
{0x007f, "en_US_POSIX"} /* duplicate for roundtripping */
};
ILCID_POSIX_SUBTABLE(es) {
{0x0a, "es"},
{0x2c0a, "es_AR"},
{0x400a, "es_BO"},
{0x340a, "es_CL"},
{0x240a, "es_CO"},
{0x140a, "es_CR"},
{0x1c0a, "es_DO"},
{0x300a, "es_EC"},
{0x0c0a, "es_ES"}, /*Modern sort.*/
{0x100a, "es_GT"},
{0x480a, "es_HN"},
{0x080a, "es_MX"},
{0x4c0a, "es_NI"},
{0x180a, "es_PA"},
{0x280a, "es_PE"},
{0x500a, "es_PR"},
{0x3c0a, "es_PY"},
{0x440a, "es_SV"},
{0x540a, "es_US"},
{0x380a, "es_UY"},
{0x200a, "es_VE"},
{0xe40a, "es_419"},
{0x040a, "es_ES@collation=traditional"},
{0x040a, "es@collation=traditional"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0425, et, et_EE)
ILCID_POSIX_ELEMENT_ARRAY(0x042d, eu, eu_ES)
/* ISO-639 doesn't distinguish between Persian and Dari.*/
ILCID_POSIX_SUBTABLE(fa) {
{0x29, "fa"},
{0x0429, "fa_IR"}, /* Persian/Farsi (Iran) */
{0x048c, "fa_AF"} /* Persian/Dari (Afghanistan) */
};
/* duplicate for roundtripping */
ILCID_POSIX_SUBTABLE(fa_AF) {
{0x8c, "fa_AF"}, /* Persian/Dari (Afghanistan) */
{0x048c, "fa_AF"} /* Persian/Dari (Afghanistan) */
};
ILCID_POSIX_SUBTABLE(ff) {
{0x67, "ff"},
{0x7c67, "ff_Latn"},
{0x0867, "ff_Latn_SN"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x040b, fi, fi_FI)
ILCID_POSIX_ELEMENT_ARRAY(0x0464, fil,fil_PH)
ILCID_POSIX_ELEMENT_ARRAY(0x0438, fo, fo_FO)
ILCID_POSIX_SUBTABLE(fr) {
{0x0c, "fr"},
{0x080c, "fr_BE"},
{0x0c0c, "fr_CA"},
{0x240c, "fr_CD"},
{0x240c, "fr_CG"},
{0x100c, "fr_CH"},
{0x300c, "fr_CI"},
{0x2c0c, "fr_CM"},
{0x040c, "fr_FR"},
{0x3c0c, "fr_HT"},
{0x140c, "fr_LU"},
{0x380c, "fr_MA"},
{0x180c, "fr_MC"},
{0x340c, "fr_ML"},
{0x200c, "fr_RE"},
{0x280c, "fr_SN"},
{0xe40c, "fr_015"},
{0x1c0c, "fr_029"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0467, fuv, fuv_NG)
ILCID_POSIX_ELEMENT_ARRAY(0x0462, fy, fy_NL)
ILCID_POSIX_SUBTABLE(ga) { /* Gaelic (Ireland) */
{0x3c, "ga"},
{0x083c, "ga_IE"},
{0x043c, "gd_GB"}
};
ILCID_POSIX_SUBTABLE(gd) { /* Gaelic (Scotland) */
{0x91, "gd"},
{0x0491, "gd_GB"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0456, gl, gl_ES)
ILCID_POSIX_ELEMENT_ARRAY(0x0447, gu, gu_IN)
ILCID_POSIX_ELEMENT_ARRAY(0x0474, gn, gn_PY)
ILCID_POSIX_ELEMENT_ARRAY(0x0484, gsw,gsw_FR)
ILCID_POSIX_SUBTABLE(ha) {
{0x68, "ha"},
{0x7c68, "ha_Latn"},
{0x0468, "ha_Latn_NG"},
};
ILCID_POSIX_ELEMENT_ARRAY(0x0475, haw,haw_US)
ILCID_POSIX_ELEMENT_ARRAY(0x040d, he, he_IL)
ILCID_POSIX_ELEMENT_ARRAY(0x0439, hi, hi_IN)
/* This LCID is really four different locales.*/
ILCID_POSIX_SUBTABLE(hr) {
{0x1a, "hr"},
{0x141a, "bs_Latn_BA"}, /* Bosnian, Bosnia and Herzegovina */
{0x681a, "bs_Latn"}, /* Bosnian, Bosnia and Herzegovina */
{0x141a, "bs_BA"}, /* Bosnian, Bosnia and Herzegovina */
{0x781a, "bs"}, /* Bosnian */
{0x201a, "bs_Cyrl_BA"}, /* Bosnian, Bosnia and Herzegovina */
{0x641a, "bs_Cyrl"}, /* Bosnian, Bosnia and Herzegovina */
{0x101a, "hr_BA"}, /* Croatian in Bosnia */
{0x041a, "hr_HR"}, /* Croatian*/
{0x2c1a, "sr_Latn_ME"},
{0x241a, "sr_Latn_RS"},
{0x181a, "sr_Latn_BA"}, /* Serbo-Croatian in Bosnia */
{0x081a, "sr_Latn_CS"}, /* Serbo-Croatian*/
{0x701a, "sr_Latn"}, /* It's 0x1a or 0x081a, pick one to make the test program happy. */
{0x1c1a, "sr_Cyrl_BA"}, /* Serbo-Croatian in Bosnia */
{0x0c1a, "sr_Cyrl_CS"}, /* Serbian*/
{0x301a, "sr_Cyrl_ME"},
{0x281a, "sr_Cyrl_RS"},
{0x6c1a, "sr_Cyrl"}, /* It's 0x1a or 0x0c1a, pick one to make the test program happy. */
{0x7c1a, "sr"} /* In CLDR sr is sr_Cyrl. */
};
ILCID_POSIX_ELEMENT_ARRAY(0x040e, hu, hu_HU)
ILCID_POSIX_ELEMENT_ARRAY(0x042b, hy, hy_AM)
ILCID_POSIX_ELEMENT_ARRAY(0x0469, ibb, ibb_NG)
ILCID_POSIX_ELEMENT_ARRAY(0x0421, id, id_ID)
ILCID_POSIX_ELEMENT_ARRAY(0x0470, ig, ig_NG)
ILCID_POSIX_ELEMENT_ARRAY(0x0478, ii, ii_CN)
ILCID_POSIX_ELEMENT_ARRAY(0x040f, is, is_IS)
ILCID_POSIX_SUBTABLE(it) {
{0x10, "it"},
{0x0810, "it_CH"},
{0x0410, "it_IT"}
};
ILCID_POSIX_SUBTABLE(iu) {
{0x5d, "iu"},
{0x045d, "iu_Cans_CA"},
{0x785d, "iu_Cans"},
{0x085d, "iu_Latn_CA"},
{0x7c5d, "iu_Latn"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x040d, iw, iw_IL) /*Left in for compatibility*/
ILCID_POSIX_ELEMENT_ARRAY(0x0411, ja, ja_JP)
ILCID_POSIX_ELEMENT_ARRAY(0x0437, ka, ka_GE)
ILCID_POSIX_ELEMENT_ARRAY(0x043f, kk, kk_KZ)
ILCID_POSIX_ELEMENT_ARRAY(0x046f, kl, kl_GL)
ILCID_POSIX_ELEMENT_ARRAY(0x0453, km, km_KH)
ILCID_POSIX_ELEMENT_ARRAY(0x044b, kn, kn_IN)
ILCID_POSIX_SUBTABLE(ko) {
{0x12, "ko"},
{0x0812, "ko_KP"},
{0x0412, "ko_KR"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0457, kok, kok_IN)
ILCID_POSIX_ELEMENT_ARRAY(0x0471, kr, kr_NG)
ILCID_POSIX_SUBTABLE(ks) { /* We could add PK and CN too */
{0x60, "ks"},
{0x0860, "ks_IN"}, /* Documentation doesn't mention script */
{0x0460, "ks_Arab_IN"},
{0x0860, "ks_Deva_IN"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0440, ky, ky_KG) /* Kyrgyz is spoken in Kyrgyzstan */
ILCID_POSIX_ELEMENT_ARRAY(0x0476, la, la_IT) /* TODO: Verify the country */
ILCID_POSIX_ELEMENT_ARRAY(0x046e, lb, lb_LU)
ILCID_POSIX_ELEMENT_ARRAY(0x0454, lo, lo_LA)
ILCID_POSIX_ELEMENT_ARRAY(0x0427, lt, lt_LT)
ILCID_POSIX_ELEMENT_ARRAY(0x0426, lv, lv_LV)
ILCID_POSIX_ELEMENT_ARRAY(0x0481, mi, mi_NZ)
ILCID_POSIX_ELEMENT_ARRAY(0x042f, mk, mk_MK)
ILCID_POSIX_ELEMENT_ARRAY(0x044c, ml, ml_IN)
ILCID_POSIX_SUBTABLE(mn) {
{0x50, "mn"},
{0x0450, "mn_MN"},
{0x7c50, "mn_Mong"},
{0x0850, "mn_Mong_CN"},
{0x0850, "mn_CN"},
{0x7850, "mn_Cyrl"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0458, mni,mni_IN)
ILCID_POSIX_ELEMENT_ARRAY(0x047c, moh,moh_CA)
ILCID_POSIX_ELEMENT_ARRAY(0x044e, mr, mr_IN)
ILCID_POSIX_SUBTABLE(ms) {
{0x3e, "ms"},
{0x083e, "ms_BN"}, /* <NAME>alam*/
{0x043e, "ms_MY"} /* Malaysia*/
};
ILCID_POSIX_ELEMENT_ARRAY(0x043a, mt, mt_MT)
ILCID_POSIX_ELEMENT_ARRAY(0x0455, my, my_MM)
ILCID_POSIX_SUBTABLE(ne) {
{0x61, "ne"},
{0x0861, "ne_IN"}, /* India*/
{0x0461, "ne_NP"} /* Nepal*/
};
ILCID_POSIX_SUBTABLE(nl) {
{0x13, "nl"},
{0x0813, "nl_BE"},
{0x0413, "nl_NL"}
};
/* The "no" locale split into nb and nn. By default in ICU, "no" is nb.*/
ILCID_POSIX_SUBTABLE(no) {
{0x14, "no"}, /* really nb_NO */
{0x7c14, "nb"}, /* really nb */
{0x0414, "nb_NO"}, /* really nb_NO. Keep first in the 414 list. */
{0x0414, "no_NO"}, /* really nb_NO */
{0x0814, "nn_NO"}, /* really nn_NO. Keep first in the 814 list. */
{0x7814, "nn"}, /* It's 0x14 or 0x814, pick one to make the test program happy. */
{0x0814, "no_NO_NY"}/* really nn_NO */
};
ILCID_POSIX_ELEMENT_ARRAY(0x046c, nso,nso_ZA) /* TODO: Verify the ISO-639 code */
ILCID_POSIX_ELEMENT_ARRAY(0x0482, oc, oc_FR)
ILCID_POSIX_SUBTABLE(om) { /* TODO: Verify the country */
{0x72, "om"},
{0x0472, "om_ET"},
{0x0472, "gaz_ET"}
};
/* Declared as or_IN to get around compiler errors*/
ILCID_POSIX_SUBTABLE(or_IN) {
{0x48, "or"},
{0x0448, "or_IN"},
};
ILCID_POSIX_SUBTABLE(pa) {
{0x46, "pa"},
{0x0446, "pa_IN"},
{0x0846, "pa_PK"},
{0x0846, "pa_Arab_PK"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0479, pap, pap_AN)
ILCID_POSIX_ELEMENT_ARRAY(0x0415, pl, pl_PL)
ILCID_POSIX_ELEMENT_ARRAY(0x0463, ps, ps_AF)
ILCID_POSIX_SUBTABLE(pt) {
{0x16, "pt"},
{0x0416, "pt_BR"},
{0x0816, "pt_PT"}
};
ILCID_POSIX_SUBTABLE(qu) {
{0x6b, "qu"},
{0x046b, "qu_BO"},
{0x086b, "qu_EC"},
{0x0C6b, "qu_PE"},
{0x046b, "quz_BO"},
{0x086b, "quz_EC"},
{0x0C6b, "quz_PE"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0486, qut, qut_GT) /* qut is an ISO-639-3 code */
ILCID_POSIX_ELEMENT_ARRAY(0x0417, rm, rm_CH)
ILCID_POSIX_SUBTABLE(ro) {
{0x18, "ro"},
{0x0418, "ro_RO"},
{0x0818, "ro_MD"}
};
ILCID_POSIX_SUBTABLE(root) {
{0x00, "root"}
};
ILCID_POSIX_SUBTABLE(ru) {
{0x19, "ru"},
{0x0419, "ru_RU"},
{0x0819, "ru_MD"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0487, rw, rw_RW)
ILCID_POSIX_ELEMENT_ARRAY(0x044f, sa, sa_IN)
ILCID_POSIX_ELEMENT_ARRAY(0x0485, sah,sah_RU)
ILCID_POSIX_SUBTABLE(sd) {
{0x59, "sd"},
{0x0459, "sd_IN"},
{0x0859, "sd_PK"}
};
ILCID_POSIX_SUBTABLE(se) {
{0x3b, "se"},
{0x0c3b, "se_FI"},
{0x043b, "se_NO"},
{0x083b, "se_SE"},
{0x783b, "sma"},
{0x183b, "sma_NO"},
{0x1c3b, "sma_SE"},
{0x7c3b, "smj"},
{0x703b, "smn"},
{0x743b, "sms"},
{0x103b, "smj_NO"},
{0x143b, "smj_SE"},
{0x243b, "smn_FI"},
{0x203b, "sms_FI"},
};
ILCID_POSIX_ELEMENT_ARRAY(0x045b, si, si_LK)
ILCID_POSIX_ELEMENT_ARRAY(0x041b, sk, sk_SK)
ILCID_POSIX_ELEMENT_ARRAY(0x0424, sl, sl_SI)
ILCID_POSIX_SUBTABLE(so) { /* TODO: Verify the country */
{0x77, "so"},
{0x0477, "so_ET"},
{0x0477, "so_SO"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x041c, sq, sq_AL)
ILCID_POSIX_ELEMENT_ARRAY(0x0430, st, st_ZA)
ILCID_POSIX_SUBTABLE(sv) {
{0x1d, "sv"},
{0x081d, "sv_FI"},
{0x041d, "sv_SE"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0441, sw, sw_KE)
ILCID_POSIX_ELEMENT_ARRAY(0x045A, syr, syr_SY)
ILCID_POSIX_SUBTABLE(ta) {
{0x49, "ta"},
{0x0449, "ta_IN"},
{0x0849, "ta_LK"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x044a, te, te_IN)
/* Cyrillic based by default */
ILCID_POSIX_SUBTABLE(tg) {
{0x28, "tg"},
{0x7c28, "tg_Cyrl"},
{0x0428, "tg_Cyrl_TJ"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x041e, th, th_TH)
ILCID_POSIX_SUBTABLE(ti) {
{0x73, "ti"},
{0x0873, "ti_ER"},
{0x0473, "ti_ET"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0442, tk, tk_TM)
ILCID_POSIX_SUBTABLE(tn) {
{0x32, "tn"},
{0x0832, "tn_BW"},
{0x0432, "tn_ZA"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x041f, tr, tr_TR)
ILCID_POSIX_ELEMENT_ARRAY(0x0431, ts, ts_ZA)
ILCID_POSIX_ELEMENT_ARRAY(0x0444, tt, tt_RU)
ILCID_POSIX_SUBTABLE(tzm) {
{0x5f, "tzm"},
{0x7c5f, "tzm_Latn"},
{0x085f, "tzm_Latn_DZ"},
{0x105f, "tzm_Tfng_MA"},
{0x045f, "tmz"}
};
ILCID_POSIX_SUBTABLE(ug) {
{0x80, "ug"},
{0x0480, "ug_CN"},
{0x0480, "ug_Arab_CN"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0422, uk, uk_UA)
ILCID_POSIX_SUBTABLE(ur) {
{0x20, "ur"},
{0x0820, "ur_IN"},
{0x0420, "ur_PK"}
};
ILCID_POSIX_SUBTABLE(uz) {
{0x43, "uz"},
{0x0843, "uz_Cyrl_UZ"}, /* Cyrillic based */
{0x7843, "uz_Cyrl"}, /* Cyrillic based */
{0x0843, "uz_UZ"}, /* Cyrillic based */
{0x0443, "uz_Latn_UZ"}, /* Latin based */
{0x7c43, "uz_Latn"} /* Latin based */
};
ILCID_POSIX_SUBTABLE(ve) { /* TODO: Verify the country */
{0x33, "ve"},
{0x0433, "ve_ZA"},
{0x0433, "ven_ZA"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x042a, vi, vi_VN)
ILCID_POSIX_SUBTABLE(wen) {
{0x2E, "wen"},
{0x042E, "wen_DE"},
{0x042E, "hsb_DE"},
{0x082E, "dsb_DE"},
{0x7C2E, "dsb"},
{0x2E, "hsb"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0488, wo, wo_SN)
ILCID_POSIX_ELEMENT_ARRAY(0x0434, xh, xh_ZA)
ILCID_POSIX_ELEMENT_ARRAY(0x043d, yi, yi)
ILCID_POSIX_ELEMENT_ARRAY(0x046a, yo, yo_NG)
ILCID_POSIX_SUBTABLE(zh) {
{0x0004, "zh_Hans"},
{0x7804, "zh"},
{0x0804, "zh_CN"},
{0x0804, "zh_Hans_CN"},
{0x0c04, "zh_Hant_HK"},
{0x0c04, "zh_HK"},
{0x1404, "zh_Hant_MO"},
{0x1404, "zh_MO"},
{0x1004, "zh_Hans_SG"},
{0x1004, "zh_SG"},
{0x0404, "zh_Hant_TW"},
{0x7c04, "zh_Hant"},
{0x0404, "zh_TW"},
{0x30404,"zh_Hant_TW"}, /* Bopomofo order */
{0x30404,"zh_TW"}, /* Bopomofo order */
{0x20004,"zh@collation=stroke"},
{0x20404,"zh_Hant@collation=stroke"},
{0x20404,"zh_Hant_TW@collation=stroke"},
{0x20404,"zh_TW@collation=stroke"},
{0x20804,"zh_Hans@collation=stroke"},
{0x20804,"zh_Hans_CN@collation=stroke"},
{0x20804,"zh_CN@collation=stroke"}
};
ILCID_POSIX_ELEMENT_ARRAY(0x0435, zu, zu_ZA)
/* This must be static and grouped by LCID. */
static const ILcidPosixMap gPosixIDmap[] = {
ILCID_POSIX_MAP(af), /* af Afrikaans 0x36 */
ILCID_POSIX_MAP(am), /* am Amharic 0x5e */
ILCID_POSIX_MAP(ar), /* ar Arabic 0x01 */
ILCID_POSIX_MAP(arn), /* arn Araucanian/Mapudungun 0x7a */
ILCID_POSIX_MAP(as), /* as Assamese 0x4d */
ILCID_POSIX_MAP(az), /* az Azerbaijani 0x2c */
ILCID_POSIX_MAP(ba), /* ba Bashkir 0x6d */
ILCID_POSIX_MAP(be), /* be Belarusian 0x23 */
/* ILCID_POSIX_MAP(ber), ber Berber/Tamazight 0x5f */
ILCID_POSIX_MAP(bg), /* bg Bulgarian 0x02 */
ILCID_POSIX_MAP(bin), /* bin Edo 0x66 */
ILCID_POSIX_MAP(bn), /* bn Bengali; Bangla 0x45 */
ILCID_POSIX_MAP(bo), /* bo Tibetan 0x51 */
ILCID_POSIX_MAP(br), /* br Breton 0x7e */
ILCID_POSIX_MAP(ca), /* ca Catalan 0x03 */
ILCID_POSIX_MAP(chr), /* chr Cherokee 0x5c */
ILCID_POSIX_MAP(ckb), /* ckb Sorani (Central Kurdish) 0x92 */
ILCID_POSIX_MAP(co), /* co Corsican 0x83 */
ILCID_POSIX_MAP(cs), /* cs Czech 0x05 */
ILCID_POSIX_MAP(cy), /* cy Welsh 0x52 */
ILCID_POSIX_MAP(da), /* da Danish 0x06 */
ILCID_POSIX_MAP(de), /* de German 0x07 */
ILCID_POSIX_MAP(dv), /* dv Divehi 0x65 */
ILCID_POSIX_MAP(el), /* el Greek 0x08 */
ILCID_POSIX_MAP(en), /* en English 0x09 */
ILCID_POSIX_MAP(en_US_POSIX), /* invariant 0x7f */
ILCID_POSIX_MAP(es), /* es Spanish 0x0a */
ILCID_POSIX_MAP(et), /* et Estonian 0x25 */
ILCID_POSIX_MAP(eu), /* eu Basque 0x2d */
ILCID_POSIX_MAP(fa), /* fa Persian/Farsi 0x29 */
ILCID_POSIX_MAP(fa_AF), /* fa Persian/Dari 0x8c */
ILCID_POSIX_MAP(ff), /* ff Fula 0x67 */
ILCID_POSIX_MAP(fi), /* fi Finnish 0x0b */
ILCID_POSIX_MAP(fil), /* fil Filipino 0x64 */
ILCID_POSIX_MAP(fo), /* fo Faroese 0x38 */
ILCID_POSIX_MAP(fr), /* fr French 0x0c */
ILCID_POSIX_MAP(fuv), /* fuv Fulfulde - Nigeria 0x67 */
ILCID_POSIX_MAP(fy), /* fy Frisian 0x62 */
ILCID_POSIX_MAP(ga), /* * Gaelic (Ireland,Scotland) 0x3c */
ILCID_POSIX_MAP(gd), /* gd Gaelic (United Kingdom) 0x91 */
ILCID_POSIX_MAP(gl), /* gl Galician 0x56 */
ILCID_POSIX_MAP(gn), /* gn Guarani 0x74 */
ILCID_POSIX_MAP(gsw), /* gsw Alemanic/Alsatian/Swiss German 0x84 */
ILCID_POSIX_MAP(gu), /* gu Gujarati 0x47 */
ILCID_POSIX_MAP(ha), /* ha Hausa 0x68 */
ILCID_POSIX_MAP(haw), /* haw Hawaiian 0x75 */
ILCID_POSIX_MAP(he), /* he Hebrew (formerly iw) 0x0d */
ILCID_POSIX_MAP(hi), /* hi Hindi 0x39 */
ILCID_POSIX_MAP(hr), /* * Croatian and others 0x1a */
ILCID_POSIX_MAP(hu), /* hu Hungarian 0x0e */
ILCID_POSIX_MAP(hy), /* hy Armenian 0x2b */
ILCID_POSIX_MAP(ibb), /* ibb Ibibio - Nigeria 0x69 */
ILCID_POSIX_MAP(id), /* id Indonesian (formerly in) 0x21 */
ILCID_POSIX_MAP(ig), /* ig Igbo 0x70 */
ILCID_POSIX_MAP(ii), /* ii Sichuan Yi 0x78 */
ILCID_POSIX_MAP(is), /* is Icelandic 0x0f */
ILCID_POSIX_MAP(it), /* it Italian 0x10 */
ILCID_POSIX_MAP(iu), /* iu Inuktitut 0x5d */
ILCID_POSIX_MAP(iw), /* iw Hebrew 0x0d */
ILCID_POSIX_MAP(ja), /* ja Japanese 0x11 */
ILCID_POSIX_MAP(ka), /* ka Georgian 0x37 */
ILCID_POSIX_MAP(kk), /* kk Kazakh 0x3f */
ILCID_POSIX_MAP(kl), /* kl Kalaallisut 0x6f */
ILCID_POSIX_MAP(km), /* km Khmer 0x53 */
ILCID_POSIX_MAP(kn), /* kn Kannada 0x4b */
ILCID_POSIX_MAP(ko), /* ko Korean 0x12 */
ILCID_POSIX_MAP(kok), /* kok Konkani 0x57 */
ILCID_POSIX_MAP(kr), /* kr Kanuri 0x71 */
ILCID_POSIX_MAP(ks), /* ks Kashmiri 0x60 */
ILCID_POSIX_MAP(ky), /* ky Kyrgyz 0x40 */
ILCID_POSIX_MAP(lb), /* lb Luxembourgish 0x6e */
ILCID_POSIX_MAP(la), /* la Latin 0x76 */
ILCID_POSIX_MAP(lo), /* lo Lao 0x54 */
ILCID_POSIX_MAP(lt), /* lt Lithuanian 0x27 */
ILCID_POSIX_MAP(lv), /* lv Latvian, Lettish 0x26 */
ILCID_POSIX_MAP(mi), /* mi Maori 0x81 */
ILCID_POSIX_MAP(mk), /* mk Macedonian 0x2f */
ILCID_POSIX_MAP(ml), /* ml Malayalam 0x4c */
ILCID_POSIX_MAP(mn), /* mn Mongolian 0x50 */
ILCID_POSIX_MAP(mni), /* mni Manipuri 0x58 */
ILCID_POSIX_MAP(moh), /* moh Mohawk 0x7c */
ILCID_POSIX_MAP(mr), /* mr Marathi 0x4e */
ILCID_POSIX_MAP(ms), /* ms Malay 0x3e */
ILCID_POSIX_MAP(mt), /* mt Maltese 0x3a */
ILCID_POSIX_MAP(my), /* my Burmese 0x55 */
/* ILCID_POSIX_MAP(nb), // no Norwegian 0x14 */
ILCID_POSIX_MAP(ne), /* ne Nepali 0x61 */
ILCID_POSIX_MAP(nl), /* nl Dutch 0x13 */
/* ILCID_POSIX_MAP(nn), // no Norwegian 0x14 */
ILCID_POSIX_MAP(no), /* * Norwegian 0x14 */
ILCID_POSIX_MAP(nso), /* nso Sotho, Northern (Sepedi dialect) 0x6c */
ILCID_POSIX_MAP(oc), /* oc Occitan 0x82 */
ILCID_POSIX_MAP(om), /* om Oromo 0x72 */
ILCID_POSIX_MAP(or_IN), /* or Oriya 0x48 */
ILCID_POSIX_MAP(pa), /* pa Punjabi 0x46 */
ILCID_POSIX_MAP(pap), /* pap Papiamentu 0x79 */
ILCID_POSIX_MAP(pl), /* pl Polish 0x15 */
ILCID_POSIX_MAP(ps), /* ps Pashto 0x63 */
ILCID_POSIX_MAP(pt), /* pt Portuguese 0x16 */
ILCID_POSIX_MAP(qu), /* qu Quechua 0x6B */
ILCID_POSIX_MAP(qut), /* qut K'iche 0x86 */
ILCID_POSIX_MAP(rm), /* rm Raeto-Romance/Romansh 0x17 */
ILCID_POSIX_MAP(ro), /* ro Romanian 0x18 */
ILCID_POSIX_MAP(root), /* root 0x00 */
ILCID_POSIX_MAP(ru), /* ru Russian 0x19 */
ILCID_POSIX_MAP(rw), /* rw Kinyarwanda 0x87 */
ILCID_POSIX_MAP(sa), /* sa Sanskrit 0x4f */
ILCID_POSIX_MAP(sah), /* sah Yakut 0x85 */
ILCID_POSIX_MAP(sd), /* sd Sindhi 0x59 */
ILCID_POSIX_MAP(se), /* se Sami 0x3b */
/* ILCID_POSIX_MAP(sh), // sh Serbo-Croatian 0x1a */
ILCID_POSIX_MAP(si), /* si Sinhalese 0x5b */
ILCID_POSIX_MAP(sk), /* sk Slovak 0x1b */
ILCID_POSIX_MAP(sl), /* sl Slovenian 0x24 */
ILCID_POSIX_MAP(so), /* so Somali 0x77 */
ILCID_POSIX_MAP(sq), /* sq Albanian 0x1c */
/* ILCID_POSIX_MAP(sr), // sr Serbian 0x1a */
ILCID_POSIX_MAP(st), /* st Sutu 0x30 */
ILCID_POSIX_MAP(sv), /* sv Swedish 0x1d */
ILCID_POSIX_MAP(sw), /* sw Swahili 0x41 */
ILCID_POSIX_MAP(syr), /* syr Syriac 0x5A */
ILCID_POSIX_MAP(ta), /* ta Tamil 0x49 */
ILCID_POSIX_MAP(te), /* te Telugu 0x4a */
ILCID_POSIX_MAP(tg), /* tg Tajik 0x28 */
ILCID_POSIX_MAP(th), /* th Thai 0x1e */
ILCID_POSIX_MAP(ti), /* ti Tigrigna 0x73 */
ILCID_POSIX_MAP(tk), /* tk Turkmen 0x42 */
ILCID_POSIX_MAP(tn), /* tn Tswana 0x32 */
ILCID_POSIX_MAP(tr), /* tr Turkish 0x1f */
ILCID_POSIX_MAP(ts), /* ts Tsonga 0x31 */
ILCID_POSIX_MAP(tt), /* tt Tatar 0x44 */
ILCID_POSIX_MAP(tzm), /* tzm Tamazight 0x5f */
ILCID_POSIX_MAP(ug), /* ug Uighur 0x80 */
ILCID_POSIX_MAP(uk), /* uk Ukrainian 0x22 */
ILCID_POSIX_MAP(ur), /* ur Urdu 0x20 */
ILCID_POSIX_MAP(uz), /* uz Uzbek 0x43 */
ILCID_POSIX_MAP(ve), /* ve Venda 0x33 */
ILCID_POSIX_MAP(vi), /* vi Vietnamese 0x2a */
ILCID_POSIX_MAP(wen), /* wen Sorbian 0x2e */
ILCID_POSIX_MAP(wo), /* wo Wolof 0x88 */
ILCID_POSIX_MAP(xh), /* xh Xhosa 0x34 */
ILCID_POSIX_MAP(yi), /* yi Yiddish 0x3d */
ILCID_POSIX_MAP(yo), /* yo Yoruba 0x6a */
ILCID_POSIX_MAP(zh), /* zh Chinese 0x04 */
ILCID_POSIX_MAP(zu), /* zu Zulu 0x35 */
};
static const uint32_t gLocaleCount = sizeof(gPosixIDmap)/sizeof(ILcidPosixMap);
/**
* Do not call this function. It is called by hostID.
* The function is not private because this struct must stay as a C struct,
* and this is an internal class.
*/
static int32_t
idCmp(const char* id1, const char* id2)
{
int32_t diffIdx = 0;
while (*id1 == *id2 && *id1 != 0) {
diffIdx++;
id1++;
id2++;
}
return diffIdx;
}
/**
* Searches for a Windows LCID
*
* @param posixid the Posix style locale id.
* @param status gets set to U_ILLEGAL_ARGUMENT_ERROR when the Posix ID has
* no equivalent Windows LCID.
* @return the LCID
*/
static uint32_t
getHostID(const ILcidPosixMap *this_0, const char* posixID, UErrorCode* status)
{
int32_t bestIdx = 0;
int32_t bestIdxDiff = 0;
int32_t posixIDlen = (int32_t)uprv_strlen(posixID);
uint32_t idx;
for (idx = 0; idx < this_0->numRegions; idx++ ) {
int32_t sameChars = idCmp(posixID, this_0->regionMaps[idx].posixID);
if (sameChars > bestIdxDiff && this_0->regionMaps[idx].posixID[sameChars] == 0) {
if (posixIDlen == sameChars) {
/* Exact match */
return this_0->regionMaps[idx].hostID;
}
bestIdxDiff = sameChars;
bestIdx = idx;
}
}
/* We asked for something unusual, like en_ZZ, and we try to return the number for the same language. */
/* We also have to make sure that sid and si and similar string subsets don't match. */
if ((posixID[bestIdxDiff] == '_' || posixID[bestIdxDiff] == '@')
&& this_0->regionMaps[bestIdx].posixID[bestIdxDiff] == 0)
{
*status = U_USING_FALLBACK_WARNING;
return this_0->regionMaps[bestIdx].hostID;
}
/*no match found */
*status = U_ILLEGAL_ARGUMENT_ERROR;
return this_0->regionMaps->hostID;
}
static const char*
getPosixID(const ILcidPosixMap *this_0, uint32_t hostID)
{
uint32_t i;
for (i = 0; i <= this_0->numRegions; i++)
{
if (this_0->regionMaps[i].hostID == hostID)
{
return this_0->regionMaps[i].posixID;
}
}
/* If you get here, then no matching region was found,
so return the language id with the wild card region. */
return this_0->regionMaps[0].posixID;
}
/*
//////////////////////////////////////
//
// LCID --> POSIX
//
/////////////////////////////////////
*/
#ifdef USE_WINDOWS_LOCALE_API
/*
* Various language tags needs to be changed:
* quz -> qu
* prs -> fa
*/
#define FIX_LANGUAGE_ID_TAG(buffer, len) \
if (len >= 3) { \
if (buffer[0] == 'q' && buffer[1] == 'u' && buffer[2] == 'z') {\
buffer[2] = 0; \
uprv_strcat(buffer, buffer+3); \
} else if (buffer[0] == 'p' && buffer[1] == 'r' && buffer[2] == 's') {\
buffer[0] = 'f'; buffer[1] = 'a'; buffer[2] = 0; \
uprv_strcat(buffer, buffer+3); \
} \
}
#endif
U_CAPI int32_t
uprv_convertToPosix(uint32_t hostid, char *posixID, int32_t posixIDCapacity, UErrorCode* status)
{
uint16_t langID;
uint32_t localeIndex;
UBool bLookup = TRUE;
const char *pPosixID = NULL;
#ifdef USE_WINDOWS_LOCALE_API
int32_t tmpLen = 0;
char locName[157]; /* ULOC_FULLNAME_CAPACITY */
tmpLen = GetLocaleInfoA(hostid, LOCALE_SNAME, (LPSTR)locName, sizeof(locName)/sizeof(locName[0]));
if (tmpLen > 1) {
/* Windows locale name may contain sorting variant, such as "es-ES_tradnl".
In such case, we need special mapping data found in the hardcoded table
in this source file. */
char *p = uprv_strchr(locName, '_');
if (p) {
/* Keep the base locale, without variant */
*p = 0;
tmpLen = uprv_strlen(locName);
} else {
/* No hardcoded table lookup necessary */
bLookup = FALSE;
}
/* Change the tag separator from '-' to '_' */
p = locName;
while (*p) {
if (*p == '-') {
*p = '_';
}
p++;
}
FIX_LANGUAGE_ID_TAG(locName, tmpLen);
pPosixID = locName;
}
#endif
if (bLookup) {
const char *pCandidate = NULL;
langID = LANGUAGE_LCID(hostid);
for (localeIndex = 0; localeIndex < gLocaleCount; localeIndex++) {
if (langID == gPosixIDmap[localeIndex].regionMaps->hostID) {
pCandidate = getPosixID(&gPosixIDmap[localeIndex], hostid);
break;
}
}
/* On Windows, when locale name has a variant, we still look up the hardcoded table.
If a match in the hardcoded table is longer than the Windows locale name without
variant, we use the one as the result */
if (pCandidate && (pPosixID == NULL || uprv_strlen(pCandidate) > uprv_strlen(pPosixID))) {
pPosixID = pCandidate;
}
}
if (pPosixID) {
int32_t resLen = uprv_strlen(pPosixID);
int32_t copyLen = resLen <= posixIDCapacity ? resLen : posixIDCapacity;
uprv_memcpy(posixID, pPosixID, copyLen);
if (resLen < posixIDCapacity) {
posixID[resLen] = 0;
if (*status == U_STRING_NOT_TERMINATED_WARNING) {
*status = U_ZERO_ERROR;
}
} else if (resLen == posixIDCapacity) {
*status = U_STRING_NOT_TERMINATED_WARNING;
} else {
*status = U_BUFFER_OVERFLOW_ERROR;
}
return resLen;
}
/* no match found */
*status = U_ILLEGAL_ARGUMENT_ERROR;
return -1;
}
/*
//////////////////////////////////////
//
// POSIX --> LCID
// This should only be called from uloc_getLCID.
// The locale ID must be in canonical form.
// langID is separate so that this file doesn't depend on the uloc_* API.
//
/////////////////////////////////////
*/
U_CAPI uint32_t
uprv_convertToLCID(const char *langID, const char* posixID, UErrorCode* status)
{
uint32_t low = 0;
uint32_t high = gLocaleCount;
uint32_t mid;
uint32_t oldmid = 0;
int32_t compVal;
uint32_t value = 0;
uint32_t fallbackValue = (uint32_t)-1;
UErrorCode myStatus;
uint32_t idx;
/* Check for incomplete id. */
if (!langID || !posixID || uprv_strlen(langID) < 2 || uprv_strlen(posixID) < 2) {
return 0;
}
/*Binary search for the map entry for normal cases */
while (high > low) /*binary search*/{
mid = (high+low) >> 1; /*Finds median*/
if (mid == oldmid)
break;
compVal = uprv_strcmp(langID, gPosixIDmap[mid].regionMaps->posixID);
if (compVal < 0){
high = mid;
}
else if (compVal > 0){
low = mid;
}
else /*we found it*/{
return getHostID(&gPosixIDmap[mid], posixID, status);
}
oldmid = mid;
}
/*
* Sometimes we can't do a binary search on posixID because some LCIDs
* go to different locales. We hit one of those special cases.
*/
for (idx = 0; idx < gLocaleCount; idx++ ) {
myStatus = U_ZERO_ERROR;
value = getHostID(&gPosixIDmap[idx], posixID, &myStatus);
if (myStatus == U_ZERO_ERROR) {
return value;
}
else if (myStatus == U_USING_FALLBACK_WARNING) {
fallbackValue = value;
}
}
if (fallbackValue != (uint32_t)-1) {
*status = U_USING_FALLBACK_WARNING;
return fallbackValue;
}
/* no match found */
*status = U_ILLEGAL_ARGUMENT_ERROR;
return 0; /* return international (root) */
}
|
TernenceHsu/harfbuzz-icu-freetype
|
icu/common/ucase_props_data.h
|
/*
* Copyright (C) 1999-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
* file name: ucase_props_data.h
*
* machine-generated by: icu/tools/unicode/c/genprops/casepropsbuilder.cpp
*/
#ifndef INCLUDED_FROM_UCASE_CPP
# error This file must be #included from ucase.cpp only.
#endif
static const UVersionInfo ucase_props_dataVersion={6,3,0,0};
static const int32_t ucase_props_indexes[UCASE_IX_TOP]={0x10,0x5908,0x4bb8,0x516,0x172,0,0,0,0,0,0,0,0,0,0,3};
static const uint16_t ucase_props_trieIndex[9684]={
0x2d1,0x2d9,0x2e1,0x2e9,0x2f7,0x2ff,0x307,0x30f,0x317,0x31f,0x326,0x32e,0x336,0x33e,0x346,0x34e,
0x354,0x35c,0x364,0x36c,0x374,0x37c,0x384,0x38c,0x394,0x39c,0x3a4,0x3ac,0x3b4,0x3bc,0x3c4,0x3cc,
0x3d4,0x3dc,0x3e0,0x3e8,0x3f0,0x3f8,0x400,0x408,0x406,0x40e,0x413,0x41b,0x422,0x42a,0x432,0x43a,
0x442,0x44a,0x452,0x45a,0x2f0,0x2f8,0x45f,0x467,0x46c,0x474,0x47c,0x484,0x483,0x48b,0x490,0x498,
0x49f,0x4a6,0x4aa,0x2f0,0x2f0,0x2f0,0x2f0,0x4b1,0x4b9,0x4bb,0x4c3,0x4cb,0x4cf,0x4d0,0x4d8,0x4e0,
0x4e8,0x4d0,0x4f0,0x4f5,0x4e8,0x4d0,0x4fd,0x4e0,0x4cf,0x501,0x509,0x4e0,0x50e,0x2f0,0x516,0x2f0,
0x2f0,0x485,0x51e,0x4e0,0x2f0,0x501,0x525,0x4e0,0x2f0,0x2f0,0x4d8,0x4e0,0x2f0,0x2f0,0x52b,0x2f0,
0x2f0,0x531,0x538,0x2f0,0x2f0,0x53c,0x544,0x2f0,0x548,0x54f,0x2f0,0x556,0x55e,0x565,0x56d,0x2f0,
0x2f0,0x572,0x57a,0x582,0x58a,0x592,0x59a,0x438,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,
0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0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2f0,0x2f0,0x2f0,
0x844,0x84c,0x850,0x2f0,0x2f0,0x2f0,0x2f0,0x2d3,0x2d9,0x858,0x860,0x813,0x485,0x2f0,0x2f0,0x868,
0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,
0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,
0xbc4,0xbc4,0xbdc,0xc1c,0xc5c,0xc98,0xcd8,0xd18,0xd50,0xd90,0xdd0,0xe10,0xe50,0xe90,0xed0,0xf10,
0xf50,0xf80,0xfc0,0x1000,0x1018,0x104c,0x1088,0x10c8,0x1108,0x1148,0xbc0,0x117c,0x11b0,0x11f0,0x120c,0x1240,
0x9e1,0xa11,0xa51,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0xa87,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0xac4,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,0x188,
0x188,0x188,0x188,0x188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0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,
0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,0x2f0,
0x2f0,0x2f0,0x2f0,0x2f0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,
0,0,4,0,0,0,0,0,0,0,0,0,0,0,4,0,
0,0,0,0,0,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x1a,0xba,0xfa,
0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x17a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0,
0,0,4,0,4,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0x1f9,0xf029,0x299,
0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0x319,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,4,0,1,0,0,4,0,4,0,0,0,0,
4,0x399,0,4,4,0,1,0,0,0,0,0,0x100a,0x100a,0x100a,0x100a,
0x100a,0x3fa,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x47a,0x4ba,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,
0x100a,0x100a,0x100a,0,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x4f9,0xf009,0xf009,0xf009,0xf009,
0xf009,0x639,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,
0xf009,0xf009,0xf009,0,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0x3c89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x6ba,0xff89,0x8a,0xff89,0x8a,0xff89,0x6fa,0xffa9,0x73a,0x7d9,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,1,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,
0xff89,0x879,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0xc38a,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x979,0x6189,0x690a,0x8a,0xff89,0x8a,0xff89,0x670a,0x8a,
0xff89,0x668a,0x668a,0x8a,0xff89,1,0x278a,0x650a,0x658a,0x8a,0xff89,0x668a,0x678a,0x3089,0x698a,0x688a,
0x8a,0xff89,0x5189,1,0x698a,0x6a8a,0x4109,0x6b0a,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x6d0a,0x8a,
0xff89,0x6d0a,1,1,0x8a,0xff89,0x6d0a,0x8a,0xff89,0x6c8a,0x6c8a,0x8a,0xff89,0x8a,0xff89,0x6d8a,
0x8a,0xff89,1,0,0x8a,0xff89,1,0x1c09,0,0,0,0,0x9da,0xa3b,0xab9,0xb1a,
0xb7b,0xbf9,0xc5a,0xcbb,0xd39,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,
0xff89,0x8a,0xff89,0x8a,0xff89,0xd889,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0xd99,0xe9a,0xefb,0xf79,0x8a,0xff89,0xcf8a,0xe40a,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0xbf0a,1,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,1,1,1,1,1,1,0xfda,0x8a,0xff89,0xae8a,0x101a,0x1059,
0x1099,0x8a,0xff89,0x9e8a,0x228a,0x238a,0x8a,0xff89,0x8a,0xffa9,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x10d9,0x1119,0x1159,0x9709,0x9909,1,0x9989,0x9989,1,0x9b09,1,0x9a89,1,1,1,1,
0x9989,1,1,0x9889,1,0x1199,0x11d9,1,0x97a9,0x9689,1,0x1219,1,1,1,0x9689,
1,0x1259,0x9589,1,1,0x9509,1,1,1,1,1,1,1,0x1299,1,1,
0x9309,1,1,0x9309,1,1,1,1,0x9309,0xdd89,0x9389,0x9389,0xdc89,1,1,1,
1,1,0x9289,1,0,1,1,1,1,1,1,1,1,0x21,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
5,5,0x25,5,5,5,5,5,5,4,4,4,0xc,4,0xc,4,
5,5,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,4,4,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
0x4c,0x4c,0x44,0x44,0x44,0x44,0x44,0x12dc,0x4c,0x44,0x4c,0x44,0x4c,0x44,0x44,0x44,
0x44,0x44,0x44,0x4c,0x44,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,
0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,
0x64,0x6c,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x44,0x44,0x44,
0x44,0x44,0x4c,0x44,0x44,0x12fd,0x44,0x64,0x64,0x64,0x44,0x44,0x44,0x64,0x64,4,
0x44,0x44,0x44,0x64,0x64,0x64,0x64,0x44,0x64,0x64,0x64,0x44,0x64,0x64,0x64,0x64,
0x64,0x64,0x64,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x8a,0xff89,0x8a,0xff89,4,4,0x8a,0xff89,0,0,5,0x4109,0x4109,0x4109,0,0,
0,0,0,0,4,4,0x130a,4,0x128a,0x128a,0x128a,0,0x200a,0,0x1f8a,0x1f8a,
0x1399,0x100a,0x153a,0x100a,0x100a,0x15ba,0x100a,0x100a,0x163a,0x16da,0x177a,0x100a,0x17fa,0x100a,0x100a,0x100a,
0x187a,0x18fa,0,0x197a,0x100a,0x100a,0x19fa,0x100a,0x100a,0x1a7a,0x100a,0x100a,0xed09,0xed89,0xed89,0xed89,
0x1af9,0xf009,0x1c99,0xf009,0xf009,0x1d19,0xf009,0xf009,0x1d99,0x1e39,0x1ed9,0xf009,0x1f59,0xf009,0xf009,0xf009,
0x1fd9,0x2059,0x20d9,0x2139,0xf009,0xf009,0x21b9,0xf009,0xf009,0x2239,0xf009,0xf009,0xe009,0xe089,0xe089,0x40a,
0x22b9,0x2319,2,2,2,0x23b9,0x2419,0xfc09,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x2479,0x24d9,0x389,0x21,0x253a,0x25d9,0,0x8a,0xff89,0xfc8a,0x8a,0xff89,1,0xbf0a,0xbf0a,0xbf0a,
0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,0x280a,
0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,
0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,
0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,
0xd809,0xd809,0xd809,0xd809,0xd809,0xd809,0xd829,0xd809,0xd829,0xd809,0xd809,0xd809,0xd809,0xd809,0xd809,0xd809,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0,0x44,0x44,0x44,0x44,0x44,4,4,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x78a,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0xf889,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0,0,0,0,0,0,0,0,0,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,
0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,
0x180a,0x180a,0x180a,0,0,4,0,0,0,0,0,0,0,0xe809,0xe809,0xe809,
0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,
0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0x2639,
0,0,0,0,0,0,0,0,0,0x64,0x44,0x44,0x44,0x44,0x64,0x44,
0x44,0x44,0x64,0x64,0x44,0x44,0x44,0x44,0x44,0x44,0x64,0x64,0x64,0x64,0x64,0x64,
0x44,0x44,0x64,0x44,0x44,0x64,0x64,0x44,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,
0x64,0x64,0x64,0x64,0x64,0x64,0,0x64,0,0x64,0x64,0,0x44,0x64,0,0x64,
0,0,0,0,0,0,0,0,0,0,0,0,0,0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,1,1,1,0x3179,1,1,5,5,5,5,
0x25,5,5,5,0x25,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,0x21,1,1,1,1,5,5,5,5,5,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0x64,0x64,0x44,0x64,0x44,0x44,0x64,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x64,0x44,0x44,0x64,0x64,0x64,0x64,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xffa9,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x31ba,0x3239,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x32b9,0x33b9,
0x34b9,0x35b9,0x36b9,0x37b9,1,1,0x381a,1,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xffa9,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x409,0x409,0x409,0x409,0x409,0x409,0x409,0x409,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0x409,0x409,0x409,0x409,0x409,0x409,0,0,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0,0,0x409,0x409,0x409,0x409,0x409,0x409,0x409,0x409,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0x409,0x409,0x409,0x409,0x409,0x409,0x409,0x409,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0x409,0x409,0x409,0x409,0x409,0x409,0,0,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0,0,0x38b9,0x409,0x39b9,0x409,0x3b19,0x409,0x3c79,0x409,
0,0xfc0a,0,0xfc0a,0,0xfc0a,0,0xfc0a,0x409,0x409,0x409,0x409,0x409,0x409,0x409,0x409,
0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0xfc0a,0x2509,0x2509,0x2b09,0x2b09,0x2b09,0x2b09,0x3209,0x3209,
0x4009,0x4009,0x3809,0x3809,0x3f09,0x3f09,0,0,0x3dd9,0x3eb9,0x3f99,0x4079,0x4159,0x4239,0x4319,0x43f9,
0x44db,0x45bb,0x469b,0x477b,0x485b,0x493b,0x4a1b,0x4afb,0x4bd9,0x4cb9,0x4d99,0x4e79,0x4f59,0x5039,0x5119,0x51f9,
0x52db,0x53bb,0x549b,0x557b,0x565b,0x573b,0x581b,0x58fb,0x59d9,0x5ab9,0x5b99,0x5c79,0x5d59,0x5e39,0x5f19,0x5ff9,
0x60db,0x61bb,0x629b,0x637b,0x645b,0x653b,0x661b,0x66fb,0x409,0x409,0x67d9,0x68d9,0x69b9,0,0x6ab9,0x6bb9,
0xfc0a,0xfc0a,0xdb0a,0xdb0a,0x6d1b,4,0x6df9,4,4,4,0x6e99,0x6f99,0x7079,0,0x7179,0x7279,
0xd50a,0xd50a,0xd50a,0xd50a,0x73db,4,4,4,0x409,0x409,0x74b9,0x7619,0,0,0x77b9,0x78b9,
0xfc0a,0xfc0a,0xce0a,0xce0a,0,4,4,4,0x409,0x409,0x7a19,0x7b79,0x7d19,0x389,0x7e19,0x7f19,
0xfc0a,0xfc0a,0xc80a,0xc80a,0xfc8a,4,4,4,0,0,0x8079,0x8179,0x8259,0,0x8359,0x8459,
0xc00a,0xc00a,0xc10a,0xc10a,0x85bb,4,4,0,0,0,0,0,0,0,0,0,
0,0,0,4,4,4,4,4,0,0,0,0,0,0,0,0,
4,4,0,0,0,0,0,0,4,0,0,4,0,0,4,4,
4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,4,4,4,4,4,0,4,4,4,4,4,4,
4,4,4,4,0,0x25,0,0,0,0,0,0,0,0,0,0,
0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,5,5,5,5,5,5,5,5,5,5,5,5,
5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0x44,0x44,0x64,0x64,0x44,0x44,0x44,0x44,0x64,0x64,0x64,0x44,
0x44,4,4,4,4,0x44,4,4,4,0x64,0x64,0x44,0x64,0x44,0x64,0x64,
0x64,0x64,0x64,0x64,0x44,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,2,0,0,0,0,2,0,0,1,2,
2,2,1,1,2,2,2,1,0,2,0,0,0,2,2,2,
2,2,0,0,0,0,0,0,2,0,0x869a,0,2,0,0x871a,0x879a,
2,2,0,1,2,2,0xe0a,2,1,0,0,0,0,1,0,0,
1,1,2,2,0,0,0,0,0,2,1,1,0x21,0x21,0,0,
0,0,0xf209,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,0x80a,
0x80a,0x80a,0x80a,0x80a,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,0xf809,
0xf809,0xf809,0xf809,0xf809,0,0,0,0x8a,0xff89,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,
0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xd0a,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,
0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0xf309,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,
0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,0x180a,
0x180a,0x180a,0x180a,0,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,
0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,0xe809,
0xe809,0xe809,0xe809,0,0x8a,0xff89,0x881a,0x885a,0x889a,0x88d9,0x8919,0x8a,0xff89,0x8a,0xff89,0x8a,
0xff89,0x895a,0x899a,0x89da,0x8a1a,1,0x8a,0xff89,1,0x8a,0xff89,1,1,1,1,1,
0x25,5,0x8a5a,0x8a9a,0x8a,0xff89,0x8a,0xff89,1,0,0,0,0,0,0,0x8a,
0xff89,0x8a,0xff89,0x44,0x44,0x44,0x8a,0xff89,0,0,0,0,0,0,0,0,
0,0,0,0,0x8ad9,0x8b19,0x8b59,0x8b99,0x8bd9,0x8c19,0x8c59,0x8c99,0x8cd9,0x8d19,0x8d59,0x8d99,
0x8dd9,0x8e19,0x8e59,0x8e99,0x8ed9,0x8f19,0x8f59,0x8f99,0x8fd9,0x9019,0x9059,0x9099,0x90d9,0x9119,0x9159,0x9199,
0x91d9,0x9219,0x9259,0x9299,0x92d9,0x9319,0x9359,0x9399,0x93d9,0x9419,0,0x9459,0,0,0,0,
0,0x9499,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0x64,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0,0,0,0,0,0,0,0,
0,0,0x64,0x64,0x64,0x64,0x60,0x60,0,4,4,4,4,4,0,0,
0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0x64,0x64,4,
4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4,4,4,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0,0x44,4,4,4,0,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0,4,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,0x8a,0xff89,
0x8a,0xff89,0x8a,0xff89,0,0,0,0,0,0,0,0x44,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0x44,0x44,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,4,4,4,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4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4,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x44,0,0x44,0x44,0x64,0,0,0x44,0x44,0,0,0,0,0,0x44,0x44,
0,0x44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,0,
0,0,0,4,4,0,0x64,0,0,0,0,0,0,0,0,0,
0,4,0,0,4,0,0,0,0,0x64,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0x9599,0x9699,0x9799,0x9899,
0x99f9,0x9b59,0x9c99,0,0,0,0,0,0,0,0,0,0,0,0,0x9dd9,
0x9ed9,0x9fd9,0xa0d9,0xa1d9,0,0,0,0,0,0,0x64,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,
0x44,0x44,0x44,0x44,0x44,0x44,0x44,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,4,0,0,4,0,0,0,0,0,0,0,0,0,0,
0,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,
0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0x100a,0,0,0,4,0,
4,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,
0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0xf009,0,0,0,0,0,
0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,4,4,4,0,0,0,0,
0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,
0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,0x140a,
0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,
0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0xec09,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,4,4,4,0,4,4,0,
0,0,0,0,4,0x64,4,0x44,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x44,0x64,0x64,0,0,0,0,0x64,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4,4,4,4,4,4,4,4,4,4,0x64,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,4,4,4,4,0,0,0x64,0x64,0,
0,4,0,0,0x44,0x44,0x44,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,4,4,4,4,4,0,4,4,4,
4,4,4,0x64,0x64,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,
4,4,4,4,4,4,4,0,0x60,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,4,0,4,0,0,
4,4,4,4,4,4,0x60,0x64,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,4,4,4,4,4,4,4,4,4,
4,4,4,4,4,4,4,4,0,0,0,0,0,0x60,0x60,0x64,
0x64,0x64,0,0,0,0x60,0x60,0x60,0x60,0x60,0x60,4,4,4,4,4,
4,4,4,0x64,0x64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2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,0,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,0,1,1,1,1,1,1,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,0,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
1,1,1,0,1,1,1,1,1,1,2,1,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0
};
static const uint16_t ucase_props_exceptions[1302]={
0xc041,0x69,2,0x130,0x131,0x4001,0x6a,0x41,0x6b,1,0x212a,0x41,0x73,1,0x17f,0x5044,
0x49,2,0x130,0x131,0x44,0x4b,1,0x212a,0x44,0x53,1,0x17f,6,0x3bc,0x39c,0x41,
0xe5,1,0x212b,0x4001,0xec,0x4001,0xed,0xc0,1,0x2220,0x73,0x73,0x53,0x53,0x53,0x73,
0x1e9e,0x44,0xc5,1,0x212b,0x4001,0x129,0x4001,0x12f,0xc041,0x69,2,0x49,0x131,0x44,0x49,
2,0x69,0x130,0x80,0x2220,0x2bc,0x6e,0x2bc,0x4e,0x2bc,0x4e,6,0x73,0x53,9,0x1c6,
0x1c5,0xd,0x1c6,0x1c4,0x1c5,0xc,0x1c4,0x1c5,9,0x1c9,0x1c8,0xd,0x1c9,0x1c7,0x1c8,0xc,
0x1c7,0x1c8,9,0x1cc,0x1cb,0xd,0x1cc,0x1ca,0x1cb,0xc,0x1ca,0x1cb,0x80,0x2220,0x6a,0x30c,
0x4a,0x30c,0x4a,0x30c,9,0x1f3,0x1f2,0xd,0x1f3,0x1f1,0x1f2,0xc,0x1f1,0x1f2,1,0x2c65,
1,0x2c66,4,0x2c7e,4,0x2c7f,4,0x2c6f,4,0x2c6d,4,0x2c70,4,0xa78d,4,0xa7aa,
4,0x2c62,4,0x2c6e,4,0x2c64,0x6000,0x3046,0x3b9,0x399,1,0x1fbe,0xc0,1,0x3330,0x3b9,
0x308,0x301,0x399,0x308,0x301,0x399,0x308,0x301,0x1fd3,0x41,0x3b2,1,0x3d0,0x41,0x3b5,1,
0x3f5,0x41,0x3b8,2,0x3d1,0x3f4,0x41,0x3b9,2,0x345,0x1fbe,0x41,0x3ba,1,0x3f0,0x41,
0x3bc,1,0xb5,0x41,0x3c0,1,0x3d6,0x41,0x3c1,1,0x3f1,0x4041,0x3c3,1,0x3c2,0x41,
0x3c6,1,0x3d5,0x41,0x3c9,1,0x2126,0xc0,1,0x3330,0x3c5,0x308,0x301,0x3a5,0x308,0x301,
0x3a5,0x308,0x301,0x1fe3,0x44,0x392,1,0x3d0,0x44,0x395,1,0x3f5,0x44,0x398,2,0x3d1,
0x3f4,0x44,0x399,2,0x345,0x1fbe,0x44,0x39a,1,0x3f0,0x44,0x39c,1,0xb5,0x44,0x3a0,
1,0x3d6,0x44,0x3a1,1,0x3f1,6,0x3c3,0x3a3,0x44,0x3a3,1,0x3c2,0x44,0x3a6,1,
0x3d5,0x44,0x3a9,1,0x2126,6,0x3b2,0x392,0x46,0x3b8,0x398,1,0x3f4,6,0x3c6,0x3a6,
6,0x3c0,0x3a0,6,0x3ba,0x39a,6,0x3c1,0x3a1,0x41,0x3b8,2,0x398,0x3d1,6,0x3b5,
0x395,0x80,0x2220,0x565,0x582,0x535,0x552,0x535,0x582,1,0x2d00,1,0x2d01,1,0x2d02,1,
0x2d03,1,0x2d04,1,0x2d05,1,0x2d06,1,0x2d07,1,0x2d08,1,0x2d09,1,0x2d0a,1,
0x2d0b,1,0x2d0c,1,0x2d0d,1,0x2d0e,1,0x2d0f,1,0x2d10,1,0x2d11,1,0x2d12,1,
0x2d13,1,0x2d14,1,0x2d15,1,0x2d16,1,0x2d17,1,0x2d18,1,0x2d19,1,0x2d1a,1,
0x2d1b,1,0x2d1c,1,0x2d1d,1,0x2d1e,1,0x2d1f,1,0x2d20,1,0x2d21,1,0x2d22,1,
0x2d23,1,0x2d24,1,0x2d25,1,0x2d27,1,0x2d2d,4,0xa77d,4,0x2c63,0x41,0x1e61,1,
0x1e9b,0x44,0x1e60,1,0x1e9b,0x80,0x2220,0x68,0x331,0x48,0x331,0x48,0x331,0x80,0x2220,0x74,
0x308,0x54,0x308,0x54,0x308,0x80,0x2220,0x77,0x30a,0x57,0x30a,0x57,0x30a,0x80,0x2220,0x79,
0x30a,0x59,0x30a,0x59,0x30a,0x80,0x2220,0x61,0x2be,0x41,0x2be,0x41,0x2be,6,0x1e61,0x1e60,
0x81,0xdf,0x20,0x73,0x73,0x80,0x2220,0x3c5,0x313,0x3a5,0x313,0x3a5,0x313,0x80,0x3330,0x3c5,
0x313,0x300,0x3a5,0x313,0x300,0x3a5,0x313,0x300,0x80,0x3330,0x3c5,0x313,0x301,0x3a5,0x313,0x301,
0x3a5,0x313,0x301,0x80,0x3330,0x3c5,0x313,0x342,0x3a5,0x313,0x342,0x3a5,0x313,0x342,0x84,0x1f88,
0x220,0x1f00,0x3b9,0x1f08,0x399,0x84,0x1f89,0x220,0x1f01,0x3b9,0x1f09,0x399,0x84,0x1f8a,0x220,0x1f02,
0x3b9,0x1f0a,0x399,0x84,0x1f8b,0x220,0x1f03,0x3b9,0x1f0b,0x399,0x84,0x1f8c,0x220,0x1f04,0x3b9,0x1f0c,
0x399,0x84,0x1f8d,0x220,0x1f05,0x3b9,0x1f0d,0x399,0x84,0x1f8e,0x220,0x1f06,0x3b9,0x1f0e,0x399,0x84,
0x1f8f,0x220,0x1f07,0x3b9,0x1f0f,0x399,0x81,0x1f80,0x220,0x1f00,0x3b9,0x1f08,0x399,0x81,0x1f81,0x220,
0x1f01,0x3b9,0x1f09,0x399,0x81,0x1f82,0x220,0x1f02,0x3b9,0x1f0a,0x399,0x81,0x1f83,0x220,0x1f03,0x3b9,
0x1f0b,0x399,0x81,0x1f84,0x220,0x1f04,0x3b9,0x1f0c,0x399,0x81,0x1f85,0x220,0x1f05,0x3b9,0x1f0d,0x399,
0x81,0x1f86,0x220,0x1f06,0x3b9,0x1f0e,0x399,0x81,0x1f87,0x220,0x1f07,0x3b9,0x1f0f,0x399,0x84,0x1f98,
0x220,0x1f20,0x3b9,0x1f28,0x399,0x84,0x1f99,0x220,0x1f21,0x3b9,0x1f29,0x399,0x84,0x1f9a,0x220,0x1f22,
0x3b9,0x1f2a,0x399,0x84,0x1f9b,0x220,0x1f23,0x3b9,0x1f2b,0x399,0x84,0x1f9c,0x220,0x1f24,0x3b9,0x1f2c,
0x399,0x84,0x1f9d,0x220,0x1f25,0x3b9,0x1f2d,0x399,0x84,0x1f9e,0x220,0x1f26,0x3b9,0x1f2e,0x399,0x84,
0x1f9f,0x220,0x1f27,0x3b9,0x1f2f,0x399,0x81,0x1f90,0x220,0x1f20,0x3b9,0x1f28,0x399,0x81,0x1f91,0x220,
0x1f21,0x3b9,0x1f29,0x399,0x81,0x1f92,0x220,0x1f22,0x3b9,0x1f2a,0x399,0x81,0x1f93,0x220,0x1f23,0x3b9,
0x1f2b,0x399,0x81,0x1f94,0x220,0x1f24,0x3b9,0x1f2c,0x399,0x81,0x1f95,0x220,0x1f25,0x3b9,0x1f2d,0x399,
0x81,0x1f96,0x220,0x1f26,0x3b9,0x1f2e,0x399,0x81,0x1f97,0x220,0x1f27,0x3b9,0x1f2f,0x399,0x84,0x1fa8,
0x220,0x1f60,0x3b9,0x1f68,0x399,0x84,0x1fa9,0x220,0x1f61,0x3b9,0x1f69,0x399,0x84,0x1faa,0x220,0x1f62,
0x3b9,0x1f6a,0x399,0x84,0x1fab,0x220,0x1f63,0x3b9,0x1f6b,0x399,0x84,0x1fac,0x220,0x1f64,0x3b9,0x1f6c,
0x399,0x84,0x1fad,0x220,0x1f65,0x3b9,0x1f6d,0x399,0x84,0x1fae,0x220,0x1f66,0x3b9,0x1f6e,0x399,0x84,
0x1faf,0x220,0x1f67,0x3b9,0x1f6f,0x399,0x81,0x1fa0,0x220,0x1f60,0x3b9,0x1f68,0x399,0x81,0x1fa1,0x220,
0x1f61,0x3b9,0x1f69,0x399,0x81,0x1fa2,0x220,0x1f62,0x3b9,0x1f6a,0x399,0x81,0x1fa3,0x220,0x1f63,0x3b9,
0x1f6b,0x399,0x81,0x1fa4,0x220,0x1f64,0x3b9,0x1f6c,0x399,0x81,0x1fa5,0x220,0x1f65,0x3b9,0x1f6d,0x399,
0x81,0x1fa6,0x220,0x1f66,0x3b9,0x1f6e,0x399,0x81,0x1fa7,0x220,0x1f67,0x3b9,0x1f6f,0x399,0x80,0x2220,
0x1f70,0x3b9,0x1fba,0x399,0x1fba,0x345,0x84,0x1fbc,0x220,0x3b1,0x3b9,0x391,0x399,0x80,0x2220,0x3ac,
0x3b9,0x386,0x399,0x386,0x345,0x80,0x2220,0x3b1,0x342,0x391,0x342,0x391,0x342,0x80,0x3330,0x3b1,
0x342,0x3b9,0x391,0x342,0x399,0x391,0x342,0x345,0x81,0x1fb3,0x220,0x3b1,0x3b9,0x391,0x399,0x46,
0x3b9,0x399,1,0x345,0x80,0x2220,0x1f74,0x3b9,0x1fca,0x399,0x1fca,0x345,0x84,0x1fcc,0x220,0x3b7,
0x3b9,0x397,0x399,0x80,0x2220,0x3ae,0x3b9,0x389,0x399,0x389,0x345,0x80,0x2220,0x3b7,0x342,0x397,
0x342,0x397,0x342,0x80,0x3330,0x3b7,0x342,0x3b9,0x397,0x342,0x399,0x397,0x342,0x345,0x81,0x1fc3,
0x220,0x3b7,0x3b9,0x397,0x399,0x80,0x3330,0x3b9,0x308,0x300,0x399,0x308,0x300,0x399,0x308,0x300,
0xc0,1,0x3330,0x3b9,0x308,0x301,0x399,0x308,0x301,0x399,0x308,0x301,0x390,0x80,0x2220,0x3b9,
0x342,0x399,0x342,0x399,0x342,0x80,0x3330,0x3b9,0x308,0x342,0x399,0x308,0x342,0x399,0x308,0x342,
0x80,0x3330,0x3c5,0x308,0x300,0x3a5,0x308,0x300,0x3a5,0x308,0x300,0xc0,1,0x3330,0x3c5,0x308,
0x301,0x3a5,0x308,0x301,0x3a5,0x308,0x301,0x3b0,0x80,0x2220,0x3c1,0x313,0x3a1,0x313,0x3a1,0x313,
0x80,0x2220,0x3c5,0x342,0x3a5,0x342,0x3a5,0x342,0x80,0x3330,0x3c5,0x308,0x342,0x3a5,0x308,0x342,
0x3a5,0x308,0x342,0x80,0x2220,0x1f7c,0x3b9,0x1ffa,0x399,0x1ffa,0x345,0x84,0x1ffc,0x220,0x3c9,0x3b9,
0x3a9,0x399,0x80,0x2220,0x3ce,0x3b9,0x38f,0x399,0x38f,0x345,0x80,0x2220,0x3c9,0x342,0x3a9,0x342,
0x3a9,0x342,0x80,0x3330,0x3c9,0x342,0x3b9,0x3a9,0x342,0x399,0x3a9,0x342,0x345,0x81,0x1ff3,0x220,
0x3c9,0x3b9,0x3a9,0x399,0x41,0x3c9,1,0x3a9,0x41,0x6b,1,0x4b,0x41,0xe5,1,0xc5,
1,0x26b,1,0x1d7d,1,0x27d,4,0x23a,4,0x23e,1,0x251,1,0x271,1,0x250,
1,0x252,1,0x23f,1,0x240,4,0x10a0,4,0x10a1,4,0x10a2,4,0x10a3,4,0x10a4,
4,0x10a5,4,0x10a6,4,0x10a7,4,0x10a8,4,0x10a9,4,0x10aa,4,0x10ab,4,0x10ac,
4,0x10ad,4,0x10ae,4,0x10af,4,0x10b0,4,0x10b1,4,0x10b2,4,0x10b3,4,0x10b4,
4,0x10b5,4,0x10b6,4,0x10b7,4,0x10b8,4,0x10b9,4,0x10ba,4,0x10bb,4,0x10bc,
4,0x10bd,4,0x10be,4,0x10bf,4,0x10c0,4,0x10c1,4,0x10c2,4,0x10c3,4,0x10c4,
4,0x10c5,4,0x10c7,4,0x10cd,1,0x1d79,1,0x265,1,0x266,0x80,0x2220,0x66,0x66,
0x46,0x46,0x46,0x66,0x80,0x2220,0x66,0x69,0x46,0x49,0x46,0x69,0x80,0x2220,0x66,0x6c,
0x46,0x4c,0x46,0x6c,0x80,0x3330,0x66,0x66,0x69,0x46,0x46,0x49,0x46,0x66,0x69,0x80,
0x3330,0x66,0x66,0x6c,0x46,0x46,0x4c,0x46,0x66,0x6c,0xc0,1,0x2220,0x73,0x74,0x53,
0x54,0x53,0x74,0xfb06,0xc0,1,0x2220,0x73,0x74,0x53,0x54,0x53,0x74,0xfb05,0x80,0x2220,
0x574,0x576,0x544,0x546,0x544,0x576,0x80,0x2220,0x574,0x565,0x544,0x535,0x544,0x565,0x80,0x2220,
0x574,0x56b,0x544,0x53b,0x544,0x56b,0x80,0x2220,0x57e,0x576,0x54e,0x546,0x54e,0x576,0x80,0x2220,
0x574,0x56d,0x544,0x53d,0x544,0x56d
};
static const uint16_t ucase_props_unfold[370]={
0x49,5,3,0,0,0x61,0x2be,0,0x1e9a,0,0x66,0x66,0,0xfb00,0,0x66,
0x66,0x69,0xfb03,0,0x66,0x66,0x6c,0xfb04,0,0x66,0x69,0,0xfb01,0,0x66,0x6c,
0,0xfb02,0,0x68,0x331,0,0x1e96,0,0x69,0x307,0,0x130,0,0x6a,0x30c,0,
0x1f0,0,0x73,0x73,0,0xdf,0x1e9e,0x73,0x74,0,0xfb05,0xfb06,0x74,0x308,0,0x1e97,
0,0x77,0x30a,0,0x1e98,0,0x79,0x30a,0,0x1e99,0,0x2bc,0x6e,0,0x149,0,
0x3ac,0x3b9,0,0x1fb4,0,0x3ae,0x3b9,0,0x1fc4,0,0x3b1,0x342,0,0x1fb6,0,0x3b1,
0x342,0x3b9,0x1fb7,0,0x3b1,0x3b9,0,0x1fb3,0x1fbc,0x3b7,0x342,0,0x1fc6,0,0x3b7,0x342,
0x3b9,0x1fc7,0,0x3b7,0x3b9,0,0x1fc3,0x1fcc,0x3b9,0x308,0x300,0x1fd2,0,0x3b9,0x308,0x301,
0x390,0x1fd3,0x3b9,0x308,0x342,0x1fd7,0,0x3b9,0x342,0,0x1fd6,0,0x3c1,0x313,0,0x1fe4,
0,0x3c5,0x308,0x300,0x1fe2,0,0x3c5,0x308,0x301,0x3b0,0x1fe3,0x3c5,0x308,0x342,0x1fe7,0,
0x3c5,0x313,0,0x1f50,0,0x3c5,0x313,0x300,0x1f52,0,0x3c5,0x313,0x301,0x1f54,0,0x3c5,
0x313,0x342,0x1f56,0,0x3c5,0x342,0,0x1fe6,0,0x3c9,0x342,0,0x1ff6,0,0x3c9,0x342,
0x3b9,0x1ff7,0,0x3c9,0x3b9,0,0x1ff3,0x1ffc,0x3ce,0x3b9,0,0x1ff4,0,0x565,0x582,0,
0x587,0,0x574,0x565,0,0xfb14,0,0x574,0x56b,0,0xfb15,0,0x574,0x56d,0,0xfb17,
0,0x574,0x576,0,0xfb13,0,0x57e,0x576,0,0xfb16,0,0x1f00,0x3b9,0,0x1f80,0x1f88,
0x1f01,0x3b9,0,0x1f81,0x1f89,0x1f02,0x3b9,0,0x1f82,0x1f8a,0x1f03,0x3b9,0,0x1f83,0x1f8b,0x1f04,
0x3b9,0,0x1f84,0x1f8c,0x1f05,0x3b9,0,0x1f85,0x1f8d,0x1f06,0x3b9,0,0x1f86,0x1f8e,0x1f07,0x3b9,
0,0x1f87,0x1f8f,0x1f20,0x3b9,0,0x1f90,0x1f98,0x1f21,0x3b9,0,0x1f91,0x1f99,0x1f22,0x3b9,0,
0x1f92,0x1f9a,0x1f23,0x3b9,0,0x1f93,0x1f9b,0x1f24,0x3b9,0,0x1f94,0x1f9c,0x1f25,0x3b9,0,0x1f95,
0x1f9d,0x1f26,0x3b9,0,0x1f96,0x1f9e,0x1f27,0x3b9,0,0x1f97,0x1f9f,0x1f60,0x3b9,0,0x1fa0,0x1fa8,
0x1f61,0x3b9,0,0x1fa1,0x1fa9,0x1f62,0x3b9,0,0x1fa2,0x1faa,0x1f63,0x3b9,0,0x1fa3,0x1fab,0x1f64,
0x3b9,0,0x1fa4,0x1fac,0x1f65,0x3b9,0,0x1fa5,0x1fad,0x1f66,0x3b9,0,0x1fa6,0x1fae,0x1f67,0x3b9,
0,0x1fa7,0x1faf,0x1f70,0x3b9,0,0x1fb2,0,0x1f74,0x3b9,0,0x1fc2,0,0x1f7c,0x3b9,0,
0x1ff2,0
};
static const UCaseProps ucase_props_singleton={
NULL,
ucase_props_indexes,
ucase_props_exceptions,
ucase_props_unfold,
{
ucase_props_trieIndex,
ucase_props_trieIndex+2884,
NULL,
2884,
6800,
0x188,
0xbc0,
0x0,
0x0,
0xe0800,
0x25d0,
NULL, 0, FALSE, FALSE, 0, NULL
},
{ 3,0,0,0 }
};
|
TernenceHsu/harfbuzz-icu-freetype
|
config.h
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#ifdef HAVE_STUB_GETENV
// Stub out getenv as not all platforms support it
#define getenv(name) 0
#endif // HAVE_STUB_GETENV
|
TernenceHsu/harfbuzz-icu-freetype
|
icu/common/uchar_props_data.h
|
/*
* Copyright (C) 1999-2013, International Business Machines
* Corporation and others. All Rights Reserved.
*
* file name: uchar_props_data.h
*
* machine-generated by: icu/tools/unicode/c/genprops/corepropsbuilder.cpp
*/
#ifndef INCLUDED_FROM_UCHAR_C
# error This file must be #included from uchar.c only.
#endif
static const UVersionInfo dataVersion={6,3,0,0};
static const uint16_t propsTrie_index[17928]={
0x3dc,0x3e4,0x3ec,0x3f4,0x40c,0x414,0x41c,0x424,0x42c,0x434,0x43a,0x442,0x44a,0x452,0x45a,0x462,
0x468,0x470,0x478,0x480,0x483,0x48b,0x493,0x49b,0x4a3,0x4ab,0x4a7,0x4af,0x4b7,0x4bf,0x4c4,0x4cc,
0x4d4,0x4dc,0x4e0,0x4e8,0x4f0,0x4f8,0x500,0x508,0x506,0x50e,0x513,0x51b,0x521,0x529,0x531,0x539,
0x541,0x549,0x551,0x559,0x55e,0x566,0x569,0x571,0x579,0x581,0x587,0x58f,0x58e,0x596,0x59e,0x5a6,
0x5b6,0x5ae,0x5be,0x3fc,0x3fc,0x5c6,0x3fc,0x5cd,0x5dd,0x5df,0x5e7,0x5d5,0x5f7,0x5fd,0x605,0x5ef,
0x615,0x61b,0x623,0x60d,0x633,0x639,0x641,0x62b,0x5f7,0x651,0x659,0x649,0x661,0x669,0x671,0x678,
0x688,0x68e,0x696,0x680,0x6a6,0x6ac,0x6b4,0x69e,0x6a6,0x6c3,0x6cb,0x6bc,0x6d9,0x6e0,0x6e8,0x6d1,
0x58a,0x6f7,0x6ff,0x3fc,0x6f0,0x707,0x70f,0x3fc,0x717,0x71f,0x727,0x72c,0x734,0x73b,0x743,0x3fc,
0x549,0x74b,0x753,0x75b,0x763,0x4d4,0x773,0x76b,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x779,0x549,0x781,0x777,0x789,0x549,0x785,0x549,0x78f,0x797,0x79f,0x549,0x549,0x7a7,
0x7af,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x7b4,0x7bc,0x549,0x549,0x7c4,0x7cc,0x7d4,0x7dc,0x7e4,0x549,0x7ec,0x7f4,0x7fc,
0x80c,0x549,0x814,0x816,0x549,0x804,0x549,0x81e,0x832,0x826,0x82e,0x83a,0x549,0x842,0x84a,0x852,
0x85a,0x549,0x86a,0x872,0x87a,0x862,0x3fc,0x3fc,0x88a,0x88d,0x895,0x882,0x8a5,0x89d,0x549,0x8ac,
0x549,0x8bb,0x8b4,0x8c3,0x3fc,0x3fc,0x8cb,0x8d3,0x47c,0x8db,0x8de,0x8e4,0x8eb,0x8de,0x4a3,0x8f3,
0x42c,0x42c,0x42c,0x42c,0x8fb,0x42c,0x42c,0x42c,0x90b,0x913,0x91b,0x923,0x92b,0x92f,0x937,0x903,
0x94f,0x957,0x93f,0x947,0x95f,0x967,0x96e,0x976,0x98e,0x97e,0x986,0x996,0x99e,0x9ad,0x9b2,0x9a5,
0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9c2,0x9ca,0x852,0x9cd,0x9d5,0x9dc,0x9e1,0x9e9,
0x852,0x9f1,0x9f9,0xa09,0xa0c,0x852,0x852,0xa01,0x852,0x852,0x852,0x852,0x852,0xa1b,0xa23,0xa13,
0x852,0x852,0x852,0xa28,0x852,0x852,0x852,0x852,0xa30,0x852,0x852,0xa36,0xa3e,0x852,0xa46,0xa4d,
0x852,0x852,0x852,0x852,0x852,0x852,0x852,0x852,0x9ba,0x9ba,0x9ba,0x9ba,0xa55,0x9ba,0xa5c,0xa63,
0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x852,0xa6b,0xa72,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x4d4,0xa82,0xa7a,0xa8a,0x42c,0x42c,0x42c,0xa92,0x47c,0xa9a,0x549,0xaa0,0xab0,0xaa8,0xaa8,0x4a3,
0xab8,0xac0,0x3fc,0x3fc,0xac8,0x852,0x852,0xacf,0x852,0x852,0x852,0x852,0x852,0x852,0xad7,0xadd,
0xaed,0xae5,0x58a,0x549,0xaf5,0x7af,0x549,0xafd,0xb05,0xb0a,0x549,0x549,0xb0f,0x535,0x852,0xb16,
0xb1e,0xb26,0xb2c,0x852,0xb26,0xb34,0x852,0xb1e,0x852,0x852,0x852,0x852,0x852,0x852,0x852,0x852,
0xb3c,0x549,0x549,0x549,0xb44,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0xb4a,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xb4f,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x81e,0x852,0x852,
0xb57,0x549,0xb5a,0x549,0xb62,0xb68,0xb70,0xb78,0xb7d,0x549,0x549,0xb81,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xb88,0x549,0xb8f,0xb95,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xb9d,0x549,0x549,0x549,0xba5,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0xba7,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbae,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0xbb5,0x549,0x549,0x549,0xbbc,0xbc4,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbc9,0x549,0x549,0xbd1,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbd5,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbd8,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbdb,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0xbe1,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0xbe9,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0xbee,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0xbf3,0x549,0x549,0x549,0xbf8,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0xc00,0xc07,0xc0b,0x549,0x549,0x549,0xc12,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xc18,0x3fc,
0xc28,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0xc20,0x852,0xc30,0x8c3,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0xc35,0xc3d,0x42c,0xc4d,0xc45,0x549,0x549,0xc55,0xc5d,0xc65,0x42c,0xc6a,0xc72,0xc7a,0x3fc,0xc7d,
0xc85,0xc8d,0x549,0xc95,0xca5,0xca8,0xc9d,0xcb0,0x59e,0xcb8,0xcbf,0x832,0x5dd,0xccf,0xcc7,0x3fc,
0x549,0xcd7,0xcdf,0xce7,0x549,0xcef,0xcf7,0xcff,0xd07,0xd0f,0x3fc,0x3fc,0x3fc,0x3fc,0x549,0xd17,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xd1f,0xd26,0x815,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,
0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,
0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0xd36,0x549,0x549,0x549,0xd3e,0x549,0xc13,0xd45,0xd4a,
0x549,0x549,0x549,0xd52,0x549,0x549,0xd56,0x3fc,0xd6e,0xd5e,0xd66,0x549,0x549,0xd76,0xd7e,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xd83,0x866,0x549,0xd8b,0x549,0xd91,0xd95,
0xd9d,0xda5,0xdac,0xdb4,0x549,0x549,0x549,0xdba,0xdd2,0x3ec,0xdda,0xde2,0xde7,0xdef,0xdc2,0xdca,
0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,
0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,0xd2e,
0xff0,0xff0,0x1030,0x1070,0x10b0,0x10e8,0x1128,0x1168,0x11a0,0x11e0,0x120c,0x124c,0x128c,0x129c,0x12dc,0x1310,
0x1350,0x1380,0x13c0,0x1400,0x1418,0x144c,0x1484,0x14c4,0x1504,0x1544,0x1578,0x15a4,0x15e4,0x161c,0x1638,0x1678,
0xa80,0xac0,0xb00,0xa40,0xb40,0xa40,0xb80,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbc0,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xc00,0xa40,0xa40,0xa40,0xc40,0xa40,0xa40,0xc80,0xcc0,0xa40,
0xd00,0xd37,0x1db,0x1db,0xd5b,0xd8f,0x1db,0xdb7,0x1db,0x1db,0x1db,0x1db,0xde4,0x1db,0x1db,0x1db,
0x1db,0x1db,0x1db,0x1db,0xdf8,0x1db,0xe30,0xe70,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xeb0,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xef0,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,
0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0xf30,
0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,
0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0x700,0xf30,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0xdf7,0xdfe,0xe06,0x3fc,0x549,0x549,0x549,0x535,0xe16,0xe0e,0xe2d,0xe1e,0xe25,0x3fc,0xe35,0xe39,
0x3fc,0x3fc,0x3fc,0x3fc,0x832,0x549,0xe41,0x3fc,0xdef,0xe49,0xe51,0x3fc,0xe59,0x549,0xe61,0x3fc,
0x4d4,0x4de,0x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,0x549,0xf4d,0x3fc,0x3fc,0x3fc,0x3fc,
0xf5d,0xf65,0xf6d,0xf55,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0xf4d,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0xf75,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x549,0x549,0xf7a,0xf7f,0xf87,0x3fc,0x3fc,0x3fc,
0xf8f,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc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,0x10ae,0x852,0x1094,0x10b2,0x3fc,0x3fc,0x10b9,
0x10c1,0x10b2,0x10c7,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x852,0x10cf,0x852,0x10d5,0xacf,0x852,0x10dd,0x10e5,
0x852,0xb1e,0x10ed,0x852,0x852,0x852,0x852,0x10ef,0x852,0xfb0,0xad3,0x10f7,0x3fc,0x3fc,0x3fc,0x10f9,
0x852,0x852,0x1101,0x3fc,0x852,0x852,0x1109,0x3fc,0x852,0x852,0x852,0xacf,0x3fc,0x3fc,0x3fc,0x3fc,
0x1111,0x549,0x549,0x1118,0x549,0x549,0x549,0x1120,0x549,0x1128,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0xbb9,0x549,0x549,0x1130,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x1138,0x1140,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xbf8,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x1147,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x114e,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x1155,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0xab0,0x3fc,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,
0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x549,0x7a7,0x549,0x549,0x549,0x549,0x549,0x549,
0xe6d,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,
0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3fc,0x3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,1,1,0,0,2,2,2,2,
2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,
2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,
2,2,0,0,1,1,1,1,1,1,0,0,2,2,2,2,
2,2,2,2,0,1,0,1,0,1,0,1,2,2,2,2,
2,2,2,2,1,1,1,1,1,1,1,1,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,0,0,2,2,2,2,
2,2,2,2,3,3,3,3,3,3,3,3,2,2,2,2,
2,2,2,2,3,3,3,3,3,3,3,3,2,2,2,2,
2,0,2,2,1,1,1,1,3,0x1a,2,0x1a,0x1a,0x1a,2,2,
2,0,2,2,1,1,1,1,3,0x1a,0x1a,0x1a,2,2,2,2,
0,0,2,2,1,1,1,1,0,0x1a,0x1a,0x1a,0x16,0x17,0x17,0x17,
0x18,0x14,0x15,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x18,0x17,
0x16,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0x17,0xc,0x10,0x10,0x10,0x10,
0x10,0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x2cb,4,0,0,
0x3cb,0x40b,0x44b,0x48b,0x4cb,0x50b,0x18,0x18,0x18,0x14,0x15,4,0xc,0xc,0xc,0xc,
0xc,0xc,0xc,0xc,0xc,0xc,0xc,0x10,0x10,0x10,0x10,0x10,0x13,0x13,0x13,0x13,
0x13,0x13,0x17,0x17,0x1c,0x1d,0x14,0x1c,0x1c,0x1d,0x14,0x1c,0x17,0x17,0x17,0x17,
0x17,0x17,0x17,0x17,0xd,0xe,0x10,0x10,0x10,0x10,0x10,0xc,0x17,0x17,0x17,0x17,
0x17,0x17,0x17,0x17,0x17,0x1c,0x1d,0x17,0x17,0x17,0x17,0x16,0x2cb,0x30b,0x34b,0x38b,
0x3cb,0x40b,0x44b,0x48b,0x4cb,0x50b,0x18,0x18,0x18,0x14,0x15,0,4,4,4,4,
4,4,4,4,4,4,4,4,4,0,0,0,0x19,0x19,0x19,0x19,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,0x19,
0x19,0x19,0x19,0x19,0x19,0x19,0x19,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,6,6,6,6,6,6,6,6,
6,6,6,6,6,7,7,7,7,6,7,7,7,6,6,6,
6,6,6,6,6,6,6,6,6,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0x1b,0x1b,0x1b,0x1b,1,0x1b,1,0x1b,
1,0x1b,1,1,1,1,0x1b,2,1,1,1,1,2,5,5,5,
5,2,0x1b,0x1b,2,2,1,1,0x18,0x18,0x18,0x18,0x18,1,2,2,
2,2,0x1b,0x18,0x1b,0x1b,2,0x1b,0x358b,0x360b,0x364b,0x348b,0x388b,0x350b,0x390b,0x3d0b,
0x410b,0x354b,0x454b,0x35cb,0x3dcb,0x45cb,0x4dcb,0x58b,0x1b,0x1b,1,0x1b,0x1b,0x1b,0x1b,1,
0x1b,0x1b,2,1,1,1,2,2,1,1,1,2,0x1b,1,0x1b,0x1b,
0x18,1,1,1,1,1,0x1b,0x1b,0x58a,0x5ca,0x60a,0x64a,0x68a,0x6ca,0x70a,0x74a,
0x78a,0x7ca,0x80a,0x84a,0x11ca,0x1e4a,0x980a,0x784a,0x58a,0x5ca,0x60a,0x64a,0x68a,0x6ca,0x70a,0x74a,
0x78a,0x7ca,0x80a,0x84a,0x11ca,0x1e4a,0x980a,0x784a,0x784a,0x984a,0x788a,1,2,0x6ca,0x11ca,0x988a,
0x78ca,0x54b,0,0,0,0,0,0,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x1b,
0x1b,0x1b,0x18,0x18,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x18,0x18,0x18,0x18,0x18,0x18,0x18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,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x14,0x15,0x14,0x15,0x14,0x15,0x14,0x15,0x14,
0x15,0x14,0x15,0x14,0x15,0x14,0x15,0x14,0x15,0x14,0x15,0x14,0x15,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x14,0x15,0x14,0x15,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x14,0x15,0x18,0x18,0x1b,0x1b,0x1b,0x1b,
0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x18,0x18,0x18,0x18,
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1b,0x1b,0x18,
0x18,0x18,0x18,0x18,0x18,0,0,0,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
0x1b,0x1b,0,0,0,0,0,0,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,0,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,0,2,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,1,2,1,1,1,2,2,1,
2,1,2,1,2,1,1,1,1,2,1,2,2,1,2,2,
2,2,2,2,4,4,1,1,1,2,1,2,2,0x1b,0x1b,0x1b,
0x1b,0x1b,0x1b,1,2,1,2,6,6,6,1,2,0,0,0,0,
0,0x17,0x17,0x17,0x17,0x344b,0x17,0x17,2,2,2,2,2,2,0,2,
0,0,0,0,0,2,0,0,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,0,0,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14,0x15,0x14,0x15,0x14,0x15,0x14,
0x15,0x14,0x15,0x14,0x15,0x17,0x17,0x14,0x15,0x17,0x17,0x17,0x17,0x16,0x16,0x16,
0x17,0x17,0x17,0,0x17,0x17,0x17,0x17,0x13,0x14,0x15,0x14,0x15,0x14,0x15,0x17,
0x17,0x17,0x18,0x13,0x18,0x18,0x18,0,0x17,0x19,0x17,0x17,0,0,0,0,
5,5,5,5,5,0,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,0,0,0x10,0,0,5,5,5,5,5,5,
0,0,5,5,5,5,5,5,0,0,5,5,5,5,5,5,
0,0,5,5,5,0,0,0,0x19,0x19,0x18,0x1a,0x1b,0x19,0x19,0,
0x1b,0x18,0x18,0x18,0x18,0x1b,0x1b,0,0,0,0,0,0,0,0,0,
0,0x10,0x10,0x10,0x1b,0x1b,0,0,0,0x17,0x17,0x17,0x19,0x17,0x17,0x17,
0x14,0x15,0x17,0x18,0x17,0x13,0x17,0x17,0x49,0x89,0xc9,0x109,0x149,0x189,0x1c9,0x209,
0x249,0x289,0x17,0x17,0x18,0x18,0x18,0x17,0x1a,2,2,2,2,2,2,2,
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
2,2,2,0x14,0x18,0x15,0x18,0x14,0x15,0x17,0x14,0x15,0x17,0x17,5,5,
5,5,5,5,5,5,5,5,4,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,4,4,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,0,5,5,5,5,
5,5,5,5,5,5,5,5,0,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,0,5,5,0,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,0,0,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,0,0,0xb00b,0xb80b,0x784b,0x804b,0x884b,0x904b,0x984b,0xa04b,
0xa84b,0xb04b,0xb84b,0x788b,0x808b,0x888b,0x908b,0x988b,0xa08b,0xa88b,0xb08b,0xb88b,0,0,0,0x1b,
0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x17,0x17,0x17,0,0,0,0,0x58b,
0x5cb,0x60b,0x64b,0x68b,0x6cb,0x70b,0x74b,0x78b,0x7cb,0xa4b,0xccb,0xf4b,0x11cb,0x144b,0x16cb,0x194b,
0x1bcb,0x1e4b,0x800b,0x880b,0x900b,0x980b,0xa00b,0xa80b,0x7ca,0x7ca,0x7ca,0x7ca,0x7ca,0xcca,0x11ca,0x11ca,
0x11ca,0x11ca,0x1e4a,0x880a,0x980a,0x980a,0x980a,0x980a,0x980a,0x784a,0x984a,0x68a,0x11ca,0x344b,0x344b,0x388b,
0x3ccb,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x54b,0,
0,0,0,0,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
0,0,0,0,0x34ca,0x344a,0x58a,0x68a,0x11ca,0x980a,0x984a,0x988a,0x68a,0x7ca,0x11ca,0x1e4a,
0x980a,0x784a,0x984a,0x68a,0x7ca,0x11ca,0x1e4a,0x980a,0x784a,0x788a,0x988a,0x7ca,0x58a,0x58a,0x58a,0x5ca,
0x5ca,0x5ca,0x5ca,0x68a,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,
0x1b,6,0,0,5,5,5,5,5,5,5,5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,6,6,6,6,6,6,
6,6,6,6,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,0x11,
0x11,0x11,0,0,0,0,0,0
};
static const UTrie2 propsTrie={
propsTrie_index,
propsTrie_index+3952,
NULL,
3952,
13976,
0xa40,
0xff0,
0x0,
0x0,
0x110000,
0x4604,
NULL, 0, FALSE, FALSE, 0, NULL
};
static const uint16_t propsVectorsTrie_index[23412]={
0x408,0x410,0x418,0x420,0x438,0x440,0x448,0x450,0x458,0x460,0x468,0x470,0x478,0x480,0x488,0x490,
0x497,0x49f,0x4a7,0x4af,0x4b2,0x4ba,0x4c2,0x4ca,0x4d2,0x4da,0x4e2,0x4ea,0x4f2,0x4fa,0x502,0x50a,
0x512,0x51a,0x521,0x529,0x531,0x539,0x541,0x549,0x551,0x559,0x55e,0x566,0x56d,0x575,0x57d,0x585,
0x58d,0x595,0x59d,0x5a5,0x5ac,0x5b4,0x5bc,0x5c4,0x5cc,0x5d4,0x5dc,0x5e4,0x5ec,0x5f4,0x5fc,0x604,
0x15ad,0xc5f,0xd47,0x428,0x428,0xdfb,0xdff,0xe06,0xeee,0xefe,0xef6,0x674,0x67c,0x682,0x68a,0x692,
0x69a,0x6a0,0x6a8,0x6b0,0x6b8,0x6be,0x6c6,0x6ce,0x6d6,0x6dc,0x6e4,0x6ec,0x6f4,0x6fc,0x704,0x70b,
0x713,0x719,0x721,0x729,0x731,0x737,0x73f,0x747,0x74f,0x755,0x75d,0x765,0x76d,0x774,0x77c,0x784,
0x78c,0x790,0x798,0x79f,0x7a7,0x7af,0x7b7,0x7bf,0x11f0,0x11f8,0x7c7,0x7cf,0x7d7,0x7df,0x7e7,0x7ee,
0x1256,0x1246,0x124e,0x150a,0x1512,0xf0e,0x7f6,0xf06,0x113d,0x113d,0x113f,0xf22,0xf23,0xf16,0xf18,0xf1a,
0x125e,0x1260,0x7fe,0x1260,0x806,0x80b,0x813,0x1265,0x819,0x1260,0x81f,0x827,0xb28,0x126d,0x126d,0x82f,
0x127d,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,0x127e,
0x127e,0x127e,0x127e,0x1275,0x837,0x1286,0x1286,0x83f,0xa4f,0xa57,0xa5f,0xa67,0x1296,0x128e,0x847,0x84f,
0x857,0x129e,0x12a6,0x85f,0x129e,0x867,0x15b5,0xc67,0xa6f,0xa77,0xa7f,0xa84,0x1485,0xb5b,0xb63,0x13ed,
0xaf8,0x15bd,0xc6f,0xc77,0xc7f,0x60c,0x428,0x428,0x14d5,0x14da,0xb9a,0xba2,0x152e,0x1536,0x164e,0xd4f,
0x153e,0xbeb,0xbf3,0x1546,0x428,0x428,0xe8e,0xc87,0x140d,0x13f5,0x1405,0x13fd,0x149d,0x1495,0x145d,0xb08,
0xf2b,0xf2b,0xf2b,0xf2b,0xf2e,0xf2b,0xf2b,0xf36,0x86f,0xf3e,0x873,0x87b,0xf3e,0x883,0x88b,0x893,
0xf4e,0xf46,0xf56,0x89b,0x8a3,0x8ab,0x8b2,0x8ba,0xf5e,0xf66,0xf6e,0xf76,0x8c2,0xf7e,0xf85,0xf8d,
0xf95,0xf9d,0xfa5,0xfad,0xfb5,0xfbc,0xfc4,0xfcc,0xfd4,0xfdc,0xfdf,0xfe1,0x12ae,0x1383,0x1389,0x8ca,
0xfe9,0x8d2,0x8da,0x10f2,0x10f7,0x10fa,0x1100,0xff1,0x1108,0x1108,0x1001,0xff9,0x1009,0x1011,0x1019,0x1021,
0x1029,0x1031,0x1039,0x1041,0x1391,0x13e5,0x151a,0x1636,0x8e2,0x104f,0x1057,0x105f,0x1049,0x1067,0x1399,0x13a0,
0x12b6,0x12b6,0x12b6,0x12b6,0x12b6,0x12b6,0x12b6,0x12b6,0x13a8,0x13a8,0x13a8,0x13a8,0x13b0,0x13b7,0x13b9,0x13c0,
0x13c8,0x13cc,0x13cc,0x13cf,0x13cc,0x13cc,0x13d5,0x13cc,0x1415,0x14cd,0xa8c,0xa93,0xa93,0xa93,0xa93,0xa93,
0x1475,0xb38,0xb3c,0x14e2,0x1465,0x1465,0x1465,0xb10,0x146d,0xb30,0x14b5,0xb8a,0xb18,0xb20,0xb20,0x154e,
0x14a5,0xb73,0xb7a,0xb7a,0x8ea,0x12be,0x12be,0x8f2,0x12c6,0x12c6,0x12c6,0x12c6,0x12c6,0x12c6,0x8fa,0x610,
0x1125,0x1147,0x902,0x114f,0x90a,0x1157,0x115f,0x1167,0x912,0x917,0x116f,0x1176,0x91c,0x924,0x14c5,0xb00,
0x92c,0x11cd,0x11d4,0x117e,0x11dc,0x11e0,0x1186,0x934,0x119f,0x119f,0x11a1,0x118e,0x1196,0x1196,0x1197,0x11e8,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,
0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0x12ce,0xea7,0x141d,0x141d,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,
0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11a9,0x11b0,0xeaf,0xeb3,
0x12d6,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,
0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,0x12dc,
0x12dc,0x12dc,0x12dc,0x12dc,0x93c,0x12e4,0x944,0x15c5,0x155a,0x155a,0x155a,0x155a,0x155a,0x155a,0x155a,0x155a,
0x1556,0xbfb,0x156a,0x1562,0xc03,0x15cd,0x15cd,0xc8f,0x147d,0x14ea,0x1522,0x1526,0xbaa,0xbb2,0xbb5,0xbb7,
0x14ad,0xb82,0x14f2,0xbbf,0x1572,0x1575,0xc0b,0xc97,0x1585,0x157d,0xc13,0xc9f,0x15d5,0x15d9,0xca7,0x428,
0x158d,0xc1b,0xc23,0xcaf,0x15e9,0x15e1,0xcb7,0xe51,0xd57,0x618,0x428,0x428,0x428,0x428,0x15f1,0xcbf,
0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,
0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,
0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,
0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,
0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,
0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,
0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,
0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,
0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,
0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,
0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,
0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,
0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,
0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,
0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,
0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,
0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,
0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,
0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,
0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,
0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,
0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x123e,0x1238,0x1239,0x123a,0x123b,0x123c,0x123d,0x94c,0xcc7,0xcca,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,
0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,0x1210,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,
0x11bd,0x11c5,0x13dd,0xebb,0x14bd,0x14bd,0xebf,0xec6,0x954,0x95c,0x964,0x1087,0x108e,0x1096,0x96c,0x109e,
0x10cf,0x10cf,0x1077,0x107f,0x10a6,0x10c6,0x10c7,0x10d7,0x10ae,0x106f,0x974,0x10b6,0x97c,0x10be,0x984,0x988,
0xb92,0x990,0x998,0x9a0,0x10df,0x10e5,0x10ea,0x9a8,0x9b8,0x112d,0x1135,0x1118,0x111d,0x9c0,0x9c8,0x9b0,
0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,
0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1200,0x1208,0x1208,0x1208,0x1208,
0x10a0,0x10a0,0x10e0,0x1120,0x1160,0x11a0,0x11e0,0x1220,0x125c,0x129c,0x12c8,0x1308,0x1348,0x1388,0x13c8,0x1408,
0x1448,0x1484,0x14c4,0x1504,0x1544,0x1578,0x15b4,0x15f4,0x1634,0x1674,0x16b0,0x16f0,0x1730,0x1770,0x17b0,0x17f0,
0xa80,0xac0,0xb00,0xa40,0xc8c,0xa40,0xb40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xccc,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xd0c,0xa40,0xa40,0xa40,0xb80,0xa40,0xa40,0xd1c,0xbc0,0xbfc,
0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,0xf9d,
0xf9d,0xf9d,0xf9d,0xf9d,0xd5c,0xfdd,0xe5d,0xd9c,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xddd,
0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,
0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xd9d,0xe1d,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xc3c,0xc4c,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,
0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xa40,0xbfc,
0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,
0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xf1d,0xe9d,
0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,
0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xf5d,0xedd,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0xa9b,0xaa2,0xaaa,0xab2,0x1425,0x1425,0x1425,0xaba,0xac2,0xac5,0x1455,0x144d,0xaf0,0xc2b,0xc2f,0xc33,
0x428,0x428,0x428,0x428,0xc3b,0x1595,0xc43,0x428,0x9d0,0x9d8,0x620,0x428,0xacd,0x148d,0xb6b,0x428,
0x12f9,0x12ec,0x12f1,0x142d,0xad5,0x628,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0xadd,0xae0,0xcd2,0x428,0x428,0x428,0x428,0x428,0xbc7,0xc4b,0x428,0x428,0x16b8,0xe59,0xe61,0xe61,
0xb44,0xb4b,0xb53,0x15f9,0x428,0x428,0x428,0x428,0x1601,0xcda,0xce2,0xcea,0x428,0x428,0x428,0x428,
0x1609,0x1609,0x630,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0xcf2,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x1656,0x1658,0xd5f,0xd66,0x1619,0x1611,0xcfa,0xe86,0x16b0,0xe49,0x638,0x428,0x16c8,0x16cc,0xe7e,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x16d4,0xe96,0x640,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,
0x1621,0x1621,0x1623,0x1621,0x162b,0x1621,0x1621,0x1621,0x1621,0x1621,0x1621,0x162e,0x1621,0x1621,0x1621,0x1621,
0x1621,0x648,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x1301,0x1301,0x1301,0x1301,0x1301,0x1301,0x1301,0x9e0,0x1311,0x9e8,0x1312,0x1309,0x131a,0x1320,0x9f0,0x9f8,
0x1445,0x1445,0x650,0x428,0x428,0x428,0x428,0x428,0x1435,0x1435,0xae8,0xbe3,0x428,0x428,0x428,0x428,
0x1351,0x1358,0xa00,0x135b,0xa08,0xa10,0xa18,0x1355,0xa20,0xa28,0xa30,0x135a,0x1362,0x1351,0x1358,0x1354,
0x135b,0x1363,0x1352,0x1359,0x1355,0xa37,0x1328,0x1330,0x1337,0x133e,0x132b,0x1333,0x133a,0x1341,0xa3f,0x1349,
0x159d,0xc53,0x15a5,0x15a5,0xc57,0xd7f,0xd87,0xd8f,0xd02,0xd08,0x163e,0xd10,0xd18,0xd1f,0xd1f,0xd26,
0xd2e,0xd32,0xd3a,0xd3f,0xd3f,0xd3f,0xd3f,0xd3f,0x1680,0xd97,0x1680,0xd9d,0xda5,0x1668,0xdad,0xdb5,
0x1680,0xdbd,0xdc5,0x1680,0x1680,0x1670,0x1680,0xdc7,0x1678,0xdcf,0xdd7,0xddd,0xddf,0xddf,0xddf,0xde1,
0x1688,0x1690,0x658,0x428,0x1698,0x1698,0xde9,0xdeb,0x16a0,0x16a0,0x16a0,0xdf3,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x65c,0xa47,0x136b,0x136b,0x136b,
0x664,0x664,0x664,0x664,0x143d,0x143d,0x143d,0x143d,0x143d,0x143d,0x143d,0x66c,0x664,0x664,0x664,0x664,
0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,
0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,
0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,
0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x664,0x14fa,0x14fa,0x14fa,0x14fa,
0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,
0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0x14fa,0xbcf,0xbd3,0xbd3,0xbd3,0xbd3,0x1502,0x1502,0x1502,0xbdb,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x1660,0x1660,0x1660,0x1660,
0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0x1660,0xd6e,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x16c0,0x16c0,0xe69,0xe6e,0xe76,0x428,0x428,0x428,0xd76,0xd77,0xd77,0xd77,
0xd77,0xd77,0xd77,0xd77,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,
0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0xe0e,0xe16,0xe1e,0xe26,
0xe2e,0xe36,0xe3d,0xe41,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x428,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0xece,0xe9e,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0xee6,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0x137b,0x137b,0x137b,
0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0x137b,0xed6,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9f,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,
0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9e,0xe9f,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0xede,0x16a8,0x16a8,0x16a8,0x16a8,0x16a8,0x16a8,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1218,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1220,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,
0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1228,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,
0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1373,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,
0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x1646,0x407,0x407,0x407,
0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f8,0x201,0x1fb,0x1fb,0x1fe,0x1f5,0x1f5,
0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,0x1f5,
0x6fc,0x6f6,0x6db,0x6c0,0x6cc,0x6c9,0x6c0,0x6d8,0x6c6,0x6d2,0x6c0,0x6ed,0x6e4,0x6d5,0x6f9,0x6cf,
0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6bd,0x6e1,0x6de,0x6e7,0x6e7,0x6e7,0x6f6,
0x6c0,0x708,0x708,0x708,0x708,0x708,0x708,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,
0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x702,0x6c6,0x6cc,0x6d2,0x6f3,0x6ba,
0x6f0,0x705,0x705,0x705,0x705,0x705,0x705,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,
0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6ff,0x6c6,0x6ea,0x6c3,0x6e7,0x1f5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x204,0x204,0x204,0x204,0x204,0x213,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,
0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,0x204,
0x207,0x56d,0x711,0x714,0x573,0x714,0x70e,0x567,0x55e,0x20d,0x57c,0x210,0x717,0x555,0x56a,0x70b,
0x570,0x579,0x55b,0x55b,0x561,0x20a,0x567,0x564,0x55e,0x55b,0x57c,0x210,0x558,0x558,0x558,0x56d,
0x219,0x219,0x219,0x219,0x219,0x219,0x585,0x219,0x219,0x219,0x219,0x219,0x219,0x219,0x219,0x219,
0x585,0x219,0x219,0x219,0x219,0x219,0x219,0x576,0x585,0x219,0x219,0x219,0x219,0x219,0x585,0x57f,
0x582,0x582,0x216,0x216,0x216,0x216,0x57f,0x216,0x582,0x582,0x582,0x216,0x582,0x582,0x216,0x216,
0x57f,0x216,0x582,0x582,0x216,0x216,0x216,0x576,0x57f,0x582,0x582,0x216,0x582,0x216,0x57f,0x216,
0x225,0x58b,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,
0x222,0x588,0x225,0x58b,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x58b,0x225,0x21c,0x225,0x21c,
0x225,0x21c,0x225,0x21c,0x225,0x21c,0x591,0x588,0x225,0x21c,0x225,0x58b,0x225,0x21c,0x225,0x21c,
0x225,0x588,0x594,0x58e,0x225,0x21c,0x225,0x21c,0x588,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x594,
0x58e,0x591,0x588,0x225,0x58b,0x225,0x21c,0x225,0x58b,0x597,0x591,0x588,0x225,0x58b,0x225,0x21c,
0x225,0x21c,0x591,0x588,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,
0x225,0x21c,0x225,0x21c,0x225,0x21c,0x591,0x588,0x225,0x21c,0x225,0x58b,0x225,0x21c,0x225,0x21c,
0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x225,0x225,0x21c,0x225,0x21c,0x225,0x21c,0x21f,
0x228,0x234,0x234,0x228,0x234,0x228,0x234,0x234,0x228,0x234,0x234,0x234,0x228,0x228,0x234,0x234,
0x234,0x234,0x228,0x234,0x234,0x228,0x234,0x234,0x234,0x228,0x228,0x228,0x234,0x234,0x228,0x234,
0x237,0x22b,0x234,0x228,0x234,0x228,0x234,0x234,0x228,0x234,0x228,0x228,0x234,0x228,0x234,0x237,
0x22b,0x234,0x234,0x234,0x228,0x234,0x228,0x234,0x234,0x228,0x228,0x231,0x234,0x228,0x228,0x228,
0x231,0x231,0x231,0x231,0x23a,0x23a,0x22e,0x23a,0x23a,0x22e,0x23a,0x23a,0x22e,0x237,0x59a,0x237,
0x59a,0x237,0x59a,0x237,0x59a,0x237,0x59a,0x237,0x59a,0x237,0x59a,0x237,0x59a,0x228,0x237,0x22b,
0x237,0x22b,0x237,0x22b,0x234,0x228,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,
0x22b,0x23a,0x23a,0x22e,0x237,0x22b,0x8c4,0x8c4,0x8c7,0x8c1,0x237,0x22b,0x237,0x22b,0x237,0x22b,
0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,0x237,0x22b,
0x237,0x22b,0x237,0x22b,0x8c7,0x8c1,0x8c7,0x8c1,0x8c4,0x8be,0x8c7,0x8c1,0xa7a,0xb70,0x8c4,0x8be,
0x8c4,0x8be,0x8c7,0x8c1,0x8c7,0x8c1,0x8c7,0x8c1,0x8c7,0x8c1,0x8c7,0x8c1,0x8c7,0x8c1,0x8c7,0x8c1,
0xb70,0xb70,0xb70,0xc5d,0xc5d,0xc5d,0xc60,0xc60,0xc5d,0xc60,0xc60,0xc5d,0xc5d,0xc60,0xd9b,0xd9e,
0xd9e,0xd9e,0xd9e,0xd9b,0xd9e,0xd9b,0xd9e,0xd9b,0xd9e,0xd9b,0xd9e,0xd9b,0x23d,0x59d,0x23d,0x23d,
0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x59d,0x23d,0x23d,
0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,
0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x240,0x23d,0x23d,0x23d,
0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,0x23d,
0x23d,0x8ca,0x8ca,0x8ca,0x8ca,0x8ca,0xb73,0xb73,0x258,0x258,0x258,0x258,0x258,0x258,0x258,0x258,
0x258,0x24f,0x24f,0x24f,0x24f,0x24f,0x24f,0x24f,0x24c,0x24c,0x243,0x243,0x5a3,0x243,0x24f,0x5a6,
0x252,0x5a6,0x5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,0x282,0x282,6,0x282,6,0x282,0x282,0x279,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,
0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,6,0x5b8,0x5b8,0x5b8,0x5b8,0x5b8,
0x5b8,0x5b8,0x282,0x282,0x279,0x279,0x279,0x279,0x279,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,
0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,0x276,0x5b5,0x5b5,0x5b5,0x5b5,0x5b5,
0x5b5,0x5b5,0x279,0x279,0x279,0x279,0x279,0xe49,0x285,0x285,0x288,0x282,0x282,0x285,0x27c,0x8d6,
0xa83,0xa80,0x27f,0x8d6,0x27f,0x8d6,0x27f,0x8d6,0x27f,0x8d6,0x26a,0x267,0x26a,0x267,0x26a,0x267,
0x26a,0x267,0x26a,0x267,0x26a,0x267,0x26a,0x267,0x285,0x285,0x27c,0x276,0xa35,0xa32,0xa7d,0xb7c,
0xb79,0xb7f,0xb7c,0xb79,0xc63,0xc66,0xc66,0xc66,0x8e5,0x5c4,0x297,0x29a,0x297,0x297,0x297,0x29a,
0x297,0x297,0x297,0x297,0x29a,0x8e5,0x29a,0x297,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,
0x5c1,0x5c4,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,
0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5c1,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,
0x5bb,0x5be,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,0x5bb,
0x5bb,0x5bb,0x5bb,0x5bb,0x8df,0x5be,0x291,0x294,0x291,0x291,0x291,0x294,0x291,0x291,0x291,0x291,
0x294,0x8df,0x294,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,
0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x29a,0x294,0x297,0x291,0x297,0x291,
0x297,0x291,0x297,0x291,0x297,0x291,0x28e,0x28b,0x28b,0x834,0x834,0xe4c,0x8d9,0x8d9,0xa89,0xa86,
0x8e2,0x8dc,0x8e2,0x8dc,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,
0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,
0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,0x297,0x291,
0x297,0x291,0x297,0x291,0x297,0x29a,0x294,0x297,0x291,0xa89,0xa86,0x297,0x291,0xa89,0xa86,0x297,
0x291,0xa89,0xa86,0xda4,0x29a,0x294,0x29a,0x294,0x297,0x291,0x29a,0x294,0x297,0x291,0x29a,0x294,
0x29a,0x294,0x29a,0x294,0x297,0x291,0x29a,0x294,0x29a,0x294,0x29a,0x294,0x297,0x291,0x29a,0x294,
0x8e5,0x8df,0x29a,0x294,0x29a,0x294,0x29a,0x294,0x29a,0x294,0xc6c,0xc69,0x29a,0x294,0xda7,0xda4,
0xda7,0xda4,0xda7,0xda4,0xaef,0xaec,0xaef,0xaec,0xaef,0xaec,0xaef,0xaec,0xaef,0xaec,0xaef,0xaec,
0xaef,0xaec,0xaef,0xaec,0xdd4,0xdd1,0xdd4,0xdd1,0xecd,0xeca,0xecd,0xeca,0xecd,0xeca,0xecd,0xeca,
0xecd,0xeca,0xecd,0xeca,0xecd,0xeca,0xecd,0xeca,0x1026,0x1023,0x11d3,0x11d0,0xba,0xba,0xba,0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xc,0xb82,0xb82,0xb82,0xb82,0x1257,0xf,0xe55,0xe55,0xe55,0xe52,0xe52,0xc7e,
0x7c5,0xb91,0xb8e,0xb8e,0xb85,0xb85,0xb85,0xb85,0xb85,0xb85,0xe4f,0xe4f,0xe4f,0xe4f,0xe4f,0x7c2,
0x132f,0xf,0xc7b,0x7c8,0x119a,0x2df,0x2e2,0x2e2,0x2e2,0x2e2,0x2e2,0x2df,0x2df,0x2df,0x2df,0x2df,
0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0xe58,
0xe58,0xe58,0xe58,0xe58,0x7cb,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x83a,
0x83a,0x83a,0x83a,0x83a,0x83a,0x83a,0x83a,0xa2c,0xa2c,0xa2c,0xb85,0xb8b,0xb88,0xc78,0xc78,0xc78,
0xc78,0xc78,0xc78,0x1197,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x7ce,0x2d9,0x2d6,
0x2d3,0x2d0,0xa8c,0xa8c,0x837,0x2df,0x2df,0x2eb,0x2df,0x2e5,0x2e5,0x2e5,0x2e5,0x2df,0x2df,0x2df,
0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,
0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,
0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,
0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x8ee,0x8ee,0x2df,0x2df,0x2df,0x2df,0x2df,0x8ee,
0x2e2,0x2df,0x2e2,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x2df,0x8ee,
0x2df,0x2df,0x2df,0x2e2,0x2ee,0x2df,0x2ca,0x2ca,0x2ca,0x2ca,0x2ca,0x2ca,0x2ca,0x2c7,0x2d0,0x2cd,
0x2cd,0x2ca,0x2ca,0x2ca,0x2ca,0x2e8,0x2e8,0x2ca,0x2ca,0x2d0,0x2cd,0x2cd,0x2cd,0x2ca,0xb94,0xb94,
0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x2dc,0x8ee,0x8ee,0x8ee,0x8eb,0x8eb,0xb94,
0x906,0x906,0x906,0x900,0x900,0x900,0x900,0x900,0x900,0x900,0x900,0x8fd,0x900,0x8fd,0x12,0x8f1,
0x903,0x8f4,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,
0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0x903,0xb97,0xb97,0xb97,
0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,0x8fa,
0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x8f7,0x12,0x12,0xb97,0xb97,0xb97,
0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,
0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xcde,0xedf,0xedf,
0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,0xedf,
0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,
0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,
0x90c,0x90c,0x90c,0x90c,0x90c,0x90c,0x909,0x909,0x909,0x909,0x909,0x909,0x909,0x909,0x909,0x909,
0x909,0xa8f,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15,
0xdec,0xdec,0xdec,0xdec,0xdec,0xdec,0xdec,0xdec,0xdec,0xdec,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,
0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,
0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xdef,0xde3,0xde3,0xde3,0xde3,0xde3,
0xde3,0xde3,0xde3,0xde3,0xdf2,0xdf2,0xde6,0xde6,0xde9,0xdf8,0xdf5,0x11a,0x11a,0x11a,0x11a,0x11a,
0x1062,0x1062,0x1062,0x1062,0x1062,0x1062,0x1062,0x1071,0x1074,0x1074,0x1074,0x1074,0x1062,0x1062,0x15f,0x15f,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0xa08,0xa08,0xa0b,0xa0b,0xa08,0xa08,0xa08,0xa08,0xa08,0xa08,0xa08,0xa08,0x78,0x78,0x78,0x78,
0x120c,0x120c,0x120c,0x120c,0x120c,0x120c,0x120c,0x1a4,0x120c,0x120c,0x120c,0x120c,0x120c,0x120c,0x120c,0x1a4,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xa41,0xab,0xab,0xab,0xab,0xab,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0xc27,0xc27,0xc27,0xc27,0xc27,0xc27,0xc27,0xc27,0xc27,0xc27,0xde,0xde,0xde,0xde,0xde,0xde,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x18c,0x18c,0x18c,0x18c,0x18c,0x18c,0x18c,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x12b7,0x12c3,0x12c3,0x12c3,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,0x1c5,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x1311,0x1311,0x1311,0x1311,0x1311,0x1311,0x1311,0x1311,0x1311,0x1311,0x1da,0x1da,0x1da,0x1da,0x1da,0x1da,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x195,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0xcd5,0xcd5,0xcd2,0xcd2,0xcd2,0xcd5,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,0xe7,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0x1233,0x1b6,0x1b6,0x1b6,0x1b6,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0x855,0x855,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
0x300,0x300,0x2f1,0x2f1,0x7d1,0x7d1,0x84c,0x84c,0x84c,0x84c,0x84c,0x84c,0x84c,0x84c,0x84c,0x84c,
0x2fa,0xe5e,0xe5b,0x11a3,0x11a3,0x11a3,0x11a3,0x11a3,0x18,0xff6,0xff6,0xdad,0xdad,0xc81,0xdad,0xdad,
0x1b,0x306,0x315,0x315,0x1b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x1b,0x1b,0x31b,
0x31b,0x1b,0x1b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,
0x31b,0x1b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x31b,0x1b,0x31b,0x1b,0x1b,0x1b,0x31b,0x31b,
0x31b,0x31b,0x1b,0x1b,0x309,0xb9d,0x306,0x315,0x315,0x306,0x306,0x306,0x306,0x1b,0x1b,0x315,
0x315,0x1b,0x1b,0x318,0x318,0x30c,0xc84,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x1b,0x306,
0x1b,0x1b,0x1b,0x1b,0x31e,0x31e,0x1b,0x31e,0x31b,0x31b,0x306,0x306,0x1b,0x1b,0x84f,0x84f,
0x84f,0x84f,0x84f,0x84f,0x84f,0x84f,0x84f,0x84f,0x31b,0x31b,0x312,0x312,0x30f,0x30f,0x30f,0x30f,
0x30f,0x312,0x30f,0xff9,0x1b,0x1b,0x1b,0x1b,0x1e,0xba0,0x321,0xba3,0x1e,0x330,0x330,0x330,
0x330,0x330,0x330,0x1e,0x1e,0x1e,0x1e,0x330,0x330,0x1e,0x1e,0x330,0x330,0x330,0x330,0x330,
0x330,0x330,0x330,0x330,0x330,0x330,0x330,0x330,0x330,0x1e,0x330,0x330,0x330,0x330,0x330,0x330,
0x330,0x1e,0x330,0x333,0x1e,0x330,0x333,0x1e,0x330,0x330,0x1e,0x1e,0x324,0x1e,0x32d,0x32d,
0x32d,0x321,0x321,0x1e,0x1e,0x1e,0x1e,0x321,0x321,0x1e,0x1e,0x321,0x321,0x327,0x1e,0x1e,
0x1e,0xe61,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x333,0x333,0x333,0x330,0x1e,0x333,0x1e,
0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x32a,0x32a,0x32a,0x32a,0x32a,0x32a,0x32a,0x32a,0x32a,0x32a,
0x321,0x321,0x330,0x330,0x330,0xe61,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,0x1e,
0x21,0x336,0x336,0x342,0x21,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0xbac,0x345,0x21,0x345,
0x345,0x345,0x21,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x345,
0x345,0x21,0x345,0x345,0x345,0x345,0x345,0x345,0x345,0x21,0x345,0x345,0x21,0x345,0x345,0x345,
0x345,0x345,0x21,0x21,0x339,0x345,0x342,0x342,0x342,0x336,0x336,0x336,0x336,0x336,0x21,0x336,
0x336,0x342,0x21,0x342,0x342,0x33c,0x21,0x21,0x345,0x21,0x21,0x21,0x21,0x21,0x21,0x21,
0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x345,0xbac,0xba6,0xba6,0x21,0x21,0x33f,0x33f,
0x33f,0x33f,0x33f,0x33f,0x33f,0x33f,0x33f,0x33f,0x125a,0xba9,0x21,0x21,0x21,0x21,0x21,0x21,
0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x21,0x24,0x348,0x357,0x357,0x24,0x35d,0x35d,0x35d,
0x35d,0x35d,0x35d,0x35d,0x35d,0x24,0x24,0x35d,0x35d,0x24,0x24,0x35d,0x35d,0x35d,0x35d,0x35d,
0x35d,0x35d,0x35d,0x35d,0x35d,0x35d,0x35d,0x35d,0x35d,0x24,0x35d,0x35d,0x35d,0x35d,0x35d,0x35d,
0x35d,0x24,0x35d,0x35d,0x24,0xbaf,0x35d,0x35d,0x35d,0x35d,0x24,0x24,0x34b,0x35d,0x348,0x348,
0x357,0x348,0x348,0x348,0xe64,0x24,0x24,0x357,0x35a,0x24,0x24,0x35a,0x35a,0x34e,0x24,0x24,
0x24,0x24,0x24,0x24,0x24,0x24,0x348,0x348,0x24,0x24,0x24,0x24,0x360,0x360,0x24,0x35d,
0x35d,0x35d,0xe64,0xe64,0x24,0x24,0x354,0x354,0x354,0x354,0x354,0x354,0x354,0x354,0x354,0x354,
0x351,0xbaf,0x11a6,0x11a6,0x11a6,0x11a6,0x11a6,0x11a6,0x24,0x24,0x24,0x24,0x24,0x24,0x24,0x24,
0x27,0x27,0x363,0x375,0x27,0x375,0x375,0x375,0x375,0x375,0x375,0x27,0x27,0x27,0x375,0x375,
0x375,0x27,0x375,0x375,0x378,0x375,0x27,0x27,0x27,0x375,0x375,0x27,0x375,0x27,0x375,0x375,
0x27,0x27,0x27,0x375,0x375,0x27,0x27,0x27,0x375,0x375,0x375,0x27,0x27,0x27,0x375,0x375,
0x375,0x375,0x375,0x375,0x375,0x375,0xc8a,0x375,0x375,0x375,0x27,0x27,0x27,0x27,0x363,0x36f,
0x363,0x36f,0x36f,0x27,0x27,0x27,0x36f,0x36f,0x36f,0x27,0x372,0x372,0x372,0x366,0x27,0x27,
0xe67,0x27,0x27,0x27,0x27,0x27,0x27,0x363,0x27,0x27,0x27,0x27,0x27,0x27,0x27,0x27,
0x27,0x27,0xc87,0x36c,0x36c,0x36c,0x36c,0x36c,0x36c,0x36c,0x36c,0x36c,0x369,0x369,0x369,0xbb2,
0xbb2,0xbb2,0xbb2,0xbb2,0xbb2,0xbb5,0xbb2,0x27,0x27,0x27,0x27,0x27,0x2a,0x387,0x387,0x387,
0x2a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x2a,0x38a,0x38a,0x38a,0x2a,0x38a,0x38a,
0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x2a,0x38a,0x38a,
0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x38a,0x2a,0x38a,0x38a,0x38a,0x38a,0x38a,0x2a,0x2a,
0x2a,0xe70,0x37b,0x37b,0x37b,0x387,0x387,0x387,0x387,0x2a,0x37b,0x37b,0x37e,0x2a,0x37b,0x37b,
0x37b,0x381,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x37b,0x37b,0x2a,0xe70,0xe70,0x2a,0x2a,
0x2a,0x2a,0x2a,0x2a,0x38a,0x38a,0xe6a,0xe6a,0x2a,0x2a,0x384,0x384,0x384,0x384,0x384,0x384,
0x384,0x384,0x384,0x384,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0x2a,0xe6d,0xe6d,0xe6d,0xe6d,
0xe6d,0xe6d,0xe6d,0xe6d,0x2d,0x2d,0x396,0x396,0x2d,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,
0x39c,0x2d,0x39c,0x39c,0x39c,0x2d,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,
0x39c,0x39c,0x39c,0x39c,0x39c,0x2d,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,0x39c,
0x2d,0x39c,0x39c,0x39c,0x39c,0x39c,0x2d,0x2d,0xbb8,0xbbb,0x396,0x38d,0x399,0x396,0x38d,0x396,
0x396,0x2d,0x38d,0x399,0x399,0x2d,0x399,0x399,0x38d,0x390,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,
0x2d,0x38d,0x38d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x39c,0x2d,0x39c,0x39c,0xdb0,0xdb0,
0x2d,0x2d,0x393,0x393,0x393,0x393,0x393,0x393,0x393,0x393,0x393,0x393,0x2d,0xdb3,0xdb3,0x2d,
0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x2d,0x30,0x30,0x3a8,0x3a8,
0x30,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x30,0x3ae,0x3ae,0x3ae,0x30,0x3ae,0x3ae,
0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x11a9,0x3ae,0x3ae,
0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x3ae,0x11a9,0x30,
0x30,0xe7c,0x39f,0x3a8,0x3a8,0x39f,0x39f,0x39f,0xe73,0x30,0x3a8,0x3a8,0x3a8,0x30,0x3ab,0x3ab,
0x3ab,0x3a2,0x11a9,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x30,0x39f,0x30,0x30,0x30,0x30,
0x30,0x30,0x30,0x30,0x3ae,0x3ae,0xe73,0xe73,0x30,0x30,0x3a5,0x3a5,0x3a5,0x3a5,0x3a5,0x3a5,
0x3a5,0x3a5,0x3a5,0x3a5,0xe76,0xe76,0xe76,0xe76,0xe76,0xe76,0x30,0x30,0x30,0xe79,0xe7c,0xe7c,
0xe7c,0xe7c,0xe7c,0xe7c,0x33,0x33,0x918,0x918,0x33,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,
0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x33,0x33,0x33,0x91e,0x91e,
0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,
0x91e,0x91e,0x33,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x33,0x91e,0x33,0x33,
0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x91e,0x33,0x33,0x33,0x912,0x33,0x33,0x33,0x33,0x90f,
0x918,0x918,0x90f,0x90f,0x90f,0x33,0x90f,0x33,0x918,0x918,0x91b,0x918,0x91b,0x91b,0x91b,0x90f,
0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
0x33,0x33,0x918,0x918,0x915,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,0x33,
0x36,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,
0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,0x3c9,
0x3c9,0x3b4,0x3c9,0x3c6,0x3b4,0x3b4,0x3b4,0x3b4,0x3b4,0x3b4,0x3ba,0x36,0x36,0x36,0x36,0x3b1,
0x3cf,0x3cf,0x3cf,0x3cf,0x3cf,0x3c9,0x3cc,0x3b7,0x3b7,0x3b7,0x3b7,0x3b7,0x3b7,0x3b4,0x3b7,0x3bd,
0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c3,0x3c0,0x3c0,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,
0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x36,0x39,0x3de,0x3de,0x39,
0x3de,0x39,0x39,0x3de,0x3de,0x39,0x3de,0x39,0x39,0x3de,0x39,0x39,0x39,0x39,0x39,0x39,
0x3de,0x3de,0x3de,0x3de,0x39,0x3de,0x3de,0x3de,0x3de,0x3de,0x3de,0x3de,0x39,0x3de,0x3de,0x3de,
0x39,0x3de,0x39,0x3de,0x39,0x39,0x3de,0x3de,0x39,0x3de,0x3de,0x3de,0x3de,0x3d2,0x3de,0x3db,
0x3d2,0x3d2,0x3d2,0x3d2,0x3d2,0x3d2,0x39,0x3d2,0x3d2,0x3de,0x39,0x39,0x3e7,0x3e7,0x3e7,0x3e7,
0x3e7,0x39,0x3e4,0x39,0x3d5,0x3d5,0x3d5,0x3d5,0x3d5,0x3d2,0x39,0x39,0x3d8,0x3d8,0x3d8,0x3d8,
0x3d8,0x3d8,0x3d8,0x3d8,0x3d8,0x3d8,0x39,0x39,0x3e1,0x3e1,0x125d,0x125d,0x39,0x39,0x39,0x39,
0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,
0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x39,0x891,0x891,0x891,0x894,
0x891,0x891,0x891,0x891,0x3c,0x891,0x891,0x891,0x891,0x894,0x891,0x891,0x891,0x891,0x894,0x891,
0x891,0x891,0x891,0x894,0x891,0x891,0x891,0x891,0x894,0x891,0x891,0x891,0x891,0x891,0x891,0x891,
0x891,0x891,0x891,0x891,0x891,0x894,0x92d,0xe88,0xe88,0x3c,0x3c,0x3c,0x3c,0x85e,0x85e,0x861,
0x85e,0x861,0x861,0x86a,0x861,0x86a,0x85e,0x85e,0x85e,0x85e,0x85e,0x88b,0x85e,0x861,0x864,0x864,
0x867,0x870,0x864,0x864,0x891,0x891,0x891,0x891,0x11b2,0x11ac,0x11ac,0x11ac,0x85e,0x85e,0x85e,0x861,
0x85e,0x85e,0x921,0x85e,0x3c,0x85e,0x85e,0x85e,0x85e,0x861,0x85e,0x85e,0x85e,0x85e,0x861,0x85e,
0x85e,0x85e,0x85e,0x861,0x85e,0x85e,0x85e,0x85e,0x861,0x85e,0x921,0x921,0x921,0x85e,0x85e,0x85e,
0x85e,0x85e,0x85e,0x85e,0x921,0x861,0x921,0x921,0x921,0x3c,0x92a,0x92a,0x927,0x927,0x927,0x927,
0x927,0x927,0x924,0x927,0x927,0x927,0x927,0x927,0x927,0x3c,0xe7f,0x927,0xc8d,0xc8d,0xe82,0xe85,
0xe7f,0xffc,0xffc,0xffc,0xffc,0x11af,0x11af,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,
0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,
0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3f0,0x3f0,0x3f0,0x3f0,0x3f0,0x3f0,0x3f,0x1263,
0x3f,0x3f,0x3f,0x3f,0x3f,0x1263,0x3f,0x3f,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,
0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0xc9c,
0x957,0x42,0x957,0x957,0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x42,
0x957,0x42,0x957,0x957,0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0xc9c,
0x957,0x42,0x957,0x957,0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0xc9c,0x957,0x42,0x957,0x957,
0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x42,0x957,0x42,0x957,0x957,
0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0xc9c,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0x42,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0xc9c,0x957,0x42,0x957,0x957,0x957,0x957,0x42,0x42,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0xc9c,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x42,0x42,0x11b5,0x11b5,0xc96,0xc99,0x951,0x95a,0x94e,
0x94e,0x94e,0x94e,0x95a,0x95a,0x954,0x954,0x954,0x954,0x954,0x954,0x954,0x954,0x954,0x94b,0x94b,
0x94b,0x94b,0x94b,0x94b,0x94b,0x94b,0x94b,0x94b,0x94b,0x42,0x42,0x42,0x95d,0x95d,0x95d,0x95d,
0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,
0x95d,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x45,0x96f,0x972,0x972,0x972,
0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x972,
0x972,0x972,0x972,0x972,0x972,0x972,0x972,0x96c,0x969,0x48,0x48,0x48,0x978,0x978,0x978,0x978,
0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x975,0x975,0x975,0x978,0x978,0x978,0x4b,0x4b,0x4b,
0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x4b,0x999,0x999,0x999,0x999,
0x999,0x999,0x97b,0x999,0x999,0x97e,0x97e,0x97e,0x97e,0x97e,0x97e,0x97e,0x97e,0x97e,0x981,0x97e,
0x990,0x990,0x993,0x99c,0x98a,0x987,0x990,0x98d,0x99c,0xbbe,0x4e,0x4e,0x996,0x996,0x996,0x996,
0x996,0x996,0x996,0x996,0x996,0x996,0x4e,0x4e,0x4e,0x4e,0x4e,0x4e,0xbc1,0xbc1,0xbc1,0xbc1,
0xbc1,0xbc1,0xbc1,0xbc1,0xbc1,0xbc1,0x4e,0x4e,0x4e,0x4e,0x4e,0x4e,0x9a8,0x9a8,0xa23,0xa26,
0x9ae,0xa20,0x9ab,0x9a8,0x9b1,0x9c0,0x9b4,0x9c3,0x9c3,0x9c3,0x9a2,0x51,0x9b7,0x9b7,0x9b7,0x9b7,
0x9b7,0x9b7,0x9b7,0x9b7,0x9b7,0x9b7,0x51,0x51,0x51,0x51,0x51,0x51,0x9ba,0x9ba,0x9ba,0x9ba,
0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,
0x9ba,0x9ba,0x9ba,0x9ba,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x51,0x9ba,0x9ba,0x9ba,0x9ba,
0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9a5,0xea9,0x51,0x51,0x51,0x51,0x51,0x1053,0x1053,0x1053,0x1053,
0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x54,0x54,0x411,0x411,0x411,0x411,0x411,0x411,0x54,0x54,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x54,0x411,0x54,0x411,0x54,0x411,0x54,0x411,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x54,0x54,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x40e,0x40e,0x40e,0x40e,
0x40e,0x54,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x408,0x40e,0x408,0x408,0x405,0x40e,0x40e,
0x40e,0x54,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x405,0x405,0x405,0x40e,0x40e,0x40e,0x40e,
0x54,0x54,0x40e,0x40e,0x411,0x411,0x411,0x411,0x54,0x405,0x405,0x405,0x40e,0x40e,0x40e,0x40e,
0x40e,0x40e,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x405,0x405,0x405,0x54,0x54,0x40e,0x40e,
0x40e,0x54,0x40e,0x40e,0x411,0x411,0x411,0x411,0x411,0x40b,0x408,0x54,0xa95,0xa98,0xa98,0xa98,
0xeb2,0x57,0x132c,0x132c,0x132c,0x132c,0x41a,0x41a,0x41a,0x41a,0x41a,0x41a,0x462,0xaaa,0x5a,0x5a,
0x5fa,0x462,0x462,0x462,0x462,0x462,0x468,0x47a,0x468,0x474,0x46e,0x5fd,0x45f,0x5f7,0x5f7,0x5f7,
0x5f7,0x45f,0x45f,0x45f,0x45f,0x45f,0x465,0x477,0x465,0x471,0x46b,0x5a,0xca5,0xca5,0xca5,0xca5,
0xca5,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x11b8,0x5a,0x5a,0x5a,0x480,0x480,0x480,0x480,
0x480,0x480,0x480,0x47d,0x483,0x660,0x480,0x89a,0x8bb,0x9cf,0x9cf,0x9cf,0xaad,0xaad,0xca8,0xca8,
0xca8,0xca8,0x1014,0x1017,0x1017,0x11bb,0x1329,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,
0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x5d,0x489,0x489,0x489,0x489,0x489,0x489,0x489,0x489,
0x489,0x489,0x489,0x489,0x489,0x486,0x486,0x486,0x486,0x489,0x9d2,0x9d2,0xab0,0xab6,0xab6,0xab3,
0xab3,0xab3,0xab3,0xcab,0xdb6,0xdb6,0xdb6,0xdb6,0xeb5,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x4b9,0x4b9,0x4b9,0x9db,0xdbf,0xebb,0xebb,0xebb,
0xebb,0x114c,0x63,0x63,0x63,0x63,0x63,0x63,0x624,0x624,0x624,0x624,0x624,0x624,0x624,0x624,
0x624,0x624,0x4c5,0x4c5,0x4c2,0x4c2,0x4c2,0x4c2,0xdc5,0xdc5,0xdc5,0xdc2,0xdc2,0xdc2,0xdc2,0xdc2,
0x101d,0x11be,0x11be,0x11be,0x11be,0x11be,0x11be,0x11be,0x11c1,0x11c1,0x11c1,0x11c1,0x66,0x66,0x66,0x66,
0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x66,0x4e3,0x4e3,0x4e3,0x4e3,0x4e3,0x9e4,0x9e4,0x69,
0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,
0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x69,0x4e6,0x4e6,0x4e6,0x4e6,0x4e6,0x4e6,0x4e6,0x4e6,
0x4e6,0x4e6,0x4e6,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,
0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6c,0x6f,0x50d,0x50d,0x50d,0x50d,0x11c7,0x507,0x507,
0x50d,0x50d,0x11ca,0x11ca,0x50d,0x50d,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,
0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,
0x9ff,0x9ff,0x72,0x9ff,0x9ff,0x9ff,0x9ff,0xa02,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,
0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0x9ff,0xa02,0x72,0x72,0x72,0x72,
0x72,0x72,0x72,0x72,0x72,0x72,0x72,0x72,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,
0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0xa05,0x75,0x75,
0x75,0x75,0x75,0x75,0x75,0x75,0x75,0x75,0x7b,0x73e,0x738,0x73e,0x738,0x73e,0x738,0x73e,
0x738,0x73e,0x738,0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,
0x73b,0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,0x738,0x738,0x738,0x73e,0x738,0x73e,0x738,0x73e,
0x738,0x738,0x738,0x738,0x738,0x738,0x73e,0x738,0x738,0x738,0x738,0x738,0x73b,0xb4c,0xb4c,0x7b,
0x7b,0x849,0x849,0x819,0x819,0x741,0x744,0xb49,0x7e,0x7e,0x7e,0x7e,0x7e,0x756,0x756,0x756,
0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,
0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0x756,0xfe7,0x7e,0x7e,0x81,0x759,0x759,0x759,
0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x81,
0x822,0x822,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,0x825,
0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,
0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0xa11,0x1242,0x1242,0x1242,0x84,0x84,0x84,0x84,0x84,
0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,
0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0x762,0xc45,0xc45,0x87,
0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,
0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x87,
0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0x8a,0x8a,0x8a,
0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,
0xa1d,0xb55,0xa1d,0xa1d,0xa1d,0xb55,0xa1d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,0x8d,
0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,
0x8b5,0x8b5,0x8b5,0x8b5,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,0x90,
0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,0x10f5,
0x525,0x525,0x525,0x525,0x525,0x525,0x525,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,0x93,
0x93,0x93,0x93,0x513,0x513,0x513,0x513,0x513,0x93,0x93,0x93,0x93,0x93,0x9f0,0x516,0x51c,
0x522,0x522,0x522,0x522,0x522,0x522,0x522,0x522,0x522,0x519,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,
0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x93,0x51c,0x51c,0x51c,0x51c,0x51c,0x93,0x51c,0x93,
0x51c,0x51c,0x93,0x51c,0x51c,0x93,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x51c,0x51f,
0x537,0x531,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,
0x11cd,0x11cd,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
0x96,0x96,0x96,0x537,0x531,0x534,0x53a,0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x537,0x531,
0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
0x534,0x531,0x534,0x534,0x534,0x534,0x534,0x534,0x531,0x534,0x531,0x531,0x534,0x534,0x531,0x531,
0x531,0x531,0x531,0x534,0x531,0x531,0x534,0x531,0x534,0x534,0x534,0x531,0x534,0x534,0x534,0x534,
0x96,0x96,0x534,0x534,0x534,0x534,0x531,0x531,0x534,0x531,0x531,0x531,0x531,0x534,0x531,0x531,
0x531,0x531,0x531,0x534,0x534,0x534,0x531,0x531,0x96,0x96,0x96,0x96,0x96,0x96,0x96,0x96,
0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,0xa38,
0x537,0x537,0x852,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x52e,0x52e,0xae6,0xc54,0x96,0x96,
0x53d,0x53d,0x53d,0x53d,0xec4,0xec4,0xec4,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,0x99,
0x780,0x786,0x786,0x792,0x792,0x783,0x77a,0x783,0x77a,0x783,0x77a,0x783,0x77a,0x783,0x77a,0x783,
0x77a,0x78c,0x789,0x78c,0x789,0xb6a,0xb6a,0xc51,0xc4e,0x77d,0x77d,0x77d,0x77d,0x78f,0x78f,0x78f,
0x7a7,0x7aa,0x7b9,0x9c,0x7ad,0x7b0,0x7bc,0x7bc,0x7a4,0x79b,0x795,0x79b,0x795,0x79b,0x795,0x798,
0x798,0x7b3,0x7b3,0x7b6,0x7b3,0x7b3,0x7b3,0x9c,0x7b3,0x7a1,0x79e,0x798,0x9c,0x9c,0x9c,0x9c,
0x543,0x54f,0x543,0xae9,0x543,0x9f,0x543,0x54f,0x543,0x54f,0x543,0x54f,0x543,0x54f,0x543,0x54f,
0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x54c,
0x546,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x54c,0x546,0x54c,0x546,0x54c,0x546,0x9f,0x9f,0x540,
0x681,0x684,0x699,0x69c,0x67b,0x684,0x684,0xa5,0x663,0x666,0x666,0x666,0x666,0x663,0x663,0xa5,
0xa2,0xa2,0xa2,0xa2,0xa2,0xa2,0xa2,0xa2,0xa2,0x9f3,0x9f3,0x9f3,0x8b8,0x65d,0x552,0x552,
0xa5,0x6ab,0x68a,0x67b,0x684,0x681,0x67b,0x68d,0x67e,0x678,0x67b,0x699,0x690,0x687,0x6a8,0x67b,
0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x6a5,0x696,0x693,0x699,0x699,0x699,0x6ab,
0x66c,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,
0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0x669,0xa5,
0xa5,0xa5,0x669,0x669,0x669,0x669,0x669,0x669,0xa5,0xa5,0x669,0x669,0x669,0x669,0x669,0x669,
0xa5,0xa5,0x669,0x669,0x669,0x669,0x669,0x669,0xa5,0xa5,0x669,0x669,0x669,0xa5,0xa5,0xa5,
0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3e,0xa3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0xcc,
0xedc,0xedc,0xedc,0xedc,0xedc,0xed9,0xed9,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xcf,0xcf,0xcf,
0xed9,0xed9,0xed9,0xed9,0xed9,0x115b,0x115b,0x115b,0x115b,0x115b,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,
0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,
0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xcf,0xc18,0xc18,0xc18,0xc18,
0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xd2,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,
0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xd2,
0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,
0xc18,0xc18,0xc18,0xd2,0xc18,0xc18,0xd2,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,
0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xd2,0xd2,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,
0xc18,0xc18,0xc18,0xc18,0xc18,0xc18,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,
0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,
0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xd2,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,
0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0x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,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,0xe4,
0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xcd8,0xea,0xea,0xea,0xea,0xea,
0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0xfc6,0x144,0x144,0x144,0x144,
0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,
0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xcea,0xce1,0xce1,0xce7,0xce7,0xce1,0xed,0xed,0xce4,0xce4,
0xfed,0xfed,0xfed,0xfed,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,0xf0,
0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,0xb5b,
0xee2,0xee2,0xee2,0xee2,0xee2,0xee2,0xee2,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,
0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0xf3,0x11d9,0x1029,0xddd,0xddd,
0xcfc,0xcf9,0xcfc,0xcf9,0xcf9,0xcf0,0xcf0,0xcf0,0xcf0,0xcf0,0xcf0,0x1032,0x102f,0x1032,0x102f,0x102c,
0x102c,0x102c,0x126c,0x1269,0xf6,0xf6,0xf6,0xf6,0xf6,0xcf6,0xcf3,0xcf3,0xcf3,0xcf0,0xcf6,0xcf3,
0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,
0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,0xf9,
0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xf9,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xf9,
0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xf9,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xcff,0xf9,
0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,0xd05,
0xd02,0xd02,0xd02,0xd02,0xd02,0xd02,0xd02,0xd02,0xd02,0xd02,0xfc,0xfc,0xfc,0xfc,0xfc,0xfc,
0xd08,0xd08,0xd08,0xd08,0xd08,0xd08,0xff,0x126f,0xff,0xff,0xff,0xff,0xff,0x126f,0xff,0xff,
0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,
0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0x102,
0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,
0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0xd0b,0x102,
0xd20,0xd14,0xd14,0xd14,0x105,0xd14,0xd14,0x105,0x105,0x105,0x105,0x105,0xd14,0xd14,0xd14,0xd14,
0xd20,0xd20,0xd20,0xd20,0x105,0xd20,0xd20,0xd20,0x105,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,
0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,0xd20,
0x105,0x105,0x105,0x105,0xd11,0xd11,0xd11,0x105,0x105,0x105,0x105,0xd17,0xd1a,0xd1a,0xd1a,0xd1a,
0xd1a,0xd1a,0xd1a,0xd1a,0x105,0x105,0x105,0x105,0x105,0x105,0x105,0x105,0xd1d,0xd1d,0xd1d,0xd1d,
0xd1d,0xd1d,0xd23,0xd23,0xd1a,0x105,0x105,0x105,0x105,0x105,0x105,0x105,0xd35,0xd35,0xd35,0xd35,
0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0x1038,0x1038,0x108,0x108,0x108,0x108,0xd2f,0xd2f,0xd2f,0xd2f,
0xd2f,0xd32,0xd32,0xd32,0xd2f,0xd2f,0xd32,0xd2f,0xd2f,0xd2f,0xd2f,0xd2f,0xd2f,0xd35,0xd35,0xd35,
0xd35,0xd35,0xd35,0xd35,0xd2f,0xd2f,0x108,0x108,0x108,0x108,0x108,0x108,0xd2c,0xd2c,0xd2c,0xd2c,
0xd2c,0xd2c,0xd2c,0xd2c,0xd2c,0xd2c,0x1035,0x108,0x108,0x108,0xd29,0xd29,0xd3b,0xd3b,0xd3b,0xd3b,
0x10b,0x10b,0x10b,0x10b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd38,0xd3b,0xd3b,0xd3b,
0xd3b,0xd3b,0x10b,0x10b,0x10b,0x10b,0x10b,0x10b,0x10b,0x10b,0x10b,0x10b,0xefa,0xefa,0xef7,0xef1,
0xef7,0xef1,0xef7,0xef1,0xef7,0xef1,0xeee,0xeee,0xeee,0xeee,0xf03,0xf00,0xeee,0x103b,0x1272,0x1275,
0x1275,0x1272,0x1272,0x1272,0x1272,0x1272,0x1278,0x1278,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,
0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,
0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0x10e,0xd62,0xd62,0xd62,0xd5f,0xd5f,0xd56,0xd56,0xd5f,
0xd5c,0xd5c,0xd5c,0xd5c,0x111,0x111,0x111,0x111,0x118b,0x118b,0x118b,0x118b,0x118b,0x118b,0x118b,0x118b,
0x118e,0x118b,0x168,0x168,0x168,0x168,0x168,0x168,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0x127b,0x127b,
0x114,0x114,0x114,0x114,0x114,0x114,0x114,0xd68,0x11df,0x114,0x114,0x114,0x114,0x114,0x114,0x114,
0x114,0x114,0x114,0x114,0x114,0x114,0x114,0x11dc,0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,
0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,0xb31,0xd8f,0xd80,0xd7a,0xd8c,0xd89,0xd83,0xd83,0xd92,
0xd7d,0xd86,0x117,0x117,0x117,0x117,0x117,0x117,0xe10,0xe10,0xdfb,0xe10,0xe13,0xe16,0xe16,0xe16,
0xe16,0xe16,0xe16,0xe16,0x11d,0x11d,0x11d,0x11d,0xe0a,0xe0a,0xe0a,0xe0a,0xe0a,0xe0a,0xe0a,0xe0a,
0xe0a,0xe0a,0xe1c,0xe1c,0xe01,0xe07,0xe1c,0xe1c,0xe04,0xe01,0xe01,0xe01,0xe01,0xe01,0xe01,0xe01,
0xe01,0xe01,0xe01,0xdfe,0xdfe,0xdfe,0xdfe,0xdfe,0xdfe,0xdfe,0xdfe,0xdfe,0xe01,0xe01,0xe01,0xe01,
0xe01,0xe01,0xe01,0xe01,0xe01,0x11d,0x11d,0x11d,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,
0xf15,0xf12,0xf12,0xf21,0xf18,0x11e5,0x11e2,0x120,0x11e5,0x11e2,0x1281,0x127e,0x120,0x120,0x120,0x120,
0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x11e5,0x11e2,0x11e5,0x11e2,0x11e5,0x11e2,0x11e5,0x11e2,
0x11e5,0x11e2,0x1281,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,
0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,0x120,
0x120,0x120,0x120,0x120,0x1284,0x1284,0x11e2,0xf1e,0xf1e,0xf1e,0xf1e,0xf1e,0xe2b,0xe2b,0xe2b,0xe2b,
0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,0xe2b,
0xe28,0xe28,0xe2e,0xe2e,0x123,0x123,0x123,0x123,0x123,0x123,0x123,0x123,0xe37,0xe37,0xe37,0xe37,
0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,0xe37,
0xe37,0xe37,0xe31,0xe31,0xe31,0xe31,0x1041,0x1041,0x126,0x126,0x126,0xe34,0xe3a,0xe3a,0xe3a,0xe3a,
0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0xe3a,0x129,0x129,0x129,0x129,0x129,
0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,
0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0x129,0xe40,0xe40,0xe40,0x12c,
0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0xe3d,0xe3d,0xe3d,0xe3d,
0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0x12c,0xe43,0xe43,0xe43,0xe43,
0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0xe43,0x12f,0x12f,
0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0x12f,0xf45,0xf45,0xf45,0xf45,
0xf42,0xf42,0xf42,0xf42,0xf42,0xf42,0xf42,0xf42,0xf33,0xf33,0xf33,0xf33,0xf33,0xf33,0xf33,0xf33,
0xf42,0xf42,0xf39,0xf36,0x132,0x132,0x132,0xf48,0xf48,0xf3c,0xf3c,0xf3c,0xf3f,0xf3f,0xf3f,0xf3f,
0xf3f,0xf3f,0xf3f,0xf3f,0xf3f,0xf3f,0x132,0x132,0x132,0xf45,0xf45,0xf45,0xf4b,0xf4b,0xf4b,0xf4b,
0xf4b,0xf4b,0xf4b,0xf4b,0xf4b,0xf4b,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf60,0xf60,0xf60,0xf60,
0xf60,0xf60,0xf60,0xf60,0xf60,0xf60,0xf63,0xf63,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,
0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0x135,0xf7e,0xf78,0xf7e,0xf78,
0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,
0xf7e,0xf78,0xf7e,0xf78,0x138,0x138,0x138,0x138,0x138,0x138,0x138,0x1290,0xf8a,0xf8a,0xf8a,0xf8a,
0xf84,0x13b,0x13b,0x13b,0x13b,0x13b,0x13b,0x13b,0x13b,0x13b,0xf90,0xf90,0xf87,0xf87,0xf87,0xf87,
0xf87,0xf87,0xf87,0xf87,0xf87,0xf87,0x13b,0x13b,0x13b,0x13b,0x13b,0x13b,0xfb1,0xfb1,0xfb1,0xfb1,
0xfb1,0xfb1,0xfb1,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfa5,0xfab,0xfae,
0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0x13e,0xfa8,0xfc0,0xfc0,0xfc0,0xfc0,
0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfb4,0xfb4,0xfb4,0xfb4,0xfb4,0xfb4,0xfbd,0xfbd,0xfb4,0xfb4,0xfbd,
0xfbd,0xfb4,0xfb4,0x141,0x141,0x141,0x141,0x141,0x141,0x141,0x141,0x141,0xfc0,0xfc0,0xfc0,0xfb4,
0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfb4,0xfbd,0x141,0x141,0xfba,0xfba,0xfba,0xfba,
0xfba,0xfba,0xfba,0xfba,0xfba,0xfba,0x141,0x141,0xfb7,0xfc3,0xfc3,0xfc3,0x144,0x144,0x144,0x144,
0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,
0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0x144,0xfc9,0xfc9,0xfc9,0xfc9,
0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,
0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfc9,0xfcc,0x147,0x147,0xfcf,0xfcf,0xfcf,0xfcf,
0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,
0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0xfcf,0x14a,0x14a,0x14a,0xfd2,0xfd2,0xfd2,0xfd2,
0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0x14d,0x14d,0x14d,
0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0x14d,0xfd8,0xfd8,0xfd8,0xfd8,
0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,
0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0xfd8,0x150,0x150,0x150,0x150,0x150,0xfd5,0xfdb,0xfdb,0xfdb,0xfdb,
0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0x153,0x153,0x153,0x153,0xfde,0xfde,0xfde,0xfde,
0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,
0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x156,0x1047,0x1047,0x1047,0x1047,
0x1050,0x1047,0x1047,0x1047,0x1050,0x1047,0x1047,0x1047,0x1047,0x1044,0x159,0x159,0x104d,0x104d,0x104d,0x104d,
0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x104d,0x159,0x1053,0x1053,0x1053,0x1053,
0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,
0x1053,0x1053,0x15c,0x15c,0x15c,0x15c,0x15c,0x15c,0x15c,0x15c,0x15c,0x15c,0x106e,0x106e,0x106e,0x106e,
0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,
0x106e,0x106b,0x1056,0x106b,0x1056,0x1056,0x1056,0x1056,0x1056,0x1056,0x1056,0x15f,0x105f,0x1068,0x1056,0x1068,
0x1068,0x1056,0x1056,0x1056,0x1056,0x1056,0x1056,0x1056,0x1056,0x106b,0x106b,0x106b,0x106b,0x106b,0x106b,0x1056,
0x1056,0x105c,0x105c,0x105c,0x105c,0x105c,0x105c,0x105c,0x105c,0x15f,0x15f,0x1059,0x1065,0x1065,0x1065,0x1065,
0x1065,0x1065,0x1065,0x1065,0x1065,0x1065,0x15f,0x15f,0x15f,0x15f,0x15f,0x15f,0x1065,0x1065,0x1065,0x1065,
0x1065,0x1065,0x1065,0x1065,0x1065,0x1065,0x15f,0x15f,0x15f,0x15f,0x15f,0x15f,0x1194,0x1188,0x1194,0x1194,
0x1194,0x1194,0x1194,0x1194,0x1194,0x107a,0x107a,0x107a,0x107a,0x1194,0x107a,0x107a,0x107a,0x107a,0x1185,0x1323,
0x1326,0x1293,0x1293,0x162,0x162,0x162,0x162,0x162,0x162,0x162,0x162,0x162,0x108f,0x108f,0x108f,0x108f,
0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x1086,0x1086,0x1089,0x1092,
0x108c,0x108c,0x108c,0x1092,0x165,0x165,0x165,0x165,0x165,0x165,0x165,0x165,0x1095,0x1095,0x1095,0x1095,
0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x1095,0x109b,0x109b,
0x109b,0x109b,0x109b,0x109b,0x1098,0x1098,0x1098,0x109b,0x16b,0x16b,0x16b,0x16b,0x1176,0x1176,0x1176,0x1176,
0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,
0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x1176,0x16e,0x16e,0x16e,0x10b0,0x10a4,0x10a4,0x10a4,
0x10a4,0x10a4,0x10a4,0x10a7,0x10b6,0x10b6,0x10a4,0x10a4,0x10a4,0x10a4,0x171,0x1191,0x10aa,0x10aa,0x10aa,0x10aa,
0x10aa,0x10aa,0x10aa,0x10aa,0x10aa,0x10aa,0x171,0x171,0x171,0x171,0x10a4,0x10a4,0x10bf,0x10bf,0x10bf,0x10bf,
0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10bf,0x10c2,0x10bf,0x10bf,0x10bf,
0x10bf,0x10bf,0x10bf,0x10b9,0x10b9,0x10b9,0x10bf,0x10bc,0x174,0x174,0x174,0x174,0x10d4,0x10c8,0x10d4,0x177,
0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x177,
0x177,0x177,0x177,0x177,0x177,0x177,0x177,0x10d1,0x10d1,0x10d7,0x10cb,0x10ce,0x10ec,0x10ec,0x10ec,0x10e6,
0x10e6,0x10dd,0x10e6,0x10e6,0x10dd,0x10e6,0x10e6,0x10ef,0x10e9,0x10e0,0x17a,0x17a,0x10e3,0x10e3,0x10e3,0x10e3,
0x10e3,0x10e3,0x10e3,0x10e3,0x10e3,0x10e3,0x17a,0x17a,0x17a,0x17a,0x17a,0x17a,0x10f5,0x10f5,0x10f5,0x10f5,
0x10f5,0x10f5,0x10f5,0x17d,0x17d,0x17d,0x17d,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,
0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,0x10f2,
0x10f2,0x10f2,0x10f2,0x10f2,0x17d,0x17d,0x17d,0x17d,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,
0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x10fe,0x180,0x10fb,
0x10f8,0x10f8,0x10f8,0x10f8,0x10f8,0x10f8,0x10f8,0x10f8,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,
0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x183,0x183,
0x183,0x1107,0x110a,0x110a,0x110a,0x110a,0x110a,0x110a,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,
0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x1113,0x186,0x186,
0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1110,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,
0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x1119,0x189,0x189,0x189,0x189,0x189,
0x1116,0x1116,0x1116,0x1116,0x1116,0x1116,0x1116,0x1116,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,
0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,
0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x111f,0x18f,0x113d,0x113d,0x192,0x192,0x192,0x192,0x192,0x192,
0x192,0x192,0x192,0x192,0x192,0x192,0x192,0x192,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,
0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,
0x1161,0x1161,0x1161,0x198,0x198,0x198,0x198,0x198,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,
0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1161,0x1164,0x1164,0x1164,0x1149,0x198,
0x123f,0x1167,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x123f,0x1167,0x123f,0x1167,
0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x1296,0x1296,0x198,0x198,0x198,0x198,
0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x115e,0x123c,0x115e,0x115e,0x123c,0x123c,0x115e,
0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x115e,0x115e,0x115e,0x115e,0x123c,0x123c,
0x1167,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x198,0x198,0x198,0x198,0x198,
0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,
0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x198,0x11ee,0x11ee,
0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,
0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x11ee,0x117f,0x1248,0x1248,0x19b,0x19b,0x19b,0x19b,0x19b,
0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,
0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x117c,0x1248,0x1248,0x1248,0x1248,0x1248,0x1248,
0x1248,0x1248,0x1248,0x19b,0x19b,0x19b,0x19b,0x19b,0x1179,0x1179,0x1179,0x1179,0x1179,0x1179,0x1179,0x1179,
0x1179,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x1245,0x1245,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,
0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,
0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x19b,0x11f7,0x11f7,0x11f7,0x11f7,
0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,
0x11f7,0x11f7,0x11f7,0x11f7,0x11f7,0x11f1,0x11f1,0x11f1,0x19e,0x19e,0x11f4,0x19e,0x1209,0x1209,0x1209,0x1209,
0x1209,0x1209,0x11fa,0x1203,0x11fd,0x11fd,0x1203,0x1203,0x1203,0x11fd,0x1203,0x11fd,0x11fd,0x11fd,0x1206,0x1206,
0x1a1,0x1a1,0x1a1,0x1a1,0x1a1,0x1a1,0x1a1,0x1a1,0x1200,0x1200,0x1200,0x1200,0x1a4,0x120c,0x120c,0x120c,
0x120c,0x120c,0x120c,0x1a4,0x1a4,0x120c,0x120c,0x120c,0x120c,0x120c,0x120c,0x1a4,0x1a4,0x120c,0x120c,0x120c,
0x120c,0x120c,0x120c,0x1a4,0x1a4,0x1a4,0x1a4,0x1a4,0x1a4,0x1a4,0x1a4,0x1a4,0x120f,0x120f,0x120f,0x120f,
0x120f,0x120f,0x1212,0x1224,0x1224,0x1218,0x1218,0x1218,0x1218,0x1218,0x1a7,0x1a7,0x1a7,0x1a7,0x1215,0x1215,
0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x1215,0x121b,0x121b,
0x121b,0x121b,0x121b,0x121b,0x121b,0x121b,0x121b,0x121b,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,
0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1a7,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,
0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,
0x1227,0x1aa,0x1aa,0x1aa,0x1aa,0x1aa,0x1aa,0x1aa,0x124e,0x124b,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,
0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,
0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x1ad,0x122a,0x122a,0x122a,0x122a,
0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x1b0,0x1b0,0x122a,0x122a,0x122a,
0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x1b0,0x1b0,0x122a,0x122a,0x122a,
0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x1b0,0x122a,0x122a,0x122a,
0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x122a,0x1b0,0x1b0,0x1b0,0x1b0,
0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,
0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1b0,0x1230,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1b3,0x1230,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1b3,0x1230,0x1230,0x1230,0x1230,0x1b3,0x1b3,0x1b3,0x122d,0x122d,0x122d,0x122d,
0x122d,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x122d,0x122d,
0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x1b3,0x1b3,0x1299,0x1299,0x1299,0x1299,
0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1b3,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,
0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1b3,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,
0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,
0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1b9,0x1239,0x1239,0x1239,0x1239,
0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,
0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x1bc,0x12a5,0x1bf,0x12a5,0x12a5,
0x12a5,0x12a5,0x12a5,0x12a5,0x12a5,0x12a5,0x12a5,0x12a5,0x12a5,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,
0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,
0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x1bf,0x12a2,0x12a2,0x12a2,0x12a2,
0x12a2,0x12a2,0x129f,0x129f,0x129f,0x129f,0x129f,0x129f,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,
0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x12a2,0x1bf,0x12ab,0x12ab,0x12ab,0x12ab,0x1c2,0x12ab,0x12ab,0x12ab,
0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,
0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x1c2,0x12ab,0x12ab,0x1c2,0x12ab,0x1c2,0x1c2,0x12ab,
0x1c2,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x12ab,0x1c2,0x12ab,0x12ab,0x12ab,0x12ab,
0x1c2,0x12ab,0x1c2,0x12ab,0x1c2,0x1c2,0x1c2,0x1c2,0x1c2,0x1c2,0x12ab,0x1c2,0x1c2,0x1c2,0x1c2,0x12ab,
0x1c2,0x12ab,0x1c2,0x12ab,0x1c2,0x12ab,0x12ab,0x12ab,0x1c2,0x12ab,0x12ab,0x1c2,0x12ab,0x1c2,0x1c2,0x12ab,
0x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x1ce,0x1ce,0x1ce,0x1ce,0x1ce,0x12de,0x12de,0x12de,0x12de,0x12e7,0x12e7,0x12e7,0x12e7,0x12e7,
0x12e7,0x12e7,0x12e7,0x12e7,0x12e7,0x12e7,0x12e7,0x12e7,0x12f9,0x12fc,0x12fc,0x12fc,0x12fc,0x12ff,0x12ff,0x12ed,
0x12f0,0x1d1,0x1d1,0x1d1,0x1d1,0x1d1,0x1d1,0x1d1,0x12f3,0x12f3,0x12f3,0x12f3,0x12f3,0x12f3,0x12f3,0x12f3,
0x12f3,0x12f3,0x1d1,0x1d1,0x1d1,0x1d1,0x1d1,0x1d1,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,0x1305,
0x1305,0x1d4,0x1d4,0x1d4,0x1d4,0x1d4,0x1d4,0x1d4,0x1302,0x1302,0x1302,0x1302,0x1302,0x1302,0x1302,0x1302,
0x1302,0x1302,0x1d4,0x1d4,0x1d4,0x1d4,0x1d4,0x1d4,0x1308,0x1308,0x1308,0x1308,0x1308,0x1308,0x1308,0x1308,
0x1d7,0x1d7,0x1d7,0x1d7,0x1d7,0x1d7,0x1d7,0x1d7,0x1194,0x1194,0x1194,0x1077,0x1194,0x1194,0x1194,0x1194,
0x1194,0x1194,0x1194,0x1194,0x1194,0x1194,0x1194,0x1194,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,
0x131a,0x131a,0x131a,0x130b,0x1314,0x130b,0x1314,0x1314,0x130b,0x130b,0x130b,0x130b,0x130b,0x130b,0x1317,0x130e,
0x1da,0x1da,0x1da,0x1da,0x1da,0x1da,0x1da,0x1da,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,
0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,
0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x1dd,0x855,0x855,0xa14,0xa14,0xa14,0xa14,
0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,
0xa14,0xa14,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0x1e0,0xfea,0xfea,0xfea,0xfea,
0x1170,0x1170,0x1170,0x1170,0x1170,0x1170,0x1170,0x1170,0x131d,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,
0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,
0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0x1e3,0xb58,0xb58,0xb58,0xb58,
0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0x1173,0x1173,0x1173,0x1e6,0x1e6,0xd77,0xd77,0xd77,0xd77,
0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,
0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,
0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,
0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0x1e6,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,
0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0x1e9,
0x1e9,0x1e9,0x1e9,0x1e9,0x1e9,0x1e9,0x1e9,0x1e9,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,
0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,
0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0x1ec,0x1ec,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,
0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1ef,0x1ef,0x1ef,
0x1ef,0x1ef,0x1ef,0x1ef,0x1ef,0x1ef,0x1ef,0x1ef,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,
0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,
0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1f2,0x1f2,0xff0,0x2f1,0x2f1,0x2fd,0xb9a,0x300,0x300,0x300,
0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,
0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x2fd,0x2f1,0x2f1,0x2f1,0x2f1,0x2f1,0x2f1,0x2f1,
0x2f1,0x2fd,0x2fd,0x2fd,0x2fd,0x2f7,0xff3,0x11a0,0x300,0x83d,0x83d,0x2f4,0x2f4,0xff0,0x119d,0x119d,
0x303,0x303,0x303,0x303,0x303,0x303,0x303,0x303,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x300,
0x300,0x303,0x300,0x300,0x300,0x300,0x300,0x300,0x300,0x303,0x300,0x300,0x303,0x300,0x300,0x300,
0x300,0x300,0x119d,0x11a0,0x2f4,0x300,0x2fd,0x2fd,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x3ed,0x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
0x3fc,0x3fc,0x3ff,0x897,0xeac,0xeac,0xeaf,0xeac,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,
0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,0x402,0x3fc,
0x402,0x3fc,0xeaf,0xeac,0xeaf,0xeac,0xeaf,0xeac,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,
0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,0x40e,
0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x411,0x5c7,0x5c7,0x5ca,0x42c,0x5d6,0x5d3,0x5d3,0x5d0,
0x456,0x456,0x414,0x414,0x414,0x414,0x414,0x9c6,0x5d9,0x438,0x5f1,0x5f4,0x44d,0x5d9,0x43b,0x43b,
0x42c,0x447,0x447,0x5c7,0x453,0x450,0x5cd,0x426,0x41d,0x41d,0x420,0x420,0x420,0x420,0x420,0x423,
0x420,0x420,0x420,0x417,0x45c,0x45c,0x459,0x459,0x5e5,0x441,0x43e,0x5e2,0x5df,0x5dc,0x5ee,0x42f,
0x5eb,0x5eb,0x444,0x447,0x5e8,0x5e8,0x444,0x447,0x429,0x42c,0x42c,0x42c,0x44a,0x435,0x432,0xaa7,
0x9cc,0x9cc,0x9c9,0x9c9,0x9c9,0x9c9,0xa9e,0xa9e,0xa9e,0xa9e,0xaa4,0xbc7,0xbc4,0xc9f,0xca2,0xaa1,
0xca2,0xca2,0xca2,0xca2,0xc9f,0xca2,0xca2,0xa9b,0x48f,0x48f,0x4a7,0x606,0x48c,0x600,0x48f,0x4a4,
0x48c,0x606,0x49e,0x4a7,0x4a7,0x4a7,0x49e,0x49e,0x4a7,0x4a7,0x4a7,0x60c,0x48c,0x4a7,0x609,0x48c,
0x49b,0x4a7,0x4a7,0x4a7,0x4a7,0x4a7,0x48c,0x48c,0x492,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0x4e3,0x4e3,0x4e3,0x4e3,0x4e3,0x4e3,0x4e3,0x4e3,
0x4e3,0x4e3,0x4e3,0x4e3,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x4e9,0xb2e,
0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,0xb2e,
0xb2e,0xb2e,0xb2e,0xc39,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,
0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x4ec,0x4ef,0x4ef,0x4ef,0x4ef,0x4ef,0x4ef,0x4ef,
0x4ef,0x4ef,0x4ef,0x4ef,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,
0x4ef,0x4ef,0x4ef,0x4ef,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,
0x63f,0x63f,0x63f,0x63f,0x642,0x642,0x642,0x642,0x642,0x642,0x642,0x642,0x642,0x642,0x642,0x642,
0x642,0x642,0x642,0x642,0x4f2,0x4f2,0x642,0x642,0x642,0x642,0xad4,0xad4,0xad4,0xad4,0xad4,0xad4,
0xad4,0xad4,0xad4,0xad4,0x648,0x648,0x4f5,0x645,0x645,0x645,0x645,0x645,0x645,0x645,0x4f5,0x4f5,
0x4f5,0x4f5,0x4f8,0x4f8,0x4f8,0x4f8,0x648,0x648,0x4f8,0x4f8,0x648,0x648,0x4f5,0x4f5,0x4f5,0x4f5,
0x648,0x648,0x4f8,0x4f8,0x648,0x648,0x4f5,0x4f5,0x4f5,0x4f5,0x648,0x648,0x645,0x4f5,0x4f8,0x648,
0x4f5,0x4f5,0x645,0x648,0x648,0x648,0x4f8,0x4f8,0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,
0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,0x4f5,0x648,0x645,0x648,0x645,0x4f5,0x4f8,0x4f8,0x4f8,0x4f8,0x4f8,
0x4f8,0x4f5,0x4f5,0x645,0x9e7,0x9e7,0x9e7,0x9e7,0x9e7,0x9e7,0x9e7,0x9e7,0xad7,0xad7,0xad7,0xad7,
0xad7,0xad7,0xad7,0xad7,0x4fe,0x4fe,0x4fe,0x4fe,0x4fb,0x651,0x651,0x4fb,0x4fb,0x64b,0x4fb,0x4fb,
0x4fb,0x4fb,0x64b,0x64b,0x4fb,0x4fb,0x4fb,0x4fb,0xc3c,0xc3c,0xada,0xada,0xcba,0x9ea,0x4fe,0x4fe,
0x64e,0x4fe,0x64e,0x4fe,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,
0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fe,0x4fe,0x4fe,
0x4fb,0x4fb,0x4fb,0x4fb,0x651,0x4fb,0x651,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,
0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,0x4fb,
0x4fb,0x4fb,0x4fb,0x4fb,0x651,0x651,0x501,0x651,0x64b,0x64b,0x4fb,0x64b,0x64e,0x64b,0x64b,0x4fb,
0x64b,0x651,0x501,0x651,0x9ea,0x9ea,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,
0xadd,0xadd,0xcb7,0xcba,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,
0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x504,0x507,0x11c7,0x11c7,0x11c7,0x507,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x11c7,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x657,0x507,0x507,0x507,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x11c7,0x507,0x11c7,0x507,0x507,0x507,0x507,0x11c7,
0x11c7,0x11c7,0x507,0x1155,0x507,0x507,0x507,0x510,0x510,0x510,0x510,0x11c7,0x11c7,0x507,0x50a,0x50a,
0x507,0x507,0x507,0x507,0xae3,0xae0,0xae3,0xae0,0xae3,0xae0,0xae3,0xae0,0xae3,0xae0,0xae3,0xae0,
0xae3,0xae0,0x654,0x654,0x654,0x654,0x654,0x654,0x654,0x654,0x654,0x654,0x507,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x11c7,0x507,0x507,0x507,
0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x507,0x11c7,0x531,0x531,0x531,0x531,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x534,0x534,0x534,0x534,0x534,0x534,0x534,
0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x531,0x537,0x52b,0x528,0x537,0x537,0x537,0x537,
0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,
0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x52e,0x52e,0x52e,0x52e,0x52e,0x52e,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x534,0x53a,0x537,0x531,
0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,
0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x537,0x531,0x537,0x531,
0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x531,0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,
0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x537,0x531,0x534,0x53a,0x537,0x531,0x537,0x531,
0x534,0x53a,0x537,0x531,0x534,0x53a,0x537,0x531,0x537,0x531,0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,
0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,0x11cd,0x537,0x531,0x537,0x531,0x537,0x531,0x534,0x53a,
0x534,0x53a,0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x531,0x537,0x531,
0x534,0x537,0x531,0x534,0x537,0x531,0x534,0x53a,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x534,
0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,
0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x531,0x531,0x531,0x531,0x531,0x531,0x531,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x534,0x534,0x531,0x534,0x531,0x534,0x531,0x531,
0x534,0x531,0x531,0x534,0x531,0x534,0x531,0x531,0x534,0x531,0x534,0x534,0x531,0x531,0x531,0x534,
0x531,0x531,0x531,0x531,0x531,0x534,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,
0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x531,0x534,0x534,0x531,0x531,
0x534,0x531,0x534,0x531,0x531,0x531,0x531,0x531,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,
0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,
0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x534,0x53a,0x537,0x537,0x537,0x537,
0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,
0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x53a,0x53a,0x53a,0x53a,
0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,0x53a,
0x53a,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x537,0x54c,0x54c,0x546,0x54c,
0x546,0x54c,0x546,0x54c,0x546,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x54c,0x546,0x549,0x54f,0x54c,
0x546,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x54c,
0x546,0x54c,0x546,0x54c,0x546,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,
0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,
0x54f,0x54c,0x546,0x549,0x54f,0x54c,0x546,0x549,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,
0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x636,0x633,0x633,0x633,0x633,
0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,
0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x633,0x63c,0x63c,
0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,0x63c,
0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,0x639,
0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,
0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,0x63f,
0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,
0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,0x65a,
0xb34,0x7e3,0x7dd,0x7da,0x7e0,0x7d7,0x66f,0x672,0x672,0x672,0x672,0x672,0x672,0x672,0x672,0x672,
0x7e9,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,
0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,0x66f,
0x66f,0x66f,0x7e6,0x7e6,0x675,0x7f8,0x7fb,0x801,0x726,0x732,0x816,0x72f,0x7ef,0x7ec,0x7ef,0x7ec,
0x7f5,0x7f2,0x7f5,0x7f2,0x7ef,0x7ec,0x72c,0x801,0x7ef,0x7ec,0x7ef,0x7ec,0x7ef,0x7ec,0x7ef,0x7ec,
0x807,0x80d,0x80a,0x80a,0x67b,0x6b7,0x6b7,0x6b7,0x6b7,0x6b7,0x6b7,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,
0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x6b1,0x67e,
0x699,0x678,0x69f,0x6a2,0x69c,0x6b4,0x6b4,0x6b4,0x6b4,0x6b4,0x6b4,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,
0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x6ae,0x67e,
0x699,0x678,0x699,0xb37,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,
0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,
0x71a,0x71a,0x71a,0x71a,0x71a,0x71a,0x116a,0x116a,0x116a,0x116a,0x116a,0x71d,0x72c,0x72f,0x72f,0x72f,
0x72f,0x72f,0x72f,0x72f,0x72f,0x72f,0x846,0x846,0x846,0x846,0x735,0x735,0x804,0x813,0x813,0x813,
0x813,0x810,0x729,0x7fe,0xa0e,0xa0e,0xa0e,0xb46,0xb64,0xb61,0xa29,0x7d4,0x73b,0x738,0x73b,0x73e,
0x738,0x73b,0x738,0x73b,0x738,0x73b,0x738,0x738,0x738,0x738,0x738,0x738,0x73b,0x73b,0x738,0x73b,
0x73b,0x738,0x73b,0x73b,0x738,0x73b,0x73b,0x738,0x73b,0x73b,0x738,0x738,0xb67,0x74d,0x747,0x74d,
0x747,0x74d,0x747,0x74d,0x747,0x74d,0x747,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,
0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x74a,0x74d,
0x747,0x74a,0x747,0x74a,0x747,0x74a,0x747,0x747,0x747,0x747,0x747,0x747,0x74a,0x74a,0x747,0x74a,
0x74a,0x747,0x74a,0x74a,0x747,0x74a,0x74a,0x747,0x74a,0x74a,0x747,0x747,0x747,0x747,0x747,0x74d,
0x747,0x74d,0x747,0x74d,0x747,0x747,0x747,0x747,0x747,0x747,0x74d,0x747,0x747,0x747,0x747,0x747,
0x74a,0x74d,0x74d,0x74a,0x74a,0x74a,0x74a,0x81c,0x81f,0x750,0x753,0xb4f,0x759,0x759,0x759,0x759,
0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,
0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x75c,0x759,0x759,0x759,
0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,
0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x759,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,
0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,0x765,
0x765,0x765,0x765,0x765,0xc48,0xc48,0xd71,0x75f,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,
0x828,0x828,0x828,0x828,0xc42,0xc42,0xc42,0xc42,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,
0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x768,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,
0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0xc4b,
0xc4b,0xc4b,0xc4b,0x831,0x831,0x831,0x831,0x831,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,
0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,
0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0x76b,0xc4b,0xc4b,0x76e,0x76e,0x76e,0x76e,
0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,
0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x76e,0x82e,0x82e,0x82e,0x82e,
0x82e,0x82e,0x82e,0x82e,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,
0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,0x771,
0x771,0x771,0x771,0x771,0x771,0x771,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,
0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xd74,0xfea,0xfea,0xfea,0xfea,
0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,
0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,0x774,
0x774,0x774,0x777,0x777,0x774,0x777,0x774,0x777,0x777,0x774,0x774,0x774,0x774,0x774,0x774,0x774,
0x774,0x774,0x774,0x777,0x774,0x777,0x774,0x777,0x777,0x774,0x774,0x777,0x777,0x777,0x774,0x774,
0x774,0x774,0x1320,0x1320,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,
0xb58,0xb58,0xb58,0xb58,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,
0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,0x828,
0x828,0x828,0x828,0x828,0x116d,0x116d,0x116d,0x116d,0x1158,0x1158,0x1158,0x1158,0x1158,0x1158,0x1158,0x1158,
0xc42,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,
0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,
0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,0x82b,
0x82b,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,0xb52,
0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,
0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0x82e,0xc4b,
0x891,0x873,0x873,0x873,0x873,0x86d,0x873,0x873,0x885,0x873,0x873,0x870,0x87c,0x882,0x882,0x882,
0x882,0x882,0x885,0x86d,0x879,0x86d,0x86d,0x86d,0x864,0x864,0x86d,0x86d,0x86d,0x86d,0x86d,0x86d,
0x888,0x888,0x888,0x888,0x888,0x888,0x888,0x888,0x888,0x888,0x86d,0x86d,0x86d,0x86d,0x86d,0x86d,
0x86d,0x86d,0x86d,0x86d,0x870,0x864,0x86d,0x864,0x86d,0x864,0x87f,0x876,0x87f,0x876,0x88e,0x88e,
0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,
0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,0x89d,
0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,0x8a0,
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x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,
0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b2,0x8b5,0x8b5,0x8b5,
0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,
0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x8b5,0x942,0x942,0xea6,0x942,0x942,0x942,0x945,0x942,
0xea6,0x942,0x942,0xe9d,0x93c,0x930,0x930,0x930,0x930,0x93f,0x930,0xe8b,0xe8b,0xe8b,0x930,0x933,
0x93c,0x936,0xe91,0xea0,0xea0,0xe8b,0xe8b,0xea6,0xa2f,0xa2f,0xa2f,0xa2f,0xa2f,0xa2f,0xa2f,0xa2f,
0xa2f,0xa2f,0x948,0x948,0x939,0x939,0x939,0x939,0x942,0x942,0x942,0x942,0x942,0x942,0x93f,0x93f,
0x930,0x930,0xea6,0xea6,0xea6,0xea6,0xe8b,0xe8b,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,
0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,
0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x942,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0xc9c,
0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0xc9c,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,0x957,
0x957,0x957,0x957,0x957,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,
0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,0x95d,
0x95d,0x95d,0x95d,0x95d,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,
0x963,0x960,0x966,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x1011,0x1011,0x1011,0x1011,0x1011,
0x1011,0x1011,0x1011,0x1011,0x100e,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,
0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,
0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x963,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,
0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,
0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x978,0x99c,0x99c,0x99c,0x99f,0x99f,0x99c,0x99c,0x99c,
0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x984,0x984,0x999,0x97b,
0x97b,0x97b,0x97b,0x97b,0x97b,0x97b,0x999,0x999,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,
0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,
0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x99c,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,
0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9ba,0x9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,
0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,
0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa14,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,
0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa1a,0xa17,0xa17,
0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,
0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,0xa17,
0xa1d,0xa1d,0xb55,0xb55,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,
0xa1d,0xa1d,0xa1d,0xa1d,0xb55,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,0xa1d,
0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xbd9,0xbd9,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,
0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,0xa44,
0xa44,0xa44,0xbd6,0xbd6,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,
0xc24,0xc24,0xc24,0xc24,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,
0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,0xa47,
0xa47,0xa47,0xa47,0xa47,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,
0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,0xa4a,
0xa4a,0xa4a,0xa4a,0xa4a,0xa59,0xa59,0xa59,0xa59,0xa59,0xa50,0xa5c,0xa62,0xa62,0xa62,0xa56,0xa56,
0xa56,0xa5f,0xa53,0xa53,0xa53,0xa53,0xa53,0xa4d,0xa4d,0xa4d,0xa4d,0xa4d,0xa4d,0xa4d,0xa4d,0xa62,
0xa62,0xa62,0xa62,0xa62,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,
0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,
0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa59,0xa59,0xa62,0xa62,0xa62,0xa56,0xa56,0xa62,0xa62,0xa62,
0xa62,0xa62,0xa62,0xa62,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,
0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa62,0xa62,0xa62,0xa62,0xa56,0xa56,
0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa56,0xa59,0xa59,0xa59,0xa59,0xa59,
0xa6e,0xa65,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,
0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa65,0xa6b,0xa6b,0xa6b,0xa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xa6b,0xa6b,
0xa6b,0xa6b,0xa6b,0xa6b,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,
0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6e,0xa6b,0xa6b,
0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,
0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6b,0xa6e,0xa6e,0xa6e,0xa6e,0xa71,0xa71,0xa71,0xa71,
0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,
0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa71,0xa74,0xa74,0xa74,0xa74,
0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,
0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa74,0xa77,0xa77,0xa77,0xa77,
0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,
0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xa77,0xad1,0xad1,0xad1,0xad1,
0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,0xad1,
0xad1,0xad1,0xace,0xad1,0xace,0xace,0xace,0xace,0xace,0xace,0xace,0xace,0xace,0xace,0xace,0xace,
0xace,0xace,0xace,0xbcd,0xbd0,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,0xcb4,
0xdc5,0xdc5,0xdc5,0xdc5,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xadd,0xbd3,0xbd3,
0xbd3,0xbd3,0xbd3,0xbd3,0xbd3,0xbd3,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,
0xcb7,0xebe,0x114f,0x114f,0xcc0,0xcc0,0xcc0,0xcc0,0xcc0,0xcc6,0xcc3,0xdd7,0xdd7,0xdd7,0xdd7,0x1266,
0xed0,0x1266,0x11d6,0x11d6,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,
0xb10,0xb10,0xb10,0xb10,0xb10,0xb10,0xb3d,0xb3a,0xb3d,0xb3a,0xb3d,0xb3a,0xfe4,0xfe1,0xed6,0xed3,
0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,0xb13,
0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,
0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,0xb16,
0xb19,0xb19,0xb19,0xb1f,0xb1c,0xb43,0xb40,0xb1f,0xb1c,0xb1f,0xb1c,0xb1f,0xb1c,0xb1f,0xb1c,0xb1f,
0xb1c,0xb1f,0xb1c,0xb1f,0xb1c,0xb1f,0xb1c,0xb1f,0xb1c,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,
0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,
0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb1f,0xb1c,0xb1f,0xb1c,
0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,
0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb19,0xb1f,0xb1c,0xb19,0xb19,
0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb28,0xb22,0xb22,0xb22,
0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,
0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,
0xb28,0xb28,0xb28,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,
0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,0xb22,
0xb25,0xb22,0xb22,0xb22,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,
0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,0xb58,
0xb58,0xb58,0xb58,0xb58,0xbd3,0xbd3,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,
0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xcb7,0xdc8,0xebe,0xebe,0xebe,0xebe,0xebe,0xebe,0xebe,0xebe,0xebe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dda,0xdda,0xdda,0xdda,0xdda,0xdda,0xdda,0xed9,
0xed9,0xed9,0xed9,0xed9,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,
0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,0xc15,
0xc15,0xc15,0xc15,0xc15,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,
0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,0xc1b,
0xc1b,0xc1b,0xc1b,0xc1b,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,
0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,0xc24,
0xc24,0xc24,0xc24,0xc24,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,
0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,0xc30,
0xc30,0xc30,0xc30,0xc30,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,
0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,0xc3f,
0xc3f,0xc3f,0xc3f,0xc3f,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,0xcd5,
0xcd5,0xcd5,0xcd5,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,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,
0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,0xd0e,
0xd0e,0xd0e,0xd0e,0xd0e,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,
0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xd26,0xde0,0xde0,0xde0,0xde0,0xee8,
0xee8,0xee8,0xee8,0xee8,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,
0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,0xd35,
0xd35,0xd35,0xd35,0xd35,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,
0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,0xd3b,
0xd3b,0xd3b,0xd3b,0xd3b,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,
0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,0xd44,
0xd44,0xd44,0xd44,0xd3e,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,
0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd41,0xd44,
0xd44,0xd44,0xd44,0xd44,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,0xd4d,
0xd4d,0xd4d,0xd4a,0xd4a,0xd4a,0xd4a,0xd4a,0xd4a,0xd4a,0xd4a,0xd47,0xd50,0xef4,0xeee,0xefd,0xeeb,
0xd4d,0xd4d,0xeeb,0xeeb,0xd62,0xd62,0xd53,0xd62,0xd62,0xd62,0xd59,0xd62,0xd62,0xd62,0xd62,0xd53,
0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,0xd62,
0xd62,0xd62,0xd62,0xd62,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,
0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,0xd65,
0xd65,0xd65,0xd65,0xd65,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,
0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,0xd77,
0xd77,0xd77,0xd77,0xd77,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,0xd95,
0xd95,0xd95,0xd95,0xd95,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,0xfed,
0xfed,0xfed,0xfed,0xfed,0xdda,0xdda,0xdda,0xdda,0xed9,0xed9,0xed9,0xed9,0xed9,0xed9,0xed9,0xed9,
0xed9,0xed9,0xed9,0xed9,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,0xedc,
0xedc,0xedc,0xedc,0xedc,0xdfb,0xdfb,0xdfb,0xdfb,0xe0d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40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,
0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe40,0xe8b,0xea6,0xe9d,0xe9a,0xe9a,0xea6,0xea6,0xe9d,
0xe9d,0xe9a,0xe9a,0xe9a,0xe9a,0xe9a,0xea6,0xea6,0xea6,0xe8b,0xe8b,0xe8b,0xe8b,0xea6,0xea6,0xea6,
0xea6,0xea6,0xea6,0xea6,0xea6,0xea6,0xea6,0xea6,0xea6,0xea6,0xe8b,0xe9d,0xea0,0xe8b,0xe8b,0xea3,
0xea3,0xea3,0xea3,0xea3,0xea3,0xe8e,0xea6,0xea3,0xe97,0xe97,0xe97,0xe97,0xe97,0xe97,0xe97,0xe97,
0xe97,0xe97,0x1005,0x1005,0x1002,0xfff,0xe94,0xe94,0xec1,0xec1,0xec1,0xec1,0x1152,0x1152,0x1152,0x1152,
0x1152,0x114f,0x114f,0x114f,0x114f,0x1152,0x11c4,0x1152,0x1152,0x1152,0x114f,0x1152,0x1152,0x114f,0x114f,0x114f,
0x1152,0x1152,0x114f,0x114f,0x1152,0x114f,0x114f,0x1152,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,
0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,
0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf18,0xf1b,0xf18,0xf18,0xf18,0xf18,0xf18,0xf18,0xf18,
0xf18,0xf21,0xf18,0xf21,0xf18,0xf21,0xf21,0xf18,0xf24,0xf24,0xf2a,0xf30,0xf30,0xf30,0xf30,0xf30,
0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,
0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf30,0xf2a,0xf24,0xf24,0xf24,0xf24,0xf2a,0xf2a,
0xf24,0xf24,0xf2d,0x1287,0x128a,0x128a,0xf30,0xf30,0xf27,0xf27,0xf27,0xf27,0xf27,0xf27,0xf27,0xf27,
0xf27,0xf27,0x128d,0x128d,0x128d,0x128d,0x128d,0x128d,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,
0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,
0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf45,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,
0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,0xf4e,
0xf51,0xf51,0xf51,0xf54,0xf51,0xf51,0xf57,0xf57,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,
0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,
0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf5a,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,
0xf63,0xf63,0xf63,0xf63,0xf66,0xf5d,0xf6c,0xf69,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,
0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,
0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0xf63,0x11eb,0x11e8,0xf7e,0xf78,0xf7e,0xf78,0xf7e,0xf78,
0xf7e,0xf78,0xf7e,0xf78,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c0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,0xfc0,
0xfc0,0xfc0,0xfc0,0xfc0,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,
0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,0xfd2,
0xfd2,0xfd2,0xfd2,0xfd2,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,
0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,0xfdb,
0xfdb,0xfdb,0xfdb,0xfdb,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,
0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,0xfde,
0xfde,0xfde,0xfde,0xfde,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,
0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1050,0x1047,0x1047,0x104a,0x104a,0x1050,0x1047,
0x1047,0x1047,0x1047,0x1047,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,
0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,0x1053,
0x1053,0x1053,0x1053,0x1053,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,
0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,0x106e,
0x106e,0x106e,0x106e,0x106e,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,
0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,0x1080,
0x1080,0x1080,0x107d,0x1083,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,
0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,0x108f,
0x108f,0x108f,0x108f,0x108f,0x109e,0x109e,0x109e,0x10ad,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,
0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,
0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10b3,0x10a1,0x10ad,0x10ad,0x109e,0x109e,0x109e,0x109e,0x10ad,0x10ad,
0x109e,0x10ad,0x10ad,0x10ad,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,
0x10d1,0x10d1,0x10d1,0x10d1,0x10c5,0x10d1,0x10c5,0x10c5,0x10c5,0x10da,0x10da,0x10c5,0x10c5,0x10da,0x10d1,0x10da,
0x10da,0x10d1,0x10c5,0x10c8,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,
0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,0x10d1,
0x10d1,0x10d1,0x10d1,0x10d1,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,
0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,0x10ec,
0x10ec,0x10ec,0x10ec,0x10ec,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,
0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,0x1104,
0x1104,0x1101,0x1101,0x1101,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,
0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,0x110d,
0x110d,0x110d,0x110d,0x110d,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,
0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,0x111c,
0x111c,0x111c,0x111c,0x111c,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x113a,
0x1137,0x1137,0x1137,0x1137,0x1134,0x1134,0x1134,0x1128,0x1128,0x1128,0x1128,0x1134,0x1134,0x112e,0x112b,0x1131,
0x1131,0x1122,0x113d,0x113d,0x1125,0x1125,0x1134,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,
0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x1137,0x113a,0x1137,
0x113a,0x1137,0x1137,0x1137,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,
0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,
0x1140,0x1140,0x1140,0x1140,0x1146,0x1146,0x1146,0x1143,0x1143,0x1143,0x1140,0x1140,0x1140,0x1140,0x1143,0x1140,
0x1140,0x1140,0x1146,0x1143,0x1146,0x1143,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,
0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,0x1140,
0x1140,0x1146,0x1143,0x1143,0x1140,0x1140,0x1140,0x1140,0x1152,0x1152,0x11c4,0x114f,0x11c4,0x11c4,0x11c4,0x11c4,
0x114f,0x114f,0x1152,0x114f,0x114f,0x114f,0x114f,0x114f,0x114f,0x1152,0x1152,0x1152,0x1152,0x1152,0x114f,0x1152,
0x1152,0x1152,0x1152,0x114f,0x114f,0x1152,0x1152,0x1152,0x123f,0x123f,0x1167,0x123f,0x123f,0x123f,0x1167,0x123f,
0x123f,0x123f,0x1167,0x1167,0x1167,0x1167,0x1167,0x123f,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x115e,
0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x123c,0x115e,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,
0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,
0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1182,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,
0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,
0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x1209,0x121e,0x120f,0x121e,0x1221,0x1221,0x1221,0x1221,0x1221,
0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,
0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x1221,0x120f,0x120f,0x120f,0x120f,0x120f,0x120f,0x120f,0x120f,
0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,
0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,0x1227,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x122d,0x122d,0x1230,0x1230,0x1230,0x1230,0x1230,0x122d,0x1230,0x1230,0x1230,
0x122d,0x1230,0x122d,0x1230,0x122d,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x122d,
0x1230,0x122d,0x122d,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,0x122d,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,0x1230,
0x129c,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,
0x1233,0x129c,0x1233,0x1233,0x1233,0x129c,0x1233,0x129c,0x1233,0x129c,0x1233,0x129c,0x1233,0x1233,0x1233,0x129c,
0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x129c,0x129c,0x1233,0x1233,0x1233,0x1233,0x129c,0x1233,0x129c,0x129c,
0x1233,0x1233,0x1233,0x1233,0x129c,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,0x1233,
0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,
0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,0x1236,
0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,
0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,0x1239,
0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,
0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,0x1251,
0x12ae,0x12ae,0x12ae,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,
0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,0x12c0,
0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,
0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,0x12db,
0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,
0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,0x12e4,
0x12ea,0x12ea,0x12f6,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,
0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,0x12fc,
0x12fc,0x12fc,0x12fc,0x12f6,0x12f6,0x12f6,0x12ea,0x12ea,0x12ea,0x12ea,0x12ea,0x12ea,0x12ea,0x12ea,0x12ea,0x12f6,
0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,
0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,0x131a,
0,0,0,0
};
static const UTrie2 propsVectorsTrie={
propsVectorsTrie_index,
propsVectorsTrie_index+4128,
NULL,
4128,
19284,
0xa40,
0x10a0,
0x0,
0x0,
0x110000,
0x5b70,
NULL, 0, FALSE, FALSE, 0, NULL
};
static const uint32_t propsVectors[4914]={
0x67,0,0,0x67,0x80000,0x20,0x867,0,0,0xa67,0,0,0xb67,0,0,0xc67,
0,0,0xd67,0,0,0xe67,0,0,0xf67,0,0,0x1067,0,0,0x1167,0,
0,0x1267,0,0,0x1367,0,0,0x1467,0,0,0x1567,0,0,0x1667,0,0,
0x1767,0,0,0x1867,0,0,0x1967,0,0,0x1a67,0,0,0x1b67,0,0,0x1d67,
0,0,0x1f67,0,0,0x2067,0,0,0x2267,0,0,0x2367,0,0,0x2467,0,
0,0x2567,0,0,0x2767,0,0,0x2867,0x80000,0x20,0x2967,0,0,0x2a67,0,0x1600000,
0x2b67,0,0,0x2d67,0,0,0x3067,0x20000000,0,0x3167,0x20000000,0,0x3267,0x20000000,0,0x3867,
0x20000000,0,0x3a67,0,0,0x3b67,0,0,0x3c67,0,0,0x3e67,0,0,0x4067,0,
0,0x4167,0,0,0x4367,0,0,0x4467,0,0,0x4867,0,0,0x4967,0,0,
0x4a67,0,0,0x5067,0,0,0x5167,0,0,0x5267,0,0,0x5467,0,0,0x5567,
0,0,0x5667,0x80000,0x20,0x5767,0,0,0x5867,0,0,0x5967,0,0,0x5b67,0,
0,0x5c67,0,0,0x5d67,0,0,0x6067,0x80000,0x20,0x6167,0,0,0x6267,0,0,
0x6367,0,0,0x6467,0,0,0x6567,0,0,0x6f67,0,0,0x7067,0,0,0x7367,
0x20000000,0,0x7567,0,0,0x7667,0,0,0x7767,0,0,0x7867,0,0,0x7a67,0,
0,0x7b67,0,0,0x7c67,0,0,0x7e67,0,0,0x7f67,0,0,0x8167,0,0,
0x8267,0,0,0x8367,0,0,0x8467,0,0,0x8567,0,0,0x8667,0,0,0x8767,
0,0,0x8867,0,0,0x8967,0,0,0x8b67,0,0,0x8c67,0,0,0x8e67,0x20000000,
0,0x8f67,0,0,0x9067,0,0,0x9167,0,0,0x9267,0,0,0x9367,0,0,
0x9567,0,0,0x9667,0,0,0x9767,0,0,0x9867,0,0,0x9967,0,0,0x9a67,
0,0,0x9c67,0,0,0x9f67,0,0,0xa067,0,0,0xa167,0,0,0xa367,0,
0,0xa467,0,0,0xa567,0,0,0xa667,0,0,0xa767,0,0,0xa867,0,0,
0xa967,0,0,0xaa67,0,0,0xab67,0,0,0xac67,0,0,0xad67,0,0,0xae67,
0,0,0xaf67,0,0,0xb167,0,0,0xb267,0,0,0xb367,0,0,0xb467,0,
0,0xb567,0,0,0xb667,0,0,0xb767,0,0,0xb867,0,0,0xb967,0,0,
0xba67,0,0,0xbc67,0,0,0xbd67,0,0,0xbe67,0,0,0xbf67,0,0,0xc067,
0,0,0xc167,0,0,0xc267,0,0,0xc367,0,0,0xc467,0,0,0xc667,0,
0,0xc767,0,0,0xc867,0,0,0xc967,0,0,0xca67,0,0,0xcb67,0,0,
0xcc67,0,0,0xcd67,0,0,0xce67,0,0,0xcf67,0,0,0xd067,0,0,0xd267,
0,0,0xd367,0,0,0xd467,0,0,0xd567,0,0,0xd667,0,0,0xd867,0,
0,0xd967,0,0,0xda67,0,0,0xdb67,0,0,0xdc67,0,0,0xa0067,0,0xe00000,
0xa4667,0,0xe00000,0xa4767,0,0xe00000,0xa4f67,0,0xe00000,0xa5e67,0,0xe00000,0xa5f67,0,0xe00000,0xac567,
0,0xe00000,0xad167,0,0xe00000,0x11000100,0,0x900020,0x11000100,0x40000001,0x440020,0x11000100,0x40000001,0x643020,0x11000100,0x40000001,
0xa5a040,0x11000100,0x40000001,0x116a8a0,0x11000200,0,0x900020,0x11000200,0x4000001,0xc4000b,0x11000200,0x7c00100,0x220402,0x11000200,0x24000000,0x200000,
0x11000200,0x24000008,0x1710000,0x11000200,0x40000001,0x1d3b020,0x11000219,0x7c00100,0x220401,0x11000219,0x7c00100,0x250401,0x11000319,0x7c00100,0x220401,0x11000319,
0x7c00100,0x220402,0x11000319,0x7c00100,0x250400,0x11000319,0x7c00100,0x250401,0x11000419,0x7c00100,0x220400,0x11000419,0x7c00100,0x220401,0x11000419,0x7c00100,
0x220402,0x11000419,0x7c00100,0x230400,0x11000419,0x7c00100,0x250400,0x11000419,0x7c00100,0x250401,0x11000419,0x7c00100,0x250402,0x11000519,0x7c00100,0x220400,
0x11000519,0x7c00100,0x230400,0x11000600,0x4000400,0x200000,0x11000600,0x4000400,0x200002,0x11000600,0x4000400,0x201000,0x11000600,0x7c00500,0x220400,0x11000600,
0x7c00500,0x230400,0x11000600,0x7c00500,0x530400,0x11000600,0x7c00d00,0x230400,0x11000619,0x7c00500,0x22040f,0x11000800,0x4000010,0x1001401,0x11000800,0x4000400,
0x200001,0x11000800,0x6800010,0x201001,0x11000800,0x7c00500,0x230401,0x11000807,0x7c00100,0x220400,0x11000807,0x7c00100,0x250400,0x1100080e,0x4000400,0x200000,
0x1100080e,0x4000400,0x200002,0x1100080e,0x7000500,0x220402,0x1100080e,0x7c00100,0x220400,0x1100080e,0x7c00100,0x220401,0x1100080e,0x7c00100,0x220402,0x1100080e,
0x7c00100,0x250400,0x1100080e,0x7c00100,0x250401,0x1100080e,0x7c00120,0x220402,0x1100080e,0x7c00120,0x250402,0x11000908,0x2802400,0x962460,0x11000908,0x4000000,
0x200000,0x11000908,0x7c00100,0x220400,0x11000908,0x7c00100,0x220401,0x11000908,0x7c00100,0x250400,0x11000908,0x7c00100,0x250401,0x11000a03,0x4000000,0x200000,
0x11000a03,0x4000000,0x270000,0x11000a03,0x7c00100,0x220400,0x11000a03,0x7c00100,0x220402,0x11000a03,0x7c00100,0x250400,0x11000a03,0x7c00500,0x230400,0x11000a03,
0xc000000,0x248000,0x11000b13,0x2802500,0x962460,0x11000b13,0x4000000,0x200000,0x11000b13,0x4000000,0x201000,0x11000b13,0x4000000,0x230400,0x11000b13,0x4000002,
0x400000,0x11000b13,0x4000010,0x200000,0x11000b13,0x7c00100,0x2633800,0x11000c00,0,0x218820,0x11000c02,0x2802100,0x962460,0x11000c02,0x2802400,0x962460,
0x11000c02,0x4000000,0x200000,0x11000c02,0x4000000,0x1329400,0x11000c02,0x4000000,0x1329800,0x11000c02,0x4000000,0x1500000,0x11000c02,0x6800000,0x1329800,0x11000c02,
0x7c00100,0x230400,0x11000c02,0x7c00100,0x230401,0x11000c02,0x7c00100,0x230402,0x11000c02,0x7c00500,0x230400,0x11000c02,0x7d00100,0x230400,0x11000c02,0xc000010,
0xb48000,0x11000f0a,0x2802100,0x962460,0x11000f0a,0x2802400,0x962460,0x11000f0a,0x2806400,0x962460,0x11000f0a,0x4000000,0x200000,0x11000f0a,0x6800100,0x962540,
0x11000f0a,0x7c00100,0x230400,0x11000f0a,0x7c00100,0x230401,0x11001004,0x2802100,0x962460,0x11001004,0x2802400,0x962460,0x11001004,0x2806400,0x962460,0x11001004,
0x4000000,0x200000,0x11001004,0x4000000,0x1500000,0x11001004,0x6800100,0x962540,0x11001004,0x6800100,0x962541,0x11001004,0x7c00100,0x230400,0x11001004,0x7c00100,
0x230401,0x11001110,0x2802100,0x962460,0x11001110,0x2802400,0x962460,0x11001110,0x2806400,0x962460,0x11001110,0x6800000,0x1329800,0x11001110,0x6800100,0x962540,
0x11001110,0x7c00100,0x230400,0x11001110,0x7c00100,0x230401,0x1100120f,0x2802100,0x962460,0x1100120f,0x2802400,0x962460,0x1100120f,0x2806400,0x962460,0x1100120f,
0x6800000,0x1329800,0x1100120f,0x6800100,0x962540,0x1100120f,0x7c00100,0x230400,0x1100131f,0x2802100,0x962460,0x1100131f,0x2802400,0x962460,0x1100131f,0x2806400,
0x962460,0x1100131f,0x4000000,0x200000,0x1100131f,0x6800000,0x1329800,0x1100131f,0x6800100,0x962540,0x1100131f,0x6800100,0x962541,0x1100131f,0x7c00100,0x230400,
0x1100131f,0x7c00100,0x230401,0x11001423,0x2802100,0x962460,0x11001423,0x2806400,0x962460,0x11001423,0x4000000,0x200000,0x11001423,0x6800000,0x1329800,0x11001423,
0x6800100,0x962540,0x11001423,0x6800100,0x962541,0x11001423,0x7c00100,0x230400,0x11001423,0x7c00100,0x230401,0x11001524,0x2802100,0x962460,0x11001524,0x2802100,
0x962461,0x11001524,0x2806400,0x962460,0x11001524,0x6800000,0x1329800,0x11001524,0x6800100,0x962540,0x11001524,0x7c00100,0x230400,0x11001615,0x2802100,0x962460,
0x11001615,0x2806400,0x962460,0x11001615,0x6800000,0x1329800,0x11001615,0x6800100,0x962540,0x11001615,0x6800100,0x962541,0x11001615,0x7c00100,0x230400,0x1100171a,
0x2802100,0x962460,0x1100171a,0x2806400,0x962460,0x1100171a,0x6800000,0x1329800,0x1100171a,0x6800100,0x962540,0x1100171a,0x6800100,0x962541,0x1100171a,0x7c00100,
0x230400,0x11001900,0x4000000,0x1600000,0x11001926,0x2802100,0x1862460,0x11001926,0x2802400,0x1862460,0x11001926,0x2806100,0x1862460,0x11001926,0x4000000,0x200000,
0x11001926,0x4000010,0x400000,0x11001926,0x6800000,0x1329800,0x11001926,0x7800100,0x1830142,0x11001926,0x7c00100,0x1830000,0x11001926,0x7c00900,0x1830000,0x11001926,
0x7e00100,0x1830000,0x11001a18,0x2802100,0x1862460,0x11001a18,0x2802400,0x1862460,0x11001a18,0x6800000,0x1329800,0x11001a18,0x7800100,0x1830142,0x11001a18,0x7c00100,
0x1830000,0x11001a18,0x7c00100,0x1830002,0x11001a18,0x7c00900,0x1830000,0x11001a18,0x7e00100,0x1830000,0x11001d00,0x4000000,0x200000,0x11001d0c,0x7c00100,0x230400,
0x11001d0c,0x7c00100,0x250400,0x11001e12,0x7c00100,0x2230500,0x11001e12,0x7c00100,0x2330520,0x11001e12,0x7c80100,0x2330520,0x11002619,0x7c00100,0x220401,0x11002619,
0x7c00100,0x220402,0x11002619,0x7c00100,0x250401,0x1100270e,0x4000400,0x200001,0x1100270e,0x4000400,0x200002,0x1100270e,0x4000400,0x500001,0x1100270e,0x7c00100,
0x220401,0x1100270e,0x7c00100,0x250401,0x11002800,0x80000,0x918820,0x11002800,0x80000,0x1c18020,0x11002800,0x180000,0x918820,0x11002800,0x4000001,0x440001,
0x11002800,0x4000001,0x440002,0x11002800,0x4000001,0xc4000b,0x11002800,0x6800000,0x201c00,0x11002800,0x6800020,0x201c00,0x11002800,0x24000000,0x200000,0x11002800,
0x24000000,0x200002,0x11002800,0x24000000,0x810000,0x11002800,0x24000000,0x1410000,0x11002800,0x24000000,0x1500000,0x11002800,0x24000000,0x1500002,0x11002800,0x24000002,
0x400000,0x11002800,0x24000006,0xc0000b,0x11002800,0x24000008,0x1410000,0x11002800,0x24000008,0x1710000,0x11002800,0x24000020,0x1001400,0x11002800,0x24000020,0x1500002,
0x11002800,0x2c000010,0x1248000,0x11002800,0x2c000010,0x1248002,0x11002800,0x40000001,0x63b020,0x11002800,0x40080000,0x918820,0x11002801,0x82000,0x962460,0x11002900,
0x4000000,0x20000e,0x11002900,0x4000000,0x20000f,0x11002900,0x4000020,0x20000e,0x11002900,0x4000020,0x20000f,0x11002900,0x4000020,0x81000e,0x11002900,0x4000020,
0x81000f,0x11002900,0x4000020,0x141000e,0x11002900,0x4000020,0x141000f,0x11002900,0x4000022,0x20000e,0x11002900,0x4000022,0x20000f,0x11002a00,0x4000000,0x1500000,
0x11002a00,0x4000000,0x1600000,0x11002a00,0x4000000,0x1600002,0x11002b01,0x2000,0x962460,0x11002b01,0x2802020,0x962460,0x11002c00,0x4000000,0x200000,0x11002c00,
0x4000000,0x200002,0x11002c00,0x4000000,0x20000f,0x11002c00,0x4000020,0x200000,0x11002c00,0x7c00000,0x200000,0x11002c00,0x7c00020,0x200000,0x11002c00,0x7c00120,
0x220405,0x11002c00,0x7c00120,0x230402,0x11002c00,0x7c00120,0x250402,0x11002c00,0x7c00120,0x250405,0x11002c19,0x7c00100,0x250400,0x11002c19,0x7c00100,0x250401,
0x11002d00,0x4000000,0x100006,0x11002d00,0x4000000,0x200006,0x11002d19,0x7c00100,0x220402,0x11002d19,0x7c00100,0x230400,0x11002d19,0x7c00100,0x250402,0x11002e00,
0x24000000,0x200000,0x11002e00,0x24000020,0x200000,0x11002e00,0x24000020,0x200001,0x11002f00,0x24000020,0x200000,0x11002f00,0x24000020,0x200001,0x11002f00,0x24000020,
0x200002,0x11002f00,0x24000020,0x1600000,0x11002f00,0x24000022,0x1600000,0x11003000,0x24000000,0x200000,0x11003000,0x24000000,0xe00000,0x11003000,0x24000020,0x200000,
0x11003000,0x24000020,0x210000,0x11003100,0x24000000,0x200000,0x11003200,0x24000000,0x200000,0x11003300,0x4000000,0x100003,0x11003400,0x24000000,0x100000,0x11003400,
0x24000000,0x200000,0x11003500,0x24000000,0x200000,0x11003600,0x24000000,0x200000,0x11003600,0x24000020,0x200000,0x11003700,0x24000000,0x200000,0x11003700,0x24000000,
0xe00000,0x11003700,0x24000020,0x200000,0x11003800,0x4000000,0x100000,0x11003800,0x24000000,0x200000,0x11003800,0x24000000,0xb00000,0x11003800,0x24000000,0xe00000,
0x11003800,0x24000000,0x1710000,0x11005003,0x7c00100,0x220402,0x11005013,0x2802500,0x962460,0x11005013,0x4000020,0x200005,0x11005013,0x7c00100,0x2633801,0x11005013,
0x7c00100,0x2633802,0x11005013,0x7c00100,0x2633805,0x11005019,0x7c00100,0x220402,0x11005100,0x24000000,0x810000,0x11005100,0x24000000,0x1410000,0x11005102,0x7000100,
0x230408,0x11005102,0x7c00100,0x230404,0x11005102,0x7c00100,0x230407,0x11005102,0x7c00100,0x230408,0x11005102,0x7c00100,0x230409,0x11005201,0x2802400,0x962460,
0x11005500,0x80000,0x1e18820,0x11005502,0x7000100,0x230408,0x11005502,0x7c00100,0x230404,0x11005502,0x7c00100,0x230407,0x11005502,0x7c00100,0x230408,0x11005502,
0x7c00100,0x230409,0x11005667,0x1000,0,0x11020200,0x80004,0x418820,0x11020200,0x4000000,0x100006,0x11020200,0x4000000,0x10000f,0x11020200,0x4000400,
0x100002,0x11020200,0x4000400,0x500002,0x11020200,0x6800c00,0x101000,0x11020200,0x24000000,0x100000,0x11020200,0x24000000,0x200000,0x11020200,0x24000000,0x1400000,
0x11020200,0x24000000,0x1500000,0x11020200,0x24000000,0x1600000,0x11020200,0x24000020,0x100000,0x11020200,0x24000020,0x1600000,0x11020219,0x7c00100,0x12040f,0x11020219,
0x7c00100,0x220400,0x11020219,0x7c00100,0x220401,0x11020219,0x7c00100,0x250400,0x11020319,0x7c00100,0x220400,0x11020319,0x7c00100,0x220401,0x11020319,0x7c00100,
0x220402,0x11020319,0x7c00100,0x250400,0x11020319,0x7c00100,0x250402,0x11020319,0x7d00100,0x220402,0x11020419,0x7c00100,0x220401,0x11020519,0x7c00100,0x220400,
0x11020600,0x4000400,0x100002,0x11020600,0x4000400,0x200000,0x11020600,0x7c00500,0x130400,0x11020600,0x7c00d00,0x130400,0x11020701,0x2802400,0x962460,0x11020701,
0x2802400,0x962461,0x11020701,0x2802400,0xc62460,0x1102080e,0x7c00100,0x220400,0x1102080e,0x7c00100,0x250400,0x11020908,0x7c00100,0x220400,0x11020908,0x7c00100,
0x220401,0x11020908,0x7c00100,0x250400,0x11020908,0x7c00100,0x250401,0x11022800,0x24000000,0x100000,0x11022800,0x24000000,0x200000,0x11022800,0x24000000,0x200002,
0x11022800,0x24000000,0x401000,0x11022800,0x24000000,0xf00002,0x11022800,0x24000000,0xf0ac02,0x11022800,0x24000000,0x1500000,0x11022800,0x24000002,0x100000,0x11022800,
0x24000002,0x370000,0x11022800,0x24000002,0x470000,0x11022800,0x24000006,0x400000,0x11022800,0x24000008,0x1710000,0x11022800,0x24000008,0x1712c00,0x11022800,0x24000020,
0x100000,0x11022800,0x24000020,0x1500000,0x11022800,0x24000020,0x1500002,0x11022900,0x4000000,0x10000e,0x11022900,0x4000000,0x10000f,0x11022919,0x7c00100,0x12040f,
0x11022c00,0x4000000,0x100002,0x11022c00,0x4000000,0x10000f,0x11022c00,0x4000000,0x1500002,0x11022c00,0x4000000,0x1600002,0x11022c00,0x7c00120,0x120405,0x11022c0e,
0x7c00100,0x250401,0x11022c19,0x7c00100,0x150401,0x11022d00,0x4000000,0x100006,0x11022d00,0x4000000,0x200006,0x11022d19,0x7c00100,0x120402,0x11022d19,0x7c00100,
0x150402,0x11022e00,0x24000000,0x200000,0x11022e00,0x24000020,0x100000,0x11022f00,0x24000020,0x100000,0x11022f00,0x24000020,0x100001,0x11022f00,0x24000020,0x100002,
0x11023000,0x24000000,0x100000,0x11023300,0x4000000,0x100002,0x11023300,0x4000000,0x100003,0x11023300,0x4000100,0x120403,0x11023300,0x4000100,0x150403,0x11023400,
0x24000000,0x100000,0x11023500,0x24000000,0x100000,0x11023600,0x24000000,0x100000,0x11023600,0x24000020,0x100000,0x11023700,0x24000000,0x100000,0x11023700,0x24000000,
0xe00000,0x11023700,0x24000020,0x100000,0x11023800,0x4000000,0x100000,0x11023800,0x24000000,0x200000,0x11024e67,0,0,0x11025600,0x4000000,0x100000,
0x11042a00,0x4000000,0x1600000,0x11045700,0x4000000,0x20000a,0x11045700,0x4000020,0x20000a,0x11045712,0x7c00100,0x23040a,0x11045712,0x7c80100,0x23040a,0x11045716,
0x7c00100,0x230c0a,0x11045716,0x7c00100,0x2530c0a,0x11063d00,0x4000001,0x440011,0x11065700,0x4000000,0x810011,0x11065700,0x4000000,0xe00011,0x11065700,0x4000000,
0x1410011,0x11065700,0x4000000,0x1500011,0x11065700,0x4000000,0x1600011,0x11065700,0x4000006,0xe70011,0x11065700,0x4000008,0xe00011,0x11065700,0x4000008,0xe02c11,
0x11065700,0x4000010,0x871411,0x11065700,0x4000010,0x1201411,0x11065700,0x4000010,0x1271011,0x11065700,0x4000020,0xe00011,0x11065700,0x4000400,0xe00011,0x11065700,
0x4000420,0xe00011,0x11065700,0x6800000,0xe01c11,0x11065700,0x6800040,0xe00011,0x11065700,0xc000010,0x80ac11,0x11065700,0xc000010,0xb48011,0x11065719,0x7c00100,
0xe20411,0x11065719,0x7c00100,0xe50411,0x11065719,0x7c00140,0xe20411,0x11065719,0x7c00140,0xe50411,0x11080100,0x6800000,0x201c00,0x11080100,0x68000c0,0x1329800,
0x11080100,0x24000000,0x200000,0x11080100,0x24000000,0x810000,0x11080100,0x24000000,0x1410000,0x11080100,0x24000000,0x1500000,0x11080100,0x24000000,0x1600000,0x11080100,
0x24000000,0x1b00000,0x11080100,0x24000000,0x2410000,0x11080100,0x24000006,0xd70000,0x11080100,0x24000008,0x1713c00,0x11080100,0x24000008,0x1714000,0x11080100,0x24000010,
0x1001400,0x11080100,0x24000010,0x1071000,0x11080100,0x24000010,0x1071400,0x11080100,0x24000020,0x200000,0x11080100,0x24000020,0x400000,0x11080100,0x24000020,0x1600000,
0x11080100,0x24000400,0x200000,0x11080100,0x24000420,0x200000,0x11080100,0x2c000010,0xb48000,0x11080100,0x2c000010,0x100ac00,0x11080100,0x44000001,0x1a40000,0x11080119,
0x7c00100,0x220400,0x11080119,0x7c00100,0x250400,0x11080119,0x7c001c0,0x220400,0x11080119,0x7c001c0,0x250400,0x11080200,0x4000400,0x200002,0x11080200,0x24000000,
0x200000,0x11080200,0x24000000,0x1500000,0x11080200,0x24000000,0x1600000,0x11080200,0x24000020,0x200000,0x110a1e12,0x7c00100,0x2130480,0x110a1e12,0x7c80100,0x2130480,
0x110a3000,0x24100000,0x810001,0x110a3000,0x24100000,0x1410001,0x110a3d00,0x4000000,0xe00000,0x110a3d00,0x4000000,0xe00002,0x110a3d00,0x24000000,0xe00000,0x110a3d11,
0x7c00300,0xe30000,0x110a3d11,0x7c00900,0x1230400,0x110a3d12,0x2802400,0x962460,0x110a3e14,0x7c00100,0xe30000,0x110a3e14,0x7c00100,0xe30001,0x110a3e14,0x7c00100,
0x2530000,0x110a3e14,0x7c00900,0x1230000,0x110a3e14,0x7c00900,0x1230001,0x110a3f16,0x7c00100,0xe30c00,0x110a3f16,0x7c00100,0xe30c01,0x110a3f16,0x7c00100,0x2530c00,
0x110a3f16,0x7c00900,0x1230c00,0x110a3f16,0x7c00900,0x1230c01,0x110a4005,0x7c00100,0xe30400,0x110a4112,0x7c00100,0xe30402,0x110a4112,0x7c80100,0xe30402,0x110a4400,
0x4000000,0xe00000,0x110a4412,0x4000000,0xe00002,0x110a4412,0x4000000,0xe00003,0x110a4416,0x4000000,0xe00c03,0x110a4500,0x4000000,0xe0000d,0x110a4516,0x4000000,
0xe00c0d,0x110a4711,0x7c40300,0xe30000,0x110a4f11,0x7c00300,0xe30001,0x110a4f11,0x7c40300,0xe30000,0x110a5300,0x4000000,0x810010,0x110a5300,0x4000000,0xe00002,
0x110a5300,0x4000000,0xe00010,0x110a5300,0x4000000,0x1410010,0x110a5300,0x4000002,0xe70010,0x110a5300,0x4000008,0x810010,0x110a5300,0x4000008,0x1410010,0x110a5300,
0x6800000,0xe01c02,0x110a5300,0x6800000,0xe01c10,0x110a5400,0x4000000,0x81000c,0x110a5400,0x4000000,0xe0000c,0x110a5400,0x4000000,0x141000c,0x110a5400,0x4000000,
0x150000c,0x110a5400,0x4000000,0x160000c,0x110a5400,0x4000002,0xe7000c,0x110a5400,0x4000010,0x87140c,0x110a5400,0x4000010,0xe7000c,0x110a5400,0x4000010,0x120140c,
0x110a5400,0x4000010,0x127100c,0x110a5400,0x4000020,0xe0000c,0x110a5400,0x4000026,0xe7000c,0x110a5400,0xc000010,0x80ac0c,0x110a5400,0xc000010,0xb4800c,0x11400a04,
0xc000010,0x1049400,0x11400c06,0x4000010,0xb00000,0x11400c06,0x4000010,0x1071400,0x11400c06,0xc000010,0xb48000,0x11400c0b,0x7c00900,0x230400,0x11400c10,0x6800000,
0x1329800,0x11400f14,0xc000010,0x448000,0x11403d34,0x4000000,0xe00000,0x1144572e,0x4000004,0x120000a,0x1144572e,0x4000008,0x81000a,0x1144572e,0x4000008,0x141000a,
0x1144572e,0x4000010,0x87000a,0x1144572e,0xc000010,0x84800a,0x11445737,0x3802500,0x126246a,0x11445737,0x7c00d00,0x2530c0a,0x114a3d2e,0x24000000,0x810000,0x114a3d2e,
0x24000000,0x1410000,0x114a3d2e,0x24000008,0x810000,0x114a3d2e,0x24000008,0x1410000,0x114a3d2e,0x24000010,0x870000,0x114a3d2e,0x2c000010,0x848000,0x114a3d34,0x4000000,
0xe00000,0x114a3d34,0x24000000,0xe00000,0x114a3d34,0x24000002,0xe00000,0x114a3d34,0x24000002,0x1200000,0x114a3d34,0x24000008,0x810000,0x114a3d34,0x24000008,0x1410000,
0x114a3d37,0x7c00900,0x930c00,0x114a3d37,0x7c00900,0xe30c00,0x114a3d39,0x7c00300,0xe30000,0x114a3e37,0x7000400,0x1200c02,0x114a3f2e,0x4000004,0x1200000,0x114a3f37,
0x7c00d00,0x2530c00,0x114a4239,0x4000000,0xe00000,0x114a4239,0x4000000,0xe0000f,0x114a4434,0x4000000,0xe00002,0x114a4434,0x4000000,0xe00003,0x114a4534,0x4000000,
0xe00002,0x114a4534,0x4000000,0xe0000d,0x11800902,0x2802400,0x962460,0x11800c0e,0x2802100,0x962460,0x11800c0e,0x2802500,0x962460,0x11800f12,0x2802400,0x962460,
0x11820700,0x2802400,0x962460,0x11820700,0x2802500,0x962460,0x118a3d3c,0x2802400,0x962460,0x118a3e37,0x2802400,0x962460,0x11c00f1b,0x6800000,0x1329800,0x11c01020,
0x6800000,0x1329800,0x11c05145,0x7c00100,0x230408,0x20000067,0x1000,0,0x20000b13,0x2802400,0x962460,0x20000b13,0x2802500,0x962460,0x20001b27,0x2802100,
0x962460,0x20001b27,0x2802100,0x962461,0x20001b27,0x2802400,0x962460,0x20001b27,0x2806400,0x962460,0x20001b27,0x2902100,0x962462,0x20001b27,0x4000000,0x200000,
0x20001b27,0x4000000,0x400000,0x20001b27,0x4000000,0x500000,0x20001b27,0x4000000,0x810000,0x20001b27,0x4000000,0xb00000,0x20001b27,0x4000000,0xc0000b,0x20001b27,
0x4000000,0x1410000,0x20001b27,0x4000010,0xb00000,0x20001b27,0x4000010,0xc00000,0x20001b27,0x6800000,0x1329800,0x20001b27,0x6800100,0x462540,0x20001b27,0x6800400,
0x962540,0x20001b27,0x7c00100,0x230400,0x20001b27,0x7c00100,0x230401,0x20002619,0x7c00100,0x220401,0x20002a00,0x4000000,0x1600000,0x20004b67,0,0x1900020,
0x20004c67,0,0x1900020,0x20004d67,0,0x1900020,0x20006d67,0x1000,0,0x20006e67,0x1000,0,0x20026d67,0,0,0x20026e67,
0,0,0x200a4a12,0x7c00100,0x1f304c1,0x200a4a12,0x7c00100,0x20304e1,0x21005600,0x4000000,0x700000,0x21022a00,0x4000000,0x1600000,0x30000419,0x7c00100,
0x220400,0x30000419,0x7c00100,0x220401,0x30000419,0x7c00100,0x250400,0x30000419,0x7c00100,0x250401,0x30000519,0x7c00100,0x220400,0x30000600,0x4000400,0x200000,
0x30000600,0x7c00500,0x230400,0x30000605,0x4000400,0x200000,0x3000080e,0x7c00100,0x220400,0x30000908,0x2000,0x962460,0x30000908,0x7c00100,0x220400,0x30000908,
0x7c00100,0x220401,0x30000908,0x7c00100,0x250400,0x30000908,0x7c00100,0x250401,0x30000a03,0x4000006,0x400000,0x30000c02,0x4000000,0x200000,0x30000c02,0x7c00100,
0x230400,0x30000d22,0,0x218820,0x30000d22,0x2802100,0x962460,0x30000d22,0x2802400,0x962460,0x30000d22,0x2802500,0x962460,0x30000d22,0x4000000,0x200000,
0x30000d22,0x4000010,0x200000,0x30000d22,0x7c00100,0x230400,0x30000d22,0xc000010,0x248000,0x30000e25,0x2802500,0x962460,0x30000e25,0x7c00100,0x230400,0x30001821,
0x2802100,0x962460,0x30001821,0x2806400,0x962460,0x30001821,0x4000000,0x200000,0x30001821,0x6800100,0x962540,0x30001821,0x6800100,0x962541,0x30001821,0x7c00100,
0x230400,0x30001b27,0x2802100,0x962460,0x30001b27,0x2802400,0x962460,0x30001b27,0x4000000,0x200000,0x30001b27,0x4000000,0x400000,0x30001b27,0x7c00100,0x230400,
0x30001c1c,0x2802100,0x1862460,0x30001c1c,0x2802400,0x1862460,0x30001c1c,0x2806400,0x1862460,0x30001c1c,0x4000000,0x200000,0x30001c1c,0x6800100,0x1862400,0x30001c1c,
0x6800100,0x1862540,0x30001c1c,0x7c00100,0x1830000,0x30001c1c,0x7c00100,0x1830001,0x30001c1c,0xc000010,0x448000,0x30001f0b,0x4000000,0x200000,0x30001f0b,0x4000010,
0x200000,0x30001f0b,0x4000010,0x400000,0x30001f0b,0x6800000,0x200000,0x30001f0b,0x7c00100,0x230400,0x30001f0b,0xc000010,0x248000,0x30002006,0x7c00100,0x230400,
0x30002128,0x4000010,0x200000,0x30002128,0x7c00100,0x230400,0x30002128,0xc000010,0x248000,0x3000221d,0x4000000,0x810000,0x3000221d,0x4000000,0x1410000,0x3000221d,
0x4000001,0x440000,0x3000221d,0x7c00100,0x230400,0x30002300,0x4000010,0x400000,0x30002320,0x7c00100,0x230400,0x30002417,0x2802100,0x1862460,0x30002417,0x2802400,
0x1862460,0x30002417,0x2806400,0x1862460,0x30002417,0x2882000,0x1862460,0x30002417,0x4000000,0x200000,0x30002417,0x4000000,0x400000,0x30002417,0x4000000,0x1600000,
0x30002417,0x4000010,0x400000,0x30002417,0x4000010,0x1200000,0x30002417,0x6800000,0x1329800,0x30002417,0x6800100,0x1862540,0x30002417,0x7c00100,0x1830000,0x30002417,
0x7d00100,0x1830000,0x3000251b,0x80000,0xc18820,0x3000251b,0x2802100,0x962460,0x3000251b,0x4000000,0x200000,0x3000251b,0x4000006,0x500000,0x3000251b,0x4000010,
0x400000,0x3000251b,0x4000010,0xb70000,0x3000251b,0x4000800,0x200000,0x3000251b,0x6800000,0x1329800,0x3000251b,0x7c00100,0x230400,0x3000251b,0x7c00900,0x230400,
0x3000251b,0xc000010,0xb48000,0x3000251b,0x12882000,0x962460,0x30002800,0x4000001,0xc4000b,0x30002800,0x24000000,0x200000,0x30002800,0x2c000010,0x1248002,0x30002a00,
0x4000000,0x1600000,0x30002b01,0x2000,0x962460,0x30002c00,0x4000000,0x200000,0x30002c00,0x7c00100,0x220405,0x30002d19,0x7c00100,0x250400,0x30002e00,0x24000000,
0x200000,0x30003000,0x24000000,0x200000,0x30003100,0x24000000,0x200000,0x30003600,0x24000000,0x200000,0x30003700,0x24000000,0x200000,0x3000392e,0x24000000,0x200000,
0x30005013,0x7c00100,0x2633801,0x30005600,0,0x918820,0x30020600,0x4000400,0x500000,0x30020701,0x2802400,0x962460,0x30020701,0x2802400,0xc62460,0x300a3a11,
0x4020000,0xe00000,0x300a3a11,0x4020000,0xe00002,0x300a3b11,0x4020000,0xe00002,0x300a3c00,0x4008000,0xe00000,0x300a3c00,0x4010000,0xe00000,0x300a3d11,0x7c00300,
0xe30002,0x300a4305,0x7c00100,0xe30400,0x300a4611,0x7c40300,0xe30000,0x300a4829,0x7c00100,0xe30400,0x300a4829,0x7c00900,0x1230400,0x300a4929,0x4000000,0xe00000,
0x3040252b,0x4000010,0x400000,0x3040252b,0x4000010,0xb70000,0x3040252b,0xc000010,0xb48000,0x304a3d34,0x4000000,0xe00000,0x30800c0e,0x2802100,0x962460,0x30c01c25,
0x6800000,0x1329800,0x3100080e,0x7c00120,0x220402,0x3100080e,0x7c00120,0x250402,0x31005167,0x1000,0,0x3100581e,0x4000000,0x200000,0x3100581e,0x7c00100,
0x230400,0x3100590d,0x7c00100,0x230400,0x31005a09,0x7c00100,0x220400,0x31005a09,0x7c00100,0x250400,0x31005b00,0x4000000,0x200000,0x31005c00,0x80000,0x918820,
0x31005c00,0x2802000,0x962460,0x31005c00,0x2802400,0x962460,0x31005c00,0x4000000,0x200000,0x31005c00,0x4000000,0x200001,0x31005c00,0x6800000,0x962540,0x31005c00,
0x6800400,0x962540,0x31005c01,0x2802400,0x962460,0x31005d00,0x4000020,0x200005,0x31005d00,0x6800020,0x1329805,0x31005d00,0x7c00120,0x220405,0x31005d00,0x7c00120,
0x250405,0x31006000,0x180000,0x918820,0x310a5e11,0x7c40300,0xe30000,0x310a5f11,0x7c00300,0xe30001,0x32000419,0x7c00100,0x250400,0x3200080e,0x4000020,0x200000,
0x3200080e,0x7c00100,0x220400,0x3200080e,0x7c00100,0x250400,0x32000908,0x7c00100,0x220400,0x32000908,0x7c00100,0x250400,0x32000c02,0x7c00100,0x230400,0x32000e25,
0x7c00100,0x230400,0x32001d0c,0x7c00100,0x230400,0x32002800,0x80000,0x1e18820,0x32002800,0x80020,0x218820,0x32002800,0x4000001,0x440002,0x32002800,0x24000000,
0x200000,0x32002800,0x24000000,0x200002,0x32002800,0x24000020,0x200000,0x32002800,0x2c000010,0x1248002,0x32002919,0x7c00100,0x22040f,0x32002a00,0x4000000,0x1600000,
0x32002b01,0x2000,0x962460,0x32002b01,0x2802000,0x962460,0x32002b01,0x2802020,0x962460,0x32002c00,0x4000000,0x200000,0x32002c00,0x4000020,0x200000,0x32002c00,
0x4000020,0x200005,0x32002c00,0x7c00120,0x220405,0x32002c00,0x7c00120,0x250405,0x32002e00,0x24000020,0x200000,0x32002f00,0x24000020,0x200000,0x32003000,0x24000000,
0x200000,0x32003000,0x24000020,0x200000,0x32003500,0x24000000,0x200000,0x32003600,0x24000020,0x200000,0x32003700,0x24000000,0x100000,0x32003700,0x24000000,0x200000,
0x32003800,0x24000000,0x810000,0x32003800,0x24000000,0x1410000,0x32005102,0x4000000,0x1500008,0x32005502,0x7c00100,0x230400,0x32006108,0x7c00100,0x220400,0x32006108,
0x7c00100,0x250400,0x3200622a,0x2802100,0x962460,0x3200622a,0x2806000,0x962460,0x3200622a,0x7c00100,0x230400,0x3200632b,0x2802100,0x962460,0x3200632b,0x2806000,
0x962460,0x3200632b,0x7c00100,0x230400,0x3200642c,0x2802100,0x962460,0x3200642c,0x7c00100,0x230400,0x3200652d,0x2802100,0x962460,0x3200652d,0x7c00100,0x230400,
0x32006600,0x24000020,0x200000,0x32006700,0x24000020,0x200000,0x32006800,0x24000020,0x200000,0x32006900,0x24000020,0x200000,0x32006900,0x24000020,0x810000,0x32006900,
0x24000020,0x1410000,0x32006a00,0x24000020,0x200000,0x32006a00,0x24000020,0x200001,0x32006a00,0x24000020,0x200002,0x32020701,0x2882000,0xc62460,0x32023300,0x4000000,
0x100000,0x32026c01,0x12882000,0x962460,0x32065700,0x4000000,0x810011,0x32065700,0x4000000,0x1410011,0x32086600,0x24000020,0x810000,0x32086600,0x24000020,0x1410000,
0x32086900,0x24000020,0x810000,0x32086900,0x24000020,0x1410000,0x320a3d11,0x7c00100,0x1230400,0x320a3e14,0x7c00100,0xe30010,0x320a3e14,0x7c00100,0x2530000,0x320a3f16,
0x7c00100,0xe30c10,0x320a4400,0x4000000,0xe00003,0x320a4929,0x4000000,0xe00000,0x320a4f11,0x7c00300,0xe30001,0x320a6b16,0x7c00100,0x2530c00,0x32406327,0xc000000,
0x448000,0x324a3d39,0x4000000,0xe00000,0x324a3d39,0x7c00100,0x1230400,0x324a3f37,0x4000002,0x1200c00,0x324a5334,0x24000000,0xe00000,0x32820701,0x2802000,0x962460,
0x40000419,0x7c00100,0x220400,0x40000519,0x7c00100,0x220400,0x40000600,0x4000400,0x200000,0x4000080e,0x7c00100,0x220400,0x4000080e,0x7c00100,0x250400,0x4000080e,
0x7c00100,0x250402,0x40000c02,0,0x218820,0x40000c02,0x2802100,0x962460,0x40000c02,0x2802400,0x962460,0x40000c02,0x2802500,0x962460,0x40000c02,0x4000000,
0x200000,0x40000c02,0x4000000,0x1071400,0x40000c02,0x7c00100,0x230400,0x40000d22,0x7c00100,0x230400,0x40000f0a,0x7c00100,0x230400,0x40001004,0x7c00100,0x230400,
0x40001110,0x2802100,0x962460,0x40001110,0x6800100,0x962540,0x4000120f,0x2802100,0x962460,0x4000120f,0x4000000,0x1600000,0x4000120f,0x7c00100,0x230400,0x4000131f,
0x7c00100,0x230400,0x40001423,0x4000000,0x200000,0x40001423,0x4000000,0x1600000,0x40001615,0x2802400,0x962460,0x40001615,0x7c00100,0x230400,0x40002417,0x2802400,
0x1862460,0x40002417,0x4000000,0x200000,0x40002800,0x6800000,0x201c00,0x40002800,0x24000002,0x200000,0x40002c00,0x4000000,0x200002,0x40003000,0x24000000,0x200000,
0x40003000,0x24000020,0x200000,0x40003700,0x24000000,0x200000,0x40005a09,0x7c00100,0x220400,0x40005a09,0x7c00100,0x250400,0x40005d00,0x7c00120,0x220405,0x40006f30,
0x2802100,0x962460,0x40006f30,0x2802400,0x962460,0x40006f30,0x4000000,0x200000,0x40006f30,0x6800000,0x1329800,0x40006f30,0x6800100,0x962540,0x40006f30,0x7c00100,
0x230400,0x40006f30,0xc000010,0xb48000,0x40007034,0x7c00100,0x1830000,0x40007117,0x4000000,0x200000,0x40007208,0x7c00100,0x220400,0x4000720e,0x7c00100,0x220400,
0x4000720e,0x7c00500,0x22040e,0x4000720e,0x7c00500,0x22040f,0x40007219,0x7c00100,0x220400,0x40007219,0x7c00500,0x220400,0x40007219,0x7c00500,0x22040e,0x40007219,
0x7c00500,0x22040f,0x40007300,0x24000000,0x200000,0x40007400,0x4000000,0x200000,0x40007531,0x7c00100,0x230400,0x40007631,0x7c00100,0x230400,0x40007835,0x4000010,
0x400000,0x40007835,0x7c00100,0x230400,0x40007933,0x7c00100,0x230400,0x40007a32,0x6800000,0x1329800,0x40007a32,0x7c00100,0x230400,0x40007b2f,0x7c00100,0x230400,
0x40007c00,0x4000000,0x200000,0x40020701,0x2802400,0x962460,0x40020701,0x2802400,0xc62460,0x40023300,0x4000000,0x200000,0x40023700,0x24000000,0xe00000,0x40027d01,
0x12882000,0x962460,0x400a4400,0x4000000,0xe0000d,0x400a4412,0x4000000,0xe00002,0x400a4412,0x4000000,0xe00003,0x400a4500,0x4000000,0xe0000d,0x400a5300,0x4000000,
0x810010,0x400a5300,0x4000000,0x1410010,0x40405110,0x4000000,0x200000,0x40407747,0x4000000,0x200000,0x40407747,0x4000000,0x400000,0x41000419,0x7c00100,0x220400,
0x41000419,0x7c00100,0x250400,0x4100080e,0x7c00100,0x220400,0x4100080e,0x7c00100,0x250400,0x41000908,0x7c00100,0x220400,0x41000908,0x7c00100,0x250400,0x41000b13,
0x2802000,0x962460,0x41000b13,0x2802100,0x962460,0x41000b13,0x4000000,0xb00000,0x41000c02,0x2802100,0x962460,0x41000c02,0x4000000,0xb00000,0x41000c02,0x4000000,
0x1500000,0x41000f0a,0x7c00100,0x230400,0x41001004,0x7c00100,0x230400,0x41001423,0x6800000,0x1329800,0x41001423,0x7c00100,0x230400,0x41001b27,0x4000000,0x500000,
0x41001d0c,0x7c00100,0x230400,0x41001d0c,0x7c00100,0x23040f,0x41001f0b,0x2802100,0x962460,0x41001f0b,0x4000000,0x200000,0x41001f0b,0x7c00100,0x230400,0x41002800,
0x24000000,0x200000,0x41002800,0x24000000,0x400000,0x41002919,0x7c00100,0x22040e,0x41002a00,0x4000000,0x1600000,0x41002b01,0x2802020,0x962460,0x41002c00,0x4000000,
0x200000,0x41002c00,0x7c00120,0x220405,0x41003000,0x24000000,0x200000,0x41003700,0x24000000,0x200000,0x41003700,0x24000000,0xe00000,0x41005d00,0x7c00120,0x220405,
0x41006600,0x24000020,0x200000,0x41006600,0x24000020,0x810000,0x41006600,0x24000020,0x1410000,0x41007208,0x7c00100,0x22040f,0x41007219,0x7c00100,0x220400,0x41007300,
0x24000000,0x200000,0x41007e0e,0x2802000,0x962460,0x41007e0e,0x4000000,0x200000,0x41007f0e,0x4000000,0x200000,0x41007f0e,0x7c00100,0x230400,0x41008002,0x7c00100,
0x230400,0x41008137,0x2802100,0x962460,0x41008137,0x4000000,0x200000,0x41008137,0x6800100,0x962540,0x41008137,0x7c00100,0x230400,0x41008301,0x2802000,0x962460,
0x41008407,0x4000000,0x200000,0x41008407,0x4000000,0x400000,0x41008407,0x4000000,0xb00000,0x41008407,0x7c00100,0x220400,0x41008407,0x7c00100,0x250400,0x4100850b,
0x7c00100,0x230400,0x4100860b,0x4000000,0x200000,0x4100860b,0x7c00100,0x230400,0x4100870c,0x7c00100,0x220400,0x41008838,0x7c00100,0x220400,0x41008838,0x7c00100,
0x250400,0x41008939,0x2802000,0x962460,0x41008939,0x2802100,0x962460,0x41008939,0x2806000,0x962460,0x41008939,0x4000000,0x200000,0x41008939,0x4000000,0x400000,
0x41008939,0x7c00100,0x230400,0x41008939,0xc000000,0x448000,0x41008a00,0x4000000,0x200000,0x41008b3b,0x4000000,0x1800000,0x41008b3b,0x6800000,0x1329800,0x41008b3b,
0x6800100,0x1862400,0x41008b3b,0x6800100,0x1862540,0x41008b3b,0x7c00100,0x1830000,0x41008c3d,0x4000010,0x400000,0x41008c3d,0x7c00100,0x230400,0x41008d0e,0x7c00100,
0x22040f,0x41008d19,0x7c00100,0x220400,0x41008d19,0x7c00100,0x22040f,0x41008e00,0x24000000,0x200000,0x41008e00,0x24000000,0x400000,0x41008e00,0x24000000,0x1710000,
0x41008e00,0x24000006,0x400000,0x41008f3a,0x2802000,0x962460,0x41008f3a,0x2802100,0x962460,0x41008f3a,0x2806000,0x962460,0x41008f3a,0x4000000,0x200000,0x41008f3a,
0x6800100,0x962540,0x41008f3a,0x7c00100,0x230400,0x4100903c,0x7c00100,0x230400,0x4100903c,0x7c00100,0x23040f,0x41020701,0x2802000,0x962460,0x41020701,0x2802000,
0xc62460,0x410a4412,0x4000000,0xe00003,0x410a4711,0x7c40300,0xe30000,0x410a4f11,0x7c00300,0xe30001,0x410a9100,0x4000000,0x800010,0x410a9100,0x4000000,0x810010,
0x410a9100,0x4000000,0x870010,0x410a9100,0x4000000,0xb00010,0x410a9100,0x4000000,0xf00010,0x410a9100,0x4000000,0x1001410,0x410a9100,0x4000000,0x1071010,0x410a9100,
0x4000000,0x1071410,0x410a9100,0x4000000,0x1410010,0x414a8234,0x4000000,0xe00000,0x41808300,0x2802000,0x962460,0x50000419,0x7c00100,0x220400,0x50000419,0x7c00100,
0x250400,0x5000080e,0x7c00100,0x220400,0x50000908,0x7c00100,0x220400,0x50000908,0x7c00100,0x250400,0x50000b13,0x2802500,0x962460,0x50000f0a,0x7c00100,0x230400,
0x50001615,0x2802100,0x962460,0x50001615,0x7c00100,0x230400,0x50002b01,0x2802020,0x962460,0x50002c00,0x4000000,0x200000,0x50002c19,0x7c00100,0x220400,0x50002d19,
0x7c00100,0x220400,0x50003000,0x24000000,0x200000,0x50003000,0x24000020,0x200000,0x50003700,0x24000000,0x200000,0x50005d00,0x7c00120,0x220405,0x50005d00,0x7c00120,
0x250405,0x50006108,0x7c00100,0x220400,0x50006108,0x7c00100,0x250400,0x50006600,0x24000020,0x200000,0x50007300,0x24000000,0x200000,0x50008301,0x2802400,0x962460,
0x50008a00,0x7c00500,0x230400,0x50009257,0x2802400,0x962460,0x50009257,0x4000000,0x200000,0x50009257,0x4000010,0x1071400,0x50009257,0x6800000,0x1329800,0x50009257,
0x7c00100,0x230400,0x50009257,0x7c00500,0x230400,0x50009257,0x7c00900,0x230400,0x50009257,0xc000010,0xb48000,0x5000933e,0x2802100,0x962460,0x5000933e,0x2802400,
0x962460,0x5000933e,0x4000000,0x200000,0x5000933e,0x4000000,0x400000,0x5000933e,0x4000010,0x400000,0x5000933e,0x6800000,0x1329800,0x5000933e,0x6800100,0x962540,
0x5000933e,0x6800100,0x962541,0x5000933e,0x6804400,0x962540,0x5000933e,0x7c00100,0x230400,0x5000933e,0x7c00100,0x230401,0x5000933e,0xc000010,0x448000,0x50009419,
0x7c00100,0x220400,0x50009419,0x7c00100,0x250400,0x50009500,0x4000400,0x200000,0x5000965a,0x4000000,0x500000,0x5000965a,0x7c00100,0x230400,0x5000965a,0xc000010,
0xb48000,0x5000975b,0x4000000,0x200000,0x5000975b,0x4000010,0x400000,0x5000975b,0x7c00100,0x230400,0x50009865,0x7c00100,0x230400,0x50009965,0x4000010,0x400000,
0x50009965,0x7c00100,0x230400,0x50009a00,0x4000000,0x200000,0x5100080e,0x7c00100,0x220400,0x5100080e,0x7c00100,0x250400,0x51000908,0x2802400,0x962460,0x51000c02,
0x2802100,0x962460,0x51000c02,0x4000000,0x1500000,0x51000c02,0x4000020,0x200000,0x51000c02,0x7c00100,0x230400,0x51000f0a,0x7c00100,0x230400,0x51000f0a,0x7c00500,
0x230400,0x51001110,0x2802100,0x962460,0x5100131f,0x2802100,0x962460,0x51001423,0x7c00100,0x230400,0x51001524,0x2802100,0x962460,0x51001524,0x4000000,0x200000,
0x51001524,0x7c00100,0x230400,0x5100171a,0x2802100,0x962460,0x5100171a,0x4000000,0x200000,0x5100171a,0x4000000,0x1500000,0x5100171a,0x7c00100,0x230400,0x51001b27,
0x4000000,0x200000,0x51001b27,0x4000000,0x400000,0x51001b27,0x4000000,0x500000,0x51001b27,0x7c00100,0x230400,0x51001c1c,0x2802100,0x1862460,0x51001c1c,0x2802400,
0x1862460,0x51001c1c,0x2806400,0x1862460,0x51001c1c,0x4000000,0x1800000,0x51001c1c,0x6800000,0x1329800,0x51001c1c,0x6800000,0x1862400,0x51001c1c,0x6800100,0x1862400,
0x51001c1c,0x6800100,0x1862540,0x51001c1c,0x6800400,0x1862400,0x51001c1c,0x7c00100,0x1830000,0x5100251b,0x7c00100,0x230400,0x51002619,0x7c00100,0x220400,0x51002619,
0x7c00100,0x250400,0x51002800,0x80020,0x218820,0x51002b01,0x2802000,0x962460,0x51002c00,0x4000000,0x200000,0x51002d19,0x7c00100,0x230400,0x51003700,0x24000000,
0x200000,0x51003700,0x24000000,0xe00000,0x51005201,0x2802400,0x962460,0x51005c00,0x4000000,0x200000,0x51006108,0x7c00100,0x220400,0x51006108,0x7c00100,0x250400,
0x51006600,0x24000020,0x200000,0x51006600,0x24000020,0x810000,0x51006600,0x24000020,0x1410000,0x51007300,0x24000000,0x200000,0x51007300,0x24000020,0x200000,0x51008002,
0x7c00100,0x230400,0x51008301,0x2802000,0x962460,0x51008301,0x2802400,0x962460,0x51008a00,0x7c00500,0x230400,0x51008e00,0x24000000,0x200000,0x51008e00,0x24000000,
0x400000,0x51008e00,0x24000000,0x810000,0x51008e00,0x24000000,0x1400000,0x51008e00,0x24000000,0x1410000,0x51008e00,0x24000000,0x1710000,0x51008e00,0x24000002,0x200000,
0x51008e00,0x24000500,0x230400,0x51008e00,0x2c000010,0xb48000,0x51009419,0x7c00100,0x220400,0x51009419,0x7c00100,0x22040e,0x51009419,0x7c00100,0x22040f,0x51009419,
0x7c00100,0x250400,0x51009500,0x4000000,0x200000,0x51009500,0x7c00500,0x230400,0x51009519,0x7c00100,0x220400,0x51009519,0x7c00100,0x22040f,0x51009519,0x7c00100,
0x230400,0x51009519,0x7c00100,0x250400,0x51009b71,0x2802100,0x962460,0x51009b71,0x6800000,0x1329800,0x51009b71,0x6800100,0x962540,0x51009b71,0x6804400,0x962540,
0x51009b71,0x7c00100,0x230400,0x51009c52,0x2802100,0x962460,0x51009c52,0x2802400,0x962460,0x51009c52,0x2802c00,0x962460,0x51009c52,0x4000010,0x400000,0x51009c52,
0x6800000,0x1329800,0x51009c52,0x6800100,0x962540,0x51009c52,0x7c00100,0x230400,0x51009c52,0xc000010,0x448000,0x51009d6d,0x6800000,0x1329800,0x51009d6d,0x7c00100,
0x230400,0x51009d6d,0x7c00500,0x230400,0x51009d6d,0x7c00d00,0x230400,0x51009d6d,0xc000010,0x448000,0x51009e08,0x2802100,0x962460,0x51009f63,0x4000010,0x400000,
0x51009f63,0x6800000,0x1329800,0x51009f63,0x7c00100,0x230400,0x51009f63,0x7c00900,0x230400,0x51009f63,0xc000010,0x448000,0x51009f63,0xc000010,0xb48000,0x5100a008,
0x2000,0x962460,0x5100a008,0x2802400,0x962460,0x5100a008,0x4000000,0x200000,0x5100a008,0x7c00100,0x220400,0x5100a008,0x7c00100,0x230400,0x5100a008,0x7c00100,
0x250400,0x5100a008,0x7c00500,0x230400,0x5100a16f,0x2806400,0x962460,0x5100a16f,0x6800000,0x1329800,0x5100a16f,0x6800100,0x962540,0x5100a16f,0x7c00100,0x230400,
0x5100a16f,0xc000010,0x448000,0x5100a24f,0x2802100,0x962460,0x5100a24f,0x2802400,0x962460,0x5100a24f,0x4000400,0x400000,0x5100a24f,0x6800000,0x1329800,0x5100a24f,
0x7c00100,0x230400,0x5100a24f,0xc000010,0x448000,0x5100a36e,0x2802100,0x962460,0x5100a36e,0x4000000,0x200000,0x5100a36e,0x6800100,0x962540,0x5100a36e,0x6804400,
0x962540,0x5100a36e,0x7c00100,0x230400,0x5100a442,0x2802100,0x962460,0x5100a442,0x4000000,0x200000,0x5100a442,0x6800000,0x1329800,0x5100a442,0x6800100,0x962540,
0x5100a442,0x7c00100,0x230400,0x5100a442,0xc000010,0x448000,0x5100a500,0x4000000,0x200000,0x5100a600,0x4000000,0x200000,0x5100a601,0x2802000,0x962460,0x5100a76b,
0x7c00100,0x230400,0x5100a868,0x7c00100,0x230400,0x5100a96c,0x4000000,0x200000,0x5100a96c,0x7c00100,0x230400,0x5100aa00,0x4000000,0xe00000,0x5100ab00,0x4000000,
0xe00000,0x51086600,0x24000020,0x810000,0x51086600,0x24000020,0x1410000,0x510a4005,0x7c00100,0xe30400,0x510a4711,0x7c40300,0xe30000,0x514a8234,0x4000000,0xe00000,
0x52000f0a,0x2802100,0x962460,0x52000f0a,0x6800100,0x962540,0x52000f0a,0x7c00100,0x230400,0x52001004,0x4000000,0x1600000,0x52001b00,0x4000000,0x200000,0x52001c1c,
0x2802100,0x1862460,0x52001c1c,0x6800100,0x1862400,0x52001c1c,0x6800400,0x1862400,0x52001e12,0x7c00100,0x2230500,0x52001e12,0x7c00100,0x2330520,0x52002128,0x4000002,
0x400000,0x52002128,0x7c00100,0x230400,0x52002a00,0x4000000,0x1500000,0x52002a00,0x4000000,0x1600000,0x52002d00,0x4000000,0x200006,0x52003000,0x24000000,0x200000,
0x52003700,0x24000000,0xe00000,0x52006108,0x7c00100,0x220400,0x52006108,0x7c00100,0x250400,0x52008301,0x2802400,0x962460,0x52008407,0x2802400,0x962460,0x52008407,
0x7c00100,0x220400,0x52008407,0x7c00100,0x250400,0x52008b3b,0x6800000,0x1800000,0x52008b3b,0x7c00100,0x1830000,0x52008e00,0x24000000,0x400000,0x52009419,0x7c00100,
0x250400,0x5200975b,0x4000000,0x200000,0x5200ac7e,0x2802000,0x962460,0x5200ac7e,0x2802100,0x962460,0x5200ac7e,0x2802400,0x962460,0x5200ac7e,0x4000010,0x200000,
0x5200ac7e,0x7c00100,0x230400,0x5200ad28,0x7c00100,0x230400,0x5200ae6a,0x2802100,0x1862460,0x5200ae6a,0x2802400,0x962460,0x5200ae6a,0x2802400,0x1862460,0x5200ae6a,
0x2806000,0x1862460,0x5200ae6a,0x4000000,0x1800000,0x5200ae6a,0x6800000,0x1329800,0x5200ae6a,0x6800100,0x1862400,0x5200ae6a,0x6800100,0x1862540,0x5200ae6a,0x7c00100,
0x1830000,0x5200ae6a,0x7c00900,0x1830000,0x5200ae6a,0xc000010,0x1848000,0x5200af00,0x4000400,0x200000,0x5200af00,0x7c00100,0x230400,0x5200b083,0x4000010,0x400000,
0x5200b083,0x7c00100,0x230400,0x5200b083,0xc000010,0x448000,0x5200b182,0x2802400,0x962460,0x5200b182,0x4000000,0x200000,0x5200b182,0x4000010,0x400000,0x5200b182,
0x7c00100,0x230400,0x5200b182,0xc000010,0x448000,0x5200b30a,0x2802400,0x962460,0x5200b30a,0x4000000,0x200000,0x5200b30a,0x7c00100,0x230400,0x5200b54e,0x2802100,
0x962460,0x5200b54e,0x2802400,0x962460,0x5200b54e,0x4000000,0x200000,0x5200b54e,0x4000010,0x400000,0x5200b54e,0x6800000,0x1329800,0x5200b54e,0x6800100,0x962540,
0x5200b54e,0x6804400,0x962540,0x5200b54e,0x7c00100,0x230400,0x5200b54e,0xc000010,0x448000,0x5200b61c,0x4000000,0x1800000,0x5200b61c,0x6800400,0x1862400,0x5200b61c,
0x7c00100,0x1830000,0x5200b61c,0x7c00900,0x1830000,0x5200b77f,0x2802100,0x1862460,0x5200b77f,0x2802400,0x1862460,0x5200b77f,0x4000000,0x1800000,0x5200b77f,0x4000010,
0x1800000,0x5200b77f,0x7c00100,0x1830000,0x5200b77f,0x7c00500,0x1830000,0x5200b77f,0x7c00900,0x1830000,0x5200b77f,0x7e00100,0x1830000,0x5200b873,0x2802100,0x962460,
0x5200b873,0x2806400,0x962460,0x5200b873,0x6800000,0x1329800,0x5200b873,0x6800100,0x962540,0x5200b873,0x6800400,0x962540,0x5200b873,0x7c00100,0x230400,0x5200b873,
0xc000010,0x448000,0x5200b912,0x7c00100,0x2230500,0x5200b912,0x7c00100,0x2330520,0x5200ba74,0x4000000,0x200000,0x5200ba74,0x4000010,0x400000,0x5200ba74,0x7c00100,
0x230400,0x5200bb85,0x4000000,0x200000,0x5200bb85,0x7c00100,0x230400,0x5200bc75,0x4000000,0x400000,0x5200bc75,0x4000010,0x400000,0x5200bc75,0x7c00100,0x230400,
0x5200bd7d,0x4000000,0x200000,0x5200bd7d,0x7c00100,0x230400,0x5200be7a,0x4000000,0x200000,0x5200be7a,0x7c00100,0x230400,0x5200bf58,0x7c00100,0x230400,0x5200c002,
0x4000000,0x200000,0x5200c178,0,0x218820,0x5200c178,0x2802000,0x962460,0x5200c178,0x2802100,0x962460,0x5200c178,0x2802400,0x962460,0x5200c178,0x2806400,
0x962460,0x5200c178,0x4000000,0x200000,0x5200c178,0x6800100,0x962540,0x5200c178,0x7c00100,0x230400,0x5200c178,0x7c00100,0x230401,0x5200c178,0xc000010,0x448000,
0x5200c247,0x7c00100,0x230400,0x5200c247,0x7c00100,0x830400,0x5200c247,0x7c00100,0x1430400,0x5200c300,0x4000000,0x200003,0x52022d00,0x4000000,0x100006,0x52023700,
0x24000000,0x100000,0x52023700,0x24000000,0xe00000,0x52023800,0x24000000,0x100000,0x52024400,0x4000000,0x100000,0x52027300,0x24000000,0x100000,0x5202c300,0x4000000,
0x100000,0x5202c300,0x4000000,0x100002,0x5202c300,0x4000000,0x100003,0x5202c300,0x4000000,0x10000d,0x520a1e12,0x7c00100,0x2130480,0x520a4400,0x4000000,0xe00003,
0x520a4711,0x7c40300,0xe30000,0x520a4f11,0x7c00300,0xe30001,0x520ab412,0x7c00100,0x2130480,0x520ac400,0x4000000,0xe00002,0x520ac400,0x4000000,0xe0000d,0x520ac414,
0x4000000,0xe0000d,0x520ac511,0x7c40300,0xe30000,0x5240af2d,0x6800100,0x962540,0x5240af2d,0x6800400,0x962540,0x5240b23e,0x4000000,0x200000,0x5240b23e,0x4000000,
0x1500000,0x5240b543,0x7c00900,0x230400,0x5280af2d,0x2802400,0x962460,0x60000c02,0x2802100,0x962460,0x60000c02,0x7c00100,0x230400,0x60000f0a,0x2802100,0x962460,
0x60000f0a,0x6800100,0x962540,0x60000f0a,0x7c00100,0x230400,0x6000131f,0x4000000,0x200000,0x6000171a,0x7c00100,0x230400,0x60001b27,0x2802100,0x962460,0x60001b27,
0x4000000,0xc00000,0x60001b27,0x7c00100,0x230400,0x60001f0b,0x2802000,0x962460,0x60002919,0x7c00100,0x22040e,0x60002a00,0x4000000,0x1600000,0x60003000,0x24000000,
0x200000,0x60003000,0x24000000,0xe00000,0x60003700,0x24000000,0x200000,0x60003800,0x24000000,0x200000,0x60003800,0x24000000,0xe00000,0x60005102,0x4000000,0x200000,
0x60006108,0x7c00100,0x220400,0x60006108,0x7c00100,0x250400,0x60006600,0x24000020,0x200000,0x60008301,0x2802000,0x962460,0x6000903c,0x2806000,0x962460,0x6000903c,
0x4000000,0x400000,0x60009519,0x7c00100,0x220400,0x60009519,0x7c00100,0x250400,0x6000a008,0x7c00100,0x220400,0x6000a008,0x7c00100,0x250400,0x6000c300,0x4000000,
0x2703580,0x6000c654,0x2802000,0x962460,0x6000c654,0x4000010,0x200000,0x6000c654,0x7c00100,0x230400,0x6000c73f,0x2802000,0x962460,0x6000c73f,0x2802100,0x962460,
0x6000c73f,0x4000000,0x200000,0x6000c73f,0x6800100,0x962540,0x6000c73f,0x6804000,0x962540,0x6000c73f,0x7c00100,0x230400,0x6000c80b,0x7c00100,0x230400,0x6000c941,
0x2802100,0x962460,0x6000c941,0x2806000,0x962460,0x6000c941,0x4000000,0x200000,0x6000c941,0x4000010,0x200000,0x6000c941,0x6800000,0x1329800,0x6000c941,0x6800100,
0x962540,0x6000c941,0x7c00100,0x230400,0x6000c941,0xc000010,0x448000,0x6000ca82,0x7c00100,0x230400,0x6000cc00,0x4000000,0xe00000,0x6000cd00,0x4000000,0x200000,
0x6000cd00,0x4000000,0xe00000,0x6000ce00,0x4000000,0xe00000,0x6000cf00,0x4000000,0xe00000,0x6000d000,0x4000000,0x200000,0x6002c300,0x4000000,0x100000,0x6002c300,
0x4000000,0x10000d,0x600a4305,0x7c00100,0xe30400,0x600ac400,0x4000000,0xe00003,0x600ac400,0x4000000,0xe0000d,0x600acb14,0x7c00100,0xe30000,0x600acb16,0x7c00100,
0xe30c00,0x600ad111,0x7c40300,0xe30000,0x61000a03,0x4000000,0x1600000,0x61000c02,0,0x218820,0x6100120f,0x4000000,0x200000,0x61001a18,0x7c00100,0x1830000,
0x61001d0c,0x7c00100,0x230400,0x61001d0c,0x7c00100,0x250400,0x61006600,0x24000020,0x200000,0x61008407,0x7c00100,0x220400,0x61008407,0x7c00100,0x250400,0x6100870c,
0x7c00100,0x220400,0x61008e00,0x24000000,0x200000,0x61008e00,0x24000000,0x400000,0x61008e00,0x24000002,0x300000,0x6100903c,0x7c00100,0x230400,0x61009519,0x7c00100,
0x220400,0x61009519,0x7c00100,0x250400,0x61009519,0x7c00500,0x22040f,0x61009b71,0x2806400,0x962460,0x61009b71,0x6800100,0x962540,0x61009b71,0x7c00100,0x230400,
0x6100a008,0x2802100,0x962460,0x6100af00,0x7c00100,0x230400,0x6100c300,0x4000000,0x20000f,0x6100cd00,0x4000000,0x200000,0x6100ce00,0x4000000,0xe00000,0x6100d202,
0x2802400,0x962460,0x6100d202,0x2802500,0x962460,0x6100d202,0x7c00100,0x230400,0x6100d302,0x4000020,0x200000,0x6100d302,0x7c00120,0x230405,0x6100d476,0x2802100,
0x962460,0x6100d476,0x2802100,0x962461,0x6100d476,0x2806400,0x962460,0x6100d476,0x4000000,0x400000,0x6100d476,0x6800000,0x1329800,0x6100d476,0x6800100,0x962540,
0x6100d476,0x7c00100,0x230400,0x6100d476,0xc000010,0x448000,0x6100d573,0x2802100,0x962460,0x6100d573,0x2806400,0x962460,0x6100d573,0x6800100,0x962540,0x6100d573,
0x7c00100,0x230400,0x6100d573,0x7c00900,0x230400,0x6100d573,0xc000010,0x448000,0x6100d68d,0x7c00100,0x230400,0x6100d756,0x7c00100,0x230400,0x6100d85c,0x2802400,
0x962460,0x6100d85c,0x6800100,0x962540,0x6100d85c,0x7c00100,0x230400,0x6100d85c,0x7c00500,0x230400,0x6100d997,0x2802100,0x962460,0x6100d997,0x4000000,0x200000,
0x6100d997,0x4000000,0x400000,0x6100d997,0x6800000,0x1329800,0x6100d997,0x6800100,0x962540,0x6100d997,0x6804400,0x962540,0x6100d997,0x7c00100,0x230400,0x6100d997,
0xc000010,0x448000,0x6100da98,0x6800000,0x1329800,0x6100da98,0x7c00100,0x230400,0x6100db71,0x4000000,0x200000,0x6100dc99,0x2802100,0x962460,0x6100dc99,0x2802400,
0x962460,0x6100dc99,0x6800000,0x1329800,0x6100dc99,0x6800100,0x962540,0x6100dc99,0x6804400,0x962540,0x6100dc99,0x7c00100,0x230400,0x610a4711,0x7c40300,0xe30000,
0x610a4f11,0x7c00300,0xe30001,0x6140af2d,0x6800100,0x962540,0x6180af2d,0x2802400,0x962460,0x62002a00,0x4000000,0x1600000,0x63002800,0x80000,0x918820,0x63c00c09,
0x80000,0x918820};
static const int32_t countPropsVectors=4914;
static const int32_t propsVectorsColumns=3;
static const uint16_t scriptExtensions[74]={
0x800e,0x8019,8,0x8019,3,0x800c,2,0x22,0x8025,2,6,2,0x22,0x8054,2,0x8022,
2,0x8025,0xa,0x8019,4,0xa,0x10,0x1f,0x8099,0xa,0x8078,0xa,0x19,4,0x3a,0x8076,
4,0x1d,0x1c,0x34,0x8076,0x1c,0x22,0x2a,0x2b,0x2c,0x802d,0x1b,0x805a,0x800a,5,0x11,
0x12,0x14,0x16,0x8029,5,0x11,0x12,0x14,0x8016,0x11,0x14,0x8016,5,0x8011,0xa,0xf,
0x10,0x78,0x8099,0x37,0x804e,2,0x10,0x2f,0x8031,0};
static const int32_t indexes[UPROPS_INDEX_COUNT]={0x2318,0x2318,0x2318,0x2318,0x50d6,3,0x6408,0x642d,0x642d,0x642d,0xadca0,0x2774191,0,0,0,0};
|
JimmyCushnie/runtime
|
src/mono/mono/mini/interp/transform.h
|
<filename>src/mono/mono/mini/interp/transform.h<gh_stars>1-10
#ifndef __MONO_MINI_INTERP_TRANSFORM_H__
#define __MONO_MINI_INTERP_TRANSFORM_H__
#include <mono/mini/mini-runtime.h>
#include <mono/metadata/seq-points-data.h>
#include "interp-internals.h"
#define INTERP_INST_FLAG_SEQ_POINT_NONEMPTY_STACK 1
#define INTERP_INST_FLAG_SEQ_POINT_METHOD_ENTRY 2
#define INTERP_INST_FLAG_SEQ_POINT_METHOD_EXIT 4
#define INTERP_INST_FLAG_SEQ_POINT_NESTED_CALL 8
#define INTERP_INST_FLAG_RECORD_CALL_PATCH 16
#define INTERP_INST_FLAG_CALL 32
// Flag used internally by the var offset allocator
#define INTERP_INST_FLAG_ACTIVE_CALL 64
// This instruction is protected by a clause
#define INTERP_INST_FLAG_PROTECTED_NEWOBJ 128
#define INTERP_LOCAL_FLAG_DEAD 1
#define INTERP_LOCAL_FLAG_EXECUTION_STACK 2
#define INTERP_LOCAL_FLAG_CALL_ARGS 4
#define INTERP_LOCAL_FLAG_GLOBAL 8
#define INTERP_LOCAL_FLAG_NO_CALL_ARGS 16
typedef struct _InterpInst InterpInst;
typedef struct _InterpBasicBlock InterpBasicBlock;
typedef struct
{
MonoClass *klass;
unsigned char type;
unsigned char flags;
/*
* The local associated with the value of this stack entry. Every time we push on
* the stack a new local is created.
*/
int local;
/* Saves how much stack this is using. It is a multiple of MINT_VT_ALIGNMENT */
int size;
} StackInfo;
#define LOCAL_VALUE_NONE 0
#define LOCAL_VALUE_LOCAL 1
#define LOCAL_VALUE_I4 2
#define LOCAL_VALUE_I8 3
// LocalValue contains data to construct an InterpInst that is equivalent with the contents
// of the stack slot / local / argument.
typedef struct {
// Indicates the type of the stored information. It can be another local or a constant
int type;
// Holds the local index or the actual constant value
union {
int local;
gint32 i;
gint64 l;
};
// The instruction that writes this local.
InterpInst *ins;
int def_index;
} LocalValue;
struct _InterpInst {
guint16 opcode;
InterpInst *next, *prev;
// If this is -1, this instruction is not logically associated with an IL offset, it is
// part of the IL instruction associated with the previous interp instruction.
int il_offset;
guint32 flags;
gint32 dreg;
gint32 sregs [3]; // Currently all instructions have at most 3 sregs
// This union serves the same purpose as the data array. The difference is that
// the data array maps exactly to the final representation of the instruction.
// FIXME We should consider using a separate higher level IR, that is also easier
// to use for various optimizations.
union {
InterpBasicBlock *target_bb;
InterpBasicBlock **target_bb_table;
// For call instructions, this represents an array of all call arg vars
// in the order they are pushed to the stack. This makes it easy to find
// all source vars for these types of opcodes. This is terminated with -1.
int *call_args;
} info;
// Variable data immediately following the dreg/sreg information. This is represented exactly
// in the final code stream as in this array.
guint16 data [MONO_ZERO_LEN_ARRAY];
};
struct _InterpBasicBlock {
int il_offset;
GSList *seq_points;
SeqPoint *last_seq_point;
InterpInst *first_ins, *last_ins;
/* Next bb in IL order */
InterpBasicBlock *next_bb;
gint16 in_count;
InterpBasicBlock **in_bb;
gint16 out_count;
InterpBasicBlock **out_bb;
int native_offset;
/*
* The state of the stack when entering this basic block. By default, the stack height is
* -1, which means it inherits the stack state from the previous instruction, in IL order
*/
int stack_height;
StackInfo *stack_state;
int index;
// This will hold a list of last sequence points of incoming basic blocks
SeqPoint **pred_seq_points;
guint num_pred_seq_points;
// This block has special semantics and it shouldn't be optimized away
int eh_block : 1;
int dead: 1;
};
typedef enum {
RELOC_SHORT_BRANCH,
RELOC_LONG_BRANCH,
RELOC_SWITCH
} RelocType;
typedef struct {
RelocType type;
/* For branch relocation, how many sreg slots to skip */
int skip;
/* In the interpreter IR */
int offset;
InterpBasicBlock *target_bb;
} Reloc;
typedef struct {
MonoType *type;
int mt;
int flags;
int indirects;
int offset;
int size;
int live_start, live_end;
// index of first basic block where this var is used
int bb_index;
union {
// If var is INTERP_LOCAL_FLAG_CALL_ARGS, this is the call instruction using it.
// Only used during var offset allocator
InterpInst *call;
// For local vars, this represents the instruction declaring it.
// Only used during super instruction pass.
InterpInst *def;
};
} InterpLocal;
typedef struct
{
MonoMethod *method;
MonoMethod *inlined_method;
MonoMethodHeader *header;
InterpMethod *rtm;
const unsigned char *il_code;
const unsigned char *ip;
const unsigned char *in_start;
InterpInst *last_ins, *first_ins;
int code_size;
int *in_offsets;
int current_il_offset;
unsigned short *new_code;
unsigned short *new_code_end;
unsigned int max_code_size;
StackInfo *stack;
StackInfo *sp;
unsigned int max_stack_height;
unsigned int stack_capacity;
gint32 param_area_offset;
gint32 total_locals_size;
InterpLocal *locals;
int *local_ref_count;
unsigned int il_locals_offset;
unsigned int il_locals_size;
unsigned int locals_size;
unsigned int locals_capacity;
int n_data_items;
int max_data_items;
void **data_items;
GHashTable *data_hash;
#ifdef ENABLE_EXPERIMENT_TIERED
GHashTable *patchsite_hash;
#endif
int *clause_indexes;
int *clause_vars;
gboolean gen_seq_points;
gboolean gen_sdb_seq_points;
GPtrArray *seq_points;
InterpBasicBlock **offset_to_bb;
InterpBasicBlock *entry_bb, *cbb;
int bb_count;
MonoMemPool *mempool;
MonoMemoryManager *mem_manager;
GList *basic_blocks;
GPtrArray *relocs;
gboolean verbose_level;
GArray *line_numbers;
gboolean prof_coverage;
MonoProfilerCoverageInfo *coverage_info;
GList *dont_inline;
int inline_depth;
int has_localloc : 1;
// If method compilation fails due to certain limits being exceeded, we disable inlining
// and retry compilation.
int disable_inlining : 1;
// If the current method (inlined_method) has the aggressive inlining attribute, we no longer
// bail out of inlining when having to generate certain opcodes (like call, throw).
int aggressive_inlining : 1;
} TransformData;
#define STACK_TYPE_I4 0
#define STACK_TYPE_I8 1
#define STACK_TYPE_R4 2
#define STACK_TYPE_R8 3
#define STACK_TYPE_O 4
#define STACK_TYPE_VT 5
#define STACK_TYPE_MP 6
#define STACK_TYPE_F 7
#if SIZEOF_VOID_P == 8
#define STACK_TYPE_I STACK_TYPE_I8
#else
#define STACK_TYPE_I STACK_TYPE_I4
#endif
/* test exports for white box testing */
void
mono_test_interp_cprop (TransformData *td);
gboolean
mono_test_interp_generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header, MonoGenericContext *generic_context, MonoError *error);
void
mono_test_interp_method_compute_offsets (TransformData *td, InterpMethod *imethod, MonoMethodSignature *signature, MonoMethodHeader *header);
/* debugging aid */
void
mono_interp_print_td_code (TransformData *td);
#endif /* __MONO_MINI_INTERP_TRANSFORM_H__ */
|
JimmyCushnie/runtime
|
src/coreclr/debug/createdump/crashinfo.h
|
<gh_stars>1-10
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifdef __APPLE__
#include "../dbgutil/machoreader.h"
#else
#include "../dbgutil/elfreader.h"
// typedef for our parsing of the auxv variables in /proc/pid/auxv.
#if TARGET_64BIT
typedef Elf64_auxv_t elf_aux_entry;
#define PRIx PRIx64
#define PRIu PRIu64
#define PRId PRId64
#define PRIA "016"
#define PRIxA PRIA PRIx
#else
typedef Elf32_auxv_t elf_aux_entry;
#define PRIx PRIx32
#define PRIu PRIu32
#define PRId PRId32
#define PRIA "08"
#define PRIxA PRIA PRIx
#endif
typedef __typeof__(((elf_aux_entry*) 0)->a_un.a_val) elf_aux_val_t;
// All interesting auvx entry types are AT_SYSINFO_EHDR and below
#define AT_MAX (AT_SYSINFO_EHDR + 1)
#endif
extern const std::string GetFileName(const std::string& fileName);
extern std::string FormatString(const char* format, ...);
extern std::string FormatGuid(const GUID* guid);
class CrashInfo : public ICLRDataEnumMemoryRegionsCallback,
#ifdef __APPLE__
public MachOReader
#else
public ElfReader
#endif
{
private:
LONG m_ref; // reference count
pid_t m_pid; // pid
pid_t m_ppid; // parent pid
pid_t m_tgid; // process group
HMODULE m_hdac; // dac module handle when loaded
bool m_gatherFrames; // if true, add the native and managed stack frames to the thread info
pid_t m_crashThread; // crashing thread id or 0 if none
uint32_t m_signal; // crash signal code or 0 if none
std::string m_name; // exe name
#ifdef __APPLE__
vm_map_t m_task; // the mach task for the process
#else
bool m_canUseProcVmReadSyscall;
int m_fd; // /proc/<pid>/mem handle
#endif
std::string m_coreclrPath; // the path of the coreclr module or empty if none
#ifdef __APPLE__
std::set<MemoryRegion> m_allMemoryRegions; // all memory regions on MacOS
#else
std::array<elf_aux_val_t, AT_MAX> m_auxvValues; // auxv values
std::vector<elf_aux_entry> m_auxvEntries; // full auxv entries
#endif
std::vector<ThreadInfo*> m_threads; // threads found and suspended
std::set<MemoryRegion> m_moduleMappings; // module memory mappings
std::set<MemoryRegion> m_otherMappings; // other memory mappings
std::set<MemoryRegion> m_memoryRegions; // memory regions from DAC, etc.
std::set<MemoryRegion> m_moduleAddresses; // memory region to module base address
std::set<ModuleInfo*, bool (*)(const ModuleInfo* lhs, const ModuleInfo* rhs)> m_moduleInfos; // module infos (base address and module name)
ModuleInfo* m_mainModule; // the module containing "Main"
// no public copy constructor
CrashInfo(const CrashInfo&) = delete;
void operator=(const CrashInfo&) = delete;
public:
CrashInfo(pid_t pid, bool gatherFrames, pid_t crashThread, uint32_t signal);
virtual ~CrashInfo();
bool Initialize();
void CleanupAndResumeProcess();
bool EnumerateAndSuspendThreads();
bool GatherCrashInfo(MINIDUMP_TYPE minidumpType);
bool ReadMemory(void* address, void* buffer, size_t size); // read memory and add to dump
bool ReadProcessMemory(void* address, void* buffer, size_t size, size_t* read); // read raw memory
uint64_t GetBaseAddressFromAddress(uint64_t address);
uint64_t GetBaseAddressFromName(const char* moduleName);
ModuleInfo* GetModuleInfoFromBaseAddress(uint64_t baseAddress);
void AddModuleAddressRange(uint64_t startAddress, uint64_t endAddress, uint64_t baseAddress);
void AddModuleInfo(bool isManaged, uint64_t baseAddress, IXCLRDataModule* pClrDataModule, const std::string& moduleName);
void InsertMemoryRegion(uint64_t address, size_t size);
static const MemoryRegion* SearchMemoryRegions(const std::set<MemoryRegion>& regions, const MemoryRegion& search);
inline pid_t Pid() const { return m_pid; }
inline pid_t Ppid() const { return m_ppid; }
inline pid_t Tgid() const { return m_tgid; }
#ifdef __APPLE__
inline vm_map_t Task() const { return m_task; }
#endif
inline const bool GatherFrames() const { return m_gatherFrames; }
inline const pid_t CrashThread() const { return m_crashThread; }
inline const uint32_t Signal() const { return m_signal; }
inline const std::string& Name() const { return m_name; }
inline const ModuleInfo* MainModule() const { return m_mainModule; }
inline const std::vector<ThreadInfo*>& Threads() const { return m_threads; }
inline const std::set<MemoryRegion>& ModuleMappings() const { return m_moduleMappings; }
inline const std::set<MemoryRegion>& OtherMappings() const { return m_otherMappings; }
inline const std::set<MemoryRegion>& MemoryRegions() const { return m_memoryRegions; }
#ifndef __APPLE__
inline const std::vector<elf_aux_entry>& AuxvEntries() const { return m_auxvEntries; }
inline size_t GetAuxvSize() const { return m_auxvEntries.size() * sizeof(elf_aux_entry); }
#endif
// IUnknown
STDMETHOD(QueryInterface)(___in REFIID InterfaceId, ___out PVOID* Interface);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();
// ICLRDataEnumMemoryRegionsCallback
virtual HRESULT STDMETHODCALLTYPE EnumMemoryRegion(/* [in] */ CLRDATA_ADDRESS address, /* [in] */ ULONG32 size);
private:
#ifdef __APPLE__
bool EnumerateMemoryRegions();
bool TryFindDyLinker(mach_vm_address_t address, mach_vm_size_t size, bool* found);
void VisitModule(MachOModule& module);
void VisitSegment(MachOModule& module, const segment_command_64& segment);
void VisitSection(MachOModule& module, const section_64& section);
#else
bool GetAuxvEntries();
bool GetDSOInfo();
void VisitModule(uint64_t baseAddress, std::string& moduleName);
void VisitProgramHeader(uint64_t loadbias, uint64_t baseAddress, ElfW(Phdr)* phdr);
bool EnumerateModuleMappings();
#endif
bool EnumerateMemoryRegionsWithDAC(MINIDUMP_TYPE minidumpType);
bool EnumerateManagedModules(IXCLRDataProcess* pClrDataProcess);
bool UnwindAllThreads(IXCLRDataProcess* pClrDataProcess);
void ReplaceModuleMapping(CLRDATA_ADDRESS baseAddress, ULONG64 size, const std::string& pszName);
void InsertMemoryBackedRegion(const MemoryRegion& region);
void InsertMemoryRegion(const MemoryRegion& region);
uint32_t GetMemoryRegionFlags(uint64_t start);
bool ValidRegion(const MemoryRegion& region);
void CombineMemoryRegions();
void Trace(const char* format, ...);
void TraceVerbose(const char* format, ...);
};
|
JimmyCushnie/runtime
|
src/coreclr/vm/comcallablewrapper.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*============================================================
**
** Header: Com Callable wrapper classes
**
===========================================================*/
#ifndef _COMCALLABLEWRAPPER_H
#define _COMCALLABLEWRAPPER_H
#ifdef FEATURE_COMINTEROP
#include "vars.hpp"
#include "stdinterfaces.h"
#include "threads.h"
#include "comutilnative.h"
#include "comtoclrcall.h"
#include "dispatchinfo.h"
#include "wrappers.h"
#include "internalunknownimpl.h"
#include "util.hpp"
class CCacheLineAllocator;
class ConnectionPoint;
class MethodTable;
class ComCallWrapper;
struct SimpleComCallWrapper;
struct ComMethodTable;
typedef DPTR(struct SimpleComCallWrapper) PTR_SimpleComCallWrapper;
// Terminator to indicate that indicates the end of a chain of linked wrappers.
#define LinkedWrapperTerminator (PTR_ComCallWrapper)-1
class ComCallWrapperCache
{
public:
// Encapsulate a SpinLockHolder, so that clients of our lock don't have to know
// the details of our implementation.
class LockHolder : public CrstHolder
{
public:
LockHolder(ComCallWrapperCache *pCache)
: CrstHolder(&pCache->m_lock)
{
WRAPPER_NO_CONTRACT;
}
};
ComCallWrapperCache();
~ComCallWrapperCache();
// create a new WrapperCache (one per each LoaderAllocator)
static ComCallWrapperCache* Create(LoaderAllocator *pLoaderAllocator);
// refcount
LONG AddRef();
LONG Release();
CCacheLineAllocator* GetCacheLineAllocator()
{
CONTRACT (CCacheLineAllocator*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
RETURN m_pCacheLineAllocator;
}
LoaderAllocator* GetLoaderAllocator()
{
CONTRACT (LoaderAllocator*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
RETURN m_pLoaderAllocator;
}
private:
LONG m_cbRef;
CCacheLineAllocator* m_pCacheLineAllocator;
LoaderAllocator* m_pLoaderAllocator;
// spin lock for fast synchronization
Crst m_lock;
};
//---------------------------------------------------------------------------------
// COM called wrappers on CLR objects
// Purpose: Expose CLR objects as COM classic Interfaces
// Reqmts: Wrapper has to have the same layout as the COM2 interface
//
// The wrapper objects are aligned at 16 bytes, and the original this
// pointer is replicated every 16 bytes, so for any COM2 interface
// within the wrapper, the original 'this' can be obtained by masking
// low 4 bits of COM2 IP.
//
// 16 byte aligned COM2 Vtable
// +-----------+
// | Org. this |
// +-----------+ +-----+
// COM2 IP-->| VTable ptr|----------------------------->|slot1|
// +-----------+ +-----+ +-----+
// COM2 IP-->| VTable ptr|---------->|slot1| |slot2|
// +-----------+ +-----+ + +
// | VTable ptr| | ....| | ... |
// +-----------+ + + + +
// | Org. this | |slotN| |slotN|
// + + +-----+ +-----+
// | .... |
// + +
// | |
// +-----------+
//
//
// The first slot of the first CCW is used to hold the basic interface -
// an interface that implements the methods of IUnknown & IDispatch. The basic
// interface's IDispatch implementation will call through to the class methods
// as if it were the class interface.
//
// The second slot of the first CCW is used to hold the IClassX interface -
// an interface that implements IUnknown, IDispatch, and a custom interface
// that contains all of the members of the class and its hierarchy. This
// will only be generated on demand and is only usable if the class and all
// of its parents are visible to COM.
//
// VTable and Stubs: can share stub code, we need to have different vtables
// for different interfaces, so the stub can jump to different
// marshalling code.
// Stubs : adjust this pointer and jump to the approp. address,
// Marshalling params and results, based on the method signature the stub jumps to
// approp. code to handle marshalling and unmarshalling.
//
//
//--------------------------------------------------------------------------------
//--------------------------------------------------------------------------------
// COM callable wrappers for CLR objects
//--------------------------------------------------------------------------------
typedef DPTR(class ComCallWrapperTemplate) PTR_ComCallWrapperTemplate;
class ComCallWrapperTemplate
{
friend class ClrDataAccess;
public:
// Iterates COM-exposed interfaces of a class.
class CCWInterfaceMapIterator
{
private:
struct InterfaceProps
{
MethodTable *m_pItfMT;
};
StackSArray<InterfaceProps> m_Interfaces;
COUNT_T m_Index;
inline const InterfaceProps &GetCurrentInterfaceProps() const
{
LIMITED_METHOD_CONTRACT;
return m_Interfaces[(COUNT_T)m_Index];
}
InterfaceProps &AppendInterface(MethodTable *pItfMT);
public:
CCWInterfaceMapIterator(TypeHandle thClass);
BOOL Next()
{
LIMITED_METHOD_CONTRACT;
return (++m_Index < GetCount());
}
MethodTable *GetInterface() const
{
LIMITED_METHOD_CONTRACT;
return GetCurrentInterfaceProps().m_pItfMT;
}
DWORD GetIndex() const
{
LIMITED_METHOD_CONTRACT;
return m_Index;
}
DWORD GetCount() const
{
LIMITED_METHOD_CONTRACT;
return m_Interfaces.GetCount();
}
void Reset()
{
LIMITED_METHOD_CONTRACT;
m_Index = (COUNT_T)-1;
}
};
// Static initializer run at startup.
static void Init();
// Template accessor, creates a template if one is not already cached.
static ComCallWrapperTemplate* GetTemplate(TypeHandle thClass);
// Ref-count the templates
LONG AddRef();
LONG Release();
// Properties
ComMethodTable* GetClassComMT();
ComMethodTable* GetComMTForItf(MethodTable *pItfMT);
ComMethodTable* GetBasicComMT();
ULONG GetNumInterfaces();
SLOT* GetVTableSlot(ULONG index);
void CheckParentComVisibility(BOOL fForIDispatch);
BOOL CheckParentComVisibilityNoThrow(BOOL fForIDispatch);
// Calls GetDefaultInterfaceForClassInternal and caches the result.
DefaultInterfaceType GetDefaultInterface(MethodTable **ppDefaultItf);
// Sets up the class method table for the IClassX and also lays it out.
static ComMethodTable *SetupComMethodTableForClass(MethodTable *pMT, BOOL bLayOutComMT);
MethodDesc * GetICustomQueryInterfaceGetInterfaceMD();
BOOL HasInvisibleParent()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_InvisibleParent);
}
BOOL SupportsICustomQueryInterface()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_ImplementsICustomQueryInterface);
}
BOOL RepresentsVariantInterface()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_RepresentsVariantInterface);
}
BOOL IsUseOleAutDispatchImpl()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_UseOleAutDispatchImpl);
}
BOOL ImplementsIMarshal()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_ImplementsIMarshal);
}
BOOL SupportsIClassX()
{
LIMITED_METHOD_CONTRACT;
return (m_flags & enum_SupportsIClassX);
}
TypeHandle GetClassType()
{
LIMITED_METHOD_CONTRACT;
return m_thClass;
}
BOOL IsSafeTypeForMarshalling();
// Creates a new Template and caches it on the MethodTable or class factory.
static ComCallWrapperTemplate *CreateTemplate(TypeHandle thClass);
// Creates a new Template for just one interface. Used for lazily created CCWs for interfaces with variance.
static ComCallWrapperTemplate *CreateTemplateForInterface(MethodTable *pItfMT);
private:
// Hide the constructor
ComCallWrapperTemplate();
// Cleanup called when the ref-count hits zero.
void Cleanup();
// Helper method called by code:CreateTemplate.
ComMethodTable* InitializeForInterface(MethodTable *pParentMT, MethodTable *pItfMT, DWORD dwIndex);
// Create a non laid out COM method table for the specified class or interface.
ComMethodTable* CreateComMethodTableForClass(MethodTable *pClassMT);
ComMethodTable* CreateComMethodTableForInterface(MethodTable* pInterfaceMT);
ComMethodTable* CreateComMethodTableForBasic(MethodTable* pClassMT);
void DetermineComVisibility();
ComCallWrapperTemplate* FindInvisibleParent();
private:
LONG m_cbRefCount;
ComCallWrapperTemplate* m_pParent;
TypeHandle m_thClass;
MethodTable* m_pDefaultItf;
ComMethodTable* m_pClassComMT;
ComMethodTable* m_pBasicComMT;
enum
{
// first 3 bits are interpreted as DefaultInterfaceType
enum_DefaultInterfaceTypeMask = 0x7,
enum_DefaultInterfaceTypeComputed = 0x10,
enum_InvisibleParent = 0x20,
enum_ImplementsICustomQueryInterface = 0x40,
// enum_Unused = 0x80,
enum_SupportsIClassX = 0x100,
enum_RepresentsVariantInterface = 0x400, // this is a template for an interface with variance
enum_UseOleAutDispatchImpl = 0x800, // the class is decorated with IDispatchImplAttribute(CompatibleImpl)
enum_ImplementsIMarshal = 0x1000, // the class implements a managed interface with Guid == IID_IMarshal
enum_IsSafeTypeForMarshalling = 0x2000, // The class can be safely marshalled out of process via DCOM
};
DWORD m_flags;
MethodDesc* m_pICustomQueryInterfaceGetInterfaceMD;
ULONG m_cbInterfaces;
SLOT* m_rgpIPtr[1];
};
inline void ComCallWrapperTemplateRelease(ComCallWrapperTemplate *value)
{
WRAPPER_NO_CONTRACT;
if (value)
{
value->Release();
}
}
typedef Wrapper<ComCallWrapperTemplate *, DoNothing<ComCallWrapperTemplate *>, ComCallWrapperTemplateRelease, NULL> ComCallWrapperTemplateHolder;
//--------------------------------------------------------------------------------
// Header on top of Vtables that we create for COM callable interfaces
//--------------------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
struct IUnkVtable
{
SLOT m_qi; // IUnk::QI
SLOT m_addref; // IUnk::AddRef
SLOT m_release; // IUnk::Release
};
struct IDispatchVtable : IUnkVtable
{
// idispatch methods
SLOT m_GetTypeInfoCount;
SLOT m_GetTypeInfo;
SLOT m_GetIDsOfNames;
SLOT m_Invoke;
};
enum Masks
{
enum_InterfaceTypeMask = 0x00000003,
enum_ClassInterfaceTypeMask = 0x00000003,
enum_ClassVtableMask = 0x00000004,
enum_LayoutComplete = 0x00000010,
enum_ComVisible = 0x00000040,
// enum_unused = 0x00000080,
// enum_unused = 0x00000100,
enum_ComClassItf = 0x00000200,
enum_GuidGenerated = 0x00000400,
// enum_unused = 0x00001000,
enum_IsBasic = 0x00002000,
// enum_unused = 0x00004000,
// enum_unused = 0x00008000,
// enum_unused = 0x00010000,
// enum_unused = 0x00020000,
// enum_unused = 0x00040000,
};
typedef DPTR(struct ComMethodTable) PTR_ComMethodTable;
struct ComMethodTable
{
friend class ComCallWrapperTemplate;
// Cleanup, frees all the stubs and the vtable
void Cleanup();
// The appropriate finalize method must be called before the COM method table is
// exposed to COM or before any methods are called on it.
void LayOutClassMethodTable();
BOOL LayOutInterfaceMethodTable(MethodTable* pClsMT);
void LayOutBasicMethodTable();
// Accessor for the IDispatch information.
DispatchInfo* GetDispatchInfo();
#ifndef DACCESS_COMPILE
LONG AddRef()
{
LIMITED_METHOD_CONTRACT;
ExecutableWriterHolder<ComMethodTable> comMTWriterHolder(this, sizeof(ComMethodTable));
return InterlockedIncrement(&comMTWriterHolder.GetRW()->m_cbRefCount);
}
LONG Release()
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(m_cbRefCount > 0);
}
CONTRACTL_END;
ExecutableWriterHolder<ComMethodTable> comMTWriterHolder(this, sizeof(ComMethodTable));
// use a different var here becuase cleanup will delete the object
// so can no longer make member refs
LONG cbRef = InterlockedDecrement(&comMTWriterHolder.GetRW()->m_cbRefCount);
if (cbRef == 0)
Cleanup();
return cbRef;
}
#endif // DACCESS_COMPILE
CorIfaceAttr GetInterfaceType()
{
WRAPPER_NO_CONTRACT;
if (IsIClassXOrBasicItf())
return ifDual;
else
return (CorIfaceAttr)(m_Flags & enum_InterfaceTypeMask);
}
CorClassIfaceAttr GetClassInterfaceType()
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(IsIClassXOrBasicItf());
return (CorClassIfaceAttr)(m_Flags & enum_ClassInterfaceTypeMask);
}
BOOL IsIClassX()
{
LIMITED_METHOD_CONTRACT;
return (IsIClassXOrBasicItf() && !IsBasic());
}
BOOL IsIClassXOrBasicItf()
{
LIMITED_METHOD_CONTRACT;
return (m_Flags & enum_ClassVtableMask) != 0;
}
BOOL IsComClassItf()
{
LIMITED_METHOD_CONTRACT;
return (m_Flags & enum_ComClassItf) != 0;
}
BOOL IsLayoutComplete()
{
LIMITED_METHOD_CONTRACT;
return (m_Flags & enum_LayoutComplete) != 0;
}
BOOL IsComVisible()
{
LIMITED_METHOD_CONTRACT;
return (m_Flags & enum_ComVisible) != 0;
}
BOOL IsBasic()
{
LIMITED_METHOD_CONTRACT;
return (m_Flags & enum_IsBasic) != 0;
}
BOOL HasInvisibleParent()
{
LIMITED_METHOD_CONTRACT;
return ((ComCallWrapperTemplate*)m_pMT->GetComCallWrapperTemplate())->HasInvisibleParent();
}
DWORD GetSlots()
{
LIMITED_METHOD_CONTRACT;
return m_cbSlots;
}
ITypeInfo *GetITypeInfo()
{
LIMITED_METHOD_CONTRACT;
return m_pITypeInfo;
}
void SetITypeInfo(ITypeInfo *pITI);
static WORD GetNumExtraSlots(CorIfaceAttr ItfType)
{
LIMITED_METHOD_CONTRACT;
switch (ItfType)
{
case ifVtable: return (sizeof(IUnkVtable) / sizeof(SLOT));
default: return (sizeof(IDispatchVtable) / sizeof(SLOT));
}
}
// Gets the ComCallMethodDesc out of a Vtable slot correctly for all platforms
ComCallMethodDesc* ComCallMethodDescFromSlot(unsigned i);
BOOL IsSlotAField(unsigned i)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(IsLayoutComplete());
PRECONDITION(i < m_cbSlots);
}
CONTRACTL_END;
i += GetNumExtraSlots(GetInterfaceType());
ComCallMethodDesc* pCMD = ComCallMethodDescFromSlot(i);
return pCMD->IsFieldCall();
}
MethodDesc* GetMethodDescForSlot(unsigned i)
{
CONTRACT (MethodDesc*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(IsLayoutComplete());
PRECONDITION(i < m_cbSlots);
PRECONDITION(!IsSlotAField(i));
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
i += GetNumExtraSlots(GetInterfaceType());
ComCallMethodDesc* pCMD;
pCMD = ComCallMethodDescFromSlot(i);
_ASSERTE(pCMD->IsMethodCall());
RETURN pCMD->GetMethodDesc();
}
ComCallMethodDesc* GetFieldCallMethodDescForSlot(unsigned i)
{
CONTRACT (ComCallMethodDesc*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(IsLayoutComplete());
PRECONDITION(i < m_cbSlots);
PRECONDITION(IsSlotAField(i));
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
i += GetNumExtraSlots(GetInterfaceType());
ComCallMethodDesc* pCMD = ComCallMethodDescFromSlot(i);
_ASSERTE(pCMD->IsFieldCall());
RETURN (ComCallMethodDesc *)pCMD;
}
BOOL OwnedbyThisMT(unsigned slotIndex)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
}
CONTRACTL_END;
if (!IsIClassXOrBasicItf())
return TRUE;
if (m_pMDescr != NULL)
{
// These are the methods from the default interfaces such as IUnknown.
unsigned cbExtraSlots = GetNumExtraSlots(GetInterfaceType());
// Refer to ComMethodTable::LayOutClassMethodTable().
ULONG cbSize = *(ULONG *)m_pMDescr;
ULONG cbNewSlots = cbSize / (COMMETHOD_PREPAD + sizeof(ComCallMethodDesc));
_ASSERTE( (cbSize % (COMMETHOD_PREPAD + sizeof(ComCallMethodDesc))) == 0);
// m_cbSlots is the total number of methods in addition to the ones from the
// default interfaces. cbNewSlots is the total number of methods introduced
// by this class (== m_cbSlots - <slots from parent MT>).
return (slotIndex >= (cbExtraSlots + m_cbSlots - cbNewSlots));
}
return FALSE;
}
ComMethodTable *GetParentClassComMT();
static inline PTR_ComMethodTable ComMethodTableFromIP(PTR_IUnknown pUnk)
{
CONTRACT (PTR_ComMethodTable)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
SUPPORTS_DAC;
PRECONDITION(CheckPointer(pUnk));
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
PTR_ComMethodTable pMT = dac_cast<PTR_ComMethodTable>(*PTR_TADDR(pUnk) - sizeof(ComMethodTable));
// validate the object
_ASSERTE((SLOT)(size_t)0xDEADC0FF == pMT->m_ptReserved );
RETURN pMT;
}
ULONG GetNumSlots()
{
LIMITED_METHOD_CONTRACT;
return m_cbSlots;
}
PTR_MethodTable GetMethodTable()
{
LIMITED_METHOD_CONTRACT;
return m_pMT;
}
#ifndef DACCESS_COMPILE
inline REFIID GetIID()
{
// Cannot use a normal CONTRACT since the return type is ref type which
// causes problems with normal CONTRACTs.
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
}
CONTRACTL_END;
// Generate the IClassX IID if it hasn't been generated yet.
if (!(m_Flags & enum_GuidGenerated))
{
ExecutableWriterHolder<ComMethodTable> comMTWriterHolder(this, sizeof(ComMethodTable));
GenerateClassItfGuid(TypeHandle(m_pMT), &comMTWriterHolder.GetRW()->m_IID);
comMTWriterHolder.GetRW()->m_Flags |= enum_GuidGenerated;
}
return m_IID;
}
#endif // DACCESS_COMPILE
void CheckParentComVisibility(BOOL fForIDispatch)
{
WRAPPER_NO_CONTRACT;
((ComCallWrapperTemplate*)m_pMT->GetComCallWrapperTemplate())->CheckParentComVisibility(fForIDispatch);
}
BOOL CheckParentComVisibilityNoThrow(BOOL fForIDispatch)
{
WRAPPER_NO_CONTRACT;
return ((ComCallWrapperTemplate*)m_pMT->GetComCallWrapperTemplate())->CheckParentComVisibilityNoThrow(fForIDispatch);
}
private:
SLOT m_ptReserved; //= (SLOT) 0xDEADC0FF; reserved
PTR_MethodTable m_pMT; // pointer to the VMs method table
ULONG m_cbSlots; // number of slots in the interface (excluding IUnk/IDisp)
LONG m_cbRefCount; // ref-count the vtable as it is being shared
size_t m_Flags; // make sure this is initialized to zero
LPVOID m_pMDescr; // pointer to methoddescr.s owned by this MT
ITypeInfo* m_pITypeInfo; // cached pointer to ITypeInfo
DispatchInfo* m_pDispatchInfo; // The dispatch info used to expose IDispatch to COM.
IID m_IID; // The IID of the interface.
};
#pragma pack(pop)
struct GetComIPFromCCW
{
enum flags
{
None = 0,
CheckVisibility = 1,
SuppressCustomizedQueryInterface = 2
};
};
inline GetComIPFromCCW::flags operator|(GetComIPFromCCW::flags lhs, GetComIPFromCCW::flags rhs)
{
LIMITED_METHOD_CONTRACT;
return static_cast<GetComIPFromCCW::flags>(static_cast<DWORD>(lhs) | static_cast<DWORD>(rhs));
}
inline GetComIPFromCCW::flags operator|=(GetComIPFromCCW::flags & lhs, GetComIPFromCCW::flags rhs)
{
LIMITED_METHOD_CONTRACT;
lhs = static_cast<GetComIPFromCCW::flags>(static_cast<DWORD>(lhs) | static_cast<DWORD>(rhs));
return lhs;
}
class ComCallWrapper
{
friend class MarshalNative;
friend class ClrDataAccess;
private:
enum
{
NumVtablePtrs = 5,
#ifdef HOST_64BIT
enum_ThisMask = ~0x3f, // mask on IUnknown ** to get at the OBJECT-REF handle
#else
enum_ThisMask = ~0x1f, // mask on IUnknown ** to get at the OBJECT-REF handle
#endif
Slot_Basic = 0,
Slot_IClassX = 1,
Slot_FirstInterface = 2,
};
public:
BOOL IsHandleWeak();
VOID MarkHandleWeak();
VOID ResetHandleStrength();
BOOL IsComActivated();
VOID MarkComActivated();
OBJECTHANDLE GetObjectHandle() { LIMITED_METHOD_CONTRACT; return m_ppThis; }
// don't instantiate this class directly
ComCallWrapper() = delete;
~ComCallWrapper() = delete;
protected:
#ifndef DACCESS_COMPILE
static void SetNext(ComCallWrapper* pWrap, ComCallWrapper* pNextWrapper)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(CheckPointer(pWrap));
PRECONDITION(CheckPointer(pNextWrapper, NULL_OK));
}
CONTRACTL_END;
pWrap->m_pNext = pNextWrapper;
}
#endif // !DACCESS_COMPILE
static PTR_ComCallWrapper GetNext(PTR_ComCallWrapper pWrap)
{
CONTRACT (PTR_ComCallWrapper)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
SUPPORTS_DAC;
PRECONDITION(CheckPointer(pWrap));
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
RETURN (LinkedWrapperTerminator == pWrap->m_pNext ? NULL : pWrap->m_pNext);
}
// Helper to create a wrapper
static ComCallWrapper* CreateWrapper(OBJECTREF* pObj);
// helper to get wrapper from sync block
static PTR_ComCallWrapper GetStartWrapper(PTR_ComCallWrapper pWrap);
// helper to create a wrapper from a template
static ComCallWrapper* CopyFromTemplate(ComCallWrapperTemplate* pTemplate,
ComCallWrapperCache *pWrapperCache,
OBJECTHANDLE oh);
static SLOT** GetComIPLocInWrapper(ComCallWrapper* pWrap, unsigned int iIndex);
public:
SLOT** GetFirstInterfaceSlot();
// walk the list and free all blocks
void FreeWrapper(ComCallWrapperCache *pWrapperCache);
BOOL IsWrapperActive();
// IsLinkedWrapper
inline BOOL IsLinked()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
INSTANCE_CHECK;
}
CONTRACTL_END;
return m_pNext != NULL;
}
// wrapper is not guaranteed to be present
// accessor to wrapper object in the sync block
inline static PTR_ComCallWrapper GetWrapperForObject(OBJECTREF pObj, ComCallWrapperTemplate *pTemplate = NULL)
{
CONTRACT (PTR_ComCallWrapper)
{
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
SUPPORTS_DAC;
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
}
CONTRACT_END;
PTR_SyncBlock pSync = pObj->PassiveGetSyncBlock();
if (!pSync)
RETURN NULL;
PTR_InteropSyncBlockInfo pInteropInfo = pSync->GetInteropInfoNoCreate();
if (!pInteropInfo)
RETURN NULL;
PTR_ComCallWrapper pCCW = pInteropInfo->GetCCW();
if (pTemplate != NULL)
{
// make sure we use the right CCW - the object may have multiple CCWs associated
// with it which were created based on different CCW templates
while (pCCW != NULL && pCCW->GetComCallWrapperTemplate() != pTemplate)
{
pCCW = GetNext(pCCW);
}
}
RETURN pCCW;
}
// get inner unknown
HRESULT GetInnerUnknown(void **pv);
// Init outer unknown
void InitializeOuter(IUnknown* pOuter);
// is the object aggregated by a COM component
BOOL IsAggregated();
// is the object extends from (aggregates) a COM component
BOOL IsExtendsCOMObject();
// get syncblock stored in the simplewrapper
SyncBlock* GetSyncBlock();
// get the CCW template this wrapper is based on
PTR_ComCallWrapperTemplate GetComCallWrapperTemplate();
// get outer unk
IUnknown* GetOuter();
// Get IClassX interface pointer from the wrapper.
// The inspectionOnly parameter should only be true to this function if you are
// only passively inspecting the value and not using the interface (such as
// passing out the pointer via ETW or in the dac).
IUnknown* GetIClassXIP(bool inspectionOnly=false);
// Get the basic interface pointer from the wrapper.
// The inspectionOnly parameter should only be true to this function if you are
// only passively inspecting the value and not using the interface (such as
// passing out the pointer via ETW or in the dac).
IUnknown* GetBasicIP(bool inspectionOnly=false);
// Get the IDispatch interface pointer from the wrapper.
IDispatch *GetIDispatchIP();
// Get ObjectRef from wrapper - this is called by GetObjectRef and GetStartWrapper.
// Need this becuase GetDomainSynchronized will call GetStartWrapper which will call
// GetObjectRef which will cause a little bit of nasty infinite recursion.
inline OBJECTREF GetObjectRef()
{
CONTRACT (OBJECTREF)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(m_ppThis));
}
CONTRACT_END;
if (m_ppThis == NULL)
{
// Force a fail fast if this CCW is already neutered
AccessNeuteredCCW_FailFast();
}
RETURN ObjectFromHandle(m_ppThis);
}
//
// Force a fail fast for better diagnostics
// Don't inline so that this call would show up in the callstack
//
NOINLINE void AccessNeuteredCCW_FailFast()
{
LIMITED_METHOD_CONTRACT;
EEPOLICY_HANDLE_FATAL_ERROR(COR_E_ACCESSING_CCW);
}
// A MODE_ANY helper to get the MethodTable of the 'this' object. This helper keeps
// the GCX_COOP transition out of the caller (it implies a holder which implies an
// FS:0 handler on x86).
MethodTable* GetMethodTableOfObjectRef();
// clean up an object wrapper
void Cleanup();
// If the object gets collected while the CCW is still active, neuter (disconnect) the CCW.
void Neuter();
void ClearHandle();
// fast access to wrapper for a com+ object,
// inline check, and call out of line to create, out of line version might cause gc
//to be enabled
static ComCallWrapper* __stdcall InlineGetWrapper(OBJECTREF* pObj);
// Get RefCount
inline ULONG GetRefCount();
// AddRef a wrapper
inline ULONG AddRef();
// AddRef a wrapper
inline ULONG AddRefWithAggregationCheck();
// Release for a Wrapper object
inline ULONG Release();
// Initialize the simple wrapper.
static void InitSimpleWrapper(ComCallWrapper* pWrap, SimpleComCallWrapper* pSimpleWrap);
// Clear the simple wrapper. This must be called on the start wrapper.
static void ClearSimpleWrapper(ComCallWrapper* pWrap);
//Get Simple wrapper, for std interfaces such as IProvideClassInfo
PTR_SimpleComCallWrapper GetSimpleWrapper()
{
CONTRACT (PTR_SimpleComCallWrapper)
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
INSTANCE_CHECK;
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
}
CONTRACT_END;
RETURN m_pSimpleWrapper;
}
// Get wrapper from IP, for std. interfaces like IDispatch
inline static PTR_ComCallWrapper GetWrapperFromIP(PTR_IUnknown pUnk);
#if !defined(DACCESS_COMPILE)
inline static ComCallWrapper* GetStartWrapperFromIP(IUnknown* pUnk)
{
CONTRACT (ComCallWrapper*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(CheckPointer(pUnk));
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
ComCallWrapper* pWrap = GetWrapperFromIP(pUnk);
if (pWrap->IsLinked())
pWrap = GetStartWrapper(pWrap);
RETURN pWrap;
}
#endif // DACCESS_COMPILE
// Get an interface from wrapper, based on riid or pIntfMT
static IUnknown* GetComIPFromCCW(ComCallWrapper *pWrap, REFIID riid, MethodTable* pIntfMT, GetComIPFromCCW::flags flags = GetComIPFromCCW::None);
private:
// pointer to OBJECTREF
OBJECTHANDLE m_ppThis;
// Pointer to the simple wrapper.
PTR_SimpleComCallWrapper m_pSimpleWrapper;
// Block of vtable pointers.
SLOT* m_rgpIPtr[NumVtablePtrs];
// Pointer to the next wrapper.
PTR_ComCallWrapper m_pNext;
};
FORCEINLINE void CCWRelease(ComCallWrapper* p)
{
WRAPPER_NO_CONTRACT;
p->Release();
}
class CCWHolder : public Wrapper<ComCallWrapper*, CCWHolderDoNothing, CCWRelease, NULL>
{
public:
CCWHolder(ComCallWrapper* p = NULL)
: Wrapper<ComCallWrapper*, CCWHolderDoNothing, CCWRelease, NULL>(p)
{
WRAPPER_NO_CONTRACT;
}
FORCEINLINE void operator=(ComCallWrapper* p)
{
WRAPPER_NO_CONTRACT;
Wrapper<ComCallWrapper*, CCWHolderDoNothing, CCWRelease, NULL>::operator=(p);
}
};
//
// Uncommonly used data on Simple CCW
// Created on-demand
//
// We used to have two fields now it only has one field, and I'm keeping this structure
// just in case we want to put more stuff in here later
//
struct SimpleCCWAuxData
{
VolatilePtr<DispatchExInfo> m_pDispatchExInfo; // Information required by the IDispatchEx standard interface
SimpleCCWAuxData()
{
LIMITED_METHOD_CONTRACT;
m_pDispatchExInfo = NULL;
}
~SimpleCCWAuxData()
{
LIMITED_METHOD_CONTRACT;
if (m_pDispatchExInfo)
{
delete m_pDispatchExInfo;
m_pDispatchExInfo = NULL;
}
}
};
//--------------------------------------------------------------------------------
// simple ComCallWrapper for all simple std interfaces, that are not used very often
// like IProvideClassInfo, ISupportsErrorInfo etc.
//--------------------------------------------------------------------------------
struct SimpleComCallWrapper
{
private:
friend class ComCallWrapper;
friend class ClrDataAccess;
enum SimpleComCallWrapperFlags
{
enum_IsAggregated = 0x1,
enum_IsExtendsCom = 0x2,
enum_IsHandleWeak = 0x4,
enum_IsComActivated = 0x8,
// unused = 0x10,
// unused = 0x80,
// unused = 0x100,
enum_CustomQIRespondsToIMarshal = 0x200,
enum_CustomQIRespondsToIMarshal_Inited = 0x400,
};
public :
enum : LONGLONG
{
CLEANUP_SENTINEL = 0x0000000080000000, // Sentinel -> 1 bit
COM_REFCOUNT_MASK = 0x000000007FFFFFFF, // COM -> 31 bits
EXT_COM_REFCOUNT_MASK = 0x00000000FFFFFFFF, // For back-compat, preserve the higher-bit so that outside can observe it
ALL_REFCOUNT_MASK = 0xFFFFFFFF7FFFFFFF,
};
#define GET_COM_REF(x) ((ULONG)((x) & SimpleComCallWrapper::COM_REFCOUNT_MASK))
#define GET_EXT_COM_REF(x) ((ULONG)((x) & SimpleComCallWrapper::EXT_COM_REFCOUNT_MASK))
#ifdef HOST_64BIT
#define READ_REF(x) (x)
#else
#define READ_REF(x) (::InterlockedCompareExchange64((LONGLONG *)&x, 0, 0))
#endif
public:
HRESULT IErrorInfo_hr();
BSTR IErrorInfo_bstrDescription();
BSTR IErrorInfo_bstrSource();
BSTR IErrorInfo_bstrHelpFile();
DWORD IErrorInfo_dwHelpContext();
GUID IErrorInfo_guid();
// non virtual methods
SimpleComCallWrapper();
VOID Cleanup();
// Used to neuter a CCW if its AD is being unloaded underneath it.
VOID Neuter();
~SimpleComCallWrapper();
VOID ResetSyncBlock()
{
LIMITED_METHOD_CONTRACT;
m_pSyncBlock = NULL;
}
SyncBlock* GetSyncBlock()
{
CONTRACT (SyncBlock*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
}
CONTRACT_END;
RETURN m_pSyncBlock;
}
// Init pointer to the vtable of the interface
// and the main ComCallWrapper if the interface needs it
void InitNew(OBJECTREF oref, ComCallWrapperCache *pWrapperCache, ComCallWrapper* pWrap,
SyncBlock* pSyncBlock,
ComCallWrapperTemplate* pTemplate);
// used by reconnect wrapper to new object
void ReInit(SyncBlock* pSyncBlock);
void InitOuter(IUnknown* pOuter);
void ResetOuter();
IUnknown* GetOuter();
// get inner unknown
HRESULT GetInnerUnknown(void **ppv)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(CheckPointer(ppv));
}
CONTRACTL_END;
*ppv = QIStandardInterface(enum_InnerUnknown);
if (*ppv)
return S_OK;
else
return E_NOINTERFACE;
}
OBJECTREF GetObjectRef()
{
CONTRACT (OBJECTREF)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_COOPERATIVE;
}
CONTRACT_END;
RETURN (GetMainWrapper()->GetObjectRef());
}
ComCallWrapperCache* GetWrapperCache()
{
CONTRACT (ComCallWrapperCache*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
RETURN m_pWrapperCache;
}
// Connection point helper methods.
BOOL FindConnectionPoint(REFIID riid, IConnectionPoint **ppCP);
void EnumConnectionPoints(IEnumConnectionPoints **ppEnumCP);
// is the object aggregated by a COM component
BOOL IsAggregated()
{
LIMITED_METHOD_CONTRACT;
return m_flags & enum_IsAggregated;
}
void MarkAggregated()
{
WRAPPER_NO_CONTRACT;
FastInterlockOr((ULONG*)&m_flags, enum_IsAggregated);
}
void UnMarkAggregated()
{
WRAPPER_NO_CONTRACT;
FastInterlockAnd((ULONG*)&m_flags, ~enum_IsAggregated);
}
BOOL IsHandleWeak()
{
LIMITED_METHOD_CONTRACT;
return m_flags & enum_IsHandleWeak;
}
void MarkHandleWeak()
{
WRAPPER_NO_CONTRACT;
FastInterlockOr((ULONG*)&m_flags, enum_IsHandleWeak);
}
VOID ResetHandleStrength()
{
WRAPPER_NO_CONTRACT;
FastInterlockAnd((ULONG*)&m_flags, ~enum_IsHandleWeak);
}
// is the object extends from (aggregates) a COM component
BOOL IsExtendsCOMObject()
{
LIMITED_METHOD_CONTRACT;
return m_flags & enum_IsExtendsCom;
}
BOOL IsComActivated()
{
LIMITED_METHOD_CONTRACT;
return m_flags & enum_IsComActivated;
}
void MarkComActivated()
{
LIMITED_METHOD_CONTRACT;
FastInterlockOr((ULONG*)&m_flags, enum_IsComActivated);
}
// Determines if the type associated with the ComCallWrapper supports exceptions.
static BOOL SupportsExceptions(MethodTable *pMT);
// Determines if the type supports IReflect.
static BOOL SupportsIReflect(MethodTable *pMT);
NOINLINE BOOL ShouldUseManagedIProvideClassInfo();
//--------------------------------------------------------------------------
// Retrieves the simple wrapper from an IUnknown pointer that is for one
// of the interfaces exposed by the simple wrapper.
//--------------------------------------------------------------------------
static PTR_SimpleComCallWrapper GetWrapperFromIP(PTR_IUnknown pUnk)
{
CONTRACT (SimpleComCallWrapper*)
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(CheckPointer(pUnk));
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
}
CONTRACT_END;
int i = GetStdInterfaceKind(pUnk);
PTR_SimpleComCallWrapper pSimpleWrapper = dac_cast<PTR_SimpleComCallWrapper>(dac_cast<TADDR>(pUnk) - sizeof(LPBYTE) * i - offsetof(SimpleComCallWrapper,m_rgpVtable));
RETURN pSimpleWrapper;
}
// get the main wrapper
PTR_ComCallWrapper GetMainWrapper()
{
CONTRACT (PTR_ComCallWrapper)
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
SUPPORTS_DAC;
INSTANCE_CHECK;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
RETURN m_pWrap;
}
inline ULONG GetRefCount()
{
LIMITED_METHOD_CONTRACT;
return GET_COM_REF(READ_REF(m_llRefCount));
}
inline BOOL IsNeutered()
{
LIMITED_METHOD_DAC_CONTRACT;
return !!(READ_REF(m_llRefCount) & CLEANUP_SENTINEL);
}
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
// CCW refcount logging consists of two steps. BuildRefCountLogMessage is an instance method which
// must be called at a point where the CCW is guaranteed to be alive. LogRefCount is static because
// we generally don't know the new refcount (the one we want to log) until the CCW is at risk of
// having been destroyed by other threads.
void BuildRefCountLogMessage(LPCWSTR wszOperation, StackSString &ssMessage, ULONG dwEstimatedRefCount);
static void LogRefCount(ComCallWrapper *pWrap, StackSString &ssMessage, ULONG dwRefCountToLog);
NOINLINE HRESULT LogCCWAddRef(ULONG newRefCount)
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
SetupForComCallHR();
// we can safely assume that the CCW is still alive since this is an AddRef
StackSString ssMessage;
BuildRefCountLogMessage(W("AddRef"), ssMessage, newRefCount);
LogRefCount(GetMainWrapper(), ssMessage, newRefCount);
return S_OK;
}
inline ULONG AddRef()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
LONGLONG newRefCount = ::InterlockedIncrement64(&m_llRefCount);
if (g_pConfig->LogCCWRefCountChangeEnabled())
{
LogCCWAddRef(GET_EXT_COM_REF(newRefCount));
}
return GET_EXT_COM_REF(newRefCount);
}
inline ULONG AddRefWithAggregationCheck()
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
// aggregation check
IUnknown* pOuter = this->GetOuter();
if (pOuter != NULL)
return SafeAddRef(pOuter);
return this->AddRef();
}
private:
LONGLONG ReleaseImplWithLogging(LONGLONG * pRefCount);
NOINLINE void ReleaseImplCleanup()
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
m_pWrap->Cleanup();
}
public:
inline ULONG Release()
{
CONTRACTL
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
}
CONTRACTL_END;
LONGLONG *pRefCount = &m_llRefCount;
ULONG ulComRef = GET_COM_REF(READ_REF(*pRefCount));
if (ulComRef <= 0)
{
_ASSERTE(!"Invalid Release() call on already released object. A managed object exposed to COM is being over-released from unmanaged code");
return -1;
}
// Null the outer pointer if refcount is about to drop to 0. We cannot perform this
// operation after decrementing the refcount as that would race with the finalizer
// that may clean this CCW up any time after the refcount drops to 0. With this pre-
// decrement reset, we are racing with other Release's and may call ResetOuter multiple
// times (which is fine - it's thread safe and idempotent) or call it when the refcount
// doesn't really drop to 0 (which is also fine - it would have dropped to 0 under
// slightly different timing and the COM client is responsible for preventing this).
if (ulComRef == 1)
ResetOuter();
LONGLONG newRefCount;
if (g_pConfig->LogCCWRefCountChangeEnabled())
{
newRefCount = ReleaseImplWithLogging(pRefCount);
}
else
{
// Decrement the ref count
newRefCount = ::InterlockedDecrement64(pRefCount);
}
// IMPORTANT: Do not touch instance fields or any other data associated with the CCW beyond this
// point unless newRefCount equals CLEANUP_SENTINEL (it's the only case when we know that Neuter
// or another Release could not swoop in and destroy our data structures).
// If we hit the sentinel value in COM ref count == 0, it's our responsibility to clean up.
if (newRefCount == CLEANUP_SENTINEL)
{
ReleaseImplCleanup();
return 0;
}
return GET_EXT_COM_REF(newRefCount);
}
#endif // !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
MethodTable* GetMethodTable()
{
CONTRACT (MethodTable*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
RETURN m_pMT;
}
DispatchExInfo* GetDispatchExInfo()
{
CONTRACT (DispatchExInfo*)
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
}
CONTRACT_END;
if (m_pAuxData.Load() == NULL)
RETURN NULL;
else
RETURN m_pAuxData->m_pDispatchExInfo;
}
BOOL SupportsICustomQueryInterface()
{
LIMITED_METHOD_CONTRACT;
return m_pTemplate->SupportsICustomQueryInterface();
}
PTR_ComCallWrapperTemplate GetComCallWrapperTemplate()
{
LIMITED_METHOD_CONTRACT;
return m_pTemplate;
}
// Returns TRUE if the ICustomQI implementation returns Handled or Failed for IID_IMarshal.
BOOL CustomQIRespondsToIMarshal();
SimpleCCWAuxData *GetOrCreateAuxData()
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;
if (m_pAuxData.Load())
return m_pAuxData;
NewHolder<SimpleCCWAuxData> pAuxData = new SimpleCCWAuxData();
if (InterlockedCompareExchangeT(&m_pAuxData, (SimpleCCWAuxData *)pAuxData, NULL) == NULL)
pAuxData.SuppressRelease();
return m_pAuxData;
}
private:
// Methods to initialize the DispatchEx and exception info.
void InitExceptionInfo();
void InitDispatchExInfo();
// Methods to set up the connection point list.
void SetUpCPList();
void SetUpCPListHelper(MethodTable **apSrcItfMTs, int cSrcItfs);
ConnectionPoint *CreateConnectionPoint(ComCallWrapper *pWrap, MethodTable *pEventMT);
ConnectionPoint *TryCreateConnectionPoint(ComCallWrapper *pWrap, MethodTable *pEventMT);
CQuickArray<ConnectionPoint*> *CreateCPArray();
// QI for well known interfaces from within the runtime direct fetch, instead of guid comparisons
IUnknown* QIStandardInterface(Enum_StdInterfaces index);
// QI for well known interfaces from within the runtime based on an IID.
IUnknown* QIStandardInterface(REFIID riid);
CQuickArray<ConnectionPoint*>* m_pCPList;
// syncblock for the ObjecRef
SyncBlock* m_pSyncBlock;
//outer unknown cookie
IUnknown* m_pOuter;
// array of pointers to std. vtables
SLOT const* m_rgpVtable[enum_LastStdVtable];
PTR_ComCallWrapper m_pWrap; // the first ComCallWrapper associated with this SimpleComCallWrapper
MethodTable* m_pMT;
ComCallWrapperCache* m_pWrapperCache;
PTR_ComCallWrapperTemplate m_pTemplate;
// Points to uncommonly used data that are dynamically allocated
VolatilePtr<SimpleCCWAuxData> m_pAuxData;
DWORD m_flags;
// This maintains the 32-bit COM refcount in 64-bits
// to enable also tracking the Cleanup sentinel. See code:CLEANUP_SENTINEL
LONGLONG m_llRefCount;
};
//--------------------------------------------------------------------------------
// ComCallWrapper* ComCallWrapper::InlineGetWrapper(OBJECTREF* ppObj)
// returns the wrapper for the object, if not yet created, creates one
// returns null for out of memory scenarios.
// Note: the wrapper is returned AddRef'd and should be Released when finished
// with.
//--------------------------------------------------------------------------------
inline ComCallWrapper* __stdcall ComCallWrapper::InlineGetWrapper(OBJECTREF* ppObj)
{
CONTRACT (ComCallWrapper*)
{
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(ppObj));
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
// get the wrapper for this com+ object
ComCallWrapper* pWrap = GetWrapperForObject(*ppObj);
if (NULL == pWrap)
{
pWrap = CreateWrapper(ppObj);
}
pWrap->AddRef();
RETURN pWrap;
}
inline ULONG ComCallWrapper::GetRefCount()
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
INSTANCE_CHECK;
}
CONTRACTL_END;
return m_pSimpleWrapper->GetRefCount();
}
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
inline ULONG ComCallWrapper::AddRef()
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
INSTANCE_CHECK;
}
CONTRACTL_END;
return m_pSimpleWrapper->AddRef();
}
inline ULONG ComCallWrapper::AddRefWithAggregationCheck()
{
WRAPPER_NO_CONTRACT;
return m_pSimpleWrapper->AddRefWithAggregationCheck();
}
inline ULONG ComCallWrapper::Release()
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
INSTANCE_CHECK;
PRECONDITION(CheckPointer(m_pSimpleWrapper));
}
CONTRACTL_END;
return m_pSimpleWrapper->Release();
}
inline void ComCallWrapper::InitSimpleWrapper(ComCallWrapper* pWrap, SimpleComCallWrapper* pSimpleWrap)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(CheckPointer(pWrap));
PRECONDITION(CheckPointer(pSimpleWrap));
PRECONDITION(pSimpleWrap->GetMainWrapper() == pWrap);
}
CONTRACTL_END;
while (pWrap)
{
pWrap->m_pSimpleWrapper = pSimpleWrap;
pWrap = GetNext(pWrap);
}
}
inline void ComCallWrapper::ClearSimpleWrapper(ComCallWrapper* pWrap)
{
CONTRACTL
{
WRAPPER(THROWS);
WRAPPER(GC_TRIGGERS);
MODE_ANY;
PRECONDITION(CheckPointer(pWrap));
}
CONTRACTL_END;
// clear the m_pSimpleWrapper field in all wrappers that share the same SimpleComCallWrapper
SimpleComCallWrapper *pSimpleWrapper = pWrap->m_pSimpleWrapper;
while (pWrap && pWrap->m_pSimpleWrapper == pSimpleWrapper)
{
pWrap->m_pSimpleWrapper = NULL;
pWrap = GetNext(pWrap);
}
}
#endif // !DACCESS_COMPILE && !CROSSGEN_COMPILE
inline PTR_ComCallWrapper ComCallWrapper::GetWrapperFromIP(PTR_IUnknown pUnk)
{
CONTRACT (PTR_ComCallWrapper)
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(CheckPointer(pUnk));
POSTCONDITION(CheckPointer(RETVAL));
SUPPORTS_DAC;
}
CONTRACT_END;
// This code path may be exercised from out-of-process. Unfortunately, we need to manipulate the
// target address here, and so we need to do some non-trivial casting. First, cast the PTR type
// to the target address first, and then mask off the least significant bits. Then use the end
// result as a target address to instantiate a ComCallWrapper. The line below is equivalent to:
// ComCallWrapper* pWrap = (ComCallWrapper*)((size_t)pUnk & enum_ThisMask);
PTR_ComCallWrapper pWrap = dac_cast<PTR_ComCallWrapper>(dac_cast<TADDR>(pUnk) & enum_ThisMask);
RETURN pWrap;
}
//--------------------------------------------------------------------------
// PTR_ComCallWrapper ComCallWrapper::GetStartWrapper(PTR_ComCallWrapper pWrap)
// get outermost wrapper, given a linked wrapper
// get the start wrapper from the sync block
//--------------------------------------------------------------------------
inline PTR_ComCallWrapper ComCallWrapper::GetStartWrapper(PTR_ComCallWrapper pWrap)
{
CONTRACT (PTR_ComCallWrapper)
{
NOTHROW;
GC_TRIGGERS;
MODE_ANY;
SUPPORTS_DAC;
PRECONDITION(CheckPointer(pWrap));
PRECONDITION(pWrap->IsLinked());
POSTCONDITION(CheckPointer(RETVAL));
}
CONTRACT_END;
PTR_SimpleComCallWrapper pSimpleWrap = pWrap->GetSimpleWrapper();
RETURN (pSimpleWrap->GetMainWrapper());
}
//--------------------------------------------------------------------------
// PTR_ComCallWrapperTemplate ComCallWrapper::GetComCallWrapperTemplate()
inline PTR_ComCallWrapperTemplate ComCallWrapper::GetComCallWrapperTemplate()
{
LIMITED_METHOD_CONTRACT;
return GetSimpleWrapper()->GetComCallWrapperTemplate();
}
inline BOOL ComCallWrapper::IsWrapperActive()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
MODE_COOPERATIVE;
}
CONTRACTL_END;
// Since its called by GCPromote, we assume that this is the start wrapper
ULONG cbRef = m_pSimpleWrapper->GetRefCount();
BOOL bHasStrongCOMRefCount = cbRef > 0;
BOOL bIsWrapperActive = (bHasStrongCOMRefCount && !m_pSimpleWrapper->IsHandleWeak());
LOG((LF_INTEROP, LL_INFO1000,
"CCW 0x%p: cbRef = 0x%x, IsHandleWeak = %d\n",
this,
cbRef, m_pSimpleWrapper->IsHandleWeak()));
LOG((LF_INTEROP, LL_INFO1000, "CCW 0x%p: IsWrapperActive returned %d\n", this, bIsWrapperActive));
return bIsWrapperActive;
}
#endif // FEATURE_COMINTEROP
#endif // _COMCALLABLEWRAPPER_H
|
JimmyCushnie/runtime
|
src/mono/mono/mini/mini-ppc.c
|
/**
* \file
* PowerPC backend for the Mono code generator
*
* Authors:
* <NAME> (<EMAIL>)
* <NAME> (<EMAIL>)
* <NAME> <<EMAIL>>
*
* (C) 2003 Ximian, Inc.
* (C) 2007-2008 <NAME>
*/
#include "mini.h"
#include <string.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/utils/mono-proclib.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-hwcap.h>
#include <mono/utils/unlocked.h>
#include "mono/utils/mono-tls-inline.h"
#include "mini-ppc.h"
#ifdef TARGET_POWERPC64
#include "cpu-ppc64.h"
#else
#include "cpu-ppc.h"
#endif
#include "ir-emit.h"
#include "aot-runtime.h"
#include "mini-runtime.h"
#ifdef __APPLE__
#include <sys/sysctl.h>
#endif
#ifdef __linux__
#include <unistd.h>
#endif
#ifdef _AIX
#include <sys/systemcfg.h>
#endif
static GENERATE_TRY_GET_CLASS_WITH_CACHE (math, "System", "Math")
static GENERATE_TRY_GET_CLASS_WITH_CACHE (mathf, "System", "MathF")
#define FORCE_INDIR_CALL 1
enum {
TLS_MODE_DETECT,
TLS_MODE_FAILED,
TLS_MODE_LTHREADS,
TLS_MODE_NPTL,
TLS_MODE_DARWIN_G4,
TLS_MODE_DARWIN_G5
};
/* cpu_hw_caps contains the flags defined below */
static int cpu_hw_caps = 0;
static int cachelinesize = 0;
static int cachelineinc = 0;
enum {
PPC_ICACHE_SNOOP = 1 << 0,
PPC_MULTIPLE_LS_UNITS = 1 << 1,
PPC_SMP_CAPABLE = 1 << 2,
PPC_ISA_2X = 1 << 3,
PPC_ISA_64 = 1 << 4,
PPC_MOVE_FPR_GPR = 1 << 5,
PPC_ISA_2_03 = 1 << 6,
PPC_HW_CAP_END
};
#define BREAKPOINT_SIZE (PPC_LOAD_SEQUENCE_LENGTH + 4)
/* This mutex protects architecture specific caches */
#define mono_mini_arch_lock() mono_os_mutex_lock (&mini_arch_mutex)
#define mono_mini_arch_unlock() mono_os_mutex_unlock (&mini_arch_mutex)
static mono_mutex_t mini_arch_mutex;
/*
* The code generated for sequence points reads from this location, which is
* made read-only when single stepping is enabled.
*/
static gpointer ss_trigger_page;
/* Enabled breakpoints read from this trigger page */
static gpointer bp_trigger_page;
#define MONO_EMIT_NEW_LOAD_R8(cfg,dr,addr) do { \
MonoInst *inst; \
MONO_INST_NEW ((cfg), (inst), OP_R8CONST); \
inst->type = STACK_R8; \
inst->dreg = (dr); \
inst->inst_p0 = (void*)(addr); \
mono_bblock_add_inst (cfg->cbb, inst); \
} while (0)
const char*
mono_arch_regname (int reg) {
static const char rnames[][4] = {
"r0", "sp", "r2", "r3", "r4",
"r5", "r6", "r7", "r8", "r9",
"r10", "r11", "r12", "r13", "r14",
"r15", "r16", "r17", "r18", "r19",
"r20", "r21", "r22", "r23", "r24",
"r25", "r26", "r27", "r28", "r29",
"r30", "r31"
};
if (reg >= 0 && reg < 32)
return rnames [reg];
return "unknown";
}
const char*
mono_arch_fregname (int reg) {
static const char rnames[][4] = {
"f0", "f1", "f2", "f3", "f4",
"f5", "f6", "f7", "f8", "f9",
"f10", "f11", "f12", "f13", "f14",
"f15", "f16", "f17", "f18", "f19",
"f20", "f21", "f22", "f23", "f24",
"f25", "f26", "f27", "f28", "f29",
"f30", "f31"
};
if (reg >= 0 && reg < 32)
return rnames [reg];
return "unknown";
}
/* this function overwrites r0, r11, r12 */
static guint8*
emit_memcpy (guint8 *code, int size, int dreg, int doffset, int sreg, int soffset)
{
/* unrolled, use the counter in big */
if (size > sizeof (target_mgreg_t) * 5) {
long shifted = size / TARGET_SIZEOF_VOID_P;
guint8 *copy_loop_start, *copy_loop_jump;
ppc_load (code, ppc_r0, shifted);
ppc_mtctr (code, ppc_r0);
//g_assert (sreg == ppc_r12);
ppc_addi (code, ppc_r11, dreg, (doffset - sizeof (target_mgreg_t)));
ppc_addi (code, ppc_r12, sreg, (soffset - sizeof (target_mgreg_t)));
copy_loop_start = code;
ppc_ldptr_update (code, ppc_r0, (unsigned int)sizeof (target_mgreg_t), ppc_r12);
ppc_stptr_update (code, ppc_r0, (unsigned int)sizeof (target_mgreg_t), ppc_r11);
copy_loop_jump = code;
ppc_bc (code, PPC_BR_DEC_CTR_NONZERO, 0, 0);
ppc_patch (copy_loop_jump, copy_loop_start);
size -= shifted * sizeof (target_mgreg_t);
doffset = soffset = 0;
dreg = ppc_r11;
}
#ifdef __mono_ppc64__
/* the hardware has multiple load/store units and the move is long
enough to use more then one register, then use load/load/store/store
to execute 2 instructions per cycle. */
if ((cpu_hw_caps & PPC_MULTIPLE_LS_UNITS) && (dreg != ppc_r11) && (sreg != ppc_r11)) {
while (size >= 16) {
ppc_ldptr (code, ppc_r0, soffset, sreg);
ppc_ldptr (code, ppc_r11, soffset+8, sreg);
ppc_stptr (code, ppc_r0, doffset, dreg);
ppc_stptr (code, ppc_r11, doffset+8, dreg);
size -= 16;
soffset += 16;
doffset += 16;
}
}
while (size >= 8) {
ppc_ldr (code, ppc_r0, soffset, sreg);
ppc_str (code, ppc_r0, doffset, dreg);
size -= 8;
soffset += 8;
doffset += 8;
}
#else
if ((cpu_hw_caps & PPC_MULTIPLE_LS_UNITS) && (dreg != ppc_r11) && (sreg != ppc_r11)) {
while (size >= 8) {
ppc_lwz (code, ppc_r0, soffset, sreg);
ppc_lwz (code, ppc_r11, soffset+4, sreg);
ppc_stw (code, ppc_r0, doffset, dreg);
ppc_stw (code, ppc_r11, doffset+4, dreg);
size -= 8;
soffset += 8;
doffset += 8;
}
}
#endif
while (size >= 4) {
ppc_lwz (code, ppc_r0, soffset, sreg);
ppc_stw (code, ppc_r0, doffset, dreg);
size -= 4;
soffset += 4;
doffset += 4;
}
while (size >= 2) {
ppc_lhz (code, ppc_r0, soffset, sreg);
ppc_sth (code, ppc_r0, doffset, dreg);
size -= 2;
soffset += 2;
doffset += 2;
}
while (size >= 1) {
ppc_lbz (code, ppc_r0, soffset, sreg);
ppc_stb (code, ppc_r0, doffset, dreg);
size -= 1;
soffset += 1;
doffset += 1;
}
return code;
}
/*
* mono_arch_get_argument_info:
* @csig: a method signature
* @param_count: the number of parameters to consider
* @arg_info: an array to store the result infos
*
* Gathers information on parameters such as size, alignment and
* padding. arg_info should be large enought to hold param_count + 1 entries.
*
* Returns the size of the activation frame.
*/
int
mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
{
#ifdef __mono_ppc64__
NOT_IMPLEMENTED;
return -1;
#else
int k, frame_size = 0;
int size, align, pad;
int offset = 8;
if (MONO_TYPE_ISSTRUCT (csig->ret)) {
frame_size += sizeof (target_mgreg_t);
offset += 4;
}
arg_info [0].offset = offset;
if (csig->hasthis) {
frame_size += sizeof (target_mgreg_t);
offset += 4;
}
arg_info [0].size = frame_size;
for (k = 0; k < param_count; k++) {
if (csig->pinvoke)
size = mono_type_native_stack_size (csig->params [k], (guint32*)&align);
else
size = mini_type_stack_size (csig->params [k], &align);
/* ignore alignment for now */
align = 1;
frame_size += pad = (align - (frame_size & (align - 1))) & (align - 1);
arg_info [k].pad = pad;
frame_size += size;
arg_info [k + 1].pad = 0;
arg_info [k + 1].size = size;
offset += pad;
arg_info [k + 1].offset = offset;
offset += size;
}
align = MONO_ARCH_FRAME_ALIGNMENT;
frame_size += pad = (align - (frame_size & (align - 1))) & (align - 1);
arg_info [k].pad = pad;
return frame_size;
#endif
}
#ifdef __mono_ppc64__
static gboolean
is_load_sequence (guint32 *seq)
{
return ppc_opcode (seq [0]) == 15 && /* lis */
ppc_opcode (seq [1]) == 24 && /* ori */
ppc_opcode (seq [2]) == 30 && /* sldi */
ppc_opcode (seq [3]) == 25 && /* oris */
ppc_opcode (seq [4]) == 24; /* ori */
}
#define ppc_load_get_dest(l) (((l)>>21) & 0x1f)
#define ppc_load_get_off(l) ((gint16)((l) & 0xffff))
#endif
/* ld || lwz */
#define ppc_is_load_op(opcode) (ppc_opcode ((opcode)) == 58 || ppc_opcode ((opcode)) == 32)
/* code must point to the blrl */
gboolean
mono_ppc_is_direct_call_sequence (guint32 *code)
{
#ifdef __mono_ppc64__
g_assert(*code == 0x4e800021 || *code == 0x4e800020 || *code == 0x4e800420);
/* the thunk-less direct call sequence: lis/ori/sldi/oris/ori/mtlr/blrl */
if (ppc_opcode (code [-1]) == 31) { /* mtlr */
if (ppc_is_load_op (code [-2]) && ppc_is_load_op (code [-3])) { /* ld/ld */
if (!is_load_sequence (&code [-8]))
return FALSE;
/* one of the loads must be "ld r2,8(rX)" or "ld r2,4(rX) for ilp32 */
return (ppc_load_get_dest (code [-2]) == ppc_r2 && ppc_load_get_off (code [-2]) == sizeof (target_mgreg_t)) ||
(ppc_load_get_dest (code [-3]) == ppc_r2 && ppc_load_get_off (code [-3]) == sizeof (target_mgreg_t));
}
if (ppc_opcode (code [-2]) == 24 && ppc_opcode (code [-3]) == 31) /* mr/nop */
return is_load_sequence (&code [-8]);
else
return is_load_sequence (&code [-6]);
}
return FALSE;
#else
g_assert(*code == 0x4e800021);
/* the thunk-less direct call sequence: lis/ori/mtlr/blrl */
return ppc_opcode (code [-1]) == 31 &&
ppc_opcode (code [-2]) == 24 &&
ppc_opcode (code [-3]) == 15;
#endif
}
#define MAX_ARCH_DELEGATE_PARAMS 7
static guint8*
get_delegate_invoke_impl (MonoTrampInfo **info, gboolean has_target, guint32 param_count, gboolean aot)
{
guint8 *code, *start;
if (has_target) {
int size = MONO_PPC_32_64_CASE (32, 32) + PPC_FTNPTR_SIZE;
start = code = mono_global_codeman_reserve (size);
if (!aot)
code = mono_ppc_create_pre_code_ftnptr (code);
/* Replace the this argument with the target */
ppc_ldptr (code, ppc_r0, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr), ppc_r3);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
/* it's a function descriptor */
/* Can't use ldptr as it doesn't work with r0 */
ppc_ldptr_indexed (code, ppc_r0, 0, ppc_r0);
#endif
ppc_mtctr (code, ppc_r0);
ppc_ldptr (code, ppc_r3, MONO_STRUCT_OFFSET (MonoDelegate, target), ppc_r3);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
g_assert ((code - start) <= size);
mono_arch_flush_icache (start, size);
MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE, NULL));
} else {
int size, i;
size = MONO_PPC_32_64_CASE (32, 32) + param_count * 4 + PPC_FTNPTR_SIZE;
start = code = mono_global_codeman_reserve (size);
if (!aot)
code = mono_ppc_create_pre_code_ftnptr (code);
ppc_ldptr (code, ppc_r0, MONO_STRUCT_OFFSET (MonoDelegate, method_ptr), ppc_r3);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
/* it's a function descriptor */
ppc_ldptr_indexed (code, ppc_r0, 0, ppc_r0);
#endif
ppc_mtctr (code, ppc_r0);
/* slide down the arguments */
for (i = 0; i < param_count; ++i) {
ppc_mr (code, (ppc_r3 + i), (ppc_r3 + i + 1));
}
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
g_assert ((code - start) <= size);
mono_arch_flush_icache (start, size);
MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_DELEGATE_INVOKE, NULL));
}
if (has_target) {
*info = mono_tramp_info_create ("delegate_invoke_impl_has_target", start, code - start, NULL, NULL);
} else {
char *name = g_strdup_printf ("delegate_invoke_impl_target_%d", param_count);
*info = mono_tramp_info_create (name, start, code - start, NULL, NULL);
g_free (name);
}
return start;
}
GSList*
mono_arch_get_delegate_invoke_impls (void)
{
GSList *res = NULL;
MonoTrampInfo *info;
int i;
get_delegate_invoke_impl (&info, TRUE, 0, TRUE);
res = g_slist_prepend (res, info);
for (i = 0; i <= MAX_ARCH_DELEGATE_PARAMS; ++i) {
get_delegate_invoke_impl (&info, FALSE, i, TRUE);
res = g_slist_prepend (res, info);
}
return res;
}
gpointer
mono_arch_get_delegate_invoke_impl (MonoMethodSignature *sig, gboolean has_target)
{
guint8 *code, *start;
/* FIXME: Support more cases */
if (MONO_TYPE_ISSTRUCT (sig->ret))
return NULL;
if (has_target) {
static guint8* cached = NULL;
if (cached)
return cached;
if (mono_ee_features.use_aot_trampolines) {
start = (guint8*)mono_aot_get_trampoline ("delegate_invoke_impl_has_target");
} else {
MonoTrampInfo *info;
start = get_delegate_invoke_impl (&info, TRUE, 0, FALSE);
mono_tramp_info_register (info, NULL);
}
mono_memory_barrier ();
cached = start;
} else {
static guint8* cache [MAX_ARCH_DELEGATE_PARAMS + 1] = {NULL};
int i;
if (sig->param_count > MAX_ARCH_DELEGATE_PARAMS)
return NULL;
for (i = 0; i < sig->param_count; ++i)
if (!mono_is_regsize_var (sig->params [i]))
return NULL;
code = cache [sig->param_count];
if (code)
return code;
if (mono_ee_features.use_aot_trampolines) {
char *name = g_strdup_printf ("delegate_invoke_impl_target_%d", sig->param_count);
start = (guint8*)mono_aot_get_trampoline (name);
g_free (name);
} else {
MonoTrampInfo *info;
start = get_delegate_invoke_impl (&info, FALSE, sig->param_count, FALSE);
mono_tramp_info_register (info, NULL);
}
mono_memory_barrier ();
cache [sig->param_count] = start;
}
return start;
}
gpointer
mono_arch_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method, int offset, gboolean load_imt_reg)
{
return NULL;
}
gpointer
mono_arch_get_this_arg_from_call (host_mgreg_t *r, guint8 *code)
{
return (gpointer)(gsize)r [ppc_r3];
}
typedef struct {
long int type;
long int value;
} AuxVec;
#define MAX_AUX_ENTRIES 128
/*
* PPC_FEATURE_POWER4, PPC_FEATURE_POWER5, PPC_FEATURE_POWER5_PLUS, PPC_FEATURE_CELL,
* PPC_FEATURE_PA6T, PPC_FEATURE_ARCH_2_05 are considered supporting 2X ISA features
*/
#define ISA_2X (0x00080000 | 0x00040000 | 0x00020000 | 0x00010000 | 0x00000800 | 0x00001000)
/* define PPC_FEATURE_64 HWCAP for 64-bit category. */
#define ISA_64 0x40000000
/* define PPC_FEATURE_POWER6_EXT HWCAP for power6x mffgpr/mftgpr instructions. */
#define ISA_MOVE_FPR_GPR 0x00000200
/*
* Initialize the cpu to execute managed code.
*/
void
mono_arch_cpu_init (void)
{
}
/*
* Initialize architecture specific code.
*/
void
mono_arch_init (void)
{
#if defined(MONO_CROSS_COMPILE)
#elif defined(__APPLE__)
int mib [3];
size_t len = sizeof (cachelinesize);
mib [0] = CTL_HW;
mib [1] = HW_CACHELINE;
if (sysctl (mib, 2, &cachelinesize, &len, NULL, 0) == -1) {
perror ("sysctl");
cachelinesize = 128;
} else {
cachelineinc = cachelinesize;
}
#elif defined(__linux__)
AuxVec vec [MAX_AUX_ENTRIES];
int i, vec_entries = 0;
/* sadly this will work only with 2.6 kernels... */
FILE* f = fopen ("/proc/self/auxv", "rb");
if (f) {
vec_entries = fread (&vec, sizeof (AuxVec), MAX_AUX_ENTRIES, f);
fclose (f);
}
for (i = 0; i < vec_entries; i++) {
int type = vec [i].type;
if (type == 19) { /* AT_DCACHEBSIZE */
cachelinesize = vec [i].value;
continue;
}
}
#elif defined(G_COMPILER_CODEWARRIOR)
cachelinesize = 32;
cachelineinc = 32;
#elif defined(_AIX)
/* FIXME: use block instead? */
cachelinesize = _system_configuration.icache_line;
cachelineinc = _system_configuration.icache_line;
#else
//#error Need a way to get cache line size
#endif
if (mono_hwcap_ppc_has_icache_snoop)
cpu_hw_caps |= PPC_ICACHE_SNOOP;
if (mono_hwcap_ppc_is_isa_2x)
cpu_hw_caps |= PPC_ISA_2X;
if (mono_hwcap_ppc_is_isa_2_03)
cpu_hw_caps |= PPC_ISA_2_03;
if (mono_hwcap_ppc_is_isa_64)
cpu_hw_caps |= PPC_ISA_64;
if (mono_hwcap_ppc_has_move_fpr_gpr)
cpu_hw_caps |= PPC_MOVE_FPR_GPR;
if (mono_hwcap_ppc_has_multiple_ls_units)
cpu_hw_caps |= PPC_MULTIPLE_LS_UNITS;
if (!cachelinesize)
cachelinesize = 32;
if (!cachelineinc)
cachelineinc = cachelinesize;
if (mono_cpu_count () > 1)
cpu_hw_caps |= PPC_SMP_CAPABLE;
mono_os_mutex_init_recursive (&mini_arch_mutex);
ss_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, MONO_MEM_ACCOUNT_OTHER);
bp_trigger_page = mono_valloc (NULL, mono_pagesize (), MONO_MMAP_READ, MONO_MEM_ACCOUNT_OTHER);
mono_mprotect (bp_trigger_page, mono_pagesize (), 0);
// FIXME: Fix partial sharing for power and remove this
mono_set_partial_sharing_supported (FALSE);
}
/*
* Cleanup architecture specific code.
*/
void
mono_arch_cleanup (void)
{
mono_os_mutex_destroy (&mini_arch_mutex);
}
gboolean
mono_arch_have_fast_tls (void)
{
return FALSE;
}
/*
* This function returns the optimizations supported on this cpu.
*/
guint32
mono_arch_cpu_optimizations (guint32 *exclude_mask)
{
guint32 opts = 0;
/* no ppc-specific optimizations yet */
*exclude_mask = 0;
return opts;
}
#ifdef __mono_ppc64__
#define CASE_PPC32(c)
#define CASE_PPC64(c) case c:
#else
#define CASE_PPC32(c) case c:
#define CASE_PPC64(c)
#endif
static gboolean
is_regsize_var (MonoType *t) {
if (t->byref)
return TRUE;
t = mini_get_underlying_type (t);
switch (t->type) {
case MONO_TYPE_I4:
case MONO_TYPE_U4:
CASE_PPC64 (MONO_TYPE_I8)
CASE_PPC64 (MONO_TYPE_U8)
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
return TRUE;
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_CLASS:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_ARRAY:
return TRUE;
case MONO_TYPE_GENERICINST:
if (!mono_type_generic_inst_is_valuetype (t))
return TRUE;
return FALSE;
case MONO_TYPE_VALUETYPE:
return FALSE;
}
return FALSE;
}
#ifndef DISABLE_JIT
GList *
mono_arch_get_allocatable_int_vars (MonoCompile *cfg)
{
GList *vars = NULL;
int i;
for (i = 0; i < cfg->num_varinfo; i++) {
MonoInst *ins = cfg->varinfo [i];
MonoMethodVar *vmv = MONO_VARINFO (cfg, i);
/* unused vars */
if (vmv->range.first_use.abs_pos >= vmv->range.last_use.abs_pos)
continue;
if (ins->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT) || (ins->opcode != OP_LOCAL && ins->opcode != OP_ARG))
continue;
/* we can only allocate 32 bit values */
if (is_regsize_var (ins->inst_vtype)) {
g_assert (MONO_VARINFO (cfg, i)->reg == -1);
g_assert (i == vmv->idx);
vars = mono_varlist_insert_sorted (cfg, vars, vmv, FALSE);
}
}
return vars;
}
#endif /* ifndef DISABLE_JIT */
GList *
mono_arch_get_global_int_regs (MonoCompile *cfg)
{
GList *regs = NULL;
int i, top = 32;
if (cfg->frame_reg != ppc_sp)
top = 31;
/* ppc_r13 is used by the system on PPC EABI */
for (i = 14; i < top; ++i) {
/*
* Reserve r29 for holding the vtable address for virtual calls in AOT mode,
* since the trampolines can clobber r12.
*/
if (!(cfg->compile_aot && i == 29))
regs = g_list_prepend (regs, GUINT_TO_POINTER (i));
}
return regs;
}
/*
* mono_arch_regalloc_cost:
*
* Return the cost, in number of memory references, of the action of
* allocating the variable VMV into a register during global register
* allocation.
*/
guint32
mono_arch_regalloc_cost (MonoCompile *cfg, MonoMethodVar *vmv)
{
/* FIXME: */
return 2;
}
void
mono_arch_flush_icache (guint8 *code, gint size)
{
#ifdef MONO_CROSS_COMPILE
/* do nothing */
#else
register guint8 *p;
guint8 *endp, *start;
p = start = code;
endp = p + size;
start = (guint8*)((gsize)start & ~(cachelinesize - 1));
/* use dcbf for smp support, later optimize for UP, see pem._64bit.d20030611.pdf page 211 */
#if defined(G_COMPILER_CODEWARRIOR)
if (cpu_hw_caps & PPC_SMP_CAPABLE) {
for (p = start; p < endp; p += cachelineinc) {
asm { dcbf 0, p };
}
} else {
for (p = start; p < endp; p += cachelineinc) {
asm { dcbst 0, p };
}
}
asm { sync };
p = code;
for (p = start; p < endp; p += cachelineinc) {
asm {
icbi 0, p
sync
}
}
asm {
sync
isync
}
#else
/* For POWER5/6 with ICACHE_SNOOPing only one icbi in the range is required.
* The sync is required to insure that the store queue is completely empty.
* While the icbi performs no cache operations, icbi/isync is required to
* kill local prefetch.
*/
if (cpu_hw_caps & PPC_ICACHE_SNOOP) {
asm ("sync");
asm ("icbi 0,%0;" : : "r"(code) : "memory");
asm ("isync");
return;
}
/* use dcbf for smp support, see pem._64bit.d20030611.pdf page 211 */
if (cpu_hw_caps & PPC_SMP_CAPABLE) {
for (p = start; p < endp; p += cachelineinc) {
asm ("dcbf 0,%0;" : : "r"(p) : "memory");
}
} else {
for (p = start; p < endp; p += cachelineinc) {
asm ("dcbst 0,%0;" : : "r"(p) : "memory");
}
}
asm ("sync");
p = code;
for (p = start; p < endp; p += cachelineinc) {
/* for ISA2.0+ implementations we should not need any extra sync between the
* icbi instructions. Both the 2.0 PEM and the PowerISA-2.05 say this.
* So I am not sure which chip had this problem but its not an issue on
* of the ISA V2 chips.
*/
if (cpu_hw_caps & PPC_ISA_2X)
asm ("icbi 0,%0;" : : "r"(p) : "memory");
else
asm ("icbi 0,%0; sync;" : : "r"(p) : "memory");
}
if (!(cpu_hw_caps & PPC_ISA_2X))
asm ("sync");
asm ("isync");
#endif
#endif
}
void
mono_arch_flush_register_windows (void)
{
}
#ifdef __APPLE__
#define ALWAYS_ON_STACK(s) s
#define FP_ALSO_IN_REG(s) s
#else
#ifdef __mono_ppc64__
#define ALWAYS_ON_STACK(s) s
#define FP_ALSO_IN_REG(s) s
#else
#define ALWAYS_ON_STACK(s)
#define FP_ALSO_IN_REG(s)
#endif
#define ALIGN_DOUBLES
#endif
enum {
RegTypeGeneral,
RegTypeBase,
RegTypeFP,
RegTypeStructByVal,
RegTypeStructByAddr,
RegTypeFPStructByVal, // For the v2 ABI, floats should be passed in FRs instead of GRs. Only valid for ABI v2!
};
typedef struct {
gint32 offset;
guint32 vtsize; /* in param area */
guint8 reg;
guint8 vtregs; /* number of registers used to pass a RegTypeStructByVal/RegTypeFPStructByVal */
guint8 regtype : 4; /* 0 general, 1 basereg, 2 floating point register, see RegType* */
guint8 size : 4; /* 1, 2, 4, 8, or regs used by RegTypeStructByVal/RegTypeFPStructByVal */
guint8 bytes : 4; /* size in bytes - only valid for
RegTypeStructByVal/RegTypeFPStructByVal if the struct fits
in one word, otherwise it's 0*/
} ArgInfo;
struct CallInfo {
int nargs;
guint32 stack_usage;
guint32 struct_ret;
ArgInfo ret;
ArgInfo sig_cookie;
gboolean vtype_retaddr;
int vret_arg_index;
ArgInfo args [1];
};
#define DEBUG(a)
#if PPC_RETURN_SMALL_FLOAT_STRUCTS_IN_FR_REGS
//
// Test if a structure is completely composed of either float XOR double fields and has fewer than
// PPC_MOST_FLOAT_STRUCT_MEMBERS_TO_RETURN_VIA_REGISTER members.
// If this is true the structure can be returned directly via float registers instead of by a hidden parameter
// pointing to where the return value should be stored.
// This is as per the ELF ABI v2.
//
static gboolean
is_float_struct_returnable_via_regs (MonoType *type, int* member_cnt, int* member_size)
{
int local_member_cnt, local_member_size;
if (!member_cnt) {
member_cnt = &local_member_cnt;
}
if (!member_size) {
member_size = &local_member_size;
}
gboolean is_all_floats = mini_type_is_hfa(type, member_cnt, member_size);
return is_all_floats && (*member_cnt <= PPC_MOST_FLOAT_STRUCT_MEMBERS_TO_RETURN_VIA_REGISTERS);
}
#else
#define is_float_struct_returnable_via_regs(a,b,c) (FALSE)
#endif
#if PPC_RETURN_SMALL_STRUCTS_IN_REGS
//
// Test if a structure is smaller in size than 2 doublewords (PPC_LARGEST_STRUCT_SIZE_TO_RETURN_VIA_REGISTERS) and is
// completely composed of fields all of basic types.
// If this is true the structure can be returned directly via registers r3/r4 instead of by a hidden parameter
// pointing to where the return value should be stored.
// This is as per the ELF ABI v2.
//
static gboolean
is_struct_returnable_via_regs (MonoClass *klass, gboolean is_pinvoke)
{
gboolean has_a_field = FALSE;
int size = 0;
if (klass) {
gpointer iter = NULL;
MonoClassField *f;
if (is_pinvoke)
size = mono_type_native_stack_size (m_class_get_byval_arg (klass), 0);
else
size = mini_type_stack_size (m_class_get_byval_arg (klass), 0);
if (size == 0)
return TRUE;
if (size > PPC_LARGEST_STRUCT_SIZE_TO_RETURN_VIA_REGISTERS)
return FALSE;
while ((f = mono_class_get_fields_internal (klass, &iter))) {
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
// TBD: Is there a better way to check for the basic types?
if (f->type->byref) {
return FALSE;
} else if ((f->type->type >= MONO_TYPE_BOOLEAN) && (f->type->type <= MONO_TYPE_R8)) {
has_a_field = TRUE;
} else if (MONO_TYPE_ISSTRUCT (f->type)) {
MonoClass *klass = mono_class_from_mono_type_internal (f->type);
if (is_struct_returnable_via_regs(klass, is_pinvoke)) {
has_a_field = TRUE;
} else {
return FALSE;
}
} else {
return FALSE;
}
}
}
}
return has_a_field;
}
#else
#define is_struct_returnable_via_regs(a,b) (FALSE)
#endif
static void inline
add_general (guint *gr, guint *stack_size, ArgInfo *ainfo, gboolean simple)
{
#ifdef __mono_ppc64__
g_assert (simple);
#endif
if (simple) {
if (*gr >= 3 + PPC_NUM_REG_ARGS) {
ainfo->offset = PPC_STACK_PARAM_OFFSET + *stack_size;
ainfo->reg = ppc_sp; /* in the caller */
ainfo->regtype = RegTypeBase;
*stack_size += sizeof (target_mgreg_t);
} else {
ALWAYS_ON_STACK (*stack_size += sizeof (target_mgreg_t));
ainfo->reg = *gr;
}
} else {
if (*gr >= 3 + PPC_NUM_REG_ARGS - 1) {
#ifdef ALIGN_DOUBLES
//*stack_size += (*stack_size % 8);
#endif
ainfo->offset = PPC_STACK_PARAM_OFFSET + *stack_size;
ainfo->reg = ppc_sp; /* in the caller */
ainfo->regtype = RegTypeBase;
*stack_size += 8;
} else {
#ifdef ALIGN_DOUBLES
if (!((*gr) & 1))
(*gr) ++;
#endif
ALWAYS_ON_STACK (*stack_size += 8);
ainfo->reg = *gr;
}
(*gr) ++;
}
(*gr) ++;
}
#if defined(__APPLE__) || (defined(__mono_ppc64__) && !PPC_PASS_SMALL_FLOAT_STRUCTS_IN_FR_REGS)
static gboolean
has_only_a_r48_field (MonoClass *klass)
{
gpointer iter;
MonoClassField *f;
gboolean have_field = FALSE;
iter = NULL;
while ((f = mono_class_get_fields_internal (klass, &iter))) {
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC)) {
if (have_field)
return FALSE;
if (!f->type->byref && (f->type->type == MONO_TYPE_R4 || f->type->type == MONO_TYPE_R8))
have_field = TRUE;
else
return FALSE;
}
}
return have_field;
}
#endif
static CallInfo*
get_call_info (MonoMethodSignature *sig)
{
guint i, fr, gr, pstart;
int n = sig->hasthis + sig->param_count;
MonoType *simpletype;
guint32 stack_size = 0;
CallInfo *cinfo = g_malloc0 (sizeof (CallInfo) + sizeof (ArgInfo) * n);
gboolean is_pinvoke = sig->pinvoke;
fr = PPC_FIRST_FPARG_REG;
gr = PPC_FIRST_ARG_REG;
if (mini_type_is_vtype (sig->ret)) {
cinfo->vtype_retaddr = TRUE;
}
pstart = 0;
n = 0;
/*
* To simplify get_this_arg_reg () and LLVM integration, emit the vret arg after
* the first argument, allowing 'this' to be always passed in the first arg reg.
* Also do this if the first argument is a reference type, since virtual calls
* are sometimes made using calli without sig->hasthis set, like in the delegate
* invoke wrappers.
*/
if (cinfo->vtype_retaddr && !is_pinvoke && (sig->hasthis || (sig->param_count > 0 && MONO_TYPE_IS_REFERENCE (mini_get_underlying_type (sig->params [0]))))) {
if (sig->hasthis) {
add_general (&gr, &stack_size, cinfo->args + 0, TRUE);
n ++;
} else {
add_general (&gr, &stack_size, &cinfo->args [sig->hasthis + 0], TRUE);
pstart = 1;
n ++;
}
add_general (&gr, &stack_size, &cinfo->ret, TRUE);
cinfo->struct_ret = cinfo->ret.reg;
cinfo->vret_arg_index = 1;
} else {
/* this */
if (sig->hasthis) {
add_general (&gr, &stack_size, cinfo->args + 0, TRUE);
n ++;
}
if (cinfo->vtype_retaddr) {
add_general (&gr, &stack_size, &cinfo->ret, TRUE);
cinfo->struct_ret = cinfo->ret.reg;
}
}
DEBUG(printf("params: %d\n", sig->param_count));
for (i = pstart; i < sig->param_count; ++i) {
if (!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG) && (i == sig->sentinelpos)) {
/* Prevent implicit arguments and sig_cookie from
being passed in registers */
gr = PPC_LAST_ARG_REG + 1;
/* FIXME: don't we have to set fr, too? */
/* Emit the signature cookie just before the implicit arguments */
add_general (&gr, &stack_size, &cinfo->sig_cookie, TRUE);
}
DEBUG(printf("param %d: ", i));
if (sig->params [i]->byref) {
DEBUG(printf("byref\n"));
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
continue;
}
simpletype = mini_get_underlying_type (sig->params [i]);
switch (simpletype->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
cinfo->args [n].size = 1;
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
case MONO_TYPE_CHAR:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
cinfo->args [n].size = 2;
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
case MONO_TYPE_I4:
case MONO_TYPE_U4:
cinfo->args [n].size = 4;
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_STRING:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_ARRAY:
cinfo->args [n].size = sizeof (target_mgreg_t);
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
case MONO_TYPE_GENERICINST:
if (!mono_type_generic_inst_is_valuetype (simpletype)) {
cinfo->args [n].size = sizeof (target_mgreg_t);
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
n++;
break;
}
/* Fall through */
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_TYPEDBYREF: {
gint size;
MonoClass *klass = mono_class_from_mono_type_internal (sig->params [i]);
if (simpletype->type == MONO_TYPE_TYPEDBYREF)
size = MONO_ABI_SIZEOF (MonoTypedRef);
else if (is_pinvoke)
size = mono_class_native_size (klass, NULL);
else
size = mono_class_value_size (klass, NULL);
#if defined(__APPLE__) || (defined(__mono_ppc64__) && !PPC_PASS_SMALL_FLOAT_STRUCTS_IN_FR_REGS)
if ((size == 4 || size == 8) && has_only_a_r48_field (klass)) {
cinfo->args [n].size = size;
/* It was 7, now it is 8 in LinuxPPC */
if (fr <= PPC_LAST_FPARG_REG) {
cinfo->args [n].regtype = RegTypeFP;
cinfo->args [n].reg = fr;
fr ++;
FP_ALSO_IN_REG (gr ++);
#if !defined(__mono_ppc64__)
if (size == 8)
FP_ALSO_IN_REG (gr ++);
#endif
ALWAYS_ON_STACK (stack_size += size);
} else {
cinfo->args [n].offset = PPC_STACK_PARAM_OFFSET + stack_size;
cinfo->args [n].regtype = RegTypeBase;
cinfo->args [n].reg = ppc_sp; /* in the caller*/
stack_size += 8;
}
n++;
break;
}
#endif
DEBUG(printf ("load %d bytes struct\n",
mono_class_native_size (sig->params [i]->data.klass, NULL)));
#if PPC_PASS_STRUCTS_BY_VALUE
{
int align_size = size;
int nregs = 0;
int rest = PPC_LAST_ARG_REG - gr + 1;
int n_in_regs = 0;
#if PPC_PASS_SMALL_FLOAT_STRUCTS_IN_FR_REGS
int mbr_cnt = 0;
int mbr_size = 0;
gboolean is_all_floats = is_float_struct_returnable_via_regs (sig->params [i], &mbr_cnt, &mbr_size);
if (is_all_floats) {
rest = PPC_LAST_FPARG_REG - fr + 1;
}
// Pass small (<= 8 member) structures entirely made up of either float or double members
// in FR registers. There have to be at least mbr_cnt registers left.
if (is_all_floats &&
(rest >= mbr_cnt)) {
nregs = mbr_cnt;
n_in_regs = MIN (rest, nregs);
cinfo->args [n].regtype = RegTypeFPStructByVal;
cinfo->args [n].vtregs = n_in_regs;
cinfo->args [n].size = mbr_size;
cinfo->args [n].vtsize = nregs - n_in_regs;
cinfo->args [n].reg = fr;
fr += n_in_regs;
if (mbr_size == 4) {
// floats
FP_ALSO_IN_REG (gr += (n_in_regs+1)/2);
} else {
// doubles
FP_ALSO_IN_REG (gr += (n_in_regs));
}
} else
#endif
{
align_size += (sizeof (target_mgreg_t) - 1);
align_size &= ~(sizeof (target_mgreg_t) - 1);
nregs = (align_size + sizeof (target_mgreg_t) -1 ) / sizeof (target_mgreg_t);
n_in_regs = MIN (rest, nregs);
if (n_in_regs < 0)
n_in_regs = 0;
#ifdef __APPLE__
/* FIXME: check this */
if (size >= 3 && size % 4 != 0)
n_in_regs = 0;
#endif
cinfo->args [n].regtype = RegTypeStructByVal;
cinfo->args [n].vtregs = n_in_regs;
cinfo->args [n].size = n_in_regs;
cinfo->args [n].vtsize = nregs - n_in_regs;
cinfo->args [n].reg = gr;
gr += n_in_regs;
}
#ifdef __mono_ppc64__
if (nregs == 1 && is_pinvoke)
cinfo->args [n].bytes = size;
else
#endif
cinfo->args [n].bytes = 0;
cinfo->args [n].offset = PPC_STACK_PARAM_OFFSET + stack_size;
/*g_print ("offset for arg %d at %d\n", n, PPC_STACK_PARAM_OFFSET + stack_size);*/
stack_size += nregs * sizeof (target_mgreg_t);
}
#else
add_general (&gr, &stack_size, cinfo->args + n, TRUE);
cinfo->args [n].regtype = RegTypeStructByAddr;
cinfo->args [n].vtsize = size;
#endif
n++;
break;
}
case MONO_TYPE_U8:
case MONO_TYPE_I8:
cinfo->args [n].size = 8;
add_general (&gr, &stack_size, cinfo->args + n, SIZEOF_REGISTER == 8);
n++;
break;
case MONO_TYPE_R4:
cinfo->args [n].size = 4;
/* It was 7, now it is 8 in LinuxPPC */
if (fr <= PPC_LAST_FPARG_REG
// For non-native vararg calls the parms must go in storage
&& !(!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG))
) {
cinfo->args [n].regtype = RegTypeFP;
cinfo->args [n].reg = fr;
fr ++;
FP_ALSO_IN_REG (gr ++);
ALWAYS_ON_STACK (stack_size += SIZEOF_REGISTER);
} else {
cinfo->args [n].offset = PPC_STACK_PARAM_OFFSET + stack_size + MONO_PPC_32_64_CASE (0, 4);
cinfo->args [n].regtype = RegTypeBase;
cinfo->args [n].reg = ppc_sp; /* in the caller*/
stack_size += SIZEOF_REGISTER;
}
n++;
break;
case MONO_TYPE_R8:
cinfo->args [n].size = 8;
/* It was 7, now it is 8 in LinuxPPC */
if (fr <= PPC_LAST_FPARG_REG
// For non-native vararg calls the parms must go in storage
&& !(!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG))
) {
cinfo->args [n].regtype = RegTypeFP;
cinfo->args [n].reg = fr;
fr ++;
FP_ALSO_IN_REG (gr += sizeof (double) / SIZEOF_REGISTER);
ALWAYS_ON_STACK (stack_size += 8);
} else {
cinfo->args [n].offset = PPC_STACK_PARAM_OFFSET + stack_size;
cinfo->args [n].regtype = RegTypeBase;
cinfo->args [n].reg = ppc_sp; /* in the caller*/
stack_size += 8;
}
n++;
break;
default:
g_error ("Can't trampoline 0x%x", sig->params [i]->type);
}
}
cinfo->nargs = n;
if (!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG) && (i == sig->sentinelpos)) {
/* Prevent implicit arguments and sig_cookie from
being passed in registers */
gr = PPC_LAST_ARG_REG + 1;
/* Emit the signature cookie just before the implicit arguments */
add_general (&gr, &stack_size, &cinfo->sig_cookie, TRUE);
}
{
simpletype = mini_get_underlying_type (sig->ret);
switch (simpletype->type) {
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_FNPTR:
case MONO_TYPE_CLASS:
case MONO_TYPE_OBJECT:
case MONO_TYPE_SZARRAY:
case MONO_TYPE_ARRAY:
case MONO_TYPE_STRING:
cinfo->ret.reg = ppc_r3;
break;
case MONO_TYPE_U8:
case MONO_TYPE_I8:
cinfo->ret.reg = ppc_r3;
break;
case MONO_TYPE_R4:
case MONO_TYPE_R8:
cinfo->ret.reg = ppc_f1;
cinfo->ret.regtype = RegTypeFP;
break;
case MONO_TYPE_GENERICINST:
if (!mono_type_generic_inst_is_valuetype (simpletype)) {
cinfo->ret.reg = ppc_r3;
break;
}
break;
case MONO_TYPE_VALUETYPE:
break;
case MONO_TYPE_TYPEDBYREF:
case MONO_TYPE_VOID:
break;
default:
g_error ("Can't handle as return value 0x%x", sig->ret->type);
}
}
/* align stack size to 16 */
DEBUG (printf (" stack size: %d (%d)\n", (stack_size + 15) & ~15, stack_size));
stack_size = (stack_size + 15) & ~15;
cinfo->stack_usage = stack_size;
return cinfo;
}
#ifndef DISABLE_JIT
gboolean
mono_arch_tailcall_supported (MonoCompile *cfg, MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig, gboolean virtual_)
{
CallInfo *caller_info = get_call_info (caller_sig);
CallInfo *callee_info = get_call_info (callee_sig);
gboolean res = IS_SUPPORTED_TAILCALL (callee_info->stack_usage <= caller_info->stack_usage)
&& IS_SUPPORTED_TAILCALL (memcmp (&callee_info->ret, &caller_info->ret, sizeof (caller_info->ret)) == 0);
// FIXME ABIs vary as to if this local is in the parameter area or not,
// so this check might not be needed.
for (int i = 0; res && i < callee_info->nargs; ++i) {
res = IS_SUPPORTED_TAILCALL (callee_info->args [i].regtype != RegTypeStructByAddr);
/* An address on the callee's stack is passed as the argument */
}
g_free (caller_info);
g_free (callee_info);
return res;
}
#endif
/*
* Set var information according to the calling convention. ppc version.
* The locals var stuff should most likely be split in another method.
*/
void
mono_arch_allocate_vars (MonoCompile *m)
{
MonoMethodSignature *sig;
MonoMethodHeader *header;
MonoInst *inst;
int i, offset, size, align, curinst;
int frame_reg = ppc_sp;
gint32 *offsets;
guint32 locals_stack_size, locals_stack_align;
m->flags |= MONO_CFG_HAS_SPILLUP;
/* this is bug #60332: remove when #59509 is fixed, so no weird vararg
* call convs needs to be handled this way.
*/
if (m->flags & MONO_CFG_HAS_VARARGS)
m->param_area = MAX (m->param_area, sizeof (target_mgreg_t)*8);
/* gtk-sharp and other broken code will dllimport vararg functions even with
* non-varargs signatures. Since there is little hope people will get this right
* we assume they won't.
*/
if (m->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
m->param_area = MAX (m->param_area, sizeof (target_mgreg_t)*8);
header = m->header;
/*
* We use the frame register also for any method that has
* exception clauses. This way, when the handlers are called,
* the code will reference local variables using the frame reg instead of
* the stack pointer: if we had to restore the stack pointer, we'd
* corrupt the method frames that are already on the stack (since
* filters get called before stack unwinding happens) when the filter
* code would call any method (this also applies to finally etc.).
*/
if ((m->flags & MONO_CFG_HAS_ALLOCA) || header->num_clauses)
frame_reg = ppc_r31;
m->frame_reg = frame_reg;
if (frame_reg != ppc_sp) {
m->used_int_regs |= 1 << frame_reg;
}
sig = mono_method_signature_internal (m->method);
offset = 0;
curinst = 0;
if (MONO_TYPE_ISSTRUCT (sig->ret)) {
m->ret->opcode = OP_REGVAR;
m->ret->inst_c0 = m->ret->dreg = ppc_r3;
} else {
/* FIXME: handle long values? */
switch (mini_get_underlying_type (sig->ret)->type) {
case MONO_TYPE_VOID:
break;
case MONO_TYPE_R4:
case MONO_TYPE_R8:
m->ret->opcode = OP_REGVAR;
m->ret->inst_c0 = m->ret->dreg = ppc_f1;
break;
default:
m->ret->opcode = OP_REGVAR;
m->ret->inst_c0 = m->ret->dreg = ppc_r3;
break;
}
}
/* local vars are at a positive offset from the stack pointer */
/*
* also note that if the function uses alloca, we use ppc_r31
* to point at the local variables.
*/
offset = PPC_MINIMAL_STACK_SIZE; /* linkage area */
/* align the offset to 16 bytes: not sure this is needed here */
//offset += 16 - 1;
//offset &= ~(16 - 1);
/* add parameter area size for called functions */
offset += m->param_area;
offset += 16 - 1;
offset &= ~(16 - 1);
/* the MonoLMF structure is stored just below the stack pointer */
if (MONO_TYPE_ISSTRUCT (sig->ret)) {
offset += sizeof(gpointer) - 1;
offset &= ~(sizeof(gpointer) - 1);
m->vret_addr->opcode = OP_REGOFFSET;
m->vret_addr->inst_basereg = frame_reg;
m->vret_addr->inst_offset = offset;
if (G_UNLIKELY (m->verbose_level > 1)) {
printf ("vret_addr =");
mono_print_ins (m->vret_addr);
}
offset += sizeof(gpointer);
}
offsets = mono_allocate_stack_slots (m, FALSE, &locals_stack_size, &locals_stack_align);
if (locals_stack_align) {
offset += (locals_stack_align - 1);
offset &= ~(locals_stack_align - 1);
}
for (i = m->locals_start; i < m->num_varinfo; i++) {
if (offsets [i] != -1) {
MonoInst *inst = m->varinfo [i];
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
inst->inst_offset = offset + offsets [i];
/*
g_print ("allocating local %d (%s) to %d\n",
i, mono_type_get_name (inst->inst_vtype), inst->inst_offset);
*/
}
}
offset += locals_stack_size;
curinst = 0;
if (sig->hasthis) {
inst = m->args [curinst];
if (inst->opcode != OP_REGVAR) {
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
offset += sizeof (target_mgreg_t) - 1;
offset &= ~(sizeof (target_mgreg_t) - 1);
inst->inst_offset = offset;
offset += sizeof (target_mgreg_t);
}
curinst++;
}
for (i = 0; i < sig->param_count; ++i) {
inst = m->args [curinst];
if (inst->opcode != OP_REGVAR) {
inst->opcode = OP_REGOFFSET;
inst->inst_basereg = frame_reg;
if (sig->pinvoke) {
size = mono_type_native_stack_size (sig->params [i], (guint32*)&align);
inst->backend.is_pinvoke = 1;
} else {
size = mono_type_size (sig->params [i], &align);
}
if (MONO_TYPE_ISSTRUCT (sig->params [i]) && size < sizeof (target_mgreg_t))
size = align = sizeof (target_mgreg_t);
/*
* Use at least 4/8 byte alignment, since these might be passed in registers, and
* they are saved using std in the prolog.
*/
align = sizeof (target_mgreg_t);
offset += align - 1;
offset &= ~(align - 1);
inst->inst_offset = offset;
offset += size;
}
curinst++;
}
/* some storage for fp conversions */
offset += 8 - 1;
offset &= ~(8 - 1);
m->arch.fp_conv_var_offset = offset;
offset += 8;
/* align the offset to 16 bytes */
offset += 16 - 1;
offset &= ~(16 - 1);
/* change sign? */
m->stack_offset = offset;
if (sig->call_convention == MONO_CALL_VARARG) {
CallInfo *cinfo = get_call_info (m->method->signature);
m->sig_cookie = cinfo->sig_cookie.offset;
g_free(cinfo);
}
}
void
mono_arch_create_vars (MonoCompile *cfg)
{
MonoMethodSignature *sig = mono_method_signature_internal (cfg->method);
if (MONO_TYPE_ISSTRUCT (sig->ret)) {
cfg->vret_addr = mono_compile_create_var (cfg, mono_get_int_type (), OP_ARG);
}
}
/* Fixme: we need an alignment solution for enter_method and mono_arch_call_opcode,
* currently alignment in mono_arch_call_opcode is computed without arch_get_argument_info
*/
static void
emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo)
{
int sig_reg = mono_alloc_ireg (cfg);
/* FIXME: Add support for signature tokens to AOT */
cfg->disable_aot = TRUE;
MONO_EMIT_NEW_ICONST (cfg, sig_reg, (gulong)call->signature);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG,
ppc_r1, cinfo->sig_cookie.offset, sig_reg);
}
void
mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call)
{
MonoInst *in, *ins;
MonoMethodSignature *sig;
int i, n;
CallInfo *cinfo;
sig = call->signature;
n = sig->param_count + sig->hasthis;
cinfo = get_call_info (sig);
for (i = 0; i < n; ++i) {
ArgInfo *ainfo = cinfo->args + i;
MonoType *t;
if (i >= sig->hasthis)
t = sig->params [i - sig->hasthis];
else
t = mono_get_int_type ();
t = mini_get_underlying_type (t);
if (!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG) && (i == sig->sentinelpos))
emit_sig_cookie (cfg, call, cinfo);
in = call->args [i];
if (ainfo->regtype == RegTypeGeneral) {
#ifndef __mono_ppc64__
if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
MONO_INST_NEW (cfg, ins, OP_MOVE);
ins->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = MONO_LVREG_LS (in->dreg);
MONO_ADD_INS (cfg->cbb, ins);
mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg + 1, FALSE);
MONO_INST_NEW (cfg, ins, OP_MOVE);
ins->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = MONO_LVREG_MS (in->dreg);
MONO_ADD_INS (cfg->cbb, ins);
mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg, FALSE);
} else
#endif
{
MONO_INST_NEW (cfg, ins, OP_MOVE);
ins->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = in->dreg;
MONO_ADD_INS (cfg->cbb, ins);
mono_call_inst_add_outarg_reg (cfg, call, ins->dreg, ainfo->reg, FALSE);
}
} else if (ainfo->regtype == RegTypeStructByAddr) {
MONO_INST_NEW (cfg, ins, OP_OUTARG_VT);
ins->opcode = OP_OUTARG_VT;
ins->sreg1 = in->dreg;
ins->klass = in->klass;
ins->inst_p0 = call;
ins->inst_p1 = mono_mempool_alloc (cfg->mempool, sizeof (ArgInfo));
memcpy (ins->inst_p1, ainfo, sizeof (ArgInfo));
MONO_ADD_INS (cfg->cbb, ins);
} else if (ainfo->regtype == RegTypeStructByVal) {
/* this is further handled in mono_arch_emit_outarg_vt () */
MONO_INST_NEW (cfg, ins, OP_OUTARG_VT);
ins->opcode = OP_OUTARG_VT;
ins->sreg1 = in->dreg;
ins->klass = in->klass;
ins->inst_p0 = call;
ins->inst_p1 = mono_mempool_alloc (cfg->mempool, sizeof (ArgInfo));
memcpy (ins->inst_p1, ainfo, sizeof (ArgInfo));
MONO_ADD_INS (cfg->cbb, ins);
} else if (ainfo->regtype == RegTypeFPStructByVal) {
/* this is further handled in mono_arch_emit_outarg_vt () */
MONO_INST_NEW (cfg, ins, OP_OUTARG_VT);
ins->opcode = OP_OUTARG_VT;
ins->sreg1 = in->dreg;
ins->klass = in->klass;
ins->inst_p0 = call;
ins->inst_p1 = mono_mempool_alloc (cfg->mempool, sizeof (ArgInfo));
memcpy (ins->inst_p1, ainfo, sizeof (ArgInfo));
MONO_ADD_INS (cfg->cbb, ins);
cfg->flags |= MONO_CFG_HAS_FPOUT;
} else if (ainfo->regtype == RegTypeBase) {
if (!t->byref && ((t->type == MONO_TYPE_I8) || (t->type == MONO_TYPE_U8))) {
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI8_MEMBASE_REG, ppc_r1, ainfo->offset, in->dreg);
} else if (!t->byref && ((t->type == MONO_TYPE_R4) || (t->type == MONO_TYPE_R8))) {
if (t->type == MONO_TYPE_R8)
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, ppc_r1, ainfo->offset, in->dreg);
else
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER4_MEMBASE_REG, ppc_r1, ainfo->offset, in->dreg);
} else {
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, ppc_r1, ainfo->offset, in->dreg);
}
} else if (ainfo->regtype == RegTypeFP) {
if (t->type == MONO_TYPE_VALUETYPE) {
/* this is further handled in mono_arch_emit_outarg_vt () */
MONO_INST_NEW (cfg, ins, OP_OUTARG_VT);
ins->opcode = OP_OUTARG_VT;
ins->sreg1 = in->dreg;
ins->klass = in->klass;
ins->inst_p0 = call;
ins->inst_p1 = mono_mempool_alloc (cfg->mempool, sizeof (ArgInfo));
memcpy (ins->inst_p1, ainfo, sizeof (ArgInfo));
MONO_ADD_INS (cfg->cbb, ins);
cfg->flags |= MONO_CFG_HAS_FPOUT;
} else {
int dreg = mono_alloc_freg (cfg);
if (ainfo->size == 4) {
MONO_EMIT_NEW_UNALU (cfg, OP_FCONV_TO_R4, dreg, in->dreg);
} else {
MONO_INST_NEW (cfg, ins, OP_FMOVE);
ins->dreg = dreg;
ins->sreg1 = in->dreg;
MONO_ADD_INS (cfg->cbb, ins);
}
mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg, TRUE);
cfg->flags |= MONO_CFG_HAS_FPOUT;
}
} else {
g_assert_not_reached ();
}
}
/* Emit the signature cookie in the case that there is no
additional argument */
if (!sig->pinvoke && (sig->call_convention == MONO_CALL_VARARG) && (n == sig->sentinelpos))
emit_sig_cookie (cfg, call, cinfo);
if (cinfo->struct_ret) {
MonoInst *vtarg;
MONO_INST_NEW (cfg, vtarg, OP_MOVE);
vtarg->sreg1 = call->vret_var->dreg;
vtarg->dreg = mono_alloc_preg (cfg);
MONO_ADD_INS (cfg->cbb, vtarg);
mono_call_inst_add_outarg_reg (cfg, call, vtarg->dreg, cinfo->struct_ret, FALSE);
}
call->stack_usage = cinfo->stack_usage;
cfg->param_area = MAX (PPC_MINIMAL_PARAM_AREA_SIZE, MAX (cfg->param_area, cinfo->stack_usage));
cfg->flags |= MONO_CFG_HAS_CALLS;
g_free (cinfo);
}
#ifndef DISABLE_JIT
void
mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src)
{
MonoCallInst *call = (MonoCallInst*)ins->inst_p0;
ArgInfo *ainfo = (ArgInfo*)ins->inst_p1;
int ovf_size = ainfo->vtsize;
int doffset = ainfo->offset;
int i, soffset, dreg;
if (ainfo->regtype == RegTypeStructByVal) {
#ifdef __APPLE__
guint32 size = 0;
#endif
soffset = 0;
#ifdef __APPLE__
/*
* Darwin pinvokes needs some special handling for 1
* and 2 byte arguments
*/
g_assert (ins->klass);
if (call->signature->pinvoke)
size = mono_class_native_size (ins->klass, NULL);
if (size == 2 || size == 1) {
int tmpr = mono_alloc_ireg (cfg);
if (size == 1)
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI1_MEMBASE, tmpr, src->dreg, soffset);
else
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI2_MEMBASE, tmpr, src->dreg, soffset);
dreg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, dreg, tmpr);
mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg, FALSE);
} else
#endif
for (i = 0; i < ainfo->vtregs; ++i) {
dreg = mono_alloc_ireg (cfg);
#if G_BYTE_ORDER == G_BIG_ENDIAN
int antipadding = 0;
if (ainfo->bytes) {
g_assert (i == 0);
antipadding = sizeof (target_mgreg_t) - ainfo->bytes;
}
MONO_EMIT_NEW_LOAD_MEMBASE (cfg, dreg, src->dreg, soffset);
if (antipadding)
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_UN_IMM, dreg, dreg, antipadding * 8);
#else
MONO_EMIT_NEW_LOAD_MEMBASE (cfg, dreg, src->dreg, soffset);
#endif
mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg + i, FALSE);
soffset += sizeof (target_mgreg_t);
}
if (ovf_size != 0)
mini_emit_memcpy (cfg, ppc_r1, doffset + soffset, src->dreg, soffset, ovf_size * sizeof (target_mgreg_t), TARGET_SIZEOF_VOID_P);
} else if (ainfo->regtype == RegTypeFPStructByVal) {
soffset = 0;
for (i = 0; i < ainfo->vtregs; ++i) {
int tmpr = mono_alloc_freg (cfg);
if (ainfo->size == 4)
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR4_MEMBASE, tmpr, src->dreg, soffset);
else // ==8
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR8_MEMBASE, tmpr, src->dreg, soffset);
dreg = mono_alloc_freg (cfg);
MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, dreg, tmpr);
mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg+i, TRUE);
soffset += ainfo->size;
}
if (ovf_size != 0)
mini_emit_memcpy (cfg, ppc_r1, doffset + soffset, src->dreg, soffset, ovf_size * sizeof (target_mgreg_t), TARGET_SIZEOF_VOID_P);
} else if (ainfo->regtype == RegTypeFP) {
int tmpr = mono_alloc_freg (cfg);
if (ainfo->size == 4)
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR4_MEMBASE, tmpr, src->dreg, 0);
else
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR8_MEMBASE, tmpr, src->dreg, 0);
dreg = mono_alloc_freg (cfg);
MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, dreg, tmpr);
mono_call_inst_add_outarg_reg (cfg, call, dreg, ainfo->reg, TRUE);
} else {
MonoInst *vtcopy = mono_compile_create_var (cfg, m_class_get_byval_arg (src->klass), OP_LOCAL);
MonoInst *load;
guint32 size;
/* FIXME: alignment? */
if (call->signature->pinvoke) {
size = mono_type_native_stack_size (m_class_get_byval_arg (src->klass), NULL);
vtcopy->backend.is_pinvoke = 1;
} else {
size = mini_type_stack_size (m_class_get_byval_arg (src->klass), NULL);
}
if (size > 0)
g_assert (ovf_size > 0);
EMIT_NEW_VARLOADA (cfg, load, vtcopy, vtcopy->inst_vtype);
mini_emit_memcpy (cfg, load->dreg, 0, src->dreg, 0, size, TARGET_SIZEOF_VOID_P);
if (ainfo->offset)
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, ppc_r1, ainfo->offset, load->dreg);
else
mono_call_inst_add_outarg_reg (cfg, call, load->dreg, ainfo->reg, FALSE);
}
}
void
mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val)
{
MonoType *ret = mini_get_underlying_type (mono_method_signature_internal (method)->ret);
if (!ret->byref) {
#ifndef __mono_ppc64__
if (ret->type == MONO_TYPE_I8 || ret->type == MONO_TYPE_U8) {
MonoInst *ins;
MONO_INST_NEW (cfg, ins, OP_SETLRET);
ins->sreg1 = MONO_LVREG_LS (val->dreg);
ins->sreg2 = MONO_LVREG_MS (val->dreg);
MONO_ADD_INS (cfg->cbb, ins);
return;
}
#endif
if (ret->type == MONO_TYPE_R8 || ret->type == MONO_TYPE_R4) {
MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, cfg->ret->dreg, val->dreg);
return;
}
}
MONO_EMIT_NEW_UNALU (cfg, OP_MOVE, cfg->ret->dreg, val->dreg);
}
gboolean
mono_arch_is_inst_imm (int opcode, int imm_opcode, gint64 imm)
{
return TRUE;
}
#endif /* DISABLE_JIT */
/*
* Conditional branches have a small offset, so if it is likely overflowed,
* we do a branch to the end of the method (uncond branches have much larger
* offsets) where we perform the conditional and jump back unconditionally.
* It's slightly slower, since we add two uncond branches, but it's very simple
* with the current patch implementation and such large methods are likely not
* going to be perf critical anyway.
*/
typedef struct {
union {
MonoBasicBlock *bb;
const char *exception;
} data;
guint32 ip_offset;
guint16 b0_cond;
guint16 b1_cond;
} MonoOvfJump;
#define EMIT_COND_BRANCH_FLAGS(ins,b0,b1) \
if (0 && ins->inst_true_bb->native_offset) { \
ppc_bc (code, (b0), (b1), (code - cfg->native_code + ins->inst_true_bb->native_offset) & 0xffff); \
} else { \
int br_disp = ins->inst_true_bb->max_offset - offset; \
if (!ppc_is_imm16 (br_disp + 8 * 1024) || !ppc_is_imm16 (br_disp - 8 * 1024)) { \
MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump)); \
ovfj->data.bb = ins->inst_true_bb; \
ovfj->ip_offset = 0; \
ovfj->b0_cond = (b0); \
ovfj->b1_cond = (b1); \
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB_OVF, ovfj); \
ppc_b (code, 0); \
} else { \
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_true_bb); \
ppc_bc (code, (b0), (b1), 0); \
} \
}
#define EMIT_COND_BRANCH(ins,cond) EMIT_COND_BRANCH_FLAGS(ins, branch_b0_table [(cond)], branch_b1_table [(cond)])
/* emit an exception if condition is fail
*
* We assign the extra code used to throw the implicit exceptions
* to cfg->bb_exit as far as the big branch handling is concerned
*/
#define EMIT_COND_SYSTEM_EXCEPTION_FLAGS(b0,b1,exc_name) \
do { \
int br_disp = cfg->bb_exit->max_offset - offset; \
if (!ppc_is_imm16 (br_disp + 1024) || ! ppc_is_imm16 (ppc_is_imm16 (br_disp - 1024))) { \
MonoOvfJump *ovfj = mono_mempool_alloc (cfg->mempool, sizeof (MonoOvfJump)); \
ovfj->data.exception = (exc_name); \
ovfj->ip_offset = code - cfg->native_code; \
ovfj->b0_cond = (b0); \
ovfj->b1_cond = (b1); \
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_EXC_OVF, ovfj); \
ppc_bl (code, 0); \
cfg->bb_exit->max_offset += 24; \
} else { \
mono_add_patch_info (cfg, code - cfg->native_code, \
MONO_PATCH_INFO_EXC, exc_name); \
ppc_bcl (code, (b0), (b1), 0); \
} \
} while (0);
#define EMIT_COND_SYSTEM_EXCEPTION(cond,exc_name) EMIT_COND_SYSTEM_EXCEPTION_FLAGS(branch_b0_table [(cond)], branch_b1_table [(cond)], (exc_name))
void
mono_arch_peephole_pass_1 (MonoCompile *cfg, MonoBasicBlock *bb)
{
}
static int
normalize_opcode (int opcode)
{
switch (opcode) {
#ifndef MONO_ARCH_ILP32
case MONO_PPC_32_64_CASE (OP_LOADI4_MEMBASE, OP_LOADI8_MEMBASE):
return OP_LOAD_MEMBASE;
case MONO_PPC_32_64_CASE (OP_LOADI4_MEMINDEX, OP_LOADI8_MEMINDEX):
return OP_LOAD_MEMINDEX;
case MONO_PPC_32_64_CASE (OP_STOREI4_MEMBASE_REG, OP_STOREI8_MEMBASE_REG):
return OP_STORE_MEMBASE_REG;
case MONO_PPC_32_64_CASE (OP_STOREI4_MEMBASE_IMM, OP_STOREI8_MEMBASE_IMM):
return OP_STORE_MEMBASE_IMM;
case MONO_PPC_32_64_CASE (OP_STOREI4_MEMINDEX, OP_STOREI8_MEMINDEX):
return OP_STORE_MEMINDEX;
#endif
case MONO_PPC_32_64_CASE (OP_ISHR_IMM, OP_LSHR_IMM):
return OP_SHR_IMM;
case MONO_PPC_32_64_CASE (OP_ISHR_UN_IMM, OP_LSHR_UN_IMM):
return OP_SHR_UN_IMM;
default:
return opcode;
}
}
void
mono_arch_peephole_pass_2 (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins, *n, *last_ins = NULL;
MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) {
switch (normalize_opcode (ins->opcode)) {
case OP_MUL_IMM:
/* remove unnecessary multiplication with 1 */
if (ins->inst_imm == 1) {
if (ins->dreg != ins->sreg1) {
ins->opcode = OP_MOVE;
} else {
MONO_DELETE_INS (bb, ins);
continue;
}
} else {
int power2 = mono_is_power_of_two (ins->inst_imm);
if (power2 > 0) {
ins->opcode = OP_SHL_IMM;
ins->inst_imm = power2;
}
}
break;
case OP_LOAD_MEMBASE:
/*
* OP_STORE_MEMBASE_REG reg, offset(basereg)
* OP_LOAD_MEMBASE offset(basereg), reg
*/
if (last_ins && normalize_opcode (last_ins->opcode) == OP_STORE_MEMBASE_REG &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
if (ins->dreg == last_ins->sreg1) {
MONO_DELETE_INS (bb, ins);
continue;
} else {
//static int c = 0; printf ("MATCHX %s %d\n", cfg->method->name,c++);
ins->opcode = OP_MOVE;
ins->sreg1 = last_ins->sreg1;
}
/*
* Note: reg1 must be different from the basereg in the second load
* OP_LOAD_MEMBASE offset(basereg), reg1
* OP_LOAD_MEMBASE offset(basereg), reg2
* -->
* OP_LOAD_MEMBASE offset(basereg), reg1
* OP_MOVE reg1, reg2
*/
} else if (last_ins && normalize_opcode (last_ins->opcode) == OP_LOAD_MEMBASE &&
ins->inst_basereg != last_ins->dreg &&
ins->inst_basereg == last_ins->inst_basereg &&
ins->inst_offset == last_ins->inst_offset) {
if (ins->dreg == last_ins->dreg) {
MONO_DELETE_INS (bb, ins);
continue;
} else {
ins->opcode = OP_MOVE;
ins->sreg1 = last_ins->dreg;
}
//g_assert_not_reached ();
#if 0
/*
* OP_STORE_MEMBASE_IMM imm, offset(basereg)
* OP_LOAD_MEMBASE offset(basereg), reg
* -->
* OP_STORE_MEMBASE_IMM imm, offset(basereg)
* OP_ICONST reg, imm
*/
} else if (last_ins && normalize_opcode (last_ins->opcode) == OP_STORE_MEMBASE_IMM &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
//static int c = 0; printf ("MATCHX %s %d\n", cfg->method->name,c++);
ins->opcode = OP_ICONST;
ins->inst_c0 = last_ins->inst_imm;
g_assert_not_reached (); // check this rule
#endif
}
break;
case OP_LOADU1_MEMBASE:
case OP_LOADI1_MEMBASE:
if (last_ins && (last_ins->opcode == OP_STOREI1_MEMBASE_REG) &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
ins->opcode = (ins->opcode == OP_LOADI1_MEMBASE) ? OP_ICONV_TO_I1 : OP_ICONV_TO_U1;
ins->sreg1 = last_ins->sreg1;
}
break;
case OP_LOADU2_MEMBASE:
case OP_LOADI2_MEMBASE:
if (last_ins && (last_ins->opcode == OP_STOREI2_MEMBASE_REG) &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
ins->opcode = (ins->opcode == OP_LOADI2_MEMBASE) ? OP_ICONV_TO_I2 : OP_ICONV_TO_U2;
ins->sreg1 = last_ins->sreg1;
}
break;
#ifdef __mono_ppc64__
case OP_LOADU4_MEMBASE:
case OP_LOADI4_MEMBASE:
if (last_ins && (last_ins->opcode == OP_STOREI4_MEMBASE_REG) &&
ins->inst_basereg == last_ins->inst_destbasereg &&
ins->inst_offset == last_ins->inst_offset) {
ins->opcode = (ins->opcode == OP_LOADI4_MEMBASE) ? OP_ICONV_TO_I4 : OP_ICONV_TO_U4;
ins->sreg1 = last_ins->sreg1;
}
break;
#endif
case OP_MOVE:
ins->opcode = OP_MOVE;
/*
* OP_MOVE reg, reg
*/
if (ins->dreg == ins->sreg1) {
MONO_DELETE_INS (bb, ins);
continue;
}
/*
* OP_MOVE sreg, dreg
* OP_MOVE dreg, sreg
*/
if (last_ins && last_ins->opcode == OP_MOVE &&
ins->sreg1 == last_ins->dreg &&
ins->dreg == last_ins->sreg1) {
MONO_DELETE_INS (bb, ins);
continue;
}
break;
}
last_ins = ins;
ins = ins->next;
}
bb->last_ins = last_ins;
}
void
mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins)
{
switch (ins->opcode) {
case OP_ICONV_TO_R_UN: {
// This value is OK as-is for both big and little endian because of how it is stored
static const guint64 adjust_val = 0x4330000000000000ULL;
int msw_reg = mono_alloc_ireg (cfg);
int adj_reg = mono_alloc_freg (cfg);
int tmp_reg = mono_alloc_freg (cfg);
int basereg = ppc_sp;
int offset = -8;
MONO_EMIT_NEW_ICONST (cfg, msw_reg, 0x43300000);
if (!ppc_is_imm16 (offset + 4)) {
basereg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IADD_IMM, basereg, cfg->frame_reg, offset);
}
#if G_BYTE_ORDER == G_BIG_ENDIAN
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset, msw_reg);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset + 4, ins->sreg1);
#else
// For little endian the words are reversed
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset + 4, msw_reg);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset, ins->sreg1);
#endif
MONO_EMIT_NEW_LOAD_R8 (cfg, adj_reg, &adjust_val);
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR8_MEMBASE, tmp_reg, basereg, offset);
MONO_EMIT_NEW_BIALU (cfg, OP_FSUB, ins->dreg, tmp_reg, adj_reg);
ins->opcode = OP_NOP;
break;
}
#ifndef __mono_ppc64__
case OP_ICONV_TO_R4:
case OP_ICONV_TO_R8: {
/* If we have a PPC_FEATURE_64 machine we can avoid
this and use the fcfid instruction. Otherwise
on an old 32-bit chip and we have to do this the
hard way. */
if (!(cpu_hw_caps & PPC_ISA_64)) {
/* FIXME: change precision for CEE_CONV_R4 */
static const guint64 adjust_val = 0x4330000080000000ULL;
int msw_reg = mono_alloc_ireg (cfg);
int xored = mono_alloc_ireg (cfg);
int adj_reg = mono_alloc_freg (cfg);
int tmp_reg = mono_alloc_freg (cfg);
int basereg = ppc_sp;
int offset = -8;
if (!ppc_is_imm16 (offset + 4)) {
basereg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IADD_IMM, basereg, cfg->frame_reg, offset);
}
MONO_EMIT_NEW_ICONST (cfg, msw_reg, 0x43300000);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset, msw_reg);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_XOR_IMM, xored, ins->sreg1, 0x80000000);
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STOREI4_MEMBASE_REG, basereg, offset + 4, xored);
MONO_EMIT_NEW_LOAD_R8 (cfg, adj_reg, (gpointer)&adjust_val);
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADR8_MEMBASE, tmp_reg, basereg, offset);
MONO_EMIT_NEW_BIALU (cfg, OP_FSUB, ins->dreg, tmp_reg, adj_reg);
if (ins->opcode == OP_ICONV_TO_R4)
MONO_EMIT_NEW_UNALU (cfg, OP_FCONV_TO_R4, ins->dreg, ins->dreg);
ins->opcode = OP_NOP;
}
break;
}
#endif
case OP_CKFINITE: {
int msw_reg = mono_alloc_ireg (cfg);
int basereg = ppc_sp;
int offset = -8;
if (!ppc_is_imm16 (offset + 4)) {
basereg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_IADD_IMM, basereg, cfg->frame_reg, offset);
}
MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORER8_MEMBASE_REG, basereg, offset, ins->sreg1);
#if G_BYTE_ORDER == G_BIG_ENDIAN
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, msw_reg, basereg, offset);
#else
MONO_EMIT_NEW_LOAD_MEMBASE_OP (cfg, OP_LOADI4_MEMBASE, msw_reg, basereg, offset+4);
#endif
MONO_EMIT_NEW_UNALU (cfg, OP_PPC_CHECK_FINITE, -1, msw_reg);
MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, ins->dreg, ins->sreg1);
ins->opcode = OP_NOP;
break;
}
#ifdef __mono_ppc64__
case OP_IADD_OVF:
case OP_IADD_OVF_UN:
case OP_ISUB_OVF: {
int shifted1_reg = mono_alloc_ireg (cfg);
int shifted2_reg = mono_alloc_ireg (cfg);
int result_shifted_reg = mono_alloc_ireg (cfg);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHL_IMM, shifted1_reg, ins->sreg1, 32);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHL_IMM, shifted2_reg, ins->sreg2, 32);
MONO_EMIT_NEW_BIALU (cfg, ins->opcode, result_shifted_reg, shifted1_reg, shifted2_reg);
if (ins->opcode == OP_IADD_OVF_UN)
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_UN_IMM, ins->dreg, result_shifted_reg, 32);
else
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_SHR_IMM, ins->dreg, result_shifted_reg, 32);
ins->opcode = OP_NOP;
break;
}
#endif
default:
break;
}
}
void
mono_arch_decompose_long_opts (MonoCompile *cfg, MonoInst *ins)
{
switch (ins->opcode) {
case OP_LADD_OVF:
/* ADC sets the condition code */
MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
NULLIFY_INS (ins);
break;
case OP_LADD_OVF_UN:
/* ADC sets the condition code */
MONO_EMIT_NEW_BIALU (cfg, OP_ADDCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
MONO_EMIT_NEW_BIALU (cfg, OP_ADD_OVF_UN_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
NULLIFY_INS (ins);
break;
case OP_LSUB_OVF:
/* SBB sets the condition code */
MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
NULLIFY_INS (ins);
break;
case OP_LSUB_OVF_UN:
/* SBB sets the condition code */
MONO_EMIT_NEW_BIALU (cfg, OP_SUBCC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), MONO_LVREG_LS (ins->sreg2));
MONO_EMIT_NEW_BIALU (cfg, OP_SUB_OVF_UN_CARRY, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1), MONO_LVREG_MS (ins->sreg2));
NULLIFY_INS (ins);
break;
case OP_LNEG:
/* From gcc generated code */
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_PPC_SUBFIC, MONO_LVREG_LS (ins->dreg), MONO_LVREG_LS (ins->sreg1), 0);
MONO_EMIT_NEW_UNALU (cfg, OP_PPC_SUBFZE, MONO_LVREG_MS (ins->dreg), MONO_LVREG_MS (ins->sreg1));
NULLIFY_INS (ins);
break;
default:
break;
}
}
/*
* the branch_b0_table should maintain the order of these
* opcodes.
case CEE_BEQ:
case CEE_BGE:
case CEE_BGT:
case CEE_BLE:
case CEE_BLT:
case CEE_BNE_UN:
case CEE_BGE_UN:
case CEE_BGT_UN:
case CEE_BLE_UN:
case CEE_BLT_UN:
*/
static const guchar
branch_b0_table [] = {
PPC_BR_TRUE,
PPC_BR_FALSE,
PPC_BR_TRUE,
PPC_BR_FALSE,
PPC_BR_TRUE,
PPC_BR_FALSE,
PPC_BR_FALSE,
PPC_BR_TRUE,
PPC_BR_FALSE,
PPC_BR_TRUE
};
static const guchar
branch_b1_table [] = {
PPC_BR_EQ,
PPC_BR_LT,
PPC_BR_GT,
PPC_BR_GT,
PPC_BR_LT,
PPC_BR_EQ,
PPC_BR_LT,
PPC_BR_GT,
PPC_BR_GT,
PPC_BR_LT
};
#define NEW_INS(cfg,dest,op) do { \
MONO_INST_NEW((cfg), (dest), (op)); \
mono_bblock_insert_after_ins (bb, last_ins, (dest)); \
} while (0)
static int
map_to_reg_reg_op (int op)
{
switch (op) {
case OP_ADD_IMM:
return OP_IADD;
case OP_SUB_IMM:
return OP_ISUB;
case OP_AND_IMM:
return OP_IAND;
case OP_COMPARE_IMM:
return OP_COMPARE;
case OP_ICOMPARE_IMM:
return OP_ICOMPARE;
case OP_LCOMPARE_IMM:
return OP_LCOMPARE;
case OP_ADDCC_IMM:
return OP_IADDCC;
case OP_ADC_IMM:
return OP_IADC;
case OP_SUBCC_IMM:
return OP_ISUBCC;
case OP_SBB_IMM:
return OP_ISBB;
case OP_OR_IMM:
return OP_IOR;
case OP_XOR_IMM:
return OP_IXOR;
case OP_MUL_IMM:
return OP_IMUL;
case OP_LMUL_IMM:
return OP_LMUL;
case OP_LOAD_MEMBASE:
return OP_LOAD_MEMINDEX;
case OP_LOADI4_MEMBASE:
return OP_LOADI4_MEMINDEX;
case OP_LOADU4_MEMBASE:
return OP_LOADU4_MEMINDEX;
case OP_LOADI8_MEMBASE:
return OP_LOADI8_MEMINDEX;
case OP_LOADU1_MEMBASE:
return OP_LOADU1_MEMINDEX;
case OP_LOADI2_MEMBASE:
return OP_LOADI2_MEMINDEX;
case OP_LOADU2_MEMBASE:
return OP_LOADU2_MEMINDEX;
case OP_LOADI1_MEMBASE:
return OP_LOADI1_MEMINDEX;
case OP_LOADR4_MEMBASE:
return OP_LOADR4_MEMINDEX;
case OP_LOADR8_MEMBASE:
return OP_LOADR8_MEMINDEX;
case OP_STOREI1_MEMBASE_REG:
return OP_STOREI1_MEMINDEX;
case OP_STOREI2_MEMBASE_REG:
return OP_STOREI2_MEMINDEX;
case OP_STOREI4_MEMBASE_REG:
return OP_STOREI4_MEMINDEX;
case OP_STOREI8_MEMBASE_REG:
return OP_STOREI8_MEMINDEX;
case OP_STORE_MEMBASE_REG:
return OP_STORE_MEMINDEX;
case OP_STORER4_MEMBASE_REG:
return OP_STORER4_MEMINDEX;
case OP_STORER8_MEMBASE_REG:
return OP_STORER8_MEMINDEX;
case OP_STORE_MEMBASE_IMM:
return OP_STORE_MEMBASE_REG;
case OP_STOREI1_MEMBASE_IMM:
return OP_STOREI1_MEMBASE_REG;
case OP_STOREI2_MEMBASE_IMM:
return OP_STOREI2_MEMBASE_REG;
case OP_STOREI4_MEMBASE_IMM:
return OP_STOREI4_MEMBASE_REG;
case OP_STOREI8_MEMBASE_IMM:
return OP_STOREI8_MEMBASE_REG;
}
if (mono_op_imm_to_op (op) == -1)
g_error ("mono_op_imm_to_op failed for %s\n", mono_inst_name (op));
return mono_op_imm_to_op (op);
}
//#define map_to_reg_reg_op(op) (cfg->new_ir? mono_op_imm_to_op (op): map_to_reg_reg_op (op))
#define compare_opcode_is_unsigned(opcode) \
(((opcode) >= CEE_BNE_UN && (opcode) <= CEE_BLT_UN) || \
((opcode) >= OP_IBNE_UN && (opcode) <= OP_IBLT_UN) || \
((opcode) >= OP_LBNE_UN && (opcode) <= OP_LBLT_UN) || \
((opcode) >= OP_COND_EXC_NE_UN && (opcode) <= OP_COND_EXC_LT_UN) || \
((opcode) >= OP_COND_EXC_INE_UN && (opcode) <= OP_COND_EXC_ILT_UN) || \
((opcode) == OP_CLT_UN || (opcode) == OP_CGT_UN || \
(opcode) == OP_ICLT_UN || (opcode) == OP_ICGT_UN || \
(opcode) == OP_LCLT_UN || (opcode) == OP_LCGT_UN))
/*
* Remove from the instruction list the instructions that can't be
* represented with very simple instructions with no register
* requirements.
*/
void
mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins, *next, *temp, *last_ins = NULL;
int imm;
MONO_BB_FOR_EACH_INS (bb, ins) {
loop_start:
switch (ins->opcode) {
case OP_IDIV_UN_IMM:
case OP_IDIV_IMM:
case OP_IREM_IMM:
case OP_IREM_UN_IMM:
CASE_PPC64 (OP_LREM_IMM) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
if (ins->opcode == OP_IDIV_IMM)
ins->opcode = OP_IDIV;
else if (ins->opcode == OP_IREM_IMM)
ins->opcode = OP_IREM;
else if (ins->opcode == OP_IDIV_UN_IMM)
ins->opcode = OP_IDIV_UN;
else if (ins->opcode == OP_IREM_UN_IMM)
ins->opcode = OP_IREM_UN;
else if (ins->opcode == OP_LREM_IMM)
ins->opcode = OP_LREM;
last_ins = temp;
/* handle rem separately */
goto loop_start;
}
case OP_IREM:
case OP_IREM_UN:
CASE_PPC64 (OP_LREM)
CASE_PPC64 (OP_LREM_UN) {
MonoInst *mul;
/* we change a rem dest, src1, src2 to
* div temp1, src1, src2
* mul temp2, temp1, src2
* sub dest, src1, temp2
*/
if (ins->opcode == OP_IREM || ins->opcode == OP_IREM_UN) {
NEW_INS (cfg, mul, OP_IMUL);
NEW_INS (cfg, temp, ins->opcode == OP_IREM? OP_IDIV: OP_IDIV_UN);
ins->opcode = OP_ISUB;
} else {
NEW_INS (cfg, mul, OP_LMUL);
NEW_INS (cfg, temp, ins->opcode == OP_LREM? OP_LDIV: OP_LDIV_UN);
ins->opcode = OP_LSUB;
}
temp->sreg1 = ins->sreg1;
temp->sreg2 = ins->sreg2;
temp->dreg = mono_alloc_ireg (cfg);
mul->sreg1 = temp->dreg;
mul->sreg2 = ins->sreg2;
mul->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = mul->dreg;
break;
}
case OP_IADD_IMM:
CASE_PPC64 (OP_LADD_IMM)
case OP_ADD_IMM:
case OP_ADDCC_IMM:
if (!ppc_is_imm16 (ins->inst_imm)) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
break;
case OP_ISUB_IMM:
CASE_PPC64 (OP_LSUB_IMM)
case OP_SUB_IMM:
if (!ppc_is_imm16 (-ins->inst_imm)) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
break;
case OP_IAND_IMM:
case OP_IOR_IMM:
case OP_IXOR_IMM:
case OP_LAND_IMM:
case OP_LOR_IMM:
case OP_LXOR_IMM:
case OP_AND_IMM:
case OP_OR_IMM:
case OP_XOR_IMM: {
gboolean is_imm = ((ins->inst_imm & 0xffff0000) && (ins->inst_imm & 0xffff));
#ifdef __mono_ppc64__
if (ins->inst_imm & 0xffffffff00000000ULL)
is_imm = TRUE;
#endif
if (is_imm) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
break;
}
case OP_ISBB_IMM:
case OP_IADC_IMM:
case OP_SBB_IMM:
case OP_SUBCC_IMM:
case OP_ADC_IMM:
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
break;
case OP_COMPARE_IMM:
case OP_ICOMPARE_IMM:
CASE_PPC64 (OP_LCOMPARE_IMM)
next = ins->next;
/* Branch opts can eliminate the branch */
if (!next || (!(MONO_IS_COND_BRANCH_OP (next) || MONO_IS_COND_EXC (next) || MONO_IS_SETCC (next)))) {
ins->opcode = OP_NOP;
break;
}
g_assert(next);
if (compare_opcode_is_unsigned (next->opcode)) {
if (!ppc_is_uimm16 (ins->inst_imm)) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
} else {
if (!ppc_is_imm16 (ins->inst_imm)) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
}
break;
case OP_IMUL_IMM:
case OP_MUL_IMM:
CASE_PPC64 (OP_LMUL_IMM)
if (ins->inst_imm == 1) {
ins->opcode = OP_MOVE;
break;
}
if (ins->inst_imm == 0) {
ins->opcode = OP_ICONST;
ins->inst_c0 = 0;
break;
}
imm = mono_is_power_of_two (ins->inst_imm);
if (imm > 0) {
ins->opcode = OP_SHL_IMM;
ins->inst_imm = imm;
break;
}
if (!ppc_is_imm16 (ins->inst_imm)) {
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
}
break;
case OP_LOCALLOC_IMM:
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = temp->dreg;
ins->opcode = OP_LOCALLOC;
break;
case OP_LOAD_MEMBASE:
case OP_LOADI4_MEMBASE:
CASE_PPC64 (OP_LOADI8_MEMBASE)
case OP_LOADU4_MEMBASE:
case OP_LOADI2_MEMBASE:
case OP_LOADU2_MEMBASE:
case OP_LOADI1_MEMBASE:
case OP_LOADU1_MEMBASE:
case OP_LOADR4_MEMBASE:
case OP_LOADR8_MEMBASE:
case OP_STORE_MEMBASE_REG:
CASE_PPC64 (OP_STOREI8_MEMBASE_REG)
case OP_STOREI4_MEMBASE_REG:
case OP_STOREI2_MEMBASE_REG:
case OP_STOREI1_MEMBASE_REG:
case OP_STORER4_MEMBASE_REG:
case OP_STORER8_MEMBASE_REG:
/* we can do two things: load the immed in a register
* and use an indexed load, or see if the immed can be
* represented as an ad_imm + a load with a smaller offset
* that fits. We just do the first for now, optimize later.
*/
if (ppc_is_imm16 (ins->inst_offset))
break;
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_offset;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg2 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
break;
case OP_STORE_MEMBASE_IMM:
case OP_STOREI1_MEMBASE_IMM:
case OP_STOREI2_MEMBASE_IMM:
case OP_STOREI4_MEMBASE_IMM:
CASE_PPC64 (OP_STOREI8_MEMBASE_IMM)
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = ins->inst_imm;
temp->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = temp->dreg;
ins->opcode = map_to_reg_reg_op (ins->opcode);
last_ins = temp;
goto loop_start; /* make it handle the possibly big ins->inst_offset */
case OP_R8CONST:
case OP_R4CONST:
if (cfg->compile_aot) {
/* Keep these in the aot case */
break;
}
NEW_INS (cfg, temp, OP_ICONST);
temp->inst_c0 = (gulong)ins->inst_p0;
temp->dreg = mono_alloc_ireg (cfg);
ins->inst_basereg = temp->dreg;
ins->inst_offset = 0;
ins->opcode = ins->opcode == OP_R4CONST? OP_LOADR4_MEMBASE: OP_LOADR8_MEMBASE;
last_ins = temp;
/* make it handle the possibly big ins->inst_offset
* later optimize to use lis + load_membase
*/
goto loop_start;
}
last_ins = ins;
}
bb->last_ins = last_ins;
bb->max_vreg = cfg->next_vreg;
}
static guchar*
emit_float_to_int (MonoCompile *cfg, guchar *code, int dreg, int sreg, int size, gboolean is_signed)
{
long offset = cfg->arch.fp_conv_var_offset;
long sub_offset;
/* sreg is a float, dreg is an integer reg. ppc_f0 is used a scratch */
#ifdef __mono_ppc64__
if (size == 8) {
ppc_fctidz (code, ppc_f0, sreg);
sub_offset = 0;
} else
#endif
{
ppc_fctiwz (code, ppc_f0, sreg);
sub_offset = 4;
}
if (ppc_is_imm16 (offset + sub_offset)) {
ppc_stfd (code, ppc_f0, offset, cfg->frame_reg);
if (size == 8)
ppc_ldr (code, dreg, offset + sub_offset, cfg->frame_reg);
else
ppc_lwz (code, dreg, offset + sub_offset, cfg->frame_reg);
} else {
ppc_load (code, dreg, offset);
ppc_add (code, dreg, dreg, cfg->frame_reg);
ppc_stfd (code, ppc_f0, 0, dreg);
if (size == 8)
ppc_ldr (code, dreg, sub_offset, dreg);
else
ppc_lwz (code, dreg, sub_offset, dreg);
}
if (!is_signed) {
if (size == 1)
ppc_andid (code, dreg, dreg, 0xff);
else if (size == 2)
ppc_andid (code, dreg, dreg, 0xffff);
#ifdef __mono_ppc64__
else if (size == 4)
ppc_clrldi (code, dreg, dreg, 32);
#endif
} else {
if (size == 1)
ppc_extsb (code, dreg, dreg);
else if (size == 2)
ppc_extsh (code, dreg, dreg);
#ifdef __mono_ppc64__
else if (size == 4)
ppc_extsw (code, dreg, dreg);
#endif
}
return code;
}
static void
emit_thunk (guint8 *code, gconstpointer target)
{
guint8 *p = code;
/* 2 bytes on 32bit, 5 bytes on 64bit */
ppc_load_sequence (code, ppc_r0, target);
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
mono_arch_flush_icache (p, code - p);
}
static void
handle_thunk (MonoCompile *cfg, guchar *code, const guchar *target)
{
MonoJitInfo *ji = NULL;
MonoThunkJitInfo *info;
guint8 *thunks, *p;
int thunks_size;
guint8 *orig_target;
guint8 *target_thunk;
if (cfg) {
/*
* This can be called multiple times during JITting,
* save the current position in cfg->arch to avoid
* doing a O(n^2) search.
*/
if (!cfg->arch.thunks) {
cfg->arch.thunks = cfg->thunks;
cfg->arch.thunks_size = cfg->thunk_area;
}
thunks = cfg->arch.thunks;
thunks_size = cfg->arch.thunks_size;
if (!thunks_size) {
g_print ("thunk failed %p->%p, thunk space=%d method %s", code, target, thunks_size, mono_method_full_name (cfg->method, TRUE));
g_assert_not_reached ();
}
g_assert (*(guint32*)thunks == 0);
emit_thunk (thunks, target);
ppc_patch (code, thunks);
cfg->arch.thunks += THUNK_SIZE;
cfg->arch.thunks_size -= THUNK_SIZE;
} else {
ji = mini_jit_info_table_find (code);
g_assert (ji);
info = mono_jit_info_get_thunk_info (ji);
g_assert (info);
thunks = (guint8 *) ji->code_start + info->thunks_offset;
thunks_size = info->thunks_size;
orig_target = mono_arch_get_call_target (code + 4);
mono_mini_arch_lock ();
target_thunk = NULL;
if (orig_target >= thunks && orig_target < thunks + thunks_size) {
/* The call already points to a thunk, because of trampolines etc. */
target_thunk = orig_target;
} else {
for (p = thunks; p < thunks + thunks_size; p += THUNK_SIZE) {
if (((guint32 *) p) [0] == 0) {
/* Free entry */
target_thunk = p;
break;
} else {
/* ppc64 requires 5 instructions, 32bit two instructions */
#ifdef __mono_ppc64__
const int const_load_size = 5;
#else
const int const_load_size = 2;
#endif
guint32 load [const_load_size];
guchar *templ = (guchar *) load;
ppc_load_sequence (templ, ppc_r0, target);
if (!memcmp (p, load, const_load_size)) {
/* Thunk already points to target */
target_thunk = p;
break;
}
}
}
}
// g_print ("THUNK: %p %p %p\n", code, target, target_thunk);
if (!target_thunk) {
mono_mini_arch_unlock ();
g_print ("thunk failed %p->%p, thunk space=%d method %s", code, target, thunks_size, cfg ? mono_method_full_name (cfg->method, TRUE) : mono_method_full_name (jinfo_get_method (ji), TRUE));
g_assert_not_reached ();
}
emit_thunk (target_thunk, target);
ppc_patch (code, target_thunk);
mono_mini_arch_unlock ();
}
}
static void
patch_ins (guint8 *code, guint32 ins)
{
*(guint32*)code = ins;
mono_arch_flush_icache (code, 4);
}
static void
ppc_patch_full (MonoCompile *cfg, guchar *code, const guchar *target, gboolean is_fd)
{
guint32 ins = *(guint32*)code;
guint32 prim = ins >> 26;
guint32 ovf;
//g_print ("patching 0x%08x (0x%08x) to point to 0x%08x\n", code, ins, target);
if (prim == 18) {
// prefer relative branches, they are more position independent (e.g. for AOT compilation).
gint diff = target - code;
g_assert (!is_fd);
if (diff >= 0){
if (diff <= 33554431){
ins = (18 << 26) | (diff) | (ins & 1);
patch_ins (code, ins);
return;
}
} else {
/* diff between 0 and -33554432 */
if (diff >= -33554432){
ins = (18 << 26) | (diff & ~0xfc000000) | (ins & 1);
patch_ins (code, ins);
return;
}
}
if ((glong)target >= 0){
if ((glong)target <= 33554431){
ins = (18 << 26) | ((gulong) target) | (ins & 1) | 2;
patch_ins (code, ins);
return;
}
} else {
if ((glong)target >= -33554432){
ins = (18 << 26) | (((gulong)target) & ~0xfc000000) | (ins & 1) | 2;
patch_ins (code, ins);
return;
}
}
handle_thunk (cfg, code, target);
return;
g_assert_not_reached ();
}
if (prim == 16) {
g_assert (!is_fd);
// absolute address
if (ins & 2) {
guint32 li = (gulong)target;
ins = (ins & 0xffff0000) | (ins & 3);
ovf = li & 0xffff0000;
if (ovf != 0 && ovf != 0xffff0000)
g_assert_not_reached ();
li &= 0xffff;
ins |= li;
// FIXME: assert the top bits of li are 0
} else {
gint diff = target - code;
ins = (ins & 0xffff0000) | (ins & 3);
ovf = diff & 0xffff0000;
if (ovf != 0 && ovf != 0xffff0000)
g_assert_not_reached ();
diff &= 0xffff;
ins |= diff;
}
patch_ins (code, ins);
return;
}
if (prim == 15 || ins == 0x4e800021 || ins == 0x4e800020 || ins == 0x4e800420) {
#ifdef __mono_ppc64__
guint32 *seq = (guint32*)code;
guint32 *branch_ins;
/* the trampoline code will try to patch the blrl, blr, bcctr */
if (ins == 0x4e800021 || ins == 0x4e800020 || ins == 0x4e800420) {
branch_ins = seq;
if (ppc_is_load_op (seq [-3]) || ppc_opcode (seq [-3]) == 31) /* ld || lwz || mr */
code -= 32;
else
code -= 24;
} else {
if (ppc_is_load_op (seq [5])
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
/* With function descs we need to do more careful
matches. */
|| ppc_opcode (seq [5]) == 31 /* ld || lwz || mr */
#endif
)
branch_ins = seq + 8;
else
branch_ins = seq + 6;
}
seq = (guint32*)code;
/* this is the lis/ori/sldi/oris/ori/(ld/ld|mr/nop)/mtlr/blrl sequence */
g_assert (mono_ppc_is_direct_call_sequence (branch_ins));
if (ppc_is_load_op (seq [5])) {
g_assert (ppc_is_load_op (seq [6]));
if (!is_fd) {
guint8 *buf = (guint8*)&seq [5];
ppc_mr (buf, PPC_CALL_REG, ppc_r12);
ppc_nop (buf);
}
} else {
if (is_fd)
target = (const guchar*)mono_get_addr_from_ftnptr ((gpointer)target);
}
/* FIXME: make this thread safe */
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
/* FIXME: we're assuming we're using r12 here */
ppc_load_ptr_sequence (code, ppc_r12, target);
#else
ppc_load_ptr_sequence (code, PPC_CALL_REG, target);
#endif
mono_arch_flush_icache ((guint8*)seq, 28);
#else
guint32 *seq;
/* the trampoline code will try to patch the blrl, blr, bcctr */
if (ins == 0x4e800021 || ins == 0x4e800020 || ins == 0x4e800420) {
code -= 12;
}
/* this is the lis/ori/mtlr/blrl sequence */
seq = (guint32*)code;
g_assert ((seq [0] >> 26) == 15);
g_assert ((seq [1] >> 26) == 24);
g_assert ((seq [2] >> 26) == 31);
g_assert (seq [3] == 0x4e800021 || seq [3] == 0x4e800020 || seq [3] == 0x4e800420);
/* FIXME: make this thread safe */
ppc_lis (code, PPC_CALL_REG, (guint32)(target) >> 16);
ppc_ori (code, PPC_CALL_REG, PPC_CALL_REG, (guint32)(target) & 0xffff);
mono_arch_flush_icache (code - 8, 8);
#endif
} else {
g_assert_not_reached ();
}
// g_print ("patched with 0x%08x\n", ins);
}
void
ppc_patch (guchar *code, const guchar *target)
{
ppc_patch_full (NULL, code, target, FALSE);
}
void
mono_ppc_patch (guchar *code, const guchar *target)
{
ppc_patch (code, target);
}
static guint8*
emit_move_return_value (MonoCompile *cfg, MonoInst *ins, guint8 *code)
{
switch (ins->opcode) {
case OP_FCALL:
case OP_FCALL_REG:
case OP_FCALL_MEMBASE:
if (ins->dreg != ppc_f1)
ppc_fmr (code, ins->dreg, ppc_f1);
break;
}
return code;
}
static guint8*
emit_reserve_param_area (MonoCompile *cfg, guint8 *code)
{
long size = cfg->param_area;
size += MONO_ARCH_FRAME_ALIGNMENT - 1;
size &= -MONO_ARCH_FRAME_ALIGNMENT;
if (!size)
return code;
ppc_ldptr (code, ppc_r0, 0, ppc_sp);
if (ppc_is_imm16 (-size)) {
ppc_stptr_update (code, ppc_r0, -size, ppc_sp);
} else {
ppc_load (code, ppc_r12, -size);
ppc_stptr_update_indexed (code, ppc_r0, ppc_sp, ppc_r12);
}
return code;
}
static guint8*
emit_unreserve_param_area (MonoCompile *cfg, guint8 *code)
{
long size = cfg->param_area;
size += MONO_ARCH_FRAME_ALIGNMENT - 1;
size &= -MONO_ARCH_FRAME_ALIGNMENT;
if (!size)
return code;
ppc_ldptr (code, ppc_r0, 0, ppc_sp);
if (ppc_is_imm16 (size)) {
ppc_stptr_update (code, ppc_r0, size, ppc_sp);
} else {
ppc_load (code, ppc_r12, size);
ppc_stptr_update_indexed (code, ppc_r0, ppc_sp, ppc_r12);
}
return code;
}
#define MASK_SHIFT_IMM(i) ((i) & MONO_PPC_32_64_CASE (0x1f, 0x3f))
#ifndef DISABLE_JIT
void
mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
{
MonoInst *ins, *next;
MonoCallInst *call;
guint8 *code = cfg->native_code + cfg->code_len;
MonoInst *last_ins = NULL;
int max_len, cpos;
int L;
/* we don't align basic blocks of loops on ppc */
if (cfg->verbose_level > 2)
g_print ("Basic block %d starting at offset 0x%x\n", bb->block_num, bb->native_offset);
cpos = bb->max_offset;
MONO_BB_FOR_EACH_INS (bb, ins) {
const guint offset = code - cfg->native_code;
set_code_cursor (cfg, code);
max_len = ins_get_size (ins->opcode);
code = realloc_code (cfg, max_len);
// if (ins->cil_code)
// g_print ("cil code\n");
mono_debug_record_line_number (cfg, ins, offset);
switch (normalize_opcode (ins->opcode)) {
case OP_RELAXED_NOP:
case OP_NOP:
case OP_DUMMY_USE:
case OP_DUMMY_ICONST:
case OP_DUMMY_I8CONST:
case OP_DUMMY_R8CONST:
case OP_DUMMY_R4CONST:
case OP_NOT_REACHED:
case OP_NOT_NULL:
break;
case OP_IL_SEQ_POINT:
mono_add_seq_point (cfg, bb, ins, code - cfg->native_code);
break;
case OP_SEQ_POINT: {
int i;
if (cfg->compile_aot)
NOT_IMPLEMENTED;
/*
* Read from the single stepping trigger page. This will cause a
* SIGSEGV when single stepping is enabled.
* We do this _before_ the breakpoint, so single stepping after
* a breakpoint is hit will step to the next IL offset.
*/
if (ins->flags & MONO_INST_SINGLE_STEP_LOC) {
ppc_load (code, ppc_r12, (gsize)ss_trigger_page);
ppc_ldptr (code, ppc_r12, 0, ppc_r12);
}
mono_add_seq_point (cfg, bb, ins, code - cfg->native_code);
/*
* A placeholder for a possible breakpoint inserted by
* mono_arch_set_breakpoint ().
*/
for (i = 0; i < BREAKPOINT_SIZE / 4; ++i)
ppc_nop (code);
break;
}
case OP_BIGMUL:
ppc_mullw (code, ppc_r0, ins->sreg1, ins->sreg2);
ppc_mulhw (code, ppc_r3, ins->sreg1, ins->sreg2);
ppc_mr (code, ppc_r4, ppc_r0);
break;
case OP_BIGMUL_UN:
ppc_mullw (code, ppc_r0, ins->sreg1, ins->sreg2);
ppc_mulhwu (code, ppc_r3, ins->sreg1, ins->sreg2);
ppc_mr (code, ppc_r4, ppc_r0);
break;
case OP_MEMORY_BARRIER:
ppc_sync (code);
break;
case OP_STOREI1_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_stb (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_stb (code, ins->sreg1, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_stbx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_STOREI2_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_sth (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_sth (code, ins->sreg1, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_sthx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_STORE_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_stptr (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_stptr (code, ins->sreg1, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_stptr_indexed (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
}
break;
#ifdef MONO_ARCH_ILP32
case OP_STOREI8_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_str (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_str_indexed (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
break;
#endif
case OP_STOREI1_MEMINDEX:
ppc_stbx (code, ins->sreg1, ins->inst_destbasereg, ins->sreg2);
break;
case OP_STOREI2_MEMINDEX:
ppc_sthx (code, ins->sreg1, ins->inst_destbasereg, ins->sreg2);
break;
case OP_STORE_MEMINDEX:
ppc_stptr_indexed (code, ins->sreg1, ins->inst_destbasereg, ins->sreg2);
break;
case OP_LOADU4_MEM:
g_assert_not_reached ();
break;
case OP_LOAD_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_ldptr (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_ldptr (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_ldptr_indexed (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
break;
case OP_LOADI4_MEMBASE:
#ifdef __mono_ppc64__
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lwa (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_lwa (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lwax (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
break;
#endif
case OP_LOADU4_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lwz (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_lwz (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lwzx (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
break;
case OP_LOADI1_MEMBASE:
case OP_LOADU1_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lbz (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_lbz (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lbzx (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
if (ins->opcode == OP_LOADI1_MEMBASE)
ppc_extsb (code, ins->dreg, ins->dreg);
break;
case OP_LOADU2_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lhz (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_lhz (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lhzx (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
break;
case OP_LOADI2_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lha (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset) && (ins->dreg > 0)) {
ppc_addis (code, ins->dreg, ins->inst_basereg, ppc_ha(ins->inst_offset));
ppc_lha (code, ins->dreg, ins->inst_offset, ins->dreg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lhax (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
}
break;
#ifdef MONO_ARCH_ILP32
case OP_LOADI8_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_ldr (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_ldr_indexed (code, ins->dreg, ins->inst_basereg, ppc_r0);
}
break;
#endif
case OP_LOAD_MEMINDEX:
ppc_ldptr_indexed (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADI4_MEMINDEX:
#ifdef __mono_ppc64__
ppc_lwax (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
#endif
case OP_LOADU4_MEMINDEX:
ppc_lwzx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADU2_MEMINDEX:
ppc_lhzx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADI2_MEMINDEX:
ppc_lhax (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADU1_MEMINDEX:
ppc_lbzx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADI1_MEMINDEX:
ppc_lbzx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
ppc_extsb (code, ins->dreg, ins->dreg);
break;
case OP_ICONV_TO_I1:
CASE_PPC64 (OP_LCONV_TO_I1)
ppc_extsb (code, ins->dreg, ins->sreg1);
break;
case OP_ICONV_TO_I2:
CASE_PPC64 (OP_LCONV_TO_I2)
ppc_extsh (code, ins->dreg, ins->sreg1);
break;
case OP_ICONV_TO_U1:
CASE_PPC64 (OP_LCONV_TO_U1)
ppc_clrlwi (code, ins->dreg, ins->sreg1, 24);
break;
case OP_ICONV_TO_U2:
CASE_PPC64 (OP_LCONV_TO_U2)
ppc_clrlwi (code, ins->dreg, ins->sreg1, 16);
break;
case OP_COMPARE:
case OP_ICOMPARE:
CASE_PPC64 (OP_LCOMPARE)
L = (sizeof (target_mgreg_t) == 4 || ins->opcode == OP_ICOMPARE) ? 0 : 1;
next = ins->next;
if (next && compare_opcode_is_unsigned (next->opcode))
ppc_cmpl (code, 0, L, ins->sreg1, ins->sreg2);
else
ppc_cmp (code, 0, L, ins->sreg1, ins->sreg2);
break;
case OP_COMPARE_IMM:
case OP_ICOMPARE_IMM:
CASE_PPC64 (OP_LCOMPARE_IMM)
L = (sizeof (target_mgreg_t) == 4 || ins->opcode == OP_ICOMPARE_IMM) ? 0 : 1;
next = ins->next;
if (next && compare_opcode_is_unsigned (next->opcode)) {
if (ppc_is_uimm16 (ins->inst_imm)) {
ppc_cmpli (code, 0, L, ins->sreg1, (ins->inst_imm & 0xffff));
} else {
g_assert_not_reached ();
}
} else {
if (ppc_is_imm16 (ins->inst_imm)) {
ppc_cmpi (code, 0, L, ins->sreg1, (ins->inst_imm & 0xffff));
} else {
g_assert_not_reached ();
}
}
break;
case OP_BREAK:
/*
* gdb does not like encountering a trap in the debugged code. So
* instead of emitting a trap, we emit a call a C function and place a
* breakpoint there.
*/
//ppc_break (code);
ppc_mr (code, ppc_r3, ins->sreg1);
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_break));
if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtlr (code, PPC_CALL_REG);
ppc_blrl (code);
} else {
ppc_bl (code, 0);
}
break;
case OP_ADDCC:
case OP_IADDCC:
ppc_addco (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IADD:
CASE_PPC64 (OP_LADD)
ppc_add (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_ADC:
case OP_IADC:
ppc_adde (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_ADDCC_IMM:
if (ppc_is_imm16 (ins->inst_imm)) {
ppc_addic (code, ins->dreg, ins->sreg1, ins->inst_imm);
} else {
g_assert_not_reached ();
}
break;
case OP_ADD_IMM:
case OP_IADD_IMM:
CASE_PPC64 (OP_LADD_IMM)
if (ppc_is_imm16 (ins->inst_imm)) {
ppc_addi (code, ins->dreg, ins->sreg1, ins->inst_imm);
} else {
g_assert_not_reached ();
}
break;
case OP_IADD_OVF:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_addo (code, ins->dreg, ins->sreg1, ins->sreg2);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_IADD_OVF_UN:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_addco (code, ins->dreg, ins->sreg1, ins->sreg2);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<13));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_ISUB_OVF:
CASE_PPC64 (OP_LSUB_OVF)
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_subfo (code, ins->dreg, ins->sreg2, ins->sreg1);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_ISUB_OVF_UN:
CASE_PPC64 (OP_LSUB_OVF_UN)
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_subfc (code, ins->dreg, ins->sreg2, ins->sreg1);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<13));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_TRUE, PPC_BR_EQ, "OverflowException");
break;
case OP_ADD_OVF_CARRY:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_addeo (code, ins->dreg, ins->sreg1, ins->sreg2);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_ADD_OVF_UN_CARRY:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_addeo (code, ins->dreg, ins->sreg1, ins->sreg2);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<13));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_SUB_OVF_CARRY:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_subfeo (code, ins->dreg, ins->sreg2, ins->sreg1);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_SUB_OVF_UN_CARRY:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_subfeo (code, ins->dreg, ins->sreg2, ins->sreg1);
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<13));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_TRUE, PPC_BR_EQ, "OverflowException");
break;
case OP_SUBCC:
case OP_ISUBCC:
ppc_subfco (code, ins->dreg, ins->sreg2, ins->sreg1);
break;
case OP_ISUB:
CASE_PPC64 (OP_LSUB)
ppc_subf (code, ins->dreg, ins->sreg2, ins->sreg1);
break;
case OP_SBB:
case OP_ISBB:
ppc_subfe (code, ins->dreg, ins->sreg2, ins->sreg1);
break;
case OP_SUB_IMM:
case OP_ISUB_IMM:
CASE_PPC64 (OP_LSUB_IMM)
// we add the negated value
if (ppc_is_imm16 (-ins->inst_imm))
ppc_addi (code, ins->dreg, ins->sreg1, -ins->inst_imm);
else {
g_assert_not_reached ();
}
break;
case OP_PPC_SUBFIC:
g_assert (ppc_is_imm16 (ins->inst_imm));
ppc_subfic (code, ins->dreg, ins->sreg1, ins->inst_imm);
break;
case OP_PPC_SUBFZE:
ppc_subfze (code, ins->dreg, ins->sreg1);
break;
case OP_IAND:
CASE_PPC64 (OP_LAND)
/* FIXME: the ppc macros as inconsistent here: put dest as the first arg! */
ppc_and (code, ins->sreg1, ins->dreg, ins->sreg2);
break;
case OP_AND_IMM:
case OP_IAND_IMM:
CASE_PPC64 (OP_LAND_IMM)
if (!(ins->inst_imm & 0xffff0000)) {
ppc_andid (code, ins->sreg1, ins->dreg, ins->inst_imm);
} else if (!(ins->inst_imm & 0xffff)) {
ppc_andisd (code, ins->sreg1, ins->dreg, ((guint32)ins->inst_imm >> 16));
} else {
g_assert_not_reached ();
}
break;
case OP_IDIV:
CASE_PPC64 (OP_LDIV) {
guint8 *divisor_is_m1;
/* XER format: SO, OV, CA, reserved [21 bits], count [8 bits]
*/
ppc_compare_reg_imm (code, 0, ins->sreg2, -1);
divisor_is_m1 = code;
ppc_bc (code, PPC_BR_FALSE | PPC_BR_LIKELY, PPC_BR_EQ, 0);
ppc_lis (code, ppc_r0, 0x8000);
#ifdef __mono_ppc64__
if (ins->opcode == OP_LDIV)
ppc_sldi (code, ppc_r0, ppc_r0, 32);
#endif
ppc_compare (code, 0, ins->sreg1, ppc_r0);
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_TRUE, PPC_BR_EQ, "OverflowException");
ppc_patch (divisor_is_m1, code);
/* XER format: SO, OV, CA, reserved [21 bits], count [8 bits]
*/
if (ins->opcode == OP_IDIV)
ppc_divwod (code, ins->dreg, ins->sreg1, ins->sreg2);
#ifdef __mono_ppc64__
else
ppc_divdod (code, ins->dreg, ins->sreg1, ins->sreg2);
#endif
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "DivideByZeroException");
break;
}
case OP_IDIV_UN:
CASE_PPC64 (OP_LDIV_UN)
if (ins->opcode == OP_IDIV_UN)
ppc_divwuod (code, ins->dreg, ins->sreg1, ins->sreg2);
#ifdef __mono_ppc64__
else
ppc_divduod (code, ins->dreg, ins->sreg1, ins->sreg2);
#endif
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "DivideByZeroException");
break;
case OP_DIV_IMM:
case OP_IREM:
case OP_IREM_UN:
case OP_REM_IMM:
g_assert_not_reached ();
case OP_IOR:
CASE_PPC64 (OP_LOR)
ppc_or (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_OR_IMM:
case OP_IOR_IMM:
CASE_PPC64 (OP_LOR_IMM)
if (!(ins->inst_imm & 0xffff0000)) {
ppc_ori (code, ins->sreg1, ins->dreg, ins->inst_imm);
} else if (!(ins->inst_imm & 0xffff)) {
ppc_oris (code, ins->dreg, ins->sreg1, ((guint32)(ins->inst_imm) >> 16));
} else {
g_assert_not_reached ();
}
break;
case OP_IXOR:
CASE_PPC64 (OP_LXOR)
ppc_xor (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IXOR_IMM:
case OP_XOR_IMM:
CASE_PPC64 (OP_LXOR_IMM)
if (!(ins->inst_imm & 0xffff0000)) {
ppc_xori (code, ins->sreg1, ins->dreg, ins->inst_imm);
} else if (!(ins->inst_imm & 0xffff)) {
ppc_xoris (code, ins->sreg1, ins->dreg, ((guint32)(ins->inst_imm) >> 16));
} else {
g_assert_not_reached ();
}
break;
case OP_ISHL:
CASE_PPC64 (OP_LSHL)
ppc_shift_left (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_SHL_IMM:
case OP_ISHL_IMM:
CASE_PPC64 (OP_LSHL_IMM)
ppc_shift_left_imm (code, ins->dreg, ins->sreg1, MASK_SHIFT_IMM (ins->inst_imm));
break;
case OP_ISHR:
ppc_sraw (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_SHR_IMM:
ppc_shift_right_arith_imm (code, ins->dreg, ins->sreg1, MASK_SHIFT_IMM (ins->inst_imm));
break;
case OP_SHR_UN_IMM:
if (MASK_SHIFT_IMM (ins->inst_imm))
ppc_shift_right_imm (code, ins->dreg, ins->sreg1, MASK_SHIFT_IMM (ins->inst_imm));
else
ppc_mr (code, ins->dreg, ins->sreg1);
break;
case OP_ISHR_UN:
ppc_srw (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_INOT:
CASE_PPC64 (OP_LNOT)
ppc_not (code, ins->dreg, ins->sreg1);
break;
case OP_INEG:
CASE_PPC64 (OP_LNEG)
ppc_neg (code, ins->dreg, ins->sreg1);
break;
case OP_IMUL:
CASE_PPC64 (OP_LMUL)
ppc_multiply (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IMUL_IMM:
case OP_MUL_IMM:
CASE_PPC64 (OP_LMUL_IMM)
if (ppc_is_imm16 (ins->inst_imm)) {
ppc_mulli (code, ins->dreg, ins->sreg1, ins->inst_imm);
} else {
g_assert_not_reached ();
}
break;
case OP_IMUL_OVF:
CASE_PPC64 (OP_LMUL_OVF)
/* we annot use mcrxr, since it's not implemented on some processors
* XER format: SO, OV, CA, reserved [21 bits], count [8 bits]
*/
if (ins->opcode == OP_IMUL_OVF)
ppc_mullwo (code, ins->dreg, ins->sreg1, ins->sreg2);
#ifdef __mono_ppc64__
else
ppc_mulldo (code, ins->dreg, ins->sreg1, ins->sreg2);
#endif
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1<<14));
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, "OverflowException");
break;
case OP_IMUL_OVF_UN:
CASE_PPC64 (OP_LMUL_OVF_UN)
/* we first multiply to get the high word and compare to 0
* to set the flags, then the result is discarded and then
* we multiply to get the lower * bits result
*/
if (ins->opcode == OP_IMUL_OVF_UN)
ppc_mulhwu (code, ppc_r0, ins->sreg1, ins->sreg2);
#ifdef __mono_ppc64__
else
ppc_mulhdu (code, ppc_r0, ins->sreg1, ins->sreg2);
#endif
ppc_cmpi (code, 0, 0, ppc_r0, 0);
EMIT_COND_SYSTEM_EXCEPTION (CEE_BNE_UN - CEE_BEQ, "OverflowException");
ppc_multiply (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_ICONST:
ppc_load (code, ins->dreg, ins->inst_c0);
break;
case OP_I8CONST: {
ppc_load (code, ins->dreg, ins->inst_l);
break;
}
case OP_LOAD_GOTADDR:
/* The PLT implementation depends on this */
g_assert (ins->dreg == ppc_r30);
code = mono_arch_emit_load_got_addr (cfg->native_code, code, cfg, NULL);
break;
case OP_GOT_ENTRY:
// FIXME: Fix max instruction length
/* XXX: This is hairy; we're casting a pointer from a union to an enum... */
mono_add_patch_info (cfg, offset, (MonoJumpInfoType)(intptr_t)ins->inst_right->inst_i1, ins->inst_right->inst_p0);
/* arch_emit_got_access () patches this */
ppc_load32 (code, ppc_r0, 0);
ppc_ldptr_indexed (code, ins->dreg, ins->inst_basereg, ppc_r0);
break;
case OP_AOTCONST:
mono_add_patch_info (cfg, offset, (MonoJumpInfoType)(intptr_t)ins->inst_i1, ins->inst_p0);
ppc_load_sequence (code, ins->dreg, 0);
break;
CASE_PPC32 (OP_ICONV_TO_I4)
CASE_PPC32 (OP_ICONV_TO_U4)
case OP_MOVE:
if (ins->dreg != ins->sreg1)
ppc_mr (code, ins->dreg, ins->sreg1);
break;
case OP_SETLRET: {
int saved = ins->sreg1;
if (ins->sreg1 == ppc_r3) {
ppc_mr (code, ppc_r0, ins->sreg1);
saved = ppc_r0;
}
if (ins->sreg2 != ppc_r3)
ppc_mr (code, ppc_r3, ins->sreg2);
if (saved != ppc_r4)
ppc_mr (code, ppc_r4, saved);
break;
}
case OP_FMOVE:
if (ins->dreg != ins->sreg1)
ppc_fmr (code, ins->dreg, ins->sreg1);
break;
case OP_MOVE_F_TO_I4:
ppc_stfs (code, ins->sreg1, -4, ppc_r1);
ppc_ldptr (code, ins->dreg, -4, ppc_r1);
break;
case OP_MOVE_I4_TO_F:
ppc_stw (code, ins->sreg1, -4, ppc_r1);
ppc_lfs (code, ins->dreg, -4, ppc_r1);
break;
#ifdef __mono_ppc64__
case OP_MOVE_F_TO_I8:
ppc_stfd (code, ins->sreg1, -8, ppc_r1);
ppc_ldptr (code, ins->dreg, -8, ppc_r1);
break;
case OP_MOVE_I8_TO_F:
ppc_stptr (code, ins->sreg1, -8, ppc_r1);
ppc_lfd (code, ins->dreg, -8, ppc_r1);
break;
#endif
case OP_FCONV_TO_R4:
ppc_frsp (code, ins->dreg, ins->sreg1);
break;
case OP_TAILCALL_PARAMETER:
// This opcode helps compute sizes, i.e.
// of the subsequent OP_TAILCALL, but contributes no code.
g_assert (ins->next);
break;
case OP_TAILCALL: {
int i, pos;
MonoCallInst *call = (MonoCallInst*)ins;
/*
* Keep in sync with mono_arch_emit_epilog
*/
g_assert (!cfg->method->save_lmf);
/*
* Note: we can use ppc_r12 here because it is dead anyway:
* we're leaving the method.
*/
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
long ret_offset = cfg->stack_usage + PPC_RET_ADDR_OFFSET;
if (ppc_is_imm16 (ret_offset)) {
ppc_ldptr (code, ppc_r0, ret_offset, cfg->frame_reg);
} else {
ppc_load (code, ppc_r12, ret_offset);
ppc_ldptr_indexed (code, ppc_r0, cfg->frame_reg, ppc_r12);
}
ppc_mtlr (code, ppc_r0);
}
if (ppc_is_imm16 (cfg->stack_usage)) {
ppc_addi (code, ppc_r12, cfg->frame_reg, cfg->stack_usage);
} else {
/* cfg->stack_usage is an int, so we can use
* an addis/addi sequence here even in 64-bit. */
ppc_addis (code, ppc_r12, cfg->frame_reg, ppc_ha(cfg->stack_usage));
ppc_addi (code, ppc_r12, ppc_r12, cfg->stack_usage);
}
if (!cfg->method->save_lmf) {
pos = 0;
for (i = 31; i >= 13; --i) {
if (cfg->used_int_regs & (1 << i)) {
pos += sizeof (target_mgreg_t);
ppc_ldptr (code, i, -pos, ppc_r12);
}
}
} else {
/* FIXME restore from MonoLMF: though this can't happen yet */
}
/* Copy arguments on the stack to our argument area */
if (call->stack_usage) {
code = emit_memcpy (code, call->stack_usage, ppc_r12, PPC_STACK_PARAM_OFFSET, ppc_sp, PPC_STACK_PARAM_OFFSET);
/* r12 was clobbered */
g_assert (cfg->frame_reg == ppc_sp);
if (ppc_is_imm16 (cfg->stack_usage)) {
ppc_addi (code, ppc_r12, cfg->frame_reg, cfg->stack_usage);
} else {
/* cfg->stack_usage is an int, so we can use
* an addis/addi sequence here even in 64-bit. */
ppc_addis (code, ppc_r12, cfg->frame_reg, ppc_ha(cfg->stack_usage));
ppc_addi (code, ppc_r12, ppc_r12, cfg->stack_usage);
}
}
ppc_mr (code, ppc_sp, ppc_r12);
mono_add_patch_info (cfg, (guint8*) code - cfg->native_code, MONO_PATCH_INFO_METHOD_JUMP, call->method);
cfg->thunk_area += THUNK_SIZE;
if (cfg->compile_aot) {
/* arch_emit_got_access () patches this */
ppc_load32 (code, ppc_r0, 0);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr_indexed (code, ppc_r12, ppc_r30, ppc_r0);
ppc_ldptr (code, ppc_r0, 0, ppc_r12);
#else
ppc_ldptr_indexed (code, ppc_r0, ppc_r30, ppc_r0);
#endif
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
} else {
ppc_b (code, 0);
}
break;
}
case OP_CHECK_THIS:
/* ensure ins->sreg1 is not NULL */
ppc_ldptr (code, ppc_r0, 0, ins->sreg1);
break;
case OP_ARGLIST: {
long cookie_offset = cfg->sig_cookie + cfg->stack_usage;
if (ppc_is_imm16 (cookie_offset)) {
ppc_addi (code, ppc_r0, cfg->frame_reg, cookie_offset);
} else {
ppc_load (code, ppc_r0, cookie_offset);
ppc_add (code, ppc_r0, cfg->frame_reg, ppc_r0);
}
ppc_stptr (code, ppc_r0, 0, ins->sreg1);
break;
}
case OP_FCALL:
case OP_LCALL:
case OP_VCALL:
case OP_VCALL2:
case OP_VOIDCALL:
case OP_CALL:
call = (MonoCallInst*)ins;
mono_call_add_patch_info (cfg, call, offset);
if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtlr (code, PPC_CALL_REG);
ppc_blrl (code);
} else {
ppc_bl (code, 0);
}
/* FIXME: this should be handled somewhere else in the new jit */
code = emit_move_return_value (cfg, ins, code);
break;
case OP_FCALL_REG:
case OP_LCALL_REG:
case OP_VCALL_REG:
case OP_VCALL2_REG:
case OP_VOIDCALL_REG:
case OP_CALL_REG:
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
ppc_ldptr (code, ppc_r0, 0, ins->sreg1);
/* FIXME: if we know that this is a method, we
can omit this load */
ppc_ldptr (code, ppc_r2, 8, ins->sreg1);
ppc_mtlr (code, ppc_r0);
#else
#if (_CALL_ELF == 2)
if (ins->flags & MONO_INST_HAS_METHOD) {
// Not a global entry point
} else {
// Need to set up r12 with function entry address for global entry point
if (ppc_r12 != ins->sreg1) {
ppc_mr(code,ppc_r12,ins->sreg1);
}
}
#endif
ppc_mtlr (code, ins->sreg1);
#endif
ppc_blrl (code);
/* FIXME: this should be handled somewhere else in the new jit */
code = emit_move_return_value (cfg, ins, code);
break;
case OP_FCALL_MEMBASE:
case OP_LCALL_MEMBASE:
case OP_VCALL_MEMBASE:
case OP_VCALL2_MEMBASE:
case OP_VOIDCALL_MEMBASE:
case OP_CALL_MEMBASE:
if (cfg->compile_aot && ins->sreg1 == ppc_r12) {
/* The trampolines clobber this */
ppc_mr (code, ppc_r29, ins->sreg1);
ppc_ldptr (code, ppc_r0, ins->inst_offset, ppc_r29);
} else {
ppc_ldptr (code, ppc_r0, ins->inst_offset, ins->sreg1);
}
ppc_mtlr (code, ppc_r0);
ppc_blrl (code);
/* FIXME: this should be handled somewhere else in the new jit */
code = emit_move_return_value (cfg, ins, code);
break;
case OP_LOCALLOC: {
guint8 * zero_loop_jump, * zero_loop_start;
/* keep alignment */
int alloca_waste = PPC_STACK_PARAM_OFFSET + cfg->param_area + 31;
int area_offset = alloca_waste;
area_offset &= ~31;
ppc_addi (code, ppc_r12, ins->sreg1, alloca_waste + 31);
/* FIXME: should be calculated from MONO_ARCH_FRAME_ALIGNMENT */
ppc_clear_right_imm (code, ppc_r12, ppc_r12, 4);
/* use ctr to store the number of words to 0 if needed */
if (ins->flags & MONO_INST_INIT) {
/* we zero 4 bytes at a time:
* we add 7 instead of 3 so that we set the counter to
* at least 1, otherwise the bdnz instruction will make
* it negative and iterate billions of times.
*/
ppc_addi (code, ppc_r0, ins->sreg1, 7);
ppc_shift_right_arith_imm (code, ppc_r0, ppc_r0, 2);
ppc_mtctr (code, ppc_r0);
}
ppc_ldptr (code, ppc_r0, 0, ppc_sp);
ppc_neg (code, ppc_r12, ppc_r12);
ppc_stptr_update_indexed (code, ppc_r0, ppc_sp, ppc_r12);
/* FIXME: make this loop work in 8 byte
increments on PPC64 */
if (ins->flags & MONO_INST_INIT) {
/* adjust the dest reg by -4 so we can use stwu */
/* we actually adjust -8 because we let the loop
* run at least once
*/
ppc_addi (code, ins->dreg, ppc_sp, (area_offset - 8));
ppc_li (code, ppc_r12, 0);
zero_loop_start = code;
ppc_stwu (code, ppc_r12, 4, ins->dreg);
zero_loop_jump = code;
ppc_bc (code, PPC_BR_DEC_CTR_NONZERO, 0, 0);
ppc_patch (zero_loop_jump, zero_loop_start);
}
ppc_addi (code, ins->dreg, ppc_sp, area_offset);
break;
}
case OP_THROW: {
//ppc_break (code);
ppc_mr (code, ppc_r3, ins->sreg1);
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_JIT_ICALL_ID, GUINT_TO_POINTER (MONO_JIT_ICALL_mono_arch_throw_exception));
if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtlr (code, PPC_CALL_REG);
ppc_blrl (code);
} else {
ppc_bl (code, 0);
}
break;
}
case OP_RETHROW: {
//ppc_break (code);
ppc_mr (code, ppc_r3, ins->sreg1);
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_JIT_ICALL_ID,
GUINT_TO_POINTER (MONO_JIT_ICALL_mono_arch_rethrow_exception));
if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtlr (code, PPC_CALL_REG);
ppc_blrl (code);
} else {
ppc_bl (code, 0);
}
break;
}
case OP_START_HANDLER: {
MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region);
g_assert (spvar->inst_basereg != ppc_sp);
code = emit_reserve_param_area (cfg, code);
ppc_mflr (code, ppc_r0);
if (ppc_is_imm16 (spvar->inst_offset)) {
ppc_stptr (code, ppc_r0, spvar->inst_offset, spvar->inst_basereg);
} else {
ppc_load (code, ppc_r12, spvar->inst_offset);
ppc_stptr_indexed (code, ppc_r0, ppc_r12, spvar->inst_basereg);
}
break;
}
case OP_ENDFILTER: {
MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region);
g_assert (spvar->inst_basereg != ppc_sp);
code = emit_unreserve_param_area (cfg, code);
if (ins->sreg1 != ppc_r3)
ppc_mr (code, ppc_r3, ins->sreg1);
if (ppc_is_imm16 (spvar->inst_offset)) {
ppc_ldptr (code, ppc_r0, spvar->inst_offset, spvar->inst_basereg);
} else {
ppc_load (code, ppc_r12, spvar->inst_offset);
ppc_ldptr_indexed (code, ppc_r0, spvar->inst_basereg, ppc_r12);
}
ppc_mtlr (code, ppc_r0);
ppc_blr (code);
break;
}
case OP_ENDFINALLY: {
MonoInst *spvar = mono_find_spvar_for_region (cfg, bb->region);
g_assert (spvar->inst_basereg != ppc_sp);
code = emit_unreserve_param_area (cfg, code);
ppc_ldptr (code, ppc_r0, spvar->inst_offset, spvar->inst_basereg);
ppc_mtlr (code, ppc_r0);
ppc_blr (code);
break;
}
case OP_CALL_HANDLER:
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_BB, ins->inst_target_bb);
ppc_bl (code, 0);
for (GList *tmp = ins->inst_eh_blocks; tmp != bb->clause_holes; tmp = tmp->prev)
mono_cfg_add_try_hole (cfg, ((MonoLeaveClause *) tmp->data)->clause, code, bb);
break;
case OP_LABEL:
ins->inst_c0 = code - cfg->native_code;
break;
case OP_BR:
/*if (ins->inst_target_bb->native_offset) {
ppc_b (code, 0);
//x86_jump_code (code, cfg->native_code + ins->inst_target_bb->native_offset);
} else*/ {
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_BB, ins->inst_target_bb);
ppc_b (code, 0);
}
break;
case OP_BR_REG:
ppc_mtctr (code, ins->sreg1);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
break;
case OP_ICNEQ:
ppc_li (code, ins->dreg, 0);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 2);
ppc_li (code, ins->dreg, 1);
break;
case OP_CEQ:
case OP_ICEQ:
CASE_PPC64 (OP_LCEQ)
ppc_li (code, ins->dreg, 0);
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 2);
ppc_li (code, ins->dreg, 1);
break;
case OP_CLT:
case OP_CLT_UN:
case OP_ICLT:
case OP_ICLT_UN:
CASE_PPC64 (OP_LCLT)
CASE_PPC64 (OP_LCLT_UN)
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_ICGE:
case OP_ICGE_UN:
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_FALSE, PPC_BR_LT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_CGT:
case OP_CGT_UN:
case OP_ICGT:
case OP_ICGT_UN:
CASE_PPC64 (OP_LCGT)
CASE_PPC64 (OP_LCGT_UN)
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_GT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_ICLE:
case OP_ICLE_UN:
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_FALSE, PPC_BR_GT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_COND_EXC_EQ:
case OP_COND_EXC_NE_UN:
case OP_COND_EXC_LT:
case OP_COND_EXC_LT_UN:
case OP_COND_EXC_GT:
case OP_COND_EXC_GT_UN:
case OP_COND_EXC_GE:
case OP_COND_EXC_GE_UN:
case OP_COND_EXC_LE:
case OP_COND_EXC_LE_UN:
EMIT_COND_SYSTEM_EXCEPTION (ins->opcode - OP_COND_EXC_EQ, (const char*)ins->inst_p1);
break;
case OP_COND_EXC_IEQ:
case OP_COND_EXC_INE_UN:
case OP_COND_EXC_ILT:
case OP_COND_EXC_ILT_UN:
case OP_COND_EXC_IGT:
case OP_COND_EXC_IGT_UN:
case OP_COND_EXC_IGE:
case OP_COND_EXC_IGE_UN:
case OP_COND_EXC_ILE:
case OP_COND_EXC_ILE_UN:
EMIT_COND_SYSTEM_EXCEPTION (ins->opcode - OP_COND_EXC_IEQ, (const char*)ins->inst_p1);
break;
case OP_IBEQ:
case OP_IBNE_UN:
case OP_IBLT:
case OP_IBLT_UN:
case OP_IBGT:
case OP_IBGT_UN:
case OP_IBGE:
case OP_IBGE_UN:
case OP_IBLE:
case OP_IBLE_UN:
EMIT_COND_BRANCH (ins, ins->opcode - OP_IBEQ);
break;
/* floating point opcodes */
case OP_R8CONST:
g_assert (cfg->compile_aot);
/* FIXME: Optimize this */
ppc_bl (code, 1);
ppc_mflr (code, ppc_r12);
ppc_b (code, 3);
*(double*)code = *(double*)ins->inst_p0;
code += 8;
ppc_lfd (code, ins->dreg, 8, ppc_r12);
break;
case OP_R4CONST:
g_assert_not_reached ();
break;
case OP_STORER8_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_stfd (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_stfd (code, ins->sreg1, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_stfdx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_LOADR8_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lfd (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_lfd (code, ins->dreg, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lfdx (code, ins->dreg, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_STORER4_MEMBASE_REG:
ppc_frsp (code, ins->sreg1, ins->sreg1);
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_stfs (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_stfs (code, ins->sreg1, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_stfsx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_LOADR4_MEMBASE:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_lfs (code, ins->dreg, ins->inst_offset, ins->inst_basereg);
} else {
if (ppc_is_imm32 (ins->inst_offset)) {
ppc_addis (code, ppc_r11, ins->inst_destbasereg, ppc_ha(ins->inst_offset));
ppc_lfs (code, ins->dreg, ins->inst_offset, ppc_r11);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_lfsx (code, ins->dreg, ins->inst_destbasereg, ppc_r0);
}
}
break;
case OP_LOADR4_MEMINDEX:
ppc_lfsx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_LOADR8_MEMINDEX:
ppc_lfdx (code, ins->dreg, ins->inst_basereg, ins->sreg2);
break;
case OP_STORER4_MEMINDEX:
ppc_frsp (code, ins->sreg1, ins->sreg1);
ppc_stfsx (code, ins->sreg1, ins->inst_destbasereg, ins->sreg2);
break;
case OP_STORER8_MEMINDEX:
ppc_stfdx (code, ins->sreg1, ins->inst_destbasereg, ins->sreg2);
break;
case CEE_CONV_R_UN:
case CEE_CONV_R4: /* FIXME: change precision */
case CEE_CONV_R8:
g_assert_not_reached ();
case OP_FCONV_TO_I1:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, TRUE);
break;
case OP_FCONV_TO_U1:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 1, FALSE);
break;
case OP_FCONV_TO_I2:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, TRUE);
break;
case OP_FCONV_TO_U2:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 2, FALSE);
break;
case OP_FCONV_TO_I4:
case OP_FCONV_TO_I:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, TRUE);
break;
case OP_FCONV_TO_U4:
case OP_FCONV_TO_U:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 4, FALSE);
break;
case OP_LCONV_TO_R_UN:
g_assert_not_reached ();
/* Implemented as helper calls */
break;
case OP_LCONV_TO_OVF_I4_2:
case OP_LCONV_TO_OVF_I: {
#ifdef __mono_ppc64__
NOT_IMPLEMENTED;
#else
guint8 *negative_branch, *msword_positive_branch, *msword_negative_branch, *ovf_ex_target;
// Check if its negative
ppc_cmpi (code, 0, 0, ins->sreg1, 0);
negative_branch = code;
ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 0);
// Its positive msword == 0
ppc_cmpi (code, 0, 0, ins->sreg2, 0);
msword_positive_branch = code;
ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
ovf_ex_target = code;
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_ALWAYS, 0, "OverflowException");
// Negative
ppc_patch (negative_branch, code);
ppc_cmpi (code, 0, 0, ins->sreg2, -1);
msword_negative_branch = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
ppc_patch (msword_negative_branch, ovf_ex_target);
ppc_patch (msword_positive_branch, code);
if (ins->dreg != ins->sreg1)
ppc_mr (code, ins->dreg, ins->sreg1);
break;
#endif
}
case OP_ROUND:
ppc_frind (code, ins->dreg, ins->sreg1);
break;
case OP_PPC_TRUNC:
ppc_frizd (code, ins->dreg, ins->sreg1);
break;
case OP_PPC_CEIL:
ppc_fripd (code, ins->dreg, ins->sreg1);
break;
case OP_PPC_FLOOR:
ppc_frimd (code, ins->dreg, ins->sreg1);
break;
case OP_ABS:
ppc_fabsd (code, ins->dreg, ins->sreg1);
break;
case OP_SQRTF:
ppc_fsqrtsd (code, ins->dreg, ins->sreg1);
break;
case OP_SQRT:
ppc_fsqrtd (code, ins->dreg, ins->sreg1);
break;
case OP_FADD:
ppc_fadd (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_FSUB:
ppc_fsub (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_FMUL:
ppc_fmul (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_FDIV:
ppc_fdiv (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_FNEG:
ppc_fneg (code, ins->dreg, ins->sreg1);
break;
case OP_FREM:
/* emulated */
g_assert_not_reached ();
break;
/* These min/max require POWER5 */
case OP_IMIN:
ppc_cmp (code, 0, 0, ins->sreg1, ins->sreg2);
ppc_isellt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IMIN_UN:
ppc_cmpl (code, 0, 0, ins->sreg1, ins->sreg2);
ppc_isellt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IMAX:
ppc_cmp (code, 0, 0, ins->sreg1, ins->sreg2);
ppc_iselgt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_IMAX_UN:
ppc_cmpl (code, 0, 0, ins->sreg1, ins->sreg2);
ppc_iselgt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
CASE_PPC64 (OP_LMIN)
ppc_cmp (code, 0, 1, ins->sreg1, ins->sreg2);
ppc_isellt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
CASE_PPC64 (OP_LMIN_UN)
ppc_cmpl (code, 0, 1, ins->sreg1, ins->sreg2);
ppc_isellt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
CASE_PPC64 (OP_LMAX)
ppc_cmp (code, 0, 1, ins->sreg1, ins->sreg2);
ppc_iselgt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
CASE_PPC64 (OP_LMAX_UN)
ppc_cmpl (code, 0, 1, ins->sreg1, ins->sreg2);
ppc_iselgt (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_FCOMPARE:
ppc_fcmpu (code, 0, ins->sreg1, ins->sreg2);
break;
case OP_FCEQ:
case OP_FCNEQ:
ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
ppc_li (code, ins->dreg, 1);
ppc_bc (code, ins->opcode == OP_FCEQ ? PPC_BR_TRUE : PPC_BR_FALSE, PPC_BR_EQ, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_FCLT:
case OP_FCGE:
ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
ppc_li (code, ins->dreg, 1);
ppc_bc (code, ins->opcode == OP_FCLT ? PPC_BR_TRUE : PPC_BR_FALSE, PPC_BR_LT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_FCLT_UN:
ppc_fcmpu (code, 0, ins->sreg1, ins->sreg2);
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 3);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_LT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_FCGT:
case OP_FCLE:
ppc_fcmpo (code, 0, ins->sreg1, ins->sreg2);
ppc_li (code, ins->dreg, 1);
ppc_bc (code, ins->opcode == OP_FCGT ? PPC_BR_TRUE : PPC_BR_FALSE, PPC_BR_GT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_FCGT_UN:
ppc_fcmpu (code, 0, ins->sreg1, ins->sreg2);
ppc_li (code, ins->dreg, 1);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 3);
ppc_bc (code, PPC_BR_TRUE, PPC_BR_GT, 2);
ppc_li (code, ins->dreg, 0);
break;
case OP_FBEQ:
EMIT_COND_BRANCH (ins, CEE_BEQ - CEE_BEQ);
break;
case OP_FBNE_UN:
EMIT_COND_BRANCH (ins, CEE_BNE_UN - CEE_BEQ);
break;
case OP_FBLT:
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 2);
EMIT_COND_BRANCH (ins, CEE_BLT - CEE_BEQ);
break;
case OP_FBLT_UN:
EMIT_COND_BRANCH_FLAGS (ins, PPC_BR_TRUE, PPC_BR_SO);
EMIT_COND_BRANCH (ins, CEE_BLT_UN - CEE_BEQ);
break;
case OP_FBGT:
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 2);
EMIT_COND_BRANCH (ins, CEE_BGT - CEE_BEQ);
break;
case OP_FBGT_UN:
EMIT_COND_BRANCH_FLAGS (ins, PPC_BR_TRUE, PPC_BR_SO);
EMIT_COND_BRANCH (ins, CEE_BGT_UN - CEE_BEQ);
break;
case OP_FBGE:
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 2);
EMIT_COND_BRANCH (ins, CEE_BGE - CEE_BEQ);
break;
case OP_FBGE_UN:
EMIT_COND_BRANCH (ins, CEE_BGE_UN - CEE_BEQ);
break;
case OP_FBLE:
ppc_bc (code, PPC_BR_TRUE, PPC_BR_SO, 2);
EMIT_COND_BRANCH (ins, CEE_BLE - CEE_BEQ);
break;
case OP_FBLE_UN:
EMIT_COND_BRANCH (ins, CEE_BLE_UN - CEE_BEQ);
break;
case OP_CKFINITE:
g_assert_not_reached ();
case OP_PPC_CHECK_FINITE: {
ppc_rlwinm (code, ins->sreg1, ins->sreg1, 0, 1, 31);
ppc_addis (code, ins->sreg1, ins->sreg1, -32752);
ppc_rlwinmd (code, ins->sreg1, ins->sreg1, 1, 31, 31);
EMIT_COND_SYSTEM_EXCEPTION (CEE_BEQ - CEE_BEQ, "ArithmeticException");
break;
case OP_JUMP_TABLE:
mono_add_patch_info (cfg, offset, (MonoJumpInfoType)ins->inst_c1, ins->inst_p0);
#ifdef __mono_ppc64__
ppc_load_sequence (code, ins->dreg, (guint64)0x0f0f0f0f0f0f0f0fLL);
#else
ppc_load_sequence (code, ins->dreg, (gulong)0x0f0f0f0fL);
#endif
break;
}
#ifdef __mono_ppc64__
case OP_ICONV_TO_I4:
case OP_SEXT_I4:
ppc_extsw (code, ins->dreg, ins->sreg1);
break;
case OP_ICONV_TO_U4:
case OP_ZEXT_I4:
ppc_clrldi (code, ins->dreg, ins->sreg1, 32);
break;
case OP_ICONV_TO_R4:
case OP_ICONV_TO_R8:
case OP_LCONV_TO_R4:
case OP_LCONV_TO_R8: {
int tmp;
if (ins->opcode == OP_ICONV_TO_R4 || ins->opcode == OP_ICONV_TO_R8) {
ppc_extsw (code, ppc_r0, ins->sreg1);
tmp = ppc_r0;
} else {
tmp = ins->sreg1;
}
if (cpu_hw_caps & PPC_MOVE_FPR_GPR) {
ppc_mffgpr (code, ins->dreg, tmp);
} else {
ppc_str (code, tmp, -8, ppc_r1);
ppc_lfd (code, ins->dreg, -8, ppc_r1);
}
ppc_fcfid (code, ins->dreg, ins->dreg);
if (ins->opcode == OP_ICONV_TO_R4 || ins->opcode == OP_LCONV_TO_R4)
ppc_frsp (code, ins->dreg, ins->dreg);
break;
}
case OP_LSHR:
ppc_srad (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_LSHR_UN:
ppc_srd (code, ins->dreg, ins->sreg1, ins->sreg2);
break;
case OP_COND_EXC_C:
/* check XER [0-3] (SO, OV, CA): we can't use mcrxr
*/
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1 << 13)); /* CA */
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, (const char*)ins->inst_p1);
break;
case OP_COND_EXC_OV:
ppc_mfspr (code, ppc_r0, ppc_xer);
ppc_andisd (code, ppc_r0, ppc_r0, (1 << 14)); /* OV */
EMIT_COND_SYSTEM_EXCEPTION_FLAGS (PPC_BR_FALSE, PPC_BR_EQ, (const char*)ins->inst_p1);
break;
case OP_LBEQ:
case OP_LBNE_UN:
case OP_LBLT:
case OP_LBLT_UN:
case OP_LBGT:
case OP_LBGT_UN:
case OP_LBGE:
case OP_LBGE_UN:
case OP_LBLE:
case OP_LBLE_UN:
EMIT_COND_BRANCH (ins, ins->opcode - OP_LBEQ);
break;
case OP_FCONV_TO_I8:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 8, TRUE);
break;
case OP_FCONV_TO_U8:
code = emit_float_to_int (cfg, code, ins->dreg, ins->sreg1, 8, FALSE);
break;
case OP_STOREI4_MEMBASE_REG:
if (ppc_is_imm16 (ins->inst_offset)) {
ppc_stw (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg);
} else {
ppc_load (code, ppc_r0, ins->inst_offset);
ppc_stwx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0);
}
break;
case OP_STOREI4_MEMINDEX:
ppc_stwx (code, ins->sreg1, ins->sreg2, ins->inst_destbasereg);
break;
case OP_ISHR_IMM:
ppc_srawi (code, ins->dreg, ins->sreg1, (ins->inst_imm & 0x1f));
break;
case OP_ISHR_UN_IMM:
if (ins->inst_imm & 0x1f)
ppc_srwi (code, ins->dreg, ins->sreg1, (ins->inst_imm & 0x1f));
else
ppc_mr (code, ins->dreg, ins->sreg1);
break;
#else
case OP_ICONV_TO_R4:
case OP_ICONV_TO_R8: {
if (cpu_hw_caps & PPC_ISA_64) {
ppc_srawi(code, ppc_r0, ins->sreg1, 31);
ppc_stw (code, ppc_r0, -8, ppc_r1);
ppc_stw (code, ins->sreg1, -4, ppc_r1);
ppc_lfd (code, ins->dreg, -8, ppc_r1);
ppc_fcfid (code, ins->dreg, ins->dreg);
if (ins->opcode == OP_ICONV_TO_R4)
ppc_frsp (code, ins->dreg, ins->dreg);
}
break;
}
#endif
case OP_ATOMIC_ADD_I4:
CASE_PPC64 (OP_ATOMIC_ADD_I8) {
int location = ins->inst_basereg;
int addend = ins->sreg2;
guint8 *loop, *branch;
g_assert (ins->inst_offset == 0);
loop = code;
ppc_sync (code);
if (ins->opcode == OP_ATOMIC_ADD_I4)
ppc_lwarx (code, ppc_r0, 0, location);
#ifdef __mono_ppc64__
else
ppc_ldarx (code, ppc_r0, 0, location);
#endif
ppc_add (code, ppc_r0, ppc_r0, addend);
if (ins->opcode == OP_ATOMIC_ADD_I4)
ppc_stwcxd (code, ppc_r0, 0, location);
#ifdef __mono_ppc64__
else
ppc_stdcxd (code, ppc_r0, 0, location);
#endif
branch = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
ppc_patch (branch, loop);
ppc_sync (code);
ppc_mr (code, ins->dreg, ppc_r0);
break;
}
case OP_ATOMIC_CAS_I4:
CASE_PPC64 (OP_ATOMIC_CAS_I8) {
int location = ins->sreg1;
int value = ins->sreg2;
int comparand = ins->sreg3;
guint8 *start, *not_equal, *lost_reservation;
start = code;
ppc_sync (code);
if (ins->opcode == OP_ATOMIC_CAS_I4)
ppc_lwarx (code, ppc_r0, 0, location);
#ifdef __mono_ppc64__
else
ppc_ldarx (code, ppc_r0, 0, location);
#endif
ppc_cmp (code, 0, ins->opcode == OP_ATOMIC_CAS_I4 ? 0 : 1, ppc_r0, comparand);
not_equal = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
if (ins->opcode == OP_ATOMIC_CAS_I4)
ppc_stwcxd (code, value, 0, location);
#ifdef __mono_ppc64__
else
ppc_stdcxd (code, value, 0, location);
#endif
lost_reservation = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
ppc_patch (lost_reservation, start);
ppc_patch (not_equal, code);
ppc_sync (code);
ppc_mr (code, ins->dreg, ppc_r0);
break;
}
case OP_LIVERANGE_START: {
if (cfg->verbose_level > 1)
printf ("R%d START=0x%x\n", MONO_VARINFO (cfg, ins->inst_c0)->vreg, (int)(code - cfg->native_code));
MONO_VARINFO (cfg, ins->inst_c0)->live_range_start = code - cfg->native_code;
break;
}
case OP_LIVERANGE_END: {
if (cfg->verbose_level > 1)
printf ("R%d END=0x%x\n", MONO_VARINFO (cfg, ins->inst_c0)->vreg, (int)(code - cfg->native_code));
MONO_VARINFO (cfg, ins->inst_c0)->live_range_end = code - cfg->native_code;
break;
}
case OP_GC_SAFE_POINT:
break;
default:
g_warning ("unknown opcode %s in %s()\n", mono_inst_name (ins->opcode), __FUNCTION__);
g_assert_not_reached ();
}
if ((cfg->opt & MONO_OPT_BRANCH) && ((code - cfg->native_code - offset) > max_len)) {
g_warning ("wrong maximal instruction length of instruction %s (expected %d, got %ld)",
mono_inst_name (ins->opcode), max_len, (glong)(code - cfg->native_code - offset));
g_assert_not_reached ();
}
cpos += max_len;
last_ins = ins;
}
set_code_cursor (cfg, code);
}
#endif /* !DISABLE_JIT */
void
mono_arch_register_lowlevel_calls (void)
{
/* The signature doesn't matter */
mono_register_jit_icall (mono_ppc_throw_exception, mono_icall_sig_void, TRUE);
}
#ifdef __mono_ppc64__
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define patch_load_sequence(ip,val) do {\
guint16 *__load = (guint16*)(ip); \
g_assert (sizeof (val) == sizeof (gsize)); \
__load [0] = (((guint64)(gsize)(val)) >> 48) & 0xffff; \
__load [2] = (((guint64)(gsize)(val)) >> 32) & 0xffff; \
__load [6] = (((guint64)(gsize)(val)) >> 16) & 0xffff; \
__load [8] = ((guint64)(gsize)(val)) & 0xffff; \
} while (0)
#elif G_BYTE_ORDER == G_BIG_ENDIAN
#define patch_load_sequence(ip,val) do {\
guint16 *__load = (guint16*)(ip); \
g_assert (sizeof (val) == sizeof (gsize)); \
__load [1] = (((guint64)(gsize)(val)) >> 48) & 0xffff; \
__load [3] = (((guint64)(gsize)(val)) >> 32) & 0xffff; \
__load [7] = (((guint64)(gsize)(val)) >> 16) & 0xffff; \
__load [9] = ((guint64)(gsize)(val)) & 0xffff; \
} while (0)
#else
#error huh? No endianess defined by compiler
#endif
#else
#define patch_load_sequence(ip,val) do {\
guint16 *__lis_ori = (guint16*)(ip); \
__lis_ori [1] = (((gulong)(val)) >> 16) & 0xffff; \
__lis_ori [3] = ((gulong)(val)) & 0xffff; \
} while (0)
#endif
#ifndef DISABLE_JIT
void
mono_arch_patch_code_new (MonoCompile *cfg, guint8 *code, MonoJumpInfo *ji, gpointer target)
{
unsigned char *ip = ji->ip.i + code;
gboolean is_fd = FALSE;
switch (ji->type) {
case MONO_PATCH_INFO_IP:
patch_load_sequence (ip, ip);
break;
case MONO_PATCH_INFO_SWITCH: {
gpointer *table = (gpointer *)ji->data.table->table;
int i;
patch_load_sequence (ip, table);
for (i = 0; i < ji->data.table->table_size; i++) {
table [i] = (glong)ji->data.table->table [i] + code;
}
/* we put into the table the absolute address, no need for ppc_patch in this case */
break;
}
case MONO_PATCH_INFO_METHODCONST:
case MONO_PATCH_INFO_CLASS:
case MONO_PATCH_INFO_IMAGE:
case MONO_PATCH_INFO_FIELD:
case MONO_PATCH_INFO_VTABLE:
case MONO_PATCH_INFO_IID:
case MONO_PATCH_INFO_SFLDA:
case MONO_PATCH_INFO_LDSTR:
case MONO_PATCH_INFO_TYPE_FROM_HANDLE:
case MONO_PATCH_INFO_LDTOKEN:
/* from OP_AOTCONST : lis + ori */
patch_load_sequence (ip, target);
break;
case MONO_PATCH_INFO_R4:
case MONO_PATCH_INFO_R8:
g_assert_not_reached ();
*((gconstpointer *)(ip + 2)) = ji->data.target;
break;
case MONO_PATCH_INFO_EXC_NAME:
g_assert_not_reached ();
*((gconstpointer *)(ip + 1)) = ji->data.name;
break;
case MONO_PATCH_INFO_NONE:
case MONO_PATCH_INFO_BB_OVF:
case MONO_PATCH_INFO_EXC_OVF:
/* everything is dealt with at epilog output time */
break;
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
case MONO_PATCH_INFO_JIT_ICALL_ID:
case MONO_PATCH_INFO_ABS:
case MONO_PATCH_INFO_RGCTX_FETCH:
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR:
is_fd = TRUE;
/* fall through */
#endif
default:
ppc_patch_full (cfg, ip, (const guchar*)target, is_fd);
break;
}
}
/*
* Emit code to save the registers in used_int_regs or the registers in the MonoLMF
* structure at positive offset pos from register base_reg. pos is guaranteed to fit into
* the instruction offset immediate for all the registers.
*/
static guint8*
save_registers (MonoCompile *cfg, guint8* code, int pos, int base_reg, gboolean save_lmf, guint32 used_int_regs, int cfa_offset)
{
int i;
if (!save_lmf) {
for (i = 13; i <= 31; i++) {
if (used_int_regs & (1 << i)) {
ppc_str (code, i, pos, base_reg);
mono_emit_unwind_op_offset (cfg, code, i, pos - cfa_offset);
pos += sizeof (target_mgreg_t);
}
}
} else {
/* pos is the start of the MonoLMF structure */
int offset = pos + G_STRUCT_OFFSET (MonoLMF, iregs);
for (i = 13; i <= 31; i++) {
ppc_str (code, i, offset, base_reg);
mono_emit_unwind_op_offset (cfg, code, i, offset - cfa_offset);
offset += sizeof (target_mgreg_t);
}
offset = pos + G_STRUCT_OFFSET (MonoLMF, fregs);
for (i = 14; i < 32; i++) {
ppc_stfd (code, i, offset, base_reg);
offset += sizeof (gdouble);
}
}
return code;
}
/*
* Stack frame layout:
*
* ------------------- sp
* MonoLMF structure or saved registers
* -------------------
* spilled regs
* -------------------
* locals
* -------------------
* param area size is cfg->param_area
* -------------------
* linkage area size is PPC_STACK_PARAM_OFFSET
* ------------------- sp
* red zone
*/
guint8 *
mono_arch_emit_prolog (MonoCompile *cfg)
{
MonoMethod *method = cfg->method;
MonoBasicBlock *bb;
MonoMethodSignature *sig;
MonoInst *inst;
long alloc_size, pos, max_offset, cfa_offset;
int i;
guint8 *code;
CallInfo *cinfo;
int lmf_offset = 0;
int tailcall_struct_index;
sig = mono_method_signature_internal (method);
cfg->code_size = 512 + sig->param_count * 32;
code = cfg->native_code = g_malloc (cfg->code_size);
cfa_offset = 0;
/* We currently emit unwind info for aot, but don't use it */
mono_emit_unwind_op_def_cfa (cfg, code, ppc_r1, 0);
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
ppc_mflr (code, ppc_r0);
ppc_str (code, ppc_r0, PPC_RET_ADDR_OFFSET, ppc_sp);
mono_emit_unwind_op_offset (cfg, code, ppc_lr, PPC_RET_ADDR_OFFSET);
}
alloc_size = cfg->stack_offset;
pos = 0;
if (!method->save_lmf) {
for (i = 31; i >= 13; --i) {
if (cfg->used_int_regs & (1 << i)) {
pos += sizeof (target_mgreg_t);
}
}
} else {
pos += sizeof (MonoLMF);
lmf_offset = pos;
}
alloc_size += pos;
// align to MONO_ARCH_FRAME_ALIGNMENT bytes
if (alloc_size & (MONO_ARCH_FRAME_ALIGNMENT - 1)) {
alloc_size += MONO_ARCH_FRAME_ALIGNMENT - 1;
alloc_size &= ~(MONO_ARCH_FRAME_ALIGNMENT - 1);
}
cfg->stack_usage = alloc_size;
g_assert ((alloc_size & (MONO_ARCH_FRAME_ALIGNMENT-1)) == 0);
if (alloc_size) {
if (ppc_is_imm16 (-alloc_size)) {
ppc_str_update (code, ppc_sp, -alloc_size, ppc_sp);
cfa_offset = alloc_size;
mono_emit_unwind_op_def_cfa_offset (cfg, code, alloc_size);
code = save_registers (cfg, code, alloc_size - pos, ppc_sp, method->save_lmf, cfg->used_int_regs, cfa_offset);
} else {
if (pos)
ppc_addi (code, ppc_r12, ppc_sp, -pos);
ppc_load (code, ppc_r0, -alloc_size);
ppc_str_update_indexed (code, ppc_sp, ppc_sp, ppc_r0);
cfa_offset = alloc_size;
mono_emit_unwind_op_def_cfa_offset (cfg, code, alloc_size);
code = save_registers (cfg, code, 0, ppc_r12, method->save_lmf, cfg->used_int_regs, cfa_offset);
}
}
if (cfg->frame_reg != ppc_sp) {
ppc_mr (code, cfg->frame_reg, ppc_sp);
mono_emit_unwind_op_def_cfa_reg (cfg, code, cfg->frame_reg);
}
/* store runtime generic context */
if (cfg->rgctx_var) {
g_assert (cfg->rgctx_var->opcode == OP_REGOFFSET &&
(cfg->rgctx_var->inst_basereg == ppc_r1 || cfg->rgctx_var->inst_basereg == ppc_r31));
ppc_stptr (code, MONO_ARCH_RGCTX_REG, cfg->rgctx_var->inst_offset, cfg->rgctx_var->inst_basereg);
}
/* compute max_offset in order to use short forward jumps
* we always do it on ppc because the immediate displacement
* for jumps is too small
*/
max_offset = 0;
for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
MonoInst *ins;
bb->max_offset = max_offset;
MONO_BB_FOR_EACH_INS (bb, ins)
max_offset += ins_get_size (ins->opcode);
}
/* load arguments allocated to register from the stack */
pos = 0;
cinfo = get_call_info (sig);
if (MONO_TYPE_ISSTRUCT (sig->ret)) {
ArgInfo *ainfo = &cinfo->ret;
inst = cfg->vret_addr;
g_assert (inst);
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stptr (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stptr_indexed (code, ainfo->reg, ppc_r12, inst->inst_basereg);
}
}
tailcall_struct_index = 0;
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
ArgInfo *ainfo = cinfo->args + i;
inst = cfg->args [pos];
if (cfg->verbose_level > 2)
g_print ("Saving argument %d (type: %d)\n", i, ainfo->regtype);
if (inst->opcode == OP_REGVAR) {
if (ainfo->regtype == RegTypeGeneral)
ppc_mr (code, inst->dreg, ainfo->reg);
else if (ainfo->regtype == RegTypeFP)
ppc_fmr (code, inst->dreg, ainfo->reg);
else if (ainfo->regtype == RegTypeBase) {
ppc_ldr (code, ppc_r12, 0, ppc_sp);
ppc_ldptr (code, inst->dreg, ainfo->offset, ppc_r12);
} else
g_assert_not_reached ();
if (cfg->verbose_level > 2)
g_print ("Argument %ld assigned to register %s\n", pos, mono_arch_regname (inst->dreg));
} else {
/* the argument should be put on the stack: FIXME handle size != word */
if (ainfo->regtype == RegTypeGeneral) {
switch (ainfo->size) {
case 1:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stb (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stb (code, ainfo->reg, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stbx (code, ainfo->reg, inst->inst_basereg, ppc_r12);
}
}
break;
case 2:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_sth (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_sth (code, ainfo->reg, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_sthx (code, ainfo->reg, inst->inst_basereg, ppc_r12);
}
}
break;
#ifdef __mono_ppc64__
case 4:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stw (code, ainfo->reg, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stwx (code, ainfo->reg, inst->inst_basereg, ppc_r12);
}
}
break;
case 8:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_str (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_str_indexed (code, ainfo->reg, ppc_r12, inst->inst_basereg);
}
break;
#else
case 8:
if (ppc_is_imm16 (inst->inst_offset + 4)) {
ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
ppc_stw (code, ainfo->reg + 1, inst->inst_offset + 4, inst->inst_basereg);
} else {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_addi (code, ppc_r12, ppc_r12, inst->inst_offset);
ppc_stw (code, ainfo->reg, 0, ppc_r12);
ppc_stw (code, ainfo->reg + 1, 4, ppc_r12);
}
break;
#endif
default:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stptr (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stptr (code, ainfo->reg, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stptr_indexed (code, ainfo->reg, inst->inst_basereg, ppc_r12);
}
}
break;
}
} else if (ainfo->regtype == RegTypeBase) {
g_assert (ppc_is_imm16 (ainfo->offset));
/* load the previous stack pointer in r12 */
ppc_ldr (code, ppc_r12, 0, ppc_sp);
ppc_ldptr (code, ppc_r0, ainfo->offset, ppc_r12);
switch (ainfo->size) {
case 1:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stb (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stb (code, ppc_r0, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stbx (code, ppc_r0, inst->inst_basereg, ppc_r12);
}
}
break;
case 2:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_sth (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_sth (code, ppc_r0, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_sthx (code, ppc_r0, inst->inst_basereg, ppc_r12);
}
}
break;
#ifdef __mono_ppc64__
case 4:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stw (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stw (code, ppc_r0, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stwx (code, ppc_r0, inst->inst_basereg, ppc_r12);
}
}
break;
case 8:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_str (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_str_indexed (code, ppc_r0, ppc_r12, inst->inst_basereg);
}
break;
#else
case 8:
g_assert (ppc_is_imm16 (ainfo->offset + 4));
if (ppc_is_imm16 (inst->inst_offset + 4)) {
ppc_stw (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
ppc_lwz (code, ppc_r0, ainfo->offset + 4, ppc_r12);
ppc_stw (code, ppc_r0, inst->inst_offset + 4, inst->inst_basereg);
} else {
/* use r11 to load the 2nd half of the long before we clobber r12. */
ppc_lwz (code, ppc_r11, ainfo->offset + 4, ppc_r12);
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_addi (code, ppc_r12, ppc_r12, inst->inst_offset);
ppc_stw (code, ppc_r0, 0, ppc_r12);
ppc_stw (code, ppc_r11, 4, ppc_r12);
}
break;
#endif
default:
if (ppc_is_imm16 (inst->inst_offset)) {
ppc_stptr (code, ppc_r0, inst->inst_offset, inst->inst_basereg);
} else {
if (ppc_is_imm32 (inst->inst_offset)) {
ppc_addis (code, ppc_r12, inst->inst_basereg, ppc_ha(inst->inst_offset));
ppc_stptr (code, ppc_r0, inst->inst_offset, ppc_r12);
} else {
ppc_load (code, ppc_r12, inst->inst_offset);
ppc_stptr_indexed (code, ppc_r0, inst->inst_basereg, ppc_r12);
}
}
break;
}
} else if (ainfo->regtype == RegTypeFP) {
g_assert (ppc_is_imm16 (inst->inst_offset));
if (ainfo->size == 8)
ppc_stfd (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
else if (ainfo->size == 4)
ppc_stfs (code, ainfo->reg, inst->inst_offset, inst->inst_basereg);
else
g_assert_not_reached ();
} else if (ainfo->regtype == RegTypeFPStructByVal) {
int doffset = inst->inst_offset;
int soffset = 0;
int cur_reg;
int size = 0;
g_assert (ppc_is_imm16 (inst->inst_offset));
g_assert (ppc_is_imm16 (inst->inst_offset + ainfo->vtregs * sizeof (target_mgreg_t)));
/* FIXME: what if there is no class? */
if (sig->pinvoke && mono_class_from_mono_type_internal (inst->inst_vtype))
size = mono_class_native_size (mono_class_from_mono_type_internal (inst->inst_vtype), NULL);
for (cur_reg = 0; cur_reg < ainfo->vtregs; ++cur_reg) {
if (ainfo->size == 4) {
ppc_stfs (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
} else {
ppc_stfd (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
}
soffset += ainfo->size;
doffset += ainfo->size;
}
} else if (ainfo->regtype == RegTypeStructByVal) {
int doffset = inst->inst_offset;
int soffset = 0;
int cur_reg;
int size = 0;
g_assert (ppc_is_imm16 (inst->inst_offset));
g_assert (ppc_is_imm16 (inst->inst_offset + ainfo->vtregs * sizeof (target_mgreg_t)));
/* FIXME: what if there is no class? */
if (sig->pinvoke && mono_class_from_mono_type_internal (inst->inst_vtype))
size = mono_class_native_size (mono_class_from_mono_type_internal (inst->inst_vtype), NULL);
for (cur_reg = 0; cur_reg < ainfo->vtregs; ++cur_reg) {
#if __APPLE__
/*
* Darwin handles 1 and 2 byte
* structs specially by
* loading h/b into the arg
* register. Only done for
* pinvokes.
*/
if (size == 2)
ppc_sth (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
else if (size == 1)
ppc_stb (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
else
#endif
{
#ifdef __mono_ppc64__
if (ainfo->bytes) {
g_assert (cur_reg == 0);
#if G_BYTE_ORDER == G_BIG_ENDIAN
ppc_sldi (code, ppc_r0, ainfo->reg,
(sizeof (target_mgreg_t) - ainfo->bytes) * 8);
ppc_stptr (code, ppc_r0, doffset, inst->inst_basereg);
#else
if (mono_class_native_size (inst->klass, NULL) == 1) {
ppc_stb (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
} else if (mono_class_native_size (inst->klass, NULL) == 2) {
ppc_sth (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
} else if (mono_class_native_size (inst->klass, NULL) == 4) { // WDS -- maybe <=4?
ppc_stw (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg);
} else {
ppc_stptr (code, ainfo->reg + cur_reg, doffset, inst->inst_basereg); // WDS -- Better way?
}
#endif
} else
#endif
{
ppc_stptr (code, ainfo->reg + cur_reg, doffset,
inst->inst_basereg);
}
}
soffset += sizeof (target_mgreg_t);
doffset += sizeof (target_mgreg_t);
}
if (ainfo->vtsize) {
/* FIXME: we need to do the shifting here, too */
if (ainfo->bytes)
NOT_IMPLEMENTED;
/* load the previous stack pointer in r12 (r0 gets overwritten by the memcpy) */
ppc_ldr (code, ppc_r12, 0, ppc_sp);
if ((size & MONO_PPC_32_64_CASE (3, 7)) != 0) {
code = emit_memcpy (code, size - soffset,
inst->inst_basereg, doffset,
ppc_r12, ainfo->offset + soffset);
} else {
code = emit_memcpy (code, ainfo->vtsize * sizeof (target_mgreg_t),
inst->inst_basereg, doffset,
ppc_r12, ainfo->offset + soffset);
}
}
} else if (ainfo->regtype == RegTypeStructByAddr) {
/* if it was originally a RegTypeBase */
if (ainfo->offset) {
/* load the previous stack pointer in r12 */
ppc_ldr (code, ppc_r12, 0, ppc_sp);
ppc_ldptr (code, ppc_r12, ainfo->offset, ppc_r12);
} else {
ppc_mr (code, ppc_r12, ainfo->reg);
}
g_assert (ppc_is_imm16 (inst->inst_offset));
code = emit_memcpy (code, ainfo->vtsize, inst->inst_basereg, inst->inst_offset, ppc_r12, 0);
/*g_print ("copy in %s: %d bytes from %d to offset: %d\n", method->name, ainfo->vtsize, ainfo->reg, inst->inst_offset);*/
} else
g_assert_not_reached ();
}
pos++;
}
if (method->save_lmf) {
if (cfg->compile_aot) {
/* Compute the got address which is needed by the PLT entry */
code = mono_arch_emit_load_got_addr (cfg->native_code, code, cfg, NULL);
}
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_JIT_ICALL_ID,
GUINT_TO_POINTER (MONO_JIT_ICALL_mono_tls_get_lmf_addr_extern));
if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtlr (code, PPC_CALL_REG);
ppc_blrl (code);
} else {
ppc_bl (code, 0);
}
/* we build the MonoLMF structure on the stack - see mini-ppc.h */
/* lmf_offset is the offset from the previous stack pointer,
* alloc_size is the total stack space allocated, so the offset
* of MonoLMF from the current stack ptr is alloc_size - lmf_offset.
* The pointer to the struct is put in ppc_r12 (new_lmf).
* The callee-saved registers are already in the MonoLMF structure
*/
ppc_addi (code, ppc_r12, ppc_sp, alloc_size - lmf_offset);
/* ppc_r3 is the result from mono_get_lmf_addr () */
ppc_stptr (code, ppc_r3, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r12);
/* new_lmf->previous_lmf = *lmf_addr */
ppc_ldptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r12);
/* *(lmf_addr) = r12 */
ppc_stptr (code, ppc_r12, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r3);
/* save method info */
if (cfg->compile_aot)
// FIXME:
ppc_load (code, ppc_r0, 0);
else
ppc_load_ptr (code, ppc_r0, method);
ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, method), ppc_r12);
ppc_stptr (code, ppc_sp, G_STRUCT_OFFSET(MonoLMF, ebp), ppc_r12);
/* save the current IP */
if (cfg->compile_aot) {
ppc_bl (code, 1);
ppc_mflr (code, ppc_r0);
} else {
mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_IP, NULL);
#ifdef __mono_ppc64__
ppc_load_sequence (code, ppc_r0, (guint64)0x0101010101010101LL);
#else
ppc_load_sequence (code, ppc_r0, (gulong)0x01010101L);
#endif
}
ppc_stptr (code, ppc_r0, G_STRUCT_OFFSET(MonoLMF, eip), ppc_r12);
}
set_code_cursor (cfg, code);
g_free (cinfo);
return code;
}
void
mono_arch_emit_epilog (MonoCompile *cfg)
{
MonoMethod *method = cfg->method;
int pos, i;
int max_epilog_size = 16 + 20*4;
guint8 *code;
if (cfg->method->save_lmf)
max_epilog_size += 128;
code = realloc_code (cfg, max_epilog_size);
pos = 0;
if (method->save_lmf) {
int lmf_offset;
pos += sizeof (MonoLMF);
lmf_offset = pos;
/* save the frame reg in r8 */
ppc_mr (code, ppc_r8, cfg->frame_reg);
ppc_addi (code, ppc_r12, cfg->frame_reg, cfg->stack_usage - lmf_offset);
/* r5 = previous_lmf */
ppc_ldptr (code, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r12);
/* r6 = lmf_addr */
ppc_ldptr (code, ppc_r6, G_STRUCT_OFFSET(MonoLMF, lmf_addr), ppc_r12);
/* *(lmf_addr) = previous_lmf */
ppc_stptr (code, ppc_r5, G_STRUCT_OFFSET(MonoLMF, previous_lmf), ppc_r6);
/* FIXME: speedup: there is no actual need to restore the registers if
* we didn't actually change them (idea from Zoltan).
*/
/* restore iregs */
ppc_ldr_multiple (code, ppc_r13, G_STRUCT_OFFSET(MonoLMF, iregs), ppc_r12);
/* restore fregs */
/*for (i = 14; i < 32; i++) {
ppc_lfd (code, i, G_STRUCT_OFFSET(MonoLMF, fregs) + ((i-14) * sizeof (gdouble)), ppc_r12);
}*/
g_assert (ppc_is_imm16 (cfg->stack_usage + PPC_RET_ADDR_OFFSET));
/* use the saved copy of the frame reg in r8 */
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
ppc_ldr (code, ppc_r0, cfg->stack_usage + PPC_RET_ADDR_OFFSET, ppc_r8);
ppc_mtlr (code, ppc_r0);
}
ppc_addic (code, ppc_sp, ppc_r8, cfg->stack_usage);
} else {
if (1 || cfg->flags & MONO_CFG_HAS_CALLS) {
long return_offset = cfg->stack_usage + PPC_RET_ADDR_OFFSET;
if (ppc_is_imm16 (return_offset)) {
ppc_ldr (code, ppc_r0, return_offset, cfg->frame_reg);
} else {
ppc_load (code, ppc_r12, return_offset);
ppc_ldr_indexed (code, ppc_r0, cfg->frame_reg, ppc_r12);
}
ppc_mtlr (code, ppc_r0);
}
if (ppc_is_imm16 (cfg->stack_usage)) {
int offset = cfg->stack_usage;
for (i = 13; i <= 31; i++) {
if (cfg->used_int_regs & (1 << i))
offset -= sizeof (target_mgreg_t);
}
if (cfg->frame_reg != ppc_sp)
ppc_mr (code, ppc_r12, cfg->frame_reg);
/* note r31 (possibly the frame register) is restored last */
for (i = 13; i <= 31; i++) {
if (cfg->used_int_regs & (1 << i)) {
ppc_ldr (code, i, offset, cfg->frame_reg);
offset += sizeof (target_mgreg_t);
}
}
if (cfg->frame_reg != ppc_sp)
ppc_addi (code, ppc_sp, ppc_r12, cfg->stack_usage);
else
ppc_addi (code, ppc_sp, ppc_sp, cfg->stack_usage);
} else {
ppc_load32 (code, ppc_r12, cfg->stack_usage);
if (cfg->used_int_regs) {
ppc_add (code, ppc_r12, cfg->frame_reg, ppc_r12);
for (i = 31; i >= 13; --i) {
if (cfg->used_int_regs & (1 << i)) {
pos += sizeof (target_mgreg_t);
ppc_ldr (code, i, -pos, ppc_r12);
}
}
ppc_mr (code, ppc_sp, ppc_r12);
} else {
ppc_add (code, ppc_sp, cfg->frame_reg, ppc_r12);
}
}
}
ppc_blr (code);
set_code_cursor (cfg, code);
}
#endif /* ifndef DISABLE_JIT */
/* remove once throw_exception_by_name is eliminated */
static int
exception_id_by_name (const char *name)
{
if (strcmp (name, "IndexOutOfRangeException") == 0)
return MONO_EXC_INDEX_OUT_OF_RANGE;
if (strcmp (name, "OverflowException") == 0)
return MONO_EXC_OVERFLOW;
if (strcmp (name, "ArithmeticException") == 0)
return MONO_EXC_ARITHMETIC;
if (strcmp (name, "DivideByZeroException") == 0)
return MONO_EXC_DIVIDE_BY_ZERO;
if (strcmp (name, "InvalidCastException") == 0)
return MONO_EXC_INVALID_CAST;
if (strcmp (name, "NullReferenceException") == 0)
return MONO_EXC_NULL_REF;
if (strcmp (name, "ArrayTypeMismatchException") == 0)
return MONO_EXC_ARRAY_TYPE_MISMATCH;
if (strcmp (name, "ArgumentException") == 0)
return MONO_EXC_ARGUMENT;
g_error ("Unknown intrinsic exception %s\n", name);
return 0;
}
#ifndef DISABLE_JIT
void
mono_arch_emit_exceptions (MonoCompile *cfg)
{
MonoJumpInfo *patch_info;
int i;
guint8 *code;
guint8* exc_throw_pos [MONO_EXC_INTRINS_NUM];
guint8 exc_throw_found [MONO_EXC_INTRINS_NUM];
int max_epilog_size = 50;
for (i = 0; i < MONO_EXC_INTRINS_NUM; i++) {
exc_throw_pos [i] = NULL;
exc_throw_found [i] = 0;
}
/* count the number of exception infos */
/*
* make sure we have enough space for exceptions
*/
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
if (patch_info->type == MONO_PATCH_INFO_EXC) {
i = exception_id_by_name ((const char*)patch_info->data.target);
if (!exc_throw_found [i]) {
max_epilog_size += (2 * PPC_LOAD_SEQUENCE_LENGTH) + 5 * 4;
exc_throw_found [i] = TRUE;
}
} else if (patch_info->type == MONO_PATCH_INFO_BB_OVF)
max_epilog_size += 12;
else if (patch_info->type == MONO_PATCH_INFO_EXC_OVF) {
MonoOvfJump *ovfj = (MonoOvfJump*)patch_info->data.target;
i = exception_id_by_name (ovfj->data.exception);
if (!exc_throw_found [i]) {
max_epilog_size += (2 * PPC_LOAD_SEQUENCE_LENGTH) + 5 * 4;
exc_throw_found [i] = TRUE;
}
max_epilog_size += 8;
}
}
code = realloc_code (cfg, max_epilog_size);
/* add code to raise exceptions */
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_BB_OVF: {
MonoOvfJump *ovfj = (MonoOvfJump*)patch_info->data.target;
unsigned char *ip = patch_info->ip.i + cfg->native_code;
/* patch the initial jump */
ppc_patch (ip, code);
ppc_bc (code, ovfj->b0_cond, ovfj->b1_cond, 2);
ppc_b (code, 0);
ppc_patch (code - 4, ip + 4); /* jump back after the initiali branch */
/* jump back to the true target */
ppc_b (code, 0);
ip = ovfj->data.bb->native_offset + cfg->native_code;
ppc_patch (code - 4, ip);
patch_info->type = MONO_PATCH_INFO_NONE;
break;
}
case MONO_PATCH_INFO_EXC_OVF: {
MonoOvfJump *ovfj = (MonoOvfJump*)patch_info->data.target;
MonoJumpInfo *newji;
unsigned char *ip = patch_info->ip.i + cfg->native_code;
unsigned char *bcl = code;
/* patch the initial jump: we arrived here with a call */
ppc_patch (ip, code);
ppc_bc (code, ovfj->b0_cond, ovfj->b1_cond, 0);
ppc_b (code, 0);
ppc_patch (code - 4, ip + 4); /* jump back after the initiali branch */
/* patch the conditional jump to the right handler */
/* make it processed next */
newji = mono_mempool_alloc (cfg->mempool, sizeof (MonoJumpInfo));
newji->type = MONO_PATCH_INFO_EXC;
newji->ip.i = bcl - cfg->native_code;
newji->data.target = ovfj->data.exception;
newji->next = patch_info->next;
patch_info->next = newji;
patch_info->type = MONO_PATCH_INFO_NONE;
break;
}
case MONO_PATCH_INFO_EXC: {
MonoClass *exc_class;
unsigned char *ip = patch_info->ip.i + cfg->native_code;
i = exception_id_by_name ((const char*)patch_info->data.target);
if (exc_throw_pos [i] && !(ip > exc_throw_pos [i] && ip - exc_throw_pos [i] > 50000)) {
ppc_patch (ip, exc_throw_pos [i]);
patch_info->type = MONO_PATCH_INFO_NONE;
break;
} else {
exc_throw_pos [i] = code;
}
exc_class = mono_class_load_from_name (mono_defaults.corlib, "System", patch_info->data.name);
ppc_patch (ip, code);
/*mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_EXC_NAME, patch_info->data.target);*/
ppc_load (code, ppc_r3, m_class_get_type_token (exc_class));
/* we got here from a conditional call, so the calling ip is set in lr */
ppc_mflr (code, ppc_r4);
patch_info->type = MONO_PATCH_INFO_JIT_ICALL_ID;
patch_info->data.jit_icall_id = MONO_JIT_ICALL_mono_arch_throw_corlib_exception;
patch_info->ip.i = code - cfg->native_code;
if (FORCE_INDIR_CALL || cfg->method->dynamic) {
ppc_load_func (code, PPC_CALL_REG, 0);
ppc_mtctr (code, PPC_CALL_REG);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
} else {
ppc_bl (code, 0);
}
break;
}
default:
/* do nothing */
break;
}
}
set_code_cursor (cfg, code);
}
#endif
#if DEAD_CODE
static int
try_offset_access (void *value, guint32 idx)
{
register void* me __asm__ ("r2");
void ***p = (void***)((char*)me + 284);
int idx1 = idx / 32;
int idx2 = idx % 32;
if (!p [idx1])
return 0;
if (value != p[idx1][idx2])
return 0;
return 1;
}
#endif
void
mono_arch_finish_init (void)
{
}
#define CMP_SIZE (PPC_LOAD_SEQUENCE_LENGTH + 4)
#define BR_SIZE 4
#define LOADSTORE_SIZE 4
#define JUMP_IMM_SIZE 12
#define JUMP_IMM32_SIZE (PPC_LOAD_SEQUENCE_LENGTH + 8)
#define ENABLE_WRONG_METHOD_CHECK 0
gpointer
mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoIMTCheckItem **imt_entries, int count,
gpointer fail_tramp)
{
int i;
int size = 0;
guint8 *code, *start;
MonoMemoryManager *mem_manager = m_class_get_mem_manager (vtable->klass);
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
if (item->is_equals) {
if (item->check_target_idx) {
if (!item->compare_done)
item->chunk_size += CMP_SIZE;
if (item->has_target_code)
item->chunk_size += BR_SIZE + JUMP_IMM32_SIZE;
else
item->chunk_size += LOADSTORE_SIZE + BR_SIZE + JUMP_IMM_SIZE;
} else {
if (fail_tramp) {
item->chunk_size += CMP_SIZE + BR_SIZE + JUMP_IMM32_SIZE * 2;
if (!item->has_target_code)
item->chunk_size += LOADSTORE_SIZE;
} else {
item->chunk_size += LOADSTORE_SIZE + JUMP_IMM_SIZE;
#if ENABLE_WRONG_METHOD_CHECK
item->chunk_size += CMP_SIZE + BR_SIZE + 4;
#endif
}
}
} else {
item->chunk_size += CMP_SIZE + BR_SIZE;
imt_entries [item->check_target_idx]->compare_done = TRUE;
}
size += item->chunk_size;
}
/* the initial load of the vtable address */
size += PPC_LOAD_SEQUENCE_LENGTH + LOADSTORE_SIZE;
if (fail_tramp) {
code = (guint8 *)mini_alloc_generic_virtual_trampoline (vtable, size);
} else {
code = mono_mem_manager_code_reserve (mem_manager, size);
}
start = code;
/*
* We need to save and restore r12 because it might be
* used by the caller as the vtable register, so
* clobbering it will trip up the magic trampoline.
*
* FIXME: Get rid of this by making sure that r12 is
* not used as the vtable register in interface calls.
*/
ppc_stptr (code, ppc_r12, PPC_RET_ADDR_OFFSET, ppc_sp);
ppc_load (code, ppc_r12, (gsize)(& (vtable->vtable [0])));
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
item->code_target = code;
if (item->is_equals) {
if (item->check_target_idx) {
if (!item->compare_done) {
ppc_load (code, ppc_r0, (gsize)item->key);
ppc_compare_log (code, 0, MONO_ARCH_IMT_REG, ppc_r0);
}
item->jmp_code = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
if (item->has_target_code) {
ppc_load_ptr (code, ppc_r0, item->value.target_code);
} else {
ppc_ldptr (code, ppc_r0, (sizeof (target_mgreg_t) * item->value.vtable_slot), ppc_r12);
ppc_ldptr (code, ppc_r12, PPC_RET_ADDR_OFFSET, ppc_sp);
}
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
} else {
if (fail_tramp) {
ppc_load (code, ppc_r0, (gulong)item->key);
ppc_compare_log (code, 0, MONO_ARCH_IMT_REG, ppc_r0);
item->jmp_code = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
if (item->has_target_code) {
ppc_load_ptr (code, ppc_r0, item->value.target_code);
} else {
g_assert (vtable);
ppc_load_ptr (code, ppc_r0, & (vtable->vtable [item->value.vtable_slot]));
ppc_ldptr_indexed (code, ppc_r0, 0, ppc_r0);
}
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
ppc_patch (item->jmp_code, code);
ppc_load_ptr (code, ppc_r0, fail_tramp);
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
item->jmp_code = NULL;
} else {
/* enable the commented code to assert on wrong method */
#if ENABLE_WRONG_METHOD_CHECK
ppc_load (code, ppc_r0, (guint32)item->key);
ppc_compare_log (code, 0, MONO_ARCH_IMT_REG, ppc_r0);
item->jmp_code = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0);
#endif
ppc_ldptr (code, ppc_r0, (sizeof (target_mgreg_t) * item->value.vtable_slot), ppc_r12);
ppc_ldptr (code, ppc_r12, PPC_RET_ADDR_OFFSET, ppc_sp);
ppc_mtctr (code, ppc_r0);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
#if ENABLE_WRONG_METHOD_CHECK
ppc_patch (item->jmp_code, code);
ppc_break (code);
item->jmp_code = NULL;
#endif
}
}
} else {
ppc_load (code, ppc_r0, (gulong)item->key);
ppc_compare_log (code, 0, MONO_ARCH_IMT_REG, ppc_r0);
item->jmp_code = code;
ppc_bc (code, PPC_BR_FALSE, PPC_BR_LT, 0);
}
}
/* patch the branches to get to the target items */
for (i = 0; i < count; ++i) {
MonoIMTCheckItem *item = imt_entries [i];
if (item->jmp_code) {
if (item->check_target_idx) {
ppc_patch (item->jmp_code, imt_entries [item->check_target_idx]->code_target);
}
}
}
if (!fail_tramp)
UnlockedAdd (&mono_stats.imt_trampolines_size, code - start);
g_assert (code - start <= size);
mono_arch_flush_icache (start, size);
MONO_PROFILER_RAISE (jit_code_buffer, (start, code - start, MONO_PROFILER_CODE_BUFFER_IMT_TRAMPOLINE, NULL));
mono_tramp_info_register (mono_tramp_info_create (NULL, start, code - start, NULL, NULL), mem_manager);
return start;
}
MonoMethod*
mono_arch_find_imt_method (host_mgreg_t *regs, guint8 *code)
{
host_mgreg_t *r = (host_mgreg_t*)regs;
return (MonoMethod*)(gsize) r [MONO_ARCH_IMT_REG];
}
MonoVTable*
mono_arch_find_static_call_vtable (host_mgreg_t *regs, guint8 *code)
{
return (MonoVTable*)(gsize) regs [MONO_ARCH_RGCTX_REG];
}
GSList*
mono_arch_get_cie_program (void)
{
GSList *l = NULL;
mono_add_unwind_op_def_cfa (l, (guint8*)NULL, (guint8*)NULL, ppc_r1, 0);
return l;
}
MonoInst*
mono_arch_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args)
{
MonoInst *ins = NULL;
int opcode = 0;
if (cmethod->klass == mono_class_try_get_math_class ()) {
if (strcmp (cmethod->name, "Sqrt") == 0) {
opcode = OP_SQRT;
} else if (strcmp (cmethod->name, "Abs") == 0 && fsig->params [0]->type == MONO_TYPE_R8) {
opcode = OP_ABS;
}
if (opcode && fsig->param_count == 1) {
MONO_INST_NEW (cfg, ins, opcode);
ins->type = STACK_R8;
ins->dreg = mono_alloc_freg (cfg);
ins->sreg1 = args [0]->dreg;
MONO_ADD_INS (cfg->cbb, ins);
}
/* Check for Min/Max for (u)int(32|64) */
opcode = 0;
if (cpu_hw_caps & PPC_ISA_2_03) {
if (strcmp (cmethod->name, "Min") == 0) {
if (fsig->params [0]->type == MONO_TYPE_I4)
opcode = OP_IMIN;
if (fsig->params [0]->type == MONO_TYPE_U4)
opcode = OP_IMIN_UN;
#ifdef __mono_ppc64__
else if (fsig->params [0]->type == MONO_TYPE_I8)
opcode = OP_LMIN;
else if (fsig->params [0]->type == MONO_TYPE_U8)
opcode = OP_LMIN_UN;
#endif
} else if (strcmp (cmethod->name, "Max") == 0) {
if (fsig->params [0]->type == MONO_TYPE_I4)
opcode = OP_IMAX;
if (fsig->params [0]->type == MONO_TYPE_U4)
opcode = OP_IMAX_UN;
#ifdef __mono_ppc64__
else if (fsig->params [0]->type == MONO_TYPE_I8)
opcode = OP_LMAX;
else if (fsig->params [0]->type == MONO_TYPE_U8)
opcode = OP_LMAX_UN;
#endif
}
/*
* TODO: Floating point version with fsel, but fsel has
* some peculiarities (need a scratch reg unless
* comparing with 0, NaN/Inf behaviour (then MathF too)
*/
}
if (opcode && fsig->param_count == 2) {
MONO_INST_NEW (cfg, ins, opcode);
ins->type = fsig->params [0]->type == MONO_TYPE_I4 ? STACK_I4 : STACK_I8;
ins->dreg = mono_alloc_ireg (cfg);
ins->sreg1 = args [0]->dreg;
ins->sreg2 = args [1]->dreg;
MONO_ADD_INS (cfg->cbb, ins);
}
/* Rounding instructions */
opcode = 0;
if ((cpu_hw_caps & PPC_ISA_2X) && (fsig->param_count == 1) && (fsig->params [0]->type == MONO_TYPE_R8)) {
/*
* XXX: sysmath.c and the POWER ISA documentation for
* frin[.] imply rounding is a little more complicated
* than expected; the semantics are slightly different,
* so just "frin." isn't a drop-in replacement. Floor,
* Truncate, and Ceiling seem to work normally though.
* (also, no float versions of these ops, but frsp
* could be preprended?)
*/
//if (!strcmp (cmethod->name, "Round"))
// opcode = OP_ROUND;
if (!strcmp (cmethod->name, "Floor"))
opcode = OP_PPC_FLOOR;
else if (!strcmp (cmethod->name, "Ceiling"))
opcode = OP_PPC_CEIL;
else if (!strcmp (cmethod->name, "Truncate"))
opcode = OP_PPC_TRUNC;
if (opcode != 0) {
MONO_INST_NEW (cfg, ins, opcode);
ins->type = STACK_R8;
ins->dreg = mono_alloc_freg (cfg);
ins->sreg1 = args [0]->dreg;
MONO_ADD_INS (cfg->cbb, ins);
}
}
}
if (cmethod->klass == mono_class_try_get_mathf_class ()) {
if (strcmp (cmethod->name, "Sqrt") == 0) {
opcode = OP_SQRTF;
} /* XXX: POWER has no single-precision normal FPU abs? */
if (opcode && fsig->param_count == 1) {
MONO_INST_NEW (cfg, ins, opcode);
ins->type = STACK_R4;
ins->dreg = mono_alloc_freg (cfg);
ins->sreg1 = args [0]->dreg;
MONO_ADD_INS (cfg->cbb, ins);
}
}
return ins;
}
host_mgreg_t
mono_arch_context_get_int_reg (MonoContext *ctx, int reg)
{
if (reg == ppc_r1)
return (host_mgreg_t)(gsize)MONO_CONTEXT_GET_SP (ctx);
return ctx->regs [reg];
}
host_mgreg_t*
mono_arch_context_get_int_reg_address (MonoContext *ctx, int reg)
{
if (reg == ppc_r1)
return (host_mgreg_t)(gsize)&MONO_CONTEXT_GET_SP (ctx);
return &ctx->regs [reg];
}
guint32
mono_arch_get_patch_offset (guint8 *code)
{
return 0;
}
/*
* mono_aot_emit_load_got_addr:
*
* Emit code to load the got address.
* On PPC, the result is placed into r30.
*/
guint8*
mono_arch_emit_load_got_addr (guint8 *start, guint8 *code, MonoCompile *cfg, MonoJumpInfo **ji)
{
ppc_bl (code, 1);
ppc_mflr (code, ppc_r30);
if (cfg)
mono_add_patch_info (cfg, code - start, MONO_PATCH_INFO_GOT_OFFSET, NULL);
else
*ji = mono_patch_info_list_prepend (*ji, code - start, MONO_PATCH_INFO_GOT_OFFSET, NULL);
/* arch_emit_got_address () patches this */
#if defined(TARGET_POWERPC64)
ppc_nop (code);
ppc_nop (code);
ppc_nop (code);
ppc_nop (code);
#else
ppc_load32 (code, ppc_r0, 0);
ppc_add (code, ppc_r30, ppc_r30, ppc_r0);
#endif
set_code_cursor (cfg, code);
return code;
}
/*
* mono_ppc_emit_load_aotconst:
*
* Emit code to load the contents of the GOT slot identified by TRAMP_TYPE and
* TARGET from the mscorlib GOT in full-aot code.
* On PPC, the GOT address is assumed to be in r30, and the result is placed into
* r12.
*/
guint8*
mono_arch_emit_load_aotconst (guint8 *start, guint8 *code, MonoJumpInfo **ji, MonoJumpInfoType tramp_type, gconstpointer target)
{
/* Load the mscorlib got address */
ppc_ldptr (code, ppc_r12, sizeof (target_mgreg_t), ppc_r30);
*ji = mono_patch_info_list_prepend (*ji, code - start, tramp_type, target);
/* arch_emit_got_access () patches this */
ppc_load32 (code, ppc_r0, 0);
ppc_ldptr_indexed (code, ppc_r12, ppc_r12, ppc_r0);
return code;
}
/* Soft Debug support */
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
/*
* BREAKPOINTS
*/
/*
* mono_arch_set_breakpoint:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_set_breakpoint (MonoJitInfo *ji, guint8 *ip)
{
guint8 *code = ip;
guint8 *orig_code = code;
ppc_load_sequence (code, ppc_r12, (gsize)bp_trigger_page);
ppc_ldptr (code, ppc_r12, 0, ppc_r12);
g_assert (code - orig_code == BREAKPOINT_SIZE);
mono_arch_flush_icache (orig_code, code - orig_code);
}
/*
* mono_arch_clear_breakpoint:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_clear_breakpoint (MonoJitInfo *ji, guint8 *ip)
{
guint8 *code = ip;
int i;
for (i = 0; i < BREAKPOINT_SIZE / 4; ++i)
ppc_nop (code);
mono_arch_flush_icache (ip, code - ip);
}
/*
* mono_arch_is_breakpoint_event:
*
* See mini-amd64.c for docs.
*/
gboolean
mono_arch_is_breakpoint_event (void *info, void *sigctx)
{
siginfo_t* sinfo = (siginfo_t*) info;
/* Sometimes the address is off by 4 */
if (sinfo->si_addr >= bp_trigger_page && (guint8*)sinfo->si_addr <= (guint8*)bp_trigger_page + 128)
return TRUE;
else
return FALSE;
}
/*
* mono_arch_skip_breakpoint:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_skip_breakpoint (MonoContext *ctx, MonoJitInfo *ji)
{
/* skip the ldptr */
MONO_CONTEXT_SET_IP (ctx, (guint8*)MONO_CONTEXT_GET_IP (ctx) + 4);
}
/*
* SINGLE STEPPING
*/
/*
* mono_arch_start_single_stepping:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_start_single_stepping (void)
{
mono_mprotect (ss_trigger_page, mono_pagesize (), 0);
}
/*
* mono_arch_stop_single_stepping:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_stop_single_stepping (void)
{
mono_mprotect (ss_trigger_page, mono_pagesize (), MONO_MMAP_READ);
}
/*
* mono_arch_is_single_step_event:
*
* See mini-amd64.c for docs.
*/
gboolean
mono_arch_is_single_step_event (void *info, void *sigctx)
{
siginfo_t* sinfo = (siginfo_t*) info;
/* Sometimes the address is off by 4 */
if (sinfo->si_addr >= ss_trigger_page && (guint8*)sinfo->si_addr <= (guint8*)ss_trigger_page + 128)
return TRUE;
else
return FALSE;
}
/*
* mono_arch_skip_single_step:
*
* See mini-amd64.c for docs.
*/
void
mono_arch_skip_single_step (MonoContext *ctx)
{
/* skip the ldptr */
MONO_CONTEXT_SET_IP (ctx, (guint8*)MONO_CONTEXT_GET_IP (ctx) + 4);
}
/*
* mono_arch_create_seq_point_info:
*
* See mini-amd64.c for docs.
*/
SeqPointInfo*
mono_arch_get_seq_point_info (guint8 *code)
{
NOT_IMPLEMENTED;
return NULL;
}
#endif
gboolean
mono_arch_opcode_supported (int opcode)
{
switch (opcode) {
case OP_ATOMIC_ADD_I4:
case OP_ATOMIC_CAS_I4:
#ifdef TARGET_POWERPC64
case OP_ATOMIC_ADD_I8:
case OP_ATOMIC_CAS_I8:
#endif
return TRUE;
default:
return FALSE;
}
}
gpointer
mono_arch_load_function (MonoJitICallId jit_icall_id)
{
gpointer target = NULL;
switch (jit_icall_id) {
#undef MONO_AOT_ICALL
#define MONO_AOT_ICALL(x) case MONO_JIT_ICALL_ ## x: target = (gpointer)x; break;
MONO_AOT_ICALL (mono_ppc_throw_exception)
}
return target;
}
|
JimmyCushnie/runtime
|
src/coreclr/vm/encee.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// EnCee.h
//
//
// Defines the core VM data structures and methods for support EditAndContinue
//
// ======================================================================================
#ifndef EnC_H
#define EnC_H
#include "ceeload.h"
#include "field.h"
#include "class.h"
#ifdef EnC_SUPPORTED
class FieldDesc;
struct EnCAddedField;
struct EnCAddedStaticField;
class EnCFieldDesc;
class EnCEEClassData;
typedef DPTR(EnCAddedField) PTR_EnCAddedField;
typedef DPTR(EnCAddedStaticField) PTR_EnCAddedStaticField;
typedef DPTR(EnCFieldDesc) PTR_EnCFieldDesc;
typedef DPTR(EnCEEClassData) PTR_EnCEEClassData;
//---------------------------------------------------------------------------------------
//
// EnCFieldDesc - A field descriptor for fields added by EnC
//
// Notes: We need to track some additional data for added fields, since they can't
// simply be glued onto existing object instances like any other field.
//
// For each field added, there is a single instance of this object tied to the type where
// the field was added.
//
class EnCFieldDesc : public FieldDesc
{
public:
// Initialize just the bare minimum necessary now.
// We'll do a proper FieldDesc initialization later when Fixup is called.
void Init( mdFieldDef token, BOOL fIsStatic);
// Compute the address of this field for a specific object
void *GetAddress( void *o);
// Returns true if Fixup still needs to be called
BOOL NeedsFixup()
{
LIMITED_METHOD_DAC_CONTRACT;
return m_bNeedsFixup;
}
// Used to properly configure the FieldDesc after it has been added
// This may do things like load classes (which can trigger a GC), and so can only be
// done after the process has resumed execution.
VOID Fixup(mdFieldDef token)
{
WRAPPER_NO_CONTRACT;
EEClass::FixupFieldDescForEnC(GetEnclosingMethodTable(), this, token);
m_bNeedsFixup = FALSE;
}
// Gets a pointer to the field's contents (assuming this is a static field) if it's
// available or NULL otherwise
EnCAddedStaticField *GetStaticFieldData();
// Gets a pointer to the field's contents (assuming this is a static field) if it's
// available or allocates space for it and returns the address to the allocated field
// Returns a valid address or throws OOM
EnCAddedStaticField * GetOrAllocateStaticFieldData();
private:
// True if Fixup() has been called on this instance
BOOL m_bNeedsFixup;
// For static fields, pointer to where the field value is held
PTR_EnCAddedStaticField m_pStaticFieldData;
};
// EnCAddedFieldElement
// A node in the linked list representing fields added to a class with EnC
typedef DPTR(struct EnCAddedFieldElement) PTR_EnCAddedFieldElement;
struct EnCAddedFieldElement
{
// Pointer to the next element in the list
PTR_EnCAddedFieldElement m_next;
// Details about this field
EnCFieldDesc m_fieldDesc;
// Initialize this entry.
// Basically just sets a couple fields to default values.
// We'll have to go back later and call Fixup on the fieldDesc.
void Init(mdFieldDef token, BOOL fIsStatic)
{
WRAPPER_NO_CONTRACT;
m_next = NULL;
m_fieldDesc.Init(token, fIsStatic);
}
};
//---------------------------------------------------------------------------------------
//
// EnCEEClassData - EnC specific information about this class
//
class EnCEEClassData
{
public:
#ifndef DACCESS_COMPILE
// Initialize all the members
// pClass - the EEClass we're tracking EnC data for
void Init(MethodTable * pMT)
{
LIMITED_METHOD_CONTRACT;
m_pMT = pMT;
m_dwNumAddedInstanceFields = 0;
m_dwNumAddedStaticFields = 0;
m_pAddedInstanceFields = NULL;
m_pAddedStaticFields = NULL;
}
#endif
// Adds the provided new field to the appropriate linked list and updates the appropriate count
void AddField(EnCAddedFieldElement *pAddedField);
// Get the number of instance fields that have been added to this class.
// Since we can only add private fields, these fields can't be seen from any other class but this one.
int GetAddedInstanceFields()
{
SUPPORTS_DAC;
return m_dwNumAddedInstanceFields;
}
// Get the number of static fields that have been added to this class.
int GetAddedStaticFields()
{
SUPPORTS_DAC;
return m_dwNumAddedStaticFields;
}
// Get the methodtable that this EnC data refers to
MethodTable * GetMethodTable()
{
LIMITED_METHOD_DAC_CONTRACT;
return m_pMT;
}
#ifdef DACCESS_COMPILE
void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
#endif
private:
friend class EEClass;
friend class EncApproxFieldDescIterator;
// The class that this EnC data refers to
PTR_MethodTable m_pMT;
// The number of instance fields that have been added to this class
int m_dwNumAddedInstanceFields;
// The number of static fields that have been added to this class
int m_dwNumAddedStaticFields;
// Linked list of EnCFieldDescs for all the added instance fields
PTR_EnCAddedFieldElement m_pAddedInstanceFields;
// Linked list of EnCFieldDescs for all the added static fields
PTR_EnCAddedFieldElement m_pAddedStaticFields;
};
//---------------------------------------------------------------------------------------
//
// EditAndContinueModule - specialization of the Module class which adds EnC support
//
// Assumptions:
//
// Notes:
//
class EditAndContinueModule : public Module
{
VPTR_VTABLE_CLASS(EditAndContinueModule, Module)
// keep track of the number of changes - this is used to apply a version number
// to an updated function. The version number for a function is the overall edit count,
// ie the number of times ApplyChanges has been called, not the number of times that
// function itself has been edited.
int m_applyChangesCount;
// Holds a table of EnCEEClassData object for classes in this module that have been modified
CUnorderedArray<EnCEEClassData*, 5> m_ClassList;
#ifndef DACCESS_COMPILE
// Return the minimum permissable address for new IL to be stored at
// This can't be less than the current load address because then we'd
// have negative RVAs.
BYTE *GetEnCBase() { return (BYTE *) GetFile()->GetManagedFileContents(); }
#endif // DACCESS_COMPILE
private:
// Constructor is invoked only by Module::Create
friend Module *Module::Create(Assembly *pAssembly, mdToken moduleRef, PEFile *file, AllocMemTracker *pamTracker);
EditAndContinueModule(Assembly *pAssembly, mdToken moduleRef, PEFile *file);
protected:
#ifndef DACCESS_COMPILE
// Initialize the module
virtual void Initialize(AllocMemTracker *pamTracker, LPCWSTR szName = NULL);
#endif
public:
#ifndef DACCESS_COMPILE
// Destruct the module when it's finished being unloaded
// Note that due to the loader's allocation mechanism, C++ consturctors and destructors
// wouldn't be called.
virtual void Destruct();
#endif
virtual BOOL IsEditAndContinueCapable() const { return TRUE; }
// Apply an EnC edit
HRESULT ApplyEditAndContinue(DWORD cbMetadata,
BYTE *pMetadata,
DWORD cbIL,
BYTE *pIL);
// Called when a method has been modified (new IL)
HRESULT UpdateMethod(MethodDesc *pMethod);
// Called when a new method has been added to the module's metadata
HRESULT AddMethod(mdMethodDef token);
// Called when a new field has been added to the module's metadata
HRESULT AddField(mdFieldDef token);
// JIT the new version of a function for EnC
PCODE JitUpdatedFunction(MethodDesc *pMD, T_CONTEXT *pContext);
// Remap execution to the latest version of an edited method
HRESULT ResumeInUpdatedFunction(MethodDesc *pMD,
void *oldDebuggerFuncHandle,
SIZE_T newILOffset,
T_CONTEXT *pContext);
// Modify the thread context for EnC remap and resume execution
void FixContextAndResume(MethodDesc *pMD,
void *oldDebuggerFuncHandle,
T_CONTEXT *pContext,
EECodeInfo *pOldCodeInfo,
EECodeInfo *pNewCodeInfo);
// Get a pointer to the value of a field added by EnC or return NULL if it doesn't exist
PTR_CBYTE ResolveField(OBJECTREF thisPointer,
EnCFieldDesc *pFD);
// Get a pointer to the value of a field added by EnC. Allocates if it doesn't exist, so we'll
// return a valid address or throw OOM
PTR_CBYTE ResolveOrAllocateField(OBJECTREF thisPointer,
EnCFieldDesc * pFD);
// Get class-specific EnC data for a class in this module
// Note: For DAC build, getOnly must be TRUE
PTR_EnCEEClassData GetEnCEEClassData(MethodTable * pMT, BOOL getOnly = FALSE);
// Get the number of times edits have been applied to this module
int GetApplyChangesCount()
{
return m_applyChangesCount;
}
#ifdef DACCESS_COMPILE
virtual void EnumMemoryRegions(CLRDataEnumMemoryFlags flags,
bool enumThis);
#endif
};
// Information about an instance field value added by EnC
// When an instance field is added to an object, we will lazily create an EnCAddedField
// for EACH instance of that object, but there will be a single EnCFieldDesc.
//
// Note that if we were concerned about the overhead when there are lots of instances of
// an object, we could slim this down to just the m_FieldData field by storing a pointer
// to a growable array of these in the EnCSyncBlockInfo, instead of using a linked list, and
// have the EnCFieldDesc specify a field index number.
//
struct EnCAddedField
{
// This field data hangs off the SyncBlock in a linked list.
// This is the pointer to the next field in the list.
PTR_EnCAddedField m_pNext;
// Pointer to the fieldDesc describing which field this refers to
PTR_EnCFieldDesc m_pFieldDesc;
// A dependent handle whose primary object points to the object instance which has been modified,
// and whose secondary object points to an EnC helper object containing a reference to the field value.
OBJECTHANDLE m_FieldData;
// Allocates a new EnCAddedField and hook it up to the object
static EnCAddedField *Allocate(OBJECTREF thisPointer, EnCFieldDesc *pFD);
};
// Information about a static field value added by EnC
// We can't change the MethodTable, so these are hung off the FieldDesc
// Note that the actual size of this type is variable.
struct EnCAddedStaticField
{
// Pointer back to the fieldDesc describing which field this refers to
// This isn't strictly necessary since our callers always know it, but the overhead
// in minimal (per type, not per instance) and this is cleaner and permits an extra sanity check.
PTR_EnCFieldDesc m_pFieldDesc;
// For primitive types, this is the beginning of the actual value.
// For reference types and user-defined value types, it's the beginning of a pointer
// to the object.
// Note that this is intentionally the last field of this structure as it is variably-sized.
// NOTE: It looks like we did the same thing for instance fields in EnCAddedField but then simplified
// it by always storing just an OBJREF which may point to a boxed value type. I suggest we do the
// same here unless we can demonstrate that the extra indirection makes a noticable perf difference
// in scenarios which are important for EnC.
BYTE m_FieldData;
// Get a pointer to the contents of this field
PTR_CBYTE GetFieldData();
// Allocate a new instance appropriate for the specified field
static EnCAddedStaticField *Allocate(EnCFieldDesc *pFD);
};
// EnCSyncBlockInfo lives off an object's SyncBlock and contains a lazily-created linked
// list of the values of all the fields added to the object by EnC
//
// Note that much of the logic here would probably belong better in EnCAddedField since it is
// specific to the implementation there. Perhaps this should ideally just be a container
// that holds a bunch of EnCAddedFields and can iterate over them and map from EnCFieldDesc
// to them.
class EnCSyncBlockInfo
{
public:
// Initialize the list
EnCSyncBlockInfo() :
m_pList(PTR_NULL)
{
}
// Get a pointer to the data in a specific field on this object or return NULL if it
// doesn't exist
PTR_CBYTE ResolveField(OBJECTREF thisPointer,
EnCFieldDesc * pFieldDesc);
// Get a pointer to the data in a specific field on this object. We'll allocate if it doesn't already
// exist, so we'll only fail on OOM
PTR_CBYTE ResolveOrAllocateField(OBJECTREF thisPointer, EnCFieldDesc *pFD);
// Free the data used by this field value. Called after the object instance the
// fields belong to is collected.
void Cleanup();
private:
// Gets the address of an EnC field accounting for its type: valuetype, class or primitive
PTR_CBYTE GetEnCFieldAddrFromHelperFieldDesc(FieldDesc * pHelperFieldDesc,
OBJECTREF pHelper,
EnCFieldDesc * pFD);
// Pointer to the head of the list
PTR_EnCAddedField m_pList;
};
// The DPTR is actually defined in syncblk.h to make it visible to SyncBlock
// typedef DPTR(EnCSyncBlockInfo) PTR_EnCSyncBlockInfo;
#endif // !EnC_SUPPORTED
//---------------------------------------------------------------------------------------
//
// EncApproxFieldDescIterator - Iterates through all fields of a class including ones
// added by EnC
//
// Notes:
// This is just like ApproxFieldDescIterator, but it also includes EnC fields if
// EnC is supported.
// This does not include inherited fields.
// The order the fields returned here is unspecified.
//
// We don't bother maintaining an accurate total and remaining field count like
// ApproxFieldDescIterator because none of our clients need it. But it would
// be easy to add this using the data from m_classData
//
class EncApproxFieldDescIterator
{
public:
#ifdef EnC_SUPPORTED
// Create and initialize the iterator
EncApproxFieldDescIterator(MethodTable *pMT, int iteratorType, BOOL fixupEnC);
// Get the next fieldDesc (either EnC or non-EnC)
PTR_FieldDesc Next();
int Count();
#else
// Non-EnC version - simple wrapper
EncApproxFieldDescIterator(MethodTable *pMT, int iteratorType, BOOL fixupEnC) :
m_nonEnCIter( pMT, iteratorType ) {}
PTR_FieldDesc Next() { WRAPPER_NO_CONTRACT; return m_nonEnCIter.Next(); }
int Count() { WRAPPER_NO_CONTRACT; return m_nonEnCIter.Count(); }
#endif // EnC_SUPPORTED
int GetIteratorType()
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
return m_nonEnCIter.GetIteratorType();
}
private:
// The iterator for the non-EnC fields.
// We delegate to this for alll non-EnC specific stuff
ApproxFieldDescIterator m_nonEnCIter;
#ifdef EnC_SUPPORTED
// Return the next available EnC FieldDesc or NULL when done
PTR_EnCFieldDesc NextEnC();
// True if our client wants us to fixup any EnC fieldDescs before handing them back
BOOL m_fixupEnC;
// A count of how many EnC fields have been returned so far
int m_encFieldsReturned;
// The current pointer into one of the EnC field lists when enumerating EnC fields
PTR_EnCAddedFieldElement m_pCurrListElem;
// EnC specific data for the class of interest.
// NULL if EnC is disabled or this class doesn't have any EnC data
PTR_EnCEEClassData m_encClassData;
#endif
};
#endif // #ifndef EnC_H
|
JimmyCushnie/runtime
|
src/coreclr/jit/emitxarch.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#if defined(TARGET_XARCH)
/************************************************************************/
/* Public inline informational methods */
/************************************************************************/
public:
inline static bool isGeneralRegister(regNumber reg)
{
return (reg <= REG_INT_LAST);
}
inline static bool isFloatReg(regNumber reg)
{
return (reg >= REG_FP_FIRST && reg <= REG_FP_LAST);
}
inline static bool isDoubleReg(regNumber reg)
{
return isFloatReg(reg);
}
/************************************************************************/
/* Routines that compute the size of / encode instructions */
/************************************************************************/
// code_t is a type used to accumulate bits of opcode + prefixes. On amd64, it must be 64 bits
// to support the REX prefixes. On both x86 and amd64, it must be 64 bits to support AVX, with
// its 3-byte VEX prefix.
typedef unsigned __int64 code_t;
struct CnsVal
{
ssize_t cnsVal;
bool cnsReloc;
};
UNATIVE_OFFSET emitInsSize(code_t code, bool includeRexPrefixSize);
UNATIVE_OFFSET emitInsSizeSV(code_t code, int var, int dsp);
UNATIVE_OFFSET emitInsSizeSV(instrDesc* id, code_t code, int var, int dsp);
UNATIVE_OFFSET emitInsSizeSV(instrDesc* id, code_t code, int var, int dsp, int val);
UNATIVE_OFFSET emitInsSizeRR(instrDesc* id, code_t code);
UNATIVE_OFFSET emitInsSizeRR(instrDesc* id, code_t code, int val);
UNATIVE_OFFSET emitInsSizeRR(instruction ins, regNumber reg1, regNumber reg2, emitAttr attr);
UNATIVE_OFFSET emitInsSizeAM(instrDesc* id, code_t code);
UNATIVE_OFFSET emitInsSizeAM(instrDesc* id, code_t code, int val);
UNATIVE_OFFSET emitInsSizeCV(instrDesc* id, code_t code);
UNATIVE_OFFSET emitInsSizeCV(instrDesc* id, code_t code, int val);
BYTE* emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst);
BYTE* emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = nullptr);
BYTE* emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = nullptr);
BYTE* emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = nullptr);
BYTE* emitOutputR(BYTE* dst, instrDesc* id);
BYTE* emitOutputRI(BYTE* dst, instrDesc* id);
BYTE* emitOutputRR(BYTE* dst, instrDesc* id);
BYTE* emitOutputIV(BYTE* dst, instrDesc* id);
BYTE* emitOutputRRR(BYTE* dst, instrDesc* id);
BYTE* emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* id);
unsigned emitOutputRexOrVexPrefixIfNeeded(instruction ins, BYTE* dst, code_t& code);
unsigned emitGetRexPrefixSize(instruction ins);
unsigned emitGetVexPrefixSize(instruction ins, emitAttr attr);
unsigned emitGetPrefixSize(code_t code, bool includeRexPrefixSize);
unsigned emitGetAdjustedSize(instruction ins, emitAttr attr, code_t code);
unsigned insEncodeReg012(instruction ins, regNumber reg, emitAttr size, code_t* code);
unsigned insEncodeReg345(instruction ins, regNumber reg, emitAttr size, code_t* code);
code_t insEncodeReg3456(instruction ins, regNumber reg, emitAttr size, code_t code);
unsigned insEncodeRegSIB(instruction ins, regNumber reg, code_t* code);
code_t insEncodeMRreg(instruction ins, code_t code);
code_t insEncodeRMreg(instruction ins, code_t code);
code_t insEncodeMRreg(instruction ins, regNumber reg, emitAttr size, code_t code);
code_t insEncodeRRIb(instruction ins, regNumber reg, emitAttr size);
code_t insEncodeOpreg(instruction ins, regNumber reg, emitAttr size);
unsigned insSSval(unsigned scale);
static bool IsSSEInstruction(instruction ins);
static bool IsSSEOrAVXInstruction(instruction ins);
static bool IsAVXOnlyInstruction(instruction ins);
static bool IsFMAInstruction(instruction ins);
static bool IsAVXVNNIInstruction(instruction ins);
static bool IsBMIInstruction(instruction ins);
static regNumber getBmiRegNumber(instruction ins);
static regNumber getSseShiftRegNumber(instruction ins);
bool IsAVXInstruction(instruction ins) const;
code_t insEncodeMIreg(instruction ins, regNumber reg, emitAttr size, code_t code);
code_t AddRexWPrefix(instruction ins, code_t code);
code_t AddRexRPrefix(instruction ins, code_t code);
code_t AddRexXPrefix(instruction ins, code_t code);
code_t AddRexBPrefix(instruction ins, code_t code);
code_t AddRexPrefix(instruction ins, code_t code);
bool EncodedBySSE38orSSE3A(instruction ins);
bool Is4ByteSSEInstruction(instruction ins);
static bool IsMovInstruction(instruction ins);
bool IsRedundantMov(
instruction ins, insFormat fmt, emitAttr size, regNumber dst, regNumber src, bool canIgnoreSideEffects);
static bool IsJccInstruction(instruction ins);
static bool IsJmpInstruction(instruction ins);
bool AreUpper32BitsZero(regNumber reg);
bool AreFlagsSetToZeroCmp(regNumber reg, emitAttr opSize, genTreeOps treeOps);
bool hasRexPrefix(code_t code)
{
#ifdef TARGET_AMD64
const code_t REX_PREFIX_MASK = 0xFF00000000LL;
return (code & REX_PREFIX_MASK) != 0;
#else // !TARGET_AMD64
return false;
#endif // !TARGET_AMD64
}
// 3-byte VEX prefix starts with byte 0xC4
#define VEX_PREFIX_MASK_3BYTE 0xFF000000000000ULL
#define VEX_PREFIX_CODE_3BYTE 0xC4000000000000ULL
bool TakesVexPrefix(instruction ins) const;
static bool TakesRexWPrefix(instruction ins, emitAttr attr);
// Returns true if the instruction encoding already contains VEX prefix
bool hasVexPrefix(code_t code)
{
return (code & VEX_PREFIX_MASK_3BYTE) == VEX_PREFIX_CODE_3BYTE;
}
code_t AddVexPrefix(instruction ins, code_t code, emitAttr attr);
code_t AddVexPrefixIfNeeded(instruction ins, code_t code, emitAttr size)
{
if (TakesVexPrefix(ins))
{
code = AddVexPrefix(ins, code, size);
}
return code;
}
code_t AddVexPrefixIfNeededAndNotPresent(instruction ins, code_t code, emitAttr size)
{
if (TakesVexPrefix(ins) && !hasVexPrefix(code))
{
code = AddVexPrefix(ins, code, size);
}
return code;
}
bool useVEXEncodings;
bool UseVEXEncoding() const
{
return useVEXEncodings;
}
void SetUseVEXEncoding(bool value)
{
useVEXEncodings = value;
}
bool containsAVXInstruction = false;
bool ContainsAVX()
{
return containsAVXInstruction;
}
void SetContainsAVX(bool value)
{
containsAVXInstruction = value;
}
bool contains256bitAVXInstruction = false;
bool Contains256bitAVX()
{
return contains256bitAVXInstruction;
}
void SetContains256bitAVX(bool value)
{
contains256bitAVXInstruction = value;
}
bool IsDstDstSrcAVXInstruction(instruction ins);
bool IsDstSrcSrcAVXInstruction(instruction ins);
bool DoesWriteZeroFlag(instruction ins);
bool DoesResetOverflowAndCarryFlags(instruction ins);
bool IsFlagsAlwaysModified(instrDesc* id);
bool IsThreeOperandAVXInstruction(instruction ins)
{
return (IsDstDstSrcAVXInstruction(ins) || IsDstSrcSrcAVXInstruction(ins));
}
bool isAvxBlendv(instruction ins)
{
return ins == INS_vblendvps || ins == INS_vblendvpd || ins == INS_vpblendvb;
}
bool isSse41Blendv(instruction ins)
{
return ins == INS_blendvps || ins == INS_blendvpd || ins == INS_pblendvb;
}
bool isPrefetch(instruction ins)
{
return (ins == INS_prefetcht0) || (ins == INS_prefetcht1) || (ins == INS_prefetcht2) || (ins == INS_prefetchnta);
}
/************************************************************************/
/* Debug-only routines to display instructions */
/************************************************************************/
#ifdef DEBUG
const char* emitFPregName(unsigned reg, bool varName = true);
void emitDispReloc(ssize_t value);
void emitDispAddrMode(instrDesc* id, bool noDetail = false);
void emitDispShift(instruction ins, int cnt = 0);
void emitDispIns(instrDesc* id,
bool isNew,
bool doffs,
bool asmfm,
unsigned offs = 0,
BYTE* code = nullptr,
size_t sz = 0,
insGroup* ig = nullptr);
const char* emitXMMregName(unsigned reg);
const char* emitYMMregName(unsigned reg);
#endif
/************************************************************************/
/* Private members that deal with target-dependent instr. descriptors */
/************************************************************************/
private:
void emitSetAmdDisp(instrDescAmd* id, ssize_t dsp);
instrDesc* emitNewInstrAmd(emitAttr attr, ssize_t dsp);
instrDesc* emitNewInstrAmdCns(emitAttr attr, ssize_t dsp, int cns);
instrDesc* emitNewInstrCallDir(int argCnt,
VARSET_VALARG_TP GCvars,
regMaskTP gcrefRegs,
regMaskTP byrefRegs,
emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize));
instrDesc* emitNewInstrCallInd(int argCnt,
ssize_t disp,
VARSET_VALARG_TP GCvars,
regMaskTP gcrefRegs,
regMaskTP byrefRegs,
emitAttr retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize));
void emitGetInsCns(instrDesc* id, CnsVal* cv);
ssize_t emitGetInsAmdCns(instrDesc* id, CnsVal* cv);
void emitGetInsDcmCns(instrDesc* id, CnsVal* cv);
ssize_t emitGetInsAmdAny(instrDesc* id);
/************************************************************************/
/* Private helpers for instruction output */
/************************************************************************/
private:
insFormat emitInsModeFormat(instruction ins, insFormat base, insFormat FPld, insFormat FPst);
bool emitVerifyEncodable(instruction ins, emitAttr size, regNumber reg1, regNumber reg2 = REG_NA);
bool emitInsCanOnlyWriteSSE2OrAVXReg(instrDesc* id);
#if FEATURE_FIXED_OUT_ARGS
void emitAdjustStackDepthPushPop(instruction ins)
{
}
void emitAdjustStackDepth(instruction ins, ssize_t val)
{
}
#else // !FEATURE_FIXED_OUT_ARGS
void emitAdjustStackDepthPushPop(instruction ins);
void emitAdjustStackDepth(instruction ins, ssize_t val);
#endif // !FEATURE_FIXED_OUT_ARGS
/*****************************************************************************
*
* Convert between an index scale in bytes to a smaller encoding used for
* storage in instruction descriptors.
*/
inline emitter::opSize emitEncodeScale(size_t scale)
{
assert(scale == 1 || scale == 2 || scale == 4 || scale == 8);
return emitSizeEncode[scale - 1];
}
inline emitAttr emitDecodeScale(unsigned ensz)
{
assert(ensz < 4);
return emitter::emitSizeDecode[ensz];
}
/************************************************************************/
/* The public entry points to output instructions */
/************************************************************************/
public:
void emitLoopAlign(unsigned short paddingBytes);
void emitLongLoopAlign(unsigned short alignmentBoundary);
void emitIns(instruction ins);
void emitIns(instruction ins, emitAttr attr);
void emitInsRMW(instruction inst, emitAttr attr, GenTreeStoreInd* storeInd, GenTree* src);
void emitInsRMW(instruction inst, emitAttr attr, GenTreeStoreInd* storeInd);
void emitIns_Nop(unsigned size);
void emitIns_I(instruction ins, emitAttr attr, cnsval_ssize_t val);
void emitIns_R(instruction ins, emitAttr attr, regNumber reg);
void emitIns_C(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fdlHnd, int offs);
void emitIns_R_I(instruction ins, emitAttr attr, regNumber reg, ssize_t val DEBUGARG(GenTreeFlags gtFlags = GTF_EMPTY));
void emitIns_Mov(instruction ins, emitAttr attr, regNumber dstReg, regNumber srgReg, bool canSkip);
void emitIns_R_R(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2);
void emitIns_R_R_I(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, int ival);
void emitIns_AR(instruction ins, emitAttr attr, regNumber base, int offs);
void emitIns_AR_R_R(instruction ins, emitAttr attr, regNumber op2Reg, regNumber op3Reg, regNumber base, int offs);
void emitIns_R_A(instruction ins, emitAttr attr, regNumber reg1, GenTreeIndir* indir);
void emitIns_R_A_I(instruction ins, emitAttr attr, regNumber reg1, GenTreeIndir* indir, int ival);
void emitIns_R_AR_I(instruction ins, emitAttr attr, regNumber reg1, regNumber base, int offs, int ival);
void emitIns_R_C_I(instruction ins, emitAttr attr, regNumber reg1, CORINFO_FIELD_HANDLE fldHnd, int offs, int ival);
void emitIns_R_S_I(instruction ins, emitAttr attr, regNumber reg1, int varx, int offs, int ival);
void emitIns_R_R_A(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, GenTreeIndir* indir);
void emitIns_R_R_AR(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, regNumber base, int offs);
void emitIns_R_AR_R(instruction ins,
emitAttr attr,
regNumber reg1,
regNumber reg2,
regNumber base,
regNumber index,
int scale,
int offs);
void emitIns_R_R_C(
instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, CORINFO_FIELD_HANDLE fldHnd, int offs);
void emitIns_R_R_S(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, int varx, int offs);
void emitIns_R_R_R(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, regNumber reg3);
void emitIns_R_R_A_I(
instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, GenTreeIndir* indir, int ival, insFormat fmt);
void emitIns_R_R_AR_I(
instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, regNumber base, int offs, int ival);
void emitIns_S_R_I(instruction ins, emitAttr attr, int varNum, int offs, regNumber reg, int ival);
void emitIns_A_R_I(instruction ins, emitAttr attr, GenTreeIndir* indir, regNumber reg, int imm);
void emitIns_R_R_C_I(
instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, CORINFO_FIELD_HANDLE fldHnd, int offs, int ival);
void emitIns_R_R_R_I(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, regNumber reg3, int ival);
void emitIns_R_R_S_I(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, int varx, int offs, int ival);
void emitIns_R_R_A_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op3Reg, GenTreeIndir* indir);
void emitIns_R_R_AR_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op3Reg, regNumber base, int offs);
void emitIns_R_R_C_R(instruction ins,
emitAttr attr,
regNumber targetReg,
regNumber op1Reg,
regNumber op3Reg,
CORINFO_FIELD_HANDLE fldHnd,
int offs);
void emitIns_R_R_S_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op3Reg, int varx, int offs);
void emitIns_R_R_R_R(instruction ins, emitAttr attr, regNumber reg1, regNumber reg2, regNumber reg3, regNumber reg4);
void emitIns_S(instruction ins, emitAttr attr, int varx, int offs);
void emitIns_S_R(instruction ins, emitAttr attr, regNumber ireg, int varx, int offs);
void emitIns_R_S(instruction ins, emitAttr attr, regNumber ireg, int varx, int offs);
void emitIns_S_I(instruction ins, emitAttr attr, int varx, int offs, int val);
void emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO_FIELD_HANDLE fldHnd, int offs);
void emitIns_C_R(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, regNumber reg, int offs);
void emitIns_C_I(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fdlHnd, int offs, int val);
void emitIns_IJ(emitAttr attr, regNumber reg, unsigned base);
void emitIns_J_S(instruction ins, emitAttr attr, BasicBlock* dst, int varx, int offs);
void emitIns_R_L(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg);
void emitIns_R_D(instruction ins, emitAttr attr, unsigned offs, regNumber reg);
void emitIns_I_AR(instruction ins, emitAttr attr, int val, regNumber reg, int offs);
void emitIns_I_AI(instruction ins, emitAttr attr, int val, ssize_t disp);
void emitIns_R_AR(instruction ins, emitAttr attr, regNumber reg, regNumber base, int disp);
void emitIns_R_AI(instruction ins, emitAttr attr, regNumber ireg, ssize_t disp);
void emitIns_AR_R(instruction ins, emitAttr attr, regNumber reg, regNumber base, cnsval_ssize_t disp);
void emitIns_AI_R(instruction ins, emitAttr attr, regNumber ireg, ssize_t disp);
void emitIns_I_ARR(instruction ins, emitAttr attr, int val, regNumber reg, regNumber rg2, int disp);
void emitIns_R_ARR(instruction ins, emitAttr attr, regNumber reg, regNumber base, regNumber index, int disp);
void emitIns_ARR_R(instruction ins, emitAttr attr, regNumber reg, regNumber base, regNumber index, int disp);
void emitIns_I_ARX(instruction ins, emitAttr attr, int val, regNumber reg, regNumber rg2, unsigned mul, int disp);
void emitIns_R_ARX(
instruction ins, emitAttr attr, regNumber reg, regNumber base, regNumber index, unsigned scale, int disp);
void emitIns_ARX_R(instruction ins,
emitAttr attr,
regNumber reg,
regNumber base,
regNumber index,
unsigned scale,
cnsval_ssize_t disp);
void emitIns_I_AX(instruction ins, emitAttr attr, int val, regNumber reg, unsigned mul, int disp);
void emitIns_R_AX(instruction ins, emitAttr attr, regNumber ireg, regNumber reg, unsigned mul, int disp);
void emitIns_AX_R(instruction ins, emitAttr attr, regNumber ireg, regNumber reg, unsigned mul, int disp);
void emitIns_SIMD_R_R_I(instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, int ival);
void emitIns_SIMD_R_R_A(instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, GenTreeIndir* indir);
void emitIns_SIMD_R_R_AR(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber base, int offset);
void emitIns_SIMD_R_R_C(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, CORINFO_FIELD_HANDLE fldHnd, int offs);
void emitIns_SIMD_R_R_R(instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg);
void emitIns_SIMD_R_R_S(instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, int varx, int offs);
#ifdef FEATURE_HW_INTRINSICS
void emitIns_SIMD_R_R_A_I(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, GenTreeIndir* indir, int ival);
void emitIns_SIMD_R_R_AR_I(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber base, int ival);
void emitIns_SIMD_R_R_C_I(instruction ins,
emitAttr attr,
regNumber targetReg,
regNumber op1Reg,
CORINFO_FIELD_HANDLE fldHnd,
int offs,
int ival);
void emitIns_SIMD_R_R_R_I(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, int ival);
void emitIns_SIMD_R_R_S_I(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, int varx, int offs, int ival);
void emitIns_SIMD_R_R_R_A(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, GenTreeIndir* indir);
void emitIns_SIMD_R_R_R_AR(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, regNumber base);
void emitIns_SIMD_R_R_R_C(instruction ins,
emitAttr attr,
regNumber targetReg,
regNumber op1Reg,
regNumber op2Reg,
CORINFO_FIELD_HANDLE fldHnd,
int offs);
void emitIns_SIMD_R_R_R_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, regNumber op3Reg);
void emitIns_SIMD_R_R_R_S(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, int varx, int offs);
void emitIns_SIMD_R_R_A_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, GenTreeIndir* indir);
void emitIns_SIMD_R_R_AR_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, regNumber base);
void emitIns_SIMD_R_R_C_R(instruction ins,
emitAttr attr,
regNumber targetReg,
regNumber op1Reg,
regNumber op2Reg,
CORINFO_FIELD_HANDLE fldHnd,
int offs);
void emitIns_SIMD_R_R_S_R(
instruction ins, emitAttr attr, regNumber targetReg, regNumber op1Reg, regNumber op2Reg, int varx, int offs);
#endif // FEATURE_HW_INTRINSICS
enum EmitCallType
{
EC_FUNC_TOKEN, // Direct call to a helper/static/nonvirtual/global method
EC_FUNC_TOKEN_INDIR, // Indirect call to a helper/static/nonvirtual/global method
EC_FUNC_ADDR, // Direct call to an absolute address
EC_FUNC_VIRTUAL, // Call to a virtual method (using the vtable)
EC_INDIR_R, // Indirect call via register
EC_INDIR_SR, // Indirect call via stack-reference (local var)
EC_INDIR_C, // Indirect call via static class var
EC_INDIR_ARD, // Indirect call via an addressing mode
EC_COUNT
};
// clang-format off
void emitIns_Call(EmitCallType callType,
CORINFO_METHOD_HANDLE methHnd,
INDEBUG_LDISASM_COMMA(CORINFO_SIG_INFO* sigInfo) // used to report call sites to the EE
void* addr,
ssize_t argSize,
emitAttr retSize
MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(emitAttr secondRetSize),
VARSET_VALARG_TP ptrVars,
regMaskTP gcrefRegs,
regMaskTP byrefRegs,
IL_OFFSETX ilOffset = BAD_IL_OFFSET,
regNumber ireg = REG_NA,
regNumber xreg = REG_NA,
unsigned xmul = 0,
ssize_t disp = 0,
bool isJump = false);
// clang-format on
#ifdef TARGET_AMD64
// Is the last instruction emitted a call instruction?
bool emitIsLastInsCall();
// Insert a NOP at the end of the the current instruction group if the last emitted instruction was a 'call',
// because the next instruction group will be an epilog.
void emitOutputPreEpilogNOP();
#endif // TARGET_AMD64
/*****************************************************************************
*
* Given a jump, return true if it's a conditional jump.
*/
inline bool emitIsCondJump(instrDesc* jmp)
{
instruction ins = jmp->idIns();
assert(jmp->idInsFmt() == IF_LABEL);
return (ins != INS_call && ins != INS_jmp);
}
/*****************************************************************************
*
* Given a jump, return true if it's an unconditional jump.
*/
inline bool emitIsUncondJump(instrDesc* jmp)
{
instruction ins = jmp->idIns();
assert(jmp->idInsFmt() == IF_LABEL);
return (ins == INS_jmp);
}
#endif // TARGET_XARCH
|
JimmyCushnie/runtime
|
src/coreclr/vm/diagnosticserveradapter.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#ifndef __DIAGNOSTIC_SERVER_ADAPTER_H__
#define __DIAGNOSTIC_SERVER_ADAPTER_H__
#if defined(FEATURE_PERFTRACING) && !(CROSSGEN_COMPILE)
#include "ds-server.h"
class DiagnosticServerAdapter final
{
public:
static inline bool Initialize()
{
return ds_server_init();
}
static inline bool Shutdown()
{
return ds_server_shutdown();
}
NOINLINE static void PauseForDiagnosticsMonitor()
{
return ds_server_pause_for_diagnostics_monitor();
}
static void ResumeRuntimeStartup()
{
return ds_server_resume_runtime_startup();
}
static bool IsPausedInRuntimeStartup()
{
return ds_server_is_paused_in_startup();
}
};
#endif // FEATURE_PERFTRACING && !CROSSGEN_COMPILE
#endif // __DIAGNOSTIC_SERVER_ADAPTER_H__
|
JimmyCushnie/runtime
|
src/mono/mono/mini/interp/mintops.h
|
/**
* \file
*/
#ifndef __INTERPRETER_MINTOPS_H
#define __INTERPRETER_MINTOPS_H
#include <glib.h>
typedef enum
{
MintOpNoArgs,
MintOpShortInt,
MintOpUShortInt,
MintOpInt,
MintOpLongInt,
MintOpFloat,
MintOpDouble,
MintOpBranch,
MintOpShortBranch,
MintOpSwitch,
MintOpMethodToken,
MintOpFieldToken,
MintOpClassToken,
MintOpTwoShorts,
MintOpShortAndInt,
MintOpShortAndShortBranch,
MintOpPair2,
MintOpPair3,
MintOpPair4
} MintOpArgType;
#define OPDEF(a,b,c,d,e,f) a,
typedef enum {
#include "mintops.def"
MINT_LASTOP
} MintOpcode;
#undef OPDEF
#if NO_UNALIGNED_ACCESS
# if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define READ32(x) (((guint16 *)(x)) [0] | ((guint16 *)(x)) [1] << 16)
#define READ64(x) ((guint64)((guint16 *)(x)) [0] | \
(guint64)((guint16 *)(x)) [1] << 16 | \
(guint64)((guint16 *)(x)) [2] << 32 | \
(guint64)((guint16 *)(x)) [3] << 48)
# else
#define READ32(x) (((guint16 *)(x)) [0] << 16 | ((guint16 *)(x)) [1])
#define READ64(x) ((guint64)((guint16 *)(x)) [0] << 48 | \
(guint64)((guint16 *)(x)) [1] << 32 | \
(guint64)((guint16 *)(x)) [2] << 16 | \
(guint64)((guint16 *)(x)) [3])
# endif
#else /* unaligned access OK */
#define READ32(x) (*(guint32 *)(x))
#define READ64(x) (*(guint64 *)(x))
#endif
#define MINT_SWITCH_LEN(n) (4 + (n) * 2)
#define MINT_IS_MOV(op) ((op) >= MINT_MOV_I1 && (op) <= MINT_MOV_VT)
#define MINT_IS_CONDITIONAL_BRANCH(op) ((op) >= MINT_BRFALSE_I4 && (op) <= MINT_BLT_UN_R8_S)
#define MINT_IS_UNOP_CONDITIONAL_BRANCH(op) ((op) >= MINT_BRFALSE_I4 && (op) <= MINT_BRTRUE_R8_S)
#define MINT_IS_BINOP_CONDITIONAL_BRANCH(op) ((op) >= MINT_BEQ_I4 && (op) <= MINT_BLT_UN_R8_S)
#define MINT_IS_CALL(op) ((op) >= MINT_CALL && (op) <= MINT_JIT_CALL)
#define MINT_IS_PATCHABLE_CALL(op) ((op) >= MINT_CALL && (op) <= MINT_VCALL)
#define MINT_IS_LDC_I4(op) ((op) >= MINT_LDC_I4_M1 && (op) <= MINT_LDC_I4)
#define MINT_IS_LDC_I8(op) ((op) >= MINT_LDC_I8_0 && (op) <= MINT_LDC_I8)
#define MINT_IS_UNOP(op) ((op) >= MINT_ADD1_I4 && (op) <= MINT_CEQ0_I4)
#define MINT_IS_BINOP(op) ((op) >= MINT_ADD_I4 && (op) <= MINT_CLT_UN_R8)
#define MINT_IS_BINOP_SHIFT(op) ((op) >= MINT_SHR_UN_I4 && (op) <= MINT_SHR_I8)
#define MINT_IS_LDFLD(op) ((op) >= MINT_LDFLD_I1 && (op) <= MINT_LDFLD_O)
#define MINT_IS_STFLD(op) ((op) >= MINT_STFLD_I1 && (op) <= MINT_STFLD_O)
#define MINT_IS_LDIND_INT(op) ((op) >= MINT_LDIND_I1 && (op) <= MINT_LDIND_I8)
#define MINT_IS_STIND_INT(op) ((op) >= MINT_STIND_I1 && (op) <= MINT_STIND_I8)
#define MINT_CALL_ARGS 2
#define MINT_CALL_ARGS_SREG -2
#define MINT_MOV_PAIRS_MAX 4
extern unsigned char const mono_interp_oplen[];
extern int const mono_interp_op_dregs [];
extern int const mono_interp_op_sregs [];
extern MintOpArgType const mono_interp_opargtype[];
extern const guint16* mono_interp_dis_mintop_len (const guint16 *ip);
// This, instead of an array of pointers, to optimize away a pointer and a relocation per string.
extern const guint16 mono_interp_opname_offsets [ ];
typedef struct MonoInterpOpnameCharacters MonoInterpOpnameCharacters;
extern const MonoInterpOpnameCharacters mono_interp_opname_characters;
const char*
mono_interp_opname (int op);
#endif
|
JimmyCushnie/runtime
|
src/coreclr/inc/clrconfig.h
|
<filename>src/coreclr/inc/clrconfig.h
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
// --------------------------------------------------------------------------------------------------
// CLRConfig.h
//
//
// Unified method of accessing configuration values.
// To define a flag, add an entry in the table in file:CLRConfigValues.h.
// --------------------------------------------------------------------------------------------------
#include "utilcode.h"
#include "holder.h"
#ifndef __CLRConfig_h__
#define __CLRConfig_h__
class CLRConfig
{
public:
// Setting each option results in some change to the config value.
enum class LookupOptions
{
// Default options.
Default = 0,
// If set, do not prepend prefix when doing environment variable lookup.
DontPrependPrefix = 0x1,
// Remove any whitespace at beginning and end of value. (Only applicable for
// *string* configuration values.)
TrimWhiteSpaceFromStringValue = 0x2,
// The configuration should be parsed using a 10 radix as opposed to the
// default of 16.
ParseIntegerAsBase10 = 0x4,
};
// Struct used to store information about where/how to find a Config DWORD.
// NOTE: Please do NOT create instances of this struct. Use the macros in file:CLRConfigValues.h instead.
typedef struct ConfigDWORDInfo
{
LPCWSTR name;
DWORD defaultValue;
LookupOptions options;
} ConfigDWORDInfo;
// Struct used to store information about where/how to find a Config String.
// NOTE: Please do NOT create instances of this struct. Use the macros in file:CLRConfigValues.h instead.
typedef struct ConfigStringInfo
{
LPCWSTR name;
LookupOptions options;
} ConfigStringInfo;
//
// Declaring structs using the macro table in CLRConfigValues.h
//
// These macros declare ConfigDWORDInfo structs.
#define RETAIL_CONFIG_DWORD_INFO(symbol, name, defaultValue, description) \
static const ConfigDWORDInfo symbol;
#define RETAIL_CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) \
static const ConfigDWORDInfo symbol;
// These macros declare ConfigStringInfo structs.
#define RETAIL_CONFIG_STRING_INFO(symbol, name, description) \
static const ConfigStringInfo symbol;
#define RETAIL_CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \
static const ConfigStringInfo symbol;
//
// Debug versions of the macros
//
#ifdef _DEBUG
#define CONFIG_DWORD_INFO(symbol, name, defaultValue, description) \
static const ConfigDWORDInfo symbol;
#define CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions) \
static const ConfigDWORDInfo symbol;
#define CONFIG_STRING_INFO(symbol, name, description) \
static const ConfigStringInfo symbol;
#define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions) \
static const ConfigStringInfo symbol;
#else
#define CONFIG_DWORD_INFO(symbol, name, defaultValue, description)
#define CONFIG_DWORD_INFO_EX(symbol, name, defaultValue, description, lookupOptions)
#define CONFIG_STRING_INFO(symbol, name, description)
#define CONFIG_STRING_INFO_EX(symbol, name, description, lookupOptions)
#endif // _DEBUG
// Now that we have defined what what the macros in file:CLRConfigValues.h mean, include it to generate the code.
#include "clrconfigvalues.h"
#undef RETAIL_CONFIG_DWORD_INFO
#undef RETAIL_CONFIG_STRING_INFO
#undef RETAIL_CONFIG_DWORD_INFO_EX
#undef RETAIL_CONFIG_STRING_INFO_EX
#undef CONFIG_DWORD_INFO
#undef CONFIG_STRING_INFO
#undef CONFIG_DWORD_INFO_EX
#undef CONFIG_STRING_INFO_EX
//
// Methods to do config value (DWORD and String) lookups.
//
static BOOL IsConfigEnabled(const ConfigDWORDInfo & info);
// Look up a DWORD config value.
static DWORD GetConfigValue(const ConfigDWORDInfo & info);
// Look up a DWORD config value.
static DWORD GetConfigValue(const ConfigDWORDInfo & info, /* [Out] */ bool *isDefault);
// Look up a DWORD config value.
static DWORD GetConfigValue(const ConfigDWORDInfo & info, DWORD defaultValue);
// Look up a string config value.
// You own the string that's returned.
static LPWSTR GetConfigValue(const ConfigStringInfo & info);
// Look up a string config value, passing it out through a pointer reference. Reports out of memory
// errors (HRESULT E_OUTOFMEMORY).
// You own the string that's returned.
static HRESULT GetConfigValue(const ConfigStringInfo & info, __deref_out_z LPWSTR * outVal);
//
// Check whether an option is specified (e.g. explicitly listed) in any of the CLRConfig
// locations: environment or registry (with or without COMPlus_) or any config file.
// The result is therefore a conservative approximation (some settings do not actually
// take effect everywhere and no setting is valid both with and without COMPlus_)
//
static BOOL IsConfigOptionSpecified(LPCWSTR name);
// Free a string returned by GetConfigValue
static void FreeConfigString(__in __in_z LPWSTR name);
// Initialize the configuration.
static void Initialize();
};
inline CLRConfig::LookupOptions operator|(CLRConfig::LookupOptions lhs, CLRConfig::LookupOptions rhs)
{
return static_cast<CLRConfig::LookupOptions>(static_cast<DWORD>(lhs) | static_cast<DWORD>(rhs));
}
inline CLRConfig::LookupOptions operator&(CLRConfig::LookupOptions lhs, CLRConfig::LookupOptions rhs)
{
return static_cast<CLRConfig::LookupOptions>(static_cast<DWORD>(lhs) & static_cast<DWORD>(rhs));
}
typedef Wrapper<LPWSTR, DoNothing, CLRConfig::FreeConfigString, NULL> CLRConfigStringHolder;
#endif //__CLRConfig_h__
|
JimmyCushnie/runtime
|
src/coreclr/vm/stublink.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// STUBLINK.H
//
//
// A StubLinker object provides a way to link several location-independent
// code sources into one executable stub, resolving references,
// and choosing the shortest possible instruction size. The StubLinker
// abstracts out the notion of a "reference" so it is completely CPU
// independent. This StubLinker is intended not only to create method
// stubs but to create the PCode-marshaling stubs for Native/Direct.
//
// A StubLinker's typical life-cycle is:
//
// 1. Create a new StubLinker (it accumulates state for the stub being
// generated.)
// 2. Emit code bytes and references (requiring fixups) into the StubLinker.
// 3. Call the Link() method to produce the final stub.
// 4. Destroy the StubLinker.
//
// StubLinkers are not multithread-aware: they're intended to be
// used entirely on a single thread. Also, StubLinker's report errors
// using COMPlusThrow. StubLinker's do have a destructor: to prevent
// C++ object unwinding from clashing with COMPlusThrow,
// you must use COMPLUSCATCH to ensure the StubLinker's cleanup in the
// event of an exception: the following code would do it:
//
// StubLinker stublink;
// Inner();
//
//
// // Have to separate into inner function because VC++ forbids
// // mixing __try & local objects in the same function.
// void Inner() {
// COMPLUSTRY {
// ... do stuff ...
// pLinker->Link();
// } COMPLUSCATCH {
// }
// }
//
// This file should only be included via the platform-specific cgencpu.h.
#include "cgensys.h"
#ifndef __stublink_h__
#define __stublink_h__
#include "crst.h"
#include "util.hpp"
#include "eecontract.h"
//-------------------------------------------------------------------------
// Forward refs
//-------------------------------------------------------------------------
class InstructionFormat;
class Stub;
class CheckDuplicatedStructLayouts;
class CodeBasedStubCache;
struct CodeLabel;
struct CodeRun;
struct LabelRef;
struct CodeElement;
struct IntermediateUnwindInfo;
#if !defined(TARGET_X86) && !defined(TARGET_UNIX)
#define STUBLINKER_GENERATES_UNWIND_INFO
#endif // !TARGET_X86 && !TARGET_UNIX
#ifdef STUBLINKER_GENERATES_UNWIND_INFO
typedef DPTR(struct StubUnwindInfoHeaderSuffix) PTR_StubUnwindInfoHeaderSuffix;
struct StubUnwindInfoHeaderSuffix
{
UCHAR nUnwindInfoSize; // Size of unwind info in bytes
};
// Variable-sized struct that preceeds a Stub when the stub requires unwind
// information. Followed by a StubUnwindInfoHeaderSuffix.
typedef DPTR(struct StubUnwindInfoHeader) PTR_StubUnwindInfoHeader;
struct StubUnwindInfoHeader
{
PTR_StubUnwindInfoHeader pNext;
T_RUNTIME_FUNCTION FunctionEntry;
UNWIND_INFO UnwindInfo; // variable length
// Computes the size needed for this variable-sized struct.
static SIZE_T ComputeSize(UINT nUnwindInfoSize);
void Init ();
bool IsRegistered ();
};
// List of stub address ranges, in increasing address order.
struct StubUnwindInfoHeapSegment
{
PBYTE pbBaseAddress;
SIZE_T cbSegment;
StubUnwindInfoHeader *pUnwindHeaderList;
StubUnwindInfoHeapSegment *pNext;
#ifdef HOST_64BIT
class UnwindInfoTable* pUnwindInfoTable; // Used to publish unwind info to ETW stack crawler
#endif
};
VOID UnregisterUnwindInfoInLoaderHeap (UnlockedLoaderHeap *pHeap);
#endif // STUBLINKER_GENERATES_UNWIND_INFO
//-------------------------------------------------------------------------
// A non-multithreaded object that fixes up and emits one executable stub.
//-------------------------------------------------------------------------
class StubLinker
{
public:
//---------------------------------------------------------------
// Construction
//---------------------------------------------------------------
StubLinker();
//---------------------------------------------------------------
// Create a new undefined label. Label must be assigned to a code
// location using EmitLabel() prior to final linking.
// Throws exception on failure.
//---------------------------------------------------------------
CodeLabel* NewCodeLabel();
//---------------------------------------------------------------
// Create a new undefined label for which we want the absolute
// address, not offset. Label must be assigned to a code
// location using EmitLabel() prior to final linking.
// Throws exception on failure.
//---------------------------------------------------------------
CodeLabel* NewAbsoluteCodeLabel();
//---------------------------------------------------------------
// Combines NewCodeLabel() and EmitLabel() for convenience.
// Throws exception on failure.
//---------------------------------------------------------------
CodeLabel* EmitNewCodeLabel();
//---------------------------------------------------------------
// Returns final location of label as an offset from the start
// of the stub. Can only be called after linkage.
//---------------------------------------------------------------
UINT32 GetLabelOffset(CodeLabel *pLabel);
//---------------------------------------------------------------
// Append code bytes.
//---------------------------------------------------------------
VOID EmitBytes(const BYTE *pBytes, UINT numBytes);
VOID Emit8 (unsigned __int8 u8);
VOID Emit16(unsigned __int16 u16);
VOID Emit32(unsigned __int32 u32);
VOID Emit64(unsigned __int64 u64);
VOID EmitPtr(const VOID *pval);
//---------------------------------------------------------------
// Emit a UTF8 string
//---------------------------------------------------------------
VOID EmitUtf8(LPCUTF8 pUTF8)
{
WRAPPER_NO_CONTRACT;
LPCUTF8 p = pUTF8;
while (*(p++)) {
//nothing
}
EmitBytes((const BYTE *)pUTF8, (unsigned int)(p-pUTF8-1));
}
//---------------------------------------------------------------
// Append an instruction containing a reference to a label.
//
// target - the label being referenced.
// instructionFormat - a platform-specific InstructionFormat object
// that gives properties about the reference.
// variationCode - uninterpreted data passed to the pInstructionFormat methods.
//---------------------------------------------------------------
VOID EmitLabelRef(CodeLabel* target, const InstructionFormat & instructionFormat, UINT variationCode);
//---------------------------------------------------------------
// Sets the label to point to the current "instruction pointer"
// It is invalid to call EmitLabel() twice on
// the same label.
//---------------------------------------------------------------
VOID EmitLabel(CodeLabel* pCodeLabel);
//---------------------------------------------------------------
// Emits the patch label for the stub.
// Throws exception on failure.
//---------------------------------------------------------------
void EmitPatchLabel();
//---------------------------------------------------------------
// Create a new label to an external address.
// Throws exception on failure.
//---------------------------------------------------------------
CodeLabel* NewExternalCodeLabel(LPVOID pExternalAddress);
CodeLabel* NewExternalCodeLabel(PCODE pExternalAddress)
{
return NewExternalCodeLabel((LPVOID)pExternalAddress);
}
//---------------------------------------------------------------
// Push and Pop can be used to keep track of stack growth.
// These should be adjusted by opcodes written to the stream.
//
// Note that popping & pushing stack size as opcodes are emitted
// is naive & may not be accurate in many cases,
// so complex stubs may have to manually adjust the stack size.
// However it should work for the vast majority of cases we care
// about.
//---------------------------------------------------------------
void Push(UINT size);
void Pop(UINT size);
INT GetStackSize() { LIMITED_METHOD_CONTRACT; return m_stackSize; }
void SetStackSize(SHORT size) { LIMITED_METHOD_CONTRACT; m_stackSize = size; }
void SetDataOnly(BOOL fDataOnly = TRUE) { LIMITED_METHOD_CONTRACT; m_fDataOnly = fDataOnly; }
#ifdef TARGET_ARM
void DescribeProlog(UINT cCalleeSavedRegs, UINT cbStackFrame, BOOL fPushArgRegs);
#elif defined(TARGET_ARM64)
void DescribeProlog(UINT cIntRegArgs, UINT cVecRegArgs, UINT cCalleeSavedRegs, UINT cbStackFrame);
UINT GetSavedRegArgsOffset();
UINT GetStackFrameSize();
#endif
//===========================================================================
// Unwind information
// Records location of preserved or parameter register
VOID UnwindSavedReg (UCHAR reg, ULONG SPRelativeOffset);
VOID UnwindPushedReg (UCHAR reg);
// Records "sub rsp, xxx"
VOID UnwindAllocStack (SHORT FrameSizeIncrement);
// Records frame pointer register
VOID UnwindSetFramePointer (UCHAR reg);
// In DEBUG, emits a call to m_pUnwindInfoCheckLabel (via
// EmitUnwindInfoCheckWorker). Code at that label will call to a
// helper that will attempt to RtlVirtualUnwind through the stub. The
// helper will preserve ALL registers.
VOID EmitUnwindInfoCheck();
#if defined(_DEBUG) && defined(STUBLINKER_GENERATES_UNWIND_INFO) && !defined(CROSSGEN_COMPILE)
protected:
// Injects a call to the given label.
virtual VOID EmitUnwindInfoCheckWorker (CodeLabel *pCheckLabel) { _ASSERTE(!"override me"); }
// Emits a call to a helper that will attempt to RtlVirtualUnwind
// through the stub. The helper will preserve ALL registers.
virtual VOID EmitUnwindInfoCheckSubfunction() { _ASSERTE(!"override me"); }
#endif
public:
//---------------------------------------------------------------
// Generate the actual stub. The returned stub has a refcount of 1.
// No other methods (other than the destructor) should be called
// after calling Link().
//
// Throws exception on failure.
//---------------------------------------------------------------
Stub *Link(LoaderHeap *heap, DWORD flags = 0);
private:
CodeElement *m_pCodeElements; // stored in *reverse* order
CodeLabel *m_pFirstCodeLabel; // linked list of CodeLabels
LabelRef *m_pFirstLabelRef; // linked list of references
CodeLabel *m_pPatchLabel; // label of stub patch offset
// currently just for multicast
// frames.
SHORT m_stackSize; // count of pushes/pops
CQuickHeap m_quickHeap; // throwaway heap for
// labels, and
// internals.
BOOL m_fDataOnly; // the stub contains only data - does not need FlushInstructionCache
#ifdef TARGET_ARM
protected:
BOOL m_fProlog; // True if DescribeProlog has been called
UINT m_cCalleeSavedRegs; // Count of callee saved registers (0 == none, 1 == r4, 2 ==
// r4-r5 etc. up to 8 == r4-r11)
UINT m_cbStackFrame; // Count of bytes in the stack frame (excl of saved regs)
BOOL m_fPushArgRegs; // If true, r0-r3 are saved before callee saved regs
#endif // TARGET_ARM
#ifdef TARGET_ARM64
protected:
BOOL m_fProlog; // True if DescribeProlog has been called
UINT m_cIntRegArgs; // Count of int register arguments (x0 - x7)
UINT m_cVecRegArgs; // Count of FP register arguments (v0 - v7)
UINT m_cCalleeSavedRegs; // Count of callee saved registers (x19 - x28)
UINT m_cbStackSpace; // Additional stack space for return buffer and stack alignment
#endif // TARGET_ARM64
#ifdef STUBLINKER_GENERATES_UNWIND_INFO
#ifdef _DEBUG
CodeLabel *m_pUnwindInfoCheckLabel; // subfunction to call to unwind info check helper.
// On AMD64, the prologue is restricted to 256
// bytes, so this reduces the size of the injected
// code from 14 to 5 bytes.
#endif
#ifdef TARGET_AMD64
IntermediateUnwindInfo *m_pUnwindInfoList;
UINT m_nUnwindSlots; // number of slots to allocate at end, == UNWIND_INFO::CountOfCodes
BOOL m_fHaveFramePointer; // indicates stack operations no longer need to be recorded
//
// Returns total UnwindInfoSize, including RUNTIME_FUNCTION entry
//
UINT UnwindInfoSize(UINT codeSize)
{
if (m_nUnwindSlots == 0) return 0;
return sizeof(T_RUNTIME_FUNCTION) + offsetof(UNWIND_INFO, UnwindCode) + m_nUnwindSlots * sizeof(UNWIND_CODE);
}
#endif // TARGET_AMD64
#ifdef TARGET_ARM
#define MAX_UNWIND_CODE_WORDS 5 /* maximum number of 32-bit words to store unwind codes */
// Cache information about the stack frame set up in the prolog and use it in the generation of the
// epilog.
private:
// Reserve fixed size block that's big enough to fit any unwind info we can have
static const int c_nUnwindInfoSize = sizeof(T_RUNTIME_FUNCTION) + sizeof(DWORD) + MAX_UNWIND_CODE_WORDS *4;
//
// Returns total UnwindInfoSize, including RUNTIME_FUNCTION entry
//
UINT UnwindInfoSize(UINT codeSize)
{
if (!m_fProlog) return 0;
return c_nUnwindInfoSize;
}
#endif // TARGET_ARM
#ifdef TARGET_ARM64
#define MAX_UNWIND_CODE_WORDS 5 /* maximum number of 32-bit words to store unwind codes */
private:
// Reserve fixed size block that's big enough to fit any unwind info we can have
static const int c_nUnwindInfoSize = sizeof(T_RUNTIME_FUNCTION) + sizeof(DWORD) + MAX_UNWIND_CODE_WORDS *4;
UINT UnwindInfoSize(UINT codeSize)
{
if (!m_fProlog) return 0;
return c_nUnwindInfoSize;
}
#endif // TARGET_ARM64
#endif // STUBLINKER_GENERATES_UNWIND_INFO
CodeRun *AppendNewEmptyCodeRun();
// Returns pointer to last CodeElement or NULL.
CodeElement *GetLastCodeElement()
{
LIMITED_METHOD_CONTRACT;
return m_pCodeElements;
}
// Appends a new CodeElement.
VOID AppendCodeElement(CodeElement *pCodeElement);
// Calculates the size of the stub code that is allocate
// immediately after the stub object. Returns the
// total size. GlobalSize contains the size without
// that data part.
virtual int CalculateSize(int* globalsize);
// Writes out the code element into memory following the
// stub object.
bool EmitStub(Stub* pStub, int globalsize, int totalSize, LoaderHeap* pHeap);
CodeRun *GetLastCodeRunIfAny();
bool EmitUnwindInfo(Stub* pStubRX, Stub* pStubRW, int globalsize, LoaderHeap* pHeap);
#if defined(TARGET_AMD64) && defined(STUBLINKER_GENERATES_UNWIND_INFO)
UNWIND_CODE *AllocUnwindInfo (UCHAR Op, UCHAR nExtraSlots = 0);
#endif // defined(TARGET_AMD64) && defined(STUBLINKER_GENERATES_UNWIND_INFO)
};
//************************************************************************
// CodeLabel
//************************************************************************
struct CodeLabel
{
// Link pointer for StubLink's list of labels
CodeLabel *m_next;
// if FALSE, label refers to some code within the same stub
// if TRUE, label refers to some externally supplied address.
BOOL m_fExternal;
// if TRUE, means we want the actual address of the label and
// not an offset to it
BOOL m_fAbsolute;
union {
// Internal
struct {
// Indicates the position of the label, expressed
// as an offset into a CodeRun.
CodeRun *m_pCodeRun;
UINT m_localOffset;
} i;
// External
struct {
LPVOID m_pExternalAddress;
} e;
};
};
enum NewStubFlags
{
NEWSTUB_FL_MULTICAST = 0x00000002,
NEWSTUB_FL_EXTERNAL = 0x00000004,
NEWSTUB_FL_LOADERHEAP = 0x00000008
};
//-------------------------------------------------------------------------
// An executable stub. These can only be created by the StubLinker().
// Each stub has a reference count (which is maintained in a thread-safe
// manner.) When the ref-count goes to zero, the stub automatically
// cleans itself up.
//-------------------------------------------------------------------------
typedef DPTR(class Stub) PTR_Stub;
typedef DPTR(PTR_Stub) PTR_PTR_Stub;
class Stub
{
friend class CheckDuplicatedStructLayouts;
friend class CheckAsmOffsets;
protected:
enum
{
MULTICAST_DELEGATE_BIT = 0x80000000,
EXTERNAL_ENTRY_BIT = 0x40000000,
LOADER_HEAP_BIT = 0x20000000,
UNWIND_INFO_BIT = 0x08000000,
PATCH_OFFSET_MASK = UNWIND_INFO_BIT - 1,
MAX_PATCH_OFFSET = PATCH_OFFSET_MASK + 1,
};
static_assert_no_msg(PATCH_OFFSET_MASK < UNWIND_INFO_BIT);
public:
//-------------------------------------------------------------------
// Inc the refcount.
//-------------------------------------------------------------------
VOID IncRef();
//-------------------------------------------------------------------
// Dec the refcount.
// Returns true if the count went to zero and the stub was deleted
//-------------------------------------------------------------------
BOOL DecRef();
//-------------------------------------------------------------------
// Used for throwing out unused stubs from stub caches. This
// method cannot be 100% accurate due to race conditions. This
// is ok because stub cache management is robust in the face
// of missed or premature cleanups.
//-------------------------------------------------------------------
BOOL HeuristicLooksOrphaned()
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(m_signature == kUsedStub);
return (m_refcount == 1);
}
//-------------------------------------------------------------------
// Used by the debugger to help step through stubs
//-------------------------------------------------------------------
BOOL IsMulticastDelegate()
{
LIMITED_METHOD_CONTRACT;
return (m_patchOffset & MULTICAST_DELEGATE_BIT) != 0;
}
//-------------------------------------------------------------------
// For stubs which execute user code, a patch offset needs to be set
// to tell the debugger how far into the stub code the debugger has
// to step until the frame is set up.
//-------------------------------------------------------------------
USHORT GetPatchOffset()
{
LIMITED_METHOD_CONTRACT;
return (USHORT)(m_patchOffset & PATCH_OFFSET_MASK);
}
void SetPatchOffset(USHORT offset)
{
LIMITED_METHOD_CONTRACT;
_ASSERTE(GetPatchOffset() == 0);
m_patchOffset |= offset;
_ASSERTE(GetPatchOffset() == offset);
}
TADDR GetPatchAddress()
{
WRAPPER_NO_CONTRACT;
return dac_cast<TADDR>(GetEntryPointInternal()) + GetPatchOffset();
}
//-------------------------------------------------------------------
// Unwind information.
//-------------------------------------------------------------------
#ifdef STUBLINKER_GENERATES_UNWIND_INFO
BOOL HasUnwindInfo()
{
LIMITED_METHOD_CONTRACT;
return (m_patchOffset & UNWIND_INFO_BIT) != 0;
}
StubUnwindInfoHeaderSuffix *GetUnwindInfoHeaderSuffix()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
}
CONTRACTL_END
_ASSERTE(HasUnwindInfo());
TADDR info = dac_cast<TADDR>(this);
return PTR_StubUnwindInfoHeaderSuffix
(info - sizeof(StubUnwindInfoHeaderSuffix));
}
StubUnwindInfoHeader *GetUnwindInfoHeader()
{
CONTRACTL
{
NOTHROW;
GC_NOTRIGGER;
FORBID_FAULT;
}
CONTRACTL_END
StubUnwindInfoHeaderSuffix *pSuffix = GetUnwindInfoHeaderSuffix();
TADDR suffixEnd = dac_cast<TADDR>(pSuffix) + sizeof(*pSuffix);
return PTR_StubUnwindInfoHeader(suffixEnd -
StubUnwindInfoHeader::ComputeSize(pSuffix->nUnwindInfoSize));
}
#endif // STUBLINKER_GENERATES_UNWIND_INFO
//-------------------------------------------------------------------
// Returns pointer to the start of the allocation containing this Stub.
//-------------------------------------------------------------------
TADDR GetAllocationBase();
//-------------------------------------------------------------------
// Return executable entrypoint after checking the ref count.
//-------------------------------------------------------------------
PCODE GetEntryPoint()
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
_ASSERTE(m_signature == kUsedStub);
_ASSERTE(m_refcount > 0);
TADDR pEntryPoint = dac_cast<TADDR>(GetEntryPointInternal());
#ifdef TARGET_ARM
#ifndef THUMB_CODE
#define THUMB_CODE 1
#endif
pEntryPoint |= THUMB_CODE;
#endif
return pEntryPoint;
}
UINT GetNumCodeBytes()
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
return m_numCodeBytes;
}
//-------------------------------------------------------------------
// Return start of the stub blob
//-------------------------------------------------------------------
PTR_CBYTE GetBlob()
{
WRAPPER_NO_CONTRACT;
SUPPORTS_DAC;
_ASSERTE(m_signature == kUsedStub);
_ASSERTE(m_refcount > 0);
return GetEntryPointInternal();
}
//-------------------------------------------------------------------
// Return the Stub as in GetEntryPoint and size of the stub+code in bytes
// WARNING: Depending on the stub kind this may be just Stub size as
// not all stubs have the info about the code size.
// It's the caller responsibility to determine that
//-------------------------------------------------------------------
static Stub* RecoverStubAndSize(PCODE pEntryPoint, DWORD *pSize)
{
CONTRACT(Stub*)
{
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
PRECONDITION(pEntryPoint && pSize);
}
CONTRACT_END;
Stub *pStub = Stub::RecoverStub(pEntryPoint);
*pSize = sizeof(Stub) + pStub->m_numCodeBytes;
RETURN pStub;
}
HRESULT CloneStub(BYTE *pBuffer, DWORD dwBufferSize)
{
LIMITED_METHOD_CONTRACT;
if ((pBuffer == NULL) ||
(dwBufferSize < (sizeof(*this) + m_numCodeBytes)))
{
return E_INVALIDARG;
}
memcpyNoGCRefs(pBuffer, this, sizeof(*this) + m_numCodeBytes);
reinterpret_cast<Stub *>(pBuffer)->m_refcount = 1;
return S_OK;
}
//-------------------------------------------------------------------
// Reverse GetEntryPoint.
//-------------------------------------------------------------------
static Stub* RecoverStub(PCODE pEntryPoint)
{
STATIC_CONTRACT_NOTHROW;
STATIC_CONTRACT_GC_NOTRIGGER;
TADDR pStubData = PCODEToPINSTR(pEntryPoint);
Stub *pStub = PTR_Stub(pStubData - sizeof(*pStub));
#if !defined(DACCESS_COMPILE)
_ASSERTE(pStub->m_signature == kUsedStub);
_ASSERTE(pStub->GetEntryPoint() == pEntryPoint);
#elif defined(_DEBUG)
// If this isn't really a stub we don't want
// to continue with it.
// TODO: This should be removed once IsStub
// can adverstise whether it's safe to call
// further StubManager methods.
if (pStub->m_signature != kUsedStub ||
pStub->GetEntryPoint() != pEntryPoint)
{
DacError(E_INVALIDARG);
}
#endif
return pStub;
}
//-------------------------------------------------------------------
// Returns TRUE if entry point is not inside the Stub allocation.
//-------------------------------------------------------------------
BOOL HasExternalEntryPoint() const
{
LIMITED_METHOD_CONTRACT;
return (m_patchOffset & EXTERNAL_ENTRY_BIT) != 0;
}
//-------------------------------------------------------------------
// This creates stubs.
//-------------------------------------------------------------------
static Stub* NewStub(LoaderHeap *pLoaderHeap, UINT numCodeBytes,
DWORD flags = 0
#ifdef STUBLINKER_GENERATES_UNWIND_INFO
, UINT nUnwindInfoSize = 0
#endif
);
static Stub* NewStub(PTR_VOID pCode, DWORD flags = 0);
static Stub* NewStub(PCODE pCode, DWORD flags = 0)
{
return NewStub((PTR_VOID)pCode, flags);
}
//-------------------------------------------------------------------
// One-time init
//-------------------------------------------------------------------
static void Init();
protected:
// fMC: Set to true if the stub is a multicast delegate, false otherwise
void SetupStub(int numCodeBytes, DWORD flags
#ifdef STUBLINKER_GENERATES_UNWIND_INFO
, UINT nUnwindInfoSlots
#endif
);
void DeleteStub();
//-------------------------------------------------------------------
// Return executable entrypoint without checking the ref count.
//-------------------------------------------------------------------
inline PTR_CBYTE GetEntryPointInternal()
{
LIMITED_METHOD_CONTRACT;
SUPPORTS_DAC;
_ASSERTE(m_signature == kUsedStub);
if (HasExternalEntryPoint())
{
return dac_cast<PTR_BYTE>(*dac_cast<PTR_PCODE>(dac_cast<TADDR>(this) + sizeof(*this)));
}
else
{
// StubLink always puts the entrypoint first.
return dac_cast<PTR_CBYTE>(this) + sizeof(*this);
}
}
ULONG m_refcount;
ULONG m_patchOffset;
UINT m_numCodeBytes;
#ifdef _DEBUG
enum {
kUsedStub = 0x42555453, // 'STUB'
kFreedStub = 0x46555453, // 'STUF'
};
UINT32 m_signature;
#else
#ifdef HOST_64BIT
//README ALIGNMENT: in retail mode UINT m_numCodeBytes does not align to 16byte for the code
// after the Stub struct. This is to pad properly
UINT m_pad_code_bytes;
#endif // HOST_64BIT
#endif // _DEBUG
#ifdef _DEBUG
Stub() // Stubs are created by NewStub(), not "new". Hide the
{ LIMITED_METHOD_CONTRACT; } // constructor to enforce this.
#endif
};
//-------------------------------------------------------------------------
// Each platform encodes the "branch" instruction in a different
// way. We use objects derived from InstructionFormat to abstract this
// information away. InstructionFormats don't contain any variable data
// so they should be allocated statically.
//
// Note that StubLinker does not create or define any InstructionFormats.
// The client does.
//
// The following example shows how to define a InstructionFormat for the
// X86 jump near instruction which takes on two forms:
//
// EB xx jmp rel8 ;; SHORT JMP (signed 8-bit offset)
// E9 xxxxxxxx jmp rel32 ;; NEAR JMP (signed 32-bit offset)
//
// InstructionFormat's provide StubLinker the following information:
//
// RRT.m_allowedSizes
//
// What are the possible sizes that the reference can
// take? The X86 jump can take either an 8-bit or 32-bit offset
// so this value is set to (k8|k32). StubLinker will try to
// use the smallest size possible.
//
//
// RRT.m_fTreatSizesAsSigned
// Sign-extend or zero-extend smallsizes offsets to the platform
// code pointer size? For x86, this field is set to TRUE (rel8
// is considered signed.)
//
//
// UINT RRT.GetSizeOfInstruction(refsize, variationCode)
// Returns the total size of the instruction in bytes for a given
// refsize. For this example:
//
// if (refsize==k8) return 2;
// if (refsize==k32) return 5;
//
//
// UINT RRT.GetSizeOfData(refsize, variationCode)
// Returns the total size of the seperate data area (if any) that the
// instruction needs in bytes for a given refsize. For this example
// on the SH3
// if (refsize==k32) return 4; else return 0;
//
// The default implem of this returns 0, so CPUs that don't have need
// for a seperate constant area don't have to worry about it.
//
//
// BOOL CanReach(refsize, variationcode, fExternal, offset)
// Returns whether the instruction with the given variationcode &
// refsize can reach the given offset. In the case of External
// calls, fExternal is set and offset is the target address. In this case an
// implementation should return TRUE only if refsize is big enough to fit a
// full machine-sized pointer to anywhere in the address space.
//
//
// VOID RRT.EmitInstruction(UINT refsize,
// __int64 fixedUpReference,
// BYTE *pOutBuffer,
// UINT variationCode,
// BYTE *pDataBuffer)
//
// Given a chosen size (refsize) and the final offset value
// computed by StubLink (fixedUpReference), write out the
// instruction into the provided buffer (guaranteed to be
// big enough provided you told the truth with GetSizeOfInstruction()).
// If needed (e.g. on SH3) a data buffer is also passed in for
// storage of constants.
//
// For x86 jmp near:
//
// if (refsize==k8) {
// pOutBuffer[0] = 0xeb;
// pOutBuffer[1] = (__int8)fixedUpReference;
// } else if (refsize == k32) {
// pOutBuffer[0] = 0xe9;
// *((__int32*)(1+pOutBuffer)) = (__int32)fixedUpReference;
// } else {
// CRASH("Bad input.");
// }
//
// VOID RRT.GetHotSpotOffset(UINT refsize, UINT variationCode)
//
// The reference offset is always relative to some IP: this
// method tells StubLinker where that IP is relative to the
// start of the instruction. For X86, the offset is always
// relative to the start of the *following* instruction so
// the correct implementation is:
//
// return GetSizeOfInstruction(refsize, variationCode);
//
// Actually, InstructionFormat() provides a default implementation of this
// method that does exactly this so X86 need not override this at all.
//
//
// The extra "variationCode" argument is an __int32 that StubLinker receives
// from EmitLabelRef() and passes uninterpreted to each RRT method.
// This allows one RRT to handle a family of related instructions,
// for example, the family of conditional jumps on the X86.
//
//-------------------------------------------------------------------------
class InstructionFormat
{
private:
enum
{
// if you want to add a size, insert it in-order (e.g. a 18-bit size would
// go between k16 and k32) and shift all the higher values up. All values
// must be a power of 2 since the get ORed together.
_k8,
#ifdef INSTRFMT_K9
_k9,
#endif
#ifdef INSTRFMT_K13
_k13,
#endif
_k16,
#ifdef INSTRFMT_K24
_k24,
#endif
#ifdef INSTRFMT_K26
_k26,
#endif
_k32,
#ifdef INSTRFMT_K64SMALL
_k64Small,
#endif
#ifdef INSTRFMT_K64
_k64,
#endif
_kAllowAlways,
};
public:
enum
{
k8 = (1 << _k8),
#ifdef INSTRFMT_K9
k9 = (1 << _k9),
#endif
#ifdef INSTRFMT_K13
k13 = (1 << _k13),
#endif
k16 = (1 << _k16),
#ifdef INSTRFMT_K24
k24 = (1 << _k24),
#endif
#ifdef INSTRFMT_K26
k26 = (1 << _k26),
#endif
k32 = (1 << _k32),
#ifdef INSTRFMT_K64SMALL
k64Small = (1 << _k64Small),
#endif
#ifdef INSTRFMT_K64
k64 = (1 << _k64),
#endif
kAllowAlways= (1 << _kAllowAlways),
kMax = kAllowAlways,
};
const UINT m_allowedSizes; // OR mask using above "k" values
InstructionFormat(UINT allowedSizes) : m_allowedSizes(allowedSizes)
{
LIMITED_METHOD_CONTRACT;
}
virtual UINT GetSizeOfInstruction(UINT refsize, UINT variationCode) = 0;
virtual VOID EmitInstruction(UINT refsize, __int64 fixedUpReference, BYTE *pCodeBufferRX, BYTE *pCodeBufferRW, UINT variationCode, BYTE *pDataBuffer) = 0;
virtual UINT GetHotSpotOffset(UINT refsize, UINT variationCode)
{
WRAPPER_NO_CONTRACT;
// Default implementation: the offset is added to the
// start of the following instruction.
return GetSizeOfInstruction(refsize, variationCode);
}
virtual UINT GetSizeOfData(UINT refsize, UINT variationCode)
{
LIMITED_METHOD_CONTRACT;
// Default implementation: 0 extra bytes needed (most CPUs)
return 0;
}
virtual BOOL CanReach(UINT refsize, UINT variationCode, BOOL fExternal, INT_PTR offset)
{
LIMITED_METHOD_CONTRACT;
if (fExternal) {
// For external, we don't have enough info to predict
// the offset yet so we only accept if the offset size
// is at least as large as the native pointer size.
switch(refsize) {
case InstructionFormat::k8: // intentional fallthru
case InstructionFormat::k16: // intentional fallthru
#ifdef INSTRFMT_K24
case InstructionFormat::k24: // intentional fallthru
#endif
#ifdef INSTRFMT_K26
case InstructionFormat::k26: // intentional fallthru
#endif
return FALSE; // no 8 or 16-bit platforms
case InstructionFormat::k32:
return sizeof(LPVOID) <= 4;
#ifdef INSTRFMT_K64
case InstructionFormat::k64:
return sizeof(LPVOID) <= 8;
#endif
case InstructionFormat::kAllowAlways:
return TRUE;
default:
_ASSERTE(0);
return FALSE;
}
} else {
switch(refsize)
{
case InstructionFormat::k8:
return FitsInI1(offset);
case InstructionFormat::k16:
return FitsInI2(offset);
#ifdef INSTRFMT_K24
case InstructionFormat::k24:
return FitsInI2(offset>>8);
#endif
#ifdef INSTRFMT_K26
case InstructionFormat::k26:
return FitsInI2(offset>>10);
#endif
case InstructionFormat::k32:
return FitsInI4(offset);
#ifdef INSTRFMT_K64
case InstructionFormat::k64:
// intentional fallthru
#endif
case InstructionFormat::kAllowAlways:
return TRUE;
default:
_ASSERTE(0);
return FALSE;
}
}
}
};
//-------------------------------------------------------------------------
// This stub cache associates stubs with an integer key. For some clients,
// this might represent the size of the argument stack in some cpu-specific
// units (for the x86, the size is expressed in DWORDS.) For other clients,
// this might take into account the style of stub (e.g. whether it returns
// an object reference or not).
//-------------------------------------------------------------------------
class ArgBasedStubCache
{
public:
ArgBasedStubCache(UINT fixedSize = NUMFIXEDSLOTS);
~ArgBasedStubCache();
//-----------------------------------------------------------------
// Retrieves the stub associated with the given key.
//-----------------------------------------------------------------
Stub *GetStub(UINT_PTR key);
//-----------------------------------------------------------------
// Tries to associate the stub with the given key.
// It may fail because another thread might swoop in and
// do the association before you do. Thus, you must use the
// return value stub rather than the pStub.
//-----------------------------------------------------------------
Stub* AttemptToSetStub(UINT_PTR key, Stub *pStub);
// Suggestions for number of slots
enum {
#ifdef _DEBUG
NUMFIXEDSLOTS = 3,
#else
NUMFIXEDSLOTS = 16,
#endif
};
#ifdef _DEBUG
VOID Dump(); //Diagnostic dump
#endif
private:
// How many low-numbered keys have direct access?
UINT m_numFixedSlots;
// For 'm_numFixedSlots' low-numbered keys, we store them in an array.
Stub **m_aStub;
struct SlotEntry
{
Stub *m_pStub;
UINT_PTR m_key;
SlotEntry *m_pNext;
};
// High-numbered keys are stored in a sparse linked list.
SlotEntry *m_pSlotEntries;
Crst m_crst;
};
#define CPUSTUBLINKER StubLinkerCPU
class NDirectStubLinker;
class CPUSTUBLINKER;
#endif // __stublink_h__
|
JimmyCushnie/runtime
|
src/tests/profiler/native/transitions/transitions.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma once
#include "../profiler.h"
class Transitions : public Profiler
{
public:
Transitions();
virtual ~Transitions() = default;
static GUID GetClsid();
virtual HRESULT STDMETHODCALLTYPE Initialize(IUnknown* pICorProfilerInfoUnk);
virtual HRESULT STDMETHODCALLTYPE Shutdown();
virtual HRESULT STDMETHODCALLTYPE UnmanagedToManagedTransition(FunctionID functionID, COR_PRF_TRANSITION_REASON reason);
virtual HRESULT STDMETHODCALLTYPE ManagedToUnmanagedTransition(FunctionID functionID, COR_PRF_TRANSITION_REASON reason);
private:
std::atomic<int> _failures;
std::atomic<bool> _sawEnter;
std::atomic<bool> _sawLeave;
bool FunctionIsTargetFunction(FunctionID functionID);
};
|
JimmyCushnie/runtime
|
src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_cipher.c
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#include "pal_cipher.h"
#include "pal_utilities.h"
enum
{
CIPHER_NONE = 0,
CIPHER_HAS_VARIABLE_TAG = 1,
CIPHER_REQUIRES_IV = 2,
};
typedef uint32_t CipherFlags;
typedef struct CipherInfo
{
CipherFlags flags;
int32_t width;
const char* name;
} CipherInfo;
#define DEFINE_CIPHER(cipherId, width, javaName, flags) \
CipherInfo* AndroidCryptoNative_ ## cipherId() \
{ \
static CipherInfo info = { flags, width, javaName }; \
return &info; \
}
DEFINE_CIPHER(Aes128Ecb, 128, "AES/ECB/NoPadding", CIPHER_NONE)
DEFINE_CIPHER(Aes128Cbc, 128, "AES/CBC/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes128Cfb8, 128, "AES/CFB8/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes128Cfb128, 128, "AES/CFB128/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes128Gcm, 128, "AES/GCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes128Ccm, 128, "AES/CCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes192Ecb, 192, "AES/ECB/NoPadding", CIPHER_NONE)
DEFINE_CIPHER(Aes192Cbc, 192, "AES/CBC/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes192Cfb8, 192, "AES/CFB8/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes192Cfb128, 192, "AES/CFB128/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes192Gcm, 192, "AES/GCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes192Ccm, 192, "AES/CCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes256Ecb, 256, "AES/ECB/NoPadding", CIPHER_NONE)
DEFINE_CIPHER(Aes256Cbc, 256, "AES/CBC/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes256Cfb8, 256, "AES/CFB8/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes256Cfb128, 256, "AES/CFB128/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes256Gcm, 256, "AES/GCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Aes256Ccm, 256, "AES/CCM/NoPadding", CIPHER_HAS_VARIABLE_TAG | CIPHER_REQUIRES_IV)
DEFINE_CIPHER(DesEcb, 64, "DES/ECB/NoPadding", CIPHER_NONE)
DEFINE_CIPHER(DesCbc, 64, "DES/CBC/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(DesCfb8, 64, "DES/CFB8/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Des3Ecb, 128, "DESede/ECB/NoPadding", CIPHER_NONE)
DEFINE_CIPHER(Des3Cbc, 128, "DESede/CBC/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Des3Cfb8, 128, "DESede/CFB8/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(Des3Cfb64, 128, "DESede/CFB/NoPadding", CIPHER_REQUIRES_IV)
DEFINE_CIPHER(ChaCha20Poly1305, 256, "ChaCha20/Poly1305/NoPadding", CIPHER_REQUIRES_IV)
//
// We don't have to check whether `CipherInfo` arguments are valid pointers, as these functions will be called after the
// context is created and the type stored in `CipherInfo` is asserted to be not NULL on creation time. Managed code
// cannot modify the context so it's fairly safe to assume that we're passed a valid pointer here.
//
// The entry functions (those that can be called by external code) take care to validate that the context passed to them
// is a valid pointer and so we can assume the assertion from the preceding paragraph.
//
ARGS_NON_NULL_ALL static bool HasVariableTag(CipherInfo* type)
{
return (type->flags & CIPHER_HAS_VARIABLE_TAG) == CIPHER_HAS_VARIABLE_TAG;
}
ARGS_NON_NULL_ALL static bool RequiresIV(CipherInfo* type)
{
return (type->flags & CIPHER_REQUIRES_IV) == CIPHER_REQUIRES_IV;
}
ARGS_NON_NULL_ALL static jobject GetAlgorithmName(JNIEnv* env, CipherInfo* type)
{
return make_java_string(env, type->name);
}
int32_t AndroidCryptoNative_CipherIsSupported(CipherInfo* type)
{
abort_if_invalid_pointer_argument (type);
JNIEnv* env = GetJNIEnv();
jobject algName = GetAlgorithmName(env, type);
if (!algName)
return FAIL;
jobject cipher = (*env)->CallStaticObjectMethod(env, g_cipherClass, g_cipherGetInstanceMethod, algName);
(*env)->DeleteLocalRef(env, algName);
(*env)->DeleteLocalRef(env, cipher);
// If we were able to call Cipher.getInstance without an exception, like NoSuchAlgorithmException,
// then the algorithm is supported.
return TryClearJNIExceptions(env) ? FAIL : SUCCESS;
}
CipherCtx* AndroidCryptoNative_CipherCreatePartial(CipherInfo* type)
{
abort_if_invalid_pointer_argument (type);
JNIEnv* env = GetJNIEnv();
jobject algName = GetAlgorithmName(env, type);
if (!algName)
return FAIL;
jobject cipher = ToGRef(env, (*env)->CallStaticObjectMethod(env, g_cipherClass, g_cipherGetInstanceMethod, algName));
(*env)->DeleteLocalRef(env, algName);
if (CheckJNIExceptions(env))
{
return FAIL;
}
CipherCtx* ctx = xmalloc(sizeof(CipherCtx));
ctx->cipher = cipher;
ctx->type = type;
ctx->tagLength = TAG_MAX_LENGTH;
ctx->keySizeInBits = type->width;
ctx->ivLength = 0;
ctx->encMode = 0;
ctx->key = NULL;
ctx->iv = NULL;
return ctx;
}
int32_t AndroidCryptoNative_CipherSetTagLength(CipherCtx* ctx, int32_t tagLength)
{
if (!ctx)
return FAIL;
if(tagLength > TAG_MAX_LENGTH)
return FAIL;
ctx->tagLength = tagLength;
return SUCCESS;
}
ARGS_NON_NULL_ALL static int32_t ReinitializeCipher(CipherCtx* ctx)
{
JNIEnv* env = GetJNIEnv();
// SecretKeySpec keySpec = new SecretKeySpec(key.getEncoded(), "AES");
// IvParameterSpec ivSpec = new IvParameterSpec(IV); or GCMParameterSpec for GCM/CCM
// cipher.init(encMode, keySpec, ivSpec);
jobject algName = GetAlgorithmName(env, ctx->type);
if (!algName)
return FAIL;
int32_t keyLength = ctx->keySizeInBits / 8;
jbyteArray keyBytes = make_java_byte_array(env, keyLength);
(*env)->SetByteArrayRegion(env, keyBytes, 0, keyLength, (jbyte*)ctx->key);
jobject sksObj = (*env)->NewObject(env, g_sksClass, g_sksCtor, keyBytes, algName);
jobject ivPsObj = NULL;
if (RequiresIV(ctx->type))
{
jbyteArray ivBytes = make_java_byte_array(env, ctx->ivLength);
(*env)->SetByteArrayRegion(env, ivBytes, 0, ctx->ivLength, (jbyte*)ctx->iv);
if (HasVariableTag(ctx->type))
{
ivPsObj = (*env)->NewObject(env, g_GCMParameterSpecClass, g_GCMParameterSpecCtor, ctx->tagLength * 8, ivBytes);
}
else
{
ivPsObj = (*env)->NewObject(env, g_ivPsClass, g_ivPsCtor, ivBytes);
}
(*env)->DeleteLocalRef(env, ivBytes);
}
(*env)->CallVoidMethod(env, ctx->cipher, g_cipherInitMethod, ctx->encMode, sksObj, ivPsObj);
(*env)->DeleteLocalRef(env, algName);
(*env)->DeleteLocalRef(env, sksObj);
(*env)->DeleteLocalRef(env, ivPsObj);
(*env)->DeleteLocalRef(env, keyBytes);
return CheckJNIExceptions(env) ? FAIL : SUCCESS;
}
int32_t AndroidCryptoNative_CipherSetKeyAndIV(CipherCtx* ctx, uint8_t* key, uint8_t* iv, int32_t enc)
{
if (!ctx)
return FAIL;
// input: 0 for Decrypt, 1 for Encrypt, -1 leave untouched
// Cipher: 2 for Decrypt, 1 for Encrypt, N/A
if (enc != -1)
{
abort_unless(enc == 0 || enc == 1, "The 'enc' parameter must be either 1 or 0");
ctx->encMode = enc == 0 ? CIPHER_DECRYPT_MODE : CIPHER_ENCRYPT_MODE;
}
// CryptoNative_CipherSetKeyAndIV can be called separately for key and iv
// so we need to wait for both and do Init after.
if (key)
SaveTo(key, &ctx->key, (size_t)ctx->keySizeInBits / 8, /* overwrite */ true);
if (iv)
{
// Make sure length is set
if (!ctx->ivLength)
{
// ivLength = cipher.getBlockSize();
JNIEnv *env = GetJNIEnv();
ctx->ivLength = (*env)->CallIntMethod(env, ctx->cipher, g_getBlockSizeMethod);
}
SaveTo(iv, &ctx->iv, (size_t)ctx->ivLength, /* overwrite */ true);
}
if (!ctx->key || (!ctx->iv && RequiresIV(ctx->type)))
return SUCCESS;
return ReinitializeCipher(ctx);
}
CipherCtx* AndroidCryptoNative_CipherCreate(CipherInfo* type, uint8_t* key, int32_t keySizeInBits, int32_t effectiveKeyLength, uint8_t* iv, int32_t enc)
{
if (effectiveKeyLength != 0)
{
LOG_ERROR("Non-zero effectiveKeyLength is not supported");
return FAIL;
}
CipherCtx* ctx = AndroidCryptoNative_CipherCreatePartial(type);
// Update the key size if provided
if (keySizeInBits > 0)
ctx->keySizeInBits = keySizeInBits;
if (AndroidCryptoNative_CipherSetKeyAndIV(ctx, key, iv, enc) != SUCCESS)
return FAIL;
return ctx;
}
int32_t AndroidCryptoNative_CipherUpdateAAD(CipherCtx* ctx, uint8_t* in, int32_t inl)
{
if (!ctx)
return FAIL;
abort_if_invalid_pointer_argument(in);
JNIEnv* env = GetJNIEnv();
jbyteArray inDataBytes = make_java_byte_array(env, inl);
(*env)->SetByteArrayRegion(env, inDataBytes, 0, inl, (jbyte*)in);
(*env)->CallVoidMethod(env, ctx->cipher, g_cipherUpdateAADMethod, inDataBytes);
(*env)->DeleteLocalRef(env, inDataBytes);
return CheckJNIExceptions(env) ? FAIL : SUCCESS;
}
int32_t AndroidCryptoNative_CipherUpdate(CipherCtx* ctx, uint8_t* outm, int32_t* outl, uint8_t* in, int32_t inl)
{
if (!ctx)
return FAIL;
if (!outl && !in)
// it means caller wants us to record "inl" but we don't need it.
return SUCCESS;
abort_if_invalid_pointer_argument(outl);
abort_if_invalid_pointer_argument(in);
JNIEnv* env = GetJNIEnv();
jbyteArray inDataBytes = make_java_byte_array(env, inl);
(*env)->SetByteArrayRegion(env, inDataBytes, 0, inl, (jbyte*)in);
*outl = 0;
jbyteArray outDataBytes = (jbyteArray)(*env)->CallObjectMethod(env, ctx->cipher, g_cipherUpdateMethod, inDataBytes);
if (outDataBytes && outm)
{
jsize outDataBytesLen = (*env)->GetArrayLength(env, outDataBytes);
*outl = outDataBytesLen;
(*env)->GetByteArrayRegion(env, outDataBytes, 0, outDataBytesLen, (jbyte*) outm);
(*env)->DeleteLocalRef(env, outDataBytes);
}
(*env)->DeleteLocalRef(env, inDataBytes);
return CheckJNIExceptions(env) ? FAIL : SUCCESS;
}
int32_t AndroidCryptoNative_CipherFinalEx(CipherCtx* ctx, uint8_t* outm, int32_t* outl)
{
if (!ctx)
return FAIL;
abort_if_invalid_pointer_argument(outm);
abort_if_invalid_pointer_argument(outl);
JNIEnv* env = GetJNIEnv();
*outl = 0;
jbyteArray outBytes = (jbyteArray)(*env)->CallObjectMethod(env, ctx->cipher, g_cipherDoFinalMethod);
if (CheckJNIExceptions(env)) return FAIL;
jsize outBytesLen = (*env)->GetArrayLength(env, outBytes);
*outl = outBytesLen;
(*env)->GetByteArrayRegion(env, outBytes, 0, outBytesLen, (jbyte*) outm);
(*env)->DeleteLocalRef(env, outBytes);
return CheckJNIExceptions(env) ? FAIL : SUCCESS;
}
int32_t AndroidCryptoNative_CipherCtxSetPadding(CipherCtx* ctx, int32_t padding)
{
if (!ctx)
return FAIL;
if (padding == 0)
{
return SUCCESS;
}
else
{
// TODO: re-init ctx->cipher ?
LOG_ERROR("Non-zero padding (%d) is not supported yet", (int)padding);
return FAIL;
}
}
int32_t AndroidCryptoNative_CipherReset(CipherCtx* ctx)
{
if (!ctx)
return FAIL;
JNIEnv* env = GetJNIEnv();
ReleaseGRef(env, ctx->cipher);
jobject algName = GetAlgorithmName(env, ctx->type);
if (!algName)
return FAIL;
// Resetting is only for the cipher, not the context.
// We recreate and reinitialize a cipher with the same context.
ctx->cipher = ToGRef(env, (*env)->CallStaticObjectMethod(env, g_cipherClass, g_cipherGetInstanceMethod, algName));
(*env)->DeleteLocalRef(env, algName);
if (CheckJNIExceptions(env))
return FAIL;
return ReinitializeCipher(ctx);
}
int32_t AndroidCryptoNative_CipherSetNonceLength(CipherCtx* ctx, int32_t ivLength)
{
if (!ctx)
return FAIL;
ctx->ivLength = ivLength;
return SUCCESS;
}
void AndroidCryptoNative_CipherDestroy(CipherCtx* ctx)
{
if (ctx)
{
JNIEnv* env = GetJNIEnv();
ReleaseGRef(env, ctx->cipher);
free(ctx->key);
free(ctx->iv);
free(ctx);
}
}
|
JimmyCushnie/runtime
|
src/mono/mono/component/debugger-stub.c
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
//
#include <config.h>
#include "mono/mini/mini-runtime.h"
#include "debugger-agent.h"
#include <mono/component/debugger.h>
static bool
debugger_avaliable (void);
static void
stub_debugger_parse_options (char *options);
static void
stub_debugger_init (MonoDefaults *mono_defaults);
static void
stub_debugger_breakpoint_hit (void *sigctx);
static void
stub_debugger_single_step_event (void *sigctx);
static void
stub_debugger_free_mem_manager (gpointer mem_manager);
static void
stub_debugger_handle_exception (MonoException *exc, MonoContext *throw_ctx, MonoContext *catch_ctx, StackFrameInfo *catch_frame);
static void
stub_debugger_begin_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx);
static void
stub_debugger_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx);
static void
stub_debugger_user_break (void);
static void
stub_debugger_debug_log (int level, MonoString *category, MonoString *message);
static gboolean
stub_debugger_debug_log_is_enabled (void);
static void
stub_debugger_unhandled_exception (MonoException *exc);
static void
stub_debugger_single_step_from_context (MonoContext *ctx);
static void
stub_debugger_breakpoint_from_context (MonoContext *ctx);
static void
stub_debugger_send_crash (char *json_dump, MonoStackHash *hashes, int pause);
static gboolean
stub_debugger_transport_handshake (void);
static void
stub_mono_wasm_breakpoint_hit (void);
static void
stub_mono_wasm_single_step_hit (void);
static void
stub_send_enc_delta (MonoImage *image, gconstpointer dmeta_bytes, int32_t dmeta_len, gconstpointer dpdb_bytes, int32_t dpdb_len);
static MonoComponentDebugger fn_table = {
{ MONO_COMPONENT_ITF_VERSION, &debugger_avaliable },
&stub_debugger_init,
&stub_debugger_user_break,
&stub_debugger_parse_options,
&stub_debugger_breakpoint_hit,
&stub_debugger_single_step_event,
&stub_debugger_single_step_from_context,
&stub_debugger_breakpoint_from_context,
&stub_debugger_free_mem_manager,
&stub_debugger_unhandled_exception,
&stub_debugger_handle_exception,
&stub_debugger_begin_exception_filter,
&stub_debugger_end_exception_filter,
&stub_debugger_debug_log,
&stub_debugger_debug_log_is_enabled,
&stub_debugger_send_crash,
&stub_debugger_transport_handshake,
//wasm
&stub_mono_wasm_breakpoint_hit,
&stub_mono_wasm_single_step_hit,
//HotReload
&stub_send_enc_delta,
};
static bool
debugger_avaliable (void)
{
return false;
}
MonoComponentDebugger *
mono_component_debugger_init (void)
{
return &fn_table;
}
static void
stub_debugger_parse_options (char *options)
{
if (!options)
return;
g_error ("This runtime is configured with the debugger agent disabled.");
}
static void
stub_debugger_init (MonoDefaults *mono_defaults)
{
}
static void
stub_debugger_breakpoint_hit (void *sigctx)
{
}
static void
stub_debugger_single_step_event (void *sigctx)
{
}
static void
stub_debugger_free_mem_manager (gpointer mem_manager)
{
}
static void
stub_debugger_handle_exception (MonoException *exc, MonoContext *throw_ctx,
MonoContext *catch_ctx, StackFrameInfo *catch_frame)
{
}
static void
stub_debugger_begin_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx)
{
}
static void
stub_debugger_end_exception_filter (MonoException *exc, MonoContext *ctx, MonoContext *orig_ctx)
{
}
static void
stub_debugger_user_break (void)
{
G_BREAKPOINT ();
}
static void
stub_debugger_debug_log (int level, MonoString *category, MonoString *message)
{
}
static gboolean
stub_debugger_debug_log_is_enabled (void)
{
return FALSE;
}
static void
stub_debugger_unhandled_exception (MonoException *exc)
{
g_assert_not_reached ();
}
static void
stub_debugger_single_step_from_context (MonoContext *ctx)
{
g_assert_not_reached ();
}
static void
stub_debugger_breakpoint_from_context (MonoContext *ctx)
{
g_assert_not_reached ();
}
static void
stub_debugger_send_crash (char *json_dump, MonoStackHash *hashes, int pause)
{
}
static gboolean
stub_debugger_transport_handshake (void)
{
g_assert_not_reached();
}
static void
stub_mono_wasm_breakpoint_hit (void)
{
}
static void
stub_mono_wasm_single_step_hit (void)
{
}
static void
stub_send_enc_delta (MonoImage *image, gconstpointer dmeta_bytes, int32_t dmeta_len, gconstpointer dpdb_bytes, int32_t dpdb_len)
{
}
#ifdef HOST_WASM
#include <emscripten.h>
//functions exported to be used by JS
G_BEGIN_DECLS
EMSCRIPTEN_KEEPALIVE gboolean mono_wasm_send_dbg_command (int id, int command_set, int command, guint8* data, unsigned int size);
EMSCRIPTEN_KEEPALIVE gboolean mono_wasm_send_dbg_command_with_parms (int id, int command_set, int command, guint8* data, unsigned int size, int valtype, char* newvalue);
G_END_DECLS
EMSCRIPTEN_KEEPALIVE gboolean
mono_wasm_send_dbg_command_with_parms (int id, int command_set, int command, guint8* data, unsigned int size, int valtype, char* newvalue)
{
return false;
}
EMSCRIPTEN_KEEPALIVE gboolean
mono_wasm_send_dbg_command (int id, int command_set, int command, guint8* data, unsigned int size)
{
return false;
}
#endif // HOST_WASM
|
JimmyCushnie/runtime
|
src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_cipher.h
|
<gh_stars>1-10
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma once
#include "pal_jni.h"
#define TAG_MAX_LENGTH 16
#define CIPHER_ENCRYPT_MODE 1
#define CIPHER_DECRYPT_MODE 2
typedef struct CipherInfo CipherInfo;
typedef struct CipherCtx
{
jobject cipher;
CipherInfo* type;
int32_t keySizeInBits;
int32_t ivLength;
int32_t tagLength;
int32_t encMode;
uint8_t* key;
uint8_t* iv;
} CipherCtx;
PALEXPORT int32_t AndroidCryptoNative_CipherIsSupported(CipherInfo* type);
PALEXPORT CipherCtx* AndroidCryptoNative_CipherCreate(CipherInfo* type, uint8_t* key, int32_t keySizeInBits, int32_t effectiveKeyLength, uint8_t* iv, int32_t enc);
PALEXPORT CipherCtx* AndroidCryptoNative_CipherCreatePartial(CipherInfo* type);
PALEXPORT int32_t AndroidCryptoNative_CipherSetTagLength(CipherCtx* ctx, int32_t tagLength);
PALEXPORT int32_t AndroidCryptoNative_CipherSetKeyAndIV(CipherCtx* ctx, uint8_t* key, uint8_t* iv, int32_t enc);
PALEXPORT int32_t AndroidCryptoNative_CipherSetNonceLength(CipherCtx* ctx, int32_t ivLength);
PALEXPORT void AndroidCryptoNative_CipherDestroy(CipherCtx* ctx);
PALEXPORT int32_t AndroidCryptoNative_CipherReset(CipherCtx* ctx);
PALEXPORT int32_t AndroidCryptoNative_CipherCtxSetPadding(CipherCtx* ctx, int32_t padding);
PALEXPORT int32_t AndroidCryptoNative_CipherUpdateAAD(CipherCtx* ctx, uint8_t* in, int32_t inl);
PALEXPORT int32_t AndroidCryptoNative_CipherUpdate(CipherCtx* ctx, uint8_t* out, int32_t* outl, uint8_t* in, int32_t inl);
PALEXPORT int32_t AndroidCryptoNative_CipherFinalEx(CipherCtx* ctx, uint8_t* outm, int32_t* outl);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Ecb(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Cbc(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Cfb8(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Cfb128(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Gcm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes128Ccm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Ecb(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Cbc(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Cfb8(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Cfb128(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Gcm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes192Ccm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Ecb(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Cbc(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Cfb8(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Cfb128(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Gcm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Aes256Ccm(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Des3Ecb(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Des3Cbc(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Des3Cfb8(void);
PALEXPORT CipherInfo* AndroidCryptoNative_Des3Cfb64(void);
PALEXPORT CipherInfo* AndroidCryptoNative_DesEcb(void);
PALEXPORT CipherInfo* AndroidCryptoNative_DesCfb8(void);
PALEXPORT CipherInfo* AndroidCryptoNative_DesCbc(void);
PALEXPORT CipherInfo* AndroidCryptoNative_ChaCha20Poly1305(void);
|
JimmyCushnie/runtime
|
src/libraries/Native/Unix/System.Native/pal_signal.h
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
#pragma once
#include "pal_compiler.h"
#include "pal_types.h"
/**
* Initializes the signal handling, called by InitializeTerminalAndSignalHandling.
*
* Returns 1 on success; otherwise returns 0 and sets errno.
*/
int32_t InitializeSignalHandlingCore(void);
typedef int32_t (*SigChldCallback)(int32_t reapAll, int32_t configureConsole);
/**
* Hooks up the specified callback for notifications when SIGCHLD is received.
*
* Should only be called when a callback is not currently registered.
*/
PALEXPORT void SystemNative_RegisterForSigChld(SigChldCallback callback);
typedef void (*TerminalInvalidationCallback)(void);
PALEXPORT void SystemNative_SetDelayedSigChildConsoleConfigurationHandler(void (*callback)(void));
/**
* Hooks up the specified callback for notifications when SIGCHLD, SIGCONT, SIGWINCH are received.
*
*/
PALEXPORT void SystemNative_SetTerminalInvalidationHandler(TerminalInvalidationCallback callback);
typedef enum
{
PosixSignalInvalid = 0,
PosixSignalSIGHUP = -1,
PosixSignalSIGINT = -2,
PosixSignalSIGQUIT = -3,
PosixSignalSIGTERM = -4,
PosixSignalSIGCHLD = -5,
PosixSignalSIGWINCH = -6,
PosixSignalSIGCONT = -7,
PosixSignalSIGTTIN = -8,
PosixSignalSIGTTOU = -9,
PosixSignalSIGTSTP = -10
} PosixSignal;
typedef int32_t (*PosixSignalHandler)(int32_t signalCode, PosixSignal signal);
/**
* Hooks up the specified callback for handling PosixSignalRegistrations.
*
* Should only be called when a callback is not currently registered.
*/
PALEXPORT void SystemNative_SetPosixSignalHandler(PosixSignalHandler signalHandler);
/**
* Converts a PosixSignal value to the platform signal number.
* When the signal is out of range, the function returns zero.
*/
PALEXPORT int32_t SystemNative_GetPlatformSignalNumber(PosixSignal signal);
/**
* Enables calling the PosixSignalHandler for the specified signal.
*/
PALEXPORT int32_t SystemNative_EnablePosixSignalHandling(int signalCode);
/**
* Disables calling the PosixSignalHandler for the specified signal.
*/
PALEXPORT void SystemNative_DisablePosixSignalHandling(int signalCode);
/**
* Performs the default runtime action for a non-canceled PosixSignal.
*/
PALEXPORT void SystemNative_HandleNonCanceledPosixSignal(int32_t signalCode);
typedef void (*ConsoleSigTtouHandler)(void);
/**
* Hooks up callback to be called from the signal handler directly on SIGTTOU.
*/
void InstallTTOUHandlerForConsole(ConsoleSigTtouHandler handler);
/**
* Uninstalls the SIGTTOU handler.
*/
void UninstallTTOUHandlerForConsole(void);
#ifndef HAS_CONSOLE_SIGNALS
/**
* Initializes signal handling and terminal for use by System.Console and System.Diagnostics.Process.
*
* Returns 1 on success; otherwise returns 0 and sets errno.
*/
PALEXPORT int32_t SystemNative_InitializeTerminalAndSignalHandling(void);
#endif
|
JimmyCushnie/runtime
|
src/mono/mono/mini/aot-compiler.c
|
<gh_stars>1-10
/**
* \file
* mono Ahead of Time compiler
*
* Author:
* <NAME> (<EMAIL>)
* <NAME> (<EMAIL>)
* <NAME> (<EMAIL>)
*
* (C) 2002 Ximian, Inc.
* Copyright 2003-2011 Novell, Inc
* Copyright 2011 Xamarin Inc (http://www.xamarin.com)
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_STDINT_H
#include <stdint.h>
#endif
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#ifndef HOST_WIN32
#include <sys/time.h>
#else
#include <winsock2.h>
#include <windows.h>
#endif
#include <errno.h>
#include <sys/stat.h>
#include <mono/metadata/abi-details.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/class.h>
#include <mono/metadata/object.h>
#include <mono/metadata/tokentype.h>
#include <mono/metadata/appdomain.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/metadata/assembly.h>
#include <mono/metadata/assembly-internals.h>
#include <mono/metadata/metadata-internals.h>
#include <mono/metadata/reflection-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/gc-internals.h>
#include <mono/metadata/mempool-internals.h>
#include <mono/metadata/mono-endian.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/custom-attrs-internals.h>
#include <mono/utils/mono-logger-internals.h>
#include <mono/utils/mono-compiler.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-mmap.h>
#include <mono/utils/mono-rand.h>
#include <mono/utils/json.h>
#include <mono/utils/mono-threads-coop.h>
#include <mono/profiler/aot.h>
#include <mono/utils/w32api.h>
#include "aot-compiler.h"
#include "aot-runtime.h"
#include "seq-points.h"
#include "image-writer.h"
#include "dwarfwriter.h"
#include "mini-gc.h"
#include "mini-llvm.h"
#include "mini-runtime.h"
#include "interp/interp.h"
static MonoMethod*
try_get_method_nofail (MonoClass *klass, const char *method_name, int param_count, int flags)
{
MonoMethod *result;
ERROR_DECL (error);
result = mono_class_get_method_from_name_checked (klass, method_name, param_count, flags, error);
mono_error_assert_ok (error);
return result;
}
// FIXME Consolidate the multiple functions named get_method_nofail.
static MonoMethod*
get_method_nofail (MonoClass *klass, const char *method_name, int param_count, int flags)
{
MonoMethod *result = try_get_method_nofail (klass, method_name, param_count, flags);
g_assertf (result, "Expected to find method %s in klass %s", method_name, m_class_get_name (klass));
return result;
}
#if !defined(DISABLE_AOT) && !defined(DISABLE_JIT)
// Use MSVC toolchain, Clang for MSVC using MSVC codegen and linker, when compiling for AMD64
// targeting WIN32 platforms running AOT compiler on WIN32 platform with VS installation.
#if defined(TARGET_AMD64) && defined(TARGET_WIN32) && defined(HOST_WIN32) && defined(_MSC_VER)
#define TARGET_X86_64_WIN32_MSVC
#endif
#if defined(TARGET_X86_64_WIN32_MSVC)
#define TARGET_WIN32_MSVC
#endif
// Emit native unwind info on Windows platforms (different from DWARF). Emitted unwind info
// works when using the MSVC toolchain using Clang for MSVC codegen and linker. Only supported when
// compiling for AMD64 (Windows x64 platforms).
#if defined(TARGET_WIN32_MSVC) && defined(MONO_ARCH_HAVE_UNWIND_TABLE)
#define EMIT_WIN32_UNWIND_INFO
#endif
#if defined(TARGET_ANDROID) || defined(__linux__)
#define RODATA_REL_SECT ".data.rel.ro"
#else
#define RODATA_REL_SECT ".text"
#endif
#if defined(__linux__)
#define RODATA_SECT ".rodata"
#elif defined(TARGET_MACH)
#define RODATA_SECT ".section __TEXT, __const"
#elif defined(TARGET_WIN32_MSVC)
#define RODATA_SECT ".rdata"
#else
#define RODATA_SECT ".text"
#endif
#define TV_DECLARE(name) gint64 name
#define TV_GETTIME(tv) tv = mono_100ns_ticks ()
#define TV_ELAPSED(start,end) (((end) - (start)) / 10)
#define ROUND_DOWN(VALUE,SIZE) ((VALUE) & ~((SIZE) - 1))
typedef struct {
char *name;
MonoImage *image;
} ImageProfileData;
typedef struct ClassProfileData ClassProfileData;
typedef struct {
int argc;
ClassProfileData **argv;
MonoGenericInst *inst;
} GInstProfileData;
struct ClassProfileData {
ImageProfileData *image;
char *ns, *name;
GInstProfileData *inst;
MonoClass *klass;
};
typedef struct {
ClassProfileData *klass;
int id;
char *name;
int param_count;
char *signature;
GInstProfileData *inst;
MonoMethod *method;
} MethodProfileData;
typedef struct {
GHashTable *images, *classes, *ginsts, *methods;
} ProfileData;
/* predefined values for static readonly fields without needed to run the .cctor */
typedef struct _ReadOnlyValue ReadOnlyValue;
struct _ReadOnlyValue {
ReadOnlyValue *next;
char *name;
int type; /* to be used later for typechecking to prevent user errors */
union {
guint8 i1;
guint16 i2;
guint32 i4;
guint64 i8;
gpointer ptr;
} value;
};
static ReadOnlyValue *readonly_values;
typedef struct MonoAotOptions {
char *outfile;
char *llvm_outfile;
char *data_outfile;
GList *profile_files;
gboolean save_temps;
gboolean write_symbols;
gboolean metadata_only;
gboolean bind_to_runtime_version;
MonoAotMode mode;
gboolean interp;
gboolean no_dlsym;
gboolean static_link;
gboolean asm_only;
gboolean asm_writer;
gboolean nodebug;
gboolean dwarf_debug;
gboolean soft_debug;
gboolean log_generics;
gboolean log_instances;
gboolean gen_msym_dir;
char *gen_msym_dir_path;
gboolean direct_pinvoke;
gboolean direct_icalls;
gboolean direct_extern_calls;
gboolean no_direct_calls;
gboolean use_trampolines_page;
gboolean no_instances;
// We are collecting inflated methods and emitting non-inflated
gboolean dedup;
// The name of the assembly for which the AOT module is going to have all deduped methods moved to.
// When set, we are emitting inflated methods only
char *dedup_include;
gboolean gnu_asm;
gboolean try_llvm;
gboolean llvm;
gboolean llvm_only;
int nthreads;
int ntrampolines;
int nrgctx_trampolines;
int nimt_trampolines;
int ngsharedvt_arg_trampolines;
int nftnptr_arg_trampolines;
int nrgctx_fetch_trampolines;
int nunbox_arbitrary_trampolines;
gboolean print_skipped_methods;
gboolean stats;
gboolean verbose;
gboolean deterministic;
char *tool_prefix;
char *ld_flags;
char *ld_name;
char *mtriple;
char *llvm_path;
char *temp_path;
char *instances_logfile_path;
char *logfile;
char *llvm_opts;
char *llvm_llc;
char *llvm_cpu_attr;
gboolean use_current_cpu;
gboolean dump_json;
gboolean profile_only;
gboolean no_opt;
char *clangxx;
char *depfile;
} MonoAotOptions;
typedef enum {
METHOD_CAT_NORMAL,
METHOD_CAT_GSHAREDVT,
METHOD_CAT_INST,
METHOD_CAT_WRAPPER,
METHOD_CAT_NUM
} MethodCategory;
typedef struct MonoAotStats {
int ccount, mcount, lmfcount, abscount, gcount, ocount, genericcount;
gint64 code_size, method_info_size, ex_info_size, unwind_info_size, got_size, class_info_size, got_info_size, plt_size, blob_size;
int methods_without_got_slots, direct_calls, all_calls, llvm_count;
int got_slots, offsets_size;
int method_categories [METHOD_CAT_NUM];
int got_slot_types [MONO_PATCH_INFO_NUM];
int got_slot_info_sizes [MONO_PATCH_INFO_NUM];
int jit_time, gen_time, link_time;
int method_ref_count, method_ref_size;
int class_ref_count, class_ref_size;
int ginst_count, ginst_size;
} MonoAotStats;
typedef struct GotInfo {
GHashTable *patch_to_got_offset;
GHashTable **patch_to_got_offset_by_type;
GPtrArray *got_patches;
} GotInfo;
#ifdef EMIT_WIN32_UNWIND_INFO
typedef struct _UnwindInfoSectionCacheItem {
char *xdata_section_label;
PUNWIND_INFO unwind_info;
gboolean xdata_section_emitted;
} UnwindInfoSectionCacheItem;
#endif
typedef struct MonoAotCompile {
MonoImage *image;
GPtrArray *methods;
GHashTable *method_indexes;
GHashTable *method_depth;
MonoCompile **cfgs;
int cfgs_size;
GHashTable **patch_to_plt_entry;
GHashTable *plt_offset_to_entry;
//GHashTable *patch_to_got_offset;
//GHashTable **patch_to_got_offset_by_type;
//GPtrArray *got_patches;
GotInfo got_info, llvm_got_info;
GHashTable *image_hash;
GHashTable *method_to_cfg;
GHashTable *token_info_hash;
GHashTable *method_to_pinvoke_import;
GHashTable *method_to_external_icall_symbol_name;
GPtrArray *extra_methods;
GPtrArray *image_table;
GPtrArray *globals;
GPtrArray *method_order;
GHashTable *dedup_stats;
GHashTable *dedup_cache;
gboolean dedup_cache_changed;
GHashTable *export_names;
/* Maps MonoClass* -> blob offset */
GHashTable *klass_blob_hash;
/* Maps MonoMethod* -> blob offset */
GHashTable *method_blob_hash;
/* Maps MonoGenericInst* -> blob offset */
GHashTable *ginst_blob_hash;
GHashTable *gsharedvt_in_signatures;
GHashTable *gsharedvt_out_signatures;
guint32 *plt_got_info_offsets;
guint32 got_offset, llvm_got_offset, plt_offset, plt_got_offset_base, plt_got_info_offset_base, nshared_got_entries;
/* Number of GOT entries reserved for trampolines */
guint32 num_trampoline_got_entries;
guint32 tramp_page_size;
guint32 table_offsets [MONO_AOT_TABLE_NUM];
guint32 num_trampolines [MONO_AOT_TRAMP_NUM];
guint32 trampoline_got_offset_base [MONO_AOT_TRAMP_NUM];
guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
guint32 tramp_page_code_offsets [MONO_AOT_TRAMP_NUM];
MonoAotOptions aot_opts;
guint32 nmethods;
int call_table_entry_size;
guint32 nextra_methods;
guint32 jit_opts;
guint32 simd_opts;
MonoMemPool *mempool;
MonoAotStats stats;
int method_index;
char *static_linking_symbol;
mono_mutex_t mutex;
gboolean gas_line_numbers;
/* Whenever to emit an object file directly from llc */
gboolean llvm_owriter;
gboolean llvm_owriter_supported;
MonoImageWriter *w;
MonoDwarfWriter *dwarf;
FILE *fp;
char *tmpbasename;
char *tmpfname;
char *temp_dir_to_delete;
char *llvm_sfile;
char *llvm_ofile;
GSList *cie_program;
GHashTable *unwind_info_offsets;
GPtrArray *unwind_ops;
guint32 unwind_info_offset;
char *global_prefix;
char *got_symbol;
char *llvm_got_symbol;
char *plt_symbol;
char *llvm_eh_frame_symbol;
GHashTable *method_label_hash;
const char *temp_prefix;
const char *user_symbol_prefix;
const char *llvm_label_prefix;
const char *inst_directive;
int align_pad_value;
guint32 label_generator;
gboolean llvm;
gboolean has_jitted_code;
gboolean is_full_aot;
gboolean dedup_collect_only;
MonoAotFileFlags flags;
MonoDynamicStream blob;
gboolean blob_closed;
GHashTable *typespec_classes;
GString *llc_args;
GString *as_args;
char *assembly_name_sym;
GHashTable *plt_entry_debug_sym_cache;
gboolean thumb_mixed, need_no_dead_strip, need_pt_gnu_stack;
GHashTable *ginst_hash;
GHashTable *dwarf_ln_filenames;
gboolean global_symbols;
int objc_selector_index, objc_selector_index_2;
GPtrArray *objc_selectors;
GHashTable *objc_selector_to_index;
GList *profile_data;
GHashTable *profile_methods;
#ifdef EMIT_WIN32_UNWIND_INFO
GList *unwind_info_section_cache;
#endif
FILE *logfile;
FILE *instances_logfile;
FILE *data_outfile;
int datafile_offset;
int gc_name_offset;
// In this mode, we are emitting dedupable methods that we encounter
gboolean dedup_emit_mode;
} MonoAotCompile;
typedef struct {
int plt_offset;
char *symbol, *llvm_symbol, *debug_sym;
MonoJumpInfo *ji;
gboolean jit_used, llvm_used;
} MonoPltEntry;
#define mono_acfg_lock(acfg) mono_os_mutex_lock (&((acfg)->mutex))
#define mono_acfg_unlock(acfg) mono_os_mutex_unlock (&((acfg)->mutex))
/* This points to the current acfg in LLVM mode */
static MonoAotCompile *llvm_acfg;
static MonoAotCompile *current_acfg;
/* Cache of decoded method external icall symbol names. */
/* Owned by acfg, but kept in this static as well since it is */
/* accessed by code paths not having access to acfg. */
static GHashTable *method_to_external_icall_symbol_name;
// This, instead of an array of pointers, to optimize away a pointer and a relocation per string.
#define MSGSTRFIELD(line) MSGSTRFIELD1(line)
#define MSGSTRFIELD1(line) str##line
static const struct msgstr_t {
#define PATCH_INFO(a,b) char MSGSTRFIELD(__LINE__) [sizeof (b)];
#include "patch-info.h"
#undef PATCH_INFO
} opstr = {
#define PATCH_INFO(a,b) b,
#include "patch-info.h"
#undef PATCH_INFO
};
static const gint16 opidx [] = {
#define PATCH_INFO(a,b) offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)),
#include "patch-info.h"
#undef PATCH_INFO
};
static G_GNUC_UNUSED const char*
get_patch_name (int info)
{
return (const char*)&opstr + opidx [info];
}
static int
emit_aot_image (MonoAotCompile *acfg);
static void
mono_flush_method_cache (MonoAotCompile *acfg);
static void
mono_read_method_cache (MonoAotCompile *acfg);
static guint32
get_unwind_info_offset (MonoAotCompile *acfg, guint8 *encoded, guint32 encoded_len);
static char*
get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cache);
static void
add_gsharedvt_wrappers (MonoAotCompile *acfg, MonoMethodSignature *sig, gboolean gsharedvt_in, gboolean gsharedvt_out, gboolean interp_in);
static void
add_profile_instances (MonoAotCompile *acfg, ProfileData *data);
static void
encode_signature (MonoAotCompile *acfg, MonoMethodSignature *sig, guint8 *buf, guint8 **endbuf);
static gboolean
ignore_cfg (MonoCompile *cfg)
{
return !cfg || cfg->skip;
}
static void
aot_printf (MonoAotCompile *acfg, const gchar *format, ...)
{
FILE *output;
va_list args;
if (acfg->logfile)
output = acfg->logfile;
else
output = stdout;
va_start (args, format);
vfprintf (output, format, args);
va_end (args);
}
static void
aot_printerrf (MonoAotCompile *acfg, const gchar *format, ...)
{
FILE *output;
va_list args;
if (acfg->logfile)
output = acfg->logfile;
else
output = stderr;
va_start (args, format);
vfprintf (output, format, args);
va_end (args);
}
static void
report_loader_error (MonoAotCompile *acfg, MonoError *error, gboolean fatal, const char *format, ...)
{
FILE *output;
va_list args;
if (is_ok (error))
return;
if (acfg->logfile)
output = acfg->logfile;
else
output = stderr;
va_start (args, format);
vfprintf (output, format, args);
va_end (args);
mono_error_cleanup (error);
if (acfg->is_full_aot && fatal) {
fprintf (output, "FullAOT cannot continue if there are loader errors.\n");
exit (1);
}
}
/* Wrappers around the image writer functions */
#define MAX_SYMBOL_SIZE 256
#if defined(TARGET_WIN32) && defined(TARGET_X86)
static const char *
mangle_symbol (const char * symbol, char * mangled_symbol, gsize length)
{
gsize needed_size = length;
g_assert (NULL != symbol);
g_assert (NULL != mangled_symbol);
g_assert (0 != length);
if (symbol && '_' != symbol [0]) {
needed_size = g_snprintf (mangled_symbol, length, "_%s", symbol);
} else {
needed_size = g_snprintf (mangled_symbol, length, "%s", symbol);
}
g_assert (0 <= needed_size && needed_size < length);
return mangled_symbol;
}
static char *
mangle_symbol_alloc (const char * symbol)
{
g_assert (NULL != symbol);
if (symbol && '_' != symbol [0]) {
return g_strdup_printf ("_%s", symbol);
}
else {
return g_strdup_printf ("%s", symbol);
}
}
#endif
static void
emit_section_change (MonoAotCompile *acfg, const char *section_name, int subsection_index)
{
mono_img_writer_emit_section_change (acfg->w, section_name, subsection_index);
}
#if defined(TARGET_WIN32) && defined(TARGET_X86)
static void
emit_local_symbol (MonoAotCompile *acfg, const char *name, const char *end_label, gboolean func)
{
const char * mangled_symbol_name = name;
char * mangled_symbol_name_alloc = NULL;
if (TRUE == func) {
mangled_symbol_name_alloc = mangle_symbol_alloc (name);
mangled_symbol_name = mangled_symbol_name_alloc;
}
if (name != mangled_symbol_name && 0 != g_strcasecmp (name, mangled_symbol_name)) {
mono_img_writer_emit_label (acfg->w, mangled_symbol_name);
}
mono_img_writer_emit_local_symbol (acfg->w, mangled_symbol_name, end_label, func);
if (NULL != mangled_symbol_name_alloc) {
g_free (mangled_symbol_name_alloc);
}
}
#else
static void
emit_local_symbol (MonoAotCompile *acfg, const char *name, const char *end_label, gboolean func)
{
mono_img_writer_emit_local_symbol (acfg->w, name, end_label, func);
}
#endif
static void
emit_label (MonoAotCompile *acfg, const char *name)
{
mono_img_writer_emit_label (acfg->w, name);
}
static void
emit_bytes (MonoAotCompile *acfg, const guint8* buf, int size)
{
mono_img_writer_emit_bytes (acfg->w, buf, size);
}
static void
emit_string (MonoAotCompile *acfg, const char *value)
{
mono_img_writer_emit_string (acfg->w, value);
}
static void
emit_line (MonoAotCompile *acfg)
{
mono_img_writer_emit_line (acfg->w);
}
static void
emit_alignment (MonoAotCompile *acfg, int size)
{
mono_img_writer_emit_alignment (acfg->w, size);
}
static void
emit_alignment_code (MonoAotCompile *acfg, int size)
{
if (acfg->align_pad_value)
mono_img_writer_emit_alignment_fill (acfg->w, size, acfg->align_pad_value);
else
mono_img_writer_emit_alignment (acfg->w, size);
}
static void
emit_padding (MonoAotCompile *acfg, int size)
{
int i;
guint8 buf [16];
if (acfg->align_pad_value) {
for (i = 0; i < 16; ++i)
buf [i] = acfg->align_pad_value;
} else {
memset (buf, 0, sizeof (buf));
}
for (i = 0; i < size; i += 16) {
if (size - i < 16)
emit_bytes (acfg, buf, size - i);
else
emit_bytes (acfg, buf, 16);
}
}
static void
emit_pointer (MonoAotCompile *acfg, const char *target)
{
mono_img_writer_emit_pointer (acfg->w, target);
}
static void
emit_pointer_2 (MonoAotCompile *acfg, const char *prefix, const char *target)
{
if (prefix [0] != '\0') {
char *s = g_strdup_printf ("%s%s", prefix, target);
mono_img_writer_emit_pointer (acfg->w, s);
g_free (s);
} else {
mono_img_writer_emit_pointer (acfg->w, target);
}
}
static void
emit_int16 (MonoAotCompile *acfg, int value)
{
mono_img_writer_emit_int16 (acfg->w, value);
}
static void
emit_int32 (MonoAotCompile *acfg, int value)
{
mono_img_writer_emit_int32 (acfg->w, value);
}
static void
emit_symbol_diff (MonoAotCompile *acfg, const char *end, const char* start, int offset)
{
mono_img_writer_emit_symbol_diff (acfg->w, end, start, offset);
}
static void
emit_zero_bytes (MonoAotCompile *acfg, int num)
{
mono_img_writer_emit_zero_bytes (acfg->w, num);
}
static void
emit_byte (MonoAotCompile *acfg, guint8 val)
{
mono_img_writer_emit_byte (acfg->w, val);
}
#if defined(TARGET_WIN32) && defined(TARGET_X86)
static G_GNUC_UNUSED void
emit_global_inner (MonoAotCompile *acfg, const char *name, gboolean func)
{
const char * mangled_symbol_name = name;
char * mangled_symbol_name_alloc = NULL;
mangled_symbol_name_alloc = mangle_symbol_alloc (name);
mangled_symbol_name = mangled_symbol_name_alloc;
if (0 != g_strcasecmp (name, mangled_symbol_name)) {
mono_img_writer_emit_label (acfg->w, mangled_symbol_name);
}
mono_img_writer_emit_global (acfg->w, mangled_symbol_name, func);
if (NULL != mangled_symbol_name_alloc) {
g_free (mangled_symbol_name_alloc);
}
}
#else
static G_GNUC_UNUSED void
emit_global_inner (MonoAotCompile *acfg, const char *name, gboolean func)
{
mono_img_writer_emit_global (acfg->w, name, func);
}
#endif
#ifdef TARGET_WIN32_MSVC
static gboolean
link_shared_library (MonoAotCompile *acfg)
{
return !acfg->aot_opts.static_link && !acfg->aot_opts.asm_only;
}
#endif
static gboolean
add_to_global_symbol_table (MonoAotCompile *acfg)
{
#ifdef TARGET_WIN32_MSVC
return acfg->aot_opts.no_dlsym || link_shared_library (acfg);
#else
return acfg->aot_opts.no_dlsym;
#endif
}
static void
emit_global (MonoAotCompile *acfg, const char *name, gboolean func)
{
if (add_to_global_symbol_table (acfg))
g_ptr_array_add (acfg->globals, g_strdup (name));
if (acfg->aot_opts.no_dlsym) {
mono_img_writer_emit_local_symbol (acfg->w, name, NULL, func);
} else {
emit_global_inner (acfg, name, func);
}
}
static void
emit_symbol_size (MonoAotCompile *acfg, const char *name, const char *end_label)
{
mono_img_writer_emit_symbol_size (acfg->w, name, end_label);
}
/* Emit a symbol which is referenced by the MonoAotFileInfo structure */
static void
emit_info_symbol (MonoAotCompile *acfg, const char *name, gboolean func)
{
char symbol [MAX_SYMBOL_SIZE];
if (acfg->llvm) {
emit_label (acfg, name);
/* LLVM generated code references this */
sprintf (symbol, "%s%s%s", acfg->user_symbol_prefix, acfg->global_prefix, name);
emit_label (acfg, symbol);
#ifndef TARGET_WIN32_MSVC
emit_global_inner (acfg, symbol, FALSE);
#else
emit_global_inner (acfg, symbol, func);
#endif
} else {
emit_label (acfg, name);
}
}
static void
emit_string_symbol (MonoAotCompile *acfg, const char *name, const char *value)
{
if (acfg->llvm) {
mono_llvm_emit_aot_data (name, (guint8*)value, strlen (value) + 1);
return;
}
mono_img_writer_emit_section_change (acfg->w, RODATA_SECT, 1);
#ifdef TARGET_MACH
/* On apple, all symbols need to be aligned to avoid warnings from ld */
emit_alignment (acfg, 4);
#endif
mono_img_writer_emit_label (acfg->w, name);
mono_img_writer_emit_string (acfg->w, value);
}
static G_GNUC_UNUSED void
emit_uleb128 (MonoAotCompile *acfg, guint32 value)
{
do {
guint8 b = value & 0x7f;
value >>= 7;
if (value != 0) /* more bytes to come */
b |= 0x80;
emit_byte (acfg, b);
} while (value);
}
static G_GNUC_UNUSED void
emit_sleb128 (MonoAotCompile *acfg, gint64 value)
{
gboolean more = 1;
gboolean negative = (value < 0);
guint32 size = 64;
guint8 byte;
while (more) {
byte = value & 0x7f;
value >>= 7;
/* the following is unnecessary if the
* implementation of >>= uses an arithmetic rather
* than logical shift for a signed left operand
*/
if (negative)
/* sign extend */
value |= - ((gint64)1 <<(size - 7));
/* sign bit of byte is second high order bit (0x40) */
if ((value == 0 && !(byte & 0x40)) ||
(value == -1 && (byte & 0x40)))
more = 0;
else
byte |= 0x80;
emit_byte (acfg, byte);
}
}
static G_GNUC_UNUSED void
encode_uleb128 (guint32 value, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
do {
guint8 b = value & 0x7f;
value >>= 7;
if (value != 0) /* more bytes to come */
b |= 0x80;
*p ++ = b;
} while (value);
*endbuf = p;
}
static G_GNUC_UNUSED void
encode_sleb128 (gint32 value, guint8 *buf, guint8 **endbuf)
{
gboolean more = 1;
gboolean negative = (value < 0);
guint32 size = 32;
guint8 byte;
guint8 *p = buf;
while (more) {
byte = value & 0x7f;
value >>= 7;
/* the following is unnecessary if the
* implementation of >>= uses an arithmetic rather
* than logical shift for a signed left operand
*/
if (negative)
/* sign extend */
value |= - (1 <<(size - 7));
/* sign bit of byte is second high order bit (0x40) */
if ((value == 0 && !(byte & 0x40)) ||
(value == -1 && (byte & 0x40)))
more = 0;
else
byte |= 0x80;
*p ++= byte;
}
*endbuf = p;
}
static void
encode_int (gint32 val, guint8 *buf, guint8 **endbuf)
{
// FIXME: Big-endian
buf [0] = (val >> 0) & 0xff;
buf [1] = (val >> 8) & 0xff;
buf [2] = (val >> 16) & 0xff;
buf [3] = (val >> 24) & 0xff;
*endbuf = buf + 4;
}
static void
encode_int16 (guint16 val, guint8 *buf, guint8 **endbuf)
{
buf [0] = (val >> 0) & 0xff;
buf [1] = (val >> 8) & 0xff;
*endbuf = buf + 2;
}
static void
encode_string (const char *s, guint8 *buf, guint8 **endbuf)
{
int len = strlen (s);
memcpy (buf, s, len + 1);
*endbuf = buf + len + 1;
}
static void
emit_unset_mode (MonoAotCompile *acfg)
{
mono_img_writer_emit_unset_mode (acfg->w);
}
static G_GNUC_UNUSED void
emit_set_thumb_mode (MonoAotCompile *acfg)
{
emit_unset_mode (acfg);
fprintf (acfg->fp, ".code 16\n");
}
static G_GNUC_UNUSED void
emit_set_arm_mode (MonoAotCompile *acfg)
{
emit_unset_mode (acfg);
fprintf (acfg->fp, ".code 32\n");
}
static void
emit_code_bytes (MonoAotCompile *acfg, const guint8* buf, int size)
{
#ifdef TARGET_ARM64
int i;
g_assert (size % 4 == 0);
emit_unset_mode (acfg);
for (i = 0; i < size; i += 4)
fprintf (acfg->fp, "%s 0x%x\n", acfg->inst_directive, *(guint32*)(buf + i));
#else
emit_bytes (acfg, buf, size);
#endif
}
/* ARCHITECTURE SPECIFIC CODE */
#if defined(TARGET_X86) || defined(TARGET_AMD64) || defined(TARGET_ARM) || defined(TARGET_POWERPC) || defined(TARGET_ARM64) || defined (TARGET_RISCV)
#define EMIT_DWARF_INFO 1
#endif
#ifdef TARGET_WIN32_MSVC
#undef EMIT_DWARF_INFO
#define EMIT_WIN32_CODEVIEW_INFO
#endif
#ifdef EMIT_WIN32_UNWIND_INFO
static UnwindInfoSectionCacheItem *
get_cached_unwind_info_section_item_win32 (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops);
static void
free_unwind_info_section_cache_win32 (MonoAotCompile *acfg);
static void
emit_unwind_info_data_win32 (MonoAotCompile *acfg, PUNWIND_INFO unwind_info);
static void
emit_unwind_info_sections_win32 (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops);
#endif
static void
arch_free_unwind_info_section_cache (MonoAotCompile *acfg)
{
#ifdef EMIT_WIN32_UNWIND_INFO
free_unwind_info_section_cache_win32 (acfg);
#endif
}
static void
arch_emit_unwind_info_sections (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops)
{
#ifdef EMIT_WIN32_UNWIND_INFO
gboolean own_unwind_ops = FALSE;
if (!unwind_ops) {
unwind_ops = mono_unwind_get_cie_program ();
own_unwind_ops = TRUE;
}
emit_unwind_info_sections_win32 (acfg, function_start, function_end, unwind_ops);
if (own_unwind_ops)
mono_free_unwind_info (unwind_ops);
#endif
}
#if defined(TARGET_ARM)
#define AOT_FUNC_ALIGNMENT 4
#else
#define AOT_FUNC_ALIGNMENT 16
#endif
#if defined(TARGET_POWERPC64) && !defined(MONO_ARCH_ILP32)
#define PPC_LD_OP "ld"
#define PPC_LDX_OP "ldx"
#else
#define PPC_LD_OP "lwz"
#define PPC_LDX_OP "lwzx"
#endif
#ifdef TARGET_X86_64_WIN32_MSVC
#define AOT_TARGET_STR "AMD64 (WIN32) (MSVC codegen)"
#elif TARGET_AMD64
#define AOT_TARGET_STR "AMD64"
#endif
#ifdef TARGET_ARM
#ifdef TARGET_MACH
#define AOT_TARGET_STR "ARM (MACH)"
#else
#define AOT_TARGET_STR "ARM (!MACH)"
#endif
#endif
#ifdef TARGET_ARM64
#ifdef TARGET_MACH
#define AOT_TARGET_STR "ARM64 (MACH)"
#else
#define AOT_TARGET_STR "ARM64 (!MACH)"
#endif
#endif
#ifdef TARGET_POWERPC64
#ifdef MONO_ARCH_ILP32
#define AOT_TARGET_STR "POWERPC64 (mono ilp32)"
#else
#define AOT_TARGET_STR "POWERPC64 (!mono ilp32)"
#endif
#else
#ifdef TARGET_POWERPC
#ifdef MONO_ARCH_ILP32
#define AOT_TARGET_STR "POWERPC (mono ilp32)"
#else
#define AOT_TARGET_STR "POWERPC (!mono ilp32)"
#endif
#endif
#endif
#ifdef TARGET_RISCV32
#define AOT_TARGET_STR "RISCV32"
#endif
#ifdef TARGET_RISCV64
#define AOT_TARGET_STR "RISCV64"
#endif
#ifdef TARGET_X86
#ifdef TARGET_WIN32
#define AOT_TARGET_STR "X86 (WIN32)"
#else
#define AOT_TARGET_STR "X86"
#endif
#endif
#ifndef AOT_TARGET_STR
#define AOT_TARGET_STR ""
#endif
static void
arch_init (MonoAotCompile *acfg)
{
acfg->llc_args = g_string_new ("");
acfg->as_args = g_string_new ("");
acfg->llvm_owriter_supported = TRUE;
/*
* The prefix LLVM likes to put in front of symbol names on darwin.
* The mach-os specs require this for globals, but LLVM puts them in front of all
* symbols. We need to handle this, since we need to refer to LLVM generated
* symbols.
*/
acfg->llvm_label_prefix = "";
acfg->user_symbol_prefix = "";
#if TARGET_X86 || TARGET_AMD64
const gboolean has_custom_args = !!acfg->aot_opts.llvm_llc || acfg->aot_opts.use_current_cpu;
#endif
#if defined(TARGET_X86)
g_string_append_printf (acfg->llc_args, " -march=x86 %s", has_custom_args ? "" : "-mcpu=generic");
#endif
#if defined(TARGET_AMD64)
g_string_append_printf (acfg->llc_args, " -march=x86-64 %s", has_custom_args ? "" : "-mcpu=generic");
/* NOP */
acfg->align_pad_value = 0x90;
#ifdef MONO_ARCH_CODE_EXEC_ONLY
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY);
#endif
#endif
g_string_append (acfg->llc_args, " -enable-implicit-null-checks -disable-fault-maps");
if (mono_use_fast_math) {
// same parameters are passed to opt and LLVM JIT
g_string_append (acfg->llc_args, " -fp-contract=fast -enable-no-infs-fp-math -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -enable-no-trapping-fp-math -enable-unsafe-fp-math");
}
#ifdef TARGET_ARM
if (acfg->aot_opts.mtriple && strstr (acfg->aot_opts.mtriple, "darwin")) {
g_string_append (acfg->llc_args, "-mattr=+v6");
} else {
if (!acfg->aot_opts.mtriple) {
g_string_append (acfg->llc_args, " -march=arm");
} else {
/* arch will be defined via mtriple, e.g. armv7s-ios or thumb. */
if (strstr (acfg->aot_opts.mtriple, "ios")) {
g_string_append (acfg->llc_args, " -mattr=+v7");
g_string_append (acfg->llc_args, " -exception-model=dwarf -disable-fp-elim");
}
}
#if defined(ARM_FPU_VFP_HARD)
g_string_append (acfg->llc_args, " -mattr=+vfp2,-neon,+d16 -float-abi=hard");
g_string_append (acfg->as_args, " -mfpu=vfp3");
#elif defined(ARM_FPU_VFP)
#if defined(TARGET_ARM)
// +d16 triggers a warning on arm
g_string_append (acfg->llc_args, " -mattr=+vfp2,-neon");
#else
g_string_append (acfg->llc_args, " -mattr=+vfp2,-neon,+d16");
#endif
g_string_append (acfg->as_args, " -mfpu=vfp3");
#else
g_string_append (acfg->llc_args, " -mattr=+soft-float");
#endif
}
if (acfg->aot_opts.mtriple && strstr (acfg->aot_opts.mtriple, "thumb"))
acfg->thumb_mixed = TRUE;
if (acfg->aot_opts.mtriple)
mono_arch_set_target (acfg->aot_opts.mtriple);
#endif
#ifdef TARGET_ARM64
g_string_append (acfg->llc_args, " -march=aarch64");
acfg->inst_directive = ".inst";
if (acfg->aot_opts.mtriple)
mono_arch_set_target (acfg->aot_opts.mtriple);
#endif
#ifdef TARGET_MACH
acfg->user_symbol_prefix = "_";
acfg->llvm_label_prefix = "_";
acfg->inst_directive = ".word";
acfg->need_no_dead_strip = TRUE;
acfg->aot_opts.gnu_asm = TRUE;
#endif
#if defined(__linux__) && !defined(TARGET_ARM)
acfg->need_pt_gnu_stack = TRUE;
#endif
#ifdef TARGET_RISCV
if (acfg->aot_opts.mtriple)
mono_arch_set_target (acfg->aot_opts.mtriple);
#ifdef TARGET_RISCV64
g_string_append (acfg->as_args, " -march=rv64i ");
#ifdef RISCV_FPABI_DOUBLE
g_string_append (acfg->as_args, " -mabi=lp64d");
#else
g_string_append (acfg->as_args, " -mabi=lp64");
#endif
#else
g_string_append (acfg->as_args, " -march=rv32i ");
#ifdef RISCV_FPABI_DOUBLE
g_string_append (acfg->as_args, " -mabi=ilp32d ");
#else
g_string_append (acfg->as_args, " -mabi=ilp32 ");
#endif
#endif
#endif
#ifdef MONOTOUCH
acfg->global_symbols = TRUE;
#endif
#ifdef TARGET_ANDROID
acfg->llvm_owriter_supported = FALSE;
#endif
}
#ifdef TARGET_ARM64
/* Load the contents of GOT_SLOT into dreg, clobbering ip0 */
/* Must emit 12 bytes of instructions */
static void
arm64_emit_load_got_slot (MonoAotCompile *acfg, int dreg, int got_slot)
{
int offset;
g_assert (acfg->fp);
emit_unset_mode (acfg);
/* r16==ip0 */
offset = (int)(got_slot * TARGET_SIZEOF_VOID_P);
#ifdef TARGET_MACH
/* clang's integrated assembler */
fprintf (acfg->fp, "adrp x16, %s@PAGE+%d\n", acfg->got_symbol, offset & 0xfffff000);
#ifdef MONO_ARCH_ILP32
fprintf (acfg->fp, "add x16, x16, %s@PAGEOFF+%d\n", acfg->got_symbol, offset & 0xfff);
fprintf (acfg->fp, "ldr w%d, [x16, #%d]\n", dreg, 0);
#else
fprintf (acfg->fp, "add x16, x16, %s@PAGEOFF\n", acfg->got_symbol);
fprintf (acfg->fp, "ldr x%d, [x16, #%d]\n", dreg, offset & 0xfff);
#endif
#else
/* Linux GAS */
fprintf (acfg->fp, "adrp x16, %s+%d\n", acfg->got_symbol, offset & 0xfffff000);
fprintf (acfg->fp, "add x16, x16, :lo12:%s\n", acfg->got_symbol);
fprintf (acfg->fp, "ldr x%d, [x16, %d]\n", dreg, offset & 0xfff);
#endif
}
static void
arm64_emit_objc_selector_ref (MonoAotCompile *acfg, guint8 *code, int index, int *code_size)
{
int reg;
g_assert (acfg->fp);
emit_unset_mode (acfg);
/* ldr rt, target */
reg = arm_get_ldr_lit_reg (code);
fprintf (acfg->fp, "adrp x%d, L_OBJC_SELECTOR_REFERENCES_%d@PAGE\n", reg, index);
fprintf (acfg->fp, "add x%d, x%d, L_OBJC_SELECTOR_REFERENCES_%d@PAGEOFF\n", reg, reg, index);
fprintf (acfg->fp, "ldr x%d, [x%d]\n", reg, reg);
*code_size = 12;
}
static void
arm64_emit_direct_call (MonoAotCompile *acfg, const char *target, gboolean external, gboolean thumb, MonoJumpInfo *ji, int *call_size)
{
g_assert (acfg->fp);
emit_unset_mode (acfg);
if (ji && ji->relocation == MONO_R_ARM64_B) {
fprintf (acfg->fp, "b %s\n", target);
} else {
if (ji)
g_assert (ji->relocation == MONO_R_ARM64_BL);
fprintf (acfg->fp, "bl %s\n", target);
}
*call_size = 4;
}
static void
arm64_emit_got_access (MonoAotCompile *acfg, guint8 *code, int got_slot, int *code_size)
{
int reg;
/* ldr rt, target */
reg = arm_get_ldr_lit_reg (code);
arm64_emit_load_got_slot (acfg, reg, got_slot);
*code_size = 12;
}
static void
arm64_emit_plt_entry (MonoAotCompile *acfg, const char *got_symbol, int offset, int info_offset)
{
arm64_emit_load_got_slot (acfg, ARMREG_R16, offset / sizeof (target_mgreg_t));
#ifdef MONO_ARCH_ENABLE_PTRAUTH
fprintf (acfg->fp, "braaz x16\n");
#else
fprintf (acfg->fp, "br x16\n");
#endif
/* Used by mono_aot_get_plt_info_offset () */
fprintf (acfg->fp, "%s %d\n", acfg->inst_directive, info_offset);
}
static void
arm64_emit_tramp_page_common_code (MonoAotCompile *acfg, int pagesize, int arg_reg, int *size)
{
guint8 buf [256];
guint8 *code;
int imm;
/* The common code */
code = buf;
imm = pagesize;
/* The trampoline address is in IP0 */
arm_movzx (code, ARMREG_IP1, imm & 0xffff, 0);
arm_movkx (code, ARMREG_IP1, (imm >> 16) & 0xffff, 16);
/* Compute the data slot address */
arm_subx (code, ARMREG_IP0, ARMREG_IP0, ARMREG_IP1);
/* Trampoline argument */
arm_ldrp (code, arg_reg, ARMREG_IP0, 0);
/* Address */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP0, TARGET_SIZEOF_VOID_P);
code = mono_arm_emit_brx (code, ARMREG_IP0);
/* Emit it */
emit_code_bytes (acfg, buf, code - buf);
*size = code - buf;
}
static void
arm64_emit_tramp_page_specific_code (MonoAotCompile *acfg, int pagesize, int common_tramp_size, int specific_tramp_size)
{
guint8 buf [256];
guint8 *code;
int i, count;
count = (pagesize - common_tramp_size) / specific_tramp_size;
for (i = 0; i < count; ++i) {
code = buf;
arm_adrx (code, ARMREG_IP0, code);
/* Branch to the generic code */
arm_b (code, code - 4 - (i * specific_tramp_size) - common_tramp_size);
#ifndef MONO_ARCH_ILP32
/* This has to be 2 pointers long */
arm_nop (code);
arm_nop (code);
#endif
g_assert (code - buf == specific_tramp_size);
emit_code_bytes (acfg, buf, code - buf);
}
}
static void
arm64_emit_specific_trampoline_pages (MonoAotCompile *acfg)
{
guint8 buf [128];
guint8 *code;
guint8 *labels [16];
int common_tramp_size;
int specific_tramp_size = 2 * TARGET_SIZEOF_VOID_P;
int imm, pagesize;
char symbol [128];
if (!acfg->aot_opts.use_trampolines_page)
return;
#ifdef TARGET_MACH
/* Have to match the target pagesize */
pagesize = 16384;
#else
pagesize = mono_pagesize ();
#endif
acfg->tramp_page_size = pagesize;
/* The specific trampolines */
sprintf (symbol, "%sspecific_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
/* The common code */
arm64_emit_tramp_page_common_code (acfg, pagesize, ARMREG_IP1, &common_tramp_size);
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_SPECIFIC] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
/* The rgctx trampolines */
/* These are the same as the specific trampolines, but they load the argument into MONO_ARCH_RGCTX_REG */
sprintf (symbol, "%srgctx_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
/* The common code */
arm64_emit_tramp_page_common_code (acfg, pagesize, MONO_ARCH_RGCTX_REG, &common_tramp_size);
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_STATIC_RGCTX] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
/* The gsharedvt arg trampolines */
/* These are the same as the specific trampolines */
sprintf (symbol, "%sgsharedvt_arg_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
arm64_emit_tramp_page_common_code (acfg, pagesize, ARMREG_IP1, &common_tramp_size);
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_GSHAREDVT_ARG] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
/* Unbox arbitrary trampolines */
sprintf (symbol, "%sunbox_arbitrary_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
imm = pagesize;
/* Unbox this arg */
arm_addx_imm (code, ARMREG_R0, ARMREG_R0, MONO_ABI_SIZEOF (MonoObject));
/* The trampoline address is in IP0 */
arm_movzx (code, ARMREG_IP1, imm & 0xffff, 0);
arm_movkx (code, ARMREG_IP1, (imm >> 16) & 0xffff, 16);
/* Compute the data slot address */
arm_subx (code, ARMREG_IP0, ARMREG_IP0, ARMREG_IP1);
/* Address */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP0, 0);
code = mono_arm_emit_brx (code, ARMREG_IP0);
/* Emit it */
emit_code_bytes (acfg, buf, code - buf);
common_tramp_size = code - buf;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_UNBOX_ARBITRARY] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
/* The IMT trampolines */
sprintf (symbol, "%simt_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
imm = pagesize;
/* The trampoline address is in IP0 */
arm_movzx (code, ARMREG_IP1, imm & 0xffff, 0);
arm_movkx (code, ARMREG_IP1, (imm >> 16) & 0xffff, 16);
/* Compute the data slot address */
arm_subx (code, ARMREG_IP0, ARMREG_IP0, ARMREG_IP1);
/* Trampoline argument */
arm_ldrp (code, ARMREG_IP1, ARMREG_IP0, 0);
/* Same as arch_emit_imt_trampoline () */
labels [0] = code;
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, 0);
arm_cmpp (code, ARMREG_IP0, MONO_ARCH_RGCTX_REG);
labels [1] = code;
arm_bcc (code, ARMCOND_EQ, 0);
/* End-of-loop check */
labels [2] = code;
arm_cbzx (code, ARMREG_IP0, 0);
/* Loop footer */
arm_addx_imm (code, ARMREG_IP1, ARMREG_IP1, 2 * TARGET_SIZEOF_VOID_P);
arm_b (code, labels [0]);
/* Match */
mono_arm_patch (labels [1], code, MONO_R_ARM64_BCC);
/* Load vtable slot addr */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, TARGET_SIZEOF_VOID_P);
/* Load vtable slot */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP0, 0);
code = mono_arm_emit_brx (code, ARMREG_IP0);
/* No match */
mono_arm_patch (labels [2], code, MONO_R_ARM64_CBZ);
/* Load fail addr */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, TARGET_SIZEOF_VOID_P);
code = mono_arm_emit_brx (code, ARMREG_IP0);
emit_code_bytes (acfg, buf, code - buf);
common_tramp_size = code - buf;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT] = common_tramp_size;
arm64_emit_tramp_page_specific_code (acfg, pagesize, common_tramp_size, specific_tramp_size);
}
static void
arm64_emit_specific_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
/* Load argument from second GOT slot */
arm64_emit_load_got_slot (acfg, ARMREG_R17, offset + 1);
/* Load generic trampoline address from first GOT slot */
arm64_emit_load_got_slot (acfg, ARMREG_R16, offset);
#ifdef MONO_ARCH_ENABLE_PTRAUTH
fprintf (acfg->fp, "braaz x16\n");
#else
fprintf (acfg->fp, "br x16\n");
#endif
*tramp_size = 7 * 4;
}
static void
arm64_emit_unbox_trampoline (MonoAotCompile *acfg, MonoCompile *cfg, MonoMethod *method, const char *call_target)
{
emit_unset_mode (acfg);
fprintf (acfg->fp, "add x0, x0, %d\n", (int)(MONO_ABI_SIZEOF (MonoObject)));
fprintf (acfg->fp, "b %s\n", call_target);
}
static void
arm64_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
/* Similar to the specific trampolines, but use the rgctx reg instead of ip1 */
/* Load argument from first GOT slot */
arm64_emit_load_got_slot (acfg, MONO_ARCH_RGCTX_REG, offset);
/* Load generic trampoline address from second GOT slot */
arm64_emit_load_got_slot (acfg, ARMREG_R16, offset + 1);
#ifdef MONO_ARCH_ENABLE_PTRAUTH
fprintf (acfg->fp, "braaz x16\n");
#else
fprintf (acfg->fp, "br x16\n");
#endif
*tramp_size = 7 * 4;
}
static void
arm64_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
guint8 buf [128];
guint8 *code, *labels [16];
/* Load parameter from GOT slot into ip1 */
arm64_emit_load_got_slot (acfg, ARMREG_R17, offset);
code = buf;
labels [0] = code;
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, 0);
arm_cmpp (code, ARMREG_IP0, MONO_ARCH_RGCTX_REG);
labels [1] = code;
arm_bcc (code, ARMCOND_EQ, 0);
/* End-of-loop check */
labels [2] = code;
arm_cbzx (code, ARMREG_IP0, 0);
/* Loop footer */
arm_addx_imm (code, ARMREG_IP1, ARMREG_IP1, 2 * 8);
arm_b (code, labels [0]);
/* Match */
mono_arm_patch (labels [1], code, MONO_R_ARM64_BCC);
/* Load vtable slot addr */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, TARGET_SIZEOF_VOID_P);
/* Load vtable slot */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP0, 0);
code = mono_arm_emit_brx (code, ARMREG_IP0);
/* No match */
mono_arm_patch (labels [2], code, MONO_R_ARM64_CBZ);
/* Load fail addr */
arm_ldrp (code, ARMREG_IP0, ARMREG_IP1, TARGET_SIZEOF_VOID_P);
code = mono_arm_emit_brx (code, ARMREG_IP0);
emit_code_bytes (acfg, buf, code - buf);
*tramp_size = code - buf + (3 * 4);
}
static void
arm64_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
/* Similar to the specific trampolines, but the address is in the second slot */
/* Load argument from first GOT slot */
arm64_emit_load_got_slot (acfg, ARMREG_R17, offset);
/* Load generic trampoline address from second GOT slot */
arm64_emit_load_got_slot (acfg, ARMREG_R16, offset + 1);
#ifdef MONO_ARCH_ENABLE_PTRAUTH
fprintf (acfg->fp, "braaz x16\n");
#else
fprintf (acfg->fp, "br x16\n");
#endif
*tramp_size = 7 * 4;
}
#endif
#ifdef MONO_ARCH_AOT_SUPPORTED
/*
* arch_emit_direct_call:
*
* Emit a direct call to the symbol TARGET. CALL_SIZE is set to the size of the
* calling code.
*/
static void
arch_emit_direct_call (MonoAotCompile *acfg, const char *target, gboolean external, gboolean thumb, MonoJumpInfo *ji, int *call_size)
{
#if defined(TARGET_X86) || defined(TARGET_AMD64)
/* Need to make sure this is exactly 5 bytes long */
emit_unset_mode (acfg);
fprintf (acfg->fp, "call %s\n", target);
*call_size = 5;
#elif defined(TARGET_ARM)
emit_unset_mode (acfg);
if (thumb)
fprintf (acfg->fp, "blx %s\n", target);
else
fprintf (acfg->fp, "bl %s\n", target);
*call_size = 4;
#elif defined(TARGET_ARM64)
arm64_emit_direct_call (acfg, target, external, thumb, ji, call_size);
#elif defined(TARGET_POWERPC)
emit_unset_mode (acfg);
fprintf (acfg->fp, "bl %s\n", target);
*call_size = 4;
#else
g_assert_not_reached ();
#endif
}
static void
arch_emit_label_address (MonoAotCompile *acfg, const char *target, gboolean external_call, gboolean thumb, MonoJumpInfo *ji, int *call_size)
{
#if defined(TARGET_ARM) && defined(TARGET_ANDROID)
/* binutils ld does not support branch islands on arm32 */
if (!thumb) {
emit_unset_mode (acfg);
fprintf (acfg->fp, "ldr pc,=%s\n", target);
fprintf (acfg->fp, ".ltorg\n");
*call_size = 8;
} else
#endif
arch_emit_direct_call (acfg, target, external_call, thumb, ji, call_size);
}
#endif
/*
* PPC32 design:
* - we use an approach similar to the x86 abi: reserve a register (r30) to hold
* the GOT pointer.
* - The full-aot trampolines need access to the GOT of mscorlib, so we store
* in in the 2. slot of every GOT, and require every method to place the GOT
* address in r30, even when it doesn't access the GOT otherwise. This way,
* the trampolines can compute the mscorlib GOT address by loading 4(r30).
*/
/*
* PPC64 design:
* PPC64 uses function descriptors which greatly complicate all code, since
* these are used very inconsistently in the runtime. Some functions like
* mono_compile_method () return ftn descriptors, while others like the
* trampoline creation functions do not.
* We assume that all GOT slots contain function descriptors, and create
* descriptors in aot-runtime.c when needed.
* The ppc64 abi uses r2 to hold the address of the TOC/GOT, which is loaded
* from function descriptors, we could do the same, but it would require
* rewriting all the ppc/aot code to handle function descriptors properly.
* So instead, we use the same approach as on PPC32.
* This is a horrible mess, but fixing it would probably lead to an even bigger
* one.
*/
/*
* X86 design:
* - similar to the PPC32 design, we reserve EBX to hold the GOT pointer.
*/
#ifdef MONO_ARCH_AOT_SUPPORTED
/*
* arch_emit_got_offset:
*
* The memory pointed to by CODE should hold native code for computing the GOT
* address (OP_LOAD_GOTADDR). Emit this code while patching it with the offset
* between code and the GOT. CODE_SIZE is set to the number of bytes emitted.
*/
static void
arch_emit_got_offset (MonoAotCompile *acfg, guint8 *code, int *code_size)
{
#if defined(TARGET_POWERPC64)
emit_unset_mode (acfg);
/*
* The ppc32 code doesn't seem to work on ppc64, the assembler complains about
* unsupported relocations. So we store the got address into the .Lgot_addr
* symbol which is in the text segment, compute its address, and load it.
*/
fprintf (acfg->fp, ".L%d:\n", acfg->label_generator);
fprintf (acfg->fp, "lis 0, (.Lgot_addr + 4 - .L%d)@h\n", acfg->label_generator);
fprintf (acfg->fp, "ori 0, 0, (.Lgot_addr + 4 - .L%d)@l\n", acfg->label_generator);
fprintf (acfg->fp, "add 30, 30, 0\n");
fprintf (acfg->fp, "%s 30, 0(30)\n", PPC_LD_OP);
acfg->label_generator ++;
*code_size = 16;
#elif defined(TARGET_POWERPC)
emit_unset_mode (acfg);
fprintf (acfg->fp, ".L%d:\n", acfg->label_generator);
fprintf (acfg->fp, "lis 0, (%s + 4 - .L%d)@h\n", acfg->got_symbol, acfg->label_generator);
fprintf (acfg->fp, "ori 0, 0, (%s + 4 - .L%d)@l\n", acfg->got_symbol, acfg->label_generator);
acfg->label_generator ++;
*code_size = 8;
#else
guint32 offset = mono_arch_get_patch_offset (code);
emit_bytes (acfg, code, offset);
emit_symbol_diff (acfg, acfg->got_symbol, ".", offset);
*code_size = offset + 4;
#endif
}
/*
* arch_emit_got_access:
*
* The memory pointed to by CODE should hold native code for loading a GOT
* slot (OP_AOTCONST/OP_GOT_ENTRY). Emit this code while patching it so it accesses the
* GOT slot GOT_SLOT. CODE_SIZE is set to the number of bytes emitted.
*/
static void
arch_emit_got_access (MonoAotCompile *acfg, const char *got_symbol, guint8 *code, int got_slot, int *code_size)
{
#ifdef TARGET_AMD64
/* mov reg, got+offset(%rip) */
if (acfg->llvm) {
/* The GOT symbol is in the LLVM module, the clang assembler has problems emitting symbol diffs for it */
int dreg;
int rex_r;
/* Decode reg, see amd64_mov_reg_membase () */
rex_r = code [0] & AMD64_REX_R;
g_assert (code [0] == 0x49 + rex_r);
g_assert (code [1] == 0x8b);
dreg = ((code [2] >> 3) & 0x7) + (rex_r ? 8 : 0);
emit_unset_mode (acfg);
fprintf (acfg->fp, "mov %s+%d(%%rip), %s\n", got_symbol, (unsigned int) ((got_slot * sizeof (target_mgreg_t))), mono_arch_regname (dreg));
*code_size = 7;
} else {
emit_bytes (acfg, code, mono_arch_get_patch_offset (code));
emit_symbol_diff (acfg, got_symbol, ".", (unsigned int) ((got_slot * sizeof (target_mgreg_t)) - 4));
*code_size = mono_arch_get_patch_offset (code) + 4;
}
#elif defined(TARGET_X86)
emit_bytes (acfg, code, mono_arch_get_patch_offset (code));
emit_int32 (acfg, (unsigned int) ((got_slot * sizeof (target_mgreg_t))));
*code_size = mono_arch_get_patch_offset (code) + 4;
#elif defined(TARGET_ARM)
emit_bytes (acfg, code, mono_arch_get_patch_offset (code));
emit_symbol_diff (acfg, got_symbol, ".", (unsigned int) ((got_slot * sizeof (target_mgreg_t))) - 12);
*code_size = mono_arch_get_patch_offset (code) + 4;
#elif defined(TARGET_ARM64)
emit_bytes (acfg, code, mono_arch_get_patch_offset (code));
arm64_emit_got_access (acfg, code, got_slot, code_size);
#elif defined(TARGET_POWERPC)
{
guint8 buf [32];
emit_bytes (acfg, code, mono_arch_get_patch_offset (code));
code = buf;
ppc_load32 (code, ppc_r0, got_slot * sizeof (target_mgreg_t));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
*code_size = code - buf;
}
#else
g_assert_not_reached ();
#endif
}
#endif
#ifdef MONO_ARCH_AOT_SUPPORTED
/*
* arch_emit_objc_selector_ref:
*
* Emit the implementation of OP_OBJC_GET_SELECTOR, which itself implements @selector(foo:) in objective-c.
*/
static void
arch_emit_objc_selector_ref (MonoAotCompile *acfg, guint8 *code, int index, int *code_size)
{
#if defined(TARGET_ARM)
char symbol1 [MAX_SYMBOL_SIZE];
char symbol2 [MAX_SYMBOL_SIZE];
int lindex = acfg->objc_selector_index_2 ++;
/* Emit ldr.imm/b */
emit_bytes (acfg, code, 8);
sprintf (symbol1, "L_OBJC_SELECTOR_%d", lindex);
sprintf (symbol2, "L_OBJC_SELECTOR_REFERENCES_%d", index);
emit_label (acfg, symbol1);
mono_img_writer_emit_unset_mode (acfg->w);
fprintf (acfg->fp, ".long %s-(%s+12)", symbol2, symbol1);
*code_size = 12;
#elif defined(TARGET_ARM64)
arm64_emit_objc_selector_ref (acfg, code, index, code_size);
#else
g_assert_not_reached ();
#endif
}
#endif
#ifdef MONO_ARCH_CODE_EXEC_ONLY
#if defined(TARGET_AMD64)
/* Keep in sync with tramp-amd64.c, aot_arch_get_plt_entry_index. */
#define PLT_ENTRY_OFFSET_REG AMD64_RAX
#endif
#endif
/*
* arch_emit_plt_entry:
*
* Emit code for the PLT entry.
* The plt entry should look like this on architectures where code is read/execute:
* <indirect jump to GOT_SYMBOL + OFFSET>
* <INFO_OFFSET embedded into the instruction stream>
* The plt entry should look like this on architectures where code is execute only:
* mov RAX, PLT entry offset
* <indirect jump to GOT_SYMBOL + OFFSET>
*/
static void
arch_emit_plt_entry (MonoAotCompile *acfg, const char *got_symbol, guint32 plt_index, int offset, int info_offset)
{
#if defined(TARGET_X86)
/* jmp *<offset>(%ebx) */
emit_byte (acfg, 0xff);
emit_byte (acfg, 0xa3);
emit_int32 (acfg, offset);
/* Used by mono_aot_get_plt_info_offset */
emit_int32 (acfg, info_offset);
#elif defined(TARGET_AMD64)
#ifdef MONO_ARCH_CODE_EXEC_ONLY
guint8 buf [16];
guint8 *code = buf;
/* Emit smallest possible imm size 1, 2 or 4 bytes based on total number of PLT entries. */
if (acfg->plt_offset <= (guint32)0xFF) {
amd64_emit_rex(code, sizeof (guint8), 0, 0, PLT_ENTRY_OFFSET_REG);
*(code)++ = (unsigned char)0xb0 + (PLT_ENTRY_OFFSET_REG & 0x7);
x86_imm_emit8 (code, (guint8)(plt_index));
} else if (acfg->plt_offset <= (guint32)0xFFFF) {
x86_prefix(code, X86_OPERAND_PREFIX);
amd64_emit_rex(code, sizeof (guint16), 0, 0, PLT_ENTRY_OFFSET_REG);
*(code)++ = (unsigned char)0xb8 + (PLT_ENTRY_OFFSET_REG & 0x7);
x86_imm_emit16 (code, (guint16)(plt_index));
} else {
amd64_mov_reg_imm_size (code, PLT_ENTRY_OFFSET_REG, plt_index, sizeof(plt_index));
}
emit_bytes (acfg, buf, code - buf);
acfg->stats.plt_size += code - buf;
emit_unset_mode (acfg);
fprintf (acfg->fp, "jmp *%s+%d(%%rip)\n", got_symbol, offset);
acfg->stats.plt_size += 6;
#else
fprintf (acfg->fp, "jmp *%s+%d(%%rip)\n", got_symbol, offset);
/* Used by mono_aot_get_plt_info_offset */
emit_int32 (acfg, info_offset);
acfg->stats.plt_size += 10;
#endif
#elif defined(TARGET_ARM)
guint8 buf [256];
guint8 *code;
code = buf;
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
ARM_LDR_REG_REG (code, ARMREG_PC, ARMREG_PC, ARMREG_IP);
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, got_symbol, ".", offset - 4);
/* Used by mono_aot_get_plt_info_offset */
emit_int32 (acfg, info_offset);
#elif defined(TARGET_ARM64)
arm64_emit_plt_entry (acfg, got_symbol, offset, info_offset);
#elif defined(TARGET_POWERPC)
/* The GOT address is guaranteed to be in r30 by OP_LOAD_GOTADDR */
emit_unset_mode (acfg);
fprintf (acfg->fp, "lis 11, %d@h\n", offset);
fprintf (acfg->fp, "ori 11, 11, %d@l\n", offset);
fprintf (acfg->fp, "add 11, 11, 30\n");
fprintf (acfg->fp, "%s 11, 0(11)\n", PPC_LD_OP);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
fprintf (acfg->fp, "%s 2, %d(11)\n", PPC_LD_OP, (int)sizeof (target_mgreg_t));
fprintf (acfg->fp, "%s 11, 0(11)\n", PPC_LD_OP);
#endif
fprintf (acfg->fp, "mtctr 11\n");
fprintf (acfg->fp, "bctr\n");
emit_int32 (acfg, info_offset);
#else
g_assert_not_reached ();
#endif
}
/*
* arch_emit_llvm_plt_entry:
*
* Same as arch_emit_plt_entry, but handles calls from LLVM generated code.
* This is only needed on arm to handle thumb interop.
*/
static void
arch_emit_llvm_plt_entry (MonoAotCompile *acfg, const char *got_symbol, int plt_index, int offset, int info_offset)
{
#if defined(TARGET_ARM)
/* LLVM calls the PLT entries using bl, so these have to be thumb2 */
/* The caller already transitioned to thumb */
/* The code below should be 12 bytes long */
/* clang has trouble encoding these instructions, so emit the binary */
#if 0
fprintf (acfg->fp, "ldr ip, [pc, #8]\n");
/* thumb can't encode ld pc, [pc, ip] */
fprintf (acfg->fp, "add ip, pc, ip\n");
fprintf (acfg->fp, "ldr ip, [ip, #0]\n");
fprintf (acfg->fp, "bx ip\n");
#endif
emit_set_thumb_mode (acfg);
fprintf (acfg->fp, ".4byte 0xc008f8df\n");
fprintf (acfg->fp, ".2byte 0x44fc\n");
fprintf (acfg->fp, ".4byte 0xc000f8dc\n");
fprintf (acfg->fp, ".2byte 0x4760\n");
emit_symbol_diff (acfg, got_symbol, ".", offset + 4);
emit_int32 (acfg, info_offset);
emit_unset_mode (acfg);
emit_set_arm_mode (acfg);
#else
g_assert_not_reached ();
#endif
}
/* Save unwind_info in the module and emit the offset to the information at symbol */
static void save_unwind_info (MonoAotCompile *acfg, char *symbol, GSList *unwind_ops)
{
guint32 uw_offset, encoded_len;
guint8 *encoded;
emit_section_change (acfg, RODATA_SECT, 0);
emit_global (acfg, symbol, FALSE);
emit_label (acfg, symbol);
encoded = mono_unwind_ops_encode (unwind_ops, &encoded_len);
uw_offset = get_unwind_info_offset (acfg, encoded, encoded_len);
g_free (encoded);
emit_int32 (acfg, uw_offset);
}
/*
* arch_emit_specific_trampoline_pages:
*
* Emits a page full of trampolines: each trampoline uses its own address to
* lookup both the generic trampoline code and the data argument.
* This page can be remapped in process multiple times so we can get an
* unlimited number of trampolines.
* Specifically this implementation uses the following trick: two memory pages
* are allocated, with the first containing the data and the second containing the trampolines.
* To reduce trampoline size, each trampoline jumps at the start of the page where a common
* implementation does all the lifting.
* Note that the ARM single trampoline size is 8 bytes, exactly like the data that needs to be stored
* on the arm 32 bit system.
*/
static void
arch_emit_specific_trampoline_pages (MonoAotCompile *acfg)
{
#if defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
guint8 *loop_start, *loop_branch_back, *loop_end_check, *imt_found_check;
int i;
int pagesize = MONO_AOT_TRAMP_PAGE_SIZE;
GSList *unwind_ops = NULL;
#define COMMON_TRAMP_SIZE 16
int count = (pagesize - COMMON_TRAMP_SIZE) / 8;
int imm8, rot_amount;
char symbol [128];
if (!acfg->aot_opts.use_trampolines_page)
return;
acfg->tramp_page_size = pagesize;
sprintf (symbol, "%sspecific_trampolines_page", acfg->user_symbol_prefix);
emit_alignment (acfg, pagesize);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
/* emit the generic code first, the trampoline address + 8 is in the lr register */
code = buf;
imm8 = mono_arm_is_rotated_imm8 (pagesize, &rot_amount);
ARM_SUB_REG_IMM (code, ARMREG_LR, ARMREG_LR, imm8, rot_amount);
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_LR, -8);
ARM_LDR_IMM (code, ARMREG_PC, ARMREG_LR, -4);
ARM_NOP (code);
g_assert (code - buf == COMMON_TRAMP_SIZE);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
for (i = 0; i < count; ++i) {
code = buf;
ARM_PUSH (code, 0x5fff);
ARM_BL (code, 0);
arm_patch (code - 4, code - COMMON_TRAMP_SIZE - 8 * (i + 1));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
}
/* now the rgctx trampolines: each specific trampolines puts in the ip register
* the instruction pointer address, so the generic trampoline at the start of the page
* subtracts 4096 to get to the data page and loads the values
* We again fit the generic trampiline in 16 bytes.
*/
sprintf (symbol, "%srgctx_trampolines_page", acfg->user_symbol_prefix);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
imm8 = mono_arm_is_rotated_imm8 (pagesize, &rot_amount);
ARM_SUB_REG_IMM (code, ARMREG_IP, ARMREG_IP, imm8, rot_amount);
ARM_LDR_IMM (code, MONO_ARCH_RGCTX_REG, ARMREG_IP, -8);
ARM_LDR_IMM (code, ARMREG_PC, ARMREG_IP, -4);
ARM_NOP (code);
g_assert (code - buf == COMMON_TRAMP_SIZE);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
for (i = 0; i < count; ++i) {
code = buf;
ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_PC);
ARM_B (code, 0);
arm_patch (code - 4, code - COMMON_TRAMP_SIZE - 8 * (i + 1));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
}
/*
* gsharedvt arg trampolines: see arch_emit_gsharedvt_arg_trampoline ()
*/
sprintf (symbol, "%sgsharedvt_arg_trampolines_page", acfg->user_symbol_prefix);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
ARM_PUSH (code, (1 << ARMREG_R0) | (1 << ARMREG_R1) | (1 << ARMREG_R2) | (1 << ARMREG_R3));
imm8 = mono_arm_is_rotated_imm8 (pagesize, &rot_amount);
ARM_SUB_REG_IMM (code, ARMREG_IP, ARMREG_IP, imm8, rot_amount);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_IP, -8);
ARM_LDR_IMM (code, ARMREG_PC, ARMREG_IP, -4);
g_assert (code - buf == COMMON_TRAMP_SIZE);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
for (i = 0; i < count; ++i) {
code = buf;
ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_PC);
ARM_B (code, 0);
arm_patch (code - 4, code - COMMON_TRAMP_SIZE - 8 * (i + 1));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
}
/* now the unbox arbitrary trampolines: each specific trampolines puts in the ip register
* the instruction pointer address, so the generic trampoline at the start of the page
* subtracts 4096 to get to the data page and loads the target addr.
* We again fit the generic trampoline in 16 bytes.
*/
sprintf (symbol, "%sunbox_arbitrary_trampolines_page", acfg->user_symbol_prefix);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, MONO_ABI_SIZEOF (MonoObject));
imm8 = mono_arm_is_rotated_imm8 (pagesize, &rot_amount);
ARM_SUB_REG_IMM (code, ARMREG_IP, ARMREG_IP, imm8, rot_amount);
ARM_LDR_IMM (code, ARMREG_PC, ARMREG_IP, -4);
ARM_NOP (code);
g_assert (code - buf == COMMON_TRAMP_SIZE);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
for (i = 0; i < count; ++i) {
code = buf;
ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_PC);
ARM_B (code, 0);
arm_patch (code - 4, code - COMMON_TRAMP_SIZE - 8 * (i + 1));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
}
/* now the imt trampolines: each specific trampolines puts in the ip register
* the instruction pointer address, so the generic trampoline at the start of the page
* subtracts 4096 to get to the data page and loads the values
*/
#define IMT_TRAMP_SIZE 72
sprintf (symbol, "%simt_trampolines_page", acfg->user_symbol_prefix);
emit_global (acfg, symbol, TRUE);
emit_label (acfg, symbol);
code = buf;
/* Need at least two free registers, plus a slot for storing the pc */
ARM_PUSH (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_R2));
imm8 = mono_arm_is_rotated_imm8 (pagesize, &rot_amount);
ARM_SUB_REG_IMM (code, ARMREG_IP, ARMREG_IP, imm8, rot_amount);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_IP, -8);
/* The IMT method is in v5, r0 has the imt array address */
loop_start = code;
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_R0, 0);
ARM_CMP_REG_REG (code, ARMREG_R1, ARMREG_V5);
imt_found_check = code;
ARM_B_COND (code, ARMCOND_EQ, 0);
/* End-of-loop check */
ARM_CMP_REG_IMM (code, ARMREG_R1, 0, 0);
loop_end_check = code;
ARM_B_COND (code, ARMCOND_EQ, 0);
/* Loop footer */
ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, sizeof (target_mgreg_t) * 2);
loop_branch_back = code;
ARM_B (code, 0);
arm_patch (loop_branch_back, loop_start);
/* Match */
arm_patch (imt_found_check, code);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 4);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 0);
/* Save it to the third stack slot */
ARM_STR_IMM (code, ARMREG_R0, ARMREG_SP, 8);
/* Restore the registers and branch */
ARM_POP (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_PC));
/* No match */
arm_patch (loop_end_check, code);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 4);
ARM_STR_IMM (code, ARMREG_R0, ARMREG_SP, 8);
ARM_POP (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_PC));
ARM_NOP (code);
/* Emit it */
g_assert (code - buf == IMT_TRAMP_SIZE);
emit_bytes (acfg, buf, code - buf);
for (i = 0; i < count; ++i) {
code = buf;
ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_PC);
ARM_B (code, 0);
arm_patch (code - 4, code - IMT_TRAMP_SIZE - 8 * (i + 1));
g_assert (code - buf == 8);
emit_bytes (acfg, buf, code - buf);
}
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_SPECIFIC] = 16;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_STATIC_RGCTX] = 16;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_IMT] = 72;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_GSHAREDVT_ARG] = 16;
acfg->tramp_page_code_offsets [MONO_AOT_TRAMP_UNBOX_ARBITRARY] = 16;
/* Unwind info for specifc trampolines */
sprintf (symbol, "%sspecific_trampolines_page_gen_p", acfg->user_symbol_prefix);
/* We unwind to the original caller, from the stack, since lr is clobbered */
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 14 * sizeof (target_mgreg_t));
mono_add_unwind_op_offset (unwind_ops, 0, 0, ARMREG_LR, -4);
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
sprintf (symbol, "%sspecific_trampolines_page_sp_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
mono_add_unwind_op_def_cfa_offset (unwind_ops, 4, 0, 14 * sizeof (target_mgreg_t));
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
/* Unwind info for rgctx trampolines */
sprintf (symbol, "%srgctx_trampolines_page_gen_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
save_unwind_info (acfg, symbol, unwind_ops);
sprintf (symbol, "%srgctx_trampolines_page_sp_p", acfg->user_symbol_prefix);
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
/* Unwind info for gsharedvt trampolines */
sprintf (symbol, "%sgsharedvt_trampolines_page_gen_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
mono_add_unwind_op_def_cfa_offset (unwind_ops, 4, 0, 4 * sizeof (target_mgreg_t));
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
sprintf (symbol, "%sgsharedvt_trampolines_page_sp_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
/* Unwind info for unbox arbitrary trampolines */
sprintf (symbol, "%sunbox_arbitrary_trampolines_page_gen_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
save_unwind_info (acfg, symbol, unwind_ops);
sprintf (symbol, "%sunbox_arbitrary_trampolines_page_sp_p", acfg->user_symbol_prefix);
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
/* Unwind info for imt trampolines */
sprintf (symbol, "%simt_trampolines_page_gen_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
mono_add_unwind_op_def_cfa_offset (unwind_ops, 4, 0, 3 * sizeof (target_mgreg_t));
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
sprintf (symbol, "%simt_trampolines_page_sp_p", acfg->user_symbol_prefix);
mono_add_unwind_op_def_cfa (unwind_ops, 0, 0, ARMREG_SP, 0);
save_unwind_info (acfg, symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
#elif defined(TARGET_ARM64)
arm64_emit_specific_trampoline_pages (acfg);
#endif
}
/*
* arch_emit_specific_trampoline:
*
* Emit code for a specific trampoline. OFFSET is the offset of the first of
* two GOT slots which contain the generic trampoline address and the trampoline
* argument. TRAMP_SIZE is set to the size of the emitted trampoline.
*/
static void
arch_emit_specific_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
/*
* The trampolines created here are variations of the specific
* trampolines created in mono_arch_create_specific_trampoline (). The
* differences are:
* - the generic trampoline address is taken from a got slot.
* - the offset of the got slot where the trampoline argument is stored
* is embedded in the instruction stream, and the generic trampoline
* can load the argument by loading the offset, adding it to the
* address of the trampoline to get the address of the got slot, and
* loading the argument from there.
* - all the trampolines should be of the same length.
*/
#if defined(TARGET_AMD64)
/* This should be exactly 8 bytes long */
*tramp_size = 8;
/* call *<offset>(%rip) */
if (acfg->llvm) {
emit_byte (acfg, '\x41');
emit_unset_mode (acfg);
fprintf (acfg->fp, "call *%s+%d(%%rip)\n", acfg->got_symbol, (int)(offset * sizeof (target_mgreg_t)));
emit_zero_bytes (acfg, 1);
} else {
emit_byte (acfg, '\x41');
emit_byte (acfg, '\xff');
emit_byte (acfg, '\x15');
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) - 4);
emit_zero_bytes (acfg, 1);
}
#elif defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
/* This should be exactly 20 bytes long */
*tramp_size = 20;
code = buf;
ARM_PUSH (code, 0x5fff);
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 4);
/* Load the value from the GOT */
ARM_LDR_REG_REG (code, ARMREG_R1, ARMREG_PC, ARMREG_R1);
/* Branch to it */
ARM_BLX_REG (code, ARMREG_R1);
g_assert (code - buf == 16);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
/*
* Only one offset is needed, since the second one would be equal to the
* first one.
*/
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) - 4 + 4);
//emit_symbol_diff (acfg, acfg->got_symbol, ".", ((offset + 1) * sizeof (target_mgreg_t)) - 4 + 8);
#elif defined(TARGET_ARM64)
arm64_emit_specific_trampoline (acfg, offset, tramp_size);
#elif defined(TARGET_POWERPC)
guint8 buf [128];
guint8 *code;
*tramp_size = 4;
code = buf;
/*
* PPC has no ip relative addressing, so we need to compute the address
* of the mscorlib got. That is slow and complex, so instead, we store it
* in the second got slot of every aot image. The caller already computed
* the address of its got and placed it into r30.
*/
emit_unset_mode (acfg);
/* Load mscorlib got address */
fprintf (acfg->fp, "%s 0, %d(30)\n", PPC_LD_OP, (int)sizeof (target_mgreg_t));
/* Load generic trampoline address */
fprintf (acfg->fp, "lis 11, %d@h\n", (int)(offset * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "ori 11, 11, %d@l\n", (int)(offset * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "%s 11, 11, 0\n", PPC_LDX_OP);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
fprintf (acfg->fp, "%s 11, 0(11)\n", PPC_LD_OP);
#endif
fprintf (acfg->fp, "mtctr 11\n");
/* Load trampoline argument */
/* On ppc, we pass it normally to the generic trampoline */
fprintf (acfg->fp, "lis 11, %d@h\n", (int)((offset + 1) * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "ori 11, 11, %d@l\n", (int)((offset + 1) * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "%s 0, 11, 0\n", PPC_LDX_OP);
/* Branch to generic trampoline */
fprintf (acfg->fp, "bctr\n");
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
*tramp_size = 10 * 4;
#else
*tramp_size = 9 * 4;
#endif
#elif defined(TARGET_X86)
guint8 buf [128];
guint8 *code;
/* Similar to the PPC code above */
/* FIXME: Could this clobber the register needed by get_vcall_slot () ? */
code = buf;
/* Load mscorlib got address */
x86_mov_reg_membase (code, X86_ECX, MONO_ARCH_GOT_REG, sizeof (target_mgreg_t), 4);
/* Push trampoline argument */
x86_push_membase (code, X86_ECX, (offset + 1) * sizeof (target_mgreg_t));
/* Load generic trampoline address */
x86_mov_reg_membase (code, X86_ECX, X86_ECX, offset * sizeof (target_mgreg_t), 4);
/* Branch to generic trampoline */
x86_jump_reg (code, X86_ECX);
emit_bytes (acfg, buf, code - buf);
*tramp_size = 17;
g_assert (code - buf == *tramp_size);
#else
g_assert_not_reached ();
#endif
}
/*
* arch_emit_unbox_trampoline:
*
* Emit code for the unbox trampoline for METHOD used in the full-aot case.
* CALL_TARGET is the symbol pointing to the native code of METHOD.
*
* See mono_aot_get_unbox_trampoline.
*/
static void
arch_emit_unbox_trampoline (MonoAotCompile *acfg, MonoCompile *cfg, MonoMethod *method, const char *call_target)
{
#if defined(TARGET_AMD64)
guint8 buf [32];
guint8 *code;
int this_reg;
this_reg = mono_arch_get_this_arg_reg (NULL);
code = buf;
amd64_alu_reg_imm (code, X86_ADD, this_reg, MONO_ABI_SIZEOF (MonoObject));
emit_bytes (acfg, buf, code - buf);
/* jump <method> */
if (acfg->llvm) {
emit_unset_mode (acfg);
fprintf (acfg->fp, "jmp %s\n", call_target);
} else {
emit_byte (acfg, '\xe9');
emit_symbol_diff (acfg, call_target, ".", -4);
}
#elif defined(TARGET_X86)
guint8 buf [32];
guint8 *code;
int this_pos = 4;
code = buf;
x86_alu_membase_imm (code, X86_ADD, X86_ESP, this_pos, MONO_ABI_SIZEOF (MonoObject));
emit_bytes (acfg, buf, code - buf);
/* jump <method> */
emit_byte (acfg, '\xe9');
emit_symbol_diff (acfg, call_target, ".", -4);
#elif defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
if (acfg->thumb_mixed && cfg->compile_llvm) {
fprintf (acfg->fp, "add r0, r0, #%d\n", (int)MONO_ABI_SIZEOF (MonoObject));
fprintf (acfg->fp, "b %s\n", call_target);
fprintf (acfg->fp, ".arm\n");
fprintf (acfg->fp, ".align 2\n");
return;
}
code = buf;
ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, MONO_ABI_SIZEOF (MonoObject));
emit_bytes (acfg, buf, code - buf);
/* jump to method */
if (acfg->thumb_mixed && cfg->compile_llvm)
fprintf (acfg->fp, "\n\tbx %s\n", call_target);
else
fprintf (acfg->fp, "\n\tb %s\n", call_target);
#elif defined(TARGET_ARM64)
arm64_emit_unbox_trampoline (acfg, cfg, method, call_target);
#elif defined(TARGET_POWERPC)
int this_pos = 3;
fprintf (acfg->fp, "\n\taddi %d, %d, %d\n", this_pos, this_pos, (int)MONO_ABI_SIZEOF (MonoObject));
fprintf (acfg->fp, "\n\tb %s\n", call_target);
#else
g_assert_not_reached ();
#endif
}
/*
* arch_emit_static_rgctx_trampoline:
*
* Emit code for a static rgctx trampoline. OFFSET is the offset of the first of
* two GOT slots which contain the rgctx argument, and the method to jump to.
* TRAMP_SIZE is set to the size of the emitted trampoline.
* These kinds of trampolines cannot be enumerated statically, since there could
* be one trampoline per method instantiation, so we emit the same code for all
* trampolines, and parameterize them using two GOT slots.
*/
static void
arch_emit_static_rgctx_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_AMD64)
/* This should be exactly 13 bytes long */
*tramp_size = 13;
if (acfg->llvm) {
emit_unset_mode (acfg);
fprintf (acfg->fp, "mov %s+%d(%%rip), %%r10\n", acfg->got_symbol, (int)(offset * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "jmp *%s+%d(%%rip)\n", acfg->got_symbol, (int)((offset + 1) * sizeof (target_mgreg_t)));
} else {
/* mov <OFFSET>(%rip), %r10 */
emit_byte (acfg, '\x4d');
emit_byte (acfg, '\x8b');
emit_byte (acfg, '\x15');
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) - 4);
/* jmp *<offset>(%rip) */
emit_byte (acfg, '\xff');
emit_byte (acfg, '\x25');
emit_symbol_diff (acfg, acfg->got_symbol, ".", ((offset + 1) * sizeof (target_mgreg_t)) - 4);
}
#elif defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
/* This should be exactly 24 bytes long */
*tramp_size = 24;
code = buf;
/* Load rgctx value */
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 8);
ARM_LDR_REG_REG (code, MONO_ARCH_RGCTX_REG, ARMREG_PC, ARMREG_IP);
/* Load branch addr + branch */
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 4);
ARM_LDR_REG_REG (code, ARMREG_PC, ARMREG_PC, ARMREG_IP);
g_assert (code - buf == 16);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) - 4 + 8);
emit_symbol_diff (acfg, acfg->got_symbol, ".", ((offset + 1) * sizeof (target_mgreg_t)) - 4 + 4);
#elif defined(TARGET_ARM64)
arm64_emit_static_rgctx_trampoline (acfg, offset, tramp_size);
#elif defined(TARGET_POWERPC)
guint8 buf [128];
guint8 *code;
*tramp_size = 4;
code = buf;
/*
* PPC has no ip relative addressing, so we need to compute the address
* of the mscorlib got. That is slow and complex, so instead, we store it
* in the second got slot of every aot image. The caller already computed
* the address of its got and placed it into r30.
*/
emit_unset_mode (acfg);
/* Load mscorlib got address */
fprintf (acfg->fp, "%s 0, %d(30)\n", PPC_LD_OP, (int)sizeof (target_mgreg_t));
/* Load rgctx */
fprintf (acfg->fp, "lis 11, %d@h\n", (int)(offset * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "ori 11, 11, %d@l\n", (int)(offset * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "%s %d, 11, 0\n", PPC_LDX_OP, MONO_ARCH_RGCTX_REG);
/* Load target address */
fprintf (acfg->fp, "lis 11, %d@h\n", (int)((offset + 1) * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "ori 11, 11, %d@l\n", (int)((offset + 1) * sizeof (target_mgreg_t)));
fprintf (acfg->fp, "%s 11, 11, 0\n", PPC_LDX_OP);
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
fprintf (acfg->fp, "%s 2, %d(11)\n", PPC_LD_OP, (int)sizeof (target_mgreg_t));
fprintf (acfg->fp, "%s 11, 0(11)\n", PPC_LD_OP);
#endif
fprintf (acfg->fp, "mtctr 11\n");
/* Branch to the target address */
fprintf (acfg->fp, "bctr\n");
#ifdef PPC_USES_FUNCTION_DESCRIPTOR
*tramp_size = 11 * 4;
#else
*tramp_size = 9 * 4;
#endif
#elif defined(TARGET_X86)
guint8 buf [128];
guint8 *code;
/* Similar to the PPC code above */
g_assert (MONO_ARCH_RGCTX_REG != X86_ECX);
code = buf;
/* Load mscorlib got address */
x86_mov_reg_membase (code, X86_ECX, MONO_ARCH_GOT_REG, sizeof (target_mgreg_t), 4);
/* Load arg */
x86_mov_reg_membase (code, MONO_ARCH_RGCTX_REG, X86_ECX, offset * sizeof (target_mgreg_t), 4);
/* Branch to the target address */
x86_jump_membase (code, X86_ECX, (offset + 1) * sizeof (target_mgreg_t));
emit_bytes (acfg, buf, code - buf);
*tramp_size = 15;
g_assert (code - buf == *tramp_size);
#else
g_assert_not_reached ();
#endif
}
/*
* arch_emit_imt_trampoline:
*
* Emit an IMT trampoline usable in full-aot mode. The trampoline uses 1 got slot which
* points to an array of pointer pairs. The pairs of the form [key, ptr], where
* key is the IMT key, and ptr holds the address of a memory location holding
* the address to branch to if the IMT arg matches the key. The array is
* terminated by a pair whose key is NULL, and whose ptr is the address of the
* fail_tramp.
* TRAMP_SIZE is set to the size of the emitted trampoline.
*/
static void
arch_emit_imt_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_AMD64)
guint8 *buf, *code;
guint8 *labels [16];
guint8 mov_buf[3];
guint8 *mov_buf_ptr = mov_buf;
const int kSizeOfMove = 7;
code = buf = (guint8 *)g_malloc (256);
/* FIXME: Optimize this, i.e. use binary search etc. */
/* Maybe move the body into a separate function (slower, but much smaller) */
/* MONO_ARCH_IMT_SCRATCH_REG is a free register */
if (acfg->llvm) {
emit_unset_mode (acfg);
fprintf (acfg->fp, "mov %s+%d(%%rip), %s\n", acfg->got_symbol, (int)(offset * sizeof (target_mgreg_t)), mono_arch_regname (MONO_ARCH_IMT_SCRATCH_REG));
}
labels [0] = code;
amd64_alu_membase_imm (code, X86_CMP, MONO_ARCH_IMT_SCRATCH_REG, 0, 0);
labels [1] = code;
amd64_branch8 (code, X86_CC_Z, 0, FALSE);
/* Check key */
amd64_alu_membase_reg_size (code, X86_CMP, MONO_ARCH_IMT_SCRATCH_REG, 0, MONO_ARCH_IMT_REG, sizeof (target_mgreg_t));
labels [2] = code;
amd64_branch8 (code, X86_CC_Z, 0, FALSE);
/* Loop footer */
amd64_alu_reg_imm (code, X86_ADD, MONO_ARCH_IMT_SCRATCH_REG, 2 * sizeof (target_mgreg_t));
amd64_jump_code (code, labels [0]);
/* Match */
mono_amd64_patch (labels [2], code);
amd64_mov_reg_membase (code, MONO_ARCH_IMT_SCRATCH_REG, MONO_ARCH_IMT_SCRATCH_REG, sizeof (target_mgreg_t), sizeof (target_mgreg_t));
amd64_jump_membase (code, MONO_ARCH_IMT_SCRATCH_REG, 0);
/* No match */
mono_amd64_patch (labels [1], code);
/* Load fail tramp */
amd64_alu_reg_imm (code, X86_ADD, MONO_ARCH_IMT_SCRATCH_REG, sizeof (target_mgreg_t));
/* Check if there is a fail tramp */
amd64_alu_membase_imm (code, X86_CMP, MONO_ARCH_IMT_SCRATCH_REG, 0, 0);
labels [3] = code;
amd64_branch8 (code, X86_CC_Z, 0, FALSE);
/* Jump to fail tramp */
amd64_jump_membase (code, MONO_ARCH_IMT_SCRATCH_REG, 0);
/* Fail */
mono_amd64_patch (labels [3], code);
x86_breakpoint (code);
if (!acfg->llvm) {
/* mov <OFFSET>(%rip), MONO_ARCH_IMT_SCRATCH_REG */
amd64_emit_rex (mov_buf_ptr, sizeof(gpointer), MONO_ARCH_IMT_SCRATCH_REG, 0, AMD64_RIP);
*(mov_buf_ptr)++ = (unsigned char)0x8b; /* mov opcode */
x86_address_byte (mov_buf_ptr, 0, MONO_ARCH_IMT_SCRATCH_REG & 0x7, 5);
emit_bytes (acfg, mov_buf, mov_buf_ptr - mov_buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) - 4);
}
emit_bytes (acfg, buf, code - buf);
*tramp_size = code - buf + kSizeOfMove;
g_free (buf);
#elif defined(TARGET_X86)
guint8 *buf, *code;
guint8 *labels [16];
code = buf = g_malloc (256);
/* Allocate a temporary stack slot */
x86_push_reg (code, X86_EAX);
/* Save EAX */
x86_push_reg (code, X86_EAX);
/* Load mscorlib got address */
x86_mov_reg_membase (code, X86_EAX, MONO_ARCH_GOT_REG, sizeof (target_mgreg_t), 4);
/* Load arg */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, offset * sizeof (target_mgreg_t), 4);
labels [0] = code;
x86_alu_membase_imm (code, X86_CMP, X86_EAX, 0, 0);
labels [1] = code;
x86_branch8 (code, X86_CC_Z, FALSE, 0);
/* Check key */
x86_alu_membase_reg (code, X86_CMP, X86_EAX, 0, MONO_ARCH_IMT_REG);
labels [2] = code;
x86_branch8 (code, X86_CC_Z, FALSE, 0);
/* Loop footer */
x86_alu_reg_imm (code, X86_ADD, X86_EAX, 2 * sizeof (target_mgreg_t));
x86_jump_code (code, labels [0]);
/* Match */
mono_x86_patch (labels [2], code);
x86_mov_reg_membase (code, X86_EAX, X86_EAX, sizeof (target_mgreg_t), 4);
x86_mov_reg_membase (code, X86_EAX, X86_EAX, 0, 4);
/* Save the target address to the temporary stack location */
x86_mov_membase_reg (code, X86_ESP, 4, X86_EAX, 4);
/* Restore EAX */
x86_pop_reg (code, X86_EAX);
/* Jump to the target address */
x86_ret (code);
/* No match */
mono_x86_patch (labels [1], code);
/* Load fail tramp */
x86_mov_reg_membase (code, X86_EAX, X86_EAX, sizeof (target_mgreg_t), 4);
x86_alu_membase_imm (code, X86_CMP, X86_EAX, 0, 0);
labels [3] = code;
x86_branch8 (code, X86_CC_Z, FALSE, 0);
/* Jump to fail tramp */
x86_mov_membase_reg (code, X86_ESP, 4, X86_EAX, 4);
x86_pop_reg (code, X86_EAX);
x86_ret (code);
/* Fail */
mono_x86_patch (labels [3], code);
x86_breakpoint (code);
emit_bytes (acfg, buf, code - buf);
*tramp_size = code - buf;
g_free (buf);
#elif defined(TARGET_ARM)
guint8 buf [128];
guint8 *code, *code2, *labels [16];
code = buf;
/* The IMT method is in v5 */
/* Need at least two free registers, plus a slot for storing the pc */
ARM_PUSH (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_R2));
labels [0] = code;
/* Load the parameter from the GOT */
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_PC, 0);
ARM_LDR_REG_REG (code, ARMREG_R0, ARMREG_PC, ARMREG_R0);
labels [1] = code;
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_R0, 0);
ARM_CMP_REG_REG (code, ARMREG_R1, ARMREG_V5);
labels [2] = code;
ARM_B_COND (code, ARMCOND_EQ, 0);
/* End-of-loop check */
ARM_CMP_REG_IMM (code, ARMREG_R1, 0, 0);
labels [3] = code;
ARM_B_COND (code, ARMCOND_EQ, 0);
/* Loop footer */
ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, sizeof (target_mgreg_t) * 2);
labels [4] = code;
ARM_B (code, 0);
arm_patch (labels [4], labels [1]);
/* Match */
arm_patch (labels [2], code);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 4);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 0);
/* Save it to the third stack slot */
ARM_STR_IMM (code, ARMREG_R0, ARMREG_SP, 8);
/* Restore the registers and branch */
ARM_POP (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_PC));
/* No match */
arm_patch (labels [3], code);
ARM_LDR_IMM (code, ARMREG_R0, ARMREG_R0, 4);
ARM_STR_IMM (code, ARMREG_R0, ARMREG_SP, 8);
ARM_POP (code, (1 << ARMREG_R0)|(1 << ARMREG_R1)|(1 << ARMREG_PC));
/* Fixup offset */
code2 = labels [0];
ARM_LDR_IMM (code2, ARMREG_R0, ARMREG_PC, (code - (labels [0] + 8)));
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + (code - (labels [0] + 8)) - 4);
*tramp_size = code - buf + 4;
#elif defined(TARGET_ARM64)
arm64_emit_imt_trampoline (acfg, offset, tramp_size);
#elif defined(TARGET_POWERPC)
guint8 buf [128];
guint8 *code, *labels [16];
code = buf;
/* Load the mscorlib got address */
ppc_ldptr (code, ppc_r12, sizeof (target_mgreg_t), ppc_r30);
/* Load the parameter from the GOT */
ppc_load (code, ppc_r0, offset * sizeof (target_mgreg_t));
ppc_ldptr_indexed (code, ppc_r12, ppc_r12, ppc_r0);
/* Load and check key */
labels [1] = code;
ppc_ldptr (code, ppc_r0, 0, ppc_r12);
ppc_cmp (code, 0, sizeof (target_mgreg_t) == 8 ? 1 : 0, ppc_r0, MONO_ARCH_IMT_REG);
labels [2] = code;
ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
/* End-of-loop check */
ppc_cmpi (code, 0, sizeof (target_mgreg_t) == 8 ? 1 : 0, ppc_r0, 0);
labels [3] = code;
ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0);
/* Loop footer */
ppc_addi (code, ppc_r12, ppc_r12, 2 * sizeof (target_mgreg_t));
labels [4] = code;
ppc_b (code, 0);
mono_ppc_patch (labels [4], labels [1]);
/* Match */
mono_ppc_patch (labels [2], code);
ppc_ldptr (code, ppc_r12, sizeof (target_mgreg_t), ppc_r12);
/* r12 now contains the value of the vtable slot */
/* this is not a function descriptor on ppc64 */
ppc_ldptr (code, ppc_r12, 0, ppc_r12);
ppc_mtctr (code, ppc_r12);
ppc_bcctr (code, PPC_BR_ALWAYS, 0);
/* Fail */
mono_ppc_patch (labels [3], code);
/* FIXME: */
ppc_break (code);
*tramp_size = code - buf;
emit_bytes (acfg, buf, code - buf);
#else
g_assert_not_reached ();
#endif
}
#if defined (TARGET_AMD64)
static void
amd64_emit_load_got_slot (MonoAotCompile *acfg, int dreg, int got_slot)
{
g_assert (acfg->fp);
emit_unset_mode (acfg);
fprintf (acfg->fp, "mov %s+%d(%%rip), %s\n", acfg->got_symbol, (unsigned int) ((got_slot * sizeof (target_mgreg_t))), mono_arch_regname (dreg));
}
#endif
/*
* arch_emit_gsharedvt_arg_trampoline:
*
* Emit code for a gsharedvt arg trampoline. OFFSET is the offset of the first of
* two GOT slots which contain the argument, and the code to jump to.
* TRAMP_SIZE is set to the size of the emitted trampoline.
* These kinds of trampolines cannot be enumerated statically, since there could
* be one trampoline per method instantiation, so we emit the same code for all
* trampolines, and parameterize them using two GOT slots.
*/
static void
arch_emit_gsharedvt_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_X86)
guint8 buf [128];
guint8 *code;
/* Similar to the PPC code above */
g_assert (MONO_ARCH_RGCTX_REG != X86_ECX);
code = buf;
/* Load mscorlib got address */
x86_mov_reg_membase (code, X86_ECX, MONO_ARCH_GOT_REG, sizeof (target_mgreg_t), 4);
/* Load arg */
x86_mov_reg_membase (code, X86_EAX, X86_ECX, offset * sizeof (target_mgreg_t), 4);
/* Branch to the target address */
x86_jump_membase (code, X86_ECX, (offset + 1) * sizeof (target_mgreg_t));
emit_bytes (acfg, buf, code - buf);
*tramp_size = 15;
g_assert (code - buf == *tramp_size);
#elif defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
/* The same as mono_arch_get_gsharedvt_arg_trampoline (), but for AOT */
/* Similar to arch_emit_specific_trampoline () */
*tramp_size = 24;
code = buf;
ARM_PUSH (code, (1 << ARMREG_R0) | (1 << ARMREG_R1) | (1 << ARMREG_R2) | (1 << ARMREG_R3));
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 8);
/* Load the arg value from the GOT */
ARM_LDR_REG_REG (code, ARMREG_R0, ARMREG_PC, ARMREG_R1);
/* Load the addr from the GOT */
ARM_LDR_REG_REG (code, ARMREG_R1, ARMREG_PC, ARMREG_R1);
/* Branch to it */
ARM_BX (code, ARMREG_R1);
g_assert (code - buf == 20);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + 4);
#elif defined(TARGET_ARM64)
arm64_emit_gsharedvt_arg_trampoline (acfg, offset, tramp_size);
#elif defined (TARGET_AMD64)
amd64_emit_load_got_slot (acfg, AMD64_RAX, offset);
amd64_emit_load_got_slot (acfg, MONO_ARCH_IMT_SCRATCH_REG, offset + 1);
g_assert (AMD64_R11 == MONO_ARCH_IMT_SCRATCH_REG);
fprintf (acfg->fp, "jmp *%%r11\n");
*tramp_size = 0x11;
#else
g_assert_not_reached ();
#endif
}
static void
arch_emit_ftnptr_arg_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_ARM)
guint8 buf [128];
guint8 *code;
*tramp_size = 32;
code = buf;
/* Load target address and push it on stack */
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 16);
ARM_LDR_REG_REG (code, ARMREG_IP, ARMREG_PC, ARMREG_IP);
ARM_PUSH (code, 1 << ARMREG_IP);
/* Load argument in ARMREG_IP */
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 8);
ARM_LDR_REG_REG (code, ARMREG_IP, ARMREG_PC, ARMREG_IP);
/* Branch */
ARM_POP (code, 1 << ARMREG_PC);
g_assert (code - buf == 24);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", ((offset + 1) * sizeof (target_mgreg_t)) + 12); // offset from ldr pc to addr
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + 4); // offset from ldr pc to arg
#else
g_assert_not_reached ();
#endif
}
static void
arch_emit_unbox_arbitrary_trampoline (MonoAotCompile *acfg, int offset, int *tramp_size)
{
#if defined(TARGET_ARM64)
emit_unset_mode (acfg);
fprintf (acfg->fp, "add x0, x0, %d\n", (int)(MONO_ABI_SIZEOF (MonoObject)));
arm64_emit_load_got_slot (acfg, ARMREG_R17, offset);
fprintf (acfg->fp, "br x17\n");
*tramp_size = 5 * 4;
#elif defined (TARGET_AMD64)
guint8 buf [32];
guint8 *code;
int this_reg;
this_reg = mono_arch_get_this_arg_reg (NULL);
code = buf;
amd64_alu_reg_imm (code, X86_ADD, this_reg, MONO_ABI_SIZEOF (MonoObject));
emit_bytes (acfg, buf, code - buf);
amd64_emit_load_got_slot (acfg, AMD64_RAX, offset);
fprintf (acfg->fp, "jmp *%%rax\n");
*tramp_size = 13;
#elif defined (TARGET_ARM)
guint8 buf [32];
guint8 *code, *label;
code = buf;
/* Unbox */
ARM_ADD_REG_IMM8 (code, ARMREG_R0, ARMREG_R0, MONO_ABI_SIZEOF (MonoObject));
label = code;
/* Calculate GOT slot */
ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
/* Load target addr into PC*/
ARM_LDR_REG_REG (code, ARMREG_PC, ARMREG_PC, ARMREG_IP);
g_assert (code - buf == 12);
/* Emit it */
emit_bytes (acfg, buf, code - buf);
emit_symbol_diff (acfg, acfg->got_symbol, ".", (offset * sizeof (target_mgreg_t)) + (code - (label + 8)) - 4);
*tramp_size = 4 * 4;
#else
g_error ("NOT IMPLEMENTED: needed for AOT<>interp mixed mode transition");
#endif
}
/* END OF ARCH SPECIFIC CODE */
static guint32
mono_get_field_token (MonoClassField *field)
{
MonoClass *klass = field->parent;
int i;
int fcount = mono_class_get_field_count (klass);
MonoClassField *klass_fields = m_class_get_fields (klass);
for (i = 0; i < fcount; ++i) {
if (field == &klass_fields [i])
return MONO_TOKEN_FIELD_DEF | (mono_class_get_first_field_idx (klass) + 1 + i);
}
g_assert_not_reached ();
return 0;
}
static void
encode_value (gint32 value, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
//printf ("ENCODE: %d 0x%x.\n", value, value);
/*
* Same encoding as the one used in the metadata, extended to handle values
* greater than 0x1fffffff.
*/
if ((value >= 0) && (value <= 127))
*p++ = value;
else if ((value >= 0) && (value <= 16383)) {
p [0] = 0x80 | (value >> 8);
p [1] = value & 0xff;
p += 2;
} else if ((value >= 0) && (value <= 0x1fffffff)) {
p [0] = (value >> 24) | 0xc0;
p [1] = (value >> 16) & 0xff;
p [2] = (value >> 8) & 0xff;
p [3] = value & 0xff;
p += 4;
}
else {
p [0] = 0xff;
p [1] = (value >> 24) & 0xff;
p [2] = (value >> 16) & 0xff;
p [3] = (value >> 8) & 0xff;
p [4] = value & 0xff;
p += 5;
}
if (endbuf)
*endbuf = p;
}
static void
stream_init (MonoDynamicStream *sh)
{
sh->index = 0;
sh->alloc_size = 4096;
sh->data = (char *)g_malloc (4096);
/* So offsets are > 0 */
sh->data [0] = 0;
sh->index ++;
}
static void
make_room_in_stream (MonoDynamicStream *stream, int size)
{
if (size <= stream->alloc_size)
return;
while (stream->alloc_size <= size) {
if (stream->alloc_size < 4096)
stream->alloc_size = 4096;
else
stream->alloc_size *= 2;
}
stream->data = (char *)g_realloc (stream->data, stream->alloc_size);
}
static guint32
add_stream_data (MonoDynamicStream *stream, const char *data, guint32 len)
{
guint32 idx;
make_room_in_stream (stream, stream->index + len);
memcpy (stream->data + stream->index, data, len);
idx = stream->index;
stream->index += len;
return idx;
}
/*
* add_to_blob:
*
* Add data to the binary blob inside the aot image. Returns the offset inside the
* blob where the data was stored.
*/
static guint32
add_to_blob (MonoAotCompile *acfg, const guint8 *data, guint32 data_len)
{
g_assert (!acfg->blob_closed);
if (acfg->blob.alloc_size == 0)
stream_init (&acfg->blob);
acfg->stats.blob_size += data_len;
return add_stream_data (&acfg->blob, (char*)data, data_len);
}
static guint32
add_to_blob_aligned (MonoAotCompile *acfg, const guint8 *data, guint32 data_len, guint32 align)
{
char buf [4] = {0};
guint32 count;
if (acfg->blob.alloc_size == 0)
stream_init (&acfg->blob);
count = acfg->blob.index % align;
/* we assume the stream data will be aligned */
if (count)
add_stream_data (&acfg->blob, buf, 4 - count);
return add_stream_data (&acfg->blob, (char*)data, data_len);
}
/* Emit a table of data into the aot image */
static void
emit_aot_data (MonoAotCompile *acfg, MonoAotFileTable table, const char *symbol, guint8 *data, int size)
{
if (acfg->data_outfile) {
acfg->table_offsets [(int)table] = acfg->datafile_offset;
fwrite (data,1, size, acfg->data_outfile);
acfg->datafile_offset += size;
// align the data to 8 bytes. Put zeros in the file (so that every build results in consistent output).
int align = 8 - size % 8;
acfg->datafile_offset += align;
guint8 align_buf [16];
memset (&align_buf, 0, sizeof (align_buf));
fwrite (align_buf, align, 1, acfg->data_outfile);
} else if (acfg->llvm) {
mono_llvm_emit_aot_data (symbol, data, size);
} else {
emit_section_change (acfg, RODATA_SECT, 0);
emit_alignment (acfg, 8);
emit_label (acfg, symbol);
emit_bytes (acfg, data, size);
}
}
/*
* emit_offset_table:
*
* Emit a table of increasing offsets in a compact form using differential encoding.
* There is an index entry for each GROUP_SIZE number of entries. The greater the
* group size, the more compact the table becomes, but the slower it becomes to compute
* a given entry. Returns the size of the table.
*/
static guint32
emit_offset_table (MonoAotCompile *acfg, const char *symbol, MonoAotFileTable table, int noffsets, int group_size, gint32 *offsets)
{
gint32 current_offset;
int i, buf_size, ngroups, index_entry_size;
guint8 *p, *buf;
guint8 *data_p, *data_buf;
guint32 *index_offsets;
ngroups = (noffsets + (group_size - 1)) / group_size;
index_offsets = g_new0 (guint32, ngroups);
buf_size = noffsets * 4;
p = buf = (guint8 *)g_malloc0 (buf_size);
current_offset = 0;
for (i = 0; i < noffsets; ++i) {
//printf ("D: %d -> %d\n", i, offsets [i]);
if ((i % group_size) == 0) {
index_offsets [i / group_size] = p - buf;
/* Emit the full value for these entries */
encode_value (offsets [i], p, &p);
} else {
/* The offsets are allowed to be non-increasing */
//g_assert (offsets [i] >= current_offset);
encode_value (offsets [i] - current_offset, p, &p);
}
current_offset = offsets [i];
}
data_buf = buf;
data_p = p;
if (ngroups && index_offsets [ngroups - 1] < 65000)
index_entry_size = 2;
else
index_entry_size = 4;
buf_size = (data_p - data_buf) + (ngroups * 4) + 16;
p = buf = (guint8 *)g_malloc0 (buf_size);
/* Emit the header */
encode_int (noffsets, p, &p);
encode_int (group_size, p, &p);
encode_int (ngroups, p, &p);
encode_int (index_entry_size, p, &p);
/* Emit the index */
for (i = 0; i < ngroups; ++i) {
if (index_entry_size == 2)
encode_int16 (index_offsets [i], p, &p);
else
encode_int (index_offsets [i], p, &p);
}
/* Emit the data */
memcpy (p, data_buf, data_p - data_buf);
p += data_p - data_buf;
g_assert (p - buf <= buf_size);
emit_aot_data (acfg, table, symbol, buf, p - buf);
g_free (buf);
g_free (data_buf);
return (int)(p - buf);
}
static guint32
get_image_index (MonoAotCompile *cfg, MonoImage *image)
{
guint32 index;
index = GPOINTER_TO_UINT (g_hash_table_lookup (cfg->image_hash, image));
if (index)
return index - 1;
else {
index = g_hash_table_size (cfg->image_hash);
g_hash_table_insert (cfg->image_hash, image, GUINT_TO_POINTER (index + 1));
g_ptr_array_add (cfg->image_table, image);
return index;
}
}
static guint32
find_typespec_for_class (MonoAotCompile *acfg, MonoClass *klass)
{
int i;
int len = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPESPEC]);
/* FIXME: Search referenced images as well */
if (!acfg->typespec_classes) {
acfg->typespec_classes = g_hash_table_new (NULL, NULL);
for (i = 0; i < len; i++) {
ERROR_DECL (error);
int typespec = MONO_TOKEN_TYPE_SPEC | (i + 1);
MonoClass *klass_key = mono_class_get_and_inflate_typespec_checked (acfg->image, typespec, NULL, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
continue;
}
g_hash_table_insert (acfg->typespec_classes, klass_key, GINT_TO_POINTER (typespec));
}
}
return GPOINTER_TO_INT (g_hash_table_lookup (acfg->typespec_classes, klass));
}
static void
encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 **endbuf);
static void
encode_klass_ref (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, guint8 **endbuf);
static void
encode_ginst (MonoAotCompile *acfg, MonoGenericInst *inst, guint8 *buf, guint8 **endbuf);
static void
encode_type (MonoAotCompile *acfg, MonoType *t, guint8 *buf, guint8 **endbuf);
static guint32
get_shared_ginst_ref (MonoAotCompile *acfg, MonoGenericInst *ginst);
static void
encode_klass_ref_inner (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
/*
* The encoding begins with one of the MONO_AOT_TYPEREF values, followed by additional
* information.
*/
if (mono_class_is_ginst (klass)) {
guint32 token;
g_assert (m_class_get_type_token (klass));
/* Find a typespec for a class if possible */
token = find_typespec_for_class (acfg, klass);
if (token) {
encode_value (MONO_AOT_TYPEREF_TYPESPEC_TOKEN, p, &p);
encode_value (token, p, &p);
} else {
MonoClass *gclass = mono_class_get_generic_class (klass)->container_class;
MonoGenericInst *inst = mono_class_get_generic_class (klass)->context.class_inst;
static int count = 0;
guint8 *p1 = p;
encode_value (MONO_AOT_TYPEREF_GINST, p, &p);
encode_klass_ref (acfg, gclass, p, &p);
guint32 offset = get_shared_ginst_ref (acfg, inst);
encode_value (offset, p, &p);
count += p - p1;
}
} else if (m_class_get_type_token (klass)) {
int iindex = get_image_index (acfg, m_class_get_image (klass));
g_assert (mono_metadata_token_code (m_class_get_type_token (klass)) == MONO_TOKEN_TYPE_DEF);
if (iindex == 0) {
encode_value (MONO_AOT_TYPEREF_TYPEDEF_INDEX, p, &p);
encode_value (m_class_get_type_token (klass) - MONO_TOKEN_TYPE_DEF, p, &p);
} else {
encode_value (MONO_AOT_TYPEREF_TYPEDEF_INDEX_IMAGE, p, &p);
encode_value (m_class_get_type_token (klass) - MONO_TOKEN_TYPE_DEF, p, &p);
encode_value (get_image_index (acfg, m_class_get_image (klass)), p, &p);
}
} else if ((m_class_get_byval_arg (klass)->type == MONO_TYPE_VAR) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_MVAR)) {
MonoGenericContainer *container = mono_type_get_generic_param_owner (m_class_get_byval_arg (klass));
MonoGenericParam *par = m_class_get_byval_arg (klass)->data.generic_param;
encode_value (MONO_AOT_TYPEREF_VAR, p, &p);
encode_value (par->gshared_constraint ? 1 : 0, p, &p);
if (par->gshared_constraint) {
MonoGSharedGenericParam *gpar = (MonoGSharedGenericParam*)par;
encode_type (acfg, par->gshared_constraint, p, &p);
encode_klass_ref (acfg, mono_class_create_generic_parameter (gpar->parent), p, &p);
} else {
encode_value (m_class_get_byval_arg (klass)->type, p, &p);
encode_value (mono_type_get_generic_param_num (m_class_get_byval_arg (klass)), p, &p);
encode_value (container->is_anonymous ? 0 : 1, p, &p);
if (!container->is_anonymous) {
encode_value (container->is_method, p, &p);
if (container->is_method)
encode_method_ref (acfg, container->owner.method, p, &p);
else
encode_klass_ref (acfg, container->owner.klass, p, &p);
}
}
} else if (m_class_get_byval_arg (klass)->type == MONO_TYPE_PTR) {
encode_value (MONO_AOT_TYPEREF_PTR, p, &p);
encode_type (acfg, m_class_get_byval_arg (klass), p, &p);
} else {
/* Array class */
g_assert (m_class_get_rank (klass) > 0);
encode_value (MONO_AOT_TYPEREF_ARRAY, p, &p);
encode_value (m_class_get_rank (klass), p, &p);
encode_klass_ref (acfg, m_class_get_element_class (klass), p, &p);
}
acfg->stats.class_ref_count++;
acfg->stats.class_ref_size += p - buf;
*endbuf = p;
}
static guint32
get_shared_klass_ref (MonoAotCompile *acfg, MonoClass *klass)
{
guint offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->klass_blob_hash, klass));
guint8 *buf2, *p;
if (!offset) {
buf2 = (guint8 *)g_malloc (1024);
p = buf2;
encode_klass_ref_inner (acfg, klass, p, &p);
g_assert (p - buf2 < 1024);
offset = add_to_blob (acfg, buf2, p - buf2);
g_free (buf2);
g_hash_table_insert (acfg->klass_blob_hash, klass, GUINT_TO_POINTER (offset + 1));
} else {
offset --;
}
return offset;
}
/*
* encode_klass_ref:
*
* Encode a reference to KLASS. We use our home-grown encoding instead of the
* standard metadata encoding.
*/
static void
encode_klass_ref (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, guint8 **endbuf)
{
gboolean shared = FALSE;
/*
* The encoding of generic instances is large so emit them only once.
*/
if (mono_class_is_ginst (klass)) {
guint32 token;
g_assert (m_class_get_type_token (klass));
/* Find a typespec for a class if possible */
token = find_typespec_for_class (acfg, klass);
if (!token)
shared = TRUE;
} else if ((m_class_get_byval_arg (klass)->type == MONO_TYPE_VAR) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_MVAR)) {
shared = TRUE;
}
if (shared) {
guint8 *p;
guint32 offset = get_shared_klass_ref (acfg, klass);
p = buf;
encode_value (MONO_AOT_TYPEREF_BLOB_INDEX, p, &p);
encode_value (offset, p, &p);
*endbuf = p;
return;
}
encode_klass_ref_inner (acfg, klass, buf, endbuf);
}
static void
encode_field_info (MonoAotCompile *cfg, MonoClassField *field, guint8 *buf, guint8 **endbuf)
{
guint32 token = mono_get_field_token (field);
guint8 *p = buf;
encode_klass_ref (cfg, field->parent, p, &p);
g_assert (mono_metadata_token_code (token) == MONO_TOKEN_FIELD_DEF);
encode_value (token - MONO_TOKEN_FIELD_DEF, p, &p);
*endbuf = p;
}
static void
encode_ginst (MonoAotCompile *acfg, MonoGenericInst *inst, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
int i;
encode_value (inst->type_argc, p, &p);
for (i = 0; i < inst->type_argc; ++i)
encode_klass_ref (acfg, mono_class_from_mono_type_internal (inst->type_argv [i]), p, &p);
acfg->stats.ginst_count++;
acfg->stats.ginst_size += p - buf;
*endbuf = p;
}
static guint32
get_shared_ginst_ref (MonoAotCompile *acfg, MonoGenericInst *ginst)
{
guint32 offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->ginst_blob_hash, ginst));
if (!offset) {
guint8 *buf2, *p2;
int len;
len = 1024 + (ginst->type_argc * 32);
buf2 = (guint8 *)g_malloc (len);
p2 = buf2;
encode_ginst (acfg, ginst, p2, &p2);
g_assert (p2 - buf2 < len);
offset = add_to_blob (acfg, buf2, p2 - buf2);
g_free (buf2);
g_hash_table_insert (acfg->ginst_blob_hash, ginst, GUINT_TO_POINTER (offset + 1));
} else {
offset --;
}
return offset;
}
static void
encode_generic_context (MonoAotCompile *acfg, MonoGenericContext *context, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
MonoGenericInst *inst;
guint32 flags = (context->class_inst ? 1 : 0) | (context->method_inst ? 2 : 0);
g_assert (flags);
encode_value (flags, p, &p);
inst = context->class_inst;
if (inst) {
guint32 offset = get_shared_ginst_ref (acfg, inst);
encode_value (offset, p, &p);
}
inst = context->method_inst;
if (inst) {
guint32 offset = get_shared_ginst_ref (acfg, inst);
encode_value (offset, p, &p);
}
*endbuf = p;
}
static void
encode_type (MonoAotCompile *acfg, MonoType *t, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
if (t->has_cmods) {
int count = mono_type_custom_modifier_count (t);
*p = MONO_TYPE_CMOD_REQD;
++p;
encode_value (count, p, &p);
for (int i = 0; i < count; ++i) {
ERROR_DECL (error);
gboolean required;
MonoType *cmod_type = mono_type_get_custom_modifier (t, i, &required, error);
mono_error_assert_ok (error);
encode_value (required, p, &p);
encode_type (acfg, cmod_type, p, &p);
}
}
/* t->attrs can be ignored */
//g_assert (t->attrs == 0);
if (t->pinned) {
*p = MONO_TYPE_PINNED;
++p;
}
if (t->byref) {
*p = MONO_TYPE_BYREF;
++p;
}
*p = t->type;
p ++;
switch (t->type) {
case MONO_TYPE_VOID:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_CHAR:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
case MONO_TYPE_TYPEDBYREF:
break;
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_CLASS:
encode_klass_ref (acfg, mono_class_from_mono_type_internal (t), p, &p);
break;
case MONO_TYPE_SZARRAY:
encode_klass_ref (acfg, t->data.klass, p, &p);
break;
case MONO_TYPE_PTR:
encode_type (acfg, t->data.type, p, &p);
break;
case MONO_TYPE_FNPTR:
encode_signature (acfg, t->data.method, p, &p);
break;
case MONO_TYPE_GENERICINST: {
MonoClass *gclass = t->data.generic_class->container_class;
MonoGenericInst *inst = t->data.generic_class->context.class_inst;
encode_klass_ref (acfg, gclass, p, &p);
encode_ginst (acfg, inst, p, &p);
break;
}
case MONO_TYPE_ARRAY: {
MonoArrayType *array = t->data.array;
int i;
encode_klass_ref (acfg, array->eklass, p, &p);
encode_value (array->rank, p, &p);
encode_value (array->numsizes, p, &p);
for (i = 0; i < array->numsizes; ++i)
encode_value (array->sizes [i], p, &p);
encode_value (array->numlobounds, p, &p);
for (i = 0; i < array->numlobounds; ++i)
encode_value (array->lobounds [i], p, &p);
break;
}
case MONO_TYPE_VAR:
case MONO_TYPE_MVAR:
encode_klass_ref (acfg, mono_class_from_mono_type_internal (t), p, &p);
break;
default:
g_assert_not_reached ();
}
*endbuf = p;
}
static void
encode_signature (MonoAotCompile *acfg, MonoMethodSignature *sig, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
guint32 flags = 0;
int i;
/* Similar to the metadata encoding */
if (sig->generic_param_count)
flags |= 0x10;
if (sig->hasthis)
flags |= 0x20;
if (sig->explicit_this)
flags |= 0x40;
flags |= (sig->call_convention & 0x0F);
*p = flags;
++p;
if (sig->generic_param_count)
encode_value (sig->generic_param_count, p, &p);
encode_value (sig->param_count, p, &p);
encode_type (acfg, sig->ret, p, &p);
for (i = 0; i < sig->param_count; ++i) {
if (sig->sentinelpos == i) {
*p = MONO_TYPE_SENTINEL;
++p;
}
encode_type (acfg, sig->params [i], p, &p);
}
*endbuf = p;
}
#define MAX_IMAGE_INDEX 250
static void
encode_method_ref (MonoAotCompile *acfg, MonoMethod *method, guint8 *buf, guint8 **endbuf)
{
guint32 image_index = get_image_index (acfg, m_class_get_image (method->klass));
guint32 token = method->token;
MonoJumpInfoToken *ji;
guint8 *p = buf;
/*
* The encoding for most methods is as follows:
* - image index encoded as a leb128
* - token index encoded as a leb128
* Values of image index >= MONO_AOT_METHODREF_MIN are used to mark additional
* types of method encodings.
*/
/* Mark methods which can't use aot trampolines because they need the further
* processing in mono_magic_trampoline () which requires a MonoMethod*.
*/
if ((method->is_generic && (method->flags & METHOD_ATTRIBUTE_VIRTUAL)) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED))
encode_value ((MONO_AOT_METHODREF_NO_AOT_TRAMPOLINE << 24), p, &p);
if (method->wrapper_type) {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
encode_value ((MONO_AOT_METHODREF_WRAPPER << 24), p, &p);
encode_value (method->wrapper_type, p, &p);
switch (method->wrapper_type) {
case MONO_WRAPPER_ALLOC: {
/* The GC name is saved once in MonoAotFileInfo */
g_assert (info->d.alloc.alloc_type != -1);
encode_value (info->d.alloc.alloc_type, p, &p);
break;
}
case MONO_WRAPPER_WRITE_BARRIER: {
g_assert (info);
break;
}
case MONO_WRAPPER_STELEMREF: {
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_VIRTUAL_STELEMREF)
encode_value (info->d.virtual_stelemref.kind, p, &p);
break;
}
case MONO_WRAPPER_OTHER: {
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_PTR_TO_STRUCTURE ||
info->subtype == WRAPPER_SUBTYPE_STRUCTURE_TO_PTR)
encode_klass_ref (acfg, method->klass, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER)
encode_method_ref (acfg, info->d.synchronized_inner.method, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_ARRAY_ACCESSOR)
encode_method_ref (acfg, info->d.array_accessor.method, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_INTERP_IN)
encode_signature (acfg, info->d.interp_in.sig, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG)
encode_signature (acfg, info->d.gsharedvt.sig, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG)
encode_signature (acfg, info->d.gsharedvt.sig, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_INTERP_LMF)
encode_value (info->d.icall.jit_icall_id, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_AOT_INIT)
encode_value (info->d.aot_init.subtype, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_LLVM_FUNC)
encode_value (info->d.llvm_func.subtype, p, &p);
break;
}
case MONO_WRAPPER_MANAGED_TO_NATIVE: {
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER) {
encode_value (info->d.icall.jit_icall_id, p, &p);
} else if (info->subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_AOT) {
encode_method_ref (acfg, info->d.managed_to_native.method, p, &p);
} else {
g_assert (info->subtype == WRAPPER_SUBTYPE_NONE || info->subtype == WRAPPER_SUBTYPE_PINVOKE);
encode_method_ref (acfg, info->d.managed_to_native.method, p, &p);
}
break;
}
case MONO_WRAPPER_SYNCHRONIZED: {
MonoMethod *m;
m = mono_marshal_method_from_wrapper (method);
g_assert (m);
g_assert (m != method);
encode_method_ref (acfg, m, p, &p);
break;
}
case MONO_WRAPPER_MANAGED_TO_MANAGED: {
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_ELEMENT_ADDR) {
encode_value (info->d.element_addr.rank, p, &p);
encode_value (info->d.element_addr.elem_size, p, &p);
} else if (info->subtype == WRAPPER_SUBTYPE_STRING_CTOR) {
encode_method_ref (acfg, info->d.string_ctor.method, p, &p);
} else if (info->subtype == WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER) {
encode_klass_ref (acfg, info->d.generic_array_helper.klass, p, &p);
encode_method_ref (acfg, info->d.generic_array_helper.method, p, &p);
int len = strlen (info->d.generic_array_helper.name);
guint32 idx = add_to_blob (acfg, (guint8*)info->d.generic_array_helper.name, len + 1);
encode_value (idx, p, &p);
} else {
g_assert_not_reached ();
}
break;
}
case MONO_WRAPPER_CASTCLASS: {
g_assert (info);
encode_value (info->subtype, p, &p);
break;
}
case MONO_WRAPPER_RUNTIME_INVOKE: {
g_assert (info);
encode_value (info->subtype, p, &p);
if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT || info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL)
encode_method_ref (acfg, info->d.runtime_invoke.method, p, &p);
else if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL)
encode_signature (acfg, info->d.runtime_invoke.sig, p, &p);
break;
}
case MONO_WRAPPER_DELEGATE_INVOKE:
case MONO_WRAPPER_DELEGATE_BEGIN_INVOKE:
case MONO_WRAPPER_DELEGATE_END_INVOKE: {
if (method->is_inflated) {
/* These wrappers are identified by their class */
encode_value (1, p, &p);
encode_klass_ref (acfg, method->klass, p, &p);
} else {
MonoMethodSignature *sig = mono_method_signature_internal (method);
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
encode_value (0, p, &p);
if (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE)
encode_value (info ? info->subtype : 0, p, &p);
encode_signature (acfg, sig, p, &p);
}
break;
}
case MONO_WRAPPER_NATIVE_TO_MANAGED: {
g_assert (info);
encode_method_ref (acfg, info->d.native_to_managed.method, p, &p);
MonoClass *klass = info->d.native_to_managed.klass;
if (!klass) {
encode_value (0, p, &p);
} else {
encode_value (1, p, &p);
encode_klass_ref (acfg, klass, p, &p);
}
break;
}
default:
g_assert_not_reached ();
}
} else if (mono_method_signature_internal (method)->is_inflated) {
/*
* This is a generic method, find the original token which referenced it and
* encode that.
* Obtain the token from information recorded by the JIT.
*/
ji = (MonoJumpInfoToken *)g_hash_table_lookup (acfg->token_info_hash, method);
if (ji) {
image_index = get_image_index (acfg, ji->image);
g_assert (image_index < MAX_IMAGE_INDEX);
token = ji->token;
encode_value ((MONO_AOT_METHODREF_METHODSPEC << 24), p, &p);
encode_value (image_index, p, &p);
encode_value (token, p, &p);
} else if (g_hash_table_lookup (acfg->method_blob_hash, method)) {
/* Already emitted as part of an rgctx fetch */
guint32 offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_blob_hash, method));
offset --;
encode_value ((MONO_AOT_METHODREF_BLOB_INDEX << 24), p, &p);
encode_value (offset, p, &p);
} else {
MonoMethod *declaring;
MonoGenericContext *context = mono_method_get_context (method);
g_assert (method->is_inflated);
declaring = ((MonoMethodInflated*)method)->declaring;
/*
* This might be a non-generic method of a generic instance, which
* doesn't have a token since the reference is generated by the JIT
* like Nullable:Box/Unbox, or by generic sharing.
*/
encode_value ((MONO_AOT_METHODREF_GINST << 24), p, &p);
/* Encode the klass */
encode_klass_ref (acfg, method->klass, p, &p);
/* Encode the method */
image_index = get_image_index (acfg, m_class_get_image (method->klass));
g_assert (image_index < MAX_IMAGE_INDEX);
g_assert (declaring->token);
token = declaring->token;
g_assert (mono_metadata_token_table (token) == MONO_TABLE_METHOD);
encode_value (image_index, p, &p);
encode_value (mono_metadata_token_index (token), p, &p);
encode_generic_context (acfg, context, p, &p);
}
} else if (token == 0) {
/* This might be a method of a constructed type like int[,].Set */
/* Obtain the token from information recorded by the JIT */
ji = (MonoJumpInfoToken *)g_hash_table_lookup (acfg->token_info_hash, method);
if (ji) {
image_index = get_image_index (acfg, ji->image);
g_assert (image_index < MAX_IMAGE_INDEX);
token = ji->token;
encode_value ((MONO_AOT_METHODREF_METHODSPEC << 24), p, &p);
encode_value (image_index, p, &p);
encode_value (token, p, &p);
} else {
/* Array methods */
g_assert (m_class_get_rank (method->klass));
/* Encode directly */
encode_value ((MONO_AOT_METHODREF_ARRAY << 24), p, &p);
encode_klass_ref (acfg, method->klass, p, &p);
if (!strcmp (method->name, ".ctor") && mono_method_signature_internal (method)->param_count == m_class_get_rank (method->klass))
encode_value (0, p, &p);
else if (!strcmp (method->name, ".ctor") && mono_method_signature_internal (method)->param_count == m_class_get_rank (method->klass) * 2)
encode_value (1, p, &p);
else if (!strcmp (method->name, "Get"))
encode_value (2, p, &p);
else if (!strcmp (method->name, "Address"))
encode_value (3, p, &p);
else if (!strcmp (method->name, "Set"))
encode_value (4, p, &p);
else
g_assert_not_reached ();
}
} else {
g_assert (mono_metadata_token_table (token) == MONO_TABLE_METHOD);
if (image_index >= MONO_AOT_METHODREF_MIN) {
encode_value ((MONO_AOT_METHODREF_LARGE_IMAGE_INDEX << 24), p, &p);
encode_value (image_index, p, &p);
encode_value (mono_metadata_token_index (token), p, &p);
} else {
encode_value ((image_index << 24) | mono_metadata_token_index (token), p, &p);
}
}
acfg->stats.method_ref_count++;
acfg->stats.method_ref_size += p - buf;
*endbuf = p;
}
static guint32
get_shared_method_ref (MonoAotCompile *acfg, MonoMethod *method)
{
guint32 offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_blob_hash, method));
if (!offset) {
guint8 *buf2, *p2;
buf2 = (guint8 *)g_malloc (1024);
p2 = buf2;
encode_method_ref (acfg, method, p2, &p2);
g_assert (p2 - buf2 < 1024);
offset = add_to_blob (acfg, buf2, p2 - buf2);
g_free (buf2);
g_hash_table_insert (acfg->method_blob_hash, method, GUINT_TO_POINTER (offset + 1));
} else {
offset --;
}
return offset;
}
static gint
compare_patches (gconstpointer a, gconstpointer b)
{
int i, j;
i = (*(MonoJumpInfo**)a)->ip.i;
j = (*(MonoJumpInfo**)b)->ip.i;
if (i < j)
return -1;
else
if (i > j)
return 1;
else
return 0;
}
static G_GNUC_UNUSED char*
patch_to_string (MonoJumpInfo *patch_info)
{
GString *str;
str = g_string_new ("");
g_string_append_printf (str, "%s(", get_patch_name (patch_info->type));
switch (patch_info->type) {
case MONO_PATCH_INFO_VTABLE:
mono_type_get_desc (str, m_class_get_byval_arg (patch_info->data.klass), TRUE);
break;
default:
break;
}
g_string_append_printf (str, ")");
return g_string_free (str, FALSE);
}
/*
* is_plt_patch:
*
* Return whenever PATCH_INFO refers to a direct call, and thus requires a
* PLT entry.
*/
static gboolean
is_plt_patch (MonoJumpInfo *patch_info)
{
switch (patch_info->type) {
case MONO_PATCH_INFO_METHOD:
case MONO_PATCH_INFO_JIT_ICALL_ID:
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
case MONO_PATCH_INFO_ICALL_ADDR_CALL:
case MONO_PATCH_INFO_RGCTX_FETCH:
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR:
return TRUE;
case MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL:
default:
return FALSE;
}
}
/*
* get_plt_symbol:
*
* Return the symbol identifying the plt entry PLT_OFFSET.
*/
static char*
get_plt_symbol (MonoAotCompile *acfg, int plt_offset, MonoJumpInfo *patch_info)
{
#ifdef TARGET_MACH
/*
* The Apple linker reorganizes object files, so it doesn't like branches to local
* labels, since those have no relocations.
*/
return g_strdup_printf ("%sp_%d", acfg->llvm_label_prefix, plt_offset);
#else
return g_strdup_printf ("%sp_%d", acfg->temp_prefix, plt_offset);
#endif
}
/*
* get_plt_entry:
*
* Return a PLT entry which belongs to the method identified by PATCH_INFO.
*/
static MonoPltEntry*
get_plt_entry (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
{
MonoPltEntry *res;
gboolean synchronized = FALSE;
static int synchronized_symbol_idx;
if (!is_plt_patch (patch_info))
return NULL;
if (!acfg->patch_to_plt_entry [patch_info->type])
acfg->patch_to_plt_entry [patch_info->type] = g_hash_table_new (mono_patch_info_hash, mono_patch_info_equal);
res = (MonoPltEntry *)g_hash_table_lookup (acfg->patch_to_plt_entry [patch_info->type], patch_info);
if (!acfg->llvm && patch_info->type == MONO_PATCH_INFO_METHOD && (patch_info->data.method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)) {
/*
* Allocate a separate PLT slot for each such patch, since some plt
* entries will refer to the method itself, and some will refer to the
* wrapper.
*/
res = NULL;
synchronized = TRUE;
}
if (!res) {
MonoJumpInfo *new_ji;
new_ji = mono_patch_info_dup_mp (acfg->mempool, patch_info);
res = (MonoPltEntry *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoPltEntry));
res->plt_offset = acfg->plt_offset;
res->ji = new_ji;
res->symbol = get_plt_symbol (acfg, res->plt_offset, patch_info);
if (acfg->aot_opts.write_symbols)
res->debug_sym = get_plt_entry_debug_sym (acfg, res->ji, acfg->plt_entry_debug_sym_cache);
if (synchronized) {
/* Avoid duplicate symbols because we don't cache */
res->symbol = g_strdup_printf ("%s_%d", res->symbol, synchronized_symbol_idx);
if (res->debug_sym)
res->debug_sym = g_strdup_printf ("%s_%d", res->debug_sym, synchronized_symbol_idx);
synchronized_symbol_idx ++;
}
if (res->debug_sym)
res->llvm_symbol = g_strdup_printf ("%s_%s_llvm", res->symbol, res->debug_sym);
else
res->llvm_symbol = g_strdup_printf ("%s_llvm", res->symbol);
if (strstr (res->llvm_symbol, acfg->temp_prefix) == res->llvm_symbol) {
/* The llvm symbol shouldn't be temporary, since the llvm generated object file references it */
char *tmp = res->llvm_symbol;
res->llvm_symbol = g_strdup (res->llvm_symbol + strlen (acfg->temp_prefix));
g_free (tmp);
}
g_hash_table_insert (acfg->patch_to_plt_entry [new_ji->type], new_ji, res);
g_hash_table_insert (acfg->plt_offset_to_entry, GUINT_TO_POINTER (res->plt_offset), res);
//g_assert (mono_patch_info_equal (patch_info, new_ji));
//mono_print_ji (patch_info); printf ("\n");
//g_hash_table_print_stats (acfg->patch_to_plt_entry);
acfg->plt_offset ++;
}
return res;
}
static guint32
lookup_got_offset (MonoAotCompile *acfg, gboolean llvm, MonoJumpInfo *ji)
{
guint32 got_offset;
GotInfo *info = llvm ? &acfg->llvm_got_info : &acfg->got_info;
got_offset = GPOINTER_TO_UINT (g_hash_table_lookup (info->patch_to_got_offset_by_type [ji->type], ji));
if (got_offset)
return got_offset - 1;
g_assert_not_reached ();
}
/**
* get_got_offset:
*
* Returns the offset of the GOT slot where the runtime object resulting from resolving
* JI could be found if it exists, otherwise allocates a new one.
*/
static guint32
get_got_offset (MonoAotCompile *acfg, gboolean llvm, MonoJumpInfo *ji)
{
guint32 got_offset;
GotInfo *info = llvm ? &acfg->llvm_got_info : &acfg->got_info;
got_offset = GPOINTER_TO_UINT (g_hash_table_lookup (info->patch_to_got_offset_by_type [ji->type], ji));
if (got_offset)
return got_offset - 1;
if (llvm) {
got_offset = acfg->llvm_got_offset;
acfg->llvm_got_offset ++;
} else {
got_offset = acfg->got_offset;
acfg->got_offset ++;
}
acfg->stats.got_slots ++;
acfg->stats.got_slot_types [ji->type] ++;
g_hash_table_insert (info->patch_to_got_offset, ji, GUINT_TO_POINTER (got_offset + 1));
g_hash_table_insert (info->patch_to_got_offset_by_type [ji->type], ji, GUINT_TO_POINTER (got_offset + 1));
g_ptr_array_add (info->got_patches, ji);
return got_offset;
}
/* Add a method to the list of methods which need to be emitted */
static void
add_method_with_index (MonoAotCompile *acfg, MonoMethod *method, int index, gboolean extra)
{
g_assert (method);
if (!g_hash_table_lookup (acfg->method_indexes, method)) {
g_ptr_array_add (acfg->methods, method);
g_hash_table_insert (acfg->method_indexes, method, GUINT_TO_POINTER (index + 1));
acfg->nmethods = acfg->methods->len + 1;
while (acfg->nmethods >= acfg->cfgs_size) {
MonoCompile **new_cfgs;
int new_size;
new_size = acfg->cfgs_size ? acfg->cfgs_size * 2 : 128;
new_cfgs = g_new0 (MonoCompile*, new_size);
memcpy (new_cfgs, acfg->cfgs, sizeof (MonoCompile*) * acfg->cfgs_size);
g_free (acfg->cfgs);
acfg->cfgs = new_cfgs;
acfg->cfgs_size = new_size;
}
}
if (method->wrapper_type || extra) {
int token = mono_metadata_token_index (method->token) - 1;
if (token < 0)
acfg->nextra_methods++;
g_ptr_array_add (acfg->extra_methods, method);
}
}
static gboolean
prefer_gsharedvt_method (MonoAotCompile *acfg, MonoMethod *method)
{
/* One instantiation with valuetypes is generated for each async method */
if (m_class_get_image (method->klass) == mono_defaults.corlib && (!strcmp (m_class_get_name (method->klass), "AsyncMethodBuilderCore") || !strcmp (m_class_get_name (method->klass), "AsyncVoidMethodBuilder")))
return TRUE;
else
return FALSE;
}
static guint32
get_method_index (MonoAotCompile *acfg, MonoMethod *method)
{
int index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_indexes, method));
g_assert (index);
return index - 1;
}
static int
add_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean extra, int depth)
{
int index;
index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_indexes, method));
if (index)
return index - 1;
index = acfg->method_index;
add_method_with_index (acfg, method, index, extra);
g_ptr_array_add (acfg->method_order, GUINT_TO_POINTER (index));
g_hash_table_insert (acfg->method_depth, method, GUINT_TO_POINTER (depth));
acfg->method_index ++;
return index;
}
static int
add_method (MonoAotCompile *acfg, MonoMethod *method)
{
return add_method_full (acfg, method, FALSE, 0);
}
static void
mono_dedup_cache_method (MonoAotCompile *acfg, MonoMethod *method)
{
g_assert (acfg->dedup_stats);
char *name = mono_aot_get_mangled_method_name (method);
g_assert (name);
// For stats
char *stats_name = g_strdup (name);
g_assert (acfg->dedup_cache);
if (!g_hash_table_lookup (acfg->dedup_cache, name)) {
// This AOTCompile owns this method
// We do this to decide whether to write it to disk
// during a dedup run (first phase, where we skip).
//
// If never changed, then maybe can avoid a recompile
// of the cache.
//
// Files not read in during last phase.
acfg->dedup_cache_changed = TRUE;
// owns name
g_hash_table_insert (acfg->dedup_cache, name, method);
} else {
// owns name
g_free (name);
}
guint count = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->dedup_stats, stats_name));
count++;
g_hash_table_insert (acfg->dedup_stats, stats_name, GUINT_TO_POINTER (count));
}
static void
add_extra_method_with_depth (MonoAotCompile *acfg, MonoMethod *method, int depth)
{
ERROR_DECL (error);
if (mono_method_is_generic_sharable_full (method, TRUE, TRUE, FALSE)) {
MonoMethod *orig = method;
method = mini_get_shared_method_full (method, SHARE_MODE_NONE, error);
if (!is_ok (error)) {
/* vtype constraint */
mono_error_cleanup (error);
return;
}
/* Add it to profile_methods so its not skipped later */
if (acfg->aot_opts.profile_only && g_hash_table_lookup (acfg->profile_methods, orig))
g_hash_table_insert (acfg->profile_methods, method, method);
} else if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && prefer_gsharedvt_method (acfg, method) && mono_method_is_generic_sharable_full (method, FALSE, FALSE, TRUE)) {
/* Use the gsharedvt version */
method = mini_get_shared_method_full (method, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
}
if ((acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (method)) {
mono_dedup_cache_method (acfg, method);
if (!acfg->dedup_emit_mode)
return;
}
if (acfg->aot_opts.log_generics)
aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method));
add_method_full (acfg, method, TRUE, depth);
}
static void
add_extra_method (MonoAotCompile *acfg, MonoMethod *method)
{
add_extra_method_with_depth (acfg, method, 0);
}
static void
add_jit_icall_wrapper (MonoAotCompile *acfg, MonoJitICallInfo *callinfo)
{
if (!callinfo->sig)
return;
g_assert (callinfo->name && callinfo->func);
add_method (acfg, mono_marshal_get_icall_wrapper (callinfo, TRUE));
}
#if ENABLE_LLVM
static void
add_lazy_init_wrappers (MonoAotCompile *acfg)
{
for (int i = 0; i < AOT_INIT_METHOD_NUM; ++i)
add_method (acfg, mono_marshal_get_aot_init_wrapper ((MonoAotInitSubtype)i));
}
#endif
static MonoMethod*
get_runtime_invoke_sig (MonoMethodSignature *sig)
{
MonoMethodBuilder *mb;
MonoMethod *m;
mb = mono_mb_new (mono_defaults.object_class, "FOO", MONO_WRAPPER_NONE);
m = mono_mb_create_method (mb, sig, 16);
MonoMethod *invoke = mono_marshal_get_runtime_invoke (m, FALSE);
mono_mb_free (mb);
return invoke;
}
static MonoMethod*
get_runtime_invoke (MonoAotCompile *acfg, MonoMethod *method, gboolean virtual_)
{
return mono_marshal_get_runtime_invoke (method, virtual_);
}
static gboolean
can_marshal_struct (MonoClass *klass)
{
MonoClassField *field;
gboolean can_marshal = TRUE;
gpointer iter = NULL;
MonoMarshalType *info;
int i;
if (mono_class_is_auto_layout (klass))
return FALSE;
info = mono_marshal_load_type_info (klass);
/* Only allow a few field types to avoid asserts in the marshalling code */
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if ((field->type->attrs & FIELD_ATTRIBUTE_STATIC))
continue;
switch (field->type->type) {
case MONO_TYPE_I4:
case MONO_TYPE_U4:
case MONO_TYPE_I1:
case MONO_TYPE_U1:
case MONO_TYPE_BOOLEAN:
case MONO_TYPE_I2:
case MONO_TYPE_U2:
case MONO_TYPE_CHAR:
case MONO_TYPE_I8:
case MONO_TYPE_U8:
case MONO_TYPE_I:
case MONO_TYPE_U:
case MONO_TYPE_PTR:
case MONO_TYPE_R4:
case MONO_TYPE_R8:
case MONO_TYPE_STRING:
break;
case MONO_TYPE_VALUETYPE:
if (!m_class_is_enumtype (mono_class_from_mono_type_internal (field->type)) && !can_marshal_struct (mono_class_from_mono_type_internal (field->type)))
can_marshal = FALSE;
break;
case MONO_TYPE_SZARRAY: {
gboolean has_mspec = FALSE;
if (info) {
for (i = 0; i < info->num_fields; ++i) {
if (info->fields [i].field == field && info->fields [i].mspec)
has_mspec = TRUE;
}
}
if (!has_mspec)
can_marshal = FALSE;
break;
}
default:
can_marshal = FALSE;
break;
}
}
/* Special cases */
/* Its hard to compute whenever these can be marshalled or not */
if (!strcmp (m_class_get_name_space (klass), "System.Net.NetworkInformation.MacOsStructs") && strcmp (m_class_get_name (klass), "sockaddr_dl"))
return TRUE;
return can_marshal;
}
static void
create_gsharedvt_inst (MonoAotCompile *acfg, MonoMethod *method, MonoGenericContext *ctx)
{
/* Create a vtype instantiation */
MonoGenericContext shared_context;
MonoType **args;
MonoGenericInst *inst;
MonoGenericContainer *container;
MonoClass **constraints;
int i;
memset (ctx, 0, sizeof (MonoGenericContext));
if (mono_class_is_gtd (method->klass)) {
shared_context = mono_class_get_generic_container (method->klass)->context;
inst = shared_context.class_inst;
args = g_new0 (MonoType*, inst->type_argc);
for (i = 0; i < inst->type_argc; ++i) {
args [i] = mono_get_int_type ();
}
ctx->class_inst = mono_metadata_get_generic_inst (inst->type_argc, args);
}
if (method->is_generic) {
container = mono_method_get_generic_container (method);
g_assert (!container->is_anonymous && container->is_method);
shared_context = container->context;
inst = shared_context.method_inst;
args = g_new0 (MonoType*, inst->type_argc);
for (i = 0; i < container->type_argc; ++i) {
MonoGenericParamInfo *info = mono_generic_param_info (&container->type_params [i]);
gboolean ref_only = FALSE;
if (info && info->constraints) {
constraints = info->constraints;
while (*constraints) {
MonoClass *cklass = *constraints;
if (!(cklass == mono_defaults.object_class || (m_class_get_image (cklass) == mono_defaults.corlib && !strcmp (m_class_get_name (cklass), "ValueType"))))
/* Inflaring the method with our vtype would not be valid */
ref_only = TRUE;
constraints ++;
}
}
if (ref_only)
args [i] = mono_get_object_type ();
else
args [i] = mono_get_int_type ();
}
ctx->method_inst = mono_metadata_get_generic_inst (inst->type_argc, args);
}
}
static void
add_gc_wrappers (MonoAotCompile *acfg)
{
MonoMethod *m;
/* Managed Allocators */
int nallocators = mono_gc_get_managed_allocator_types ();
for (int i = 0; i < nallocators; ++i) {
if ((m = mono_gc_get_managed_allocator_by_type (i, MANAGED_ALLOCATOR_REGULAR)))
add_method (acfg, m);
if ((m = mono_gc_get_managed_allocator_by_type (i, MANAGED_ALLOCATOR_SLOW_PATH)))
add_method (acfg, m);
if ((m = mono_gc_get_managed_allocator_by_type (i, MANAGED_ALLOCATOR_PROFILER)))
add_method (acfg, m);
}
/* write barriers */
if (mono_gc_is_moving ()) {
add_method (acfg, mono_gc_get_specific_write_barrier (FALSE));
add_method (acfg, mono_gc_get_specific_write_barrier (TRUE));
}
}
static gboolean
contains_disable_reflection_attribute (MonoCustomAttrInfo *cattr)
{
for (int i = 0; i < cattr->num_attrs; ++i) {
MonoCustomAttrEntry *attr = &cattr->attrs [i];
if (!attr->ctor)
return FALSE;
if (strcmp (m_class_get_name_space (attr->ctor->klass), "System.Runtime.CompilerServices"))
return FALSE;
if (strcmp (m_class_get_name (attr->ctor->klass), "DisablePrivateReflectionAttribute"))
return FALSE;
}
return TRUE;
}
gboolean
mono_aot_can_specialize (MonoMethod *method)
{
if (!method)
return FALSE;
if (method->wrapper_type != MONO_WRAPPER_NONE)
return FALSE;
// If it's not private, we can't specialize
if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE)
return FALSE;
// If it has the attribute disabling the specialization, we can't specialize
//
// Set by linker, indicates that the method can be found through reflection
// and that call-site specialization shouldn't be done.
//
// Important that this attribute is used for *nothing else*
//
// If future authors make use of it (to disable more optimizations),
// change this place to use a new attribute.
ERROR_DECL (cattr_error);
MonoCustomAttrInfo *cattr = mono_custom_attrs_from_class_checked (method->klass, cattr_error);
if (!is_ok (cattr_error)) {
mono_error_cleanup (cattr_error);
goto cleanup_false;
} else if (cattr && contains_disable_reflection_attribute (cattr)) {
goto cleanup_true;
}
cattr = mono_custom_attrs_from_method_checked (method, cattr_error);
if (!is_ok (cattr_error)) {
mono_error_cleanup (cattr_error);
goto cleanup_false;
} else if (cattr && contains_disable_reflection_attribute (cattr)) {
goto cleanup_true;
} else {
goto cleanup_false;
}
cleanup_false:
if (cattr)
mono_custom_attrs_free (cattr);
return FALSE;
cleanup_true:
if (cattr)
mono_custom_attrs_free (cattr);
return TRUE;
}
static gboolean
always_aot (MonoMethod *method)
{
/*
* Calls to these methods do not go through the normal call processing code so
* calling code cannot enter the interpreter. So always aot them even in profile guided aot mode.
*/
if (method->klass == mono_get_string_class () && (strstr (method->name, "memcpy") || strstr (method->name, "bzero")))
return TRUE;
if (method->string_ctor)
return TRUE;
return FALSE;
}
gboolean
mono_aot_can_enter_interp (MonoMethod *method)
{
MonoAotCompile *acfg = current_acfg;
g_assert (acfg);
if (always_aot (method))
return FALSE;
if (acfg->aot_opts.profile_only && !g_hash_table_lookup (acfg->profile_methods, method))
return TRUE;
return FALSE;
}
static void
add_wrappers (MonoAotCompile *acfg)
{
MonoMethod *method, *m;
int i, j;
MonoMethodSignature *sig, *csig;
guint32 token;
/*
* FIXME: Instead of AOTing all the wrappers, it might be better to redesign them
* so there is only one wrapper of a given type, or inlining their contents into their
* callers.
*/
int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
gboolean skip = FALSE;
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error));
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
(method->flags & METHOD_ATTRIBUTE_ABSTRACT))
skip = TRUE;
/* Skip methods which can not be handled by get_runtime_invoke () */
sig = mono_method_signature_internal (method);
if (!sig)
continue;
if ((sig->ret->type == MONO_TYPE_PTR) ||
(sig->ret->type == MONO_TYPE_TYPEDBYREF))
skip = TRUE;
if (mono_class_is_open_constructed_type (sig->ret) || m_class_is_byreflike (mono_class_from_mono_type_internal (sig->ret)))
skip = TRUE;
for (j = 0; j < sig->param_count; j++) {
if (sig->params [j]->type == MONO_TYPE_TYPEDBYREF)
skip = TRUE;
if (mono_class_is_open_constructed_type (sig->params [j]))
skip = TRUE;
}
#ifdef MONO_ARCH_DYN_CALL_SUPPORTED
{
MonoDynCallInfo *info = mono_arch_dyn_call_prepare (sig);
gboolean has_nullable = FALSE;
for (j = 0; j < sig->param_count; j++) {
if (sig->params [j]->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type_internal (sig->params [j])))
has_nullable = TRUE;
}
if (info && !has_nullable && !acfg->aot_opts.llvm_only) {
/* Supported by the dynamic runtime-invoke wrapper */
skip = TRUE;
}
if (info)
mono_arch_dyn_call_free (info);
}
#endif
if (acfg->aot_opts.llvm_only)
/* Supported by the gsharedvt based runtime-invoke wrapper */
skip = TRUE;
if (!skip) {
//printf ("%s\n", mono_method_full_name (method, TRUE));
add_method (acfg, get_runtime_invoke (acfg, method, FALSE));
}
}
if (mono_is_corlib_image (acfg->image->assembly->image)) {
/* Runtime invoke wrappers */
MonoType *void_type = mono_get_void_type ();
MonoType *string_type = m_class_get_byval_arg (mono_defaults.string_class);
/* void runtime-invoke () [.cctor] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
csig->ret = void_type;
add_method (acfg, get_runtime_invoke_sig (csig));
/* void runtime-invoke () [Finalize] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
csig->hasthis = 1;
csig->ret = void_type;
add_method (acfg, get_runtime_invoke_sig (csig));
/* void runtime-invoke (string) [exception ctor] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 1);
csig->hasthis = 1;
csig->ret = void_type;
csig->params [0] = string_type;
add_method (acfg, get_runtime_invoke_sig (csig));
/* void runtime-invoke (string, string) [exception ctor] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
csig->hasthis = 1;
csig->ret = void_type;
csig->params [0] = string_type;
csig->params [1] = string_type;
add_method (acfg, get_runtime_invoke_sig (csig));
/* string runtime-invoke () [Exception.ToString ()] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 0);
csig->hasthis = 1;
csig->ret = string_type;
add_method (acfg, get_runtime_invoke_sig (csig));
/* void runtime-invoke (string, Exception) [exception ctor] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
csig->hasthis = 1;
csig->ret = void_type;
csig->params [0] = string_type;
csig->params [1] = m_class_get_byval_arg (mono_defaults.exception_class);
add_method (acfg, get_runtime_invoke_sig (csig));
/* Assembly runtime-invoke (string, Assembly, bool) [DoAssemblyResolve] */
csig = mono_metadata_signature_alloc (mono_defaults.corlib, 3);
csig->hasthis = 1;
csig->ret = m_class_get_byval_arg (mono_class_load_from_name (mono_defaults.corlib, "System.Reflection", "Assembly"));
csig->params [0] = string_type;
csig->params [1] = m_class_get_byval_arg (mono_class_load_from_name (mono_defaults.corlib, "System.Reflection", "Assembly"));
csig->params [2] = m_class_get_byval_arg (mono_defaults.boolean_class);
add_method (acfg, get_runtime_invoke_sig (csig));
/* runtime-invoke used by finalizers */
add_method (acfg, get_runtime_invoke (acfg, get_method_nofail (mono_defaults.object_class, "Finalize", 0, 0), TRUE));
/* This is used by mono_runtime_capture_context () */
method = mono_get_context_capture_method ();
if (method)
add_method (acfg, get_runtime_invoke (acfg, method, FALSE));
#ifdef MONO_ARCH_DYN_CALL_SUPPORTED
if (!acfg->aot_opts.llvm_only)
add_method (acfg, mono_marshal_get_runtime_invoke_dynamic ());
#endif
/* These are used by mono_jit_runtime_invoke () to calls gsharedvt out wrappers */
if (acfg->aot_opts.llvm_only) {
int variants;
/* Create simplified signatures which match the signature used by the gsharedvt out wrappers */
for (variants = 0; variants < 4; ++variants) {
for (i = 0; i < 40; ++i) {
sig = mini_get_gsharedvt_out_sig_wrapper_signature ((variants & 1) > 0, (variants & 2) > 0, i);
add_extra_method (acfg, mono_marshal_get_runtime_invoke_for_sig (sig));
g_free (sig);
}
}
}
/* stelemref */
add_method (acfg, mono_marshal_get_stelemref ());
add_gc_wrappers (acfg);
/* Stelemref wrappers */
{
MonoMethod **wrappers;
int nwrappers;
wrappers = mono_marshal_get_virtual_stelemref_wrappers (&nwrappers);
for (i = 0; i < nwrappers; ++i)
add_method (acfg, wrappers [i]);
g_free (wrappers);
}
/* castclass_with_check wrapper */
add_method (acfg, mono_marshal_get_castclass_with_cache ());
/* isinst_with_check wrapper */
add_method (acfg, mono_marshal_get_isinst_with_cache ());
/* JIT icall wrappers */
/* FIXME: locking - this is "safe" as full-AOT threads don't mutate the icall data */
for (int i = 0; i < MONO_JIT_ICALL_count; ++i)
add_jit_icall_wrapper (acfg, mono_find_jit_icall_info ((MonoJitICallId)i));
if (acfg->aot_opts.llvm_only) {
/* String ctors are called directly on llvmonly */
for (int i = 0; i < rows; ++i) {
ERROR_DECL (error);
token = MONO_TOKEN_METHOD_DEF | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
if (method && method->string_ctor) {
MonoMethod *w = get_runtime_invoke (acfg, method, FALSE);
add_method (acfg, w);
}
}
}
}
/*
* remoting-invoke-with-check wrappers are very frequent, so avoid emitting them,
* we use the original method instead at runtime.
* Since full-aot doesn't support remoting, this is not a problem.
*/
#if 0
/* remoting-invoke wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoMethodSignature *sig;
token = MONO_TOKEN_METHOD_DEF | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
sig = mono_method_signature_internal (method);
if (sig->hasthis && (method->klass->marshalbyref || method->klass == mono_defaults.object_class)) {
m = mono_marshal_get_remoting_invoke_with_check (method);
add_method (acfg, m);
}
}
#endif
/* delegate-invoke wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoClass *klass;
token = MONO_TOKEN_TYPE_DEF | (i + 1);
klass = mono_class_get_checked (acfg->image, token, error);
if (!klass) {
mono_error_cleanup (error);
continue;
}
if (!m_class_is_delegate (klass) || klass == mono_defaults.delegate_class || klass == mono_defaults.multicastdelegate_class)
continue;
if (!mono_class_is_gtd (klass)) {
method = mono_get_delegate_invoke_internal (klass);
m = mono_marshal_get_delegate_invoke (method, NULL);
add_method (acfg, m);
method = try_get_method_nofail (klass, "BeginInvoke", -1, 0);
if (method)
add_method (acfg, mono_marshal_get_delegate_begin_invoke (method));
method = try_get_method_nofail (klass, "EndInvoke", -1, 0);
if (method)
add_method (acfg, mono_marshal_get_delegate_end_invoke (method));
MonoCustomAttrInfo *cattr;
cattr = mono_custom_attrs_from_class_checked (klass, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
g_assert (!cattr);
continue;
}
if (cattr) {
int j;
for (j = 0; j < cattr->num_attrs; ++j)
if (cattr->attrs [j].ctor && (!strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "MonoNativeFunctionWrapperAttribute") || !strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "UnmanagedFunctionPointerAttribute")))
break;
if (j < cattr->num_attrs) {
MonoMethod *invoke;
MonoMethod *wrapper;
MonoMethod *del_invoke;
/* Add wrappers needed by mono_ftnptr_to_delegate () */
invoke = mono_get_delegate_invoke_internal (klass);
wrapper = mono_marshal_get_native_func_wrapper_aot (klass);
del_invoke = mono_marshal_get_delegate_invoke_internal (invoke, FALSE, TRUE, wrapper);
add_method (acfg, wrapper);
add_method (acfg, del_invoke);
}
mono_custom_attrs_free (cattr);
}
} else if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && mono_class_is_gtd (klass)) {
ERROR_DECL (error);
MonoGenericContext ctx;
MonoMethod *inst, *gshared;
/*
* Emit gsharedvt versions of the generic delegate-invoke wrappers
*/
/* Invoke */
method = mono_get_delegate_invoke_internal (klass);
create_gsharedvt_inst (acfg, method, &ctx);
inst = mono_class_inflate_generic_method_checked (method, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
m = mono_marshal_get_delegate_invoke (inst, NULL);
g_assert (m->is_inflated);
gshared = mini_get_shared_method_full (m, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
add_extra_method (acfg, gshared);
/* begin-invoke */
method = mono_get_delegate_begin_invoke_internal (klass);
if (method) {
create_gsharedvt_inst (acfg, method, &ctx);
inst = mono_class_inflate_generic_method_checked (method, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
m = mono_marshal_get_delegate_begin_invoke (inst);
g_assert (m->is_inflated);
gshared = mini_get_shared_method_full (m, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
add_extra_method (acfg, gshared);
}
/* end-invoke */
method = mono_get_delegate_end_invoke_internal (klass);
if (method) {
create_gsharedvt_inst (acfg, method, &ctx);
inst = mono_class_inflate_generic_method_checked (method, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
m = mono_marshal_get_delegate_end_invoke (inst);
g_assert (m->is_inflated);
gshared = mini_get_shared_method_full (m, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
add_extra_method (acfg, gshared);
}
}
}
/* array access wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPESPEC]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoClass *klass;
token = MONO_TOKEN_TYPE_SPEC | (i + 1);
klass = mono_class_get_checked (acfg->image, token, error);
if (!klass) {
mono_error_cleanup (error);
continue;
}
if (m_class_get_rank (klass) && MONO_TYPE_IS_PRIMITIVE (m_class_get_byval_arg (m_class_get_element_class (klass)))) {
MonoMethod *m, *wrapper;
/* Add runtime-invoke wrappers too */
m = get_method_nofail (klass, "Get", -1, 0);
g_assert (m);
wrapper = mono_marshal_get_array_accessor_wrapper (m);
add_extra_method (acfg, wrapper);
if (!acfg->aot_opts.llvm_only)
add_extra_method (acfg, get_runtime_invoke (acfg, wrapper, FALSE));
m = get_method_nofail (klass, "Set", -1, 0);
g_assert (m);
wrapper = mono_marshal_get_array_accessor_wrapper (m);
add_extra_method (acfg, wrapper);
if (!acfg->aot_opts.llvm_only)
add_extra_method (acfg, get_runtime_invoke (acfg, wrapper, FALSE));
}
}
/* Synchronized wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
token = MONO_TOKEN_METHOD_DEF | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error));
if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) {
if (method->is_generic) {
// FIXME:
} else if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && mono_class_is_gtd (method->klass)) {
ERROR_DECL (error);
MonoGenericContext ctx;
MonoMethod *inst, *gshared, *m;
/*
* Create a generic wrapper for a generic instance, and AOT that.
*/
create_gsharedvt_inst (acfg, method, &ctx);
inst = mono_class_inflate_generic_method_checked (method, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
m = mono_marshal_get_synchronized_wrapper (inst);
g_assert (m->is_inflated);
gshared = mini_get_shared_method_full (m, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
add_method (acfg, gshared);
} else {
add_method (acfg, mono_marshal_get_synchronized_wrapper (method));
}
}
}
/* pinvoke wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error));
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
add_method (acfg, mono_marshal_get_native_wrapper (method, TRUE, TRUE));
}
if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
if (acfg->aot_opts.llvm_only) {
/* The wrappers have a different signature (hasthis is not set) so need to add this too */
add_gsharedvt_wrappers (acfg, mono_method_signature_internal (method), FALSE, TRUE, FALSE);
}
}
}
/* native-to-managed wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
MonoCustomAttrInfo *cattr;
int j;
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error));
/*
* Only generate native-to-managed wrappers for methods which have an
* attribute named MonoPInvokeCallbackAttribute. We search for the attribute by
* name to avoid defining a new assembly to contain it.
*/
cattr = mono_custom_attrs_from_method_checked (method, error);
if (!is_ok (error)) {
char *name = mono_method_get_full_name (method);
report_loader_error (acfg, error, TRUE, "Failed to load custom attributes from method %s due to %s\n", name, mono_error_get_message (error));
g_free (name);
}
if (cattr) {
for (j = 0; j < cattr->num_attrs; ++j)
if (cattr->attrs [j].ctor && !strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "MonoPInvokeCallbackAttribute"))
break;
if (j < cattr->num_attrs) {
MonoCustomAttrEntry *e = &cattr->attrs [j];
MonoMethodSignature *sig = mono_method_signature_internal (e->ctor);
const char *p = (const char*)e->data;
const char *named;
int slen, num_named, named_type;
char *n;
MonoType *t;
MonoClass *klass;
char *export_name = NULL;
MonoMethod *wrapper;
/* this cannot be enforced by the C# compiler so we must give the user some warning before aborting */
if (!(method->flags & METHOD_ATTRIBUTE_STATIC)) {
g_warning ("AOT restriction: Method '%s' must be static since it is decorated with [MonoPInvokeCallback]. See https://docs.microsoft.com/xamarin/ios/internals/limitations#reverse-callbacks",
mono_method_full_name (method, TRUE));
exit (1);
}
g_assert (sig->param_count == 1);
g_assert (sig->params [0]->type == MONO_TYPE_CLASS && !strcmp (m_class_get_name (mono_class_from_mono_type_internal (sig->params [0])), "Type"));
/*
* Decode the cattr manually since we can't create objects
* during aot compilation.
*/
/* Skip prolog */
p += 2;
/* From load_cattr_value () in reflection.c */
slen = mono_metadata_decode_value (p, &p);
n = (char *)g_memdup (p, slen + 1);
n [slen] = 0;
t = mono_reflection_type_from_name_checked (n, mono_alc_get_ambient (), acfg->image, error);
g_assert (t);
mono_error_assert_ok (error);
g_free (n);
klass = mono_class_from_mono_type_internal (t);
g_assert (m_class_get_parent (klass) == mono_defaults.multicastdelegate_class);
p += slen;
num_named = read16 (p);
p += 2;
g_assert (num_named < 2);
if (num_named == 1) {
int name_len;
char *name;
/* parse ExportSymbol attribute */
named = p;
named_type = *named;
named += 1;
/* data_type = *named; */
named += 1;
name_len = mono_metadata_decode_blob_size (named, &named);
name = (char *)g_malloc (name_len + 1);
memcpy (name, named, name_len);
name [name_len] = 0;
named += name_len;
g_assert (named_type == 0x54);
g_assert (!strcmp (name, "ExportSymbol"));
/* load_cattr_value (), string case */
MONO_DISABLE_WARNING (4310) // cast truncates constant value
g_assert (*named != (char)0xFF);
MONO_RESTORE_WARNING
slen = mono_metadata_decode_value (named, &named);
export_name = (char *)g_malloc (slen + 1);
memcpy (export_name, named, slen);
export_name [slen] = 0;
named += slen;
}
wrapper = mono_marshal_get_managed_wrapper (method, klass, 0, error);
mono_error_assert_ok (error);
add_method (acfg, wrapper);
if (export_name)
g_hash_table_insert (acfg->export_names, wrapper, export_name);
}
for (j = 0; j < cattr->num_attrs; ++j)
if (cattr->attrs [j].ctor && mono_is_corlib_image (m_class_get_image (cattr->attrs [j].ctor->klass)) && !strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "UnmanagedCallersOnlyAttribute"))
break;
if (j < cattr->num_attrs) {
MonoCustomAttrEntry *e = &cattr->attrs [j];
const char *named;
int slen;
char *export_name = NULL;
MonoMethod *wrapper;
if (!(method->flags & METHOD_ATTRIBUTE_STATIC)) {
g_warning ("AOT restriction: Method '%s' must be static since it is decorated with [UnmanagedCallers].",
mono_method_full_name (method, TRUE));
exit (1);
}
gpointer *typed_args = NULL;
gpointer *named_args = NULL;
CattrNamedArg *named_arg_info = NULL;
int num_named_args = 0;
mono_reflection_create_custom_attr_data_args_noalloc (acfg->image, e->ctor, e->data, e->data_size, &typed_args, &named_args, &num_named_args, &named_arg_info, error);
mono_error_assert_ok (error);
for (j = 0; j < num_named_args; ++j) {
if (named_arg_info [j].field && !strcmp (named_arg_info [j].field->name, "EntryPoint")) {
named = named_args [j];
slen = mono_metadata_decode_value (named, &named);
export_name = (char *)g_malloc (slen + 1);
memcpy (export_name, named, slen);
export_name [slen] = 0;
}
}
g_free (named_args);
g_free (named_arg_info);
wrapper = mono_marshal_get_managed_wrapper (method, NULL, 0, error);
mono_error_assert_ok (error);
add_method (acfg, wrapper);
if (export_name)
g_hash_table_insert (acfg->export_names, wrapper, export_name);
}
g_free (cattr);
}
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)) {
add_method (acfg, mono_marshal_get_native_wrapper (method, TRUE, TRUE));
}
}
/* StructureToPtr/PtrToStructure wrappers */
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoClass *klass;
token = MONO_TOKEN_TYPE_DEF | (i + 1);
klass = mono_class_get_checked (acfg->image, token, error);
if (!klass) {
mono_error_cleanup (error);
continue;
}
if (m_class_is_valuetype (klass) && !mono_class_is_gtd (klass) && can_marshal_struct (klass) &&
!(m_class_get_nested_in (klass) && strstr (m_class_get_name (m_class_get_nested_in (klass)), "<PrivateImplementationDetails>") == m_class_get_name (m_class_get_nested_in (klass)))) {
add_method (acfg, mono_marshal_get_struct_to_ptr (klass));
add_method (acfg, mono_marshal_get_ptr_to_struct (klass));
}
}
}
static gboolean
has_type_vars (MonoClass *klass)
{
if ((m_class_get_byval_arg (klass)->type == MONO_TYPE_VAR) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_MVAR))
return TRUE;
if (m_class_get_rank (klass))
return has_type_vars (m_class_get_element_class (klass));
if (mono_class_is_ginst (klass)) {
MonoGenericContext *context = &mono_class_get_generic_class (klass)->context;
if (context->class_inst) {
int i;
for (i = 0; i < context->class_inst->type_argc; ++i)
if (has_type_vars (mono_class_from_mono_type_internal (context->class_inst->type_argv [i])))
return TRUE;
}
}
if (mono_class_is_gtd (klass))
return TRUE;
return FALSE;
}
static gboolean
is_vt_inst (MonoGenericInst *inst)
{
int i;
for (i = 0; i < inst->type_argc; ++i) {
MonoType *t = inst->type_argv [i];
if (MONO_TYPE_ISSTRUCT (t) || t->type == MONO_TYPE_VALUETYPE)
return TRUE;
}
return FALSE;
}
static gboolean
is_vt_inst_no_enum (MonoGenericInst *inst)
{
int i;
for (i = 0; i < inst->type_argc; ++i) {
MonoType *t = inst->type_argv [i];
if (MONO_TYPE_ISSTRUCT (t))
return TRUE;
}
return FALSE;
}
static gboolean
method_has_type_vars (MonoMethod *method)
{
if (has_type_vars (method->klass))
return TRUE;
if (method->is_inflated) {
MonoGenericContext *context = mono_method_get_context (method);
if (context->method_inst) {
int i;
for (i = 0; i < context->method_inst->type_argc; ++i)
if (has_type_vars (mono_class_from_mono_type_internal (context->method_inst->type_argv [i])))
return TRUE;
}
}
return FALSE;
}
static
gboolean mono_aot_mode_is_full (MonoAotOptions *opts)
{
return opts->mode == MONO_AOT_MODE_FULL;
}
static
gboolean mono_aot_mode_is_interp (MonoAotOptions *opts)
{
return opts->interp;
}
static
gboolean mono_aot_mode_is_hybrid (MonoAotOptions *opts)
{
return opts->mode == MONO_AOT_MODE_HYBRID;
}
static void add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, const char *ref);
static void
add_generic_class (MonoAotCompile *acfg, MonoClass *klass, gboolean force, const char *ref)
{
/* This might lead to a huge code blowup so only do it if neccesary */
if (!mono_aot_mode_is_full (&acfg->aot_opts) && !mono_aot_mode_is_hybrid (&acfg->aot_opts) && !force)
return;
add_generic_class_with_depth (acfg, klass, 0, ref);
}
static gboolean
check_type_depth (MonoType *t, int depth)
{
int i;
if (depth > 8)
return TRUE;
switch (t->type) {
case MONO_TYPE_GENERICINST: {
MonoGenericClass *gklass = t->data.generic_class;
MonoGenericInst *ginst = gklass->context.class_inst;
if (ginst) {
for (i = 0; i < ginst->type_argc; ++i) {
if (check_type_depth (ginst->type_argv [i], depth + 1))
return TRUE;
}
}
break;
}
default:
break;
}
return FALSE;
}
static void
add_types_from_method_header (MonoAotCompile *acfg, MonoMethod *method);
static gboolean
inst_has_vtypes (MonoGenericInst *inst)
{
for (int i = 0; i < inst->type_argc; ++i) {
MonoType *t = inst->type_argv [i];
if (MONO_TYPE_ISSTRUCT (t))
return TRUE;
}
return FALSE;
}
/*
* add_generic_class:
*
* Add all methods of a generic class.
*/
static void
add_generic_class_with_depth (MonoAotCompile *acfg, MonoClass *klass, int depth, const char *ref)
{
MonoMethod *method;
MonoClassField *field;
gpointer iter;
gboolean use_gsharedvt = FALSE;
gboolean use_gsharedvt_for_array = FALSE;
if (!acfg->ginst_hash)
acfg->ginst_hash = g_hash_table_new (NULL, NULL);
mono_class_init_internal (klass);
if (mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->context.class_inst->is_open)
return;
if (has_type_vars (klass))
return;
if (!mono_class_is_ginst (klass) && !m_class_get_rank (klass))
return;
if (mono_class_has_failure (klass))
return;
if (!acfg->ginst_hash)
acfg->ginst_hash = g_hash_table_new (NULL, NULL);
if (g_hash_table_lookup (acfg->ginst_hash, klass))
return;
if (check_type_depth (m_class_get_byval_arg (klass), 0))
return;
if (acfg->aot_opts.log_generics) {
char *s = mono_type_full_name (m_class_get_byval_arg (klass));
aot_printf (acfg, "%*sAdding generic instance %s [%s].\n", depth, "", s, ref);
g_free (s);
}
g_hash_table_insert (acfg->ginst_hash, klass, klass);
/*
* Use gsharedvt for generic collections with vtype arguments to avoid code blowup.
* Enable this only for some classes since gsharedvt might not support all methods.
*/
if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && m_class_get_image (klass) == mono_defaults.corlib && mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->context.class_inst && is_vt_inst (mono_class_get_generic_class (klass)->context.class_inst) &&
(!strcmp (m_class_get_name (klass), "Dictionary`2") || !strcmp (m_class_get_name (klass), "List`1") || !strcmp (m_class_get_name (klass), "ReadOnlyCollection`1")))
use_gsharedvt = TRUE;
#ifdef TARGET_WASM
/*
* Use gsharedvt for instances with vtype arguments.
* WASM only since other platforms depend on the
* previous behavior.
*/
if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && mono_class_is_ginst (klass) && mono_class_get_generic_class (klass)->context.class_inst && is_vt_inst_no_enum (mono_class_get_generic_class (klass)->context.class_inst)) {
use_gsharedvt = TRUE;
use_gsharedvt_for_array = TRUE;
}
#endif
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
if ((acfg->jit_opts & MONO_OPT_GSHAREDVT) && method->is_inflated && mono_method_get_context (method)->method_inst) {
/*
* This is partial sharing, and we can't handle it yet
*/
continue;
}
if (mono_method_is_generic_sharable_full (method, FALSE, FALSE, use_gsharedvt)) {
/* Already added */
add_types_from_method_header (acfg, method);
continue;
}
if (method->is_generic)
/* FIXME: */
continue;
/*
* FIXME: Instances which are referenced by these methods are not added,
* for example Array.Resize<int> for List<int>.Add ().
*/
add_extra_method_with_depth (acfg, method, depth + 1);
}
iter = NULL;
while ((field = mono_class_get_fields_internal (klass, &iter))) {
if (field->type->type == MONO_TYPE_GENERICINST)
add_generic_class_with_depth (acfg, mono_class_from_mono_type_internal (field->type), depth + 1, "field");
}
if (m_class_is_delegate (klass)) {
method = mono_get_delegate_invoke_internal (klass);
method = mono_marshal_get_delegate_invoke (method, NULL);
if (acfg->aot_opts.log_generics)
aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method));
add_method (acfg, method);
}
/* Add superclasses */
if (m_class_get_parent (klass))
add_generic_class_with_depth (acfg, m_class_get_parent (klass), depth, "parent");
const char *klass_name = m_class_get_name (klass);
const char *klass_name_space = m_class_get_name_space (klass);
const gboolean in_corlib = m_class_get_image (klass) == mono_defaults.corlib;
/*
* For ICollection<T>, add instances of the helper methods
* in Array, since a T[] could be cast to ICollection<T>.
*/
if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") &&
(!strcmp(klass_name, "ICollection`1") || !strcmp (klass_name, "IEnumerable`1") || !strcmp (klass_name, "IList`1") || !strcmp (klass_name, "IEnumerator`1") || !strcmp (klass_name, "IReadOnlyList`1"))) {
MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]);
MonoClass *array_class = mono_class_create_bounded_array (tclass, 1, FALSE);
gpointer iter;
char *name_prefix;
if (!strcmp (klass_name, "IEnumerator`1"))
name_prefix = g_strdup_printf ("%s.%s", klass_name_space, "IEnumerable`1");
else
name_prefix = g_strdup_printf ("%s.%s", klass_name_space, klass_name);
iter = NULL;
while ((method = mono_class_get_methods (array_class, &iter))) {
if (!strncmp (method->name, name_prefix, strlen (name_prefix))) {
MonoMethod *m = mono_aot_get_array_helper_from_wrapper (method);
if (m->is_inflated && !mono_method_is_generic_sharable_full (m, FALSE, FALSE, use_gsharedvt_for_array))
add_extra_method_with_depth (acfg, m, depth);
}
}
g_free (name_prefix);
}
/* Add an instance of GenericComparer<T> which is created dynamically by Comparer<T> */
if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") && !strcmp (klass_name, "Comparer`1")) {
ERROR_DECL (error);
MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]);
MonoClass *icomparable, *gcomparer, *icomparable_inst;
MonoGenericContext ctx;
memset (&ctx, 0, sizeof (ctx));
icomparable = mono_class_load_from_name (mono_defaults.corlib, "System", "IComparable`1");
MonoType *args [ ] = { m_class_get_byval_arg (tclass) };
ctx.class_inst = mono_metadata_get_generic_inst (1, args);
icomparable_inst = mono_class_inflate_generic_class_checked (icomparable, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
if (mono_class_is_assignable_from_internal (icomparable_inst, tclass)) {
MonoClass *gcomparer_inst;
gcomparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericComparer`1");
gcomparer_inst = mono_class_inflate_generic_class_checked (gcomparer, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
add_generic_class (acfg, gcomparer_inst, FALSE, "Comparer<T>");
}
}
/* Add an instance of GenericEqualityComparer<T> which is created dynamically by EqualityComparer<T> */
if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") && !strcmp (klass_name, "EqualityComparer`1")) {
ERROR_DECL (error);
MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]);
MonoClass *iface, *gcomparer, *iface_inst;
MonoGenericContext ctx;
memset (&ctx, 0, sizeof (ctx));
iface = mono_class_load_from_name (mono_defaults.corlib, "System", "IEquatable`1");
g_assert (iface);
MonoType *args [ ] = { m_class_get_byval_arg (tclass) };
ctx.class_inst = mono_metadata_get_generic_inst (1, args);
iface_inst = mono_class_inflate_generic_class_checked (iface, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
if (mono_class_is_assignable_from_internal (iface_inst, tclass)) {
MonoClass *gcomparer_inst;
ERROR_DECL (error);
gcomparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "GenericEqualityComparer`1");
gcomparer_inst = mono_class_inflate_generic_class_checked (gcomparer, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
add_generic_class (acfg, gcomparer_inst, FALSE, "EqualityComparer<T>");
}
}
/* Add an instance of EnumComparer<T> which is created dynamically by EqualityComparer<T> for enums */
if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") && !strcmp (klass_name, "EqualityComparer`1")) {
MonoClass *enum_comparer;
MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]);
MonoGenericContext ctx;
if (m_class_is_enumtype (tclass)) {
MonoClass *enum_comparer_inst;
ERROR_DECL (error);
memset (&ctx, 0, sizeof (ctx));
MonoType *args [ ] = { m_class_get_byval_arg (tclass) };
ctx.class_inst = mono_metadata_get_generic_inst (1, args);
enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumEqualityComparer`1");
enum_comparer_inst = mono_class_inflate_generic_class_checked (enum_comparer, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
add_generic_class (acfg, enum_comparer_inst, FALSE, "EqualityComparer<T>");
}
}
/* Add an instance of ObjectComparer<T> which is created dynamically by Comparer<T> for enums */
if (in_corlib && !strcmp (klass_name_space, "System.Collections.Generic") && !strcmp (klass_name, "Comparer`1")) {
MonoClass *comparer;
MonoClass *tclass = mono_class_from_mono_type_internal (mono_class_get_generic_class (klass)->context.class_inst->type_argv [0]);
MonoGenericContext ctx;
if (m_class_is_enumtype (tclass)) {
MonoClass *comparer_inst;
ERROR_DECL (error);
memset (&ctx, 0, sizeof (ctx));
MonoType *args [ ] = { m_class_get_byval_arg (tclass) };
ctx.class_inst = mono_metadata_get_generic_inst (1, args);
comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "ObjectComparer`1");
comparer_inst = mono_class_inflate_generic_class_checked (comparer, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
add_generic_class (acfg, comparer_inst, FALSE, "Comparer<T>");
}
}
}
static void
add_instances_of (MonoAotCompile *acfg, MonoClass *klass, MonoType **insts, int ninsts, gboolean force)
{
int i;
MonoGenericContext ctx;
if (acfg->aot_opts.no_instances)
return;
memset (&ctx, 0, sizeof (ctx));
for (i = 0; i < ninsts; ++i) {
ERROR_DECL (error);
MonoClass *generic_inst;
MonoType *args [ ] = { insts [i] };
ctx.class_inst = mono_metadata_get_generic_inst (1, args);
generic_inst = mono_class_inflate_generic_class_checked (klass, &ctx, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
add_generic_class (acfg, generic_inst, force, "");
}
}
static void
add_types_from_method_header (MonoAotCompile *acfg, MonoMethod *method)
{
ERROR_DECL (error);
MonoMethodHeader *header;
MonoMethodSignature *sig;
int j, depth;
depth = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_depth, method));
sig = mono_method_signature_internal (method);
if (sig) {
for (j = 0; j < sig->param_count; ++j)
if (sig->params [j]->type == MONO_TYPE_GENERICINST)
add_generic_class_with_depth (acfg, mono_class_from_mono_type_internal (sig->params [j]), depth + 1, "arg");
}
header = mono_method_get_header_checked (method, error);
if (header) {
for (j = 0; j < header->num_locals; ++j)
if (header->locals [j]->type == MONO_TYPE_GENERICINST)
add_generic_class_with_depth (acfg, mono_class_from_mono_type_internal (header->locals [j]), depth + 1, "local");
mono_metadata_free_mh (header);
} else {
mono_error_cleanup (error); /* FIXME report the error */
}
}
/*
* add_generic_instances:
*
* Add instances referenced by the METHODSPEC/TYPESPEC table.
*/
static void
add_generic_instances (MonoAotCompile *acfg)
{
int i;
guint32 token;
MonoMethod *method;
MonoGenericContext *context;
if (acfg->aot_opts.no_instances)
return;
int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHODSPEC]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
token = MONO_TOKEN_METHOD_SPEC | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
if (!method) {
aot_printerrf (acfg, "Failed to load methodspec 0x%x due to %s.\n", token, mono_error_get_message (error));
aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
mono_error_cleanup (error);
continue;
}
if (m_class_get_image (method->klass) != acfg->image)
continue;
context = mono_method_get_context (method);
if (context && ((context->class_inst && context->class_inst->is_open)))
continue;
/*
* For open methods, create an instantiation which can be passed to the JIT.
* FIXME: Handle class_inst as well.
*/
if (context && context->method_inst && context->method_inst->is_open) {
ERROR_DECL (error);
MonoGenericContext shared_context;
MonoGenericInst *inst;
MonoType **type_argv;
int i;
MonoMethod *declaring_method;
gboolean supported = TRUE;
/* Check that the context doesn't contain open constructed types */
if (context->class_inst) {
inst = context->class_inst;
for (i = 0; i < inst->type_argc; ++i) {
if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
continue;
if (mono_class_is_open_constructed_type (inst->type_argv [i]))
supported = FALSE;
}
}
if (context->method_inst) {
inst = context->method_inst;
for (i = 0; i < inst->type_argc; ++i) {
if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
continue;
if (mono_class_is_open_constructed_type (inst->type_argv [i]))
supported = FALSE;
}
}
if (!supported)
continue;
memset (&shared_context, 0, sizeof (MonoGenericContext));
inst = context->class_inst;
if (inst) {
type_argv = g_new0 (MonoType*, inst->type_argc);
for (i = 0; i < inst->type_argc; ++i) {
if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
type_argv [i] = mono_get_object_type ();
else
type_argv [i] = inst->type_argv [i];
}
shared_context.class_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
g_free (type_argv);
}
inst = context->method_inst;
if (inst) {
type_argv = g_new0 (MonoType*, inst->type_argc);
for (i = 0; i < inst->type_argc; ++i) {
if (MONO_TYPE_IS_REFERENCE (inst->type_argv [i]) || inst->type_argv [i]->type == MONO_TYPE_VAR || inst->type_argv [i]->type == MONO_TYPE_MVAR)
type_argv [i] = mono_get_object_type ();
else
type_argv [i] = inst->type_argv [i];
}
shared_context.method_inst = mono_metadata_get_generic_inst (inst->type_argc, type_argv);
g_free (type_argv);
}
if (method->is_generic || mono_class_is_gtd (method->klass))
declaring_method = method;
else
declaring_method = mono_method_get_declaring_generic_method (method);
method = mono_class_inflate_generic_method_checked (declaring_method, &shared_context, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
}
/*
* If the method is fully sharable, it was already added in place of its
* generic definition.
*/
if (mono_method_is_generic_sharable_full (method, FALSE, FALSE, FALSE))
continue;
/*
* FIXME: Partially shared methods are not shared here, so we end up with
* many identical methods.
*/
add_extra_method (acfg, method);
}
rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPESPEC]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoClass *klass;
token = MONO_TOKEN_TYPE_SPEC | (i + 1);
klass = mono_class_get_checked (acfg->image, token, error);
if (!klass || m_class_get_rank (klass)) {
mono_error_cleanup (error);
continue;
}
add_generic_class (acfg, klass, FALSE, "typespec");
}
/* Add types of args/locals */
for (i = 0; i < acfg->methods->len; ++i) {
method = (MonoMethod *)g_ptr_array_index (acfg->methods, i);
add_types_from_method_header (acfg, method);
}
if (acfg->image == mono_defaults.corlib) {
MonoClass *klass;
MonoType *insts [256];
int ninsts = 0;
MonoType *byte_type = m_class_get_byval_arg (mono_defaults.byte_class);
MonoType *sbyte_type = m_class_get_byval_arg (mono_defaults.sbyte_class);
MonoType *int16_type = m_class_get_byval_arg (mono_defaults.int16_class);
MonoType *uint16_type = m_class_get_byval_arg (mono_defaults.uint16_class);
MonoType *int32_type = mono_get_int32_type ();
MonoType *uint32_type = m_class_get_byval_arg (mono_defaults.uint32_class);
MonoType *int64_type = m_class_get_byval_arg (mono_defaults.int64_class);
MonoType *uint64_type = m_class_get_byval_arg (mono_defaults.uint64_class);
MonoType *object_type = mono_get_object_type ();
insts [ninsts ++] = byte_type;
insts [ninsts ++] = sbyte_type;
insts [ninsts ++] = int16_type;
insts [ninsts ++] = uint16_type;
insts [ninsts ++] = int32_type;
insts [ninsts ++] = uint32_type;
insts [ninsts ++] = int64_type;
insts [ninsts ++] = uint64_type;
insts [ninsts ++] = m_class_get_byval_arg (mono_defaults.single_class);
insts [ninsts ++] = m_class_get_byval_arg (mono_defaults.double_class);
insts [ninsts ++] = m_class_get_byval_arg (mono_defaults.char_class);
insts [ninsts ++] = m_class_get_byval_arg (mono_defaults.boolean_class);
/* Add GenericComparer<T> instances for primitive types for Enum.ToString () */
klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "GenericComparer`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "GenericEqualityComparer`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
/* Add instances of EnumEqualityComparer which are created by EqualityComparer<T> for enums */
{
MonoClass *k, *enum_comparer;
MonoType *insts [16];
int ninsts;
const char *enum_names [] = { "I8Enum", "I16Enum", "I32Enum", "I64Enum", "UI8Enum", "UI16Enum", "UI32Enum", "UI64Enum" };
ninsts = 0;
for (int i = 0; i < G_N_ELEMENTS (enum_names); ++i) {
k = mono_class_try_load_from_name (acfg->image, "Mono", enum_names [i]);
g_assert (k);
insts [ninsts ++] = m_class_get_byval_arg (k);
}
enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumEqualityComparer`1");
add_instances_of (acfg, enum_comparer, insts, ninsts, TRUE);
enum_comparer = mono_class_load_from_name (mono_defaults.corlib, "System.Collections.Generic", "EnumComparer`1");
add_instances_of (acfg, enum_comparer, insts, ninsts, TRUE);
}
/* Add instances of the array generic interfaces for primitive types */
/* This will add instances of the InternalArray_ helper methods in Array too */
klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "ICollection`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "IList`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
klass = mono_class_try_load_from_name (acfg->image, "System.Collections.Generic", "IEnumerable`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
klass = mono_class_try_load_from_name (acfg->image, "System", "SZGenericArrayEnumerator`1");
if (klass)
add_instances_of (acfg, klass, insts, ninsts, TRUE);
/*
* Add a managed-to-native wrapper of Array.GetGenericValue_icall<object>, which is
* used for all instances of GetGenericValue_icall by the AOT runtime.
*/
{
ERROR_DECL (error);
MonoGenericContext ctx;
MonoMethod *get_method;
MonoClass *array_klass = m_class_get_parent (mono_class_create_array (mono_defaults.object_class, 1));
get_method = mono_class_get_method_from_name_checked (array_klass, "GetGenericValue_icall", 3, 0, error);
mono_error_assert_ok (error);
if (get_method) {
memset (&ctx, 0, sizeof (ctx));
MonoType *args [ ] = { object_type };
ctx.method_inst = mono_metadata_get_generic_inst (1, args);
add_extra_method (acfg, mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (get_method, &ctx, error), TRUE, TRUE));
mono_error_assert_ok (error); /* FIXME don't swallow the error */
}
}
/* object[] accessor wrappers. */
for (i = 1; i < 4; ++i) {
MonoClass *obj_array_class = mono_class_create_array (mono_defaults.object_class, i);
MonoMethod *m;
m = get_method_nofail (obj_array_class, "Get", i, 0);
g_assert (m);
m = mono_marshal_get_array_accessor_wrapper (m);
add_extra_method (acfg, m);
m = get_method_nofail (obj_array_class, "Address", i, 0);
g_assert (m);
m = mono_marshal_get_array_accessor_wrapper (m);
add_extra_method (acfg, m);
m = get_method_nofail (obj_array_class, "Set", i + 1, 0);
g_assert (m);
m = mono_marshal_get_array_accessor_wrapper (m);
add_extra_method (acfg, m);
}
}
}
static char *
decode_direct_icall_symbol_name_attribute (MonoMethod *method)
{
ERROR_DECL (error);
int j = 0;
char *symbol_name = NULL;
MonoCustomAttrInfo *cattr = mono_custom_attrs_from_method_checked (method, error);
if (is_ok(error) && cattr) {
for (j = 0; j < cattr->num_attrs; j++)
if (cattr->attrs [j].ctor && !strcmp (m_class_get_name (cattr->attrs [j].ctor->klass), "MonoDirectICallSymbolNameAttribute"))
break;
if (j < cattr->num_attrs) {
MonoCustomAttrEntry *e = &cattr->attrs [j];
MonoMethodSignature *sig = mono_method_signature_internal (e->ctor);
if (e->data && sig && sig->param_count == 1 && sig->params [0]->type == MONO_TYPE_STRING) {
/*
* Decode the cattr manually since we can't create objects
* during aot compilation.
*/
/* Skip prolog */
const char *p = ((const char*)e->data) + 2;
int slen = mono_metadata_decode_value (p, &p);
symbol_name = (char *)g_memdup (p, slen + 1);
if (symbol_name)
symbol_name [slen] = 0;
}
}
}
return symbol_name;
}
static const char*
lookup_external_icall_symbol_name_aot (MonoMethod *method)
{
g_assert (method_to_external_icall_symbol_name);
gpointer key, value;
if (g_hash_table_lookup_extended (method_to_external_icall_symbol_name, method, &key, &value))
return (const char*)value;
char *symbol_name = decode_direct_icall_symbol_name_attribute (method);
g_hash_table_insert (method_to_external_icall_symbol_name, method, symbol_name);
return symbol_name;
}
static const char*
lookup_icall_symbol_name_aot (MonoMethod *method)
{
const char * symbol_name = mono_lookup_icall_symbol (method);
if (!symbol_name)
symbol_name = lookup_external_icall_symbol_name_aot (method);
return symbol_name;
}
gboolean
mono_aot_direct_icalls_enabled_for_method (MonoCompile *cfg, MonoMethod *method)
{
gboolean enable_icall = FALSE;
if (cfg->compile_aot)
enable_icall = lookup_external_icall_symbol_name_aot (method) ? TRUE : FALSE;
else
enable_icall = FALSE;
return enable_icall;
}
/*
* method_is_externally_callable:
*
* Return whenever METHOD can be directly called from other AOT images
* without going through a PLT.
*/
static gboolean
method_is_externally_callable (MonoAotCompile *acfg, MonoMethod *method)
{
// FIXME: Unify
if (acfg->aot_opts.llvm_only) {
if (!acfg->aot_opts.static_link)
return FALSE;
if (method->wrapper_type == MONO_WRAPPER_ALLOC)
return TRUE;
if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
return TRUE;
if (method->string_ctor)
return FALSE;
if (method->wrapper_type)
return FALSE;
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
return FALSE;
if (method->is_inflated)
return FALSE;
if (!((mono_class_get_flags (method->klass) & TYPE_ATTRIBUTE_PUBLIC) && (method->flags & METHOD_ATTRIBUTE_PUBLIC)))
return FALSE;
/* Can't enable this as the callee might fail llvm compilation */
//return TRUE;
return FALSE;
} else {
if (!acfg->aot_opts.direct_extern_calls)
return FALSE;
if (!acfg->llvm)
return FALSE;
if (acfg->aot_opts.soft_debug || acfg->aot_opts.no_direct_calls)
return FALSE;
if (method->wrapper_type == MONO_WRAPPER_ALLOC)
return FALSE;
if (method->string_ctor)
return FALSE;
if (method->wrapper_type)
return FALSE;
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
return FALSE;
if (method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED)
return FALSE;
if (method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME)
return FALSE;
if (method->is_inflated)
return FALSE;
if (!((mono_class_get_flags (method->klass) & TYPE_ATTRIBUTE_PUBLIC) && (method->flags & METHOD_ATTRIBUTE_PUBLIC)))
return FALSE;
return TRUE;
}
}
/*
* is_direct_callable:
*
* Return whenever the method identified by JI is directly callable without
* going through the PLT.
*/
static gboolean
is_direct_callable (MonoAotCompile *acfg, MonoMethod *method, MonoJumpInfo *patch_info)
{
if ((patch_info->type == MONO_PATCH_INFO_METHOD) && (m_class_get_image (patch_info->data.method->klass) == acfg->image)) {
MonoCompile *callee_cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, patch_info->data.method);
if (callee_cfg) {
gboolean direct_callable = TRUE;
if (direct_callable && (acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (patch_info->data.method))
direct_callable = FALSE;
if (direct_callable && !acfg->llvm && !(!callee_cfg->has_got_slots && mono_class_is_before_field_init (callee_cfg->method->klass)))
direct_callable = FALSE;
if (direct_callable && !strcmp (callee_cfg->method->name, ".cctor"))
direct_callable = FALSE;
//
// FIXME: Support inflated methods, it asserts in mini_llvm_init_gshared_method_this () because the method is not in
// amodule->extra_methods.
//
if (direct_callable && callee_cfg->method->is_inflated)
direct_callable = FALSE;
if (direct_callable && (callee_cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) && (!method || method->wrapper_type != MONO_WRAPPER_SYNCHRONIZED))
// FIXME: Maybe call the wrapper directly ?
direct_callable = FALSE;
if (direct_callable && (acfg->aot_opts.soft_debug || acfg->aot_opts.no_direct_calls)) {
/* Disable this so all calls go through load_method (), see the
* mini_get_debug_options ()->load_aot_jit_info_eagerly = TRUE; line in
* mono_debugger_agent_init ().
*/
direct_callable = FALSE;
}
if (direct_callable && (callee_cfg->method->wrapper_type == MONO_WRAPPER_ALLOC))
/* sgen does some initialization when the allocator method is created */
direct_callable = FALSE;
if (direct_callable && (callee_cfg->method->wrapper_type == MONO_WRAPPER_WRITE_BARRIER))
/* we don't know at compile time whether sgen is concurrent or not */
direct_callable = FALSE;
if (direct_callable)
return TRUE;
}
} else if ((patch_info->type == MONO_PATCH_INFO_METHOD) && (m_class_get_image (patch_info->data.method->klass) != acfg->image)) {
/* Cross assembly calls */
return method_is_externally_callable (acfg, patch_info->data.method);
} else if ((patch_info->type == MONO_PATCH_INFO_ICALL_ADDR_CALL && patch_info->data.method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)) {
if (acfg->aot_opts.direct_pinvoke)
return TRUE;
} else if (patch_info->type == MONO_PATCH_INFO_ICALL_ADDR_CALL) {
if (acfg->aot_opts.direct_icalls)
return TRUE;
return FALSE;
}
return FALSE;
}
#ifdef MONO_ARCH_AOT_SUPPORTED
static const char *
get_pinvoke_import (MonoAotCompile *acfg, MonoMethod *method)
{
MonoImage *image = m_class_get_image (method->klass);
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *) method;
MonoTableInfo *tables = image->tables;
MonoTableInfo *im = &tables [MONO_TABLE_IMPLMAP];
guint32 im_cols [MONO_IMPLMAP_SIZE];
char *import;
import = (char *)g_hash_table_lookup (acfg->method_to_pinvoke_import, method);
if (import != NULL)
return import;
if (piinfo->implmap_idx == 0 || mono_metadata_table_bounds_check (image, MONO_TABLE_IMPLMAP, piinfo->implmap_idx))
return NULL;
mono_metadata_decode_row (im, piinfo->implmap_idx - 1, im_cols, MONO_IMPLMAP_SIZE);
int module_idx = im_cols [MONO_IMPLMAP_SCOPE];
if (module_idx == 0 || mono_metadata_table_bounds_check (image, MONO_TABLE_MODULEREF, module_idx))
return NULL;
import = g_strdup_printf ("%s", mono_metadata_string_heap (image, im_cols [MONO_IMPLMAP_NAME]));
g_hash_table_insert (acfg->method_to_pinvoke_import, method, import);
return import;
}
#else
static const char *
get_pinvoke_import (MonoAotCompile *acfg, MonoMethod *method)
{
return NULL;
}
#endif
static gint
compare_lne (MonoDebugLineNumberEntry *a, MonoDebugLineNumberEntry *b)
{
if (a->native_offset == b->native_offset)
return a->il_offset - b->il_offset;
else
return a->native_offset - b->native_offset;
}
/*
* compute_line_numbers:
*
* Returns a sparse array of size CODE_SIZE containing MonoDebugSourceLocation* entries for the native offsets which have a corresponding line number
* entry.
*/
static MonoDebugSourceLocation**
compute_line_numbers (MonoMethod *method, int code_size, MonoDebugMethodJitInfo *debug_info)
{
MonoDebugMethodInfo *minfo;
MonoDebugLineNumberEntry *ln_array;
MonoDebugSourceLocation *loc;
int i, prev_line, prev_il_offset;
int *native_to_il_offset = NULL;
MonoDebugSourceLocation **res;
gboolean first;
minfo = mono_debug_lookup_method (method);
if (!minfo)
return NULL;
// FIXME: This seems to happen when two methods have the same cfg->method_to_register
if (debug_info->code_size != code_size)
return NULL;
g_assert (code_size);
/* Compute the native->IL offset mapping */
ln_array = g_new0 (MonoDebugLineNumberEntry, debug_info->num_line_numbers);
memcpy (ln_array, debug_info->line_numbers, debug_info->num_line_numbers * sizeof (MonoDebugLineNumberEntry));
mono_qsort (ln_array, debug_info->num_line_numbers, sizeof (MonoDebugLineNumberEntry), (int (*)(const void *, const void *))compare_lne);
native_to_il_offset = g_new0 (int, code_size + 1);
for (i = 0; i < debug_info->num_line_numbers; ++i) {
int j;
MonoDebugLineNumberEntry *lne = &ln_array [i];
if (i == 0) {
for (j = 0; j < lne->native_offset; ++j)
native_to_il_offset [j] = -1;
}
if (i < debug_info->num_line_numbers - 1) {
MonoDebugLineNumberEntry *lne_next = &ln_array [i + 1];
for (j = lne->native_offset; j < lne_next->native_offset; ++j)
native_to_il_offset [j] = lne->il_offset;
} else {
for (j = lne->native_offset; j < code_size; ++j)
native_to_il_offset [j] = lne->il_offset;
}
}
g_free (ln_array);
/* Compute the native->line number mapping */
res = g_new0 (MonoDebugSourceLocation*, code_size);
prev_il_offset = -1;
prev_line = -1;
first = TRUE;
for (i = 0; i < code_size; ++i) {
int il_offset = native_to_il_offset [i];
if (il_offset == -1 || il_offset == prev_il_offset)
continue;
prev_il_offset = il_offset;
loc = mono_debug_method_lookup_location (minfo, il_offset);
if (!(loc && loc->source_file))
continue;
if (loc->row == prev_line) {
mono_debug_free_source_location (loc);
continue;
}
prev_line = loc->row;
//printf ("D: %s:%d il=%x native=%x\n", loc->source_file, loc->row, il_offset, i);
if (first)
/* This will cover the prolog too */
res [0] = loc;
else
res [i] = loc;
first = FALSE;
}
return res;
}
static int
get_file_index (MonoAotCompile *acfg, const char *source_file)
{
int findex;
// FIXME: Free these
if (!acfg->dwarf_ln_filenames)
acfg->dwarf_ln_filenames = g_hash_table_new (g_str_hash, g_str_equal);
findex = GPOINTER_TO_INT (g_hash_table_lookup (acfg->dwarf_ln_filenames, source_file));
if (!findex) {
findex = g_hash_table_size (acfg->dwarf_ln_filenames) + 1;
g_hash_table_insert (acfg->dwarf_ln_filenames, g_strdup (source_file), GINT_TO_POINTER (findex));
emit_unset_mode (acfg);
fprintf (acfg->fp, ".file %d \"%s\"\n", findex, mono_dwarf_escape_path (source_file));
}
return findex;
}
#ifdef TARGET_ARM64
#define INST_LEN 4
#else
#define INST_LEN 1
#endif
static gboolean
never_direct_pinvoke (const char *pinvoke_symbol)
{
#if defined(TARGET_IOS) || defined (TARGET_TVOS) || defined (TARGET_OSX) || defined (TARGET_WATCHOS)
/* XI must be able to override the functions that start with objc_msgSend.
* (there are a few variants with the same prefix) */
return !strncmp (pinvoke_symbol, "objc_msgSend", 12);
#else
return FALSE;
#endif
}
/*
* emit_and_reloc_code:
*
* Emit the native code in CODE, handling relocations along the way. If GOT_ONLY
* is true, calls are made through the GOT too. This is used for emitting trampolines
* in full-aot mode, since calls made from trampolines couldn't go through the PLT,
* since trampolines are needed to make PLT work.
*/
static void
emit_and_reloc_code (MonoAotCompile *acfg, MonoMethod *method, guint8 *code, guint32 code_len, MonoJumpInfo *relocs, gboolean got_only, MonoDebugMethodJitInfo *debug_info)
{
int i, pindex, start_index;
GPtrArray *patches;
MonoJumpInfo *patch_info;
MonoDebugSourceLocation **locs = NULL;
gboolean skip, prologue_end = FALSE;
#ifdef MONO_ARCH_AOT_SUPPORTED
gboolean direct_call, external_call;
guint32 got_slot;
const char *direct_call_target = 0;
const char *direct_pinvoke;
#endif
if (acfg->gas_line_numbers && method && debug_info) {
locs = compute_line_numbers (method, code_len, debug_info);
if (!locs) {
int findex = get_file_index (acfg, "<unknown>");
emit_unset_mode (acfg);
fprintf (acfg->fp, ".loc %d %d 0\n", findex, 1);
}
}
/* Collect and sort relocations */
patches = g_ptr_array_new ();
for (patch_info = relocs; patch_info; patch_info = patch_info->next)
g_ptr_array_add (patches, patch_info);
g_ptr_array_sort (patches, compare_patches);
start_index = 0;
for (i = 0; i < code_len; i += INST_LEN) {
patch_info = NULL;
for (pindex = start_index; pindex < patches->len; ++pindex) {
patch_info = (MonoJumpInfo *)g_ptr_array_index (patches, pindex);
if (patch_info->ip.i >= i)
break;
}
if (locs && locs [i]) {
MonoDebugSourceLocation *loc = locs [i];
int findex;
const char *options;
findex = get_file_index (acfg, loc->source_file);
emit_unset_mode (acfg);
if (!prologue_end)
options = " prologue_end";
else
options = "";
prologue_end = TRUE;
fprintf (acfg->fp, ".loc %d %d 0%s\n", findex, loc->row, options);
mono_debug_free_source_location (loc);
}
skip = FALSE;
#ifdef MONO_ARCH_AOT_SUPPORTED
if (patch_info && (patch_info->ip.i == i) && (pindex < patches->len)) {
start_index = pindex;
switch (patch_info->type) {
case MONO_PATCH_INFO_NONE:
break;
case MONO_PATCH_INFO_GOT_OFFSET: {
int code_size;
arch_emit_got_offset (acfg, code + i, &code_size);
i += code_size - INST_LEN;
skip = TRUE;
patch_info->type = MONO_PATCH_INFO_NONE;
break;
}
case MONO_PATCH_INFO_OBJC_SELECTOR_REF: {
int code_size, index;
char *selector = (char *)patch_info->data.target;
if (!acfg->objc_selector_to_index)
acfg->objc_selector_to_index = g_hash_table_new (g_str_hash, g_str_equal);
if (!acfg->objc_selectors)
acfg->objc_selectors = g_ptr_array_new ();
index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->objc_selector_to_index, selector));
if (index)
index --;
else {
index = acfg->objc_selector_index;
g_ptr_array_add (acfg->objc_selectors, (void*)patch_info->data.target);
g_hash_table_insert (acfg->objc_selector_to_index, selector, GUINT_TO_POINTER (index + 1));
acfg->objc_selector_index ++;
}
arch_emit_objc_selector_ref (acfg, code + i, index, &code_size);
i += code_size - INST_LEN;
skip = TRUE;
patch_info->type = MONO_PATCH_INFO_NONE;
break;
}
default: {
/*
* If this patch is a call, try emitting a direct call instead of
* through a PLT entry. This is possible if the called method is in
* the same assembly and requires no initialization.
*/
direct_call = FALSE;
external_call = FALSE;
if (patch_info->type == MONO_PATCH_INFO_METHOD) {
MonoMethod *cmethod = patch_info->data.method;
if (cmethod->wrapper_type == MONO_WRAPPER_OTHER && mono_marshal_get_wrapper_info (cmethod)->subtype == WRAPPER_SUBTYPE_AOT_INIT) {
WrapperInfo *info = mono_marshal_get_wrapper_info (cmethod);
/*
* This is a call from a JITted method to the init wrapper emitted by LLVM.
*/
g_assert (acfg->aot_opts.llvm && acfg->aot_opts.direct_extern_calls);
const char *init_name = mono_marshal_get_aot_init_wrapper_name (info->d.aot_init.subtype);
char *symbol = g_strdup_printf ("%s%s_%s", acfg->user_symbol_prefix, acfg->global_prefix, init_name);
direct_call = TRUE;
direct_call_target = symbol;
patch_info->type = MONO_PATCH_INFO_NONE;
} else if ((m_class_get_image (patch_info->data.method->klass) == acfg->image) && !got_only && is_direct_callable (acfg, method, patch_info)) {
MonoCompile *callee_cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, cmethod);
// Don't compile inflated methods if we're doing dedup
if (acfg->aot_opts.dedup && !mono_aot_can_dedup (cmethod)) {
char *name = mono_aot_get_mangled_method_name (cmethod);
mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_AOT, "DIRECT CALL: %s by %s", name, method ? mono_method_full_name (method, TRUE) : "");
g_free (name);
direct_call = TRUE;
direct_call_target = callee_cfg->asm_symbol;
patch_info->type = MONO_PATCH_INFO_NONE;
acfg->stats.direct_calls ++;
}
}
acfg->stats.all_calls ++;
} else if (patch_info->type == MONO_PATCH_INFO_ICALL_ADDR_CALL) {
if (!got_only && is_direct_callable (acfg, method, patch_info)) {
if (!(patch_info->data.method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
direct_pinvoke = lookup_icall_symbol_name_aot (patch_info->data.method);
else
direct_pinvoke = get_pinvoke_import (acfg, patch_info->data.method);
if (direct_pinvoke && !never_direct_pinvoke (direct_pinvoke)) {
direct_call = TRUE;
g_assert (strlen (direct_pinvoke) < 1000);
direct_call_target = g_strdup_printf ("%s%s", acfg->user_symbol_prefix, direct_pinvoke);
}
}
} else if (patch_info->type == MONO_PATCH_INFO_JIT_ICALL_ADDR) {
const char *sym = mono_find_jit_icall_info (patch_info->data.jit_icall_id)->c_symbol;
if (!got_only && sym && acfg->aot_opts.direct_icalls) {
/* Call to a C function implementing a jit icall */
direct_call = TRUE;
external_call = TRUE;
g_assert (strlen (sym) < 1000);
direct_call_target = g_strdup_printf ("%s%s", acfg->user_symbol_prefix, sym);
}
} else if (patch_info->type == MONO_PATCH_INFO_JIT_ICALL_ID) {
MonoJitICallInfo * const info = mono_find_jit_icall_info (patch_info->data.jit_icall_id);
const char * const sym = info->c_symbol;
if (!got_only && sym && acfg->aot_opts.direct_icalls && info->func == info->wrapper) {
/* Call to a jit icall without a wrapper */
direct_call = TRUE;
external_call = TRUE;
g_assert (strlen (sym) < 1000);
direct_call_target = g_strdup_printf ("%s%s", acfg->user_symbol_prefix, sym);
}
}
if (direct_call) {
patch_info->type = MONO_PATCH_INFO_NONE;
acfg->stats.direct_calls ++;
}
if (!got_only && !direct_call) {
MonoPltEntry *plt_entry = get_plt_entry (acfg, patch_info);
if (plt_entry) {
/* This patch has a PLT entry, so we must emit a call to the PLT entry */
direct_call = TRUE;
direct_call_target = plt_entry->symbol;
/* Nullify the patch */
patch_info->type = MONO_PATCH_INFO_NONE;
plt_entry->jit_used = TRUE;
}
}
if (direct_call) {
int call_size;
arch_emit_direct_call (acfg, direct_call_target, external_call, FALSE, patch_info, &call_size);
i += call_size - INST_LEN;
} else {
int code_size;
got_slot = get_got_offset (acfg, FALSE, patch_info);
arch_emit_got_access (acfg, acfg->got_symbol, code + i, got_slot, &code_size);
i += code_size - INST_LEN;
}
skip = TRUE;
}
}
}
#endif /* MONO_ARCH_AOT_SUPPORTED */
if (!skip) {
/* Find next patch */
patch_info = NULL;
for (pindex = start_index; pindex < patches->len; ++pindex) {
patch_info = (MonoJumpInfo *)g_ptr_array_index (patches, pindex);
if (patch_info->ip.i >= i)
break;
}
/* Try to emit multiple bytes at once */
if (pindex < patches->len && patch_info->ip.i > i) {
int limit;
for (limit = i + INST_LEN; limit < patch_info->ip.i; limit += INST_LEN) {
if (locs && locs [limit])
break;
}
emit_code_bytes (acfg, code + i, limit - i);
i = limit - INST_LEN;
} else {
emit_code_bytes (acfg, code + i, INST_LEN);
}
}
}
g_ptr_array_free (patches, TRUE);
g_free (locs);
}
/*
* sanitize_symbol:
*
* Return a modified version of S which only includes characters permissible in symbols.
*/
static char*
sanitize_symbol (MonoAotCompile *acfg, char *s)
{
gboolean process = FALSE;
int i, len;
GString *gs;
char *res;
if (!s)
return s;
len = strlen (s);
for (i = 0; i < len; ++i)
if (!(s [i] <= 0x7f && (isalnum (s [i]) || s [i] == '_')))
process = TRUE;
if (!process)
return s;
gs = g_string_sized_new (len);
for (i = 0; i < len; ++i) {
guint8 c = s [i];
if (c <= 0x7f && (isalnum (c) || c == '_')) {
g_string_append_c (gs, c);
} else if (c > 0x7f) {
/* multi-byte utf8 */
g_string_append_printf (gs, "_0x%x", c);
i ++;
c = s [i];
while (c >> 6 == 0x2) {
g_string_append_printf (gs, "%x", c);
i ++;
c = s [i];
}
g_string_append_printf (gs, "_");
i --;
} else {
g_string_append_c (gs, '_');
}
}
res = mono_mempool_strdup (acfg->mempool, gs->str);
g_string_free (gs, TRUE);
return res;
}
static char*
get_debug_sym (MonoMethod *method, const char *prefix, GHashTable *cache)
{
char *name1, *name2, *cached;
int i, j, len, count;
MonoMethod *cached_method;
name1 = mono_method_full_name (method, TRUE);
#ifdef TARGET_MACH
// This is so that we don't accidentally create a local symbol (which starts with 'L')
if ((!prefix || !*prefix) && name1 [0] == 'L')
prefix = "_";
#endif
#if defined(TARGET_WIN32) && defined(TARGET_X86)
char adjustedPrefix [MAX_SYMBOL_SIZE];
prefix = mangle_symbol (prefix, adjustedPrefix, G_N_ELEMENTS (adjustedPrefix));
#endif
len = strlen (name1);
name2 = (char *) g_malloc (strlen (prefix) + len + 16);
memcpy (name2, prefix, strlen (prefix));
j = strlen (prefix);
for (i = 0; i < len; ++i) {
if (i == 0 && name1 [0] >= '0' && name1 [0] <= '9') {
name2 [j ++] = '_';
} else if (isalnum (name1 [i])) {
name2 [j ++] = name1 [i];
} else if (name1 [i] == ' ' && name1 [i + 1] == '(' && name1 [i + 2] == ')') {
i += 2;
} else if (name1 [i] == ',' && name1 [i + 1] == ' ') {
name2 [j ++] = '_';
i++;
} else if (name1 [i] == '(' || name1 [i] == ')' || name1 [i] == '>') {
} else
name2 [j ++] = '_';
}
name2 [j] = '\0';
g_free (name1);
count = 0;
while (TRUE) {
cached_method = (MonoMethod *)g_hash_table_lookup (cache, name2);
if (!(cached_method && cached_method != method))
break;
sprintf (name2 + j, "_%d", count);
count ++;
}
cached = g_strdup (name2);
g_hash_table_insert (cache, cached, method);
return name2;
}
static void
emit_method_code (MonoAotCompile *acfg, MonoCompile *cfg)
{
MonoMethod *method;
int method_index;
guint8 *code;
char *debug_sym = NULL;
char *symbol = NULL;
int func_alignment = AOT_FUNC_ALIGNMENT;
char *export_name;
g_assert (!ignore_cfg (cfg));
method = cfg->orig_method;
code = cfg->native_code;
method_index = get_method_index (acfg, method);
symbol = g_strdup_printf ("%sme_%x", acfg->temp_prefix, method_index);
/* Make the labels local */
emit_section_change (acfg, ".text", 0);
emit_alignment_code (acfg, func_alignment);
if (acfg->global_symbols && acfg->need_no_dead_strip)
fprintf (acfg->fp, " .no_dead_strip %s\n", cfg->asm_symbol);
emit_label (acfg, cfg->asm_symbol);
if (acfg->aot_opts.write_symbols && !acfg->global_symbols && !acfg->llvm) {
/*
* Write a C style symbol for every method, this has two uses:
* - it works on platforms where the dwarf debugging info is not
* yet supported.
* - it allows the setting of breakpoints of aot-ed methods.
*/
// Comment out to force dedup to link these symbols and forbid compiling
// in duplicated code. This is an "assert when linking if broken" trick.
/*if (mono_aot_can_dedup (method) && (acfg->aot_opts.dedup || acfg->aot_opts.dedup_include))*/
/*debug_sym = mono_aot_get_mangled_method_name (method);*/
/*else*/
debug_sym = get_debug_sym (method, "", acfg->method_label_hash);
cfg->asm_debug_symbol = g_strdup (debug_sym);
if (acfg->need_no_dead_strip)
fprintf (acfg->fp, " .no_dead_strip %s\n", debug_sym);
// Comment out to force dedup to link these symbols and forbid compiling
// in duplicated code. This is an "assert when linking if broken" trick.
/*if (mono_aot_can_dedup (method) && (acfg->aot_opts.dedup || acfg->aot_opts.dedup_include))*/
/*emit_global_inner (acfg, debug_sym, TRUE);*/
/*else*/
emit_local_symbol (acfg, debug_sym, symbol, TRUE);
emit_label (acfg, debug_sym);
}
export_name = (char *)g_hash_table_lookup (acfg->export_names, method);
if (export_name) {
/* Emit a global symbol for the method */
emit_global_inner (acfg, export_name, TRUE);
emit_label (acfg, export_name);
}
if (cfg->verbose_level > 0 && !ignore_cfg (cfg))
g_print ("Method %s emitted as %s\n", mono_method_get_full_name (method), cfg->asm_symbol);
acfg->stats.code_size += cfg->code_len;
acfg->cfgs [method_index]->got_offset = acfg->got_offset;
MonoDebugMethodJitInfo *jit_debug_info = mono_debug_find_method (cfg->jit_info->d.method, mono_domain_get ());
emit_and_reloc_code (acfg, method, code, cfg->code_len, cfg->patch_info, FALSE, jit_debug_info);
mono_debug_free_method_jit_info (jit_debug_info);
emit_line (acfg);
if (acfg->aot_opts.write_symbols) {
if (debug_sym)
emit_symbol_size (acfg, debug_sym, ".");
else
emit_symbol_size (acfg, cfg->asm_symbol, ".");
g_free (debug_sym);
}
emit_label (acfg, symbol);
arch_emit_unwind_info_sections (acfg, cfg->asm_symbol, symbol, cfg->unwind_ops);
g_free (symbol);
}
/**
* encode_patch:
*
* Encode PATCH_INFO into its disk representation.
*/
static void
encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
switch (patch_info->type) {
case MONO_PATCH_INFO_NONE:
break;
case MONO_PATCH_INFO_IMAGE:
encode_value (get_image_index (acfg, patch_info->data.image), p, &p);
break;
case MONO_PATCH_INFO_MSCORLIB_GOT_ADDR:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
case MONO_PATCH_INFO_GC_NURSERY_BITS:
break;
case MONO_PATCH_INFO_SWITCH: {
gpointer *table = (gpointer *)patch_info->data.table->table;
int k;
encode_value (patch_info->data.table->table_size, p, &p);
for (k = 0; k < patch_info->data.table->table_size; k++)
encode_value ((int)(gssize)table [k], p, &p);
break;
}
case MONO_PATCH_INFO_METHODCONST:
case MONO_PATCH_INFO_METHOD:
case MONO_PATCH_INFO_METHOD_JUMP:
case MONO_PATCH_INFO_METHOD_FTNDESC:
case MONO_PATCH_INFO_ICALL_ADDR:
case MONO_PATCH_INFO_ICALL_ADDR_CALL:
case MONO_PATCH_INFO_METHOD_RGCTX:
case MONO_PATCH_INFO_METHOD_CODE_SLOT:
case MONO_PATCH_INFO_METHOD_PINVOKE_ADDR_CACHE:
encode_method_ref (acfg, patch_info->data.method, p, &p);
break;
case MONO_PATCH_INFO_AOT_JIT_INFO:
case MONO_PATCH_INFO_CASTCLASS_CACHE:
encode_value (patch_info->data.index, p, &p);
break;
case MONO_PATCH_INFO_JIT_ICALL_ID:
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
case MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL:
encode_value (patch_info->data.jit_icall_id, p, &p);
break;
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR:
encode_value (patch_info->data.uindex, p, &p);
break;
case MONO_PATCH_INFO_LDSTR_LIT: {
guint32 len = strlen (patch_info->data.name);
encode_value (len, p, &p);
memcpy (p, patch_info->data.name, len + 1);
p += len + 1;
break;
}
case MONO_PATCH_INFO_LDSTR: {
guint32 image_index = get_image_index (acfg, patch_info->data.token->image);
guint32 token = patch_info->data.token->token;
g_assert (mono_metadata_token_code (token) == MONO_TOKEN_STRING);
encode_value (image_index, p, &p);
encode_value (patch_info->data.token->token - MONO_TOKEN_STRING, p, &p);
break;
}
case MONO_PATCH_INFO_RVA:
case MONO_PATCH_INFO_DECLSEC:
case MONO_PATCH_INFO_LDTOKEN:
case MONO_PATCH_INFO_TYPE_FROM_HANDLE:
encode_value (get_image_index (acfg, patch_info->data.token->image), p, &p);
encode_value (patch_info->data.token->token, p, &p);
encode_value (patch_info->data.token->has_context, p, &p);
if (patch_info->data.token->has_context)
encode_generic_context (acfg, &patch_info->data.token->context, p, &p);
break;
case MONO_PATCH_INFO_EXC_NAME: {
MonoClass *ex_class;
ex_class =
mono_class_load_from_name (m_class_get_image (mono_defaults.exception_class),
"System", (const char *)patch_info->data.target);
encode_klass_ref (acfg, ex_class, p, &p);
break;
}
case MONO_PATCH_INFO_R4:
case MONO_PATCH_INFO_R4_GOT:
encode_value (*((guint32 *)patch_info->data.target), p, &p);
break;
case MONO_PATCH_INFO_R8:
case MONO_PATCH_INFO_R8_GOT:
encode_value (((guint32 *)patch_info->data.target) [MINI_LS_WORD_IDX], p, &p);
encode_value (((guint32 *)patch_info->data.target) [MINI_MS_WORD_IDX], p, &p);
break;
case MONO_PATCH_INFO_VTABLE:
case MONO_PATCH_INFO_CLASS:
case MONO_PATCH_INFO_IID:
case MONO_PATCH_INFO_ADJUSTED_IID:
encode_klass_ref (acfg, patch_info->data.klass, p, &p);
break;
case MONO_PATCH_INFO_DELEGATE_TRAMPOLINE:
encode_klass_ref (acfg, patch_info->data.del_tramp->klass, p, &p);
if (patch_info->data.del_tramp->method) {
encode_value (1, p, &p);
encode_method_ref (acfg, patch_info->data.del_tramp->method, p, &p);
} else {
encode_value (0, p, &p);
}
encode_value (patch_info->data.del_tramp->is_virtual, p, &p);
break;
case MONO_PATCH_INFO_FIELD:
case MONO_PATCH_INFO_SFLDA:
encode_field_info (acfg, patch_info->data.field, p, &p);
break;
case MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG:
break;
case MONO_PATCH_INFO_PROFILER_ALLOCATION_COUNT:
case MONO_PATCH_INFO_PROFILER_CLAUSE_COUNT:
break;
case MONO_PATCH_INFO_RGCTX_FETCH:
case MONO_PATCH_INFO_RGCTX_SLOT_INDEX: {
MonoJumpInfoRgctxEntry *entry = patch_info->data.rgctx_entry;
guint32 offset;
/*
* entry->d.klass/method has a lenghtly encoding and multiple rgctx_fetch entries
* reference the same klass/method, so encode it only once.
* For patches which refer to got entries, this sharing is done by get_got_offset, but
* these are not got entries.
*/
if (entry->in_mrgctx) {
offset = get_shared_method_ref (acfg, entry->d.method);
} else {
offset = get_shared_klass_ref (acfg, entry->d.klass);
}
encode_value (offset, p, &p);
g_assert ((int)entry->info_type < 256);
g_assert (entry->data->type < 256);
encode_value ((entry->in_mrgctx ? 1 : 0) | (entry->info_type << 1) | (entry->data->type << 9), p, &p);
encode_patch (acfg, entry->data, p, &p);
break;
}
case MONO_PATCH_INFO_SEQ_POINT_INFO:
case MONO_PATCH_INFO_AOT_MODULE:
break;
case MONO_PATCH_INFO_SIGNATURE:
case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER:
encode_signature (acfg, (MonoMethodSignature*)patch_info->data.target, p, &p);
break;
case MONO_PATCH_INFO_GSHAREDVT_CALL:
encode_signature (acfg, (MonoMethodSignature*)patch_info->data.gsharedvt->sig, p, &p);
encode_method_ref (acfg, patch_info->data.gsharedvt->method, p, &p);
break;
case MONO_PATCH_INFO_GSHAREDVT_METHOD: {
MonoGSharedVtMethodInfo *info = patch_info->data.gsharedvt_method;
int i;
encode_method_ref (acfg, info->method, p, &p);
encode_value (info->num_entries, p, &p);
for (i = 0; i < info->num_entries; ++i) {
MonoRuntimeGenericContextInfoTemplate *template_ = &info->entries [i];
encode_value (template_->info_type, p, &p);
switch (mini_rgctx_info_type_to_patch_info_type (template_->info_type)) {
case MONO_PATCH_INFO_CLASS:
encode_klass_ref (acfg, mono_class_from_mono_type_internal ((MonoType *)template_->data), p, &p);
break;
case MONO_PATCH_INFO_FIELD:
encode_field_info (acfg, (MonoClassField *)template_->data, p, &p);
break;
default:
g_assert_not_reached ();
break;
}
}
break;
}
case MONO_PATCH_INFO_VIRT_METHOD:
encode_klass_ref (acfg, patch_info->data.virt_method->klass, p, &p);
encode_method_ref (acfg, patch_info->data.virt_method->method, p, &p);
break;
case MONO_PATCH_INFO_GC_SAFE_POINT_FLAG:
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINES:
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINES_GOT_SLOTS_BASE:
break;
default:
g_error ("unable to handle jump info %d", patch_info->type);
}
*endbuf = p;
}
static void
encode_patch_list (MonoAotCompile *acfg, GPtrArray *patches, int n_patches, gboolean llvm, guint8 *buf, guint8 **endbuf)
{
guint8 *p = buf;
guint32 pindex, offset;
MonoJumpInfo *patch_info;
encode_value (n_patches, p, &p);
for (pindex = 0; pindex < patches->len; ++pindex) {
patch_info = (MonoJumpInfo *)g_ptr_array_index (patches, pindex);
if (patch_info->type == MONO_PATCH_INFO_NONE || patch_info->type == MONO_PATCH_INFO_BB)
/* Nothing to do */
continue;
/* This shouldn't allocate a new offset */
offset = lookup_got_offset (acfg, llvm, patch_info);
encode_value (offset, p, &p);
}
*endbuf = p;
}
static void
emit_method_info (MonoAotCompile *acfg, MonoCompile *cfg)
{
MonoMethod *method;
int pindex, buf_size, n_patches;
GPtrArray *patches;
MonoJumpInfo *patch_info;
guint8 *p, *buf;
guint32 offset;
gboolean needs_ctx = FALSE;
method = cfg->orig_method;
(void)get_method_index (acfg, method);
/* Sort relocations */
patches = g_ptr_array_new ();
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next)
g_ptr_array_add (patches, patch_info);
if (!acfg->aot_opts.llvm_only)
g_ptr_array_sort (patches, compare_patches);
/**********************/
/* Encode method info */
/**********************/
guint32 *got_offsets = g_new0 (guint32, patches->len);
n_patches = 0;
for (pindex = 0; pindex < patches->len; ++pindex) {
patch_info = (MonoJumpInfo *)g_ptr_array_index (patches, pindex);
if ((patch_info->type == MONO_PATCH_INFO_GOT_OFFSET) ||
(patch_info->type == MONO_PATCH_INFO_NONE)) {
patch_info->type = MONO_PATCH_INFO_NONE;
/* Nothing to do */
continue;
}
if ((patch_info->type == MONO_PATCH_INFO_IMAGE) && (patch_info->data.image == acfg->image)) {
/* Stored in a GOT slot initialized at module load time */
patch_info->type = MONO_PATCH_INFO_NONE;
continue;
}
if (patch_info->type == MONO_PATCH_INFO_GC_CARD_TABLE_ADDR ||
patch_info->type == MONO_PATCH_INFO_GC_NURSERY_START ||
patch_info->type == MONO_PATCH_INFO_GC_NURSERY_BITS ||
patch_info->type == MONO_PATCH_INFO_AOT_MODULE) {
/* Stored in a GOT slot initialized at module load time */
patch_info->type = MONO_PATCH_INFO_NONE;
continue;
}
if (is_plt_patch (patch_info) && !(cfg->compile_llvm && acfg->aot_opts.llvm_only)) {
/* Calls are made through the PLT */
patch_info->type = MONO_PATCH_INFO_NONE;
continue;
}
if (acfg->aot_opts.llvm_only && patch_info->type == MONO_PATCH_INFO_METHOD)
needs_ctx = TRUE;
/* This shouldn't allocate a new offset */
offset = lookup_got_offset (acfg, cfg->compile_llvm, patch_info);
if (offset >= acfg->nshared_got_entries)
got_offsets [n_patches ++] = offset;
}
if (n_patches)
g_assert (cfg->has_got_slots);
buf_size = (patches->len < 1000) ? 40960 : 40960 + (patches->len * 64);
p = buf = (guint8 *)g_malloc (buf_size);
MonoGenericContext *ctx = mono_method_get_context (cfg->method);
guint8 flags = 0;
if (mono_class_get_cctor (method->klass))
flags |= MONO_AOT_METHOD_FLAG_HAS_CCTOR;
if (mini_jit_info_is_gsharedvt (cfg->jit_info) && mini_is_gsharedvt_variable_signature (mono_method_signature_internal (jinfo_get_method (cfg->jit_info))))
flags |= MONO_AOT_METHOD_FLAG_GSHAREDVT_VARIABLE;
if (n_patches)
flags |= MONO_AOT_METHOD_FLAG_HAS_PATCHES;
if (needs_ctx && ctx)
flags |= MONO_AOT_METHOD_FLAG_HAS_CTX;
if (cfg->interp_entry_only)
flags |= MONO_AOT_METHOD_FLAG_INTERP_ENTRY_ONLY;
/* Saved into another table so it can be accessed without having access to this data */
cfg->aot_method_flags = flags;
encode_int (cfg->method_index, p, &p);
if (flags & MONO_AOT_METHOD_FLAG_HAS_CCTOR)
encode_klass_ref (acfg, method->klass, p, &p);
if (needs_ctx && ctx)
encode_generic_context (acfg, ctx, p, &p);
if (n_patches) {
encode_value (n_patches, p, &p);
for (int i = 0; i < n_patches; ++i)
encode_value (got_offsets [i], p, &p);
}
g_ptr_array_free (patches, TRUE);
g_free (got_offsets);
acfg->stats.method_info_size += p - buf;
g_assert (p - buf < buf_size);
if (cfg->compile_llvm) {
char *symbol = g_strdup_printf ("info_%s", cfg->llvm_method_name);
cfg->llvm_info_var = mono_llvm_emit_aot_data_aligned (symbol, buf, p - buf, 1);
g_free (symbol);
/* aot-runtime.c will use this to check whenever this is an llvm method */
cfg->method_info_offset = 0;
} else {
cfg->method_info_offset = add_to_blob (acfg, buf, p - buf);
}
g_free (buf);
}
static guint32
get_unwind_info_offset (MonoAotCompile *acfg, guint8 *encoded, guint32 encoded_len)
{
guint32 cache_index;
guint32 offset;
/* Reuse the unwind module to canonize and store unwind info entries */
cache_index = mono_cache_unwind_info (encoded, encoded_len);
/* Use +/- 1 to distinguish 0s from missing entries */
offset = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->unwind_info_offsets, GUINT_TO_POINTER (cache_index + 1)));
if (offset)
return offset - 1;
else {
guint8 buf [16];
guint8 *p;
/*
* It would be easier to use assembler symbols, but the caller needs an
* offset now.
*/
offset = acfg->unwind_info_offset;
g_hash_table_insert (acfg->unwind_info_offsets, GUINT_TO_POINTER (cache_index + 1), GUINT_TO_POINTER (offset + 1));
g_ptr_array_add (acfg->unwind_ops, GUINT_TO_POINTER (cache_index));
p = buf;
encode_value (encoded_len, p, &p);
acfg->unwind_info_offset += encoded_len + (p - buf);
return offset;
}
}
static void
emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg, gboolean store_seq_points)
{
int i, k, buf_size;
guint32 debug_info_size, seq_points_size;
guint8 *code;
MonoMethodHeader *header;
guint8 *p, *buf, *debug_info;
MonoJitInfo *jinfo = cfg->jit_info;
guint32 flags;
gboolean use_unwind_ops = FALSE;
MonoSeqPointInfo *seq_points;
code = cfg->native_code;
header = cfg->header;
if (!acfg->aot_opts.nodebug) {
mono_debug_serialize_debug_info (cfg, &debug_info, &debug_info_size);
} else {
debug_info = NULL;
debug_info_size = 0;
}
seq_points = cfg->seq_point_info;
seq_points_size = (store_seq_points)? mono_seq_point_info_get_write_size (seq_points) : 0;
buf_size = header->num_clauses * 256 + debug_info_size + 2048 + seq_points_size + cfg->gc_map_size;
if (jinfo->has_try_block_holes) {
MonoTryBlockHoleTableJitInfo *table = mono_jit_info_get_try_block_hole_table_info (jinfo);
buf_size += table->num_holes * 16;
}
p = buf = (guint8 *)g_malloc (buf_size);
use_unwind_ops = cfg->unwind_ops != NULL;
flags = (jinfo->has_generic_jit_info ? 1 : 0) | (use_unwind_ops ? 2 : 0) | (header->num_clauses ? 4 : 0) | (seq_points_size ? 8 : 0) | (cfg->compile_llvm ? 16 : 0) | (jinfo->has_try_block_holes ? 32 : 0) | (cfg->gc_map ? 64 : 0) | (jinfo->has_arch_eh_info ? 128 : 0);
encode_value (flags, p, &p);
if (use_unwind_ops) {
guint32 encoded_len;
guint8 *encoded;
guint32 unwind_desc;
encoded = mono_unwind_ops_encode (cfg->unwind_ops, &encoded_len);
unwind_desc = get_unwind_info_offset (acfg, encoded, encoded_len);
encode_value (unwind_desc, p, &p);
g_free (encoded);
} else {
encode_value (jinfo->unwind_info, p, &p);
}
/*Encode the number of holes before the number of clauses to make decoding easier*/
if (jinfo->has_try_block_holes) {
MonoTryBlockHoleTableJitInfo *table = mono_jit_info_get_try_block_hole_table_info (jinfo);
encode_value (table->num_holes, p, &p);
}
if (jinfo->has_arch_eh_info) {
/*
* In AOT mode, the code length is calculated from the address of the previous method,
* which could include alignment padding, so calculating the start of the epilog as
* code_len - epilog_size is correct any more. Save the real code len as a workaround.
*/
encode_value (jinfo->code_size, p, &p);
}
/* Exception table */
if (cfg->compile_llvm) {
/*
* When using LLVM, we can't emit some data, like pc offsets, this reg/offset etc.,
* since the information is only available to llc. Instead, we let llc save the data
* into the LSDA, and read it from there at runtime.
*/
/* The assembly might be CIL stripped so emit the data ourselves */
if (header->num_clauses)
encode_value (header->num_clauses, p, &p);
for (k = 0; k < header->num_clauses; ++k) {
MonoExceptionClause *clause;
clause = &header->clauses [k];
encode_value (clause->flags, p, &p);
if (!(clause->flags == MONO_EXCEPTION_CLAUSE_FILTER || clause->flags == MONO_EXCEPTION_CLAUSE_FINALLY)) {
if (clause->data.catch_class) {
guint8 *buf2, *p2;
int len;
buf2 = (guint8 *)g_malloc (4096);
p2 = buf2;
encode_klass_ref (acfg, clause->data.catch_class, p2, &p2);
len = p2 - buf2;
g_assert (len < 4096);
encode_value (len, p, &p);
memcpy (p, buf2, len);
p += p2 - buf2;
g_free (buf2);
} else {
encode_value (0, p, &p);
}
}
/* Emit the IL ranges too, since they might not be available at runtime */
encode_value (clause->try_offset, p, &p);
encode_value (clause->try_len, p, &p);
encode_value (clause->handler_offset, p, &p);
encode_value (clause->handler_len, p, &p);
/* Emit a list of nesting clauses */
for (i = 0; i < header->num_clauses; ++i) {
gint32 cindex1 = k;
MonoExceptionClause *clause1 = &header->clauses [cindex1];
gint32 cindex2 = i;
MonoExceptionClause *clause2 = &header->clauses [cindex2];
if (cindex1 != cindex2 && clause1->try_offset >= clause2->try_offset && clause1->handler_offset <= clause2->handler_offset)
encode_value (i, p, &p);
}
encode_value (-1, p, &p);
}
} else {
if (jinfo->num_clauses)
encode_value (jinfo->num_clauses, p, &p);
for (k = 0; k < jinfo->num_clauses; ++k) {
MonoJitExceptionInfo *ei = &jinfo->clauses [k];
encode_value (ei->flags, p, &p);
#ifdef MONO_CONTEXT_SET_LLVM_EXC_REG
/* Not used for catch clauses */
if (ei->flags != MONO_EXCEPTION_CLAUSE_NONE)
encode_value (ei->exvar_offset, p, &p);
#else
encode_value (ei->exvar_offset, p, &p);
#endif
if (ei->flags == MONO_EXCEPTION_CLAUSE_FILTER || ei->flags == MONO_EXCEPTION_CLAUSE_FINALLY)
encode_value ((gint)((guint8*)ei->data.filter - code), p, &p);
else {
if (ei->data.catch_class) {
guint8 *buf2, *p2;
int len;
buf2 = (guint8 *)g_malloc (4096);
p2 = buf2;
encode_klass_ref (acfg, ei->data.catch_class, p2, &p2);
len = p2 - buf2;
g_assert (len < 4096);
encode_value (len, p, &p);
memcpy (p, buf2, len);
p += p2 - buf2;
g_free (buf2);
} else {
encode_value (0, p, &p);
}
}
encode_value ((gint)((guint8*)ei->try_start - code), p, &p);
encode_value ((gint)((guint8*)ei->try_end - code), p, &p);
encode_value ((gint)((guint8*)ei->handler_start - code), p, &p);
}
}
if (jinfo->has_try_block_holes) {
MonoTryBlockHoleTableJitInfo *table = mono_jit_info_get_try_block_hole_table_info (jinfo);
for (i = 0; i < table->num_holes; ++i) {
MonoTryBlockHoleJitInfo *hole = &table->holes [i];
encode_value (hole->clause, p, &p);
encode_value (hole->length, p, &p);
encode_value (hole->offset, p, &p);
}
}
if (jinfo->has_arch_eh_info) {
MonoArchEHJitInfo *eh_info;
eh_info = mono_jit_info_get_arch_eh_info (jinfo);
encode_value (eh_info->stack_size, p, &p);
encode_value (eh_info->epilog_size, p, &p);
}
if (jinfo->has_generic_jit_info) {
MonoGenericJitInfo *gi = mono_jit_info_get_generic_jit_info (jinfo);
MonoGenericSharingContext* gsctx = gi->generic_sharing_context;
guint8 *buf2, *p2;
int len;
encode_value (gi->nlocs, p, &p);
if (gi->nlocs) {
for (i = 0; i < gi->nlocs; ++i) {
MonoDwarfLocListEntry *entry = &gi->locations [i];
encode_value (entry->is_reg ? 1 : 0, p, &p);
encode_value (entry->reg, p, &p);
if (!entry->is_reg)
encode_value (entry->offset, p, &p);
if (i == 0)
g_assert (entry->from == 0);
else
encode_value (entry->from, p, &p);
encode_value (entry->to, p, &p);
}
} else {
if (!cfg->compile_llvm) {
encode_value (gi->has_this ? 1 : 0, p, &p);
encode_value (gi->this_reg, p, &p);
encode_value (gi->this_offset, p, &p);
}
}
/*
* Need to encode jinfo->method too, since it is not equal to 'method'
* when using generic sharing.
*/
buf2 = (guint8 *)g_malloc (4096);
p2 = buf2;
encode_method_ref (acfg, jinfo->d.method, p2, &p2);
len = p2 - buf2;
g_assert (len < 4096);
encode_value (len, p, &p);
memcpy (p, buf2, len);
p += p2 - buf2;
g_free (buf2);
if (gsctx && gsctx->is_gsharedvt) {
encode_value (1, p, &p);
} else {
encode_value (0, p, &p);
}
}
if (seq_points_size)
p += mono_seq_point_info_write (seq_points, p);
g_assert (debug_info_size < buf_size);
encode_value (debug_info_size, p, &p);
if (debug_info_size) {
memcpy (p, debug_info, debug_info_size);
p += debug_info_size;
g_free (debug_info);
}
/* GC Map */
if (cfg->gc_map) {
encode_value (cfg->gc_map_size, p, &p);
/* The GC map requires 4 bytes of alignment */
while ((gsize)p % 4)
p ++;
memcpy (p, cfg->gc_map, cfg->gc_map_size);
p += cfg->gc_map_size;
}
acfg->stats.ex_info_size += p - buf;
g_assert (p - buf < buf_size);
/* Emit info */
/* The GC Map requires 4 byte alignment */
cfg->ex_info_offset = add_to_blob_aligned (acfg, buf, p - buf, cfg->gc_map ? 4 : 1);
g_free (buf);
}
static guint32
emit_klass_info (MonoAotCompile *acfg, guint32 token)
{
ERROR_DECL (error);
MonoClass *klass = mono_class_get_checked (acfg->image, token, error);
guint8 *p, *buf;
int i, buf_size, res;
gboolean no_special_static, cant_encode;
gpointer iter = NULL;
if (!klass) {
mono_error_cleanup (error);
buf_size = 16;
p = buf = (guint8 *)g_malloc (buf_size);
/* Mark as unusable */
encode_value (-1, p, &p);
res = add_to_blob (acfg, buf, p - buf);
g_free (buf);
return res;
}
buf_size = 10240 + (m_class_get_vtable_size (klass) * 16);
p = buf = (guint8 *)g_malloc (buf_size);
g_assert (klass);
mono_class_init_internal (klass);
mono_class_get_nested_types (klass, &iter);
g_assert (m_class_is_nested_classes_inited (klass));
mono_class_setup_vtable (klass);
/*
* Emit all the information which is required for creating vtables so
* the runtime does not need to create the MonoMethod structures which
* take up a lot of space.
*/
no_special_static = !mono_class_has_special_static_fields (klass);
/* Check whenever we have enough info to encode the vtable */
cant_encode = FALSE;
MonoMethod **klass_vtable = m_class_get_vtable (klass);
for (i = 0; i < m_class_get_vtable_size (klass); ++i) {
MonoMethod *cm = klass_vtable [i];
if (cm && mono_method_signature_internal (cm)->is_inflated && !g_hash_table_lookup (acfg->token_info_hash, cm))
cant_encode = TRUE;
}
mono_class_has_finalizer (klass);
if (mono_class_has_failure (klass))
cant_encode = TRUE;
if (mono_class_is_gtd (klass) || cant_encode) {
encode_value (-1, p, &p);
} else {
gboolean has_nested = mono_class_get_nested_classes_property (klass) != NULL;
encode_value (m_class_get_vtable_size (klass), p, &p);
encode_value ((m_class_has_weak_fields (klass) << 9) | (mono_class_is_gtd (klass) ? (1 << 8) : 0) | (no_special_static << 7) | (m_class_has_static_refs (klass) << 6) | (m_class_has_references (klass) << 5) | ((m_class_is_blittable (klass) << 4) | (has_nested ? 1 : 0) << 3) | (m_class_has_cctor (klass) << 2) | (m_class_has_finalize (klass) << 1) | m_class_is_ghcimpl (klass), p, &p);
if (m_class_has_cctor (klass))
encode_method_ref (acfg, mono_class_get_cctor (klass), p, &p);
if (m_class_has_finalize (klass))
encode_method_ref (acfg, mono_class_get_finalizer (klass), p, &p);
encode_value (m_class_get_instance_size (klass), p, &p);
encode_value (mono_class_data_size (klass), p, &p);
encode_value (m_class_get_packing_size (klass), p, &p);
encode_value (m_class_get_min_align (klass), p, &p);
for (i = 0; i < m_class_get_vtable_size (klass); ++i) {
MonoMethod *cm = klass_vtable [i];
if (cm)
encode_method_ref (acfg, cm, p, &p);
else
encode_value (0, p, &p);
}
}
acfg->stats.class_info_size += p - buf;
g_assert (p - buf < buf_size);
res = add_to_blob (acfg, buf, p - buf);
g_free (buf);
return res;
}
static char*
get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cache)
{
char *debug_sym = NULL;
char *prefix;
if (acfg->llvm && llvm_acfg->aot_opts.static_link) {
/* Need to add a prefix to create unique symbols */
prefix = g_strdup_printf ("plt_%s_", acfg->assembly_name_sym);
} else {
#if defined(TARGET_WIN32) && defined(TARGET_X86)
prefix = mangle_symbol_alloc ("plt_");
#else
prefix = g_strdup ("plt_");
#endif
}
switch (ji->type) {
case MONO_PATCH_INFO_METHOD:
debug_sym = get_debug_sym (ji->data.method, prefix, cache);
break;
case MONO_PATCH_INFO_JIT_ICALL_ID:
debug_sym = g_strdup_printf ("%s_jit_icall_%s", prefix, mono_find_jit_icall_info (ji->data.jit_icall_id)->name);
break;
case MONO_PATCH_INFO_RGCTX_FETCH:
debug_sym = g_strdup_printf ("%s_rgctx_fetch_%d", prefix, acfg->label_generator ++);
break;
case MONO_PATCH_INFO_ICALL_ADDR:
case MONO_PATCH_INFO_ICALL_ADDR_CALL: {
char *s = get_debug_sym (ji->data.method, "", cache);
debug_sym = g_strdup_printf ("%s_icall_native_%s", prefix, s);
g_free (s);
break;
}
case MONO_PATCH_INFO_SPECIFIC_TRAMPOLINE_LAZY_FETCH_ADDR:
debug_sym = g_strdup_printf ("%s_jit_icall_native_specific_trampoline_lazy_fetch_%lu", prefix, (gulong)ji->data.uindex);
break;
case MONO_PATCH_INFO_JIT_ICALL_ADDR:
debug_sym = g_strdup_printf ("%s_jit_icall_native_%s", prefix, mono_find_jit_icall_info (ji->data.jit_icall_id)->name);
break;
default:
break;
}
g_free (prefix);
return sanitize_symbol (acfg, debug_sym);
}
/*
* Calls made from AOTed code are routed through a table of jumps similar to the
* ELF PLT (Program Linkage Table). Initially the PLT entries jump to code which transfers
* control to the AOT runtime through a trampoline.
*/
static void
emit_plt (MonoAotCompile *acfg)
{
int i;
if (acfg->aot_opts.llvm_only) {
g_assert (acfg->plt_offset == 1);
return;
}
emit_line (acfg);
emit_section_change (acfg, ".text", 0);
emit_alignment_code (acfg, 16);
emit_info_symbol (acfg, "plt", TRUE);
emit_label (acfg, acfg->plt_symbol);
for (i = 0; i < acfg->plt_offset; ++i) {
char *debug_sym = NULL;
MonoPltEntry *plt_entry = NULL;
if (i == 0)
/*
* The first plt entry is unused.
*/
continue;
plt_entry = (MonoPltEntry *)g_hash_table_lookup (acfg->plt_offset_to_entry, GUINT_TO_POINTER (i));
debug_sym = plt_entry->debug_sym;
if (acfg->thumb_mixed && !plt_entry->jit_used)
/* Emit only a thumb version */
continue;
/* Skip plt entries not actually called */
if (!plt_entry->jit_used && !plt_entry->llvm_used)
continue;
if (acfg->llvm && !acfg->thumb_mixed) {
emit_label (acfg, plt_entry->llvm_symbol);
if (acfg->llvm) {
emit_global_inner (acfg, plt_entry->llvm_symbol, TRUE);
#if defined(TARGET_MACH)
fprintf (acfg->fp, ".private_extern %s\n", plt_entry->llvm_symbol);
#endif
}
}
if (debug_sym) {
if (acfg->need_no_dead_strip) {
emit_unset_mode (acfg);
fprintf (acfg->fp, " .no_dead_strip %s\n", debug_sym);
}
emit_local_symbol (acfg, debug_sym, NULL, TRUE);
emit_label (acfg, debug_sym);
}
emit_label (acfg, plt_entry->symbol);
arch_emit_plt_entry (acfg, acfg->got_symbol, i, (acfg->plt_got_offset_base + i) * sizeof (target_mgreg_t), acfg->plt_got_info_offsets [i]);
if (debug_sym)
emit_symbol_size (acfg, debug_sym, ".");
}
if (acfg->thumb_mixed) {
/* Make sure the ARM symbols don't alias the thumb ones */
emit_zero_bytes (acfg, 16);
/*
* Emit a separate set of PLT entries using thumb2 which is called by LLVM generated
* code.
*/
for (i = 0; i < acfg->plt_offset; ++i) {
char *debug_sym = NULL;
MonoPltEntry *plt_entry = NULL;
if (i == 0)
continue;
plt_entry = (MonoPltEntry *)g_hash_table_lookup (acfg->plt_offset_to_entry, GUINT_TO_POINTER (i));
/* Skip plt entries not actually called by LLVM code */
if (!plt_entry->llvm_used)
continue;
if (acfg->aot_opts.write_symbols) {
if (plt_entry->debug_sym)
debug_sym = g_strdup_printf ("%s_thumb", plt_entry->debug_sym);
}
if (debug_sym) {
#if defined(TARGET_MACH)
fprintf (acfg->fp, " .thumb_func %s\n", debug_sym);
fprintf (acfg->fp, " .no_dead_strip %s\n", debug_sym);
#endif
emit_local_symbol (acfg, debug_sym, NULL, TRUE);
emit_label (acfg, debug_sym);
}
fprintf (acfg->fp, "\n.thumb_func\n");
emit_label (acfg, plt_entry->llvm_symbol);
if (acfg->llvm)
emit_global_inner (acfg, plt_entry->llvm_symbol, TRUE);
arch_emit_llvm_plt_entry (acfg, acfg->got_symbol, i, (acfg->plt_got_offset_base + i) * sizeof (target_mgreg_t), acfg->plt_got_info_offsets [i]);
if (debug_sym) {
emit_symbol_size (acfg, debug_sym, ".");
g_free (debug_sym);
}
}
}
emit_symbol_size (acfg, acfg->plt_symbol, ".");
emit_info_symbol (acfg, "plt_end", TRUE);
arch_emit_unwind_info_sections (acfg, "plt", "plt_end", NULL);
}
/*
* emit_trampoline_full:
*
* If EMIT_TINFO is TRUE, emit additional information which can be used to create a MonoJitInfo for this trampoline by
* create_jit_info_for_trampoline ().
*/
static G_GNUC_UNUSED void
emit_trampoline_full (MonoAotCompile *acfg, MonoTrampInfo *info, gboolean emit_tinfo)
{
char start_symbol [MAX_SYMBOL_SIZE];
char end_symbol [MAX_SYMBOL_SIZE];
char symbol [MAX_SYMBOL_SIZE];
guint32 buf_size, info_offset;
MonoJumpInfo *patch_info;
guint8 *buf, *p;
GPtrArray *patches;
char *name;
guint8 *code;
guint32 code_size;
MonoJumpInfo *ji;
GSList *unwind_ops;
g_assert (info);
name = info->name;
code = (guint8*)MINI_FTNPTR_TO_ADDR (info->code);
code_size = info->code_size;
ji = info->ji;
unwind_ops = info->unwind_ops;
/* Emit code */
sprintf (start_symbol, "%s%s", acfg->user_symbol_prefix, name);
emit_section_change (acfg, ".text", 0);
emit_global (acfg, start_symbol, TRUE);
emit_alignment_code (acfg, AOT_FUNC_ALIGNMENT);
emit_label (acfg, start_symbol);
sprintf (symbol, "%snamed_%s", acfg->temp_prefix, name);
emit_label (acfg, symbol);
/*
* The code should access everything through the GOT, so we pass
* TRUE here.
*/
emit_and_reloc_code (acfg, NULL, code, code_size, ji, TRUE, NULL);
emit_symbol_size (acfg, start_symbol, ".");
if (emit_tinfo) {
sprintf (end_symbol, "%snamede_%s", acfg->temp_prefix, name);
emit_label (acfg, end_symbol);
}
/* Emit info */
/* Sort relocations */
patches = g_ptr_array_new ();
for (patch_info = ji; patch_info; patch_info = patch_info->next)
if (patch_info->type != MONO_PATCH_INFO_NONE)
g_ptr_array_add (patches, patch_info);
g_ptr_array_sort (patches, compare_patches);
buf_size = patches->len * 128 + 128;
buf = (guint8 *)g_malloc (buf_size);
p = buf;
encode_patch_list (acfg, patches, patches->len, FALSE, p, &p);
g_assert (p - buf < buf_size);
g_ptr_array_free (patches, TRUE);
sprintf (symbol, "%s%s_p", acfg->user_symbol_prefix, name);
info_offset = add_to_blob (acfg, buf, p - buf);
emit_section_change (acfg, RODATA_SECT, 0);
emit_global (acfg, symbol, FALSE);
emit_label (acfg, symbol);
emit_int32 (acfg, info_offset);
if (emit_tinfo) {
guint8 *encoded;
guint32 encoded_len;
guint32 uw_offset;
/*
* Emit additional information which can be used to reconstruct a partial MonoTrampInfo.
*/
encoded = mono_unwind_ops_encode (info->unwind_ops, &encoded_len);
uw_offset = get_unwind_info_offset (acfg, encoded, encoded_len);
g_free (encoded);
emit_symbol_diff (acfg, end_symbol, start_symbol, 0);
emit_int32 (acfg, uw_offset);
}
/* Emit debug info */
if (unwind_ops) {
char symbol2 [MAX_SYMBOL_SIZE];
sprintf (symbol, "%s", name);
sprintf (symbol2, "%snamed_%s", acfg->temp_prefix, name);
arch_emit_unwind_info_sections (acfg, start_symbol, end_symbol, unwind_ops);
if (acfg->dwarf)
mono_dwarf_writer_emit_trampoline (acfg->dwarf, symbol, symbol2, NULL, NULL, code_size, unwind_ops);
}
g_free (buf);
}
static G_GNUC_UNUSED void
emit_trampoline (MonoAotCompile *acfg, MonoTrampInfo *info)
{
emit_trampoline_full (acfg, info, TRUE);
}
static void
emit_trampolines (MonoAotCompile *acfg)
{
char symbol [MAX_SYMBOL_SIZE];
char end_symbol [MAX_SYMBOL_SIZE + 2];
int i, tramp_got_offset;
int ntype;
#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
int tramp_type;
#endif
if (!mono_aot_mode_is_full (&acfg->aot_opts) && !mono_aot_mode_is_interp (&acfg->aot_opts))
return;
if (acfg->aot_opts.llvm_only)
return;
g_assert (acfg->image->assembly);
/* Currently, we emit most trampolines into the mscorlib AOT image. */
if (mono_is_corlib_image(acfg->image->assembly->image)) {
#ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
MonoTrampInfo *info;
/*
* Emit the generic trampolines.
*
* We could save some code by treating the generic trampolines as a wrapper
* method, but that approach has its own complexities, so we choose the simpler
* method.
*/
for (tramp_type = 0; tramp_type < MONO_TRAMPOLINE_NUM; ++tramp_type) {
/* we overload the boolean here to indicate the slightly different trampoline needed, see mono_arch_create_generic_trampoline() */
mono_arch_create_generic_trampoline ((MonoTrampolineType)tramp_type, &info, acfg->aot_opts.use_trampolines_page? 2: TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
}
/* Emit the exception related code pieces */
mono_arch_get_restore_context (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_get_call_filter (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_get_throw_exception (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_get_rethrow_exception (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_get_rethrow_preserve_exception (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_get_throw_corlib_exception (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
#ifdef MONO_ARCH_HAVE_SDB_TRAMPOLINES
mono_arch_create_sdb_trampoline (TRUE, &info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
mono_arch_create_sdb_trampoline (FALSE, &info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
#endif
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
mono_arch_get_gsharedvt_trampoline (&info, TRUE);
if (info) {
emit_trampoline_full (acfg, info, TRUE);
/* Create a separate out trampoline for more information in stack traces */
info->name = g_strdup ("gsharedvt_out_trampoline");
emit_trampoline_full (acfg, info, TRUE);
mono_tramp_info_free (info);
}
#endif
#if defined(MONO_ARCH_HAVE_GET_TRAMPOLINES)
{
GSList *l = mono_arch_get_trampolines (TRUE);
while (l) {
MonoTrampInfo *info = (MonoTrampInfo *)l->data;
emit_trampoline (acfg, info);
l = l->next;
}
}
#endif
for (i = 0; i < acfg->aot_opts.nrgctx_fetch_trampolines; ++i) {
int offset;
offset = MONO_RGCTX_SLOT_MAKE_RGCTX (i);
mono_arch_create_rgctx_lazy_fetch_trampoline (offset, &info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
offset = MONO_RGCTX_SLOT_MAKE_MRGCTX (i);
mono_arch_create_rgctx_lazy_fetch_trampoline (offset, &info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
}
#ifdef MONO_ARCH_HAVE_GENERAL_RGCTX_LAZY_FETCH_TRAMPOLINE
mono_arch_create_general_rgctx_lazy_fetch_trampoline (&info, TRUE);
emit_trampoline (acfg, info);
mono_tramp_info_free (info);
#endif
{
GSList *l;
/* delegate_invoke_impl trampolines */
l = mono_arch_get_delegate_invoke_impls ();
while (l) {
MonoTrampInfo *info = (MonoTrampInfo *)l->data;
emit_trampoline (acfg, info);
l = l->next;
}
}
if (mono_aot_mode_is_interp (&acfg->aot_opts) && mono_is_corlib_image (acfg->image->assembly->image)) {
mono_arch_get_interp_to_native_trampoline (&info);
emit_trampoline (acfg, info);
#ifdef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
mono_arch_get_native_to_interp_trampoline (&info);
emit_trampoline (acfg, info);
#endif
}
#endif /* #ifdef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES */
/* Emit trampolines which are numerous */
/*
* These include the following:
* - specific trampolines
* - static rgctx invoke trampolines
* - imt trampolines
* These trampolines have the same code, they are parameterized by GOT
* slots.
* They are defined in this file, in the arch_... routines instead of
* in tramp-<ARCH>.c, since it is easier to do it this way.
*/
/*
* When running in aot-only mode, we can't create specific trampolines at
* runtime, so we create a few, and save them in the AOT file.
* Normal trampolines embed their argument as a literal inside the
* trampoline code, we can't do that here, so instead we embed an offset
* which needs to be added to the trampoline address to get the address of
* the GOT slot which contains the argument value.
* The generated trampolines jump to the generic trampolines using another
* GOT slot, which will be setup by the AOT loader to point to the
* generic trampoline code of the given type.
*/
/*
* FIXME: Maybe we should use more specific trampolines (i.e. one class init for
* each class).
*/
emit_section_change (acfg, ".text", 0);
tramp_got_offset = acfg->got_offset;
for (ntype = 0; ntype < MONO_AOT_TRAMP_NUM; ++ntype) {
switch (ntype) {
case MONO_AOT_TRAMP_SPECIFIC:
sprintf (symbol, "specific_trampolines");
break;
case MONO_AOT_TRAMP_STATIC_RGCTX:
sprintf (symbol, "static_rgctx_trampolines");
break;
case MONO_AOT_TRAMP_IMT:
sprintf (symbol, "imt_trampolines");
break;
case MONO_AOT_TRAMP_GSHAREDVT_ARG:
sprintf (symbol, "gsharedvt_arg_trampolines");
break;
case MONO_AOT_TRAMP_FTNPTR_ARG:
sprintf (symbol, "ftnptr_arg_trampolines");
break;
case MONO_AOT_TRAMP_UNBOX_ARBITRARY:
sprintf (symbol, "unbox_arbitrary_trampolines");
break;
default:
g_assert_not_reached ();
}
sprintf (end_symbol, "%s_e", symbol);
if (acfg->aot_opts.write_symbols)
emit_local_symbol (acfg, symbol, end_symbol, TRUE);
emit_alignment_code (acfg, AOT_FUNC_ALIGNMENT);
emit_info_symbol (acfg, symbol, TRUE);
acfg->trampoline_got_offset_base [ntype] = tramp_got_offset;
for (i = 0; i < acfg->num_trampolines [ntype]; ++i) {
int tramp_size = 0;
switch (ntype) {
case MONO_AOT_TRAMP_SPECIFIC:
arch_emit_specific_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 2;
break;
case MONO_AOT_TRAMP_STATIC_RGCTX:
arch_emit_static_rgctx_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 2;
break;
case MONO_AOT_TRAMP_IMT:
arch_emit_imt_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 1;
break;
case MONO_AOT_TRAMP_GSHAREDVT_ARG:
arch_emit_gsharedvt_arg_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 2;
break;
case MONO_AOT_TRAMP_FTNPTR_ARG:
arch_emit_ftnptr_arg_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 2;
break;
case MONO_AOT_TRAMP_UNBOX_ARBITRARY:
arch_emit_unbox_arbitrary_trampoline (acfg, tramp_got_offset, &tramp_size);
tramp_got_offset += 1;
break;
default:
g_assert_not_reached ();
}
if (!acfg->trampoline_size [ntype]) {
g_assert (tramp_size);
acfg->trampoline_size [ntype] = tramp_size;
}
}
emit_label (acfg, end_symbol);
emit_int32 (acfg, 0);
}
arch_emit_specific_trampoline_pages (acfg);
/* Reserve some entries at the end of the GOT for our use */
acfg->num_trampoline_got_entries = tramp_got_offset - acfg->got_offset;
}
acfg->got_offset += acfg->num_trampoline_got_entries;
}
static gboolean
str_begins_with (const char *str1, const char *str2)
{
int len = strlen (str2);
return strncmp (str1, str2, len) == 0;
}
void*
mono_aot_readonly_field_override (MonoClassField *field)
{
ReadOnlyValue *rdv;
for (rdv = readonly_values; rdv; rdv = rdv->next) {
char *p = rdv->name;
int len;
len = strlen (m_class_get_name_space (field->parent));
if (strncmp (p, m_class_get_name_space (field->parent), len))
continue;
p += len;
if (*p++ != '.')
continue;
len = strlen (m_class_get_name (field->parent));
if (strncmp (p, m_class_get_name (field->parent), len))
continue;
p += len;
if (*p++ != '.')
continue;
if (strcmp (p, field->name))
continue;
switch (rdv->type) {
case MONO_TYPE_I1:
return &rdv->value.i1;
case MONO_TYPE_I2:
return &rdv->value.i2;
case MONO_TYPE_I4:
return &rdv->value.i4;
default:
break;
}
}
return NULL;
}
static void
add_readonly_value (MonoAotOptions *opts, const char *val)
{
ReadOnlyValue *rdv;
const char *fval;
const char *tval;
/* the format of val is:
* namespace.typename.fieldname=type/value
* type can be i1 for uint8/int8/boolean, i2 for uint16/int16/char, i4 for uint32/int32
*/
fval = strrchr (val, '/');
if (!fval) {
fprintf (stderr, "AOT : invalid format for readonly field '%s', missing /.\n", val);
exit (1);
}
tval = strrchr (val, '=');
if (!tval) {
fprintf (stderr, "AOT : invalid format for readonly field '%s', missing =.\n", val);
exit (1);
}
rdv = g_new0 (ReadOnlyValue, 1);
rdv->name = (char *)g_malloc0 (tval - val + 1);
memcpy (rdv->name, val, tval - val);
tval++;
fval++;
if (strncmp (tval, "i1", 2) == 0) {
rdv->value.i1 = atoi (fval);
rdv->type = MONO_TYPE_I1;
} else if (strncmp (tval, "i2", 2) == 0) {
rdv->value.i2 = atoi (fval);
rdv->type = MONO_TYPE_I2;
} else if (strncmp (tval, "i4", 2) == 0) {
rdv->value.i4 = atoi (fval);
rdv->type = MONO_TYPE_I4;
} else {
fprintf (stderr, "AOT : unsupported type for readonly field '%s'.\n", tval);
exit (1);
}
rdv->next = readonly_values;
readonly_values = rdv;
}
static gchar *
clean_path (gchar * path)
{
if (!path)
return NULL;
if (g_str_has_suffix (path, G_DIR_SEPARATOR_S))
return path;
gchar *clean = g_strconcat (path, G_DIR_SEPARATOR_S, (const char*)NULL);
g_free (path);
return clean;
}
static const gchar *
wrap_path (const gchar * path)
{
int len;
if (!path)
return NULL;
// If the string contains no spaces, just return the original string.
if (strstr (path, " ") == NULL)
return path;
// If the string is already wrapped in quotes, return it.
len = strlen (path);
if (len >= 2 && path[0] == '\"' && path[len-1] == '\"')
return path;
// If the string contains spaces, then wrap it in quotes.
gchar *clean = g_strdup_printf ("\"%s\"", path);
return clean;
}
// Duplicate a char range and add it to a ptrarray, but only if it is nonempty
static void
ptr_array_add_range_if_nonempty(GPtrArray *args, gchar const *start, gchar const *end)
{
ptrdiff_t len = end-start;
if (len > 0)
g_ptr_array_add (args, g_strndup (start, len));
}
static GPtrArray *
mono_aot_split_options (const char *aot_options)
{
enum MonoAotOptionState {
MONO_AOT_OPTION_STATE_DEFAULT,
MONO_AOT_OPTION_STATE_STRING,
MONO_AOT_OPTION_STATE_ESCAPE,
};
GPtrArray *args = g_ptr_array_new ();
enum MonoAotOptionState state = MONO_AOT_OPTION_STATE_DEFAULT;
gchar const *opt_start = aot_options;
gboolean end_of_string = FALSE;
gchar cur;
g_return_val_if_fail (aot_options != NULL, NULL);
while ((cur = *aot_options) != '\0') {
if (state == MONO_AOT_OPTION_STATE_ESCAPE)
goto next;
switch (cur) {
case '"':
// If we find a quote, then if we're in the default case then
// it means we've found the start of a string, if not then it
// means we've found the end of the string and should switch
// back to the default case.
switch (state) {
case MONO_AOT_OPTION_STATE_DEFAULT:
state = MONO_AOT_OPTION_STATE_STRING;
break;
case MONO_AOT_OPTION_STATE_STRING:
state = MONO_AOT_OPTION_STATE_DEFAULT;
break;
case MONO_AOT_OPTION_STATE_ESCAPE:
g_assert_not_reached ();
break;
}
break;
case '\\':
// If we've found an escaping operator, then this means we
// should not process the next character if inside a string.
if (state == MONO_AOT_OPTION_STATE_STRING)
state = MONO_AOT_OPTION_STATE_ESCAPE;
break;
case ',':
// If we're in the default state then this means we've found
// an option, store it for later processing.
if (state == MONO_AOT_OPTION_STATE_DEFAULT)
goto new_opt;
break;
}
next:
aot_options++;
restart:
// If the next character is end of string, then process the last option.
if (*(aot_options) == '\0') {
end_of_string = TRUE;
goto new_opt;
}
continue;
new_opt:
ptr_array_add_range_if_nonempty (args, opt_start, aot_options);
opt_start = ++aot_options;
if (end_of_string)
break;
goto restart; // Check for null and continue loop
}
return args;
}
static gboolean
parse_cpu_features (const gchar *attr)
{
if (!attr || strlen (attr) < 2) {
fprintf (stderr, "Invalid attribute");
return FALSE;
}
//+foo - enable foo
//foo - enable foo
//-foo - disable foo
gboolean enabled = TRUE;
if (attr [0] == '-')
enabled = FALSE;
int prefix = (attr [0] == '-' || attr [0] == '+') ? 1 : 0;
MonoCPUFeatures feature = (MonoCPUFeatures) 0;
#if defined(TARGET_X86) || defined(TARGET_AMD64)
// e.g.:
// `mattr=+sse3` = +sse,+sse2,+sse3
// `mattr=-sse3` = -sse3,-ssse3,-sse4.1,-sse4.2,-popcnt,-avx,-avx2,-fma
if (!strcmp (attr + prefix, "sse"))
feature = MONO_CPU_X86_SSE_COMBINED;
else if (!strcmp (attr + prefix, "sse2"))
feature = MONO_CPU_X86_SSE2_COMBINED;
else if (!strcmp (attr + prefix, "sse3"))
feature = MONO_CPU_X86_SSE3_COMBINED;
else if (!strcmp (attr + prefix, "ssse3"))
feature = MONO_CPU_X86_SSSE3_COMBINED;
else if (!strcmp (attr + prefix, "sse4.1"))
feature = MONO_CPU_X86_SSE41_COMBINED;
else if (!strcmp (attr + prefix, "sse4.2"))
feature = MONO_CPU_X86_SSE42_COMBINED;
else if (!strcmp (attr + prefix, "avx"))
feature = MONO_CPU_X86_AVX_COMBINED;
else if (!strcmp (attr + prefix, "avx2"))
feature = MONO_CPU_X86_AVX2_COMBINED;
else if (!strcmp (attr + prefix, "pclmul"))
feature = MONO_CPU_X86_PCLMUL_COMBINED;
else if (!strcmp (attr + prefix, "aes"))
feature = MONO_CPU_X86_AES_COMBINED;
else if (!strcmp (attr + prefix, "popcnt"))
feature = MONO_CPU_X86_POPCNT_COMBINED;
else if (!strcmp (attr + prefix, "fma"))
feature = MONO_CPU_X86_FMA_COMBINED;
// these are independent
else if (!strcmp (attr + prefix, "lzcnt")) // technically, it'a a part of BMI but only on Intel
feature = MONO_CPU_X86_LZCNT;
else if (!strcmp (attr + prefix, "bmi")) // NOTE: it's not "bmi1"
feature = MONO_CPU_X86_BMI1;
else if (!strcmp (attr + prefix, "bmi2"))
feature = MONO_CPU_X86_BMI2; // BMI2 doesn't imply BMI1
else {
// we don't have a flag for it but it's probably recognized by opt/llc so let's don't fire an error here
// printf ("Unknown cpu feature: %s\n", attr);
}
// if we disable a feature from the SSE-AVX tree we also need to disable all dependencies
if (!enabled && (feature & MONO_CPU_X86_FULL_SSEAVX_COMBINED))
feature = (MonoCPUFeatures) (MONO_CPU_X86_FULL_SSEAVX_COMBINED & ~feature);
#elif defined(TARGET_ARM64)
// MONO_CPU_ARM64_BASE is unconditionally set in mini_get_cpu_features.
if (!strcmp (attr + prefix, "crc"))
feature = MONO_CPU_ARM64_CRC;
else if (!strcmp (attr + prefix, "crypto"))
feature = MONO_CPU_ARM64_CRYPTO;
else if (!strcmp (attr + prefix, "neon"))
feature = MONO_CPU_ARM64_NEON;
else if (!strcmp (attr + prefix, "rdm"))
feature = MONO_CPU_ARM64_RDM;
else if (!strcmp (attr + prefix, "dotprod"))
feature = MONO_CPU_ARM64_DP;
#elif defined(TARGET_WASM)
if (!strcmp (attr + prefix, "simd"))
feature = MONO_CPU_WASM_SIMD;
#endif
if (enabled)
mono_cpu_features_enabled = (MonoCPUFeatures) (mono_cpu_features_enabled | feature);
else
mono_cpu_features_disabled = (MonoCPUFeatures) (mono_cpu_features_disabled | feature);
return TRUE;
}
static void
mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts)
{
GPtrArray* args;
args = mono_aot_split_options (aot_options ? aot_options : "");
for (int i = 0; i < args->len; ++i) {
const char *arg = (const char *)g_ptr_array_index (args, i);
if (str_begins_with (arg, "outfile=")) {
opts->outfile = g_strdup (arg + strlen ("outfile="));
} else if (str_begins_with (arg, "llvm-outfile=")) {
opts->llvm_outfile = g_strdup (arg + strlen ("llvm-outfile="));
} else if (str_begins_with (arg, "temp-path=")) {
opts->temp_path = clean_path (g_strdup (arg + strlen ("temp-path=")));
} else if (str_begins_with (arg, "save-temps")) {
opts->save_temps = TRUE;
} else if (str_begins_with (arg, "keep-temps")) {
opts->save_temps = TRUE;
} else if (str_begins_with (arg, "write-symbols")) {
opts->write_symbols = TRUE;
} else if (str_begins_with (arg, "no-write-symbols")) {
opts->write_symbols = FALSE;
// Intentionally undocumented -- one-off experiment
} else if (str_begins_with (arg, "metadata-only")) {
opts->metadata_only = TRUE;
} else if (str_begins_with (arg, "bind-to-runtime-version")) {
opts->bind_to_runtime_version = TRUE;
} else if (str_begins_with (arg, "full")) {
opts->mode = MONO_AOT_MODE_FULL;
} else if (str_begins_with (arg, "hybrid")) {
opts->mode = MONO_AOT_MODE_HYBRID;
} else if (str_begins_with (arg, "interp")) {
opts->interp = TRUE;
} else if (str_begins_with (arg, "threads=")) {
opts->nthreads = atoi (arg + strlen ("threads="));
} else if (str_begins_with (arg, "static")) {
opts->static_link = TRUE;
opts->no_dlsym = TRUE;
} else if (str_begins_with (arg, "asmonly")) {
opts->asm_only = TRUE;
} else if (str_begins_with (arg, "asmwriter")) {
opts->asm_writer = TRUE;
} else if (str_begins_with (arg, "nodebug")) {
opts->nodebug = TRUE;
} else if (str_begins_with (arg, "dwarfdebug")) {
opts->dwarf_debug = TRUE;
// Intentionally undocumented -- No one remembers what this does. It appears to be ARM-only
} else if (str_begins_with (arg, "nopagetrampolines")) {
opts->use_trampolines_page = FALSE;
} else if (str_begins_with (arg, "ntrampolines=")) {
opts->ntrampolines = atoi (arg + strlen ("ntrampolines="));
} else if (str_begins_with (arg, "nrgctx-trampolines=")) {
opts->nrgctx_trampolines = atoi (arg + strlen ("nrgctx-trampolines="));
} else if (str_begins_with (arg, "nrgctx-fetch-trampolines=")) {
opts->nrgctx_fetch_trampolines = atoi (arg + strlen ("nrgctx-fetch-trampolines="));
} else if (str_begins_with (arg, "nimt-trampolines=")) {
opts->nimt_trampolines = atoi (arg + strlen ("nimt-trampolines="));
} else if (str_begins_with (arg, "ngsharedvt-trampolines=")) {
opts->ngsharedvt_arg_trampolines = atoi (arg + strlen ("ngsharedvt-trampolines="));
} else if (str_begins_with (arg, "nftnptr-arg-trampolines=")) {
opts->nftnptr_arg_trampolines = atoi (arg + strlen ("nftnptr-arg-trampolines="));
} else if (str_begins_with (arg, "nunbox-arbitrary-trampolines=")) {
opts->nunbox_arbitrary_trampolines = atoi (arg + strlen ("unbox-arbitrary-trampolines="));
} else if (str_begins_with (arg, "tool-prefix=")) {
opts->tool_prefix = g_strdup (arg + strlen ("tool-prefix="));
} else if (str_begins_with (arg, "ld-flags=")) {
opts->ld_flags = g_strdup (arg + strlen ("ld-flags="));
} else if (str_begins_with (arg, "ld-name=")) {
opts->ld_name = g_strdup (arg + strlen ("ld-name="));
} else if (str_begins_with (arg, "soft-debug")) {
opts->soft_debug = TRUE;
// Intentionally undocumented x2-- deprecated
} else if (str_begins_with (arg, "gen-seq-points-file=")) {
fprintf (stderr, "Mono Warning: aot option gen-seq-points-file= is deprecated.\n");
} else if (str_begins_with (arg, "gen-seq-points-file")) {
fprintf (stderr, "Mono Warning: aot option gen-seq-points-file is deprecated.\n");
} else if (str_begins_with (arg, "msym-dir=")) {
mini_debug_options.no_seq_points_compact_data = FALSE;
opts->gen_msym_dir = TRUE;
opts->gen_msym_dir_path = g_strdup (arg + strlen ("msym_dir="));
} else if (str_begins_with (arg, "direct-pinvoke")) {
opts->direct_pinvoke = TRUE;
} else if (str_begins_with (arg, "direct-icalls")) {
opts->direct_icalls = TRUE;
} else if (str_begins_with (arg, "direct-extern-calls")) {
opts->direct_extern_calls = TRUE;
} else if (str_begins_with (arg, "no-direct-calls")) {
opts->no_direct_calls = TRUE;
} else if (str_begins_with (arg, "print-skipped")) {
opts->print_skipped_methods = TRUE;
} else if (str_begins_with (arg, "stats")) {
opts->stats = TRUE;
// Intentionally undocumented-- has no known function other than to debug the compiler
} else if (str_begins_with (arg, "no-instances")) {
opts->no_instances = TRUE;
// Intentionally undocumented x4-- Used for internal debugging of compiler
} else if (str_begins_with (arg, "log-generics")) {
opts->log_generics = TRUE;
} else if (str_begins_with (arg, "log-instances=")) {
opts->log_instances = TRUE;
opts->instances_logfile_path = g_strdup (arg + strlen ("log-instances="));
} else if (str_begins_with (arg, "log-instances")) {
opts->log_instances = TRUE;
} else if (str_begins_with (arg, "internal-logfile=")) {
opts->logfile = g_strdup (arg + strlen ("internal-logfile="));
} else if (str_begins_with (arg, "dedup-skip")) {
opts->dedup = TRUE;
} else if (str_begins_with (arg, "dedup-include=")) {
opts->dedup_include = g_strdup (arg + strlen ("dedup-include="));
} else if (str_begins_with (arg, "mtriple=")) {
opts->mtriple = g_strdup (arg + strlen ("mtriple="));
} else if (str_begins_with (arg, "llvm-path=")) {
opts->llvm_path = clean_path (g_strdup (arg + strlen ("llvm-path=")));
} else if (!strcmp (arg, "try-llvm")) {
// If we can load LLVM, use it
// Note: if you call this function from anywhere but mono_compile_assembly,
// this will only set the try_llvm attribute and not do the probing / set the
// attribute.
opts->try_llvm = TRUE;
} else if (!strcmp (arg, "llvm")) {
opts->llvm = TRUE;
} else if (str_begins_with (arg, "readonly-value=")) {
add_readonly_value (opts, arg + strlen ("readonly-value="));
} else if (str_begins_with (arg, "info")) {
printf ("AOT target setup: %s.\n", AOT_TARGET_STR);
exit (0);
// Intentionally undocumented: Used for precise stack maps, which are not available yet
} else if (str_begins_with (arg, "gc-maps")) {
mini_gc_enable_gc_maps_for_aot ();
// Intentionally undocumented: Used for internal debugging
} else if (str_begins_with (arg, "dump")) {
opts->dump_json = TRUE;
} else if (str_begins_with (arg, "llvmonly")) {
opts->mode = MONO_AOT_MODE_FULL;
opts->llvm = TRUE;
opts->llvm_only = TRUE;
} else if (str_begins_with (arg, "data-outfile=")) {
opts->data_outfile = g_strdup (arg + strlen ("data-outfile="));
} else if (str_begins_with (arg, "profile=")) {
opts->profile_files = g_list_append (opts->profile_files, g_strdup (arg + strlen ("profile=")));
} else if (!strcmp (arg, "profile-only")) {
opts->profile_only = TRUE;
} else if (!strcmp (arg, "verbose")) {
opts->verbose = TRUE;
} else if (str_begins_with (arg, "llvmopts=")){
if (opts->llvm_opts) {
char *s = g_strdup_printf ("%s %s", opts->llvm_opts, arg + strlen ("llvmopts="));
g_free (opts->llvm_opts);
opts->llvm_opts = s;
} else {
opts->llvm_opts = g_strdup (arg + strlen ("llvmopts="));
}
} else if (str_begins_with (arg, "llvmllc=")){
opts->llvm_llc = g_strdup (arg + strlen ("llvmllc="));
} else if (!strcmp (arg, "deterministic")) {
opts->deterministic = TRUE;
} else if (!strcmp (arg, "no-opt")) {
opts->no_opt = TRUE;
} else if (str_begins_with (arg, "clangxx=")) {
opts->clangxx = g_strdup (arg + strlen ("clangxx="));
} else if (str_begins_with (arg, "mcpu=")) {
if (!strcmp(arg, "mcpu=native")) {
opts->use_current_cpu = TRUE;
} else if (!strcmp(arg, "mcpu=generic")) {
opts->use_current_cpu = FALSE;
} else {
printf ("mcpu can only be 'native' or 'generic' (default).\n");
exit (0);
}
} else if (str_begins_with (arg, "mattr=")) {
gchar* attr = g_strdup (arg + strlen ("mattr="));
if (!parse_cpu_features (attr))
exit (0);
// mattr can be declared more than once, e.g.
// `mattr=avx2,mattr=lzcnt,mattr=bmi2`
if (!opts->llvm_cpu_attr)
opts->llvm_cpu_attr = attr;
else {
char* old_attrs = opts->llvm_cpu_attr;
opts->llvm_cpu_attr = g_strdup_printf ("%s,%s", opts->llvm_cpu_attr, attr);
g_free (old_attrs);
}
} else if (str_begins_with (arg, "depfile=")) {
opts->depfile = g_strdup (arg + strlen ("depfile="));
} else if (str_begins_with (arg, "help") || str_begins_with (arg, "?")) {
printf ("Supported options for --aot:\n");
printf (" asmonly\n");
printf (" bind-to-runtime-version\n");
printf (" bitcode\n");
printf (" data-outfile=\n");
printf (" direct-icalls\n");
printf (" direct-pinvoke\n");
printf (" dwarfdebug\n");
printf (" full\n");
printf (" hybrid\n");
printf (" info\n");
printf (" keep-temps\n");
printf (" llvm\n");
printf (" llvmonly\n");
printf (" llvm-outfile=\n");
printf (" llvm-path=\n");
printf (" msym-dir=\n");
printf (" mtriple\n");
printf (" nimt-trampolines=\n");
printf (" nodebug\n");
printf (" no-direct-calls\n");
printf (" no-write-symbols\n");
printf (" nrgctx-trampolines=\n");
printf (" nrgctx-fetch-trampolines=\n");
printf (" ngsharedvt-trampolines=\n");
printf (" nftnptr-arg-trampolines=\n");
printf (" nunbox-arbitrary-trampolines=\n");
printf (" ntrampolines=\n");
printf (" outfile=\n");
printf (" profile=\n");
printf (" profile-only\n");
printf (" print-skipped-methods\n");
printf (" readonly-value=\n");
printf (" save-temps\n");
printf (" soft-debug\n");
printf (" static\n");
printf (" stats\n");
printf (" temp-path=\n");
printf (" tool-prefix=\n");
printf (" threads=\n");
printf (" write-symbols\n");
printf (" verbose\n");
printf (" no-opt\n");
printf (" llvmopts=\n");
printf (" llvmllc=\n");
printf (" clangxx=\n");
printf (" depfile=\n");
printf (" mcpu=\n");
printf (" mattr=\n");
printf (" help/?\n");
exit (0);
} else {
fprintf (stderr, "AOT : Unknown argument '%s'.\n", arg);
exit (1);
}
g_free ((gpointer) arg);
}
if (opts->use_trampolines_page) {
opts->ntrampolines = 0;
opts->nrgctx_trampolines = 0;
opts->nimt_trampolines = 0;
opts->ngsharedvt_arg_trampolines = 0;
opts->nftnptr_arg_trampolines = 0;
opts->nunbox_arbitrary_trampolines = 0;
}
g_ptr_array_free (args, /*free_seg=*/TRUE);
}
static void
add_token_info_hash (gpointer key, gpointer value, gpointer user_data)
{
MonoMethod *method = (MonoMethod*)key;
MonoJumpInfoToken *ji = (MonoJumpInfoToken*)value;
MonoAotCompile *acfg = (MonoAotCompile *)user_data;
MonoJumpInfoToken *new_ji;
new_ji = (MonoJumpInfoToken *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfoToken));
new_ji->image = ji->image;
new_ji->token = ji->token;
g_hash_table_insert (acfg->token_info_hash, method, new_ji);
}
static gboolean
can_encode_class (MonoAotCompile *acfg, MonoClass *klass)
{
if (m_class_get_type_token (klass))
return TRUE;
if ((m_class_get_byval_arg (klass)->type == MONO_TYPE_VAR) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_MVAR) || (m_class_get_byval_arg (klass)->type == MONO_TYPE_PTR))
return TRUE;
if (m_class_get_rank (klass))
return can_encode_class (acfg, m_class_get_element_class (klass));
return FALSE;
}
static gboolean
can_encode_method (MonoAotCompile *acfg, MonoMethod *method)
{
if (method->wrapper_type) {
switch (method->wrapper_type) {
case MONO_WRAPPER_NONE:
case MONO_WRAPPER_STELEMREF:
case MONO_WRAPPER_ALLOC:
case MONO_WRAPPER_OTHER:
case MONO_WRAPPER_WRITE_BARRIER:
case MONO_WRAPPER_DELEGATE_INVOKE:
case MONO_WRAPPER_DELEGATE_BEGIN_INVOKE:
case MONO_WRAPPER_DELEGATE_END_INVOKE:
case MONO_WRAPPER_SYNCHRONIZED:
case MONO_WRAPPER_MANAGED_TO_NATIVE:
break;
case MONO_WRAPPER_MANAGED_TO_MANAGED:
case MONO_WRAPPER_NATIVE_TO_MANAGED:
case MONO_WRAPPER_CASTCLASS: {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
if (info)
return TRUE;
else
return FALSE;
break;
}
default:
//printf ("Skip (wrapper call): %d -> %s\n", patch_info->type, mono_method_full_name (patch_info->data.method, TRUE));
return FALSE;
}
} else {
if (!method->token) {
/* The method is part of a constructed type like Int[,].Set (). */
if (!g_hash_table_lookup (acfg->token_info_hash, method)) {
if (m_class_get_rank (method->klass))
return TRUE;
return FALSE;
}
}
}
return TRUE;
}
static gboolean
can_encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info)
{
switch (patch_info->type) {
case MONO_PATCH_INFO_METHOD:
case MONO_PATCH_INFO_METHOD_FTNDESC:
case MONO_PATCH_INFO_METHODCONST:
case MONO_PATCH_INFO_METHOD_CODE_SLOT:
case MONO_PATCH_INFO_METHOD_PINVOKE_ADDR_CACHE: {
MonoMethod *method = patch_info->data.method;
return can_encode_method (acfg, method);
}
case MONO_PATCH_INFO_VTABLE:
case MONO_PATCH_INFO_CLASS:
case MONO_PATCH_INFO_IID:
case MONO_PATCH_INFO_ADJUSTED_IID:
if (!can_encode_class (acfg, patch_info->data.klass)) {
//printf ("Skip: %s\n", mono_type_full_name (m_class_get_byval_arg (patch_info->data.klass)));
return FALSE;
}
break;
case MONO_PATCH_INFO_DELEGATE_TRAMPOLINE: {
if (!can_encode_class (acfg, patch_info->data.del_tramp->klass)) {
//printf ("Skip: %s\n", mono_type_full_name (m_class_get_byval_arg (patch_info->data.klass)));
return FALSE;
}
break;
}
case MONO_PATCH_INFO_RGCTX_FETCH:
case MONO_PATCH_INFO_RGCTX_SLOT_INDEX: {
MonoJumpInfoRgctxEntry *entry = patch_info->data.rgctx_entry;
if (entry->in_mrgctx) {
if (!can_encode_method (acfg, entry->d.method))
return FALSE;
} else {
if (!can_encode_class (acfg, entry->d.klass))
return FALSE;
}
if (!can_encode_patch (acfg, entry->data))
return FALSE;
break;
}
default:
break;
}
return TRUE;
}
static gboolean
is_concrete_type (MonoType *t)
{
MonoClass *klass;
int i;
if (t->type == MONO_TYPE_VAR || t->type == MONO_TYPE_MVAR)
return FALSE;
if (t->type == MONO_TYPE_GENERICINST) {
MonoGenericContext *orig_ctx;
MonoGenericInst *inst;
MonoType *arg;
if (!MONO_TYPE_ISSTRUCT (t))
return TRUE;
klass = mono_class_from_mono_type_internal (t);
orig_ctx = &mono_class_get_generic_class (klass)->context;
inst = orig_ctx->class_inst;
if (inst) {
for (i = 0; i < inst->type_argc; ++i) {
arg = mini_get_underlying_type (inst->type_argv [i]);
if (!is_concrete_type (arg))
return FALSE;
}
}
inst = orig_ctx->method_inst;
if (inst) {
for (i = 0; i < inst->type_argc; ++i) {
arg = mini_get_underlying_type (inst->type_argv [i]);
if (!is_concrete_type (arg))
return FALSE;
}
}
}
return TRUE;
}
static MonoMethodSignature*
get_concrete_sig (MonoMethodSignature *sig)
{
gboolean concrete = TRUE;
if (!sig->has_type_parameters)
return sig;
/* For signatures created during generic sharing, convert them to a concrete signature if possible */
MonoMethodSignature *copy = mono_metadata_signature_dup (sig);
int i;
//printf ("%s\n", mono_signature_full_name (sig));
if (sig->ret->byref)
copy->ret = m_class_get_this_arg (mono_defaults.int_class);
else
copy->ret = mini_get_underlying_type (sig->ret);
if (!is_concrete_type (copy->ret))
concrete = FALSE;
for (i = 0; i < sig->param_count; ++i) {
if (sig->params [i]->byref) {
MonoType *t = m_class_get_byval_arg (mono_class_from_mono_type_internal (sig->params [i]));
t = mini_get_underlying_type (t);
copy->params [i] = m_class_get_this_arg (mono_class_from_mono_type_internal (t));
} else {
copy->params [i] = mini_get_underlying_type (sig->params [i]);
}
if (!is_concrete_type (copy->params [i]))
concrete = FALSE;
}
copy->has_type_parameters = 0;
if (!concrete)
return NULL;
return copy;
}
/* LOCKING: Assumes the loader lock is held */
static void
add_gsharedvt_wrappers (MonoAotCompile *acfg, MonoMethodSignature *sig, gboolean gsharedvt_in, gboolean gsharedvt_out, gboolean interp_in)
{
MonoMethod *wrapper;
gboolean add_in = gsharedvt_in;
gboolean add_out = gsharedvt_out;
if (gsharedvt_in && g_hash_table_lookup (acfg->gsharedvt_in_signatures, sig))
add_in = FALSE;
if (gsharedvt_out && g_hash_table_lookup (acfg->gsharedvt_out_signatures, sig))
add_out = FALSE;
if (!add_in && !add_out && !interp_in)
return;
if (mini_is_gsharedvt_variable_signature (sig))
return;
if (add_in)
g_hash_table_insert (acfg->gsharedvt_in_signatures, sig, sig);
if (add_out)
g_hash_table_insert (acfg->gsharedvt_out_signatures, sig, sig);
sig = get_concrete_sig (sig);
if (!sig)
return;
//printf ("%s\n", mono_signature_full_name (sig));
if (gsharedvt_in) {
wrapper = mini_get_gsharedvt_in_sig_wrapper (sig);
add_extra_method (acfg, wrapper);
}
if (gsharedvt_out) {
wrapper = mini_get_gsharedvt_out_sig_wrapper (sig);
add_extra_method (acfg, wrapper);
}
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
if (interp_in) {
wrapper = mini_get_interp_in_wrapper (sig);
add_extra_method (acfg, wrapper);
}
#endif
}
/*
* compile_method:
*
* AOT compile a given method.
* This function might be called by multiple threads, so it must be thread-safe.
*/
static void
compile_method (MonoAotCompile *acfg, MonoMethod *method)
{
MonoCompile *cfg;
MonoJumpInfo *patch_info;
gboolean skip;
int index, depth;
MonoMethod *wrapped;
gint64 jit_time_start;
JitFlags flags;
if (acfg->aot_opts.metadata_only)
return;
mono_acfg_lock (acfg);
index = get_method_index (acfg, method);
mono_acfg_unlock (acfg);
/* fixme: maybe we can also precompile wrapper methods */
if ((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
(method->flags & METHOD_ATTRIBUTE_ABSTRACT)) {
//printf ("Skip (impossible): %s\n", mono_method_full_name (method, TRUE));
return;
}
if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL)
return;
wrapped = mono_marshal_method_from_wrapper (method);
if (wrapped && (wrapped->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) && wrapped->is_generic)
// FIXME: The wrapper should be generic too, but it is not
return;
if (method->wrapper_type == MONO_WRAPPER_COMINTEROP)
return;
if (acfg->aot_opts.profile_only && !g_hash_table_lookup (acfg->profile_methods, method)) {
if (acfg->aot_opts.llvm_only) {
gboolean keep = FALSE;
if (method->wrapper_type) {
/* Keep most wrappers */
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
switch (info->subtype) {
case WRAPPER_SUBTYPE_PTR_TO_STRUCTURE:
case WRAPPER_SUBTYPE_STRUCTURE_TO_PTR:
break;
default:
keep = TRUE;
break;
}
}
if (always_aot (method))
keep = TRUE;
if (!keep)
return;
} else {
if (!method->is_inflated)
return;
}
}
mono_atomic_inc_i32 (&acfg->stats.mcount);
#if 0
if (method->is_generic || mono_class_is_gtd (method->klass)) {
mono_atomic_inc_i32 (&acfg->stats.genericcount);
return;
}
#endif
//acfg->aot_opts.print_skipped_methods = TRUE;
/*
* Since these methods are the only ones which are compiled with
* AOT support, and they are not used by runtime startup/shutdown code,
* the runtime will not see AOT methods during AOT compilation,so it
* does not need to support them by creating a fake GOT etc.
*/
flags = JIT_FLAG_AOT;
if (mono_aot_mode_is_full (&acfg->aot_opts))
flags = (JitFlags)(flags | JIT_FLAG_FULL_AOT);
if (acfg->llvm)
flags = (JitFlags)(flags | JIT_FLAG_LLVM);
if (acfg->aot_opts.llvm_only)
flags = (JitFlags)(flags | JIT_FLAG_LLVM_ONLY | JIT_FLAG_EXPLICIT_NULL_CHECKS);
if (acfg->aot_opts.no_direct_calls)
flags = (JitFlags)(flags | JIT_FLAG_NO_DIRECT_ICALLS);
if (acfg->aot_opts.direct_pinvoke)
flags = (JitFlags)(flags | JIT_FLAG_DIRECT_PINVOKE);
if (acfg->aot_opts.interp)
flags = (JitFlags)(flags | JIT_FLAG_INTERP);
if (acfg->aot_opts.use_current_cpu)
flags = (JitFlags)(flags | JIT_FLAG_USE_CURRENT_CPU);
if (method_is_externally_callable (acfg, method))
flags = (JitFlags)(flags | JIT_FLAG_SELF_INIT);
if (acfg->flags & MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY)
flags = (JitFlags)(flags | JIT_FLAG_CODE_EXEC_ONLY);
jit_time_start = mono_time_track_start ();
cfg = mini_method_compile (method, acfg->jit_opts, flags, 0, index);
mono_time_track_end (&mono_jit_stats.jit_time, jit_time_start);
if (cfg->exception_type == MONO_EXCEPTION_GENERIC_SHARING_FAILED) {
if (acfg->aot_opts.print_skipped_methods)
printf ("Skip (gshared failure): %s (%s)\n", mono_method_get_full_name (method), cfg->exception_message);
mono_atomic_inc_i32 (&acfg->stats.genericcount);
return;
}
if (cfg->exception_type != MONO_EXCEPTION_NONE) {
/* Some instances cannot be JITted due to constraints etc. */
if (!method->is_inflated)
report_loader_error (acfg, cfg->error, FALSE, "Unable to compile method '%s' due to: '%s'.\n", mono_method_get_full_name (method), mono_error_get_message (cfg->error));
/* Let the exception happen at runtime */
return;
}
if (cfg->disable_aot) {
if (acfg->aot_opts.print_skipped_methods)
printf ("Skip (disabled): %s\n", mono_method_get_full_name (method));
mono_atomic_inc_i32 (&acfg->stats.ocount);
return;
}
cfg->method_index = index;
/* Nullify patches which need no aot processing */
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_LABEL:
case MONO_PATCH_INFO_BB:
patch_info->type = MONO_PATCH_INFO_NONE;
break;
default:
break;
}
}
/* Collect method->token associations from the cfg */
mono_acfg_lock (acfg);
g_hash_table_foreach (cfg->token_info_hash, add_token_info_hash, acfg);
mono_acfg_unlock (acfg);
g_hash_table_destroy (cfg->token_info_hash);
cfg->token_info_hash = NULL;
/*
* Check for absolute addresses.
*/
skip = FALSE;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_ABS:
/* unable to handle this */
skip = TRUE;
break;
default:
break;
}
}
if (skip) {
if (acfg->aot_opts.print_skipped_methods)
printf ("Skip (abs call): %s\n", mono_method_get_full_name (method));
mono_atomic_inc_i32 (&acfg->stats.abscount);
return;
}
/* Lock for the rest of the code */
mono_acfg_lock (acfg);
if (cfg->gsharedvt)
acfg->stats.method_categories [METHOD_CAT_GSHAREDVT] ++;
else if (cfg->gshared)
acfg->stats.method_categories [METHOD_CAT_INST] ++;
else if (cfg->method->wrapper_type)
acfg->stats.method_categories [METHOD_CAT_WRAPPER] ++;
else
acfg->stats.method_categories [METHOD_CAT_NORMAL] ++;
/*
* Check for methods/klasses we can't encode.
*/
skip = FALSE;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
if (!can_encode_patch (acfg, patch_info))
skip = TRUE;
}
if (skip) {
if (acfg->aot_opts.print_skipped_methods)
printf ("Skip (patches): %s\n", mono_method_get_full_name (method));
acfg->stats.ocount++;
mono_acfg_unlock (acfg);
return;
}
if (!cfg->compile_llvm)
acfg->has_jitted_code = TRUE;
if (method->is_inflated && acfg->aot_opts.log_instances) {
if (acfg->instances_logfile)
fprintf (acfg->instances_logfile, "%s ### %d\n", mono_method_get_full_name (method), cfg->code_size);
else
printf ("%s ### %d\n", mono_method_get_full_name (method), cfg->code_size);
}
/* Adds generic instances referenced by this method */
/*
* The depth is used to avoid infinite loops when generic virtual recursion is
* encountered.
*/
depth = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_depth, method));
if (!acfg->aot_opts.no_instances && depth < 32 && (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))) {
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_RGCTX_FETCH:
case MONO_PATCH_INFO_RGCTX_SLOT_INDEX:
case MONO_PATCH_INFO_METHOD:
case MONO_PATCH_INFO_METHOD_FTNDESC:
case MONO_PATCH_INFO_METHOD_RGCTX: {
MonoMethod *m = NULL;
if (patch_info->type == MONO_PATCH_INFO_RGCTX_FETCH || patch_info->type == MONO_PATCH_INFO_RGCTX_SLOT_INDEX) {
MonoJumpInfoRgctxEntry *e = patch_info->data.rgctx_entry;
if (e->info_type == MONO_RGCTX_INFO_GENERIC_METHOD_CODE || e->info_type == MONO_RGCTX_INFO_METHOD_FTNDESC)
m = e->data->data.method;
} else {
m = patch_info->data.method;
}
if (!m)
break;
if (m->is_inflated && (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))) {
if (!(mono_class_generic_sharing_enabled (m->klass) &&
mono_method_is_generic_sharable_full (m, FALSE, FALSE, FALSE)) &&
(!method_has_type_vars (m) || mono_method_is_generic_sharable_full (m, TRUE, TRUE, FALSE))) {
if (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
if (mono_aot_mode_is_full (&acfg->aot_opts) && !method_has_type_vars (m))
add_extra_method_with_depth (acfg, mono_marshal_get_native_wrapper (m, TRUE, TRUE), depth + 1);
} else {
add_extra_method_with_depth (acfg, m, depth + 1);
add_types_from_method_header (acfg, m);
}
}
add_generic_class_with_depth (acfg, m->klass, depth + 5, "method");
}
if (m->wrapper_type == MONO_WRAPPER_MANAGED_TO_MANAGED) {
WrapperInfo *info = mono_marshal_get_wrapper_info (m);
if (info && info->subtype == WRAPPER_SUBTYPE_ELEMENT_ADDR)
add_extra_method_with_depth (acfg, m, depth + 1);
}
break;
}
case MONO_PATCH_INFO_VTABLE: {
MonoClass *klass = patch_info->data.klass;
if (mono_class_is_ginst (klass) && !mini_class_is_generic_sharable (klass))
add_generic_class_with_depth (acfg, klass, depth + 5, "vtable");
break;
}
case MONO_PATCH_INFO_SFLDA: {
MonoClass *klass = patch_info->data.field->parent;
/* The .cctor needs to run at runtime. */
if (mono_class_is_ginst (klass) && !mono_generic_context_is_sharable_full (&mono_class_get_generic_class (klass)->context, FALSE, FALSE) && mono_class_get_cctor (klass))
add_extra_method_with_depth (acfg, mono_class_get_cctor (klass), depth + 1);
break;
}
default:
break;
}
}
}
/* Determine whenever the method has GOT slots */
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
switch (patch_info->type) {
case MONO_PATCH_INFO_GOT_OFFSET:
case MONO_PATCH_INFO_NONE:
case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR:
case MONO_PATCH_INFO_GC_NURSERY_START:
case MONO_PATCH_INFO_GC_NURSERY_BITS:
break;
case MONO_PATCH_INFO_IMAGE:
/* The assembly is stored in GOT slot 0 */
if (patch_info->data.image != acfg->image)
cfg->has_got_slots = TRUE;
break;
default:
if (!is_plt_patch (patch_info) || (cfg->compile_llvm && acfg->aot_opts.llvm_only))
cfg->has_got_slots = TRUE;
break;
}
}
if (!cfg->has_got_slots)
mono_atomic_inc_i32 (&acfg->stats.methods_without_got_slots);
/* Add gsharedvt wrappers for signatures used by the method */
if (acfg->aot_opts.llvm_only) {
GSList *l;
if (!cfg->method->wrapper_type || cfg->method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE)
/* These only need out wrappers */
add_gsharedvt_wrappers (acfg, mono_method_signature_internal (cfg->method), FALSE, TRUE, FALSE);
for (l = cfg->signatures; l; l = l->next) {
MonoMethodSignature *sig = mono_metadata_signature_dup ((MonoMethodSignature*)l->data);
/* These only need in wrappers */
add_gsharedvt_wrappers (acfg, sig, TRUE, FALSE, FALSE);
if (mono_aot_mode_is_interp (&acfg->aot_opts) && sig->param_count > MAX_INTERP_ENTRY_ARGS)
/* See below */
add_gsharedvt_wrappers (acfg, sig, FALSE, FALSE, TRUE);
}
for (l = cfg->interp_in_signatures; l; l = l->next) {
MonoMethodSignature *sig = mono_metadata_signature_dup ((MonoMethodSignature*)l->data);
/*
* Interpreter methods in llvmonly+interp mode are called using gsharedvt_in wrappers,
* since we already generate those in llvmonly mode. But methods with a large
* number of arguments need special processing (see interp_create_method_pointer_llvmonly),
* which only interp_in wrappers do.
*/
if (sig->param_count > MAX_INTERP_ENTRY_ARGS)
add_gsharedvt_wrappers (acfg, sig, FALSE, FALSE, TRUE);
else
add_gsharedvt_wrappers (acfg, sig, TRUE, FALSE, FALSE);
}
} else if (mono_aot_mode_is_full (&acfg->aot_opts) && mono_aot_mode_is_interp (&acfg->aot_opts)) {
/* The interpreter uses these wrappers to call aot-ed code */
if (!cfg->method->wrapper_type || cfg->method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE)
add_gsharedvt_wrappers (acfg, mono_method_signature_internal (cfg->method), FALSE, TRUE, TRUE);
}
if (cfg->llvm_only)
acfg->stats.llvm_count ++;
if (acfg->llvm && !cfg->compile_llvm && method_is_externally_callable (acfg, cfg->method)) {
/*
* This is a JITted fallback method for a method which failed LLVM compilation, emit a global
* symbol for it with the same name the LLVM method would get.
*/
char *name = mono_aot_get_mangled_method_name (cfg->method);
char *export_name = g_strdup_printf ("%s%s", acfg->user_symbol_prefix, name);
g_hash_table_insert (acfg->export_names, cfg->method, export_name);
}
/*
* FIXME: Instead of this mess, allocate the patches from the aot mempool.
*/
/* Make a copy of the patch info which is in the mempool */
{
MonoJumpInfo *patches = NULL, *patches_end = NULL;
for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
MonoJumpInfo *new_patch_info = mono_patch_info_dup_mp (acfg->mempool, patch_info);
if (!patches)
patches = new_patch_info;
else
patches_end->next = new_patch_info;
patches_end = new_patch_info;
}
cfg->patch_info = patches;
}
/* Make a copy of the unwind info */
{
GSList *l, *unwind_ops;
MonoUnwindOp *op;
unwind_ops = NULL;
for (l = cfg->unwind_ops; l; l = l->next) {
op = (MonoUnwindOp *)mono_mempool_alloc (acfg->mempool, sizeof (MonoUnwindOp));
memcpy (op, l->data, sizeof (MonoUnwindOp));
unwind_ops = g_slist_prepend_mempool (acfg->mempool, unwind_ops, op);
}
cfg->unwind_ops = g_slist_reverse (unwind_ops);
}
/* Make a copy of the argument/local info */
{
ERROR_DECL (error);
MonoInst **args, **locals;
MonoMethodSignature *sig;
MonoMethodHeader *header;
int i;
sig = mono_method_signature_internal (method);
args = (MonoInst **)mono_mempool_alloc (acfg->mempool, sizeof (MonoInst*) * (sig->param_count + sig->hasthis));
for (i = 0; i < sig->param_count + sig->hasthis; ++i) {
args [i] = (MonoInst *)mono_mempool_alloc (acfg->mempool, sizeof (MonoInst));
memcpy (args [i], cfg->args [i], sizeof (MonoInst));
}
cfg->args = args;
header = mono_method_get_header_checked (method, error);
mono_error_assert_ok (error); /* FIXME don't swallow the error */
locals = (MonoInst **)mono_mempool_alloc (acfg->mempool, sizeof (MonoInst*) * header->num_locals);
for (i = 0; i < header->num_locals; ++i) {
locals [i] = (MonoInst *)mono_mempool_alloc (acfg->mempool, sizeof (MonoInst));
memcpy (locals [i], cfg->locals [i], sizeof (MonoInst));
}
mono_metadata_free_mh (header);
cfg->locals = locals;
}
/* Free some fields used by cfg to conserve memory */
mono_empty_compile (cfg);
//printf ("Compile: %s\n", mono_method_full_name (method, TRUE));
acfg->cfgs [index] = cfg;
g_hash_table_insert (acfg->method_to_cfg, cfg->orig_method, cfg);
/* Update global stats while holding a lock. */
mono_update_jit_stats (cfg);
/*
if (cfg->orig_method->wrapper_type)
g_ptr_array_add (acfg->extra_methods, cfg->orig_method);
*/
mono_acfg_unlock (acfg);
mono_atomic_inc_i32 (&acfg->stats.ccount);
}
static mono_thread_start_return_t WINAPI
compile_thread_main (gpointer user_data)
{
MonoAotCompile *acfg = ((MonoAotCompile **)user_data) [0];
GPtrArray *methods = ((GPtrArray **)user_data) [1];
int i;
mono_thread_set_name_constant_ignore_error (mono_thread_internal_current (), "AOT compiler", MonoSetThreadNameFlag_Permanent);
for (i = 0; i < methods->len; ++i)
compile_method (acfg, (MonoMethod *)g_ptr_array_index (methods, i));
return 0;
}
/* Used by the LLVM backend */
guint32
mono_aot_get_got_offset (MonoJumpInfo *ji)
{
return get_got_offset (llvm_acfg, TRUE, ji);
}
/*
* mono_aot_is_shared_got_offset:
*
* Return whenever OFFSET refers to a GOT slot which is preinitialized
* when the AOT image is loaded.
*/
gboolean
mono_aot_is_shared_got_offset (int offset)
{
return offset < llvm_acfg->nshared_got_entries;
}
gboolean
mono_aot_is_externally_callable (MonoMethod *cmethod)
{
return method_is_externally_callable (llvm_acfg, cmethod);
}
char*
mono_aot_get_method_name (MonoCompile *cfg)
{
MonoMethod *method = cfg->orig_method;
/* Use the mangled name if possible */
if (method->wrapper_type == MONO_WRAPPER_OTHER) {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG || info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG) {
char *name, *s;
name = mono_aot_get_mangled_method_name (method);
if (llvm_acfg->aot_opts.static_link) {
/* Include the assembly name too to avoid duplicate symbol errors */
s = g_strdup_printf ("%s_%s", llvm_acfg->assembly_name_sym, name);
g_free (name);
return s;
} else {
return name;
}
}
}
if (llvm_acfg->aot_opts.static_link)
/* Include the assembly name too to avoid duplicate symbol errors */
return g_strdup_printf ("%s_%s", llvm_acfg->assembly_name_sym, get_debug_sym (cfg->orig_method, "", llvm_acfg->method_label_hash));
else
return get_debug_sym (cfg->orig_method, "", llvm_acfg->method_label_hash);
}
static gboolean
append_mangled_type (GString *s, MonoType *t)
{
if (t->byref)
g_string_append_printf (s, "b");
switch (t->type) {
case MONO_TYPE_VOID:
g_string_append_printf (s, "void");
break;
case MONO_TYPE_BOOLEAN:
g_string_append_printf (s, "bool");
break;
case MONO_TYPE_CHAR:
g_string_append_printf (s, "char");
break;
case MONO_TYPE_I1:
g_string_append_printf (s, "i1");
break;
case MONO_TYPE_U1:
g_string_append_printf (s, "u1");
break;
case MONO_TYPE_I2:
g_string_append_printf (s, "i2");
break;
case MONO_TYPE_U2:
g_string_append_printf (s, "u2");
break;
case MONO_TYPE_I4:
g_string_append_printf (s, "i4");
break;
case MONO_TYPE_U4:
g_string_append_printf (s, "u4");
break;
case MONO_TYPE_I8:
g_string_append_printf (s, "i8");
break;
case MONO_TYPE_U8:
g_string_append_printf (s, "u8");
break;
case MONO_TYPE_I:
g_string_append_printf (s, "ii");
break;
case MONO_TYPE_U:
g_string_append_printf (s, "ui");
break;
case MONO_TYPE_R4:
g_string_append_printf (s, "fl");
break;
case MONO_TYPE_R8:
g_string_append_printf (s, "do");
break;
case MONO_TYPE_OBJECT:
g_string_append_printf (s, "obj");
break;
default: {
char *fullname = mono_type_full_name (t);
char *name = fullname;
GString *temp;
char *temps;
gboolean is_system = FALSE;
int i, len;
len = strlen ("System.");
if (strncmp (fullname, "System.", len) == 0) {
name = fullname + len;
is_system = TRUE;
}
/*
* Have to create a mangled name which is:
* - a valid symbol
* - unique
*/
temp = g_string_new ("");
len = strlen (name);
for (i = 0; i < len; ++i) {
char c = name [i];
if (isalnum (c)) {
g_string_append_c (temp, c);
} else if (c == '_') {
g_string_append_c (temp, '_');
g_string_append_c (temp, '_');
} else {
g_string_append_c (temp, '_');
if (c == '.')
g_string_append_c (temp, 'd');
else
g_string_append_printf (temp, "%x", (int)c);
}
}
temps = g_string_free (temp, FALSE);
/* Include the length to avoid different length type names aliasing each other */
g_string_append_printf (s, "cl%s%x_%s_", is_system ? "s" : "", (int)strlen (temps), temps);
g_free (temps);
g_free (fullname);
}
}
if (t->attrs)
g_string_append_printf (s, "_attrs_%d", t->attrs);
return TRUE;
}
static gboolean
append_mangled_signature (GString *s, MonoMethodSignature *sig)
{
int i;
gboolean supported;
if (sig->pinvoke)
g_string_append_printf (s, "pinvoke_");
supported = append_mangled_type (s, sig->ret);
if (!supported)
return FALSE;
g_string_append_printf (s, "_");
if (sig->hasthis)
g_string_append_printf (s, "this_");
for (i = 0; i < sig->param_count; ++i) {
supported = append_mangled_type (s, sig->params [i]);
if (!supported)
return FALSE;
}
return TRUE;
}
static void
append_mangled_wrapper_type (GString *s, guint32 wrapper_type)
{
const char *label;
switch (wrapper_type) {
case MONO_WRAPPER_ALLOC:
label = "alloc";
break;
case MONO_WRAPPER_WRITE_BARRIER:
label = "write_barrier";
break;
case MONO_WRAPPER_STELEMREF:
label = "stelemref";
break;
case MONO_WRAPPER_OTHER:
label = "unknown";
break;
case MONO_WRAPPER_MANAGED_TO_NATIVE:
label = "man2native";
break;
case MONO_WRAPPER_SYNCHRONIZED:
label = "synch";
break;
case MONO_WRAPPER_MANAGED_TO_MANAGED:
label = "man2man";
break;
case MONO_WRAPPER_CASTCLASS:
label = "castclass";
break;
case MONO_WRAPPER_RUNTIME_INVOKE:
label = "run_invoke";
break;
case MONO_WRAPPER_DELEGATE_INVOKE:
label = "del_inv";
break;
case MONO_WRAPPER_DELEGATE_BEGIN_INVOKE:
label = "del_beg_inv";
break;
case MONO_WRAPPER_DELEGATE_END_INVOKE:
label = "del_end_inv";
break;
case MONO_WRAPPER_NATIVE_TO_MANAGED:
label = "native2man";
break;
default:
g_assert_not_reached ();
}
g_string_append_printf (s, "%s_", label);
}
static void
append_mangled_wrapper_subtype (GString *s, WrapperSubtype subtype)
{
const char *label;
switch (subtype)
{
case WRAPPER_SUBTYPE_NONE:
return;
case WRAPPER_SUBTYPE_ELEMENT_ADDR:
label = "elem_addr";
break;
case WRAPPER_SUBTYPE_STRING_CTOR:
label = "str_ctor";
break;
case WRAPPER_SUBTYPE_VIRTUAL_STELEMREF:
label = "virt_stelem";
break;
case WRAPPER_SUBTYPE_FAST_MONITOR_ENTER:
label = "fast_mon_enter";
break;
case WRAPPER_SUBTYPE_FAST_MONITOR_ENTER_V4:
label = "fast_mon_enter_4";
break;
case WRAPPER_SUBTYPE_FAST_MONITOR_EXIT:
label = "fast_monitor_exit";
break;
case WRAPPER_SUBTYPE_PTR_TO_STRUCTURE:
label = "ptr2struct";
break;
case WRAPPER_SUBTYPE_STRUCTURE_TO_PTR:
label = "struct2ptr";
break;
case WRAPPER_SUBTYPE_CASTCLASS_WITH_CACHE:
label = "castclass_w_cache";
break;
case WRAPPER_SUBTYPE_ISINST_WITH_CACHE:
label = "isinst_w_cache";
break;
case WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL:
label = "run_inv_norm";
break;
case WRAPPER_SUBTYPE_RUNTIME_INVOKE_DYNAMIC:
label = "run_inv_dyn";
break;
case WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT:
label = "run_inv_dir";
break;
case WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL:
label = "run_inv_vir";
break;
case WRAPPER_SUBTYPE_ICALL_WRAPPER:
label = "icall";
break;
case WRAPPER_SUBTYPE_NATIVE_FUNC_AOT:
label = "native_func_aot";
break;
case WRAPPER_SUBTYPE_PINVOKE:
label = "pinvoke";
break;
case WRAPPER_SUBTYPE_SYNCHRONIZED_INNER:
label = "synch_inner";
break;
case WRAPPER_SUBTYPE_GSHAREDVT_IN:
label = "gshared_in";
break;
case WRAPPER_SUBTYPE_GSHAREDVT_OUT:
label = "gshared_out";
break;
case WRAPPER_SUBTYPE_ARRAY_ACCESSOR:
label = "array_acc";
break;
case WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER:
label = "generic_arry_help";
break;
case WRAPPER_SUBTYPE_DELEGATE_INVOKE_VIRTUAL:
label = "del_inv_virt";
break;
case WRAPPER_SUBTYPE_DELEGATE_INVOKE_BOUND:
label = "del_inv_bound";
break;
case WRAPPER_SUBTYPE_INTERP_IN:
label = "interp_in";
break;
case WRAPPER_SUBTYPE_INTERP_LMF:
label = "interp_lmf";
break;
case WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG:
label = "gsharedvt_in_sig";
break;
case WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG:
label = "gsharedvt_out_sig";
break;
case WRAPPER_SUBTYPE_AOT_INIT:
label = "aot_init";
break;
case WRAPPER_SUBTYPE_LLVM_FUNC:
label = "llvm_func";
break;
default:
g_assert_not_reached ();
}
g_string_append_printf (s, "%s_", label);
}
static char *
sanitize_mangled_string (const char *input)
{
GString *s = g_string_new ("");
for (int i=0; input [i] != '\0'; i++) {
char c = input [i];
switch (c) {
case '.':
g_string_append (s, "_dot_");
break;
case ' ':
g_string_append (s, "_");
break;
case '`':
g_string_append (s, "_bt_");
break;
case '<':
g_string_append (s, "_le_");
break;
case '>':
g_string_append (s, "_gt_");
break;
case '/':
g_string_append (s, "_sl_");
break;
case '[':
g_string_append (s, "_lbrack_");
break;
case ']':
g_string_append (s, "_rbrack_");
break;
case '(':
g_string_append (s, "_lparen_");
break;
case '-':
g_string_append (s, "_dash_");
break;
case ')':
g_string_append (s, "_rparen_");
break;
case ',':
g_string_append (s, "_comma_");
break;
case ':':
g_string_append (s, "_colon_");
break;
case '|':
g_string_append (s, "_verbar_");
break;
default:
g_string_append_c (s, c);
}
}
return g_string_free (s, FALSE);
}
static gboolean
append_mangled_klass (GString *s, MonoClass *klass)
{
char *klass_desc = mono_class_full_name (klass);
g_string_append_printf (s, "_%s_%s_", m_class_get_name_space (klass), klass_desc);
g_free (klass_desc);
// Success
return TRUE;
}
static const char*
get_assembly_prefix (MonoImage *image)
{
if (mono_is_corlib_image (image))
return "corlib";
else if (!strcmp (image->assembly->aname.name, "corlib"))
return "__corlib__";
else
return image->assembly->aname.name;
}
static gboolean
append_mangled_method (GString *s, MonoMethod *method);
static gboolean
append_mangled_wrapper (GString *s, MonoMethod *method)
{
gboolean success = TRUE;
gboolean append_sig = TRUE;
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
gboolean is_corlib = mono_is_corlib_image (m_class_get_image (method->klass));
g_string_append_printf (s, "wrapper_");
/* Most wrappers are in mscorlib */
if (!is_corlib)
g_string_append_printf (s, "%s_", m_class_get_image (method->klass)->assembly->aname.name);
if (method->wrapper_type != MONO_WRAPPER_OTHER && method->wrapper_type != MONO_WRAPPER_MANAGED_TO_NATIVE)
append_mangled_wrapper_type (s, method->wrapper_type);
switch (method->wrapper_type) {
case MONO_WRAPPER_ALLOC: {
/* The GC name is saved once in MonoAotFileInfo */
g_assert (info->d.alloc.alloc_type != -1);
g_string_append_printf (s, "%d_", info->d.alloc.alloc_type);
// SlowAlloc, etc
g_string_append_printf (s, "%s_", method->name);
break;
}
case MONO_WRAPPER_WRITE_BARRIER: {
g_string_append_printf (s, "%s_", method->name);
break;
}
case MONO_WRAPPER_STELEMREF: {
append_mangled_wrapper_subtype (s, info->subtype);
if (info->subtype == WRAPPER_SUBTYPE_VIRTUAL_STELEMREF)
g_string_append_printf (s, "%d", info->d.virtual_stelemref.kind);
else if (info->subtype == WRAPPER_SUBTYPE_LLVM_FUNC)
g_string_append_printf (s, "%d", info->d.llvm_func.subtype);
break;
}
case MONO_WRAPPER_OTHER: {
append_mangled_wrapper_subtype (s, info->subtype);
if (info->subtype == WRAPPER_SUBTYPE_PTR_TO_STRUCTURE ||
info->subtype == WRAPPER_SUBTYPE_STRUCTURE_TO_PTR)
success = success && append_mangled_klass (s, method->klass);
else if (info->subtype == WRAPPER_SUBTYPE_SYNCHRONIZED_INNER)
success = success && append_mangled_method (s, info->d.synchronized_inner.method);
else if (info->subtype == WRAPPER_SUBTYPE_ARRAY_ACCESSOR)
success = success && append_mangled_method (s, info->d.array_accessor.method);
else if (info->subtype == WRAPPER_SUBTYPE_INTERP_IN)
append_mangled_signature (s, info->d.interp_in.sig);
else if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_IN_SIG) {
append_mangled_signature (s, info->d.gsharedvt.sig);
append_sig = FALSE;
} else if (info->subtype == WRAPPER_SUBTYPE_GSHAREDVT_OUT_SIG) {
append_mangled_signature (s, info->d.gsharedvt.sig);
append_sig = FALSE;
} else if (info->subtype == WRAPPER_SUBTYPE_INTERP_LMF)
g_string_append_printf (s, "%s", method->name);
else if (info->subtype == WRAPPER_SUBTYPE_AOT_INIT) {
g_string_append_printf (s, "%s_%d_", get_assembly_prefix (m_class_get_image (method->klass)), info->d.aot_init.subtype);
append_sig = FALSE;
}
break;
}
case MONO_WRAPPER_MANAGED_TO_NATIVE: {
append_mangled_wrapper_subtype (s, info->subtype);
if (info->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER) {
const char *name = method->name;
const char *prefix = "__icall_wrapper_";
if (strstr (name, prefix) == name)
name += strlen (prefix);
g_string_append_printf (s, "%s", name);
append_sig = FALSE;
} else if (info->subtype == WRAPPER_SUBTYPE_NATIVE_FUNC_AOT) {
success = success && append_mangled_method (s, info->d.managed_to_native.method);
} else {
g_assert (info->subtype == WRAPPER_SUBTYPE_NONE || info->subtype == WRAPPER_SUBTYPE_PINVOKE);
success = success && append_mangled_method (s, info->d.managed_to_native.method);
}
break;
}
case MONO_WRAPPER_SYNCHRONIZED: {
MonoMethod *m;
m = mono_marshal_method_from_wrapper (method);
g_assert (m);
g_assert (m != method);
success = success && append_mangled_method (s, m);
break;
}
case MONO_WRAPPER_MANAGED_TO_MANAGED: {
append_mangled_wrapper_subtype (s, info->subtype);
if (info->subtype == WRAPPER_SUBTYPE_ELEMENT_ADDR) {
g_string_append_printf (s, "%d_", info->d.element_addr.rank);
g_string_append_printf (s, "%d_", info->d.element_addr.elem_size);
} else if (info->subtype == WRAPPER_SUBTYPE_STRING_CTOR) {
success = success && append_mangled_method (s, info->d.string_ctor.method);
} else if (info->subtype == WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER) {
success = success && append_mangled_method (s, info->d.generic_array_helper.method);
} else {
success = FALSE;
}
break;
}
case MONO_WRAPPER_CASTCLASS: {
append_mangled_wrapper_subtype (s, info->subtype);
break;
}
case MONO_WRAPPER_RUNTIME_INVOKE: {
append_mangled_wrapper_subtype (s, info->subtype);
if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_DIRECT || info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_VIRTUAL)
success = success && append_mangled_method (s, info->d.runtime_invoke.method);
else if (info->subtype == WRAPPER_SUBTYPE_RUNTIME_INVOKE_NORMAL)
success = success && append_mangled_signature (s, info->d.runtime_invoke.sig);
break;
}
case MONO_WRAPPER_DELEGATE_INVOKE:
case MONO_WRAPPER_DELEGATE_BEGIN_INVOKE:
case MONO_WRAPPER_DELEGATE_END_INVOKE: {
if (method->is_inflated) {
/* These wrappers are identified by their class */
g_string_append_printf (s, "i_");
success = success && append_mangled_klass (s, method->klass);
} else {
WrapperInfo *info = mono_marshal_get_wrapper_info (method);
g_string_append_printf (s, "u_");
if (method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE)
append_mangled_wrapper_subtype (s, info->subtype);
g_string_append_printf (s, "u_sigstart");
}
break;
}
case MONO_WRAPPER_NATIVE_TO_MANAGED: {
g_assert (info);
success = success && append_mangled_method (s, info->d.native_to_managed.method);
success = success && append_mangled_klass (s, method->klass);
break;
}
default:
g_assert_not_reached ();
}
if (success && append_sig)
success = append_mangled_signature (s, mono_method_signature_internal (method));
return success;
}
static void
append_mangled_ginst (GString *str, MonoGenericInst *ginst)
{
int i;
for (i = 0; i < ginst->type_argc; ++i) {
if (i > 0)
g_string_append (str, ", ");
MonoType *type = ginst->type_argv [i];
switch (type->type) {
case MONO_TYPE_VAR:
case MONO_TYPE_MVAR: {
MonoType *constraint = NULL;
if (type->data.generic_param)
constraint = type->data.generic_param->gshared_constraint;
if (constraint) {
g_assert (constraint->type != MONO_TYPE_VAR && constraint->type != MONO_TYPE_MVAR);
g_string_append (str, "gshared:");
mono_type_get_desc (str, constraint, TRUE);
break;
}
// Else falls through to common case
}
default:
mono_type_get_desc (str, type, TRUE);
}
}
}
static void
append_mangled_context (GString *str, MonoGenericContext *context)
{
GString *res = g_string_new ("");
g_string_append_printf (res, "gens_");
g_string_append (res, "00");
gboolean good = context->class_inst && context->class_inst->type_argc > 0;
good = good || (context->method_inst && context->method_inst->type_argc > 0);
g_assert (good);
if (context->class_inst)
append_mangled_ginst (res, context->class_inst);
if (context->method_inst) {
if (context->class_inst)
g_string_append (res, "11");
append_mangled_ginst (res, context->method_inst);
}
g_string_append_printf (str, "gens_%s", res->str);
g_free (res);
}
static gboolean
append_mangled_method (GString *s, MonoMethod *method)
{
if (method->wrapper_type)
return append_mangled_wrapper (s, method);
if (method->is_inflated) {
g_string_append_printf (s, "inflated_");
MonoMethodInflated *imethod = (MonoMethodInflated*) method;
g_assert (imethod->context.class_inst != NULL || imethod->context.method_inst != NULL);
append_mangled_context (s, &imethod->context);
g_string_append_printf (s, "_declared_by_%s_", get_assembly_prefix (m_class_get_image (imethod->declaring->klass)));
append_mangled_method (s, imethod->declaring);
} else if (method->is_generic) {
g_string_append_printf (s, "%s_", get_assembly_prefix (m_class_get_image (method->klass)));
g_string_append_printf (s, "generic_");
append_mangled_klass (s, method->klass);
g_string_append_printf (s, "_%s_", method->name);
MonoGenericContainer *container = mono_method_get_generic_container (method);
g_string_append_printf (s, "_");
append_mangled_context (s, &container->context);
return append_mangled_signature (s, mono_method_signature_internal (method));
} else {
g_string_append_printf (s, "%s", get_assembly_prefix (m_class_get_image (method->klass)));
append_mangled_klass (s, method->klass);
g_string_append_printf (s, "_%s_", method->name);
if (!append_mangled_signature (s, mono_method_signature_internal (method))) {
g_string_free (s, TRUE);
return FALSE;
}
}
return TRUE;
}
/*
* mono_aot_get_mangled_method_name:
*
* Return a unique mangled name for METHOD, or NULL.
*/
char*
mono_aot_get_mangled_method_name (MonoMethod *method)
{
// FIXME: use static cache (mempool?)
// We call this a *lot*
GString *s = g_string_new ("aot_");
if (!append_mangled_method (s, method)) {
g_string_free (s, TRUE);
return NULL;
} else {
char *out = g_string_free (s, FALSE);
// Scrub method and class names
char *cleaned = sanitize_mangled_string (out);
g_free (out);
return cleaned;
}
}
gboolean
mono_aot_is_direct_callable (MonoJumpInfo *patch_info)
{
return is_direct_callable (llvm_acfg, NULL, patch_info);
}
void
mono_aot_mark_unused_llvm_plt_entry (MonoJumpInfo *patch_info)
{
MonoPltEntry *plt_entry;
plt_entry = get_plt_entry (llvm_acfg, patch_info);
plt_entry->llvm_used = FALSE;
}
char*
mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data)
{
const char *sym = NULL;
if (llvm_acfg->aot_opts.direct_icalls) {
if (type == MONO_PATCH_INFO_JIT_ICALL_ADDR) {
/* Call to a C function implementing a jit icall */
sym = mono_find_jit_icall_info ((MonoJitICallId)(gsize)data)->c_symbol;
} else if (type == MONO_PATCH_INFO_ICALL_ADDR_CALL) {
MonoMethod *method = (MonoMethod *)data;
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
sym = lookup_icall_symbol_name_aot (method);
else if (llvm_acfg->aot_opts.direct_pinvoke)
sym = get_pinvoke_import (llvm_acfg, method);
} else if (type == MONO_PATCH_INFO_JIT_ICALL_ID) {
MonoJitICallInfo const * const info = mono_find_jit_icall_info ((MonoJitICallId)(gsize)data);
char const * const name = info->c_symbol;
if (name && info->func == info->wrapper)
sym = name;
}
if (sym)
return g_strdup (sym);
}
return NULL;
}
char*
mono_aot_get_plt_symbol (MonoJumpInfoType type, gconstpointer data)
{
MonoJumpInfo *ji = (MonoJumpInfo *)mono_mempool_alloc (llvm_acfg->mempool, sizeof (MonoJumpInfo));
MonoPltEntry *plt_entry;
const char *sym = NULL;
ji->type = type;
ji->data.target = data;
if (!can_encode_patch (llvm_acfg, ji))
return NULL;
if (llvm_acfg->aot_opts.direct_icalls) {
if (type == MONO_PATCH_INFO_JIT_ICALL_ADDR) {
/* Call to a C function implementing a jit icall */
sym = mono_find_jit_icall_info ((MonoJitICallId)(gsize)data)->c_symbol;
} else if (type == MONO_PATCH_INFO_ICALL_ADDR_CALL) {
MonoMethod *method = (MonoMethod *)data;
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
sym = lookup_icall_symbol_name_aot (method);
}
if (sym)
return g_strdup (sym);
}
plt_entry = get_plt_entry (llvm_acfg, ji);
plt_entry->llvm_used = TRUE;
#if defined(TARGET_MACH)
return g_strdup (plt_entry->llvm_symbol + strlen (llvm_acfg->llvm_label_prefix));
#else
return g_strdup (plt_entry->llvm_symbol);
#endif
}
int
mono_aot_get_method_index (MonoMethod *method)
{
g_assert (llvm_acfg);
return get_method_index (llvm_acfg, method);
}
MonoJumpInfo*
mono_aot_patch_info_dup (MonoJumpInfo* ji)
{
MonoJumpInfo *res;
mono_acfg_lock (llvm_acfg);
res = mono_patch_info_dup_mp (llvm_acfg->mempool, ji);
mono_acfg_unlock (llvm_acfg);
return res;
}
static int
execute_system (const char * command)
{
int status = 0;
#if defined (HOST_WIN32)
// We need an extra set of quotes around the whole command to properly handle commands
// with spaces since internally the command is called through "cmd /c.
char * quoted_command = g_strdup_printf ("\"%s\"", command);
int size = MultiByteToWideChar (CP_UTF8, 0 , quoted_command , -1, NULL , 0);
wchar_t* wstr = g_malloc (sizeof (wchar_t) * size);
MultiByteToWideChar (CP_UTF8, 0, quoted_command, -1, wstr , size);
status = _wsystem (wstr);
g_free (wstr);
g_free (quoted_command);
#elif defined (HAVE_SYSTEM)
status = system (command);
#else
g_assert_not_reached ();
#endif
return status;
}
#ifdef ENABLE_LLVM
/*
* emit_llvm_file:
*
* Emit the LLVM code into an LLVM bytecode file, and compile it using the LLVM
* tools.
*/
static gboolean
emit_llvm_file (MonoAotCompile *acfg)
{
char *command, *opts, *tempbc, *optbc, *output_fname;
if (acfg->aot_opts.llvm_only && acfg->aot_opts.asm_only) {
if (acfg->aot_opts.no_opt)
tempbc = g_strdup (acfg->aot_opts.llvm_outfile);
else
tempbc = g_strdup_printf ("%s.bc", acfg->tmpbasename);
optbc = g_strdup (acfg->aot_opts.llvm_outfile);
} else {
tempbc = g_strdup_printf ("%s.bc", acfg->tmpbasename);
optbc = g_strdup_printf ("%s.opt.bc", acfg->tmpbasename);
}
mono_llvm_emit_aot_module (tempbc, g_path_get_basename (acfg->image->name));
if (acfg->aot_opts.no_opt)
return TRUE;
/*
* FIXME: Experiment with adding optimizations, the -std-compile-opts set takes
* a lot of time, and doesn't seem to save much space.
* The following optimizations cannot be enabled:
* - 'tailcallelim'
* - 'jump-threading' changes our blockaddress references to int constants.
* - 'basiccg' fails because it contains:
* if (CS && !isa<IntrinsicInst>(II)) {
* and isa<IntrinsicInst> is false for invokes to intrinsics (iltests.exe).
* - 'prune-eh' and 'functionattrs' depend on 'basiccg'.
* The opt list below was produced by taking the output of:
* llvm-as < /dev/null | opt -O2 -disable-output -debug-pass=Arguments
* then removing tailcallelim + the global opts.
* strip-dead-prototypes deletes unused intrinsics definitions.
*/
/* The dse pass is disabled because of #13734 and #17616 */
/*
* The dse bug is in DeadStoreElimination.cpp:isOverwrite ():
* // If we have no DataLayout information around, then the size of the store
* // is inferrable from the pointee type. If they are the same type, then
* // we know that the store is safe.
* if (AA.getDataLayout() == 0 &&
* Later.Ptr->getType() == Earlier.Ptr->getType()) {
* return OverwriteComplete;
* Here, if 'Earlier' refers to a memset, and Later has no size info, it mistakenly thinks the memset is redundant.
*/
if (acfg->aot_opts.llvm_only) {
// FIXME: This doesn't work yet
opts = g_strdup ("");
} else {
opts = g_strdup ("-disable-tail-calls -place-safepoints -spp-all-backedges");
}
if (acfg->aot_opts.llvm_opts) {
opts = g_strdup_printf ("%s %s", acfg->aot_opts.llvm_opts, opts);
} else if (!acfg->aot_opts.llvm_only) {
opts = g_strdup_printf ("-O2 %s", opts);
}
if (acfg->aot_opts.use_current_cpu) {
opts = g_strdup_printf ("%s -mcpu=native", opts);
}
if (acfg->aot_opts.llvm_cpu_attr) {
opts = g_strdup_printf ("%s -mattr=%s", opts, acfg->aot_opts.llvm_cpu_attr);
}
if (mono_use_fast_math) {
// same parameters are passed to llc and LLVM JIT
opts = g_strdup_printf ("%s -fp-contract=fast -enable-no-infs-fp-math -enable-no-nans-fp-math -enable-no-signed-zeros-fp-math -enable-no-trapping-fp-math -enable-unsafe-fp-math", opts);
}
command = g_strdup_printf ("\"%sopt\" -f %s -o \"%s\" \"%s\"", acfg->aot_opts.llvm_path, opts, optbc, tempbc);
aot_printf (acfg, "Executing opt: %s\n", command);
if (execute_system (command) != 0)
return FALSE;
g_free (opts);
if (acfg->aot_opts.llvm_only && acfg->aot_opts.asm_only)
/* Nothing else to do */
return TRUE;
if (acfg->aot_opts.llvm_only) {
/* Use the stock clang from xcode */
// FIXME: arch
command = g_strdup_printf ("%s -fexceptions -fpic -O2 -fno-optimize-sibling-calls -Wno-override-module -c -o \"%s\" \"%s.opt.bc\"", acfg->aot_opts.clangxx, acfg->llvm_ofile, acfg->tmpbasename);
aot_printf (acfg, "Executing clang: %s\n", command);
if (execute_system (command) != 0)
return FALSE;
return TRUE;
}
if (!acfg->llc_args)
acfg->llc_args = g_string_new ("");
/* Verbose asm slows down llc greatly */
g_string_append (acfg->llc_args, " -asm-verbose=false");
if (acfg->aot_opts.mtriple)
g_string_append_printf (acfg->llc_args, " -mtriple=%s", acfg->aot_opts.mtriple);
#if defined(TARGET_X86_64_WIN32_MSVC)
if (!acfg->aot_opts.mtriple)
g_string_append_printf (acfg->llc_args, " -mtriple=%s", "x86_64-pc-windows-msvc");
#endif
g_string_append (acfg->llc_args, " -disable-gnu-eh-frame -enable-mono-eh-frame");
g_string_append_printf (acfg->llc_args, " -mono-eh-frame-symbol=%s%s", acfg->user_symbol_prefix, acfg->llvm_eh_frame_symbol);
g_string_append_printf (acfg->llc_args, " -disable-tail-calls");
#if defined(TARGET_AMD64) || defined(TARGET_X86)
/* This generates stack adjustments in the middle of functions breaking unwind info */
g_string_append_printf (acfg->llc_args, " -no-x86-call-frame-opt");
#endif
#if ( defined(TARGET_MACH) && defined(TARGET_ARM) ) || defined(TARGET_ORBIS) || defined(TARGET_X86_64_WIN32_MSVC) || defined(TARGET_ANDROID)
g_string_append_printf (acfg->llc_args, " -relocation-model=pic");
#else
if (llvm_acfg->aot_opts.static_link)
g_string_append_printf (acfg->llc_args, " -relocation-model=static");
else
g_string_append_printf (acfg->llc_args, " -relocation-model=pic");
#endif
if (acfg->llvm_owriter) {
/* Emit an object file directly */
output_fname = g_strdup_printf ("%s", acfg->llvm_ofile);
g_string_append_printf (acfg->llc_args, " -filetype=obj");
} else {
output_fname = g_strdup_printf ("%s", acfg->llvm_sfile);
}
if (acfg->aot_opts.llvm_llc) {
g_string_append_printf (acfg->llc_args, " %s", acfg->aot_opts.llvm_llc);
}
if (acfg->aot_opts.use_current_cpu) {
g_string_append (acfg->llc_args, " -mcpu=native");
}
if (acfg->aot_opts.llvm_cpu_attr) {
g_string_append_printf (acfg->llc_args, " -mattr=%s", acfg->aot_opts.llvm_cpu_attr);
}
command = g_strdup_printf ("\"%sllc\" %s -o \"%s\" \"%s.opt.bc\"", acfg->aot_opts.llvm_path, acfg->llc_args->str, output_fname, acfg->tmpbasename);
g_free (output_fname);
aot_printf (acfg, "Executing llc: %s\n", command);
if (execute_system (command) != 0)
return FALSE;
return TRUE;
}
#endif
/* Set the skip flag for methods which do not need to be emitted because of dedup */
static void
dedup_skip_methods (MonoAotCompile *acfg)
{
int oindex, i;
if (acfg->aot_opts.llvm_only)
return;
for (oindex = 0; oindex < acfg->method_order->len; ++oindex) {
MonoCompile *cfg;
MonoMethod *method;
i = GPOINTER_TO_UINT (g_ptr_array_index (acfg->method_order, oindex));
cfg = acfg->cfgs [i];
if (!cfg)
continue;
method = cfg->orig_method;
gboolean dedup_collect = acfg->aot_opts.dedup || (acfg->aot_opts.dedup_include && !acfg->dedup_emit_mode);
gboolean dedupable = mono_aot_can_dedup (method);
// cfg->skip is vital for LLVM to work, can't just continue in this loop
if (dedupable && strcmp (method->name, "wbarrier_conc") && dedup_collect) {
mono_dedup_cache_method (acfg, method);
// Don't compile inflated methods if we're in first phase of
// dedup
//
// In second phase, we emit methods that
// are dedupable. We also emit later methods
// which are referenced by them and added later.
// For this reason, when in the dedup_include mode,
// we never set skip.
if (acfg->aot_opts.dedup)
cfg->skip = TRUE;
}
// Don't compile anything in this mode
if (acfg->aot_opts.dedup_include && !acfg->dedup_emit_mode)
cfg->skip = TRUE;
// Compile everything in this mode
if (acfg->aot_opts.dedup_include && acfg->dedup_emit_mode)
cfg->skip = FALSE;
/*if (dedup_collect) {*/
/*char *name = mono_aot_get_mangled_method_name (method);*/
/*if (ignore_cfg (cfg))*/
/*aot_printf (acfg, "Dedup Skipping %s\n", acfg->image->name, name);*/
/*else*/
/*aot_printf (acfg, "Dedup Keeping %s\n", acfg->image->name, name);*/
/*g_free (name);*/
/*}*/
}
}
static void
emit_code (MonoAotCompile *acfg)
{
int oindex, i, prev_index;
gboolean saved_unbox_info = FALSE; // See mono_aot_get_unbox_trampoline.
char symbol [MAX_SYMBOL_SIZE];
if (acfg->aot_opts.llvm_only)
return;
#if defined(TARGET_POWERPC64)
sprintf (symbol, ".Lgot_addr");
emit_section_change (acfg, ".text", 0);
emit_alignment (acfg, 8);
emit_label (acfg, symbol);
emit_pointer (acfg, acfg->got_symbol);
#endif
/*
* This global symbol is used to compute the address of each method using the
* code_offsets array. It is also used to compute the memory ranges occupied by
* AOT code, so it must be equal to the address of the first emitted method.
*/
emit_section_change (acfg, ".text", 0);
emit_alignment_code (acfg, 8);
emit_info_symbol (acfg, "jit_code_start", TRUE);
/*
* Emit some padding so the local symbol for the first method doesn't have the
* same address as 'methods'.
*/
emit_padding (acfg, 16);
for (oindex = 0; oindex < acfg->method_order->len; ++oindex) {
MonoCompile *cfg;
MonoMethod *method;
i = GPOINTER_TO_UINT (g_ptr_array_index (acfg->method_order, oindex));
cfg = acfg->cfgs [i];
if (!cfg)
continue;
method = cfg->orig_method;
if (ignore_cfg (cfg))
continue;
/* Emit unbox trampoline */
if (mono_aot_mode_is_full (&acfg->aot_opts) && m_class_is_valuetype (cfg->orig_method->klass)) {
sprintf (symbol, "ut_%d", get_method_index (acfg, method));
emit_section_change (acfg, ".text", 0);
if (acfg->thumb_mixed && cfg->compile_llvm) {
emit_set_thumb_mode (acfg);
fprintf (acfg->fp, "\n.thumb_func\n");
}
emit_label (acfg, symbol);
arch_emit_unbox_trampoline (acfg, cfg, cfg->orig_method, cfg->asm_symbol);
if (acfg->thumb_mixed && cfg->compile_llvm)
emit_set_arm_mode (acfg);
if (!saved_unbox_info) {
char user_symbol [128];
GSList *unwind_ops;
sprintf (user_symbol, "%sunbox_trampoline_p", acfg->user_symbol_prefix);
emit_label (acfg, "ut_end");
unwind_ops = mono_unwind_get_cie_program ();
save_unwind_info (acfg, user_symbol, unwind_ops);
mono_free_unwind_info (unwind_ops);
/* Save the unbox trampoline size */
#ifdef TARGET_AMD64
// LLVM unbox trampolines vary in size, 6 or 9 bytes,
// due to the last instruction being 2 or 5 bytes.
// There is no need to describe interior bytes of instructions
// however, so state the size as if the last instruction is size 1.
emit_int32 (acfg, 5);
#else
emit_symbol_diff (acfg, "ut_end", symbol, 0);
#endif
saved_unbox_info = TRUE;
}
}
if (cfg->compile_llvm) {
acfg->stats.llvm_count ++;
} else {
emit_method_code (acfg, cfg);
}
}
emit_section_change (acfg, ".text", 0);
emit_alignment_code (acfg, 8);
emit_info_symbol (acfg, "jit_code_end", TRUE);
/* To distinguish it from the next symbol */
emit_padding (acfg, 4);
/*
* Add .no_dead_strip directives for all LLVM methods to prevent the OSX linker
* from optimizing them away, since it doesn't see that code_offsets references them.
* JITted methods don't need this since they are referenced using assembler local
* symbols.
* FIXME: This is why write-symbols doesn't work on OSX ?
*/
if (acfg->llvm && acfg->need_no_dead_strip) {
fprintf (acfg->fp, "\n");
for (i = 0; i < acfg->nmethods; ++i) {
if (acfg->cfgs [i] && acfg->cfgs [i]->compile_llvm)
fprintf (acfg->fp, ".no_dead_strip %s\n", acfg->cfgs [i]->asm_symbol);
}
}
/*
* To work around linker issues, we emit a table of branches, and disassemble them at runtime.
* This is PIE code, and the linker can update it if needed.
*/
#if defined(TARGET_ANDROID) || defined(__linux__)
gboolean is_func = FALSE;
#else
gboolean is_func = TRUE;
#endif
sprintf (symbol, "method_addresses");
if (acfg->flags & MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY) {
/* Emit the method address table as a table of pointers */
emit_section_change (acfg, ".data", 0);
} else {
emit_section_change (acfg, RODATA_REL_SECT, !!is_func);
}
emit_alignment_code (acfg, 8);
emit_info_symbol (acfg, symbol, is_func);
if (acfg->aot_opts.write_symbols)
emit_local_symbol (acfg, symbol, "method_addresses_end", is_func);
emit_unset_mode (acfg);
if (acfg->need_no_dead_strip)
fprintf (acfg->fp, " .no_dead_strip %s\n", symbol);
for (i = 0; i < acfg->nmethods; ++i) {
#ifdef MONO_ARCH_AOT_SUPPORTED
if (acfg->flags & MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY) {
if (!ignore_cfg (acfg->cfgs [i]))
emit_pointer (acfg, acfg->cfgs [i]->asm_symbol);
else
emit_pointer (acfg, NULL);
} else {
if (!ignore_cfg (acfg->cfgs [i])) {
arch_emit_label_address (acfg, acfg->cfgs [i]->asm_symbol, FALSE, acfg->thumb_mixed && acfg->cfgs [i]->compile_llvm, NULL, &acfg->call_table_entry_size);
} else {
arch_emit_label_address (acfg, symbol, FALSE, FALSE, NULL, &acfg->call_table_entry_size);
}
}
#endif
}
sprintf (symbol, "method_addresses_end");
emit_label (acfg, symbol);
emit_line (acfg);
/* Emit a sorted table mapping methods to the index of their unbox trampolines */
sprintf (symbol, "unbox_trampolines");
emit_section_change (acfg, RODATA_SECT, 0);
emit_alignment (acfg, 8);
emit_info_symbol (acfg, symbol, FALSE);
prev_index = -1;
for (i = 0; i < acfg->nmethods; ++i) {
MonoCompile *cfg;
MonoMethod *method;
int index;
cfg = acfg->cfgs [i];
if (ignore_cfg (cfg))
continue;
method = cfg->orig_method;
if (mono_aot_mode_is_full (&acfg->aot_opts) && m_class_is_valuetype (cfg->orig_method->klass)) {
index = get_method_index (acfg, method);
emit_int32 (acfg, index);
/* Make sure the table is sorted by index */
g_assert (index > prev_index);
prev_index = index;
}
}
sprintf (symbol, "unbox_trampolines_end");
emit_info_symbol (acfg, symbol, FALSE);
emit_int32 (acfg, 0);
/* Emit a separate table with the trampoline addresses/offsets */
sprintf (symbol, "unbox_trampoline_addresses");
if (acfg->flags & MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY) {
/* Emit the unbox trampoline address table as a table of pointers */
emit_section_change (acfg, ".data", 0);
} else {
emit_section_change (acfg, ".text", 0);
}
emit_alignment_code (acfg, 8);
emit_info_symbol (acfg, symbol, TRUE);
for (i = 0; i < acfg->nmethods; ++i) {
MonoCompile *cfg;
MonoMethod *method;
cfg = acfg->cfgs [i];
if (ignore_cfg (cfg))
continue;
method = cfg->orig_method;
(void)method;
if (mono_aot_mode_is_full (&acfg->aot_opts) && m_class_is_valuetype (cfg->orig_method->klass)) {
#ifdef MONO_ARCH_AOT_SUPPORTED
const int index = get_method_index (acfg, method);
sprintf (symbol, "ut_%d", index);
if (acfg->flags & MONO_AOT_FILE_FLAG_CODE_EXEC_ONLY) {
emit_pointer (acfg, symbol);
} else {
int call_size;
arch_emit_direct_call (acfg, symbol, FALSE, acfg->thumb_mixed && cfg->compile_llvm, NULL, &call_size);
}
#endif
}
}
emit_int32 (acfg, 0);
}
static void
emit_method_info_table (MonoAotCompile *acfg)
{
int oindex, i;
gint32 *offsets;
guint8 *method_flags;
offsets = g_new0 (gint32, acfg->nmethods);
for (oindex = 0; oindex < acfg->method_order->len; ++oindex) {
i = GPOINTER_TO_UINT (g_ptr_array_index (acfg->method_order, oindex));
if (acfg->cfgs [i]) {
emit_method_info (acfg, acfg->cfgs [i]);
offsets [i] = acfg->cfgs [i]->method_info_offset;
} else {
offsets [i] = 0;
}
}
acfg->stats.offsets_size += emit_offset_table (acfg, "method_info_offsets", MONO_AOT_TABLE_METHOD_INFO_OFFSETS, acfg->nmethods, 10, offsets);
g_free (offsets);
/* Emit a separate table for method flags, its needed at runtime */
method_flags = g_new0 (guint8, acfg->nmethods);
for (i = 0; i < acfg->nmethods; ++i) {
if (acfg->cfgs [i])
method_flags [acfg->cfgs [i]->method_index] = acfg->cfgs [i]->aot_method_flags;
}
emit_aot_data (acfg, MONO_AOT_TABLE_METHOD_FLAGS_TABLE, "method_flags_table", method_flags, acfg->nmethods);
}
#endif /* #if !defined(DISABLE_AOT) && !defined(DISABLE_JIT) */
#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
#define mix(a,b,c) { \
a -= c; a ^= rot(c, 4); c += b; \
b -= a; b ^= rot(a, 6); a += c; \
c -= b; c ^= rot(b, 8); b += a; \
a -= c; a ^= rot(c,16); c += b; \
b -= a; b ^= rot(a,19); a += c; \
c -= b; c ^= rot(b, 4); b += a; \
}
#define mono_final(a,b,c) { \
c ^= b; c -= rot(b,14); \
a ^= c; a -= rot(c,11); \
b ^= a; b -= rot(a,25); \
c ^= b; c -= rot(b,16); \
a ^= c; a -= rot(c,4); \
b ^= a; b -= rot(a,14); \
c ^= b; c -= rot(b,24); \
}
static guint
mono_aot_type_hash (MonoType *t1)
{
guint hash = t1->type;
hash |= t1->byref << 6; /* do not collide with t1->type values */
switch (t1->type) {
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_CLASS:
case MONO_TYPE_SZARRAY:
/* check if the distribution is good enough */
return ((hash << 5) - hash) ^ mono_metadata_str_hash (m_class_get_name (t1->data.klass));
case MONO_TYPE_PTR:
return ((hash << 5) - hash) ^ mono_metadata_type_hash (t1->data.type);
case MONO_TYPE_ARRAY:
return ((hash << 5) - hash) ^ mono_metadata_type_hash (m_class_get_byval_arg (t1->data.array->eklass));
case MONO_TYPE_GENERICINST:
return ((hash << 5) - hash) ^ 0;
default:
return hash;
}
}
/*
* mono_aot_method_hash:
*
* Return a hash code for methods which only depends on metadata.
*/
guint32
mono_aot_method_hash (MonoMethod *method)
{
MonoMethodSignature *sig;
MonoClass *klass;
int i, hindex;
int hashes_count;
guint32 *hashes_start, *hashes;
guint32 a, b, c;
MonoGenericInst *class_ginst = NULL;
MonoGenericInst *ginst = NULL;
/* Similar to the hash in mono_method_get_imt_slot () */
sig = mono_method_signature_internal (method);
if (mono_class_is_ginst (method->klass))
class_ginst = mono_class_get_generic_class (method->klass)->context.class_inst;
if (method->is_inflated)
ginst = ((MonoMethodInflated*)method)->context.method_inst;
hashes_count = sig->param_count + 5 + (class_ginst ? class_ginst->type_argc : 0) + (ginst ? ginst->type_argc : 0);
hashes_start = (guint32 *)g_malloc0 (hashes_count * sizeof (guint32));
hashes = hashes_start;
/* Some wrappers are assigned to random classes */
if (!method->wrapper_type)
klass = method->klass;
else
klass = mono_defaults.object_class;
if (!method->wrapper_type) {
char *full_name;
if (mono_class_is_ginst (klass))
full_name = mono_type_full_name (m_class_get_byval_arg (mono_class_get_generic_class (klass)->container_class));
else
full_name = mono_type_full_name (m_class_get_byval_arg (klass));
hashes [0] = mono_metadata_str_hash (full_name);
hashes [1] = 0;
g_free (full_name);
} else {
hashes [0] = mono_metadata_str_hash (m_class_get_name (klass));
hashes [1] = mono_metadata_str_hash (m_class_get_name_space (klass));
}
if (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE && mono_marshal_get_wrapper_info (method)->subtype == WRAPPER_SUBTYPE_ICALL_WRAPPER)
/* The name might not be set correctly if DISABLE_JIT is set */
hashes [2] = mono_marshal_get_wrapper_info (method)->d.icall.jit_icall_id;
else
hashes [2] = mono_metadata_str_hash (method->name);
hashes [3] = method->wrapper_type;
hashes [4] = mono_aot_type_hash (sig->ret);
hindex = 5;
for (i = 0; i < sig->param_count; i++) {
hashes [hindex ++] = mono_aot_type_hash (sig->params [i]);
}
if (class_ginst) {
for (i = 0; i < class_ginst->type_argc; ++i)
hashes [hindex ++] = mono_aot_type_hash (class_ginst->type_argv [i]);
}
if (ginst) {
for (i = 0; i < ginst->type_argc; ++i)
hashes [hindex ++] = mono_aot_type_hash (ginst->type_argv [i]);
}
g_assert (hindex == hashes_count);
/* Setup internal state */
a = b = c = 0xdeadbeef + (((guint32)hashes_count)<<2);
/* Handle most of the hashes */
while (hashes_count > 3) {
a += hashes [0];
b += hashes [1];
c += hashes [2];
mix (a,b,c);
hashes_count -= 3;
hashes += 3;
}
/* Handle the last 3 hashes (all the case statements fall through) */
switch (hashes_count) {
case 3 : c += hashes [2];
case 2 : b += hashes [1];
case 1 : a += hashes [0];
mono_final (a,b,c);
case 0: /* nothing left to add */
break;
}
g_free (hashes_start);
return c;
}
#undef rot
#undef mix
#undef mono_final
/*
* mono_aot_get_array_helper_from_wrapper;
*
* Get the helper method in Array called by an array wrapper method.
*/
MonoMethod*
mono_aot_get_array_helper_from_wrapper (MonoMethod *method)
{
MonoMethod *m;
const char *prefix;
MonoGenericContext ctx;
char *mname, *iname, *s, *s2, *helper_name = NULL;
prefix = "System.Collections.Generic";
s = g_strdup_printf ("%s", method->name + strlen (prefix) + 1);
s2 = strstr (s, "`1.");
g_assert (s2);
s2 [0] = '\0';
iname = s;
mname = s2 + 3;
//printf ("X: %s %s\n", iname, mname);
if (!strcmp (iname, "IList"))
helper_name = g_strdup_printf ("InternalArray__%s", mname);
else
helper_name = g_strdup_printf ("InternalArray__%s_%s", iname, mname);
m = get_method_nofail (mono_defaults.array_class, helper_name, mono_method_signature_internal (method)->param_count, 0);
g_assert (m);
g_free (helper_name);
g_free (s);
if (m->is_generic) {
ERROR_DECL (error);
memset (&ctx, 0, sizeof (ctx));
MonoType *args [ ] = { m_class_get_byval_arg (m_class_get_element_class (method->klass)) };
ctx.method_inst = mono_metadata_get_generic_inst (1, args);
m = mono_class_inflate_generic_method_checked (m, &ctx, error);
g_assert (is_ok (error)); /* FIXME don't swallow the error */
}
return m;
}
#if !defined(DISABLE_AOT) && !defined(DISABLE_JIT)
typedef struct HashEntry {
guint32 key, value, index;
struct HashEntry *next;
} HashEntry;
/*
* emit_extra_methods:
*
* Emit methods which are not in the METHOD table, like wrappers.
*/
static void
emit_extra_methods (MonoAotCompile *acfg)
{
int i, table_size, buf_size;
guint8 *p, *buf;
guint32 *info_offsets;
guint32 hash;
GPtrArray *table;
HashEntry *entry, *new_entry;
int nmethods, max_chain_length;
int *chain_lengths;
info_offsets = g_new0 (guint32, acfg->extra_methods->len);
/* Emit method info */
nmethods = 0;
for (i = 0; i < acfg->extra_methods->len; ++i) {
MonoMethod *method = (MonoMethod *)g_ptr_array_index (acfg->extra_methods, i);
MonoCompile *cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, method);
if (ignore_cfg (cfg))
continue;
buf_size = 10240;
p = buf = (guint8 *)g_malloc (buf_size);
nmethods ++;
method = cfg->method_to_register;
encode_method_ref (acfg, method, p, &p);
g_assert ((p - buf) < buf_size);
info_offsets [i] = add_to_blob (acfg, buf, p - buf);
g_free (buf);
}
/*
* Construct a chained hash table for mapping indexes in extra_method_info to
* method indexes.
*/
table_size = g_spaced_primes_closest ((int)(nmethods * 1.5));
table = g_ptr_array_sized_new (table_size);
for (i = 0; i < table_size; ++i)
g_ptr_array_add (table, NULL);
chain_lengths = g_new0 (int, table_size);
max_chain_length = 0;
for (i = 0; i < acfg->extra_methods->len; ++i) {
MonoMethod *method = (MonoMethod *)g_ptr_array_index (acfg->extra_methods, i);
MonoCompile *cfg = (MonoCompile *)g_hash_table_lookup (acfg->method_to_cfg, method);
guint32 key, value;
if (ignore_cfg (cfg))
continue;
key = info_offsets [i];
value = get_method_index (acfg, method);
hash = mono_aot_method_hash (method) % table_size;
//printf ("X: %s %x\n", mono_method_get_full_name (method), mono_aot_method_hash (method));
chain_lengths [hash] ++;
max_chain_length = MAX (max_chain_length, chain_lengths [hash]);
new_entry = (HashEntry *)mono_mempool_alloc0 (acfg->mempool, sizeof (HashEntry));
new_entry->key = key;
new_entry->value = value;
entry = (HashEntry *)g_ptr_array_index (table, hash);
if (entry == NULL) {
new_entry->index = hash;
g_ptr_array_index (table, hash) = new_entry;
} else {
while (entry->next)
entry = entry->next;
entry->next = new_entry;
new_entry->index = table->len;
g_ptr_array_add (table, new_entry);
}
}
g_free (chain_lengths);
//printf ("MAX: %d\n", max_chain_length);
buf_size = table->len * 12 + 4;
p = buf = (guint8 *)g_malloc (buf_size);
encode_int (table_size, p, &p);
for (i = 0; i < table->len; ++i) {
HashEntry *entry = (HashEntry *)g_ptr_array_index (table, i);
if (entry == NULL) {
encode_int (0, p, &p);
encode_int (0, p, &p);
encode_int (0, p, &p);
} else {
//g_assert (entry->key > 0);
encode_int (entry->key, p, &p);
encode_int (entry->value, p, &p);
if (entry->next)
encode_int (entry->next->index, p, &p);
else
encode_int (0, p, &p);
}
}
g_assert (p - buf <= buf_size);
/* Emit the table */
emit_aot_data (acfg, MONO_AOT_TABLE_EXTRA_METHOD_TABLE, "extra_method_table", buf, p - buf);
g_free (buf);
/*
* Emit a table reverse mapping method indexes to their index in extra_method_info.
* This is used by mono_aot_find_jit_info ().
*/
buf_size = acfg->extra_methods->len * 8 + 4;
p = buf = (guint8 *)g_malloc (buf_size);
encode_int (acfg->extra_methods->len, p, &p);
for (i = 0; i < acfg->extra_methods->len; ++i) {
MonoMethod *method = (MonoMethod *)g_ptr_array_index (acfg->extra_methods, i);
encode_int (get_method_index (acfg, method), p, &p);
encode_int (info_offsets [i], p, &p);
}
emit_aot_data (acfg, MONO_AOT_TABLE_EXTRA_METHOD_INFO_OFFSETS, "extra_method_info_offsets", buf, p - buf);
g_free (buf);
g_free (info_offsets);
g_ptr_array_free (table, TRUE);
}
static void
generate_aotid (guint8* aotid)
{
gpointer rand_handle;
ERROR_DECL (error);
mono_rand_open ();
rand_handle = mono_rand_init (NULL, 0);
mono_rand_try_get_bytes (&rand_handle, aotid, 16, error);
mono_error_assert_ok (error);
mono_rand_close (rand_handle);
}
static void
emit_exception_info (MonoAotCompile *acfg)
{
int i;
gint32 *offsets;
SeqPointData sp_data;
gboolean seq_points_to_file = FALSE;
offsets = g_new0 (gint32, acfg->nmethods);
for (i = 0; i < acfg->nmethods; ++i) {
if (acfg->cfgs [i]) {
MonoCompile *cfg = acfg->cfgs [i];
// By design aot-runtime decode_exception_debug_info is not able to load sequence point debug data from a file.
// As it is not possible to load debug data from a file its is also not possible to store it in a file.
gboolean method_seq_points_to_file = acfg->aot_opts.gen_msym_dir &&
cfg->gen_seq_points && !cfg->gen_sdb_seq_points;
gboolean method_seq_points_to_binary = cfg->gen_seq_points && !method_seq_points_to_file;
emit_exception_debug_info (acfg, cfg, method_seq_points_to_binary);
offsets [i] = cfg->ex_info_offset;
if (method_seq_points_to_file) {
if (!seq_points_to_file) {
mono_seq_point_data_init (&sp_data, acfg->nmethods);
seq_points_to_file = TRUE;
}
mono_seq_point_data_add (&sp_data, cfg->method->token, cfg->method_index, cfg->seq_point_info);
}
} else {
offsets [i] = 0;
}
}
if (seq_points_to_file) {
char *aotid = mono_guid_to_string_minimal (acfg->image->aotid);
char *dir = g_build_filename (acfg->aot_opts.gen_msym_dir_path, aotid, (const char*)NULL);
char *image_basename = g_path_get_basename (acfg->image->name);
char *aot_file = g_strdup_printf("%s%s", image_basename, SEQ_POINT_AOT_EXT);
char *aot_file_path = g_build_filename (dir, aot_file, (const char*)NULL);
if (g_ensure_directory_exists (aot_file_path) == FALSE) {
fprintf (stderr, "AOT : failed to create msym directory: %s\n", aot_file_path);
exit (1);
}
mono_seq_point_data_write (&sp_data, aot_file_path);
mono_seq_point_data_free (&sp_data);
g_free (aotid);
g_free (dir);
g_free (image_basename);
g_free (aot_file);
g_free (aot_file_path);
}
acfg->stats.offsets_size += emit_offset_table (acfg, "ex_info_offsets", MONO_AOT_TABLE_EX_INFO_OFFSETS, acfg->nmethods, 10, offsets);
g_free (offsets);
}
static void
emit_unwind_info (MonoAotCompile *acfg)
{
int i;
char symbol [128];
if (acfg->aot_opts.llvm_only) {
g_assert (acfg->unwind_ops->len == 0);
return;
}
/*
* The unwind info contains a lot of duplicates so we emit each unique
* entry once, and only store the offset from the start of the table in the
* exception info.
*/
sprintf (symbol, "unwind_info");
emit_section_change (acfg, RODATA_SECT, 1);
emit_alignment (acfg, 8);
emit_info_symbol (acfg, symbol, TRUE);
for (i = 0; i < acfg->unwind_ops->len; ++i) {
guint32 index = GPOINTER_TO_UINT (g_ptr_array_index (acfg->unwind_ops, i));
guint8 *unwind_info;
guint32 unwind_info_len;
guint8 buf [16];
guint8 *p;
unwind_info = mono_get_cached_unwind_info (index, &unwind_info_len);
p = buf;
encode_value (unwind_info_len, p, &p);
emit_bytes (acfg, buf, p - buf);
emit_bytes (acfg, unwind_info, unwind_info_len);
acfg->stats.unwind_info_size += (p - buf) + unwind_info_len;
}
}
static void
emit_class_info (MonoAotCompile *acfg)
{
int i;
gint32 *offsets;
int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]);
offsets = g_new0 (gint32, rows);
for (i = 0; i < rows; ++i)
offsets [i] = emit_klass_info (acfg, MONO_TOKEN_TYPE_DEF | (i + 1));
acfg->stats.offsets_size += emit_offset_table (acfg, "class_info_offsets", MONO_AOT_TABLE_CLASS_INFO_OFFSETS, rows, 10, offsets);
g_free (offsets);
}
typedef struct ClassNameTableEntry {
guint32 token, index;
struct ClassNameTableEntry *next;
} ClassNameTableEntry;
static void
emit_class_name_table (MonoAotCompile *acfg)
{
int i, table_size, buf_size;
guint32 token, hash;
MonoClass *klass;
GPtrArray *table;
char *full_name;
guint8 *buf, *p;
ClassNameTableEntry *entry, *new_entry;
/*
* Construct a chained hash table for mapping class names to typedef tokens.
*/
int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_TYPEDEF]);
table_size = g_spaced_primes_closest ((int)(rows * 1.5));
table = g_ptr_array_sized_new (table_size);
for (i = 0; i < table_size; ++i)
g_ptr_array_add (table, NULL);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
token = MONO_TOKEN_TYPE_DEF | (i + 1);
klass = mono_class_get_checked (acfg->image, token, error);
if (!klass) {
mono_error_cleanup (error);
continue;
}
full_name = mono_type_get_name_full (m_class_get_byval_arg (klass), MONO_TYPE_NAME_FORMAT_FULL_NAME);
hash = mono_metadata_str_hash (full_name) % table_size;
g_free (full_name);
/* FIXME: Allocate from the mempool */
new_entry = g_new0 (ClassNameTableEntry, 1);
new_entry->token = token;
entry = (ClassNameTableEntry *)g_ptr_array_index (table, hash);
if (entry == NULL) {
new_entry->index = hash;
g_ptr_array_index (table, hash) = new_entry;
} else {
while (entry->next)
entry = entry->next;
entry->next = new_entry;
new_entry->index = table->len;
g_ptr_array_add (table, new_entry);
}
}
/* Emit the table */
buf_size = table->len * 4 + 4;
p = buf = (guint8 *)g_malloc0 (buf_size);
/* FIXME: Optimize memory usage */
g_assert (table_size < 65000);
encode_int16 (table_size, p, &p);
g_assert (table->len < 65000);
for (i = 0; i < table->len; ++i) {
ClassNameTableEntry *entry = (ClassNameTableEntry *)g_ptr_array_index (table, i);
if (entry == NULL) {
encode_int16 (0, p, &p);
encode_int16 (0, p, &p);
} else {
encode_int16 (mono_metadata_token_index (entry->token), p, &p);
if (entry->next)
encode_int16 (entry->next->index, p, &p);
else
encode_int16 (0, p, &p);
}
g_free (entry);
}
g_assert (p - buf <= buf_size);
g_ptr_array_free (table, TRUE);
emit_aot_data (acfg, MONO_AOT_TABLE_CLASS_NAME, "class_name_table", buf, p - buf);
g_free (buf);
}
static void
emit_image_table (MonoAotCompile *acfg)
{
int i, buf_size;
guint8 *buf, *p;
/*
* The image table is small but referenced in a lot of places.
* So we emit it at once, and reference its elements by an index.
*/
buf_size = acfg->image_table->len * 28 + 4;
for (i = 0; i < acfg->image_table->len; i++) {
MonoImage *image = (MonoImage*)g_ptr_array_index (acfg->image_table, i);
MonoAssemblyName *aname = &image->assembly->aname;
buf_size += strlen (image->assembly_name) + strlen (image->guid) + (aname->culture ? strlen (aname->culture) : 1) + strlen ((char*)aname->public_key_token) + 4;
}
buf = p = (guint8 *)g_malloc0 (buf_size);
encode_int (acfg->image_table->len, p, &p);
for (i = 0; i < acfg->image_table->len; i++) {
MonoImage *image = (MonoImage*)g_ptr_array_index (acfg->image_table, i);
MonoAssemblyName *aname = &image->assembly->aname;
/* FIXME: Support multi-module assemblies */
g_assert (image->assembly->image == image);
encode_string (image->assembly_name, p, &p);
encode_string (image->guid, p, &p);
encode_string (aname->culture ? aname->culture : "", p, &p);
encode_string ((const char*)aname->public_key_token, p, &p);
while (GPOINTER_TO_UINT (p) % 8 != 0)
p ++;
encode_int (aname->flags, p, &p);
encode_int (aname->major, p, &p);
encode_int (aname->minor, p, &p);
encode_int (aname->build, p, &p);
encode_int (aname->revision, p, &p);
}
g_assert (p - buf <= buf_size);
emit_aot_data (acfg, MONO_AOT_TABLE_IMAGE_TABLE, "image_table", buf, p - buf);
g_free (buf);
}
static void
emit_weak_field_indexes (MonoAotCompile *acfg)
{
GHashTable *indexes;
GHashTableIter iter;
gpointer key, value;
int buf_size;
guint8 *buf, *p;
/* Emit a table of weak field indexes, since computing these at runtime is expensive */
mono_assembly_init_weak_fields (acfg->image);
indexes = acfg->image->weak_field_indexes;
g_assert (indexes);
buf_size = (g_hash_table_size (indexes) + 1) * 4;
buf = p = (guint8 *)g_malloc0 (buf_size);
encode_int (g_hash_table_size (indexes), p, &p);
g_hash_table_iter_init (&iter, indexes);
while (g_hash_table_iter_next (&iter, &key, &value)) {
guint32 index = GPOINTER_TO_UINT (key);
encode_int (index, p, &p);
}
g_assert (p - buf <= buf_size);
emit_aot_data (acfg, MONO_AOT_TABLE_WEAK_FIELD_INDEXES, "weak_field_indexes", buf, p - buf);
g_free (buf);
}
static void
emit_got_info (MonoAotCompile *acfg, gboolean llvm)
{
int i, first_plt_got_patch = 0, buf_size;
guint8 *p, *buf;
guint32 *got_info_offsets;
GotInfo *info = llvm ? &acfg->llvm_got_info : &acfg->got_info;
/* Add the patches needed by the PLT to the GOT */
if (!llvm) {
acfg->plt_got_offset_base = acfg->got_offset;
acfg->plt_got_info_offset_base = info->got_patches->len;
first_plt_got_patch = acfg->plt_got_info_offset_base;
for (i = 1; i < acfg->plt_offset; ++i) {
MonoPltEntry *plt_entry = (MonoPltEntry *)g_hash_table_lookup (acfg->plt_offset_to_entry, GUINT_TO_POINTER (i));
g_ptr_array_add (info->got_patches, plt_entry->ji);
acfg->stats.got_slot_types [plt_entry->ji->type] ++;
}
acfg->got_offset += acfg->plt_offset;
}
/**
* FIXME:
* - optimize offsets table.
* - reduce number of exported symbols.
* - emit info for a klass only once.
* - determine when a method uses a GOT slot which is guaranteed to be already
* initialized.
* - clean up and document the code.
* - use String.Empty in class libs.
*/
/* Encode info required to decode shared GOT entries */
buf_size = info->got_patches->len * 128;
p = buf = (guint8 *)mono_mempool_alloc (acfg->mempool, buf_size);
got_info_offsets = (guint32 *)mono_mempool_alloc (acfg->mempool, info->got_patches->len * sizeof (guint32));
if (!llvm) {
acfg->plt_got_info_offsets = (guint32 *)mono_mempool_alloc (acfg->mempool, acfg->plt_offset * sizeof (guint32));
/* Unused */
if (acfg->plt_offset)
acfg->plt_got_info_offsets [0] = 0;
}
for (i = 0; i < info->got_patches->len; ++i) {
MonoJumpInfo *ji = (MonoJumpInfo *)g_ptr_array_index (info->got_patches, i);
guint8 *p2;
p = buf;
encode_value (ji->type, p, &p);
p2 = p;
encode_patch (acfg, ji, p, &p);
acfg->stats.got_slot_info_sizes [ji->type] += p - p2;
g_assert (p - buf <= buf_size);
got_info_offsets [i] = add_to_blob (acfg, buf, p - buf);
if (!llvm && i >= first_plt_got_patch)
acfg->plt_got_info_offsets [i - first_plt_got_patch + 1] = got_info_offsets [i];
acfg->stats.got_info_size += p - buf;
}
/* Emit got_info_offsets table */
#ifdef MONO_ARCH_CODE_EXEC_ONLY
int got_info_offsets_to_emit = info->got_patches->len;
#else
/* No need to emit offsets for the got plt entries, the plt embeds them directly */
int got_info_offsets_to_emit = first_plt_got_patch;
#endif
acfg->stats.offsets_size += emit_offset_table (acfg, llvm ? "llvm_got_info_offsets" : "got_info_offsets", llvm ? MONO_AOT_TABLE_LLVM_GOT_INFO_OFFSETS : MONO_AOT_TABLE_GOT_INFO_OFFSETS, llvm ? acfg->llvm_got_offset : got_info_offsets_to_emit, 10, (gint32*)got_info_offsets);
}
static void
emit_got (MonoAotCompile *acfg)
{
char symbol [MAX_SYMBOL_SIZE];
if (acfg->aot_opts.llvm_only)
return;
/* Don't make GOT global so accesses to it don't need relocations */
sprintf (symbol, "%s", acfg->got_symbol);
#ifdef TARGET_MACH
emit_unset_mode (acfg);
fprintf (acfg->fp, ".section __DATA, __bss\n");
emit_alignment (acfg, 8);
if (acfg->llvm)
emit_info_symbol (acfg, "jit_got", FALSE);
fprintf (acfg->fp, ".lcomm %s, %d\n", acfg->got_symbol, (int)(acfg->got_offset * sizeof (target_mgreg_t)));
#else
emit_section_change (acfg, ".bss", 0);
emit_alignment (acfg, 8);
if (acfg->aot_opts.write_symbols)
emit_local_symbol (acfg, symbol, "got_end", FALSE);
emit_label (acfg, symbol);
if (acfg->llvm)
emit_info_symbol (acfg, "jit_got", FALSE);
if (acfg->got_offset > 0)
emit_zero_bytes (acfg, (int)(acfg->got_offset * sizeof (target_mgreg_t)));
#endif
sprintf (symbol, "got_end");
emit_label (acfg, symbol);
}
typedef struct GlobalsTableEntry {
guint32 value, index;
struct GlobalsTableEntry *next;
} GlobalsTableEntry;
#ifdef TARGET_WIN32_MSVC
#define DLL_ENTRY_POINT "DllMain"
static void
emit_library_info (MonoAotCompile *acfg)
{
// Only include for shared libraries linked directly from generated object.
if (link_shared_library (acfg)) {
char *name = NULL;
char symbol [MAX_SYMBOL_SIZE];
// Ask linker to export all global symbols.
emit_section_change (acfg, ".drectve", 0);
for (guint i = 0; i < acfg->globals->len; ++i) {
name = (char *)g_ptr_array_index (acfg->globals, i);
g_assert (name != NULL);
sprintf_s (symbol, MAX_SYMBOL_SIZE, " /EXPORT:%s", name);
emit_string (acfg, symbol);
}
// Emit DLLMain function, needed by MSVC linker for DLL's.
// NOTE, DllMain should not go into exports above.
emit_section_change (acfg, ".text", 0);
emit_global (acfg, DLL_ENTRY_POINT, TRUE);
emit_label (acfg, DLL_ENTRY_POINT);
// Simple implementation of DLLMain, just returning TRUE.
// For more information about DLLMain: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682583(v=vs.85).aspx
fprintf (acfg->fp, "movl $1, %%eax\n");
fprintf (acfg->fp, "ret\n");
// Inform linker about our dll entry function.
emit_section_change (acfg, ".drectve", 0);
emit_string (acfg, "/ENTRY:" DLL_ENTRY_POINT);
return;
}
}
#else
static void
emit_library_info (MonoAotCompile *acfg)
{
return;
}
#endif
static void
emit_globals (MonoAotCompile *acfg)
{
int i, table_size;
guint32 hash;
GPtrArray *table;
char symbol [1024];
GlobalsTableEntry *entry, *new_entry;
if (!acfg->aot_opts.static_link)
return;
if (acfg->aot_opts.llvm_only) {
g_assert (acfg->globals->len == 0);
return;
}
/*
* When static linking, we emit a table containing our globals.
*/
/*
* Construct a chained hash table for mapping global names to their index in
* the globals table.
*/
table_size = g_spaced_primes_closest ((int)(acfg->globals->len * 1.5));
table = g_ptr_array_sized_new (table_size);
for (i = 0; i < table_size; ++i)
g_ptr_array_add (table, NULL);
for (i = 0; i < acfg->globals->len; ++i) {
char *name = (char *)g_ptr_array_index (acfg->globals, i);
hash = mono_metadata_str_hash (name) % table_size;
/* FIXME: Allocate from the mempool */
new_entry = g_new0 (GlobalsTableEntry, 1);
new_entry->value = i;
entry = (GlobalsTableEntry *)g_ptr_array_index (table, hash);
if (entry == NULL) {
new_entry->index = hash;
g_ptr_array_index (table, hash) = new_entry;
} else {
while (entry->next)
entry = entry->next;
entry->next = new_entry;
new_entry->index = table->len;
g_ptr_array_add (table, new_entry);
}
}
/* Emit the table */
sprintf (symbol, ".Lglobals_hash");
emit_section_change (acfg, RODATA_SECT, 0);
emit_alignment (acfg, 8);
emit_label (acfg, symbol);
/* FIXME: Optimize memory usage */
g_assert (table_size < 65000);
emit_int16 (acfg, table_size);
for (i = 0; i < table->len; ++i) {
GlobalsTableEntry *entry = (GlobalsTableEntry *)g_ptr_array_index (table, i);
if (entry == NULL) {
emit_int16 (acfg, 0);
emit_int16 (acfg, 0);
} else {
emit_int16 (acfg, entry->value + 1);
if (entry->next)
emit_int16 (acfg, entry->next->index);
else
emit_int16 (acfg, 0);
}
}
/* Emit the names */
for (i = 0; i < acfg->globals->len; ++i) {
char *name = (char *)g_ptr_array_index (acfg->globals, i);
sprintf (symbol, "name_%d", i);
emit_section_change (acfg, RODATA_SECT, 1);
#ifdef TARGET_MACH
emit_alignment (acfg, 4);
#endif
emit_label (acfg, symbol);
emit_string (acfg, name);
}
/* Emit the globals table */
sprintf (symbol, "globals");
emit_section_change (acfg, ".data", 0);
/* This is not a global, since it is accessed by the init function */
emit_alignment (acfg, 8);
emit_info_symbol (acfg, symbol, FALSE);
sprintf (symbol, "%sglobals_hash", acfg->temp_prefix);
emit_pointer (acfg, symbol);
for (i = 0; i < acfg->globals->len; ++i) {
char *name = (char *)g_ptr_array_index (acfg->globals, i);
sprintf (symbol, "name_%d", i);
emit_pointer (acfg, symbol);
g_assert (strlen (name) < sizeof (symbol));
sprintf (symbol, "%s", name);
emit_pointer (acfg, symbol);
}
/* Null terminate the table */
emit_int32 (acfg, 0);
emit_int32 (acfg, 0);
}
static void
emit_mem_end (MonoAotCompile *acfg)
{
char symbol [128];
if (acfg->aot_opts.llvm_only)
return;
sprintf (symbol, "mem_end");
emit_section_change (acfg, ".text", 1);
emit_alignment_code (acfg, 8);
emit_label (acfg, symbol);
}
static void
init_aot_file_info (MonoAotCompile *acfg, MonoAotFileInfo *info)
{
int i;
info->version = MONO_AOT_FILE_VERSION;
info->plt_got_offset_base = acfg->plt_got_offset_base;
info->plt_got_info_offset_base = acfg->plt_got_info_offset_base;
info->got_size = acfg->got_offset * sizeof (target_mgreg_t);
info->llvm_got_size = acfg->llvm_got_offset * sizeof (target_mgreg_t);
info->plt_size = acfg->plt_offset;
info->nmethods = acfg->nmethods;
info->call_table_entry_size = acfg->call_table_entry_size;
info->nextra_methods = acfg->nextra_methods;
info->flags = acfg->flags;
info->opts = acfg->jit_opts;
info->simd_opts = acfg->simd_opts;
info->gc_name_index = acfg->gc_name_offset;
info->datafile_size = acfg->datafile_offset;
for (i = 0; i < MONO_AOT_TABLE_NUM; ++i)
info->table_offsets [i] = acfg->table_offsets [i];
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
info->num_trampolines [i] = acfg->num_trampolines [i];
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
info->trampoline_got_offset_base [i] = acfg->trampoline_got_offset_base [i];
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
info->trampoline_size [i] = acfg->trampoline_size [i];
info->num_rgctx_fetch_trampolines = acfg->aot_opts.nrgctx_fetch_trampolines;
int card_table_shift_bits = 0;
target_mgreg_t card_table_mask = 0;
mono_gc_get_target_card_table (&card_table_shift_bits, &card_table_mask);
/*
* Sanity checking variables used to make sure the host and target
* environment matches when cross compiling.
*/
info->double_align = MONO_ABI_ALIGNOF (double);
info->long_align = MONO_ABI_ALIGNOF (gint64);
info->generic_tramp_num = MONO_TRAMPOLINE_NUM;
info->card_table_shift_bits = card_table_shift_bits;
info->card_table_mask = card_table_mask;
info->tramp_page_size = acfg->tramp_page_size;
info->nshared_got_entries = acfg->nshared_got_entries;
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
info->tramp_page_code_offsets [i] = acfg->tramp_page_code_offsets [i];
memcpy(&info->aotid, acfg->image->aotid, 16);
}
static void
emit_aot_file_info (MonoAotCompile *acfg, MonoAotFileInfo *info)
{
char symbol [MAX_SYMBOL_SIZE];
int i, sindex;
const char **symbols;
symbols = g_new0 (const char *, MONO_AOT_FILE_INFO_NUM_SYMBOLS);
sindex = 0;
symbols [sindex ++] = acfg->got_symbol;
if (acfg->llvm) {
symbols [sindex ++] = acfg->llvm_eh_frame_symbol;
} else {
symbols [sindex ++] = NULL;
}
/* llvm_get_method */
symbols [sindex ++] = NULL;
/* llvm_get_unbox_tramp */
symbols [sindex ++] = NULL;
/* llvm_init_aotconst */
symbols [sindex ++] = NULL;
if (!acfg->aot_opts.llvm_only) {
symbols [sindex ++] = "jit_code_start";
symbols [sindex ++] = "jit_code_end";
symbols [sindex ++] = "method_addresses";
} else {
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
}
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
if (acfg->data_outfile) {
for (i = 0; i < MONO_AOT_TABLE_NUM; ++i)
symbols [sindex ++] = NULL;
} else {
symbols [sindex ++] = "blob";
symbols [sindex ++] = "class_name_table";
symbols [sindex ++] = "class_info_offsets";
symbols [sindex ++] = "method_info_offsets";
symbols [sindex ++] = "ex_info_offsets";
symbols [sindex ++] = "extra_method_info_offsets";
symbols [sindex ++] = "extra_method_table";
symbols [sindex ++] = "got_info_offsets";
if (acfg->llvm)
symbols [sindex ++] = "llvm_got_info_offsets";
else
symbols [sindex ++] = NULL;
symbols [sindex ++] = "image_table";
symbols [sindex ++] = "weak_field_indexes";
symbols [sindex ++] = "method_flags_table";
}
symbols [sindex ++] = "mem_end";
symbols [sindex ++] = "assembly_guid";
symbols [sindex ++] = "runtime_version";
if (acfg->num_trampoline_got_entries) {
symbols [sindex ++] = "specific_trampolines";
symbols [sindex ++] = "static_rgctx_trampolines";
symbols [sindex ++] = "imt_trampolines";
symbols [sindex ++] = "gsharedvt_arg_trampolines";
symbols [sindex ++] = "ftnptr_arg_trampolines";
symbols [sindex ++] = "unbox_arbitrary_trampolines";
} else {
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
}
if (acfg->aot_opts.static_link) {
symbols [sindex ++] = "globals";
} else {
symbols [sindex ++] = NULL;
}
symbols [sindex ++] = "assembly_name";
symbols [sindex ++] = "plt";
symbols [sindex ++] = "plt_end";
symbols [sindex ++] = "unwind_info";
if (!acfg->aot_opts.llvm_only) {
symbols [sindex ++] = "unbox_trampolines";
symbols [sindex ++] = "unbox_trampolines_end";
symbols [sindex ++] = "unbox_trampoline_addresses";
} else {
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
symbols [sindex ++] = NULL;
}
g_assert (sindex == MONO_AOT_FILE_INFO_NUM_SYMBOLS);
sprintf (symbol, "%smono_aot_file_info", acfg->user_symbol_prefix);
emit_section_change (acfg, ".data", 0);
emit_alignment (acfg, 8);
emit_label (acfg, symbol);
if (!acfg->aot_opts.static_link)
emit_global (acfg, symbol, FALSE);
/* The data emitted here must match MonoAotFileInfo. */
emit_int32 (acfg, info->version);
emit_int32 (acfg, info->dummy);
/*
* We emit pointers to our data structures instead of emitting global symbols which
* point to them, to reduce the number of globals, and because using globals leads to
* various problems (i.e. arm/thumb).
*/
for (i = 0; i < MONO_AOT_FILE_INFO_NUM_SYMBOLS; ++i)
emit_pointer (acfg, symbols [i]);
emit_int32 (acfg, info->plt_got_offset_base);
emit_int32 (acfg, info->plt_got_info_offset_base);
emit_int32 (acfg, info->got_size);
emit_int32 (acfg, info->llvm_got_size);
emit_int32 (acfg, info->plt_size);
emit_int32 (acfg, info->nmethods);
emit_int32 (acfg, info->nextra_methods);
emit_int32 (acfg, info->flags);
emit_int32 (acfg, info->opts);
emit_int32 (acfg, info->simd_opts);
emit_int32 (acfg, info->gc_name_index);
emit_int32 (acfg, info->num_rgctx_fetch_trampolines);
emit_int32 (acfg, info->double_align);
emit_int32 (acfg, info->long_align);
emit_int32 (acfg, info->generic_tramp_num);
emit_int32 (acfg, info->card_table_shift_bits);
emit_int32 (acfg, info->card_table_mask);
emit_int32 (acfg, info->tramp_page_size);
emit_int32 (acfg, info->call_table_entry_size);
emit_int32 (acfg, info->nshared_got_entries);
emit_int32 (acfg, info->datafile_size);
emit_int32 (acfg, 0);
emit_int32 (acfg, 0);
for (i = 0; i < MONO_AOT_TABLE_NUM; ++i)
emit_int32 (acfg, info->table_offsets [i]);
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
emit_int32 (acfg, info->num_trampolines [i]);
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
emit_int32 (acfg, info->trampoline_got_offset_base [i]);
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
emit_int32 (acfg, info->trampoline_size [i]);
for (i = 0; i < MONO_AOT_TRAMP_NUM; ++i)
emit_int32 (acfg, info->tramp_page_code_offsets [i]);
emit_bytes (acfg, info->aotid, 16);
if (acfg->aot_opts.static_link) {
emit_global_inner (acfg, acfg->static_linking_symbol, FALSE);
emit_alignment (acfg, sizeof (target_mgreg_t));
emit_label (acfg, acfg->static_linking_symbol);
emit_pointer_2 (acfg, acfg->user_symbol_prefix, "mono_aot_file_info");
}
}
/*
* Emit a structure containing all the information not stored elsewhere.
*/
static void
emit_file_info (MonoAotCompile *acfg)
{
char *build_info;
MonoAotFileInfo *info;
if (acfg->aot_opts.bind_to_runtime_version) {
build_info = mono_get_runtime_build_info ();
emit_string_symbol (acfg, "runtime_version", build_info);
g_free (build_info);
} else {
emit_string_symbol (acfg, "runtime_version", "");
}
emit_string_symbol (acfg, "assembly_guid" , acfg->image->guid);
/* Emit a string holding the assembly name */
emit_string_symbol (acfg, "assembly_name", acfg->image->assembly->aname.name);
info = g_new0 (MonoAotFileInfo, 1);
init_aot_file_info (acfg, info);
if (acfg->aot_opts.static_link) {
char symbol [MAX_SYMBOL_SIZE];
char *p;
/*
* Emit a global symbol which can be passed by an embedding app to
* mono_aot_register_module (). The symbol points to a pointer to the the file info
* structure.
*/
sprintf (symbol, "%smono_aot_module_%s_info", acfg->user_symbol_prefix, acfg->image->assembly->aname.name);
/* Get rid of characters which cannot occur in symbols */
p = symbol;
for (p = symbol; *p; ++p) {
if (!(isalnum (*p) || *p == '_'))
*p = '_';
}
acfg->static_linking_symbol = g_strdup (symbol);
}
if (acfg->llvm)
mono_llvm_emit_aot_file_info (info, acfg->has_jitted_code);
else
emit_aot_file_info (acfg, info);
}
static void
emit_blob (MonoAotCompile *acfg)
{
acfg->blob_closed = TRUE;
emit_aot_data (acfg, MONO_AOT_TABLE_BLOB, "blob", (guint8*)acfg->blob.data, acfg->blob.index);
}
static void
emit_objc_selectors (MonoAotCompile *acfg)
{
int i;
char symbol [128];
if (!acfg->objc_selectors || acfg->objc_selectors->len == 0)
return;
/*
* From
* cat > foo.m << EOF
* void *ret ()
* {
* return @selector(print:);
* }
* EOF
*/
mono_img_writer_emit_unset_mode (acfg->w);
g_assert (acfg->fp);
fprintf (acfg->fp, ".section __DATA,__objc_selrefs,literal_pointers,no_dead_strip\n");
fprintf (acfg->fp, ".align 3\n");
for (i = 0; i < acfg->objc_selectors->len; ++i) {
sprintf (symbol, "L_OBJC_SELECTOR_REFERENCES_%d", i);
emit_label (acfg, symbol);
sprintf (symbol, "L_OBJC_METH_VAR_NAME_%d", i);
emit_pointer (acfg, symbol);
}
fprintf (acfg->fp, ".section __TEXT,__cstring,cstring_literals\n");
for (i = 0; i < acfg->objc_selectors->len; ++i) {
fprintf (acfg->fp, "L_OBJC_METH_VAR_NAME_%d:\n", i);
fprintf (acfg->fp, ".asciz \"%s\"\n", (char*)g_ptr_array_index (acfg->objc_selectors, i));
}
fprintf (acfg->fp, ".section __DATA,__objc_imageinfo,regular,no_dead_strip\n");
fprintf (acfg->fp, ".align 3\n");
fprintf (acfg->fp, "L_OBJC_IMAGE_INFO:\n");
fprintf (acfg->fp, ".long 0\n");
fprintf (acfg->fp, ".long 16\n");
}
static void
emit_dwarf_info (MonoAotCompile *acfg)
{
#ifdef EMIT_DWARF_INFO
int i;
char symbol2 [128];
/* DIEs for methods */
for (i = 0; i < acfg->nmethods; ++i) {
MonoCompile *cfg = acfg->cfgs [i];
if (ignore_cfg (cfg))
continue;
// FIXME: LLVM doesn't define .Lme_...
if (cfg->compile_llvm)
continue;
sprintf (symbol2, "%sme_%x", acfg->temp_prefix, i);
MonoDebugMethodJitInfo *jit_debug_info = mono_debug_find_method (cfg->jit_info->d.method, mono_domain_get ());
mono_dwarf_writer_emit_method (acfg->dwarf, cfg, cfg->method, cfg->asm_symbol, symbol2, cfg->asm_debug_symbol, (guint8 *)cfg->jit_info->code_start, cfg->jit_info->code_size, cfg->args, cfg->locals, cfg->unwind_ops, jit_debug_info);
mono_debug_free_method_jit_info (jit_debug_info);
}
#endif
}
#ifdef EMIT_WIN32_CODEVIEW_INFO
typedef struct _CodeViewSubSectionData
{
gchar *start_section;
gchar *end_section;
gchar *start_section_record;
gchar *end_section_record;
int section_type;
int section_record_type;
int section_id;
} CodeViewSubsectionData;
typedef struct _CodeViewCompilerVersion
{
gint major;
gint minor;
gint revision;
gint patch;
} CodeViewCompilerVersion;
#define CODEVIEW_SUBSECTION_SYMBOL_TYPE 0xF1
#define CODEVIEW_SUBSECTION_RECORD_COMPILER_TYPE 0x113c
#define CODEVIEW_SUBSECTION_RECORD_FUNCTION_START_TYPE 0x1147
#define CODEVIEW_SUBSECTION_RECORD_FUNCTION_END_TYPE 0x114F
#define CODEVIEW_CSHARP_LANGUAGE_TYPE 0x0A
#define CODEVIEW_CPU_TYPE 0x0
#define CODEVIEW_MAGIC_HEADER 0x4
static void
codeview_clear_subsection_data (CodeViewSubsectionData *section_data)
{
g_free (section_data->start_section);
g_free (section_data->end_section);
g_free (section_data->start_section_record);
g_free (section_data->end_section_record);
memset (section_data, 0, sizeof (CodeViewSubsectionData));
}
static void
codeview_parse_compiler_version (gchar *version, CodeViewCompilerVersion *data)
{
gint values[4] = { 0 };
gint *value = values;
while (*version && (value < values + G_N_ELEMENTS (values))) {
if (isdigit (*version)) {
*value *= 10;
*value += *version - '0';
}
else if (*version == '.') {
value++;
}
version++;
}
data->major = values[0];
data->minor = values[1];
data->revision = values[2];
data->patch = values[3];
}
static void
emit_codeview_start_subsection (MonoAotCompile *acfg, int section_id, int section_type, int section_record_type, CodeViewSubsectionData *section_data)
{
// Starting a new subsection, clear old data.
codeview_clear_subsection_data (section_data);
// Keep subsection data.
section_data->section_id = section_id;
section_data->section_type = section_type;
section_data->section_record_type = section_record_type;
// Allocate all labels used in subsection.
section_data->start_section = g_strdup_printf ("%scvs_%d", acfg->temp_prefix, section_data->section_id);
section_data->end_section = g_strdup_printf ("%scvse_%d", acfg->temp_prefix, section_data->section_id);
section_data->start_section_record = g_strdup_printf ("%scvsr_%d", acfg->temp_prefix, section_data->section_id);
section_data->end_section_record = g_strdup_printf ("%scvsre_%d", acfg->temp_prefix, section_data->section_id);
// Subsection type, function symbol.
emit_int32 (acfg, section_data->section_type);
// Subsection size.
emit_symbol_diff (acfg, section_data->end_section, section_data->start_section, 0);
emit_label (acfg, section_data->start_section);
// Subsection record size.
fprintf (acfg->fp, "\t.word %s - %s\n", section_data->end_section_record, section_data->start_section_record);
emit_label (acfg, section_data->start_section_record);
// Subsection record type.
emit_int16 (acfg, section_record_type);
}
static void
emit_codeview_end_subsection (MonoAotCompile *acfg, CodeViewSubsectionData *section_data, int *section_id)
{
g_assert (section_data->start_section);
g_assert (section_data->end_section);
g_assert (section_data->start_section_record);
g_assert (section_data->end_section_record);
emit_label (acfg, section_data->end_section_record);
if (section_data->section_record_type == CODEVIEW_SUBSECTION_RECORD_FUNCTION_START_TYPE) {
// Emit record length.
emit_int16 (acfg, 2);
// Emit specific record type end.
emit_int16 (acfg, CODEVIEW_SUBSECTION_RECORD_FUNCTION_END_TYPE);
}
emit_label (acfg, section_data->end_section);
// Next subsection needs to be 4 byte aligned.
emit_alignment (acfg, 4);
*section_id = section_data->section_id + 1;
codeview_clear_subsection_data (section_data);
}
inline static void
emit_codeview_start_symbol_subsection (MonoAotCompile *acfg, int section_id, int section_record_type, CodeViewSubsectionData *section_data)
{
emit_codeview_start_subsection (acfg, section_id, CODEVIEW_SUBSECTION_SYMBOL_TYPE, section_record_type, section_data);
}
inline static void
emit_codeview_end_symbol_subsection (MonoAotCompile *acfg, CodeViewSubsectionData *section_data, int *section_id)
{
emit_codeview_end_subsection (acfg, section_data, section_id);
}
static void
emit_codeview_compiler_info (MonoAotCompile *acfg, int *section_id)
{
CodeViewSubsectionData section_data = { 0 };
CodeViewCompilerVersion compiler_version = { 0 };
// Start new compiler record subsection.
emit_codeview_start_symbol_subsection (acfg, *section_id, CODEVIEW_SUBSECTION_RECORD_COMPILER_TYPE, §ion_data);
emit_int32 (acfg, CODEVIEW_CSHARP_LANGUAGE_TYPE);
emit_int16 (acfg, CODEVIEW_CPU_TYPE);
// Get compiler version information.
codeview_parse_compiler_version (VERSION, &compiler_version);
// Compiler frontend version, 4 digits.
emit_int16 (acfg, compiler_version.major);
emit_int16 (acfg, compiler_version.minor);
emit_int16 (acfg, compiler_version.revision);
emit_int16 (acfg, compiler_version.patch);
// Compiler backend version, 4 digits (currently same as frontend).
emit_int16 (acfg, compiler_version.major);
emit_int16 (acfg, compiler_version.minor);
emit_int16 (acfg, compiler_version.revision);
emit_int16 (acfg, compiler_version.patch);
// Compiler string.
emit_string (acfg, "Mono AOT compiler");
// Done with section.
emit_codeview_end_symbol_subsection (acfg, §ion_data, section_id);
}
static void
emit_codeview_function_info (MonoAotCompile *acfg, MonoMethod *method, int *section_id, gchar *symbol, gchar *symbol_start, gchar *symbol_end)
{
CodeViewSubsectionData section_data = { 0 };
gchar *full_method_name = NULL;
// Start new function record subsection.
emit_codeview_start_symbol_subsection (acfg, *section_id, CODEVIEW_SUBSECTION_RECORD_FUNCTION_START_TYPE, §ion_data);
// Emit 3 int 0 byte padding, currently not used.
emit_zero_bytes (acfg, sizeof (int) * 3);
// Emit size of function.
emit_symbol_diff (acfg, symbol_end, symbol_start, 0);
// Emit 3 int 0 byte padding, currently not used.
emit_zero_bytes (acfg, sizeof (int) * 3);
// Emit reallocation info.
fprintf (acfg->fp, "\t.secrel32 %s\n", symbol);
fprintf (acfg->fp, "\t.secidx %s\n", symbol);
// Emit flag, currently not used.
emit_zero_bytes (acfg, 1);
// Emit function name, exclude signature since it should be described by own metadata.
full_method_name = mono_method_full_name (method, FALSE);
emit_string (acfg, full_method_name ? full_method_name : "");
g_free (full_method_name);
// Done with section.
emit_codeview_end_symbol_subsection (acfg, §ion_data, section_id);
}
static void
emit_codeview_info (MonoAotCompile *acfg)
{
int i;
int section_id = 0;
gchar symbol_buffer[MAX_SYMBOL_SIZE];
// Emit codeview debug info section
emit_section_change (acfg, ".debug$S", 0);
// Emit magic header.
emit_int32 (acfg, CODEVIEW_MAGIC_HEADER);
emit_codeview_compiler_info (acfg, §ion_id);
for (i = 0; i < acfg->nmethods; ++i) {
MonoCompile *cfg = acfg->cfgs[i];
if (!cfg || COMPILE_LLVM (cfg))
continue;
int ret = g_snprintf (symbol_buffer, G_N_ELEMENTS (symbol_buffer), "%sme_%x", acfg->temp_prefix, i);
if (ret > 0 && ret < G_N_ELEMENTS (symbol_buffer))
emit_codeview_function_info (acfg, cfg->method, §ion_id, cfg->asm_debug_symbol, cfg->asm_symbol, symbol_buffer);
}
}
#else
static void
emit_codeview_info (MonoAotCompile *acfg)
{
}
#endif /* EMIT_WIN32_CODEVIEW_INFO */
#ifdef EMIT_WIN32_UNWIND_INFO
static UnwindInfoSectionCacheItem *
get_cached_unwind_info_section_item_win32 (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops)
{
UnwindInfoSectionCacheItem *item = NULL;
if (!acfg->unwind_info_section_cache)
acfg->unwind_info_section_cache = g_list_alloc ();
PUNWIND_INFO unwind_info = mono_arch_unwindinfo_alloc_unwind_info (unwind_ops);
// Search for unwind info in cache.
GList *list = acfg->unwind_info_section_cache;
int list_size = 0;
while (list && list->data) {
item = (UnwindInfoSectionCacheItem*)list->data;
if (!memcmp (unwind_info, item->unwind_info, sizeof (UNWIND_INFO))) {
// Cache hit, return cached item.
return item;
}
list = list->next;
list_size++;
}
// Add to cache.
if (acfg->unwind_info_section_cache) {
item = g_new0 (UnwindInfoSectionCacheItem, 1);
if (item) {
// Format .xdata section label for function, used to get unwind info address RVA.
// Since the unwind info is similar for most functions, the symbol will be reused.
item->xdata_section_label = g_strdup_printf ("%sunwind_%d", acfg->temp_prefix, list_size);
// Cache unwind info data, used when checking cache for matching unwind info. NOTE, cache takes
//over ownership of unwind info.
item->unwind_info = unwind_info;
// Needs to be emitted once.
item->xdata_section_emitted = FALSE;
// Prepend to beginning of list to speed up inserts.
acfg->unwind_info_section_cache = g_list_prepend (acfg->unwind_info_section_cache, (gpointer)item);
}
}
return item;
}
static void
free_unwind_info_section_cache_win32 (MonoAotCompile *acfg)
{
GList *list = acfg->unwind_info_section_cache;
while (list) {
UnwindInfoSectionCacheItem *item = (UnwindInfoSectionCacheItem *)list->data;
if (item) {
g_free (item->xdata_section_label);
mono_arch_unwindinfo_free_unwind_info (item->unwind_info);
g_free (item);
list->data = NULL;
}
list = list->next;
}
g_list_free (acfg->unwind_info_section_cache);
acfg->unwind_info_section_cache = NULL;
}
static void
emit_unwind_info_data_win32 (MonoAotCompile *acfg, PUNWIND_INFO unwind_info)
{
// Emit the unwind info struct.
emit_bytes (acfg, (guint8*)unwind_info, sizeof (UNWIND_INFO) - (sizeof (UNWIND_CODE) * MONO_MAX_UNWIND_CODES));
// Emit all unwind codes encoded in unwind info struct.
PUNWIND_CODE current_unwind_node = &unwind_info->UnwindCode[MONO_MAX_UNWIND_CODES - unwind_info->CountOfCodes];
PUNWIND_CODE last_unwind_node = &unwind_info->UnwindCode[MONO_MAX_UNWIND_CODES];
while (current_unwind_node < last_unwind_node) {
guint8 node_count = 0;
switch (current_unwind_node->UnwindOp) {
case UWOP_PUSH_NONVOL:
case UWOP_ALLOC_SMALL:
case UWOP_SET_FPREG:
case UWOP_PUSH_MACHFRAME:
node_count = 1;
break;
case UWOP_SAVE_NONVOL:
case UWOP_SAVE_XMM128:
node_count = 2;
break;
case UWOP_SAVE_NONVOL_FAR:
case UWOP_SAVE_XMM128_FAR:
node_count = 3;
break;
case UWOP_ALLOC_LARGE:
if (current_unwind_node->OpInfo == 0)
node_count = 2;
else
node_count = 3;
break;
default:
g_assert (!"Unknown unwind opcode.");
}
while (node_count > 0) {
g_assert (current_unwind_node < last_unwind_node);
//Emit current node.
emit_bytes (acfg, (guint8*)current_unwind_node, sizeof (UNWIND_CODE));
node_count--;
current_unwind_node++;
}
}
}
// Emit unwind info sections for each function. Unwind info on Windows x64 is emitted into two different sections.
// .pdata includes the serialized DWORD aligned RVA's of function start, end and address of serialized
// UNWIND_INFO struct emitted into .xdata, see https://msdn.microsoft.com/en-us/library/ft9x1kdx.aspx.
// .xdata section includes DWORD aligned serialized version of UNWIND_INFO struct, https://msdn.microsoft.com/en-us/library/ddssxxy8.aspx.
static void
emit_unwind_info_sections_win32 (MonoAotCompile *acfg, const char *function_start, const char *function_end, GSList *unwind_ops)
{
char *pdata_section_label = NULL;
int temp_prefix_len = (acfg->temp_prefix != NULL) ? strlen (acfg->temp_prefix) : 0;
if (strncmp (function_start, acfg->temp_prefix, temp_prefix_len)) {
temp_prefix_len = 0;
}
// Format .pdata section label for function.
pdata_section_label = g_strdup_printf ("%spdata_%s", acfg->temp_prefix, function_start + temp_prefix_len);
UnwindInfoSectionCacheItem *cache_item = get_cached_unwind_info_section_item_win32 (acfg, function_start, function_end, unwind_ops);
g_assert (cache_item && cache_item->xdata_section_label && cache_item->unwind_info);
// Emit .pdata section.
emit_section_change (acfg, ".pdata", 0);
emit_alignment (acfg, sizeof (DWORD));
emit_label (acfg, pdata_section_label);
// Emit function start address RVA.
fprintf (acfg->fp, "\t.long %s@IMGREL\n", function_start);
// Emit function end address RVA.
fprintf (acfg->fp, "\t.long %s@IMGREL\n", function_end);
// Emit unwind info address RVA.
fprintf (acfg->fp, "\t.long %s@IMGREL\n", cache_item->xdata_section_label);
if (!cache_item->xdata_section_emitted) {
// Emit .xdata section.
emit_section_change (acfg, ".xdata", 0);
emit_alignment (acfg, sizeof (DWORD));
emit_label (acfg, cache_item->xdata_section_label);
// Emit unwind info into .xdata section.
emit_unwind_info_data_win32 (acfg, cache_item->unwind_info);
cache_item->xdata_section_emitted = TRUE;
}
g_free (pdata_section_label);
}
#endif
static gboolean
should_emit_gsharedvt_method (MonoAotCompile *acfg, MonoMethod *method)
{
#ifdef TARGET_WASM
if (acfg->image == mono_get_corlib () && !strcmp (m_class_get_name (method->klass), "Vector`1"))
/* The SIMD fallback code in Vector<T> is very large, and not likely to be used */
return FALSE;
#endif
if (acfg->image == mono_get_corlib () && !strcmp (m_class_get_name (method->klass), "Volatile"))
/* Read<T>/Write<T> are not needed and cause JIT failures */
return FALSE;
return TRUE;
}
static gboolean
collect_methods (MonoAotCompile *acfg)
{
int mindex, i;
MonoImage *image = acfg->image;
/* Collect methods */
int rows = table_info_get_rows (&image->tables [MONO_TABLE_METHOD]);
for (i = 0; i < rows; ++i) {
ERROR_DECL (error);
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (i + 1);
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
if (!method) {
aot_printerrf (acfg, "Failed to load method 0x%x from '%s' due to %s.\n", token, image->name, mono_error_get_message (error));
aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
mono_error_cleanup (error);
return FALSE;
}
/* Load all methods eagerly to skip the slower lazy loading code */
mono_class_setup_methods (method->klass);
if (mono_aot_mode_is_full (&acfg->aot_opts) && method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
/* Compile the wrapper instead */
/* We do this here instead of add_wrappers () because it is easy to do it here */
MonoMethod *wrapper = mono_marshal_get_native_wrapper (method, TRUE, TRUE);
method = wrapper;
}
/* FIXME: Some mscorlib methods don't have debug info */
/*
if (acfg->aot_opts.soft_debug && !method->wrapper_type) {
if (!((method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME) ||
(method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
(method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))) {
if (!mono_debug_lookup_method (method)) {
fprintf (stderr, "Method %s has no debug info, probably the .mdb file for the assembly is missing.\n", mono_method_get_full_name (method));
exit (1);
}
}
}
*/
if (method->is_generic || mono_class_is_gtd (method->klass)) {
/* Compile the ref shared version instead */
method = mini_get_shared_method_full (method, SHARE_MODE_NONE, error);
if (!method) {
aot_printerrf (acfg, "Failed to load method 0x%x from '%s' due to %s.\n", token, image->name, mono_error_get_message (error));
aot_printerrf (acfg, "Run with MONO_LOG_LEVEL=debug for more information.\n");
mono_error_cleanup (error);
return FALSE;
}
}
/* Since we add the normal methods first, their index will be equal to their zero based token index */
add_method_with_index (acfg, method, i, FALSE);
acfg->method_index ++;
}
/* gsharedvt methods */
rows = table_info_get_rows (&image->tables [MONO_TABLE_METHOD]);
for (mindex = 0; mindex < rows; ++mindex) {
ERROR_DECL (error);
MonoMethod *method;
guint32 token = MONO_TOKEN_METHOD_DEF | (mindex + 1);
if (!(acfg->jit_opts & MONO_OPT_GSHAREDVT))
continue;
method = mono_get_method_checked (acfg->image, token, NULL, NULL, error);
report_loader_error (acfg, error, TRUE, "Failed to load method token 0x%x due to %s\n", i, mono_error_get_message (error));
if ((method->is_generic || mono_class_is_gtd (method->klass)) && should_emit_gsharedvt_method (acfg, method)) {
MonoMethod *gshared;
gshared = mini_get_shared_method_full (method, SHARE_MODE_GSHAREDVT, error);
mono_error_assert_ok (error);
add_extra_method (acfg, gshared);
}
}
if (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))
add_generic_instances (acfg);
if (mono_aot_mode_is_full (&acfg->aot_opts))
add_wrappers (acfg);
return TRUE;
}
static void
compile_methods (MonoAotCompile *acfg)
{
int i, methods_len;
if (acfg->aot_opts.nthreads > 0) {
GPtrArray *frag;
int len, j;
GPtrArray *threads;
MonoThreadHandle *thread_handle;
gpointer *user_data;
MonoMethod **methods;
methods_len = acfg->methods->len;
len = acfg->methods->len / acfg->aot_opts.nthreads;
g_assert (len > 0);
/*
* Partition the list of methods into fragments, and hand it to threads to
* process.
*/
threads = g_ptr_array_new ();
/* Make a copy since acfg->methods is modified by compile_method () */
methods = g_new0 (MonoMethod*, methods_len);
//memcpy (methods, g_ptr_array_index (acfg->methods, 0), sizeof (MonoMethod*) * methods_len);
for (i = 0; i < methods_len; ++i)
methods [i] = (MonoMethod *)g_ptr_array_index (acfg->methods, i);
i = 0;
while (i < methods_len) {
ERROR_DECL (error);
MonoInternalThread *thread;
frag = g_ptr_array_new ();
for (j = 0; j < len; ++j) {
if (i < methods_len) {
g_ptr_array_add (frag, methods [i]);
i ++;
}
}
user_data = g_new0 (gpointer, 3);
user_data [0] = acfg;
user_data [1] = frag;
thread = mono_thread_create_internal ((MonoThreadStart)compile_thread_main, user_data, MONO_THREAD_CREATE_FLAGS_NONE, error);
mono_error_assert_ok (error);
thread_handle = mono_threads_open_thread_handle (thread->handle);
g_ptr_array_add (threads, thread_handle);
}
g_free (methods);
for (i = 0; i < threads->len; ++i) {
mono_thread_info_wait_one_handle ((MonoThreadHandle*)g_ptr_array_index (threads, i), MONO_INFINITE_WAIT, FALSE);
mono_threads_close_thread_handle ((MonoThreadHandle*)g_ptr_array_index (threads, i));
}
} else {
methods_len = 0;
}
/* Compile methods added by compile_method () or all methods if nthreads == 0 */
for (i = methods_len; i < acfg->methods->len; ++i) {
/* This can add new methods to acfg->methods */
compile_method (acfg, (MonoMethod *)g_ptr_array_index (acfg->methods, i));
}
#ifdef ENABLE_LLVM
if (acfg->llvm)
mono_llvm_fixup_aot_module ();
#endif
}
static int
compile_asm (MonoAotCompile *acfg)
{
char *command, *objfile;
char *outfile_name, *tmp_outfile_name, *llvm_ofile;
const char *tool_prefix = acfg->aot_opts.tool_prefix ? acfg->aot_opts.tool_prefix : "";
char *ld_flags = acfg->aot_opts.ld_flags ? acfg->aot_opts.ld_flags : g_strdup("");
#ifdef TARGET_WIN32_MSVC
#define AS_OPTIONS "--target=x86_64-pc-windows-msvc -c -x assembler"
#elif defined(TARGET_AMD64) && !defined(TARGET_MACH)
#define AS_OPTIONS "--64"
#elif defined(TARGET_POWERPC64)
#define AS_OPTIONS "-a64 -mppc64"
#elif defined(sparc) && TARGET_SIZEOF_VOID_P == 8
#define AS_OPTIONS "-xarch=v9"
#elif defined(TARGET_X86) && defined(TARGET_MACH)
#define AS_OPTIONS "-arch i386"
#elif defined(TARGET_X86) && !defined(TARGET_MACH)
#define AS_OPTIONS "--32"
#elif defined(MONO_ARCH_ENABLE_PTRAUTH)
#define AS_OPTIONS "-arch arm64e"
#else
#define AS_OPTIONS ""
#endif
#if defined(TARGET_OSX)
#define AS_NAME "clang"
#elif defined(TARGET_WIN32_MSVC)
#define AS_NAME "clang.exe"
#else
#define AS_NAME "as"
#endif
#ifdef TARGET_WIN32_MSVC
#define AS_OBJECT_FILE_SUFFIX "obj"
#else
#define AS_OBJECT_FILE_SUFFIX "o"
#endif
#if defined(sparc)
#define LD_NAME "ld"
#define LD_OPTIONS "-shared -G -Bsymbolic"
#elif defined(__ppc__) && defined(TARGET_MACH)
#define LD_NAME "gcc"
#define LD_OPTIONS "-dynamiclib -Wl,-Bsymbolic"
#elif defined(TARGET_AMD64) && defined(TARGET_MACH)
#define LD_NAME "clang"
#define LD_OPTIONS "--shared"
#elif defined(TARGET_ARM64) && defined(TARGET_OSX)
#define LD_NAME "clang"
#if defined(TARGET_OSX) && __has_feature(ptrauth_intrinsics)
#define LD_OPTIONS "--shared -arch arm64e"
#else
#define LD_OPTIONS "--shared"
#endif
#elif defined(TARGET_WIN32_MSVC)
#define LD_NAME "link.exe"
#define LD_OPTIONS "/DLL /MACHINE:X64 /NOLOGO /INCREMENTAL:NO"
#define LD_DEBUG_OPTIONS LD_OPTIONS " /DEBUG"
#elif defined(TARGET_WIN32) && !defined(TARGET_ANDROID)
#define LD_NAME "gcc"
#define LD_OPTIONS "-shared -Wl,-Bsymbolic"
#elif defined(TARGET_X86) && defined(TARGET_MACH)
#define LD_NAME "clang"
#define LD_OPTIONS "-m32 -dynamiclib"
#elif defined(TARGET_X86) && !defined(TARGET_MACH)
#define LD_OPTIONS "-m elf_i386 -Bsymbolic"
#elif defined(TARGET_ARM) && !defined(TARGET_ANDROID)
#define LD_NAME "gcc"
#define LD_OPTIONS "--shared -Wl,-Bsymbolic"
#elif defined(TARGET_POWERPC64)
#define LD_OPTIONS "-m elf64ppc -Bsymbolic"
#endif
#ifndef LD_OPTIONS
#define LD_OPTIONS "-Bsymbolic"
#endif
if (acfg->aot_opts.asm_only) {
aot_printf (acfg, "Output file: '%s'.\n", acfg->tmpfname);
if (acfg->aot_opts.static_link)
aot_printf (acfg, "Linking symbol: '%s'.\n", acfg->static_linking_symbol);
if (acfg->llvm)
aot_printf (acfg, "LLVM output file: '%s'.\n", acfg->llvm_sfile);
return 0;
}
if (acfg->aot_opts.static_link) {
if (acfg->aot_opts.outfile)
objfile = g_strdup_printf ("%s", acfg->aot_opts.outfile);
else
objfile = g_strdup_printf ("%s." AS_OBJECT_FILE_SUFFIX, acfg->image->name);
} else {
objfile = g_strdup_printf ("%s." AS_OBJECT_FILE_SUFFIX, acfg->tmpfname);
}
#ifdef TARGET_OSX
g_string_append (acfg->as_args, "-c -x assembler ");
#endif
command = g_strdup_printf ("\"%s%s\" %s %s -o %s %s", tool_prefix, AS_NAME, AS_OPTIONS,
acfg->as_args ? acfg->as_args->str : "",
wrap_path (objfile), wrap_path (acfg->tmpfname));
aot_printf (acfg, "Executing the native assembler: %s\n", command);
if (execute_system (command) != 0) {
g_free (command);
g_free (objfile);
return 1;
}
if (acfg->llvm && !acfg->llvm_owriter) {
command = g_strdup_printf ("\"%s%s\" %s %s -o %s %s", tool_prefix, AS_NAME, AS_OPTIONS,
acfg->as_args ? acfg->as_args->str : "",
wrap_path (acfg->llvm_ofile), wrap_path (acfg->llvm_sfile));
aot_printf (acfg, "Executing the native assembler: %s\n", command);
if (execute_system (command) != 0) {
g_free (command);
g_free (objfile);
return 1;
}
}
g_free (command);
if (acfg->aot_opts.static_link) {
aot_printf (acfg, "Output file: '%s'.\n", objfile);
aot_printf (acfg, "Linking symbol: '%s'.\n", acfg->static_linking_symbol);
g_free (objfile);
return 0;
}
if (acfg->aot_opts.outfile)
outfile_name = g_strdup_printf ("%s", acfg->aot_opts.outfile);
else
outfile_name = g_strdup_printf ("%s%s", acfg->image->name, MONO_SOLIB_EXT);
tmp_outfile_name = g_strdup_printf ("%s.tmp", outfile_name);
if (acfg->llvm) {
llvm_ofile = g_strdup_printf ("\"%s\"", acfg->llvm_ofile);
} else {
llvm_ofile = g_strdup ("");
}
/* replace the ; flags separators with spaces */
g_strdelimit (ld_flags, ';', ' ');
if (acfg->aot_opts.llvm_only)
ld_flags = g_strdup_printf ("%s %s", ld_flags, "-lstdc++");
#ifdef TARGET_WIN32_MSVC
g_assert (tmp_outfile_name != NULL);
g_assert (objfile != NULL);
command = g_strdup_printf ("\"%s%s\" %s %s /OUT:%s %s %s", tool_prefix, LD_NAME,
acfg->aot_opts.nodebug ? LD_OPTIONS : LD_DEBUG_OPTIONS, ld_flags, wrap_path (tmp_outfile_name), wrap_path (objfile), wrap_path (llvm_ofile));
#else
GString *str;
str = g_string_new ("");
const char *ld_binary_name = acfg->aot_opts.ld_name;
#if defined(LD_NAME)
if (ld_binary_name == NULL) {
ld_binary_name = LD_NAME;
}
g_string_append_printf (str, "%s%s %s", tool_prefix, ld_binary_name, LD_OPTIONS);
#else
if (ld_binary_name == NULL) {
ld_binary_name = "ld";
}
// Default (linux)
if (acfg->aot_opts.tool_prefix)
/* Cross compiling */
g_string_append_printf (str, "\"%s%s\" %s", tool_prefix, ld_binary_name, LD_OPTIONS);
else if (acfg->aot_opts.llvm_only)
g_string_append_printf (str, "%s", acfg->aot_opts.clangxx);
else
g_string_append_printf (str, "\"%s%s\"", tool_prefix, ld_binary_name);
g_string_append_printf (str, " -shared");
#endif
g_string_append_printf (str, " -o %s %s %s %s",
wrap_path (tmp_outfile_name), wrap_path (llvm_ofile),
wrap_path (g_strdup_printf ("%s." AS_OBJECT_FILE_SUFFIX, acfg->tmpfname)), ld_flags);
#if defined(TARGET_MACH)
g_string_append_printf (str, " \"-Wl,-install_name,%s%s\"", g_path_get_basename (acfg->image->name), MONO_SOLIB_EXT);
#endif
command = g_string_free (str, FALSE);
#endif
aot_printf (acfg, "Executing the native linker: %s\n", command);
if (execute_system (command) != 0) {
g_free (tmp_outfile_name);
g_free (outfile_name);
g_free (command);
g_free (objfile);
g_free (ld_flags);
return 1;
}
g_free (command);
/*com = g_strdup_printf ("strip --strip-unneeded %s%s", acfg->image->name, MONO_SOLIB_EXT);
printf ("Stripping the binary: %s\n", com);
execute_system (com);
g_free (com);*/
#if defined(TARGET_ARM) && !defined(TARGET_MACH)
/*
* gas generates 'mapping symbols' each time code and data is mixed, which
* happens a lot in emit_and_reloc_code (), so we need to get rid of them.
*/
command = g_strdup_printf ("\"%sstrip\" --strip-symbol=\\$a --strip-symbol=\\$d %s", tool_prefix, wrap_path(tmp_outfile_name));
aot_printf (acfg, "Stripping the binary: %s\n", command);
if (execute_system (command) != 0) {
g_free (tmp_outfile_name);
g_free (outfile_name);
g_free (command);
g_free (objfile);
return 1;
}
#endif
if (0 != rename (tmp_outfile_name, outfile_name)) {
if (G_FILE_ERROR_EXIST == g_file_error_from_errno (errno)) {
/* Since we are rebuilding the module we need to be able to replace any old copies. Remove old file and retry rename operation. */
unlink (outfile_name);
rename (tmp_outfile_name, outfile_name);
}
}
#if defined(TARGET_MACH)
command = g_strdup_printf ("dsymutil \"%s\"", outfile_name);
aot_printf (acfg, "Executing dsymutil: %s\n", command);
if (execute_system (command) != 0) {
return 1;
}
#endif
if (!acfg->aot_opts.save_temps)
unlink (objfile);
g_free (tmp_outfile_name);
g_free (outfile_name);
g_free (objfile);
if (acfg->aot_opts.save_temps)
aot_printf (acfg, "Retained input file.\n");
else
unlink (acfg->tmpfname);
return 0;
}
static guint8
profread_byte (FILE *infile)
{
guint8 i;
int res;
res = fread (&i, 1, 1, infile);
g_assert (res == 1);
return i;
}
static int
profread_int (FILE *infile)
{
int i, res;
res = fread (&i, 4, 1, infile);
g_assert (res == 1);
return i;
}
static char*
profread_string (FILE *infile)
{
int len, res;
char *pbuf;
len = profread_int (infile);
pbuf = (char*)g_malloc (len + 1);
res = fread (pbuf, 1, len, infile);
g_assert (res == len);
pbuf [len] = '\0';
return pbuf;
}
static void
load_profile_file (MonoAotCompile *acfg, char *filename)
{
FILE *infile;
char buf [1024];
int res, len, version;
char magic [32];
infile = fopen (filename, "rb");
if (!infile) {
fprintf (stderr, "Unable to open file '%s': %s.\n", filename, strerror (errno));
exit (1);
}
printf ("Using profile data file '%s'\n", filename);
sprintf (magic, AOT_PROFILER_MAGIC);
len = strlen (magic);
res = fread (buf, 1, len, infile);
magic [len] = '\0';
buf [len] = '\0';
if ((res != len) || strcmp (buf, magic) != 0) {
printf ("Profile file has wrong header: '%s'.\n", buf);
fclose (infile);
exit (1);
}
guint32 expected_version = (AOT_PROFILER_MAJOR_VERSION << 16) | AOT_PROFILER_MINOR_VERSION;
version = profread_int (infile);
if (version != expected_version) {
printf ("Profile file has wrong version 0x%4x, expected 0x%4x.\n", version, expected_version);
fclose (infile);
exit (1);
}
ProfileData *data = g_new0 (ProfileData, 1);
data->images = g_hash_table_new (NULL, NULL);
data->classes = g_hash_table_new (NULL, NULL);
data->ginsts = g_hash_table_new (NULL, NULL);
data->methods = g_hash_table_new (NULL, NULL);
while (TRUE) {
int type = profread_byte (infile);
int id = profread_int (infile);
if (type == AOTPROF_RECORD_NONE)
break;
switch (type) {
case AOTPROF_RECORD_IMAGE: {
ImageProfileData *idata = g_new0 (ImageProfileData, 1);
idata->name = profread_string (infile);
char *mvid = profread_string (infile);
g_free (mvid);
g_hash_table_insert (data->images, GINT_TO_POINTER (id), idata);
break;
}
case AOTPROF_RECORD_GINST: {
int i;
int len = profread_int (infile);
GInstProfileData *gdata = g_new0 (GInstProfileData, 1);
gdata->argc = len;
gdata->argv = g_new0 (ClassProfileData*, len);
for (i = 0; i < len; ++i) {
int class_id = profread_int (infile);
gdata->argv [i] = (ClassProfileData*)g_hash_table_lookup (data->classes, GINT_TO_POINTER (class_id));
g_assert (gdata->argv [i]);
}
g_hash_table_insert (data->ginsts, GINT_TO_POINTER (id), gdata);
break;
}
case AOTPROF_RECORD_TYPE: {
int type = profread_byte (infile);
switch (type) {
case MONO_TYPE_CLASS: {
int image_id = profread_int (infile);
int ginst_id = profread_int (infile);
char *class_name = profread_string (infile);
ImageProfileData *image = (ImageProfileData*)g_hash_table_lookup (data->images, GINT_TO_POINTER (image_id));
g_assert (image);
char *p = strrchr (class_name, '.');
g_assert (p);
*p = '\0';
ClassProfileData *cdata = g_new0 (ClassProfileData, 1);
cdata->image = image;
cdata->ns = g_strdup (class_name);
cdata->name = g_strdup (p + 1);
if (ginst_id != -1) {
cdata->inst = (GInstProfileData*)g_hash_table_lookup (data->ginsts, GINT_TO_POINTER (ginst_id));
g_assert (cdata->inst);
}
g_free (class_name);
g_hash_table_insert (data->classes, GINT_TO_POINTER (id), cdata);
break;
}
#if 0
case MONO_TYPE_SZARRAY: {
int elem_id = profread_int (infile);
// FIXME:
break;
}
#endif
default:
g_assert_not_reached ();
break;
}
break;
}
case AOTPROF_RECORD_METHOD: {
int class_id = profread_int (infile);
int ginst_id = profread_int (infile);
int param_count = profread_int (infile);
char *method_name = profread_string (infile);
char *sig = profread_string (infile);
ClassProfileData *klass = (ClassProfileData*)g_hash_table_lookup (data->classes, GINT_TO_POINTER (class_id));
g_assert (klass);
MethodProfileData *mdata = g_new0 (MethodProfileData, 1);
mdata->id = id;
mdata->klass = klass;
mdata->name = method_name;
mdata->signature = sig;
mdata->param_count = param_count;
if (ginst_id != -1) {
mdata->inst = (GInstProfileData*)g_hash_table_lookup (data->ginsts, GINT_TO_POINTER (ginst_id));
g_assert (mdata->inst);
}
g_hash_table_insert (data->methods, GINT_TO_POINTER (id), mdata);
break;
}
default:
printf ("%d\n", type);
g_assert_not_reached ();
break;
}
}
fclose (infile);
acfg->profile_data = g_list_append (acfg->profile_data, data);
}
static void
resolve_class (ClassProfileData *cdata);
static void
resolve_ginst (GInstProfileData *inst_data)
{
int i;
if (inst_data->inst)
return;
for (i = 0; i < inst_data->argc; ++i) {
resolve_class (inst_data->argv [i]);
if (!inst_data->argv [i]->klass)
return;
}
MonoType **args = g_new0 (MonoType*, inst_data->argc);
for (i = 0; i < inst_data->argc; ++i)
args [i] = m_class_get_byval_arg (inst_data->argv [i]->klass);
inst_data->inst = mono_metadata_get_generic_inst (inst_data->argc, args);
}
static void
resolve_class (ClassProfileData *cdata)
{
ERROR_DECL (error);
MonoClass *klass;
if (!cdata->image->image)
return;
klass = mono_class_from_name_checked (cdata->image->image, cdata->ns, cdata->name, error);
if (!klass) {
//printf ("[%s] %s.%s\n", cdata->image->name, cdata->ns, cdata->name);
return;
}
if (cdata->inst) {
resolve_ginst (cdata->inst);
if (!cdata->inst->inst)
return;
MonoGenericContext ctx;
memset (&ctx, 0, sizeof (ctx));
ctx.class_inst = cdata->inst->inst;
cdata->klass = mono_class_inflate_generic_class_checked (klass, &ctx, error);
} else {
cdata->klass = klass;
}
}
/*
* Resolve the profile data to the corresponding loaded classes/methods etc. if possible.
*/
static void
resolve_profile_data (MonoAotCompile *acfg, ProfileData *data, MonoAssembly* current)
{
GHashTableIter iter;
gpointer key, value;
int i;
if (!data)
return;
/* Images */
GPtrArray *assemblies = mono_alc_get_all_loaded_assemblies ();
g_hash_table_iter_init (&iter, data->images);
while (g_hash_table_iter_next (&iter, &key, &value)) {
ImageProfileData *idata = (ImageProfileData*)value;
if (!strcmp (current->aname.name, idata->name)) {
idata->image = current->image;
continue;
}
for (i = 0; i < assemblies->len; ++i) {
MonoAssembly *ass = (MonoAssembly*)g_ptr_array_index (assemblies, i);
if (!strcmp (ass->aname.name, idata->name)) {
idata->image = ass->image;
break;
}
}
}
g_ptr_array_free (assemblies, TRUE);
/* Classes */
g_hash_table_iter_init (&iter, data->classes);
while (g_hash_table_iter_next (&iter, &key, &value)) {
ClassProfileData *cdata = (ClassProfileData*)value;
if (!cdata->image->image) {
if (acfg->aot_opts.verbose)
printf ("Unable to load class '%s.%s' because its image '%s' is not loaded.\n", cdata->ns, cdata->name, cdata->image->name);
continue;
}
resolve_class (cdata);
/*
if (cdata->klass)
printf ("%s %s %s\n", cdata->ns, cdata->name, mono_class_full_name (cdata->klass));
*/
}
/* Methods */
g_hash_table_iter_init (&iter, data->methods);
while (g_hash_table_iter_next (&iter, &key, &value)) {
MethodProfileData *mdata = (MethodProfileData*)value;
MonoClass *klass;
MonoMethod *m;
gpointer miter;
resolve_class (mdata->klass);
klass = mdata->klass->klass;
if (!klass) {
if (acfg->aot_opts.verbose)
printf ("Unable to load method '%s' because its class '%s.%s' is not loaded.\n", mdata->name, mdata->klass->ns, mdata->klass->name);
continue;
}
miter = NULL;
while ((m = mono_class_get_methods (klass, &miter))) {
ERROR_DECL (error);
if (strcmp (m->name, mdata->name))
continue;
MonoMethodSignature *sig = mono_method_signature_internal (m);
if (!sig)
continue;
if (sig->param_count != mdata->param_count)
continue;
if (mdata->inst) {
resolve_ginst (mdata->inst);
if (!mdata->inst->inst)
continue;
MonoGenericContext ctx;
memset (&ctx, 0, sizeof (ctx));
ctx.method_inst = mdata->inst->inst;
m = mono_class_inflate_generic_method_checked (m, &ctx, error);
if (!m)
continue;
sig = mono_method_signature_checked (m, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
continue;
}
}
char *sig_str = mono_signature_full_name (sig);
gboolean match = !strcmp (sig_str, mdata->signature);
g_free (sig_str);
if (!match)
continue;
//printf ("%s\n", mono_method_full_name (m, 1));
mdata->method = m;
break;
}
if (!mdata->method) {
if (acfg->aot_opts.verbose)
printf ("Unable to load method '%s' from class '%s', not found.\n", mdata->name, mono_class_full_name (klass));
}
}
}
static gboolean
inst_references_image (MonoGenericInst *inst, MonoImage *image)
{
int i;
for (i = 0; i < inst->type_argc; ++i) {
MonoClass *k = mono_class_from_mono_type_internal (inst->type_argv [i]);
if (m_class_get_image (k) == image)
return TRUE;
if (mono_class_is_ginst (k)) {
MonoGenericInst *kinst = mono_class_get_context (k)->class_inst;
if (inst_references_image (kinst, image))
return TRUE;
}
}
return FALSE;
}
static gboolean
is_local_inst (MonoGenericInst *inst, MonoImage *image)
{
int i;
for (i = 0; i < inst->type_argc; ++i) {
MonoClass *k = mono_class_from_mono_type_internal (inst->type_argv [i]);
if (!MONO_TYPE_IS_PRIMITIVE (inst->type_argv [i]) && m_class_get_image (k) != image)
return FALSE;
}
return TRUE;
}
static void
add_profile_method (MonoAotCompile *acfg, MonoMethod *m)
{
g_hash_table_insert (acfg->profile_methods, m, m);
add_extra_method (acfg, m);
}
static void
add_profile_instances (MonoAotCompile *acfg, ProfileData *data)
{
GHashTableIter iter;
gpointer key, value;
int count = 0;
if (!data)
return;
if (acfg->aot_opts.profile_only) {
/* Add methods referenced by the profile */
g_hash_table_iter_init (&iter, data->methods);
while (g_hash_table_iter_next (&iter, &key, &value)) {
MethodProfileData *mdata = (MethodProfileData*)value;
MonoMethod *m = mdata->method;
if (!m)
continue;
if (m->is_inflated)
continue;
if (m_class_get_image (m->klass) != acfg->image)
continue;
add_profile_method (acfg, m);
count ++;
}
}
/*
* Add method instances 'related' to this assembly to the AOT image.
*/
g_hash_table_iter_init (&iter, data->methods);
while (g_hash_table_iter_next (&iter, &key, &value)) {
MethodProfileData *mdata = (MethodProfileData*)value;
MonoMethod *m = mdata->method;
MonoGenericContext *ctx;
if (!m)
continue;
if (!m->is_inflated)
continue;
if (mono_method_is_generic_sharable_full (m, FALSE, FALSE, FALSE))
continue;
if (acfg->aot_opts.dedup_include) {
/* Add all instances from the profile */
add_profile_method (acfg, m);
count ++;
} else {
ctx = mono_method_get_context (m);
/* For simplicity, add instances which reference the assembly we are compiling */
if (((ctx->class_inst && inst_references_image (ctx->class_inst, acfg->image)) ||
(ctx->method_inst && inst_references_image (ctx->method_inst, acfg->image)))) {
//printf ("%s\n", mono_method_full_name (m, TRUE));
add_profile_method (acfg, m);
count ++;
} else if (m_class_get_image (m->klass) == acfg->image &&
((ctx->class_inst && is_local_inst (ctx->class_inst, acfg->image)) ||
(ctx->method_inst && is_local_inst (ctx->method_inst, acfg->image)))) {
/* Add instances where the gtd is in the assembly and its inflated with types from this assembly or corlib */
//printf ("%s\n", mono_method_full_name (m, TRUE));
add_profile_method (acfg, m);
count ++;
} else {
//printf ("SKIP: %s (%s)\n", mono_method_get_full_name (m), acfg->image->name);
}
/*
* FIXME: We might skip some instances, for example:
* Foo<Bar> won't be compiled when compiling Foo's assembly since it doesn't match the first case,
* and it won't be compiled when compiling Bar's assembly if Foo's assembly is not loaded.
*/
}
}
printf ("Added %d methods from profile.\n", count);
}
static void
init_got_info (GotInfo *info)
{
int i;
info->patch_to_got_offset = g_hash_table_new (mono_patch_info_hash, mono_patch_info_equal);
info->patch_to_got_offset_by_type = g_new0 (GHashTable*, MONO_PATCH_INFO_NUM);
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i)
info->patch_to_got_offset_by_type [i] = g_hash_table_new (mono_patch_info_hash, mono_patch_info_equal);
info->got_patches = g_ptr_array_new ();
}
static MonoAotCompile*
acfg_create (MonoAssembly *ass, guint32 jit_opts)
{
MonoImage *image = ass->image;
MonoAotCompile *acfg;
acfg = g_new0 (MonoAotCompile, 1);
acfg->methods = g_ptr_array_new ();
acfg->method_indexes = g_hash_table_new (NULL, NULL);
acfg->method_depth = g_hash_table_new (NULL, NULL);
acfg->plt_offset_to_entry = g_hash_table_new (NULL, NULL);
acfg->patch_to_plt_entry = g_new0 (GHashTable*, MONO_PATCH_INFO_NUM);
acfg->method_to_cfg = g_hash_table_new (NULL, NULL);
acfg->token_info_hash = g_hash_table_new_full (NULL, NULL, NULL, NULL);
acfg->method_to_pinvoke_import = g_hash_table_new_full (NULL, NULL, NULL, g_free);
acfg->method_to_external_icall_symbol_name = g_hash_table_new_full (NULL, NULL, NULL, g_free);
acfg->image_hash = g_hash_table_new (NULL, NULL);
acfg->image_table = g_ptr_array_new ();
acfg->globals = g_ptr_array_new ();
acfg->image = image;
acfg->jit_opts = jit_opts;
acfg->mempool = mono_mempool_new ();
acfg->extra_methods = g_ptr_array_new ();
acfg->unwind_info_offsets = g_hash_table_new (NULL, NULL);
acfg->unwind_ops = g_ptr_array_new ();
acfg->method_label_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
acfg->method_order = g_ptr_array_new ();
acfg->export_names = g_hash_table_new (NULL, NULL);
acfg->klass_blob_hash = g_hash_table_new (NULL, NULL);
acfg->method_blob_hash = g_hash_table_new (NULL, NULL);
acfg->ginst_blob_hash = g_hash_table_new (mono_metadata_generic_inst_hash, mono_metadata_generic_inst_equal);
acfg->plt_entry_debug_sym_cache = g_hash_table_new (g_str_hash, g_str_equal);
acfg->gsharedvt_in_signatures = g_hash_table_new ((GHashFunc)mono_signature_hash, (GEqualFunc)mono_metadata_signature_equal);
acfg->gsharedvt_out_signatures = g_hash_table_new ((GHashFunc)mono_signature_hash, (GEqualFunc)mono_metadata_signature_equal);
acfg->profile_methods = g_hash_table_new (NULL, NULL);
mono_os_mutex_init_recursive (&acfg->mutex);
init_got_info (&acfg->got_info);
init_got_info (&acfg->llvm_got_info);
method_to_external_icall_symbol_name = acfg->method_to_external_icall_symbol_name;
return acfg;
}
static void
got_info_free (GotInfo *info)
{
int i;
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i)
g_hash_table_destroy (info->patch_to_got_offset_by_type [i]);
g_free (info->patch_to_got_offset_by_type);
g_hash_table_destroy (info->patch_to_got_offset);
g_ptr_array_free (info->got_patches, TRUE);
}
static void
acfg_free (MonoAotCompile *acfg)
{
int i;
mono_img_writer_destroy (acfg->w);
for (i = 0; i < acfg->nmethods; ++i)
if (acfg->cfgs [i])
mono_destroy_compile (acfg->cfgs [i]);
g_free (acfg->cfgs);
g_free (acfg->static_linking_symbol);
g_free (acfg->got_symbol);
g_free (acfg->plt_symbol);
g_ptr_array_free (acfg->methods, TRUE);
g_ptr_array_free (acfg->image_table, TRUE);
g_ptr_array_free (acfg->globals, TRUE);
g_ptr_array_free (acfg->unwind_ops, TRUE);
g_hash_table_destroy (acfg->method_indexes);
g_hash_table_destroy (acfg->method_depth);
g_hash_table_destroy (acfg->plt_offset_to_entry);
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i)
g_hash_table_destroy (acfg->patch_to_plt_entry [i]);
g_free (acfg->patch_to_plt_entry);
g_hash_table_destroy (acfg->method_to_cfg);
g_hash_table_destroy (acfg->token_info_hash);
g_hash_table_destroy (acfg->method_to_pinvoke_import);
g_hash_table_destroy (acfg->method_to_external_icall_symbol_name);
g_hash_table_destroy (acfg->image_hash);
g_hash_table_destroy (acfg->unwind_info_offsets);
g_hash_table_destroy (acfg->method_label_hash);
g_hash_table_destroy (acfg->typespec_classes);
g_hash_table_destroy (acfg->export_names);
g_hash_table_destroy (acfg->plt_entry_debug_sym_cache);
g_hash_table_destroy (acfg->klass_blob_hash);
g_hash_table_destroy (acfg->method_blob_hash);
got_info_free (&acfg->got_info);
got_info_free (&acfg->llvm_got_info);
arch_free_unwind_info_section_cache (acfg);
mono_mempool_destroy (acfg->mempool);
method_to_external_icall_symbol_name = NULL;
g_free (acfg);
}
#define WRAPPER(e,n) n,
static const char* const
wrapper_type_names [MONO_WRAPPER_NUM + 1] = {
#include "mono/metadata/wrapper-types.h"
NULL
};
static G_GNUC_UNUSED const char*
get_wrapper_type_name (int type)
{
return wrapper_type_names [type];
}
//#define DUMP_PLT
//#define DUMP_GOT
static void aot_dump (MonoAotCompile *acfg)
{
FILE *dumpfile;
char * dumpname;
JsonWriter writer;
mono_json_writer_init (&writer);
mono_json_writer_object_begin(&writer);
// Methods
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "methods");
mono_json_writer_array_begin (&writer);
int i;
for (i = 0; i < acfg->nmethods; ++i) {
MonoCompile *cfg;
MonoMethod *method;
MonoClass *klass;
cfg = acfg->cfgs [i];
if (ignore_cfg (cfg))
continue;
method = cfg->orig_method;
mono_json_writer_indent (&writer);
mono_json_writer_object_begin(&writer);
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "name");
mono_json_writer_printf (&writer, "\"%s\",\n", method->name);
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "signature");
mono_json_writer_printf (&writer, "\"%s\",\n", mono_method_get_full_name (method));
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "code_size");
mono_json_writer_printf (&writer, "\"%d\",\n", cfg->code_size);
klass = method->klass;
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "class");
mono_json_writer_printf (&writer, "\"%s\",\n", m_class_get_name (klass));
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "namespace");
mono_json_writer_printf (&writer, "\"%s\",\n", m_class_get_name_space (klass));
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "wrapper_type");
mono_json_writer_printf (&writer, "\"%s\",\n", get_wrapper_type_name(method->wrapper_type));
mono_json_writer_indent_pop (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_object_end (&writer);
mono_json_writer_printf (&writer, ",\n");
}
mono_json_writer_indent_pop (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_array_end (&writer);
mono_json_writer_printf (&writer, ",\n");
// PLT entries
#ifdef DUMP_PLT
mono_json_writer_indent_push (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "plt");
mono_json_writer_array_begin (&writer);
for (i = 0; i < acfg->plt_offset; ++i) {
MonoPltEntry *plt_entry = NULL;
MonoJumpInfo *ji;
if (i == 0)
/*
* The first plt entry is unused.
*/
continue;
plt_entry = g_hash_table_lookup (acfg->plt_offset_to_entry, GUINT_TO_POINTER (i));
ji = plt_entry->ji;
mono_json_writer_indent (&writer);
mono_json_writer_printf (&writer, "{ ");
mono_json_writer_object_key(&writer, "symbol");
mono_json_writer_printf (&writer, "\"%s\" },\n", plt_entry->symbol);
}
mono_json_writer_indent_pop (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_array_end (&writer);
mono_json_writer_printf (&writer, ",\n");
#endif
// GOT entries
#ifdef DUMP_GOT
mono_json_writer_indent_push (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_object_key(&writer, "got");
mono_json_writer_array_begin (&writer);
mono_json_writer_indent_push (&writer);
for (i = 0; i < acfg->got_info.got_patches->len; ++i) {
MonoJumpInfo *ji = g_ptr_array_index (acfg->got_info.got_patches, i);
mono_json_writer_indent (&writer);
mono_json_writer_printf (&writer, "{ ");
mono_json_writer_object_key(&writer, "patch_name");
mono_json_writer_printf (&writer, "\"%s\" },\n", get_patch_name (ji->type));
}
mono_json_writer_indent_pop (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_array_end (&writer);
mono_json_writer_printf (&writer, ",\n");
#endif
mono_json_writer_indent_pop (&writer);
mono_json_writer_indent (&writer);
mono_json_writer_object_end (&writer);
dumpname = g_strdup_printf ("%s.json", g_path_get_basename (acfg->image->name));
dumpfile = fopen (dumpname, "w+");
g_free (dumpname);
fprintf (dumpfile, "%s", writer.text->str);
fclose (dumpfile);
mono_json_writer_destroy (&writer);
}
static const MonoJitICallId preinited_jit_icalls [] = {
MONO_JIT_ICALL_mini_llvm_init_method,
MONO_JIT_ICALL_mini_llvmonly_throw_nullref_exception,
MONO_JIT_ICALL_mono_llvm_throw_corlib_exception,
MONO_JIT_ICALL_mono_threads_state_poll,
MONO_JIT_ICALL_mini_llvmonly_init_vtable_slot,
MONO_JIT_ICALL_mono_helper_ldstr_mscorlib,
MONO_JIT_ICALL_mono_fill_method_rgctx,
MONO_JIT_ICALL_mono_fill_class_rgctx
};
static void
add_preinit_slot (MonoAotCompile *acfg, MonoJumpInfo *ji)
{
if (!acfg->aot_opts.llvm_only)
get_got_offset (acfg, FALSE, ji);
get_got_offset (acfg, TRUE, ji);
}
static void
add_preinit_got_slots (MonoAotCompile *acfg)
{
MonoJumpInfo *ji;
int i;
/*
* Allocate the first few GOT entries to information which is needed frequently, or it is needed
* during method initialization etc.
*/
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_IMAGE;
ji->data.image = acfg->image;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_MSCORLIB_GOT_ADDR;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_GC_CARD_TABLE_ADDR;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_GC_NURSERY_START;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_AOT_MODULE;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_GC_NURSERY_BITS;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_INTERRUPTION_REQUEST_FLAG;
add_preinit_slot (acfg, ji);
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_GC_SAFE_POINT_FLAG;
add_preinit_slot (acfg, ji);
if (!acfg->aot_opts.llvm_only) {
for (i = 0; i < TLS_KEY_NUM; i++) {
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL;
ji->data.jit_icall_id = mono_get_tls_key_to_jit_icall_id (i);
add_preinit_slot (acfg, ji);
}
}
/* Called by native-to-managed wrappers on possibly unattached threads */
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_JIT_ICALL_ADDR_NOCALL;
ji->data.jit_icall_id = MONO_JIT_ICALL_mono_threads_attach_coop;
add_preinit_slot (acfg, ji);
for (i = 0; i < G_N_ELEMENTS (preinited_jit_icalls); ++i) {
ji = (MonoJumpInfo *)mono_mempool_alloc0 (acfg->mempool, sizeof (MonoJumpInfo));
ji->type = MONO_PATCH_INFO_JIT_ICALL_ID;
ji->data.jit_icall_id = preinited_jit_icalls [i];
add_preinit_slot (acfg, ji);
}
if (acfg->aot_opts.llvm_only)
acfg->nshared_got_entries = acfg->llvm_got_offset;
else
acfg->nshared_got_entries = acfg->got_offset;
g_assert (acfg->nshared_got_entries);
}
static void
mono_dedup_log_stats (MonoAotCompile *acfg)
{
GHashTableIter iter;
g_assert (acfg->dedup_stats);
if (!acfg->dedup_emit_mode)
return;
// If dedup_emit_mode, acfg is the dummy dedup module that consolidates
// deduped modules
g_hash_table_iter_init (&iter, acfg->method_to_cfg);
MonoCompile *dcfg = NULL;
MonoMethod *method = NULL;
size_t wrappers_size_saved = 0;
size_t inflated_size_saved = 0;
size_t copied_singles = 0;
int wrappers_saved = 0;
int instances_saved = 0;
int copied = 0;
while (g_hash_table_iter_next (&iter, (gpointer *) &method, (gpointer *)&dcfg)) {
gchar *dedup_name = mono_aot_get_mangled_method_name (method);
guint count = GPOINTER_TO_UINT(g_hash_table_lookup (acfg->dedup_stats, dedup_name));
if (count == 0)
continue;
if (acfg->dedup_emit_mode) {
// Size *saved* is the size due to things not emitted.
if (count < 2) {
// Just moved, didn't save space / dedup
copied ++;
copied_singles += dcfg->code_len;
} else if (method->wrapper_type != MONO_WRAPPER_NONE) {
wrappers_saved ++;
wrappers_size_saved += dcfg->code_len * (count - 1);
} else {
instances_saved ++;
inflated_size_saved += dcfg->code_len * (count - 1);
}
}
if (acfg->aot_opts.dedup) {
if (method->wrapper_type != MONO_WRAPPER_NONE) {
wrappers_saved ++;
wrappers_size_saved += dcfg->code_len * count;
} else {
instances_saved ++;
inflated_size_saved += dcfg->code_len * count;
}
}
}
aot_printf (acfg, "Dedup Pass: Size Saved From Deduped Wrappers:\t%d methods, %" G_GSIZE_FORMAT "u bytes\n", wrappers_saved, wrappers_size_saved);
aot_printf (acfg, "Dedup Pass: Size Saved From Inflated Methods:\t%d methods, %" G_GSIZE_FORMAT "u bytes\n", instances_saved, inflated_size_saved);
if (acfg->dedup_emit_mode)
aot_printf (acfg, "Dedup Pass: Size of Moved But Not Deduped (only 1 copy) Methods:\t%d methods, %" G_GSIZE_FORMAT "u bytes\n", copied, copied_singles);
g_hash_table_destroy (acfg->dedup_stats);
acfg->dedup_stats = NULL;
}
// Flush the cache to tell future calls what to skip
static void
mono_flush_method_cache (MonoAotCompile *acfg)
{
GHashTable *method_cache = acfg->dedup_cache;
char *filename = g_strdup_printf ("%s.dedup", acfg->image->name);
if (!acfg->dedup_cache_changed || !acfg->aot_opts.dedup) {
g_free (filename);
return;
}
acfg->dedup_cache = NULL;
FILE *cache = fopen (filename, "w");
if (!cache)
g_error ("Could not create cache at %s because of error: %s\n", filename, strerror (errno));
GHashTableIter iter;
gchar *name = NULL;
g_hash_table_iter_init (&iter, method_cache);
gboolean cont = TRUE;
while (cont && g_hash_table_iter_next (&iter, (gpointer *) &name, NULL)) {
int res = fprintf (cache, "%s\n", name);
cont = res >= 0;
}
// FIXME: don't assert if error when flushing
g_assert (cont);
fclose (cache);
g_free (filename);
// The keys are all in the imageset, nothing to free
// Values are just pointers to memory owned elsewhere, or sentinels
g_hash_table_destroy (method_cache);
}
// Read in what has been emitted by previous invocations,
// what can be skipped
static void
mono_read_method_cache (MonoAotCompile *acfg)
{
char *filename = g_strdup_printf ("%s.dedup", acfg->image->name);
// Only do once, when dedup_cache is null
if (acfg->dedup_cache)
goto early_exit;
if (acfg->aot_opts.dedup_include || acfg->aot_opts.dedup)
g_assert (acfg->dedup_stats);
// only in skip mode
if (!acfg->aot_opts.dedup)
goto early_exit;
g_assert (acfg->dedup_cache);
FILE *cache;
cache = fopen (filename, "r");
if (!cache)
goto early_exit;
// Since we do pointer comparisons, and it can't be allocated at
// the address 0x1 due to alignment, we use this as a sentinel
gpointer other_acfg_sentinel;
other_acfg_sentinel = GINT_TO_POINTER (0x1);
if (fseek (cache, 0L, SEEK_END))
goto cleanup;
size_t fileLength;
fileLength = ftell (cache);
g_assert (fileLength > 0);
if (fseek (cache, 0L, SEEK_SET))
goto cleanup;
// Avoid thousands of new malloc entries
// FIXME: allocate into imageset, so we don't need to free.
// put the other mangled names there too.
char *bulk;
bulk = g_malloc0 (fileLength * sizeof (char));
size_t offset;
offset = 0;
while (fgets (&bulk [offset], fileLength - offset, cache)) {
// strip newline
char *line = &bulk [offset];
size_t len = strlen (line);
if (len == 0)
break;
if (len >= 0 && line [len] == '\n')
line [len] = '\0';
offset += strlen (line) + 1;
g_assert (fileLength >= offset);
g_hash_table_insert (acfg->dedup_cache, line, other_acfg_sentinel);
}
cleanup:
fclose (cache);
early_exit:
g_free (filename);
return;
}
typedef struct {
GHashTable *cache;
GHashTable *stats;
gboolean emit_inflated_methods;
MonoAssembly *inflated_assembly;
} MonoAotState;
static MonoAotState *
alloc_aot_state (void)
{
MonoAotState *state = g_malloc (sizeof (MonoAotState));
// FIXME: Should this own the memory?
state->cache = g_hash_table_new (g_str_hash, g_str_equal);
state->stats = g_hash_table_new (g_str_hash, g_str_equal);
// Start in "collect mode"
state->emit_inflated_methods = FALSE;
state->inflated_assembly = NULL;
return state;
}
static void
free_aot_state (MonoAotState *astate)
{
g_hash_table_destroy (astate->cache);
g_free (astate);
}
static void
mono_add_deferred_extra_methods (MonoAotCompile *acfg, MonoAotState *astate)
{
GHashTableIter iter;
gchar *name = NULL;
MonoMethod *method = NULL;
acfg->dedup_emit_mode = TRUE;
g_hash_table_iter_init (&iter, astate->cache);
while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &method)) {
add_method_full (acfg, method, TRUE, 0);
}
return;
}
static void
mono_setup_dedup_state (MonoAotCompile *acfg, MonoAotState **global_aot_state, MonoAssembly *ass, MonoAotState **astate, gboolean *is_dedup_dummy)
{
if (!acfg->aot_opts.dedup_include && !acfg->aot_opts.dedup)
return;
if (global_aot_state && *global_aot_state && acfg->aot_opts.dedup_include) {
// Thread the state through when making the inflate pass
*astate = *global_aot_state;
}
if (!*astate) {
*astate = alloc_aot_state ();
*global_aot_state = *astate;
}
acfg->dedup_cache = (*astate)->cache;
acfg->dedup_stats = (*astate)->stats;
// fills out acfg->dedup_cache
if (acfg->aot_opts.dedup)
mono_read_method_cache (acfg);
if (!(*astate)->inflated_assembly && acfg->aot_opts.dedup_include) {
gchar **asm_path = g_strsplit (ass->image->name, G_DIR_SEPARATOR_S, 0);
gchar *asm_file = NULL;
// Get the last part of the path, the filename
for (int i=0; asm_path [i] != NULL; i++)
asm_file = asm_path [i];
if (!strcmp (acfg->aot_opts.dedup_include, asm_file)) {
// Save
*is_dedup_dummy = TRUE;
(*astate)->inflated_assembly = ass;
}
g_strfreev (asm_path);
} else if ((*astate)->inflated_assembly) {
*is_dedup_dummy = (ass == (*astate)->inflated_assembly);
}
}
int
mono_compile_deferred_assemblies (guint32 opts, const char *aot_options, gpointer **aot_state)
{
// create assembly, loop and add extra_methods
// in add_generic_instances , rip out what's in that for loop
// and apply that to this aot_state inside of mono_compile_assembly
MonoAotState *astate;
astate = *(MonoAotState **)aot_state;
g_assert (astate);
// FIXME: allow suffixes?
if (!astate->inflated_assembly) {
const char* inflate = strstr (aot_options, "dedup-inflate");
if (!inflate)
return 0;
else
g_error ("Error: mono was not given an assembly with the provided inflate name\n");
}
// Switch modes
astate->emit_inflated_methods = TRUE;
int res = mono_compile_assembly (astate->inflated_assembly, opts, aot_options, aot_state);
*aot_state = NULL;
free_aot_state (astate);
return res;
}
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
static MonoMethodSignature * const * const interp_in_static_sigs [] = {
&mono_icall_sig_bool_ptr_int32_ptrref,
&mono_icall_sig_bool_ptr_ptrref,
&mono_icall_sig_int32_int32_ptrref,
&mono_icall_sig_int32_int32_ptr_ptrref,
&mono_icall_sig_int32_ptr_int32_ptr,
&mono_icall_sig_int32_ptr_int32_ptrref,
&mono_icall_sig_int32_ptr_ptrref,
&mono_icall_sig_object_object_ptr_ptr_ptr,
&mono_icall_sig_object,
&mono_icall_sig_ptr_int32_ptrref,
&mono_icall_sig_ptr_ptr_int32_ptr_ptr_ptrref,
&mono_icall_sig_ptr_ptr_int32_ptr_ptrref,
&mono_icall_sig_ptr_ptr_int32_ptrref,
&mono_icall_sig_ptr_ptr_ptr_int32_ptrref,
&mono_icall_sig_ptr_ptr_ptr_ptrref_ptrref,
&mono_icall_sig_ptr_ptr_ptr_ptr_ptrref,
&mono_icall_sig_ptr_ptr_ptr_ptrref,
&mono_icall_sig_ptr_ptr_ptrref,
&mono_icall_sig_ptr_ptr_uint32_ptrref,
&mono_icall_sig_ptr_uint32_ptrref,
&mono_icall_sig_void_object_ptr_ptr_ptr,
&mono_icall_sig_void_ptr_ptr_int32_ptr_ptrref_ptr_ptrref,
&mono_icall_sig_void_ptr_ptr_int32_ptr_ptrref,
&mono_icall_sig_void_ptr_ptr_ptrref,
&mono_icall_sig_void_ptr_ptrref,
&mono_icall_sig_void_ptr,
&mono_icall_sig_void_int32_ptrref,
&mono_icall_sig_void_uint32_ptrref,
&mono_icall_sig_void,
};
#else
// Common signatures for which we use interp in wrappers even in fullaot + trampolines mode
// for increased performance
static MonoMethodSignature *const * const interp_in_static_common_sigs [] = {
&mono_icall_sig_void,
&mono_icall_sig_ptr,
&mono_icall_sig_void_ptr,
&mono_icall_sig_ptr_ptr,
&mono_icall_sig_void_ptr_ptr,
&mono_icall_sig_ptr_ptr_ptr,
&mono_icall_sig_void_ptr_ptr_ptr,
&mono_icall_sig_ptr_ptr_ptr_ptr,
&mono_icall_sig_void_ptr_ptr_ptr_ptr,
&mono_icall_sig_ptr_ptr_ptr_ptr_ptr,
&mono_icall_sig_void_ptr_ptr_ptr_ptr_ptr,
&mono_icall_sig_ptr_ptr_ptr_ptr_ptr_ptr,
&mono_icall_sig_void_ptr_ptr_ptr_ptr_ptr_ptr,
&mono_icall_sig_ptr_ptr_ptr_ptr_ptr_ptr_ptr,
};
#endif
static void
add_interp_in_wrapper_for_sig (MonoAotCompile *acfg, MonoMethodSignature *sig)
{
MonoMethod *wrapper;
sig = mono_metadata_signature_dup_full (mono_get_corlib (), sig);
sig->pinvoke = FALSE;
wrapper = mini_get_interp_in_wrapper (sig);
add_method (acfg, wrapper);
}
int
mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options, gpointer **global_aot_state)
{
MonoImage *image = ass->image;
int res;
MonoAotCompile *acfg;
char *p;
TV_DECLARE (atv);
TV_DECLARE (btv);
acfg = acfg_create (ass, opts);
memset (&acfg->aot_opts, 0, sizeof (acfg->aot_opts));
acfg->aot_opts.write_symbols = TRUE;
acfg->aot_opts.ntrampolines = 4096;
acfg->aot_opts.nrgctx_trampolines = 4096;
acfg->aot_opts.nimt_trampolines = 512;
acfg->aot_opts.nrgctx_fetch_trampolines = 128;
acfg->aot_opts.ngsharedvt_arg_trampolines = 512;
#ifdef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
acfg->aot_opts.nftnptr_arg_trampolines = 128;
#endif
acfg->aot_opts.nunbox_arbitrary_trampolines = 256;
if (!acfg->aot_opts.llvm_path)
acfg->aot_opts.llvm_path = g_strdup ("");
acfg->aot_opts.temp_path = g_strdup ("");
#if defined(MONOTOUCH)&& !defined(TARGET_AMD64)
acfg->aot_opts.use_trampolines_page = TRUE;
#endif
acfg->aot_opts.clangxx = g_strdup ("clang++");
mono_aot_parse_options (aot_options, &acfg->aot_opts);
if (acfg->aot_opts.direct_extern_calls && !(acfg->aot_opts.llvm && acfg->aot_opts.static_link)) {
aot_printerrf (acfg, "The 'direct-extern-calls' option requires the 'llvm' and 'static' options.\n");
return 1;
}
// start dedup
MonoAotState *astate = NULL;
gboolean is_dedup_dummy = FALSE;
mono_setup_dedup_state (acfg, (MonoAotState **) global_aot_state, ass, &astate, &is_dedup_dummy);
// Process later
if (is_dedup_dummy && astate && !astate->emit_inflated_methods)
return 0;
if (acfg->aot_opts.dedup_include && !is_dedup_dummy)
acfg->dedup_collect_only = TRUE;
// end dedup
if (acfg->aot_opts.logfile) {
acfg->logfile = fopen (acfg->aot_opts.logfile, "a+");
}
if (acfg->aot_opts.data_outfile) {
acfg->data_outfile = fopen (acfg->aot_opts.data_outfile, "w+");
if (!acfg->data_outfile) {
aot_printerrf (acfg, "Unable to create file '%s': %s\n", acfg->aot_opts.data_outfile, strerror (errno));
return 1;
}
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_SEPARATE_DATA);
}
//acfg->aot_opts.print_skipped_methods = TRUE;
#if !defined(MONO_ARCH_GSHAREDVT_SUPPORTED)
if (acfg->jit_opts & MONO_OPT_GSHAREDVT) {
aot_printerrf (acfg, "-O=gsharedvt not supported on this platform.\n");
return 1;
}
if (acfg->aot_opts.llvm_only) {
aot_printerrf (acfg, "--aot=llvmonly requires a runtime that supports gsharedvt.\n");
return 1;
}
#else
if (acfg->aot_opts.llvm_only) {
if (!mono_aot_mode_is_interp (&acfg->aot_opts))
acfg->jit_opts |= MONO_OPT_GSHAREDVT;
} else if (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))
acfg->jit_opts |= MONO_OPT_GSHAREDVT;
#endif
#if !defined(ENABLE_LLVM)
if (acfg->aot_opts.llvm_only) {
aot_printerrf (acfg, "--aot=llvmonly requires a runtime compiled with llvm support.\n");
return 1;
}
if (mono_use_llvm || acfg->aot_opts.llvm) {
aot_printerrf (acfg, "--aot=llvm requires a runtime compiled with llvm support.\n");
return 1;
}
#endif
if (acfg->jit_opts & MONO_OPT_GSHAREDVT)
mono_set_generic_sharing_vt_supported (TRUE);
if (!acfg->dedup_collect_only)
aot_printf (acfg, "Mono Ahead of Time compiler - compiling assembly %s\n", image->name);
if (!acfg->aot_opts.deterministic)
generate_aotid ((guint8*) &acfg->image->aotid);
char *aotid = mono_guid_to_string (acfg->image->aotid);
if (!acfg->dedup_collect_only && !acfg->aot_opts.deterministic)
aot_printf (acfg, "AOTID %s\n", aotid);
g_free (aotid);
#ifndef MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES
if (mono_aot_mode_is_full (&acfg->aot_opts)) {
aot_printerrf (acfg, "--aot=full is not supported on this platform.\n");
return 1;
}
#endif
if (acfg->aot_opts.direct_pinvoke && !acfg->aot_opts.static_link) {
aot_printerrf (acfg, "The 'direct-pinvoke' AOT option also requires the 'static' AOT option.\n");
return 1;
}
if (acfg->aot_opts.static_link)
acfg->aot_opts.asm_writer = TRUE;
if (acfg->aot_opts.soft_debug) {
mini_debug_options.mdb_optimizations = TRUE;
mini_debug_options.gen_sdb_seq_points = TRUE;
if (!mono_debug_enabled ()) {
aot_printerrf (acfg, "The soft-debug AOT option requires the --debug option.\n");
return 1;
}
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_DEBUG);
}
if (acfg->aot_opts.try_llvm)
acfg->aot_opts.llvm = mini_llvm_init ();
if (mono_use_llvm || acfg->aot_opts.llvm) {
acfg->llvm = TRUE;
acfg->aot_opts.asm_writer = TRUE;
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_WITH_LLVM);
if (acfg->aot_opts.soft_debug) {
aot_printerrf (acfg, "The 'soft-debug' option is not supported when compiling with LLVM.\n");
return 1;
}
mini_llvm_init ();
if (acfg->aot_opts.asm_only && !acfg->aot_opts.llvm_outfile) {
aot_printerrf (acfg, "Compiling with LLVM and the asm-only option requires the llvm-outfile= option.\n");
return 1;
}
}
if (mono_aot_mode_is_full (&acfg->aot_opts)) {
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_FULL_AOT);
acfg->is_full_aot = TRUE;
}
if (mono_aot_mode_is_interp (&acfg->aot_opts)) {
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_INTERP);
acfg->is_full_aot = TRUE;
}
if (mini_safepoints_enabled ())
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_SAFEPOINTS);
// The methods in dedup-emit amodules must be available on runtime startup
// Note: Only one such amodule can have this attribute
if (astate && astate->emit_inflated_methods)
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_EAGER_LOAD);
if (acfg->aot_opts.instances_logfile_path) {
acfg->instances_logfile = fopen (acfg->aot_opts.instances_logfile_path, "w");
if (!acfg->instances_logfile) {
aot_printerrf (acfg, "Unable to create logfile: '%s'.\n", acfg->aot_opts.instances_logfile_path);
return 1;
}
}
if (acfg->aot_opts.profile_files) {
GList *l;
for (l = acfg->aot_opts.profile_files; l; l = l->next) {
load_profile_file (acfg, (char*)l->data);
}
}
if (!(mono_aot_mode_is_interp (&acfg->aot_opts) && !mono_aot_mode_is_full (&acfg->aot_opts))) {
int rows = table_info_get_rows (&acfg->image->tables [MONO_TABLE_METHOD]);
for (int method_index = 0; method_index < rows; ++method_index)
g_ptr_array_add (acfg->method_order,GUINT_TO_POINTER (method_index));
}
if (mono_aot_mode_is_interp (&acfg->aot_opts) || mono_aot_mode_is_full (&acfg->aot_opts)) {
/* In interp mode, we don't need some trampolines, but this avoids having to add more conditionals at runtime */
acfg->num_trampolines [MONO_AOT_TRAMP_SPECIFIC] = acfg->aot_opts.ntrampolines;
#ifdef MONO_ARCH_GSHARED_SUPPORTED
acfg->num_trampolines [MONO_AOT_TRAMP_STATIC_RGCTX] = acfg->aot_opts.nrgctx_trampolines;
#endif
acfg->num_trampolines [MONO_AOT_TRAMP_IMT] = acfg->aot_opts.nimt_trampolines;
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED
if (acfg->jit_opts & MONO_OPT_GSHAREDVT)
acfg->num_trampolines [MONO_AOT_TRAMP_GSHAREDVT_ARG] = acfg->aot_opts.ngsharedvt_arg_trampolines;
#endif
#ifdef MONO_ARCH_HAVE_FTNPTR_ARG_TRAMPOLINE
acfg->num_trampolines [MONO_AOT_TRAMP_FTNPTR_ARG] = acfg->aot_opts.nftnptr_arg_trampolines;
#endif
acfg->num_trampolines [MONO_AOT_TRAMP_UNBOX_ARBITRARY] = mono_aot_mode_is_interp (&acfg->aot_opts) && mono_aot_mode_is_full (&acfg->aot_opts) ? acfg->aot_opts.nunbox_arbitrary_trampolines : 0;
}
acfg->temp_prefix = mono_img_writer_get_temp_label_prefix (NULL);
arch_init (acfg);
if (mono_use_llvm || acfg->aot_opts.llvm) {
/*
* Emit all LLVM code into a separate assembly/object file and link with it
* normally.
*/
if (!acfg->aot_opts.asm_only && acfg->llvm_owriter_supported) {
acfg->llvm_owriter = TRUE;
} else if (acfg->aot_opts.llvm_outfile) {
int len = strlen (acfg->aot_opts.llvm_outfile);
if (len >= 2 && acfg->aot_opts.llvm_outfile [len - 2] == '.' && acfg->aot_opts.llvm_outfile [len - 1] == 'o')
acfg->llvm_owriter = TRUE;
}
}
if (acfg->llvm && acfg->thumb_mixed)
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_LLVM_THUMB);
if (acfg->aot_opts.llvm_only)
acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_LLVM_ONLY);
acfg->assembly_name_sym = g_strdup (get_assembly_prefix (acfg->image));
/* Get rid of characters which cannot occur in symbols */
for (p = acfg->assembly_name_sym; *p; ++p) {
if (!(isalnum (*p) || *p == '_'))
*p = '_';
}
acfg->global_prefix = g_strdup_printf ("mono_aot_%s", acfg->assembly_name_sym);
acfg->plt_symbol = g_strdup_printf ("%s_plt", acfg->global_prefix);
acfg->got_symbol = g_strdup_printf ("%s_got", acfg->global_prefix);
if (acfg->llvm) {
acfg->llvm_got_symbol = g_strdup_printf ("%s_llvm_got", acfg->global_prefix);
acfg->llvm_eh_frame_symbol = g_strdup_printf ("%s_eh_frame", acfg->global_prefix);
}
acfg->method_index = 1;
if (mono_aot_mode_is_full (&acfg->aot_opts) || mono_aot_mode_is_hybrid (&acfg->aot_opts))
mono_set_partial_sharing_supported (TRUE);
if (!(mono_aot_mode_is_interp (&acfg->aot_opts) && !mono_aot_mode_is_full (&acfg->aot_opts))) {
res = collect_methods (acfg);
if (!res)
return 1;
}
// If we're emitting all of the inflated methods into a dummy
// Assembly, then after extra_methods is set up, we're done
// in this function.
if (astate && astate->emit_inflated_methods)
mono_add_deferred_extra_methods (acfg, astate);
{
GList *l;
for (l = acfg->profile_data; l; l = l->next)
resolve_profile_data (acfg, (ProfileData*)l->data, ass);
for (l = acfg->profile_data; l; l = l->next)
add_profile_instances (acfg, (ProfileData*)l->data);
}
/* PLT offset 0 is reserved for the PLT trampoline */
acfg->plt_offset = 1;
add_preinit_got_slots (acfg);
current_acfg = acfg;
#ifdef ENABLE_LLVM
if (acfg->llvm) {
llvm_acfg = acfg;
LLVMModuleFlags flags = (LLVMModuleFlags)0;
#ifdef EMIT_DWARF_INFO
flags = LLVM_MODULE_FLAG_DWARF;
#endif
#ifdef EMIT_WIN32_CODEVIEW_INFO
flags = LLVM_MODULE_FLAG_CODEVIEW;
#endif
if (acfg->aot_opts.static_link)
flags = (LLVMModuleFlags)(flags | LLVM_MODULE_FLAG_STATIC);
if (acfg->aot_opts.llvm_only)
flags = (LLVMModuleFlags)(flags | LLVM_MODULE_FLAG_LLVM_ONLY);
if (acfg->aot_opts.interp)
flags = (LLVMModuleFlags)(flags | LLVM_MODULE_FLAG_INTERP);
mono_llvm_create_aot_module (acfg->image->assembly, acfg->global_prefix, acfg->nshared_got_entries, flags);
add_lazy_init_wrappers (acfg);
add_method (acfg, mono_marshal_get_llvm_func_wrapper (LLVM_FUNC_WRAPPER_GC_POLL));
}
#endif
if (mono_aot_mode_is_interp (&acfg->aot_opts) && mono_is_corlib_image (acfg->image->assembly->image)) {
MonoMethod *wrapper = mini_get_interp_lmf_wrapper ("mono_interp_to_native_trampoline", (gpointer) mono_interp_to_native_trampoline);
add_method (acfg, wrapper);
wrapper = mini_get_interp_lmf_wrapper ("mono_interp_entry_from_trampoline", (gpointer) mono_interp_entry_from_trampoline);
add_method (acfg, wrapper);
#ifndef MONO_ARCH_HAVE_INTERP_ENTRY_TRAMPOLINE
for (int i = 0; i < G_N_ELEMENTS (interp_in_static_sigs); i++)
add_interp_in_wrapper_for_sig (acfg, *interp_in_static_sigs [i]);
#else
for (int i = 0; i < G_N_ELEMENTS (interp_in_static_common_sigs); i++)
add_interp_in_wrapper_for_sig (acfg, *interp_in_static_common_sigs [i]);
#endif
/* required for mixed mode */
if (strcmp (acfg->image->assembly->aname.name, MONO_ASSEMBLY_CORLIB_NAME) == 0) {
add_gc_wrappers (acfg);
for (int i = 0; i < MONO_JIT_ICALL_count; ++i)
add_jit_icall_wrapper (acfg, mono_find_jit_icall_info ((MonoJitICallId)i));
}
}
TV_GETTIME (atv);
compile_methods (acfg);
TV_GETTIME (btv);
acfg->stats.jit_time = TV_ELAPSED (atv, btv);
dedup_skip_methods (acfg);
if (acfg->aot_opts.dedup_include && !is_dedup_dummy)
/* We only collected methods from this assembly */
return 0;
current_acfg = NULL;
return emit_aot_image (acfg);
}
static void
print_stats (MonoAotCompile *acfg)
{
int i;
gint64 all_sizes;
char llvm_stats_msg [256];
if (acfg->llvm && !acfg->aot_opts.llvm_only)
sprintf (llvm_stats_msg, ", LLVM: %d (%d%%)", acfg->stats.llvm_count, acfg->stats.mcount ? (acfg->stats.llvm_count * 100) / acfg->stats.mcount : 100);
else
strcpy (llvm_stats_msg, "");
all_sizes = acfg->stats.code_size + acfg->stats.method_info_size + acfg->stats.ex_info_size + acfg->stats.unwind_info_size + acfg->stats.class_info_size + acfg->stats.got_info_size + acfg->stats.offsets_size + acfg->stats.plt_size;
aot_printf (acfg, "Code: %d(%d%%) Info: %d(%d%%) Ex Info: %d(%d%%) Unwind Info: %d(%d%%) Class Info: %d(%d%%) PLT: %d(%d%%) GOT Info: %d(%d%%) Offsets: %d(%d%%) GOT: %d, BLOB: %d\n",
(int)acfg->stats.code_size, (int)(acfg->stats.code_size * 100 / all_sizes),
(int)acfg->stats.method_info_size, (int)(acfg->stats.method_info_size * 100 / all_sizes),
(int)acfg->stats.ex_info_size, (int)(acfg->stats.ex_info_size * 100 / all_sizes),
(int)acfg->stats.unwind_info_size, (int)(acfg->stats.unwind_info_size * 100 / all_sizes),
(int)acfg->stats.class_info_size, (int)(acfg->stats.class_info_size * 100 / all_sizes),
acfg->stats.plt_size ? (int)acfg->stats.plt_size : (int)acfg->plt_offset, acfg->stats.plt_size ? (int)(acfg->stats.plt_size * 100 / all_sizes) : 0,
(int)acfg->stats.got_info_size, (int)(acfg->stats.got_info_size * 100 / all_sizes),
(int)acfg->stats.offsets_size, (int)(acfg->stats.offsets_size * 100 / all_sizes),
(int)(acfg->got_offset * sizeof (target_mgreg_t)),
(int)acfg->stats.blob_size);
aot_printf (acfg, "Compiled: %d/%d (%d%%)%s, No GOT slots: %d (%d%%), Direct calls: %d (%d%%)\n",
acfg->stats.ccount, acfg->stats.mcount, acfg->stats.mcount ? (acfg->stats.ccount * 100) / acfg->stats.mcount : 100,
llvm_stats_msg,
acfg->stats.methods_without_got_slots, acfg->stats.mcount ? (acfg->stats.methods_without_got_slots * 100) / acfg->stats.mcount : 100,
acfg->stats.direct_calls, acfg->stats.all_calls ? (acfg->stats.direct_calls * 100) / acfg->stats.all_calls : 100);
if (acfg->stats.genericcount)
aot_printf (acfg, "%d methods failed gsharing (%d%%)\n", acfg->stats.genericcount, acfg->stats.mcount ? (acfg->stats.genericcount * 100) / acfg->stats.mcount : 100);
if (acfg->stats.abscount)
aot_printf (acfg, "%d methods contain absolute addresses (%d%%)\n", acfg->stats.abscount, acfg->stats.mcount ? (acfg->stats.abscount * 100) / acfg->stats.mcount : 100);
if (acfg->stats.lmfcount)
aot_printf (acfg, "%d methods contain lmf pointers (%d%%)\n", acfg->stats.lmfcount, acfg->stats.mcount ? (acfg->stats.lmfcount * 100) / acfg->stats.mcount : 100);
if (acfg->stats.ocount)
aot_printf (acfg, "%d methods have other problems (%d%%)\n", acfg->stats.ocount, acfg->stats.mcount ? (acfg->stats.ocount * 100) / acfg->stats.mcount : 100);
aot_printf (acfg, "GOT slot distribution:\n");
int nslots = 0;
int size = 0;
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i) {
nslots += acfg->stats.got_slot_types [i];
size += acfg->stats.got_slot_info_sizes [i];
if (acfg->stats.got_slot_types [i])
aot_printf (acfg, "\t%s: %d (%d)\n", get_patch_name (i), acfg->stats.got_slot_types [i], acfg->stats.got_slot_info_sizes [i]);
}
aot_printf (acfg, "GOT SLOTS: %d, INFO SIZE: %d\n", nslots, size);
aot_printf (acfg, "\nEncoding stats:\n");
aot_printf (acfg, "\tMethod ref: %d (%dk)\n", acfg->stats.method_ref_count, acfg->stats.method_ref_size / 1024);
aot_printf (acfg, "\tClass ref: %d (%dk)\n", acfg->stats.class_ref_count, acfg->stats.class_ref_size / 1024);
aot_printf (acfg, "\tGinst: %d (%dk)\n", acfg->stats.ginst_count, acfg->stats.ginst_size / 1024);
aot_printf (acfg, "\nMethod stats:\n");
aot_printf (acfg, "\tNormal: %d\n", acfg->stats.method_categories [METHOD_CAT_NORMAL]);
aot_printf (acfg, "\tInstance: %d\n", acfg->stats.method_categories [METHOD_CAT_INST]);
aot_printf (acfg, "\tGSharedvt: %d\n", acfg->stats.method_categories [METHOD_CAT_GSHAREDVT]);
aot_printf (acfg, "\tWrapper: %d\n", acfg->stats.method_categories [METHOD_CAT_WRAPPER]);
if (acfg->aot_opts.dedup || acfg->dedup_emit_mode)
mono_dedup_log_stats (acfg);
}
static void
create_depfile (MonoAotCompile *acfg)
{
FILE *depfile;
// FIXME: Support other configurations
g_assert (acfg->aot_opts.llvm_only && acfg->aot_opts.asm_only && acfg->aot_opts.llvm_outfile);
depfile = fopen (acfg->aot_opts.depfile, "w");
g_assert (depfile);
int ntargets = 1;
char **targets = g_new0 (char*, ntargets);
targets [0] = acfg->aot_opts.llvm_outfile;
for (int tindex = 0; tindex < ntargets; ++tindex) {
fprintf (depfile, "%s: ", targets [tindex]);
for (int i = 0; i < acfg->image_table->len; i++) {
MonoImage *image = (MonoImage*)g_ptr_array_index (acfg->image_table, i);
fprintf (depfile, " %s", image->filename);
}
fprintf (depfile, "\n");
}
g_free (targets);
fclose (depfile);
}
static int
emit_aot_image (MonoAotCompile *acfg)
{
int i, res;
TV_DECLARE (atv);
TV_DECLARE (btv);
TV_GETTIME (atv);
#ifdef ENABLE_LLVM
if (acfg->llvm) {
if (acfg->aot_opts.asm_only) {
if (acfg->aot_opts.outfile) {
acfg->tmpfname = g_strdup_printf ("%s", acfg->aot_opts.outfile);
acfg->tmpbasename = g_strdup (acfg->tmpfname);
} else {
acfg->tmpbasename = g_strdup_printf ("%s", acfg->image->name);
acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename);
}
g_assert (acfg->aot_opts.llvm_outfile);
acfg->llvm_sfile = g_strdup (acfg->aot_opts.llvm_outfile);
if (acfg->llvm_owriter)
acfg->llvm_ofile = g_strdup (acfg->aot_opts.llvm_outfile);
else
acfg->llvm_sfile = g_strdup (acfg->aot_opts.llvm_outfile);
} else {
gchar *temp_path;
if (strcmp (acfg->aot_opts.temp_path, "") != 0) {
temp_path = g_strdup (acfg->aot_opts.temp_path);
} else {
temp_path = g_mkdtemp (g_strdup ("mono_aot_XXXXXX"));
g_assertf (temp_path, "mkdtemp failed, error = (%d) %s", errno, g_strerror (errno));
acfg->temp_dir_to_delete = g_strdup (temp_path);
}
acfg->tmpbasename = g_build_filename (temp_path, "temp", (const char*)NULL);
acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename);
acfg->llvm_sfile = g_strdup_printf ("%s-llvm.s", acfg->tmpbasename);
acfg->llvm_ofile = g_strdup_printf ("%s-llvm." AS_OBJECT_FILE_SUFFIX, acfg->tmpbasename);
g_free (temp_path);
}
}
#endif
if (acfg->aot_opts.asm_only && !acfg->aot_opts.llvm_only) {
if (acfg->aot_opts.outfile)
acfg->tmpfname = g_strdup_printf ("%s", acfg->aot_opts.outfile);
else
acfg->tmpfname = g_strdup_printf ("%s.s", acfg->image->name);
acfg->fp = fopen (acfg->tmpfname, "w+");
} else {
if (strcmp (acfg->aot_opts.temp_path, "") == 0) {
int i = g_file_open_tmp ("mono_aot_XXXXXX", &acfg->tmpfname, NULL);
acfg->fp = fdopen (i, "w+");
} else {
acfg->tmpbasename = g_build_filename (acfg->aot_opts.temp_path, "temp", (const char*)NULL);
acfg->tmpfname = g_strdup_printf ("%s.s", acfg->tmpbasename);
acfg->fp = fopen (acfg->tmpfname, "w+");
}
}
if (acfg->fp == 0 && !acfg->aot_opts.llvm_only) {
aot_printerrf (acfg, "Unable to open file '%s': %s\n", acfg->tmpfname, strerror (errno));
return 1;
}
if (acfg->fp)
acfg->w = mono_img_writer_create (acfg->fp);
/* Compute symbols for methods */
for (i = 0; i < acfg->nmethods; ++i) {
if (acfg->cfgs [i]) {
MonoCompile *cfg = acfg->cfgs [i];
int method_index = get_method_index (acfg, cfg->orig_method);
if (cfg->asm_symbol) {
// Set by method emitter in backend
if (acfg->llvm_label_prefix) {
char *old_symbol = cfg->asm_symbol;
cfg->asm_symbol = g_strdup_printf ("%s%s", acfg->llvm_label_prefix, cfg->asm_symbol);
g_free (old_symbol);
}
} else if (COMPILE_LLVM (cfg)) {
cfg->asm_symbol = g_strdup_printf ("%s%s", acfg->llvm_label_prefix, cfg->llvm_method_name);
} else if (acfg->global_symbols || acfg->llvm) {
cfg->asm_symbol = get_debug_sym (cfg->orig_method, "", acfg->method_label_hash);
} else {
cfg->asm_symbol = g_strdup_printf ("%s%sm_%x", acfg->temp_prefix, acfg->llvm_label_prefix, method_index);
}
cfg->asm_debug_symbol = cfg->asm_symbol;
}
}
if (acfg->aot_opts.dwarf_debug && acfg->aot_opts.gnu_asm) {
/*
* CLANG supports GAS .file/.loc directives, so emit line number information this way
*/
acfg->gas_line_numbers = TRUE;
}
#ifdef EMIT_DWARF_INFO
if ((!acfg->aot_opts.nodebug || acfg->aot_opts.dwarf_debug) && acfg->has_jitted_code) {
if (acfg->aot_opts.dwarf_debug && !mono_debug_enabled ()) {
aot_printerrf (acfg, "The dwarf AOT option requires the --debug option.\n");
return 1;
}
acfg->dwarf = mono_dwarf_writer_create (acfg->w, NULL, 0, !acfg->gas_line_numbers);
}
#endif /* EMIT_DWARF_INFO */
if (acfg->w)
mono_img_writer_emit_start (acfg->w);
if (acfg->dwarf)
mono_dwarf_writer_emit_base_info (acfg->dwarf, g_path_get_basename (acfg->image->name), mono_unwind_get_cie_program ());
if (acfg->aot_opts.dedup)
mono_flush_method_cache (acfg);
emit_code (acfg);
emit_method_info_table (acfg);
emit_extra_methods (acfg);
emit_trampolines (acfg);
emit_class_name_table (acfg);
emit_got_info (acfg, FALSE);
if (acfg->llvm)
emit_got_info (acfg, TRUE);
emit_exception_info (acfg);
emit_unwind_info (acfg);
emit_class_info (acfg);
emit_plt (acfg);
emit_image_table (acfg);
emit_weak_field_indexes (acfg);
emit_got (acfg);
{
/*
* The managed allocators are GC specific, so can't use an AOT image created by one GC
* in another.
*/
const char *gc_name = mono_gc_get_gc_name ();
acfg->gc_name_offset = add_to_blob (acfg, (guint8*)gc_name, strlen (gc_name) + 1);
}
emit_blob (acfg);
emit_objc_selectors (acfg);
emit_globals (acfg);
emit_file_info (acfg);
if (acfg->dwarf) {
emit_dwarf_info (acfg);
mono_dwarf_writer_close (acfg->dwarf);
} else {
if (!acfg->aot_opts.nodebug)
emit_codeview_info (acfg);
}
emit_mem_end (acfg);
if (acfg->need_pt_gnu_stack) {
/* This is required so the .so doesn't have an executable stack */
/* The bin writer already emits this */
fprintf (acfg->fp, "\n.section .note.GNU-stack,\"\",@progbits\n");
}
if (acfg->aot_opts.data_outfile)
fclose (acfg->data_outfile);
#ifdef ENABLE_LLVM
if (acfg->llvm) {
gboolean res;
res = emit_llvm_file (acfg);
if (!res)
return 1;
}
#endif
emit_library_info (acfg);
TV_GETTIME (btv);
acfg->stats.gen_time = TV_ELAPSED (atv, btv);
if (!acfg->aot_opts.stats)
aot_printf (acfg, "Compiled: %d/%d\n", acfg->stats.ccount, acfg->stats.mcount);
TV_GETTIME (atv);
if (acfg->w) {
res = mono_img_writer_emit_writeout (acfg->w);
if (res != 0) {
acfg_free (acfg);
return res;
}
res = compile_asm (acfg);
if (res != 0) {
acfg_free (acfg);
return res;
}
}
TV_GETTIME (btv);
acfg->stats.link_time = TV_ELAPSED (atv, btv);
if (acfg->aot_opts.stats)
print_stats (acfg);
aot_printf (acfg, "JIT time: %d ms, Generation time: %d ms, Assembly+Link time: %d ms.\n", acfg->stats.jit_time / 1000, acfg->stats.gen_time / 1000, acfg->stats.link_time / 1000);
if (acfg->aot_opts.depfile)
create_depfile (acfg);
if (acfg->aot_opts.dump_json)
aot_dump (acfg);
if (!acfg->aot_opts.save_temps && acfg->temp_dir_to_delete) {
char *command = g_strdup_printf ("rm -r %s", acfg->temp_dir_to_delete);
execute_system (command);
g_free (command);
}
acfg_free (acfg);
return 0;
}
#else
/* AOT disabled */
void*
mono_aot_readonly_field_override (MonoClassField *field)
{
return NULL;
}
int
mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options, gpointer **aot_state)
{
return 0;
}
gboolean
mono_aot_is_shared_got_offset (int offset)
{
return FALSE;
}
gboolean
mono_aot_is_externally_callable (MonoMethod *cmethod)
{
return FALSE;
}
int
mono_compile_deferred_assemblies (guint32 opts, const char *aot_options, gpointer **aot_state)
{
g_assert_not_reached ();
return 0;
}
gboolean
mono_aot_direct_icalls_enabled_for_method (MonoCompile *cfg, MonoMethod *method)
{
g_assert_not_reached ();
return 0;
}
gboolean
mono_aot_can_enter_interp (MonoMethod *method)
{
return FALSE;
}
int
mono_aot_get_method_index (MonoMethod *method)
{
g_assert_not_reached ();
return 0;
}
#endif
|
JimmyCushnie/runtime
|
src/coreclr/zap/zaplog.h
|
<filename>src/coreclr/zap/zaplog.h
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
/*
* Hook IfFailThrow calls to do some logging when exceptions are thrown.
*
*/
#ifndef __ZAPLOG_H__
#define __ZAPLOG_H__
#undef IfFailThrow
#define IfFailThrow(x) \
do { \
HRESULT hrMacro = x; \
if (FAILED(hrMacro)) { \
/* don't embed file names in retail to save space and avoid IP */ \
/* a findstr /n will allow you to locate it in a pinch */ \
ThrowAndLog(hrMacro, INDEBUG_COMMA(#x) INDEBUG_COMMA(__FILE__) __LINE__); \
} \
} while(FALSE)
inline void ThrowAndLog(HRESULT hr, INDEBUG_COMMA(__in_z const char * szMsg) INDEBUG_COMMA(__in_z const char * szFile) int lineNum)
{
WRAPPER_NO_CONTRACT;
// Log failures when StressLog is on
static ConfigDWORD g_iStressLog;
BOOL bLog = g_iStressLog.val(CLRConfig::UNSUPPORTED_StressLog);
if (bLog)
{
#ifdef _DEBUG
GetSvcLogger()->Printf("IfFailThrow about to throw in file %s line %d, msg = %s, hr: 0x%X\n", szFile, lineNum, szMsg, hr);
#else
GetSvcLogger()->Printf("IfFailThrow about to throw on line %d. hr: 0x%X\n", lineNum, hr);
#endif
}
ThrowHR(hr);
}
#endif // __ZAPLOG_H__
|
AllanBastos/SO
|
Roteiro 2 em C/prodconssync.c
|
/*
* Producer/Consumer demo using POSIX threads without synchronization
* Linux version
* MJB Apr'05
*/
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
/* buffer using a shared integer variable */
typedef struct
{
int writeable; /*true/false*/
int sharedData;
int finish; /*true/false*/
} buffer;
buffer theBuffer; /* global */
pthread_mutex_t mutex;
void delay(int secs)
{
time_t beg = time(NULL), end = beg + secs;
do
{
;
} while (time(NULL) < end);
}
int store(int item, buffer *pb)
{
pthread_mutex_lock(&mutex);
pb->sharedData += item;
pb->writeable = !pb->writeable;
pthread_mutex_unlock(&mutex);
return 0;
}
int retrieve(buffer *pb)
{
pthread_mutex_lock(&mutex);
int data = pb->sharedData;
pb->sharedData -= data;
pb->writeable = !pb->writeable;
return data;
}
void *producer(void *n)
{
int j = 1, tot_prod = 0;
while (j <= 10)
{
store(j, &theBuffer);
printf("Produzido: %d | Total no buffer: %d\n", j, theBuffer.sharedData);
tot_prod += j++;
delay(rand() % 6); /* up to 5 sec */
}
theBuffer.finish = 0;
printf("Total produzido = %d\n", tot_prod);
return n;
}
void *consumer(void *n)
{
int j = 0, tot = 0;
while (theBuffer.finish)
{
if (theBuffer.sharedData > 0) {
j = retrieve(&theBuffer);
tot += j;
pthread_mutex_unlock(&mutex);
printf("Consumido: %d | Total no buffer: %d\n", j, theBuffer.sharedData);
delay(rand() % 6); /* up to 5 sec */
}
}
printf("Total consumido = %d\n", tot);
return (n);
}
int main()
{
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
pthread_t prodThread, consThread;
int e, st;
theBuffer.writeable = 1;
theBuffer.finish = 1;
pthread_mutex_init(&mutex, NULL);
srand(time(NULL));
printf("Iniciou!\n");
if (e = pthread_create(&prodThread, &attr, producer, NULL) != 0) {
printf("Criação da thread produtora falhou! Erro %d\n", e);
exit(-1);
}
if (e = pthread_create(&consThread, &attr, consumer, NULL) != 0) {
printf("Criação da thread consumidora falhou! Erro %d\n", e);
exit(-1);
}
if (e = pthread_join(prodThread, (void **)&st) != 0) {
printf("Thread produtora erro ao juntar %d\n", e);
exit(-1);
}
printf("Thread produtora uniu: status = %x\n", st);
if (e = pthread_join(consThread, (void **)&st) != 0) {
printf("Thread consumidora erro ao juntar %d\n", e);
exit(-1);
}
printf("Thread consumidora uniu: status = %x\n", st);
pthread_exit(NULL);
}
|
AllanBastos/SO
|
Roteiro 3/main.c
|
<filename>Roteiro 3/main.c
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
#define N 5
#define LEFT (i+N-1)%N
#define RIGHT (i+1)%N
#define THINKING 0
#define HUNGRY 1
#define EATING 2
#define CICLO_J 2
#define down pthread_mutex_lock
#define up pthread_mutex_unlock
int state[N], i;
// declarando semafaros
pthread_mutex_t mutex;
pthread_mutex_t forks[N];
pthread_t philosofers[N];
// funçoes
void * philosofer(void * id);
void think(int i);
void take_forks(int i);
void eat(int i);
void put_forks(int i);
void test(int i);
void print_status(int i);
void* philosofer(void * id){
int i = * (int*)id;
printf("filosofo %d entrou\n", i + 1);
for(int k=0; k < CICLO_J; k++){
think(i);
take_forks(i);
eat(i);
put_forks(i);
}
printf("filosofo %d saindo\n",i + 1);
pthread_exit((void *)0);
return 0;
}
void think(int i){
int t = (rand()%10);
sleep(t);
}
void eat(int i){
int t = (rand()%10);
sleep(t);
}
void take_forks(int i){
down((&mutex));
state[i] = HUNGRY;
print_status(i);
test(i);
up(&mutex);
down(&forks[i]);
}
void put_forks(int i){
down(&mutex);
state[i] = THINKING;
print_status(i);
test(LEFT);
test(RIGHT);
up(&mutex);
}
void test(i){
if(state[i] == HUNGRY && state[LEFT] != EATING && state[RIGHT] != EATING ){
state[i] = EATING;
print_status(i);
up(&forks[i]);
}
}
void print_status(int i){
printf("\n");
for(i=1; i<=N; i++){
if(state[i-1] == THINKING){
printf("O filosofo %d esta pensando!\n", i);
}
if(state[i-1] == HUNGRY){
printf("O filosofo %d esta com fome!\n", i);
}
if(state[i-1] == EATING){
printf("O filosofo %d esta comendo!\n", i);
}
}
printf("\n");
}
int main(void) {
pthread_mutex_init( &(mutex), NULL);
for (int i = 0; i < N; i++ ){
pthread_create(&philosofers[i], NULL, philosofer, (void*) &(i) );
sleep(1);
}
pthread_mutex_destroy(&(mutex));
for (int i = 0; i < N; i++ ){
pthread_mutex_destroy(&forks[i]);
}
pthread_join(philosofers[0], NULL);
pthread_join(philosofers[1], NULL);
pthread_join(philosofers[2], NULL);
pthread_join(philosofers[3], NULL);
pthread_join(philosofers[4], NULL);
printf("todas os filosofos sairam\n");
return 0;
}
|
AllanBastos/SO
|
Roteiro 2 em C/joinEx.c
|
<filename>Roteiro 2 em C/joinEx.c<gh_stars>1-10
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NTHRDS 3
void * theWork(void * n) { //main function of the "worker thread"
int i; double r = 0.0;
for (i=0; i<1000000; i++) //do lots of work
r += (double)random();
printf("Result: %e\n", r);
pthread_exit((void *)0);
}
int main(int argc, char ** argv) {
pthread_t thrd[NTHRDS];
//data structure for managing several worker thread instances
pthread_attr_t attr; //data structure for managing thread attributes
pthread_attr_init(&attr); //initialise thread attribute data ...
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
//...and set "joinable" attribute
int t, e, st;
for (t=0; t<NTHRDS; t++) { // create several worker thread instances
printf("Creating thread %d\n", t);
if (e = pthread_create(&thrd[t], &attr, theWork, NULL)!= 0) {
printf("Thread create error %d\n", e);
exit(-1);
}
}
pthread_attr_destroy(&attr);
//garbage-collect the thread attribute oject, no longer needed
for (t=0; t<NTHRDS; t++) { //wait for each worker thread to join
if (e = pthread_join(thrd[t], (void **)&st)!= 0) {
printf("Thread %d join error %d\n", t, e);
exit(-1);
}
printf("Thread %d has joined: status = %x\n", t, st);
}
pthread_exit(NULL); //master-thread (program main) is done.
}
|
AllanBastos/SO
|
Roteiro 1/process_exercise/threaddemo.c
|
/* threaddemo.c */
/* Thread demonstration program. Note that this program uses a shared variable
in an unsafe manner (eg mutual exclusion is not attempted!) */
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
int x = 50; /* a global (shared) variable */
const clock_t MAXDELAY = 2000000;
void delay(clock_t ticks) { /* a "busy" delay */
clock_t start = clock();
do
; while (clock() < start + ticks);
}
void * adjustX(void *n)
{ int i = (int)n;
int x = 50;
while (1) /* loop forever */
{ printf("adjustment = %2i; x = %i\n", i, x);
x += i;
delay(rand()%MAXDELAY);
}
return(n);
}
main()
{ int a;
srand(time(NULL));
pthread_t up_thread, dn_thread;
pthread_attr_t *attr; /* thread attribute variable */
attr=0;
printf("creating threads:\n");
pthread_create(&up_thread,attr, adjustX, (void *)1);
pthread_create(&dn_thread,attr, adjustX, (void *)-1);
while (1) /* loop forever */
{ ;}
}
|
AllanBastos/SO
|
Roteiro 2 em C/simpleMutexEx.c
|
/*
* Simple mutex demo using POSIX threads and mutexes (Linux version)
* MJB Sep 07
*/
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#define NTHRDS 5
int sharedData = 0;
pthread_mutex_t mutex;
void delay(int secs) { //utility function
time_t beg = time(NULL), end = beg + secs;
do ; while (time(NULL) < end);
}
//Try commenting out the calls to the lock and unlock functions.
void *add1000(void *n) {
pthread_mutex_lock(&mutex); //Obtain exclusive mutex lock
int j = sharedData;
delay(rand() % 6);
sharedData = j + 1000;
pthread_mutex_unlock(&mutex); //Release mutex lock
printf("1000 added!\n");
return n;
}
int main() {
pthread_attr_t *attr = NULL;
pthread_t thrd[NTHRDS]; //Data strs form managing several threads
int t;
pthread_mutex_init(&mutex, NULL);
srand(time(NULL)); // initialise random num generator
for (t=0; t<NTHRDS; t++) //create & initialise several thread instances
pthread_create(&thrd[t], attr, add1000, NULL);
for (t=0; t<NTHRDS; t++) //wait for all threads to finish ...
pthread_join(thrd[t], NULL);
printf("Shared data = %d\n", sharedData); //...& display net result.
return 0;
}
|
AllanBastos/SO
|
Roteiro 2 em C/prodconsUnsync.c
|
/*
* Producer/Consumer demo using POSIX threads without synchronization
* Linux version
* MJB Apr'05
*/
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
/* buffer using a shared integer variable */
typedef struct {
int writeable; /*true/false*/
int sharedData;
} buffer;
buffer theBuffer; /* global */
int store(int item, buffer *pb) {
pb->sharedData = item; /*put data in buffer... */
pb->writeable = !pb->writeable;
return 0;
}
int retrieve(buffer *pb) {
int data;
data = pb->sharedData; /*get data from buffer...*/
pb->writeable = !pb->writeable;
return data;
}
void delay(int secs) { /*utility function*/
time_t beg = time(NULL), end = beg + secs;
do {
;
} while (time(NULL) < end);
}
/* core routine for the producer thread */
void *producer(void *n) {
int j=1;
while (j<=10) {
store(j, &theBuffer);
printf("Stored: %d\n", j);
j++;
delay(rand() % 6); /* up to 5 sec */
}
return n;
}
/* core routine for the consumer thread */
void *consumer(void *n) {
int j=0, tot=0;
while (j < 10) {
j = retrieve(&theBuffer);
tot += j;
printf("Retrieved: %d\n", j);
delay(rand() % 6); /* up to 5 sec */
}
printf("Retrieved total = %d\n", tot);
return(n);
}
int main() {
pthread_attr_t *attr = NULL;
pthread_t prodThread, consThread;
theBuffer.writeable = 1;
srand(time(NULL)); /* initialise the rng */
pthread_create(&prodThread, attr, producer, NULL);
pthread_create(&consThread, attr, consumer, NULL);
while (1)
; /*loop forever*/
return 0; /*!!!*/
}
|
arielszabo/YOLO3-4-Py
|
bridge.h
|
#if USE_CV == 1
#include <opencv2/opencv.hpp>
#endif
#if USE_GPU == 1
// Set GPU tag so darknet.h is imported with GPU features
#define GPU
#include <cuda_runtime.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
// Include darknet as a C Library
#include <darknet.h>
#include <image.h>
#ifdef __cplusplus
}
#endif
#if USE_CV == 1
using namespace cv;
image get_darknet_image(const Mat &input);
#endif
|
dylan-thinnes/solsys-functional
|
solsys-core/src/Primes/glue/msieve/glue.c
|
<gh_stars>1-10
#include <stdio.h>
#include <stdint.h>
#include <msieve.h>
#include <malloc.h>
#include <string.h>
void get_random_seeds(uint32 *seed1, uint32 *seed2) {
uint32 tmp_seed1, tmp_seed2;
/* In a multithreaded program, every msieve object
should have two unique, non-correlated seeds
chosen for it */
#if !defined(WIN32) && !defined(_WIN64)
FILE *rand_device = fopen("/dev/urandom", "r");
if (rand_device != NULL) {
/* Yay! Cryptographic-quality nondeterministic randomness! */
fread(&tmp_seed1, sizeof(uint32), (size_t)1, rand_device);
fread(&tmp_seed2, sizeof(uint32), (size_t)1, rand_device);
fclose(rand_device);
}
else
#endif
{
/* <Shrug> For everyone else, sample the current time,
the high-res timer (hopefully not correlated to the
current time), and the process ID. Multithreaded
applications should fold in the thread ID too */
uint64 high_res_time = read_clock();
tmp_seed1 = ((uint32)(high_res_time >> 32) ^
(uint32)time(NULL)) *
(uint32)getpid();
tmp_seed2 = (uint32)high_res_time;
}
/* The final seeds are the result of a multiplicative
hash of the initial seeds */
(*seed1) = tmp_seed1 * ((uint32)40499 * 65543);
(*seed2) = tmp_seed2 * ((uint32)40499 * 65543);
}
char * factor_integer(char *buf) {
msieve_obj *obj;
msieve_obj *g_curr_factorization;
msieve_factor *factor;
uint32 seed1, seed2;
get_random_seeds(&seed1, &seed2);
enum cpu_type cpu = get_cpu_type();
uint32 cache_size1, cache_size2;
get_cache_sizes(&cache_size1, &cache_size2);
g_curr_factorization = msieve_obj_new(buf, 0,
"/tmp/msieve.dat", NULL,
NULL,
seed1, seed2, 0,
cpu, cache_size1, cache_size2,
0, 0,
NULL);
if (g_curr_factorization == NULL) {
printf("factoring initialization failed\n");
return;
}
msieve_run(g_curr_factorization);
if (!(g_curr_factorization->flags & MSIEVE_FLAG_FACTORIZATION_DONE)) {
printf("\ncurrent factorization was interrupted\n");
exit(0);
}
factor = g_curr_factorization->factors;
char * factors_list = "[";
while (factor != NULL) {
char * number = factor->number;
char * new_factors_list = malloc(strlen(factors_list) + strlen(number) + 2);
new_factors_list[0] = '\0';
strcat(new_factors_list, factors_list);
strcat(new_factors_list, number);
if (factor->next != NULL) strcat(new_factors_list, ",");
//if (factors_list != NULL) free(factors_list);
factors_list = new_factors_list;
factor = factor->next;
}
strcat(factors_list, "]");
/* free the current factorization struct. The following
avoids a race condition in the signal handler */
obj = g_curr_factorization;
g_curr_factorization = NULL;
if (obj)
msieve_obj_free(obj);
return factors_list;
}
|
OpenLab-SI/ThinkSpeak-Arduino
|
ThingSpeak.h
|
<reponame>OpenLab-SI/ThinkSpeak-Arduino<gh_stars>1-10
#ifndef ThingSpeak_h
#define ThingSpeak_h
#include "Arduino.h"
#include "SPI.h"
#include "Ethernet.h"
class ThingSpeak
{
public:
ThingSpeak();
ThingSpeak(String address);
void setChannel(String key);
void setTalkBack(int id, String key);
void setTalkBack(String id, String key);
void setThingTweet(String key);
void addField(String name);
void setField(int field, int value);
void setField(int field, long value);
void setField(int field, double value);
void setField(int field, String value);
void setField(String name, int value);
void setField(String name, long value);
void setField(String name, double value);
void setField(String name, String value);
void _setField(String field, String value);
void update();
String nextCommand();
void addCommand(String command);
void tweet(String status);
private:
String _address;
int _fieldCount;
String _fields[8];
String _values;
String _channelKey;
String _talkBackId;
String _talkBackKey;
String _thingTweetKey;
String _send(String location, String data);
};
#endif
|
zx96/3dshex
|
source/timing.c
|
<filename>source/timing.c
#include "timing.h"
/*
* GetSystemTick function by xerpi
*/
u64 getSystemTick() {
register unsigned long lo64 asm ("r0");
register unsigned long hi64 asm ("r1");
asm volatile ( "SVC 0x28" : "=r"(lo64), "=r"(hi64) );
return ((uint64_t)hi64<<32) | (uint64_t)lo64;
}
|
zx96/3dshex
|
source/main.c
|
#define PI 3.14159265
#include <3ds.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> //memset
#include "costable.h"
#include "draw.h"
#include "minlib.h"
#include "timing.h"
typedef u8 angle_t;
int main(int argc, char **argv)
{
int i; //Generic iterator
//Initialize services
srvInit();
aptInit();
hidInit(NULL);
gfxInitDefault();
consoleInit(GFX_BOTTOM, NULL); //Show a console on the bottom screen
srand(getSystemTick()); //Seed rand with the time
u8 *fbTop, *fbBot; //Framebuffers
// Main loop
angle_t angle = 0;
angle_t tmpAngle = angle;
u8 regions = 6;
s8 speed = 1;
while (aptMainLoop())
{
//Scan all the inputs. This should be done once for each frame
hidScanInput();
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
u32 kDown = hidKeysDown();
if (kDown & KEY_START) break; // break in order to return to hbmenu
//Clear screens
fbTop = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(fbTop, 0, 240 * 400 * 3);
//fbBot = gfxGetFramebuffer(GFX_BOTTOM, 0, NULL, NULL);
//memset(fbBot, 0, 240 * 320 * 3);
printf("\x1b[0;10H%s", "Press Start to exit.");
printf("\x1b[1;1H%s", "Remove region <");
printf("\x1b[2;1H%s", "Add region >");
printf("\x1b[1;20H%s", "^ Increase speed");
printf("\x1b[2;20H%s", "v Decrease speed");
printf("\x1b[5;0HBinary Angle %3d", angle);
printf("\x1b[6;0HSin %9f", sin(PI/128 * tmpAngle));
printf("\x1b[7;0HCos %9f", cos(PI/128 * tmpAngle));
printf("\x1b[5;20HSpeed %3d", speed);
printf("\x1b[6;20HRegions %3d", regions);
//Draw lines
tmpAngle = angle;
for (i = 0; i < regions; i++) {
drawLine(fbTop, 200, 120, 200 + 234*cos(PI/128 * tmpAngle), 120 + 234*sin(PI/128 * tmpAngle), 255, 255, 255);
tmpAngle += (256 / regions);
}
//Rotate
if (speed < 0) {
for (i = 0; i > speed; i--) angle--;
} else {
for (i = 0; i < speed; i++) angle++;
}
if (kDown & KEY_UP) speed++;
if (kDown & KEY_DOWN) speed--;
if (kDown & KEY_LEFT) regions--;
if (kDown & KEY_RIGHT) regions++;
gfxFlushBuffers();
gfxSwapBuffers();
//Wait for VBlank
gspWaitForVBlank();
}
// Exit services
gfxExit();
hidExit();
aptExit();
srvExit();
return 0;
}
|
zx96/3dshex
|
include/draw.h
|
#ifndef DRAW_H
#define DRAW_H
#include <3ds.h>
#include <stdbool.h>
u16 getScreenWidth(u8* fb);
bool isInBounds(u8* fb, s16 x, s16 y);
void drawPixel(u8* fb, s16 x, s16 y, u8 r, u8 g, u8 b, u8 a);
void drawLine(u8* fb, s16 x1, s16 y1, s16 x2, s16 y2, u8 r, u8 g, u8 b);
void drawHLine(u8* fb, s16 row, s16 x1, s16 x2, u8 r, u8 g, u8 b, u8 a);
void drawVLine(u8* fb, s16 col, s16 y1, s16 y2, u8 r, u8 g, u8 b, u8 a);
#endif
|
zx96/3dshex
|
include/costable.h
|
#ifndef TRIGTABLE_H
#define TRIGTABLE_H
double cosTable[256];
double sinTable[256];
#endif
|
zx96/3dshex
|
source/minlib.c
|
#include "minlib.h"
void swap(s16 *n1, s16 *n2) {
*n1 ^= *n2;
*n2 ^= *n1;
*n1 ^= *n2;
}
s16 absVal(s16 n) {
if (n < 0) return -n;
return n;
}
|
zx96/3dshex
|
source/draw.c
|
<filename>source/draw.c
#include <math.h>
#include <stdbool.h>
#include "draw.h"
#include "minlib.h"
u16 getScreenWidth(u8* fb) {
if (fb == gfxGetFramebuffer(GFX_BOTTOM, 0, NULL, NULL)) {
return 320;
} else {
return 400;
}
}
bool isInBounds(u8* fb, s16 x, s16 y) {
if (x < 0) return false;
if (y < 0) return false;
if (x >= getScreenWidth(fb)) return false;
if (y > 239) return false;
return true;
}
void drawPixel(u8* fb, s16 x, s16 y, u8 r, u8 g, u8 b, u8 a) {
if (!isInBounds(fb, x, y)) return;
//Transparent pixel
if (a == 0) return;
u32 index = 3 * ((x + 1) * 240 - y - 1); //Get the address of the pixel
if (a == 255) { //Solid pixel
fb[index] = b;
fb[index + 1] = g;
fb[index + 2] = r;
} else { //Alpha blending
float alpha_ratio = a/255.0f;
fb[index] = fb[index] * (1 - alpha_ratio) + b * alpha_ratio;
fb[index + 1] = fb[index + 1] * (1 - alpha_ratio) + g * alpha_ratio;
fb[index + 2] = fb[index + 2] * (1 - alpha_ratio) + r * alpha_ratio;
}
}
//Wu's Line Algorithm
//Optimized with integer endpoints
void drawLine(u8* fb, s16 x1, s16 y1, s16 x2, s16 y2, u8 r, u8 g, u8 b) {
bool steep = absVal(y2 - y1) > absVal(x2 - x1);
if (steep) {
swap(&x1, &y1);
swap(&x2, &y2);
}
if (x1 > x2) {
swap(&x1, &x2);
swap(&y1, &y2);
}
s16 dx = x2 - x1;
s16 dy = y2 - y1;
float m = (float)dy / (float)dx;
int i;
float fPart, inter = y1;
for (i = x1; i < x2; i++) {
fPart = inter - (int)inter;
if (steep) {
drawPixel(fb, inter, i, r, g, b, (1 - fPart)*255.0f);
drawPixel(fb, inter+1, i, r, g, b, fPart*255.0f);
} else {
drawPixel(fb, i, inter, r, g, b, (1 - fPart)*255.0f);
drawPixel(fb, i, inter+1, r, g, b, fPart*255.0f);
}
inter += m;
}
}
void drawHLine(u8* fb, s16 row, s16 x1, s16 x2, u8 r, u8 g, u8 b, u8 a) {
if (x1 > x2) swap(&x1, &x2);
int i;
for (i = x1; i <= x2; i++) drawPixel(fb, i, row, r, g, b, a);
}
void drawVLine(u8* fb, s16 col, s16 y1, s16 y2, u8 r, u8 g, u8 b, u8 a) {
if (y1 > y2) swap(&y1, &y2);
int i;
for (i = y1; i <= y2; i++) drawPixel(fb, col, i, r, g, b, a);
}
|
zx96/3dshex
|
include/minlib.h
|
<gh_stars>1-10
#ifndef MINLIB_H
#define MINLIB_H
#include <3ds.h>
void swap(s16 *n1, s16 *n2);
s16 absVal(s16 n);
#endif
|
zx96/3dshex
|
include/timing.h
|
#ifndef TIMING_H
#define TIMING_H
#include <3ds.h>
u64 getSystemTick();
#endif
|
rnnsilveira/CarthageExampleModule
|
CarthageExampleModule/CarthageExampleModule.h
|
<reponame>rnnsilveira/CarthageExampleModule<filename>CarthageExampleModule/CarthageExampleModule.h
//
// CarthageExampleModule.h
// CarthageExampleModule
//
// Created by <NAME> on 06/12/19.
// Copyright © 2019 <NAME>. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for CarthageExampleModule.
FOUNDATION_EXPORT double CarthageExampleModuleVersionNumber;
//! Project version string for CarthageExampleModule.
FOUNDATION_EXPORT const unsigned char CarthageExampleModuleVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CarthageExampleModule/PublicHeader.h>
|
DanielSaromo/PyDuino_Bridge
|
src/pyduino_bridge.h
|
/*
pyduino_bridge.h - Library for transparent bidirectional
communication between Python and Arduino. Arduino header file.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Author: <NAME>. Adapted from Robin2 code.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
Description:
The Arduino board expects a message with three parts: A header, a group of ints (separated with commas),
and a group of floats (separated with commas).
The message to be sent to the Arduino starts with < and ends with > (startMarker and endMarker default values).
For instance:
<LED1,100,300,123,1.1,2.3,2.4>
The code is as minimalist as possible, so that you can keep your
existing python and arduino and use it with the library.
Python code tested in: Windows, Jetson Nano and Raspberry Pi.
Created by <NAME>, Apr 23, 2020.
Released into the public domain.
Configuration considerations:
By default, the maximum number of characters allowed in the messages between Arduino and Python is 40.
If you want to change this buffer size, you have to put the same value in both the Python (change the value `buffSize`
when using the `begin` method) and the Arduino code (change the line `#define buffSize 40` in the `pyduino_bridge.h` and
`pyduino_bridge.cpp` files).
Also, verify that the same `numIntValues_FromPy` and `numFloatsValues_FromPy` values are configured in the Python code
you are using, and also in the Arduino library files (before uploading, change the lines `#define numIntValues_FromPy 1`
and `#define numFloatValues_FromPy 1` in the `pyduino_bridge.h` and `pyduino_bridge.cpp`). In the Arduino library files,
this number is set by the `#define` command, since the value representing the number of elements in the array must be a
constant expression, because arrays are blocks of static memory whose size must be determined at the compilation time,
before the program runs (for more information, see http://www.cplusplus.com/doc/tutorial/arrays/).
Adapted from Robin2 code: https://forum.arduino.cc/index.php?topic=225329.msg1810764#msg1810764
Robin2 modification for Python3: https://forum.arduino.cc/index.php?topic=566897.0
*/
#define buffSize 40
#define numIntValues_FromPy 1 //Number of integer values that are going to be in the message
#define numFloatValues_FromPy 1 //Number of float values that are going to be in the message
#ifndef pyduino_bridge_h
#define pyduino_bridge_h
#include "Arduino.h"
class Bridge_ino
{
public:
Bridge_ino(Stream &serial);
//const int buffSize;
char inputBuffer[buffSize];
char inputBuffer_original[buffSize];
const char startMarker = '<';
const char endMarker = '>';
int intsRecvd[numIntValues_FromPy];
float floatsRecvd[numFloatValues_FromPy];
int xd_int = 123;
float xd_float = 1.23;
byte rightBitShifter = 10;//10: makes the divided millis value to be approx seconds
byte bytesRecvd = 0;
boolean readInProgress = false;
boolean newDataFromPC = false;
char headerOfMsg[buffSize] = {0};
unsigned long curMillis;
unsigned long prevReplyToPCmillis = 0;
unsigned long replyToPCinterval = 1000;
void read();
void writeEcho();
void write_HeaderAndTwoArrays(char* header, int arrInts[], int numInts, float arrayFloats[], int numFloats);
void parseData();
void setMillisBitShifter(byte newRightBitShifter);
Stream& ser;
private:
//int _pin;
};
#endif
|
gleu/mods_since_analyze
|
mods_since_analyze.c
|
<reponame>gleu/mods_since_analyze<filename>mods_since_analyze.c<gh_stars>0
/*-------------------------------------------------------------------------
*
* mods_since_analyze.c
* Expose the estimation of number of changed tuples since last analyze.
*
*
* Copyright (c) 2013-2021, <NAME> (Dalibo),
* <EMAIL>
*
*-------------------------------------------------------------------------
*/
#include <stdio.h>
#include "postgres.h"
#include "pgstat.h"
PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(pg_stat_get_mod_since_analyze);
Datum pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS);
Datum
pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
int64 result;
PgStat_StatTabEntry *tabentry;
if ((tabentry = pgstat_fetch_stat_tabentry(relid)) == NULL)
result = 0;
else
result = (int64) (tabentry->changes_since_analyze);
PG_RETURN_INT64(result);
}
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/pch.h
|
#pragma once
#include <wrl.h>
#include <wrl/client.h>
#include <dxgi1_4.h>
#include <d3d11_3.h>
#include <d2d1_3.h>
#include <d2d1effects_2.h>
#include <dwrite_3.h>
#include <wincodec.h>
#include <DirectXColors.h>
#include <DirectXMath.h>
#include <memory>
#include <agile.h> // ghv : if want to #include <agile.h> then must compile with /ZW.
#include <ppltasks.h> // ghv : for asynchronous file reader tasks;
#include <concrt.h>
#include <complex>
#include <vector> // ghv ;
#include <map> // ghv : 2018_07_29
#include <d2d1helper.h> // ghv : 2018_08_03 : for ctor D2D1::Point2F();
#include "Keyboard.h"
#include "Mouse.h"
#include "WICTextureLoader.h" // CWS ---> DirectXTK;
#include <d2d1_1.h> // ghv : 2018_08_09 : for D2D1_BITMAP_PROPERTIES1 structure;
#include <random>
#include <assert.h>
#pragma comment(lib, "DirectXTK")
#pragma comment(lib, "dxguid") // ghv : 2018_07_30 for unresolved symbol CLSID_D2D1Opacity for D2D1Effect;
namespace HvyDXBase
{
extern double const konst_pi;
extern double const MedievalFadeDuration;
}
//
// $ grep - i - I - R ghv_option . --exclude \*_rel_\* --exclude \*_annot.\*
//
// . / Common / DeviceResources.cpp:#ifdef GHV_OPTION_DISCARDVIEW
// . / vhglib / DefTypes.h : #define GHV_OPTION_USE_DJJ_CHOPPER
// . / vhglib / VhgSystem.cpp : #define GHV_OPTION_GO_MEDIEVAL
//
//
template <class Interface>
inline void
SafeRelease(
Interface **ppInterfaceToRelease
)
{
if (*ppInterfaceToRelease != nullptr)
{
(*ppInterfaceToRelease)->Release();
(*ppInterfaceToRelease) = nullptr;
}
}
template <class DestInterface, class SourceInterace>
inline void
SafeReplace(
DestInterface **ppDestInterface,
SourceInterace *pSourceInterface
)
{
if (*ppDestInterface != nullptr)
{
(*ppDestInterface)->Release();
}
*ppDestInterface = pSourceInterface;
if (pSourceInterface)
{
(*ppDestInterface)->AddRef();
}
}
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/VhgSystem.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Content\HvySchlafliButtons.h"
#include "..\Content\HvySkipNumButtons.h"
#include "..\Content\HvyCheckBoxQuasiRegular.h"
#include "DefTypes.h"
#include "JPoincareDisk.h"
namespace HvyDXBase
{
class VhgSystem
{
public:
VhgSystem(
std::shared_ptr<DX::DeviceResources>const & deviceResources,
const std::shared_ptr<HvyDXBase::HvySchlafliButtons> & p_schlafliButtons,
const std::shared_ptr<HvyDXBase::HvySkipNumButtons> & p_skipNumButtons,
const std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> & p_checkBoxQuasiRegular
);
void hideMedieval() { sy_ShowMedieval = false; }
bool displayModeIsMedieval() { return sy_ShowMedieval; }
std::wstring getTilingDescription();
static std::random_device e_rng_seed;
static std::mt19937 e_rng_gen;
static std::uniform_int_distribution<int> e_rng_dist;
static unsigned char e_OpMode_Joyce;
static unsigned char e_OpMode_bits;
void RenderByMode();
private:
std::shared_ptr<DX::DeviceResources> sy_deviceResources;
std::shared_ptr<HvyDXBase::HvySchlafliButtons> sy_schlafliButtons;
std::shared_ptr<HvyDXBase::HvySkipNumButtons> sy_skipNumButtons;
std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> sy_checkBoxQuasiRegular;
bool sy_ShowMedieval;
Microsoft::WRL::ComPtr<ID2D1Bitmap> sy_D2D1BitmapMedieval;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> sy_d2d1_brush;
std::unique_ptr<DJJ::JPoincareDisk> sy_JoyceJavaDisk;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/Content/HvySkipNumButtons.h
|
<reponame>GarrettVance/HyperbolicJoyce
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
#include "HvyWidgets.h"
namespace HvyDXBase
{
class HvySkipNumButtons : public HvyWidgets
{
public:
HvySkipNumButtons::HvySkipNumButtons(
const std::shared_ptr<DX::DeviceResources>& p_deviceResources,
const uint32_t p_number_of_radiettes,
const float& p_horizontal_percent,
const float& p_vertical_percent,
D2D1::ColorF::Enum p_D2D1_ColorF_Enum
);
virtual void Render();
virtual void MouseButtonLeft(std::complex<double> p_mouseClickPhysical);
void SetSkipNumberMaximum(uint32_t p_skipMAXIMUM) { snb_skipMAXIMUM = p_skipMAXIMUM; }
void SetSelectedButton(uint32_t p_selectedButton) { snb_theSelectedButton = p_selectedButton; }
uint32_t GetChosenButton() { return snb_theSelectedButton; }
uint32_t GetDefaultButton() { return 0; }
private:
std::vector<Microsoft::WRL::ComPtr<ID2D1EllipseGeometry>> m_ellipseGeometries;
uint32_t rb_numberOfRadiettes;
uint32_t snb_theSelectedButton;
std::wstring m_text;
uint32_t snb_skipMAXIMUM;
float m_panelCornerRadius;
float m_panelOutlineThickness;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/Content/HvyWidgets.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
namespace HvyDXBase
{
class HvyWidgets
{
public:
HvyWidgets::HvyWidgets(
const std::shared_ptr<DX::DeviceResources>& p_deviceResources,
const float& p_pos_horizontal,
const float& p_pos_vertical,
D2D1::ColorF::Enum p_D2D1_ColorF_Enum
);
//====================================================================
//====================================================================
//
// Non-virtual methods: these methods
// are implemented completely in this base class:
//
//====================================================================
//====================================================================
void CreateDeviceDependentResources(); // Intentionally not virtual;
void ReleaseDeviceDependentResources(); // Intentionally not virtual;
//====================================================================
//====================================================================
//
// Virtual but not pure:
//
//====================================================================
//====================================================================
virtual void Update(
DX::StepTimer const& p_timer,
std::wstring const& p_wchar_message
);
virtual void OnDemandText(std::wstring p_message);
//====================================================================
//====================================================================
//
// Methods that every derived class must implement
// in code that is unique to each derived class:
//
//====================================================================
//====================================================================
virtual void Render() = 0;
virtual void MouseButtonLeft(std::complex<double> p_mouseClickPhysical) = 0;
//=================================================================
//
// My HvyWidgets class has no public data members.
//
//=================================================================
protected:
std::shared_ptr<DX::DeviceResources> m_deviceResources;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_text_SolidColorBrush;
D2D1::ColorF::Enum m_color_enum;
float m_screen_pos_vert;
float m_screen_pos_horz;
DWRITE_TEXT_METRICS m_textMetrics;
Microsoft::WRL::ComPtr<ID2D1DrawingStateBlock1> m_stateBlock;
Microsoft::WRL::ComPtr<IDWriteTextLayout3> m_textLayout;
Microsoft::WRL::ComPtr<IDWriteTextFormat2> m_textFormat;
float m_textMaxWidth;
float m_textMaxHeight;
float m_refDatumX;
float m_refDatumY;
float m_buttonDeltaY;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/Content/Hvy3DScene.h
|
<reponame>GarrettVance/HyperbolicJoyce<gh_stars>0
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
#include "HvySchlafliButtons.h"
#include "HvySkipNumButtons.h"
#include "HvyCheckBoxQuasiRegular.h"
#include "..\vhglib\VhgSystem.h"
namespace HvyDXBase
{
struct ModelViewProjectionConstantBuffer
{
DirectX::XMFLOAT4X4 model;
DirectX::XMFLOAT4X4 view;
DirectX::XMFLOAT4X4 projection;
};
// Used to send per-vertex data to the vertex shader.
struct VertexPositionColor
{
DirectX::XMFLOAT3 pos;
DirectX::XMFLOAT3 color;
};
class Hvy3DScene
{
public:
Hvy3DScene(
const std::shared_ptr<DX::DeviceResources>& deviceResources,
const std::shared_ptr<HvyDXBase::HvySchlafliButtons> & p_schlafliButtons,
const std::shared_ptr<HvyDXBase::HvySkipNumButtons> & p_skipNumButtons,
const std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> & p_checkBoxQuasiRegular
);
void CreateDeviceDependentResources();
void CreateWindowSizeDependentResources();
void ReleaseDeviceDependentResources();
bool displayModeIsMedieval() { return e_ghv_system->displayModeIsMedieval(); }
std::wstring getTilingDescription() { return e_ghv_system->getTilingDescription(); }
void Hvy3DScene::debouncer_for_mouse(void);
void Hvy3DScene::debouncer_for_keyboard(void);
void Update(DX::StepTimer const& timer);
void Hvy3DScene::Render_D2D1(void);
void Hvy3DScene::Render_3D_Shaders(void);
void Render();
void MeshMonoQuad(void);
HvyDXBase::VhgSystem *e_ghv_system;
private:
std::shared_ptr<DX::DeviceResources> m_deviceResources;
std::shared_ptr<HvyDXBase::HvySchlafliButtons> sc_schlafliButtons;
std::shared_ptr<HvyDXBase::HvySkipNumButtons> sc_skipNumButtons;
std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> sc_checkBoxQuasiRegular;
std::unique_ptr<DirectX::Keyboard> e_keyboard;
bool g0_debouncer_processed_mouse;
bool g0_debouncer_processed_keyboard;
Microsoft::WRL::ComPtr<ID3D11Buffer> s3d_conbuf_Klein_buffer;
conbuf_Klein_struct s3d_conbuf_Klein_data;
Microsoft::WRL::ComPtr<ID3D11BlendState> s3d_blend_state;
Microsoft::WRL::ComPtr<ID3D11SamplerState> s3d_texture_sampler_state;
Microsoft::WRL::ComPtr<ID3D11ShaderResourceView> s3d_texture_srv_1;
Microsoft::WRL::ComPtr<ID3D11InputLayout> m_inputLayout;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_vertexBuffer;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_indexBuffer;
uint32 m_indexCount;
Microsoft::WRL::ComPtr<ID3D11VertexShader> m_vertexShader;
Microsoft::WRL::ComPtr<ID3D11PixelShader> m_pixelShader;
Microsoft::WRL::ComPtr<ID3D11Buffer> m_constantBuffer;
ModelViewProjectionConstantBuffer m_constantBufferData;
bool m_loadingComplete;
float m_degreesPerSecond;
bool m_tracking;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/JLine.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "DefTypes.h"
namespace DJJ // <NAME>'s Java classes and methods;
{
class JLine // Class to realize hyperbolic geodesics, be they circular or be they straight.
{
public:
JLine(); // default ctor doesn't do much...
JLine(DJJ::HvyPlex const& pA, DJJ::HvyPlex const& pB); // useful ctor;
JLine(JLine const& p_source); // copy ctor;
DJJ::HvyPlex ReflectPointInLine(DJJ::HvyPlex const & jpt_preimage);
public:
DJJ::HvyPlex endptA_logical; // "this" is the line segment with end points endptA and endptB;
DJJ::HvyPlex endptB_logical; // "this" is the line segment with end points endptA and endptB;
bool isStraight; // is this geodesic a diameter of the Poincare disk???
// if it's a circle, then a center C and radius r are needed:
DJJ::HvyPlex circleCenter; // typical hyperbolic geodesic is circular arc;
double circleRadius; // typical hyperbolic geodesic is circular arc;
// if it's is a straight line, then a point P and a direction D are needed:
DJJ::HvyPlex P_logical;
DJJ::HvyPlex D_logical;
};
}
// Closes namespace DJJ;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/JPoincareDisk.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Content\HvySchlafliButtons.h"
#include "..\Content\HvySkipNumButtons.h"
#include "..\Content\HvyCheckBoxQuasiRegular.h"
#include "DefTypes.h"
#include "JPolygon.h"
namespace DJJ // <NAME>'s Java classes and methods;
{
class JPoincareDisk
{
public:
JPoincareDisk(
const std::shared_ptr<DX::DeviceResources>& p_DeviceResources,
const std::shared_ptr<HvyDXBase::HvySchlafliButtons> & p_schlafliButtons,
const std::shared_ptr<HvyDXBase::HvySkipNumButtons> & p_skipNumButtons,
const std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> & p_checkBoxQuasiRegular
);
std::wstring getTilingDescription();
void init();
void RenderWithoutStars();
void RenderSomeStars();
void updateLikeJoyceJavaUpdate();
private:
D2D1::ColorF randomColor();
int applyRule(int i, int j);
void countPolygons(int p_num_layers);
void determinePolygons();
JPolygon createNextPolygon(JPolygon& srcGon, int s);
public:
static std::random_device e_rng_seed;
static std::mt19937 e_rng_gen;
static std::uniform_real_distribution<float> e_rng_dist;
static bool jj_AlternatingRequested;
private:
std::shared_ptr<DX::DeviceResources> jj_DeviceResources;
std::shared_ptr<HvyDXBase::HvySchlafliButtons> jj_schlafliRadioButtons;
uint32_t jj_schlafliCurrentButton;
uint32_t jj_SchlafliN; // number of sides of the polygon: it is an n-gon;
uint32_t jj_SchlafliK; // vertex valence (number of n-gons meeting at each vertex);
std::shared_ptr<HvyDXBase::HvySkipNumButtons> jj_skipNumberRadioButtons;
uint32_t jj_skipNumberCurrentButton;
uint32_t jj_skipNumber;
uint32_t jj_skipMAXIMUM;
std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> jj_checkBoxQuasiRegular;
bool jj_quasiRegularCheckBoxState;
bool jj_quasiRegular;
Microsoft::WRL::ComPtr<ID2D1PathGeometry> jj_PolygonPathGeometry;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> jj_SolidColorBrush;
std::vector<DJJ::JPolygon> jj_NGons;
std::vector<int> jj_Rules;
std::vector<D2D1::ColorF> jj_ColorVector;
uint32_t jj_totalPolygons;
int jj_innerPolygons;
bool jj_AlternatingGranted;
uint32_t jj_Layers;
};
}
// Closes namespace DJJ;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/Content/Hvy2DHUD.h
|
<reponame>GarrettVance/HyperbolicJoyce
#pragma once
#include <string>
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
namespace HvyDXBase
{
class Hvy2DHUD
{
public:
Hvy2DHUD(const std::shared_ptr<DX::DeviceResources>& deviceResources);
// TODO: add copy ctor and dtor;
void CreateDeviceDependentResources();
void ReleaseDeviceDependentResources();
void Hvy2DHUD::Update(
DX::StepTimer const& p_timer,
std::wstring const& p_wchar_message
);
void Render();
public:
uint32_t m_HUD_id;
private:
std::shared_ptr<DX::DeviceResources> m_deviceResources;
std::wstring m_text;
float m_screen_pos_vert;
float m_screen_pos_horz;
D2D1_COLOR_F m_special_color;
Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> m_text_SolidColorBrush;
DWRITE_TEXT_METRICS m_textMetrics;
Microsoft::WRL::ComPtr<ID2D1DrawingStateBlock1> m_stateBlock;
Microsoft::WRL::ComPtr<IDWriteTextLayout3> m_textLayout;
Microsoft::WRL::ComPtr<IDWriteTextFormat2> m_textFormat;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/EdgeODesic.h
|
<filename>HyperbolicJoyce/vhglib/EdgeODesic.h
#pragma once
#include "..\Common\DeviceResources.h"
#include "DefTypes.h"
#include "JLine.h"
namespace DJJ // <NAME>'s Java classes and methods;
{
class EdgeODesic
{
public:
EdgeODesic();
EdgeODesic(EdgeODesic const& p_source); // copy ctor;
// EdgeODesic::~EdgeODesic();
public:
D2D1_SWEEP_DIRECTION eo_sweepDirection;
DJJ::JLine eo_jLine;
};
}
// Closes namespace DJJ;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/JPolygon.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "DefTypes.h"
#include "EdgeODesic.h"
namespace DJJ // <NAME>'s Java classes and methods;
{
DJJ::HvyPlex ReflectPointInPoint(DJJ::HvyPlex preimage, DJJ::HvyPlex mirror);
double HyperbolicDistanceFromEuclideanDistanceFromOrigin( double p_euclidean_distance_to_origin );
class JPolygon
{
public:
JPolygon(uint32_t p_Taxonomy);
DJJ::HvyPlex getVertex(int i) { return jpolyVertices[i]; }
void setVertex(int i, DJJ::HvyPlex P) { jpolyVertices.at(i) = P; }
static JPolygon constructCenterPolygon(int p_VertexCount, int p_VertexValence, bool p_quasiregular);
void constructEdges();
void GeometryUseNativeArcs(
ID2D1GeometrySink *pSink,
Windows::Foundation::Size const& renderTargetSize
);
public:
uint32_t jpolyTaxonomy; // 5 for Pentagon, 6 for hexagon, ...
std::vector<DJJ::HvyPlex> jpolyVertices;
std::vector<DJJ::EdgeODesic> jpolyEdges;
};
}
// Closes namespace DJJ;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/HyperbolicJoyceMain.h
|
<filename>HyperbolicJoyce/HyperbolicJoyceMain.h
#pragma once
#include "Common\StepTimer.h"
#include "Common\DeviceResources.h"
#include "Content\Hvy3DScene.h"
#include "Content\Hvy2DHUD.h"
#include "Content\HvySchlafliButtons.h"
#include "Content\HvySkipNumButtons.h"
#include "Content\HvyCheckBoxQuasiRegular.h"
namespace HyperbolicJoyce
{
class HyperbolicJoyceMain : public DX::IDeviceNotify
{
public:
HyperbolicJoyceMain(const std::shared_ptr<DX::DeviceResources>& deviceResources);
~HyperbolicJoyceMain();
void CreateWindowSizeDependentResources();
void Update();
bool Render();
// IDeviceNotify
virtual void OnDeviceLost();
virtual void OnDeviceRestored();
private:
std::shared_ptr<DX::DeviceResources> m_deviceResources;
DX::StepTimer m_timer;
std::unique_ptr<DirectX::Mouse> e_mouse;
DirectX::Mouse::ButtonStateTracker tracker;
std::unique_ptr<HvyDXBase::Hvy3DScene> m_sceneRenderer;
std::unique_ptr<HvyDXBase::Hvy2DHUD> hudZero;
std::shared_ptr<HvyDXBase::HvySchlafliButtons> schlafliButtons;
std::shared_ptr<HvyDXBase::HvySkipNumButtons> skipNumberButtons;
std::shared_ptr<HvyDXBase::HvyCheckBoxQuasiRegular> checkBoxQuasiRegular;
};
}
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/BitmapUtil.h
|
<reponame>GarrettVance/HyperbolicJoyce<filename>HyperbolicJoyce/vhglib/BitmapUtil.h<gh_stars>0
#pragma once
#include "..\Common\DeviceResources.h"
#include "DefTypes.h"
namespace HvyDXBase
{
//
// generic method to create D2D1Bitmap from an Image File:
//
void CreateSimpleD2D1BitmapFromImage(
std::shared_ptr<DX::DeviceResources>const & p_DeviceResources,
Microsoft::WRL::ComPtr<ID2D1Bitmap>& p_comptr_D2D1Bitmap, // ghv : call by reference or fail and crash;
std::wstring p_file_path
);
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/Content/HvyCheckBoxQuasiRegular.h
|
#pragma once
#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
#include "HvyWidgets.h"
namespace HvyDXBase
{
class HvyCheckBoxQuasiRegular : public HvyWidgets
{
public:
HvyCheckBoxQuasiRegular::HvyCheckBoxQuasiRegular(
const std::shared_ptr<DX::DeviceResources>& p_deviceResources,
const float& p_horizontal_percent,
const float& p_vertical_percent,
D2D1::ColorF::Enum p_D2D1_ColorF_Enum
);
virtual void Render();
virtual void MouseButtonLeft(std::complex<double> p_mouseClickPhysical);
void SetCheckedState(bool p_buttonState) { m_buttonState = p_buttonState; }
bool GetCheckedState() { return m_buttonState; }
bool GetDefaultState() { return false; }
private:
std::vector<Microsoft::WRL::ComPtr<ID2D1EllipseGeometry>> m_ellipseGeometries;
bool m_buttonState;
std::wstring m_text;
float m_panelCornerRadius;
float m_panelOutlineThickness;
};
}
// Closes namespace HvyDXBase;
|
GarrettVance/HyperbolicJoyce
|
HyperbolicJoyce/vhglib/DefTypes.h
|
<reponame>GarrettVance/HyperbolicJoyce
#pragma once
#include <complex>
#define GHV_OPTION_USE_DJJ_CHOPPER
namespace DJJ // <NAME>'s Java classes and methods;
{
using HvyPlex = std::complex<double>;
}
// Closes namespace DJJ;
namespace HvyDXBase
{
using HvyPlex = std::complex<double>;
struct HvyGeodesic
{
public:
bool e_infinite_radius;
double e_radius;
std::complex<double> e_center;
};
struct Hv3D_ViewTransform
{
double scale;
double rotation;
double translationX;
double translationY;
};
struct conbuf_Klein_struct
{
DirectX::XMFLOAT2 obs_z;
DirectX::XMFLOAT2 obs_dir;
DirectX::XMFLOAT2 e_pixel_size; // Store pixel size in x;
DirectX::XMFLOAT2 e_alpha_channel;
};
}
// Closes namespace HvyDXBase;
|
MobMonRob/ScrewRobotStudien
|
ros/src/dhbw_screw_localization/include/dhbw_screw_localization/PclScrew.h
|
#ifndef PCLSCREW_H_
#define PCLSCREW_H_
#include <pcl/common/common.h>
#include <pcl/common/centroid.h>
#include <pcl/common/transforms.h>
class PclScrew
{
public:
PclScrew(pcl::PointCloud<pcl::PointXYZ> pCloud,
pcl::PointXYZ pointMin,
pcl::PointXYZ pointMax,
Eigen::Quaternionf rotation,
Eigen::Vector3f translation)
: m_pCloud(pCloud),
m_pointMin(pointMin),
m_pointMax(pointMax),
m_rotation(rotation),
m_translation(translation) {};
pcl::PointCloud<pcl::PointXYZ> getPCloud() { return m_pCloud; };
private:
pcl::PointCloud<pcl::PointXYZ> m_pCloud;
pcl::PointXYZ m_pointMin;
pcl::PointXYZ m_pointMax;
Eigen::Quaternionf m_rotation;
Eigen::Vector3f m_translation;
};
#endif
|
MobMonRob/ScrewRobotStudien
|
ros/src/dhbw_screw_localization/include/dhbw_screw_localization/PclEye.h
|
#ifndef PCLEYE_H_
#define PCLEYE_H_
#include <pcl_ros/point_cloud.h>
#include "PclEyeParameters.h"
#include "PclScrew.h"
#include "PclScrewRecognitionTools.h"
class PclEye
{
public:
static PclEye* openUp();
PclEye* useTheseParameters(PclEyeParameters parameters);
std::shared_ptr<PclScrew> toFindScrewIn(pcl::PointCloud<pcl::PointXYZ>::Ptr pCloud);
private:
PclEye() {};
static PclEye* m_singleton;
PclEyeParameters m_parameters;
};
#endif
|
MobMonRob/ScrewRobotStudien
|
ros/src/dhbw_screw_localization/include/dhbw_screw_localization/PclEyeParameters.h
|
<filename>ros/src/dhbw_screw_localization/include/dhbw_screw_localization/PclEyeParameters.h
#ifndef PCLEYEPARAMETERS_H_
#define PCLEYEPARAMETERS_H_
#include <string>
#include <vector>
struct PclEuclideanClusterExtractionParameters
{
float tolerance;
int minSize;
int maxSize;
};
enum PclPassThroughFieldName : unsigned int
{
X = 0,
Y = 1,
Z = 2
};
struct PclPassThroughParameters
{
PclPassThroughFieldName filterFieldName;
float filterLimitMin;
float filterLimitMax;
};
enum PclSacModel : unsigned int
{
PLANE
};
enum PclSacMethod : unsigned int
{
RANSAC
};
struct PclSacSegmentationParameters
{
PclSacModel model;
PclSacMethod method;
float distanceThreshold;
};
struct PclSvmClassificationParameters
{
bool training;
std::string pathToModel;
double positive;
};
struct PclVfhEstimationParameters
{
float normalsRadiusSearch;
};
struct PclEyeParameters
{
PclEuclideanClusterExtractionParameters ece;
std::vector<PclPassThroughParameters> pt;
std::vector<PclSacSegmentationParameters> sacs;
PclSvmClassificationParameters svmc;
PclVfhEstimationParameters vfhe;
};
#endif
|
MobMonRob/ScrewRobotStudien
|
ros/src/dhbw_screw_localization/include/dhbw_screw_localization/PclScrewRecognitionTools.h
|
#ifndef PCLSCREWRECOGNITIONTOOLS_H_H
#define PCLSCREWRECOGNITIONTOOLS_H_H
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/filters/extract_indices.h>
#include <pcl/segmentation/extract_clusters.h>
#include <pcl/filters/passthrough.h>
#include <pcl/sample_consensus/method_types.h>
#include <pcl/sample_consensus/model_types.h>
#include <pcl/segmentation/sac_segmentation.h>
#include <pcl/ml/svm_wrapper.h>
#include <pcl/features/normal_3d.h>
#include <pcl/features/vfh.h>
#include "dhbw_screw_localization/PclEye.h"
#include <vector>
#include <memory>
typedef pcl::PointCloud<pcl::PointXYZ> PCloud;
typedef pcl::PointCloud<pcl::PointXYZ>::Ptr PCloudPtr;
typedef std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> PCloudPtrVector;
typedef std::shared_ptr<PclScrew> PclScrewPtr;
typedef pcl::PointCloud<pcl::VFHSignature308> VFHFeature;
typedef pcl::PointCloud<pcl::VFHSignature308>::Ptr VFHFeaturePtr;
typedef pcl::SVMData PclSvmData;
typedef std::vector<pcl::SVMDataPoint> PclSvmDataPointVector;
class PclScrewRecognitionTools
{
public:
PclScrewRecognitionTools(PclEyeParameters parameters) : m_parameters(parameters) {};
PclScrewPtr localizeScrew(PCloudPtr pCloud);
PclScrewPtr calculateResult(PCloudPtr pCloud);
PCloudPtrVector euclideanClusterExtraction(PCloudPtr pCloud);
void passThrough(PCloudPtr pCloud);
void sacSegmentation(PCloudPtr pCloud);
bool svmClassification(PCloudPtr pCloud);
VFHFeaturePtr vfhEstimation(PCloudPtr pCloud);
private:
pcl::SVMData generateSvmDataOf(VFHFeaturePtr feature);
PclEyeParameters& m_parameters;
static const std::map<PclPassThroughFieldName, std::string> m_pt_field_name;
static const std::map<PclSacModel, int> m_sac_model;
static const std::map<PclSacMethod, int> m_sac_method;
};
#endif
|
SharmagRit/device_xiaomi_whyred
|
gps/android/2.0/GnssMeasurement.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/*
* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
* Not a Contribution
*/
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#define ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
#include <android/hardware/gnss/2.0/IGnssMeasurement.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::hardware::hidl_vec;
using ::android::hardware::hidl_string;
using ::android::sp;
class MeasurementAPIClient;
struct GnssMeasurement : public V2_0::IGnssMeasurement {
GnssMeasurement();
~GnssMeasurement();
/*
* Methods from ::android::hardware::gnss::V1_0::IGnssMeasurement follow.
* These declarations were generated from IGnssMeasurement.hal.
*/
Return<GnssMeasurement::GnssMeasurementStatus> setCallback(
const sp<V1_0::IGnssMeasurementCallback>& callback) override;
Return<void> close() override;
// Methods from ::android::hardware::gnss::V1_1::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_1_1(
const sp<V1_1::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
// Methods from ::android::hardware::gnss::V2_0::IGnssMeasurement follow.
Return<GnssMeasurement::GnssMeasurementStatus> setCallback_2_0(
const sp<V2_0::IGnssMeasurementCallback>& callback,
bool enableFullTracking) override;
private:
struct GnssMeasurementDeathRecipient : hidl_death_recipient {
GnssMeasurementDeathRecipient(sp<GnssMeasurement> gnssMeasurement) :
mGnssMeasurement(gnssMeasurement) {
}
~GnssMeasurementDeathRecipient() = default;
virtual void serviceDied(uint64_t cookie, const wp<IBase>& who) override;
sp<GnssMeasurement> mGnssMeasurement;
};
private:
sp<GnssMeasurementDeathRecipient> mGnssMeasurementDeathRecipient = nullptr;
sp<V1_0::IGnssMeasurementCallback> mGnssMeasurementCbIface = nullptr;
sp<V1_1::IGnssMeasurementCallback> mGnssMeasurementCbIface_1_1 = nullptr;
sp<V2_0::IGnssMeasurementCallback> mGnssMeasurementCbIface_2_0 = nullptr;
MeasurementAPIClient* mApi;
void clearInterfaces();
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V2_0_GNSSMEASUREMENT_H
|
SharmagRit/device_xiaomi_whyred
|
gps/android/2.0/location_api/GnssAPIClient.h
|
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GNSS_API_CLINET_H
#define GNSS_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnss.h>
#include <android/hardware/gnss/2.0/IGnssCallback.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
using ::android::sp;
class GnssAPIClient : public LocationAPIClientBase
{
public:
GnssAPIClient(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
GnssAPIClient(const sp<V2_0::IGnssCallback>& gpsCb);
GnssAPIClient(const GnssAPIClient&) = delete;
GnssAPIClient& operator=(const GnssAPIClient&) = delete;
// for GpsInterface
void gnssUpdateCallbacks(const sp<V1_0::IGnssCallback>& gpsCb,
const sp<V1_0::IGnssNiCallback>& niCb);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssCallback>& gpsCb);
bool gnssStart();
bool gnssStop();
bool gnssSetPositionMode(V1_0::IGnss::GnssPositionMode mode,
V1_0::IGnss::GnssPositionRecurrence recurrence,
uint32_t minIntervalMs,
uint32_t preferredAccuracyMeters,
uint32_t preferredTimeMs,
GnssPowerMode powerMode = GNSS_POWER_MODE_INVALID,
uint32_t timeBetweenMeasurement = 0);
// for GpsNiInterface
void gnssNiRespond(int32_t notifId, V1_0::IGnssNiCallback::GnssUserResponseType userResponse);
// these apis using LocationAPIControlClient
void gnssDeleteAidingData(V1_0::IGnss::GnssAidingData aidingDataFlags);
void gnssEnable(LocationTechnologyType techType);
void gnssDisable();
void gnssConfigurationUpdate(const GnssConfig& gnssConfig);
inline LocationCapabilitiesMask gnssGetCapabilities() const {
return mLocationCapabilitiesMask;
}
void requestCapabilities();
// callbacks we are interested in
void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
void onTrackingCb(Location location) final;
void onGnssNiCb(uint32_t id, GnssNiNotification gnssNiNotification) final;
void onGnssSvCb(GnssSvNotification gnssSvNotification) final;
void onGnssNmeaCb(GnssNmeaNotification gnssNmeaNotification) final;
void onStartTrackingCb(LocationError error) final;
void onStopTrackingCb(LocationError error) final;
private:
virtual ~GnssAPIClient();
void setCallbacks();
void initLocationOptions();
sp<V1_0::IGnssCallback> mGnssCbIface;
sp<V1_0::IGnssNiCallback> mGnssNiCbIface;
std::mutex mMutex;
LocationAPIControlClient* mControlClient;
LocationCapabilitiesMask mLocationCapabilitiesMask;
bool mLocationCapabilitiesCached;
TrackingOptions mTrackingOptions;
bool mTracking;
sp<V2_0::IGnssCallback> mGnssCbIface_2_0;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // GNSS_API_CLINET_H
|
SharmagRit/device_xiaomi_whyred
|
gps/location/ILocationAPI.h
|
<gh_stars>100-1000
/* Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ILOCATIONAPI_H
#define ILOCATIONAPI_H
#include "LocationDataTypes.h"
class ILocationAPI
{
public:
virtual ~ILocationAPI(){};
/** @brief Updates/changes the callbacks that will be called.
mandatory callbacks must be present for callbacks to be successfully updated
no return value */
virtual void updateCallbacks(LocationCallbacks&) = 0;
/* ================================== TRACKING ================================== */
/** @brief Starts a tracking session, which returns a session id that will be
used by the other tracking APIs and also in the responseCallback to match command
with response. locations are reported on the registered trackingCallback
periodically according to LocationOptions.
@return session id
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successfully started
LOCATION_ERROR_ALREADY_STARTED if a startTracking session is already in progress
LOCATION_ERROR_CALLBACK_MISSING if no trackingCallback was passed
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameter is invalid */
virtual uint32_t startTracking(TrackingOptions&) = 0;
/** @brief Stops a tracking session associated with id parameter.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
virtual void stopTracking(uint32_t id) = 0;
/** @brief Changes the LocationOptions of a tracking session associated with id.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a tracking session */
virtual void updateTrackingOptions(uint32_t id, TrackingOptions&) = 0;
/* ================================== BATCHING ================================== */
/** @brief starts a batching session, which returns a session id that will be
used by the other batching APIs and also in the responseCallback to match command
with response. locations are reported on the batchingCallback passed in createInstance
periodically according to LocationOptions. A batching session starts tracking on
the low power processor and delivers them in batches by the batchingCallback when
the batch is full or when getBatchedLocations is called. This allows for the processor
that calls this API to sleep when the low power processor can batch locations in the
backgroup and wake up the processor calling the API only when the batch is full, thus
saving power.
@return session id
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_ALREADY_STARTED if a startBatching session is already in progress
LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback
LOCATION_ERROR_INVALID_PARAMETER if a parameter is invalid
LOCATION_ERROR_NOT_SUPPORTED if batching is not supported */
virtual uint32_t startBatching(BatchingOptions&) = 0;
/** @brief Stops a batching session associated with id parameter.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with batching session */
virtual void stopBatching(uint32_t id) = 0;
/** @brief Changes the LocationOptions of a batching session associated with id.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if LocationOptions parameters are invalid
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
virtual void updateBatchingOptions(uint32_t id, BatchingOptions&) = 0;
/** @brief Gets a number of locations that are currently stored/batched
on the low power processor, delivered by the batchingCallback passed in createInstance.
Location are then deleted from the batch stored on the low power processor.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful, will be followed by batchingCallback call
LOCATION_ERROR_CALLBACK_MISSING if no batchingCallback
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a batching session */
virtual void getBatchedLocations(uint32_t id, size_t count) = 0;
/* ================================== GEOFENCE ================================== */
/** @brief Adds any number of geofences and returns an array of geofence ids that
will be used by the other geofence APIs and also in the collectiveResponseCallback to
match command with response. The geofenceBreachCallback will deliver the status of each
geofence according to the GeofenceOption for each. The geofence id array returned will
be valid until the collectiveResponseCallback is called and has returned.
@return id array
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_CALLBACK_MISSING if no geofenceBreachCallback
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if geofence is not supported */
virtual uint32_t* addGeofences(size_t count, GeofenceOption*, GeofenceInfo*) = 0;
/** @brief Removes any number of geofences. Caller should delete ids array after
removeGeofences returneds.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
virtual void removeGeofences(size_t count, uint32_t* ids) = 0;
/** @brief Modifies any number of geofences. Caller should delete ids array after
modifyGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid */
virtual void modifyGeofences(size_t count, uint32_t* ids, GeofenceOption* options) = 0;
/** @brief Pauses any number of geofences, which is similar to removeGeofences,
only that they can be resumed at any time. Caller should delete ids array after
pauseGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
virtual void pauseGeofences(size_t count, uint32_t* ids) = 0;
/** @brief Resumes any number of geofences that are currently paused. Caller should
delete ids array after resumeGeofences returns.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_ID_UNKNOWN if id is not associated with a geofence session */
virtual void resumeGeofences(size_t count, uint32_t* ids) = 0;
/* ================================== GNSS ====================================== */
/** @brief gnssNiResponse is called in response to a gnssNiCallback.
responseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters in GnssNiResponse are invalid
LOCATION_ERROR_ID_UNKNOWN if id does not match a gnssNiCallback */
virtual void gnssNiResponse(uint32_t id, GnssNiResponse response) = 0;
};
class ILocationControlAPI
{
public:
virtual ~ILocationControlAPI(){};
/** @brief Updates the gnss specific configuration, which returns a session id array
with an id for each of the bits set in GnssConfig.flags, order from low bits to high bits.
The response for each config that is set will be returned in collectiveResponseCallback.
The session id array returned will be valid until the collectiveResponseCallback is called
and has returned. This effect is global for all clients of ILocationAPI.
collectiveResponseCallback returns:
LOCATION_ERROR_SUCCESS if session was successful
LOCATION_ERROR_INVALID_PARAMETER if any other parameters are invalid
LOCATION_ERROR_GENERAL_FAILURE if failure for any other reason */
virtual uint32_t* gnssUpdateConfig(const GnssConfig& config) = 0;
/** @brief Delete specific gnss aiding data for testing, which returns a session id
that will be returned in responseCallback to match command with response.
Only allowed in userdebug builds. This effect is global for all clients of ILocationAPI.
responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
LOCATION_ERROR_NOT_SUPPORTED if build is not userdebug */
virtual uint32_t gnssDeleteAidingData(GnssAidingData& data) = 0;
/** @brief
Configure the constellation and SVs to be used by the GNSS engine on
modem.
@param
constellationEnablementConfig: configuration to enable/disable SV
constellation to be used by SPE engine. When size in
constellationEnablementConfig is set to 0, this indicates to reset SV
constellation configuration to modem NV default.
blacklistSvConfig: configuration to blacklist or unblacklist SVs
used by SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellations(
const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig) = 0;
/** @brief
Configure the secondary band of constellations to be used by
the GNSS engine on modem.
@param
secondaryBandConfig: configuration the secondary band usage
for SPE engine
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configConstellationSecondaryBand(
const GnssSvTypeConfig& secondaryBandConfig) = 0;
/** @brief
Enable or disable the constrained time uncertainty feature.
@param
enable: true to enable the constrained time uncertainty
feature and false to disable the constrainted time
uncertainty feature.
@param
tuncThreshold: this specifies the time uncertainty threshold
that gps engine need to maintain, in units of milli-seconds.
Default is 0.0 meaning that modem default value of time
uncertainty threshold will be used. This parameter is
ignored when requesting to disable this feature.
@param
energyBudget: this specifies the power budget that gps
engine is allowed to spend to maintain the time uncertainty.
Default is 0 meaning that GPS engine is not constained by
power budget and can spend as much power as needed. The
parameter need to be specified in units of 0.1 milli watt
second. This parameter is ignored requesting to disable this
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters
are invalid
*/
virtual uint32_t configConstrainedTimeUncertainty(
bool enable, float tuncThreshold = 0.0,
uint32_t energyBudget = 0) = 0;
/** @brief
Enable or disable position assisted clock estimator feature.
@param
enable: true to enable position assisted clock estimator and
false to disable the position assisted clock estimator
feature.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configPositionAssistedClockEstimator(bool enable) = 0;
/** @brief
Sets the lever arm parameters for the vehicle.
@param
configInfo: lever arm configuration info regarding below two
types of lever arm info:
a: GNSS Antenna w.r.t the origin at the IMU e.g.: inertial
measurement unit.
b: lever arm parameters regarding the OPF (output frame)
w.r.t the origin (at the GPS Antenna). Vehicle manufacturers
prefer the position output to be tied to a specific point in
the vehicle rather than where the antenna is placed
(midpoint of the rear axle is typical).
Caller can choose types of lever arm info to configure via the
leverMarkTypeMask.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configLeverArm(const LeverArmConfigInfo& configInfo) = 0;
/** @brief
Configure the robust location setting.
@param
enable: true to enable robust location and false to disable
robust location.
@param
enableForE911: true to enable robust location when device is on
E911 session and false to disable on E911 session.
This parameter is only valid if robust location is enabled.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configRobustLocation(bool enable, bool enableForE911) = 0;
/** @brief
Config the minimum GPS week used by modem GNSS engine.
@param
minGpsWeek: minimum GPS week to be used by modem GNSS engine.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configMinGpsWeek(uint16_t minGpsWeek) = 0;
/** @brief
Configure the vehicle body-to-Sensor mount parameters and
other parameters for dead reckoning position engine.
@param
dreConfig: vehicle body-to-Sensor mount angles and other
parameters.
@return
A session id that will be returned in responseCallback to
match command with response. This effect is global for all
clients of LocationAPI responseCallback returns:
LOCATION_ERROR_SUCCESS if successful
LOCATION_ERROR_INVALID_PARAMETER if any parameters are invalid
*/
virtual uint32_t configDeadReckoningEngineParams(const DeadReckoningEngineConfig& dreConfig)=0;
};
#endif /* ILOCATIONAPI_H */
|
SharmagRit/device_xiaomi_whyred
|
gps/pla/oe/loc_pla.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/* Copyright (c) 2014, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LOC_PLA__
#define __LOC_PLA__
#ifdef __cplusplus
#ifndef FEATURE_EXTERNAL_AP
#include <utils/SystemClock.h>
#endif /* FEATURE_EXTERNAL_AP */
#include <inttypes.h>
#include <sys/time.h>
#include <time.h>
#if defined(__GNUC__) && defined(__GNUC_PREREQ)
#if __GNUC_PREREQ(6,0)
#pragma message "GNU C version is above 6"
#else
#pragma message "GNU C version is less than 6"
#define NO_UNORDERED_SET_OR_MAP
#endif
#endif
// use set/map instead of unordered_set/unordered_map for
// older GCC versions
#ifdef NO_UNORDERED_SET_OR_MAP
#define unordered_set set
#define unordered_map map
#endif
inline int64_t sysTimeMillis(int clock)
{
struct timespec ts;
int64_t time_ms = 0;
clock_gettime(clock, &ts);
time_ms += (ts.tv_sec * 1000000000LL);
time_ms += ts.tv_nsec + 500000LL;
return time_ms / 1000000LL;
}
inline int64_t uptimeMillis() {
return sysTimeMillis(CLOCK_MONOTONIC);
}
inline int64_t elapsedRealtime() {
return sysTimeMillis(CLOCK_BOOTTIME);
}
extern "C" {
#endif
#ifndef FEATURE_EXTERNAL_AP
#include <cutils/properties.h>
#include <cutils/threads.h>
#include <cutils/sched_policy.h>
#else
#define set_sched_policy(a, b)
#endif /* FEATURE_EXTERNAL_AP */
#include <pthread.h>
#include <sys/time.h>
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#define MAX_COMMAND_STR_LEN (255)
#define BOOT_KPI_FILE "/sys/kernel/debug/bootkpi/kpi_values"
#ifndef OFF_TARGET
#include <glib.h>
#define strlcat g_strlcat
#define strlcpy g_strlcpy
#else
#define strlcat strncat
#define strlcpy strncpy
#endif
#define UID_GPS (1021)
#define GID_GPS (1021)
#define UID_LOCCLIENT (4021)
#define GID_LOCCLIENT (4021)
#define LOC_PATH_GPS_CONF_STR "/etc/gps.conf"
#define LOC_PATH_IZAT_CONF_STR "/etc/izat.conf"
#define LOC_PATH_FLP_CONF_STR "/etc/flp.conf"
#define LOC_PATH_LOWI_CONF_STR "/etc/lowi.conf"
#define LOC_PATH_SAP_CONF_STR "/etc/sap.conf"
#define LOC_PATH_APDR_CONF_STR "/etc/apdr.conf"
#define LOC_PATH_XTWIFI_CONF_STR "/etc/xtwifi.conf"
#define LOC_PATH_QUIPC_CONF_STR "/etc/quipc.conf"
#define LOC_PATH_ANT_CORR_STR "/etc/gnss_antenna_info.conf"
#define LOC_PATH_SLIM_CONF_STR "/etc/slim.conf"
#define LOC_PATH_VPE_CONF_STR "/etc/vpeglue.conf"
#ifdef FEATURE_EXTERNAL_AP
#define PROPERTY_VALUE_MAX 92
inline int property_get(const char* key, char* value, const char* default_value)
{
strlcpy(value, default_value, PROPERTY_VALUE_MAX - 1);
return strlen(value);
}
#endif /* FEATURE_EXTERNAL_AP */
/*!
* @brief Function for memory block copy
*
* @param[out] p_Dest Destination buffer.
* @param[in] q_DestSize Destination buffer size.
* @param[in] p_Src Source buffer.
* @param[in] q_SrcSize Source buffer size.
*
* @return Number of bytes copied.
*/
static inline size_t memscpy (void *p_Dest, size_t q_DestSize, const void *p_Src, size_t q_SrcSize)
{
size_t res = (q_DestSize < q_SrcSize) ? q_DestSize : q_SrcSize;
if (p_Dest && p_Src && q_DestSize > 0 && q_SrcSize > 0) {
memcpy(p_Dest, p_Src, res);
} else {
res = 0;
}
return res;
}
/*API for boot kpi marker prints */
static inline int loc_boot_kpi_marker(const char * pFmt, ...)
{
int result = 0;
FILE *stream = NULL;
char data[MAX_COMMAND_STR_LEN] = {};
char buf[MAX_COMMAND_STR_LEN] = {};
va_list ap;
va_start(ap, pFmt);
vsnprintf(&buf[0], sizeof(buf), pFmt, ap);
snprintf(data, sizeof(data), "echo -n %s > %s", buf, BOOT_KPI_FILE);
stream = popen(data, "w" );
if (NULL == stream) {
result = -1;
} else {
pclose(stream);
}
va_end(ap);
return result;
}
#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __LOC_PLA__ */
|
SharmagRit/device_xiaomi_whyred
|
gps/android/2.0/location_api/BatchingAPIClient.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef BATCHING_API_CLINET_H
#define BATCHING_API_CLINET_H
#include <mutex>
#include <android/hardware/gnss/2.0/IGnssBatching.h>
#include <android/hardware/gnss/2.0/IGnssBatchingCallback.h>
#include <pthread.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_0 {
namespace implementation {
class BatchingAPIClient : public LocationAPIClientBase
{
public:
BatchingAPIClient(const sp<V1_0::IGnssBatchingCallback>& callback);
BatchingAPIClient(const sp<V2_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks(const sp<V1_0::IGnssBatchingCallback>& callback);
void gnssUpdateCallbacks_2_0(const sp<V2_0::IGnssBatchingCallback>& callback);
int getBatchSize();
int startSession(const V1_0::IGnssBatching::Options& options);
int updateSessionOptions(const V1_0::IGnssBatching::Options& options);
int stopSession();
void getBatchedLocation(int last_n_locations);
void flushBatchedLocations();
inline LocationCapabilitiesMask getCapabilities() { return mLocationCapabilitiesMask; }
// callbacks
void onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) final;
void onBatchingCb(size_t count, Location* location, BatchingOptions batchOptions) final;
private:
void setCallbacks();
~BatchingAPIClient();
std::mutex mMutex;
sp<V1_0::IGnssBatchingCallback> mGnssBatchingCbIface;
uint32_t mDefaultId;
LocationCapabilitiesMask mLocationCapabilitiesMask;
sp<V2_0::IGnssBatchingCallback> mGnssBatchingCbIface_2_0;
};
} // namespace implementation
} // namespace V2_0
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // BATCHING_API_CLINET_H
|
SharmagRit/device_xiaomi_whyred
|
gps/utils/LocTimer.h
|
/* Copyright (c) 2015, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_TIMER_CPP_H__
#define __LOC_TIMER_CPP_H__
#include <stddef.h>
#include <loc_pla.h>
namespace loc_util {
// opaque class to provide service implementation.
class LocTimerDelegate;
class LocSharedLock;
// LocTimer client must extend this class and implementthe callback.
// start() / stop() methods are to arm / disarm timer.
class LocTimer
{
LocTimerDelegate* mTimer;
LocSharedLock* mLock;
// don't really want mLock to be manipulated by clients, yet LocTimer
// has to have a reference to the lock so that the delete of LocTimer
// and LocTimerDelegate can work together on their share resources.
friend class LocTimerDelegate;
public:
LocTimer();
virtual ~LocTimer();
// timeOutInMs: timeout delay in ms
// wakeOnExpire: true if to wake up CPU (if sleeping) upon timer
// expiration and notify the client.
// false if to wait until next time CPU wakes up (if
// sleeping) and then notify the client.
// return: true on success;
// false on failure, e.g. timer is already running.
bool start(uint32_t timeOutInMs, bool wakeOnExpire);
// return: true on success;
// false on failure, e.g. timer is not running.
bool stop();
// LocTimer client Should implement this method.
// This method is used for timeout calling back to client. This method
// should be short enough (eg: send a message to your own thread).
virtual void timeOutCallback() = 0;
};
} // namespace loc_util
#endif //__LOC_DELAY_H__
|
SharmagRit/device_xiaomi_whyred
|
gps/utils/loc_log.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/* Copyright (c) 2011-2012, 2015, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef LOC_LOG_H
#define LOC_LOG_H
#include <ctype.h>
#include <stdlib.h>
#include <unordered_map>
#include <string>
#include "loc_target.h"
#include "loc_misc_utils.h"
using std::string;
using std::unordered_map;
typedef unordered_map<int64_t, string> NameValTbl;
#define NAME_VAL(x) {x, "" #x ""}
#define DECLARE_TBL(T) static const NameValTbl T##_tbl
extern const string gEmptyStr;
extern const string gUnknownStr;
#define CHECK_MASK(type, value, mask_var, mask) \
(((mask_var) & (mask)) ? (type) (value) : (type) (-1))
#define LOC_TABLE_SIZE(table) (sizeof(table)/sizeof((table)[0]))
#define FIELDVAL_DEC(field) \
loc_put_tag_val(#field, to_string(field))
#define FIELDVAL_DEC_ARR(field) \
loc_put_tag_val(#field, \
loc_parenthesize(loc_prim_arr_to_string(field, \
sizeof(field)/sizeof(field[0]))))
#define FIELDVAL_HEX(field) \
loc_put_tag_val(#field, to_string_hex(field))
#define FIELDVAL_HEX_ARR(field) \
loc_put_tag_val(#field, \
loc_parenthesize(loc_prim_arr_to_string(field, \
sizeof(field)/sizeof(field[0]), \
false)))
#define FIELDVAL_ENUM(field, tbl) \
loc_put_tag_val(#field, \
loc_get_name_from_tbl(tbl, field, gUnknownStr))
#define FIELDVAL_MASK(field, tbl) \
loc_put_tag_val(#field, \
to_string_hex((uint64_t)field) + " " + \
loc_parenthesize(loc_get_bit_defs(field, tbl)))
/* get from a table of strings with index */
/* tbl - map of <int, string> entries
key - key to the matching entry
defalt - default pointer in case of incorrect parameters
*/
inline static const string& loc_get_name_from_tbl(const NameValTbl& tbl, int64_t key,
const string& defalt = gEmptyStr) {
auto item = tbl.find(key);
if (item != tbl.end()) {
return item->second;
} else {
return defalt;
}
}
/* puts to string formatted "TAG: VAL" with option ending string, default to newline */
inline string loc_put_tag_val(const string& tag, const string& val, const string& eol = "\n") {
return tag + ": " + val + eol;
}
inline string loc_parenthesize(const string& str) {
return "(" + str + ")";
}
/* Get names from value */
inline const char* loc_get_name_from_val(const NameValTbl& table, int64_t value) {
return loc_get_name_from_tbl(table, value, gUnknownStr).c_str();
}
inline const char* log_succ_fail_string(int is_succ) {
return is_succ? "successful" : "failed";
}
/* prints mask into a string with bit definitions from tbl */
/* mask - bit mask, to be expanded into " BIT_NAMEx | BIT_NAMEy ... "
tbl - a table with defs for each bit, defined as <bit, name> entries
{{bit0, "BIT0_NAME"}, {bit1, "BIT1_NAME"}, .... {bitn, "BITn_NAME"} }
entries - number of strings in the table
*/
string loc_get_bit_defs(uint64_t mask, const NameValTbl& tbl);
uint64_t loc_get_least_bit(uint64_t& mask, bool clearThebit = true);
const char* loc_get_msg_q_status(int status);
const char* loc_get_target_name(unsigned int target);
char *loc_get_time(char *time_string, size_t buf_size);
#endif /* LOC_LOG_H */
|
SharmagRit/device_xiaomi_whyred
|
gps/android/2.0/MeasurementCorrections.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/*
* Copyright (c) 2019-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#define ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrections.h>
#include <android/hardware/gnss/measurement_corrections/1.0/IMeasurementCorrectionsCallback.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include <location_interface.h>
namespace android {
namespace hardware {
namespace gnss {
namespace measurement_corrections {
namespace V1_0 {
namespace implementation {
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_memory;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::sp;
using ::android::hardware::gnss::V1_0::GnssLocation;
using ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrectionsCallback;
struct MeasurementCorrections : public IMeasurementCorrections {
MeasurementCorrections();
~MeasurementCorrections();
// Methods from ::android::hardware::gnss::measurement_corrections::V1_0::IMeasurementCorrections follow.
Return<bool> setCorrections(
const ::android::hardware::gnss::measurement_corrections::
V1_0::MeasurementCorrections& corrections) override;
Return<bool> setCallback(const sp<IMeasurementCorrectionsCallback>& callback) override;
};
} // namespace implementation
} // namespace V1_0
} // namespace measurement_corrections
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_GNSS_V1_0_MeasurementCorrections_H
|
SharmagRit/device_xiaomi_whyred
|
gps/android/2.1/location_api/GeofenceAPIClient.h
|
<reponame>SharmagRit/device_xiaomi_whyred
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef GEOFENCE_API_CLINET_H
#define GEOFENCE_API_CLINET_H
#include <android/hardware/gnss/1.0/IGnssGeofenceCallback.h>
#include <LocationAPIClientBase.h>
namespace android {
namespace hardware {
namespace gnss {
namespace V2_1 {
namespace implementation {
using ::android::sp;
class GeofenceAPIClient : public LocationAPIClientBase
{
public:
GeofenceAPIClient(const sp<V1_0::IGnssGeofenceCallback>& callback);
void geofenceAdd(uint32_t geofence_id, double latitude, double longitude,
double radius_meters, int32_t last_transition, int32_t monitor_transitions,
uint32_t notification_responsiveness_ms, uint32_t unknown_timer_ms);
void geofencePause(uint32_t geofence_id);
void geofenceResume(uint32_t geofence_id, int32_t monitor_transitions);
void geofenceRemove(uint32_t geofence_id);
void geofenceRemoveAll();
// callbacks
void onGeofenceBreachCb(GeofenceBreachNotification geofenceBreachNotification) final;
void onGeofenceStatusCb(GeofenceStatusNotification geofenceStatusNotification) final;
void onAddGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onRemoveGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onPauseGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
void onResumeGeofencesCb(size_t count, LocationError* errors, uint32_t* ids) final;
private:
virtual ~GeofenceAPIClient() = default;
sp<V1_0::IGnssGeofenceCallback> mGnssGeofencingCbIface;
};
} // namespace implementation
} // namespace V2_1
} // namespace gnss
} // namespace hardware
} // namespace android
#endif // GEOFENCE_API_CLINET_H
|
SharmagRit/device_xiaomi_whyred
|
gps/core/SystemStatusOsObserver.h
|
<gh_stars>100-1000
/* Copyright (c) 2015-2017, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SYSTEM_STATUS_OSOBSERVER__
#define __SYSTEM_STATUS_OSOBSERVER__
#include <cinttypes>
#include <string>
#include <list>
#include <map>
#include <new>
#include <vector>
#include <MsgTask.h>
#include <DataItemId.h>
#include <IOsObserver.h>
#include <loc_pla.h>
#include <log_util.h>
#include <LocUnorderedSetMap.h>
namespace loc_core
{
/******************************************************************************
SystemStatusOsObserver
******************************************************************************/
using namespace std;
using namespace loc_util;
// Forward Declarations
class IDataItemCore;
class SystemStatus;
class SystemStatusOsObserver;
typedef map<IDataItemObserver*, list<DataItemId>> ObserverReqCache;
typedef LocUnorderedSetMap<IDataItemObserver*, DataItemId> ClientToDataItems;
typedef LocUnorderedSetMap<DataItemId, IDataItemObserver*> DataItemToClients;
typedef unordered_map<DataItemId, IDataItemCore*> DataItemIdToCore;
typedef unordered_map<DataItemId, int> DataItemIdToInt;
#ifdef USE_GLIB
// Cache details of backhaul client requests
typedef unordered_set<string> ClientBackhaulReqCache;
#endif
struct ObserverContext {
IDataItemSubscription* mSubscriptionObj;
IFrameworkActionReq* mFrameworkActionReqObj;
const MsgTask* mMsgTask;
SystemStatusOsObserver* mSSObserver;
inline ObserverContext(const MsgTask* msgTask, SystemStatusOsObserver* observer) :
mSubscriptionObj(NULL), mFrameworkActionReqObj(NULL),
mMsgTask(msgTask), mSSObserver(observer) {}
};
// Clients wanting to get data from OS/Framework would need to
// subscribe with OSObserver using IDataItemSubscription interface.
// Such clients would need to implement IDataItemObserver interface
// to receive data when it becomes available.
class SystemStatusOsObserver : public IOsObserver {
public:
// ctor
inline SystemStatusOsObserver(SystemStatus* systemstatus, const MsgTask* msgTask) :
mSystemStatus(systemstatus), mContext(msgTask, this),
mAddress("SystemStatusOsObserver"),
mClientToDataItems(MAX_DATA_ITEM_ID), mDataItemToClients(MAX_DATA_ITEM_ID) {}
// dtor
~SystemStatusOsObserver();
template <typename CINT, typename COUT>
static COUT containerTransfer(CINT& s);
template <typename CINT, typename COUT>
inline static COUT containerTransfer(CINT&& s) {
return containerTransfer<CINT, COUT>(s);
}
// To set the subscription object
virtual void setSubscriptionObj(IDataItemSubscription* subscriptionObj);
// To set the framework action request object
inline void setFrameworkActionReqObj(IFrameworkActionReq* frameworkActionReqObj) {
mContext.mFrameworkActionReqObj = frameworkActionReqObj;
#ifdef USE_GLIB
uint32_t numBackHaulClients = mBackHaulConnReqCache.size();
if (numBackHaulClients > 0) {
// For each client, invoke connectbackhaul.
for (auto clientName : mBackHaulConnReqCache) {
LOC_LOGd("Invoke connectBackhaul for client: %s", clientName.c_str());
connectBackhaul(clientName);
}
// Clear the set
mBackHaulConnReqCache.clear();
}
#endif
}
// IDataItemSubscription Overrides
inline virtual void subscribe(const list<DataItemId>& l, IDataItemObserver* client) override {
subscribe(l, client, false);
}
virtual void updateSubscription(const list<DataItemId>& l, IDataItemObserver* client) override;
inline virtual void requestData(const list<DataItemId>& l, IDataItemObserver* client) override {
subscribe(l, client, true);
}
virtual void unsubscribe(const list<DataItemId>& l, IDataItemObserver* client) override;
virtual void unsubscribeAll(IDataItemObserver* client) override;
// IDataItemObserver Overrides
virtual void notify(const list<IDataItemCore*>& dlist) override;
inline virtual void getName(string& name) override {
name = mAddress;
}
// IFrameworkActionReq Overrides
virtual void turnOn(DataItemId dit, int timeOut = 0) override;
virtual void turnOff(DataItemId dit) override;
#ifdef USE_GLIB
virtual bool connectBackhaul(const string& clientName) override;
virtual bool disconnectBackhaul(const string& clientName) override;
#endif
private:
SystemStatus* mSystemStatus;
ObserverContext mContext;
const string mAddress;
ClientToDataItems mClientToDataItems;
DataItemToClients mDataItemToClients;
DataItemIdToCore mDataItemCache;
DataItemIdToInt mActiveRequestCount;
// Cache the subscribe and requestData till subscription obj is obtained
void cacheObserverRequest(ObserverReqCache& reqCache,
const list<DataItemId>& l, IDataItemObserver* client);
#ifdef USE_GLIB
// Cache the framework action request for connect/disconnect
ClientBackhaulReqCache mBackHaulConnReqCache;
#endif
void subscribe(const list<DataItemId>& l, IDataItemObserver* client, bool toRequestData);
// Helpers
void sendCachedDataItems(const unordered_set<DataItemId>& s, IDataItemObserver* to);
bool updateCache(IDataItemCore* d);
inline void logMe(const unordered_set<DataItemId>& l) {
IF_LOC_LOGD {
for (auto id : l) {
LOC_LOGD("DataItem %d", id);
}
}
}
};
} // namespace loc_core
#endif //__SYSTEM_STATUS__
|
SharmagRit/device_xiaomi_whyred
|
gps/location/location_interface.h
|
<gh_stars>100-1000
/* Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef LOCATION_INTERFACE_H
#define LOCATION_INTERFACE_H
#include <LocationAPI.h>
#include <gps_extended_c.h>
#include <functional>
/* Used for callback to deliver GNSS energy consumed */
/** @fn
@brief Used by query API that retrieves energy consumed by
modem GNSS engine.
@param gnssEnergyConsumedFromFirstBoot:
Energy consumed by the GNSS engine since the first bootup
in units of 0.1 milli watt seconds.
A value of 0xffffffffffffffff indicates an invalid reading.
*/
typedef std::function<void(
uint64_t gnssEnergyConsumedFromFirstBoot
)> GnssEnergyConsumedCallback;
typedef void (*removeClientCompleteCallback)(LocationAPI* client);
struct GnssInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
void (*requestCapabilities)(LocationAPI* client);
uint32_t (*startTracking)(LocationAPI* client, TrackingOptions&);
void (*updateTrackingOptions)(LocationAPI* client, uint32_t id, TrackingOptions&);
void (*stopTracking)(LocationAPI* client, uint32_t id);
void (*gnssNiResponse)(LocationAPI* client, uint32_t id, GnssNiResponse response);
void (*setControlCallbacks)(LocationControlCallbacks& controlCallbacks);
uint32_t (*enable)(LocationTechnologyType techType);
void (*disable)(uint32_t id);
uint32_t* (*gnssUpdateConfig)(const GnssConfig& config);
uint32_t* (*gnssGetConfig)(GnssConfigFlagsMask config);
void (*gnssUpdateSvTypeConfig)(GnssSvTypeConfig& config);
void (*gnssGetSvTypeConfig)(GnssSvTypeConfigCallback& callback);
void (*gnssResetSvTypeConfig)();
uint32_t (*gnssDeleteAidingData)(GnssAidingData& data);
void (*gnssUpdateXtraThrottle)(const bool enabled);
void (*injectLocation)(double latitude, double longitude, float accuracy);
void (*injectTime)(int64_t time, int64_t timeReference, int32_t uncertainty);
void (*agpsInit)(const AgpsCbInfo& cbInfo);
void (*agpsDataConnOpen)(AGpsExtType agpsType, const char* apnName, int apnLen, int ipType);
void (*agpsDataConnClosed)(AGpsExtType agpsType);
void (*agpsDataConnFailed)(AGpsExtType agpsType);
void (*getDebugReport)(GnssDebugReport& report);
void (*updateConnectionStatus)(bool connected, int8_t type, bool roaming,
NetworkHandle networkHandle);
void (*odcpiInit)(const OdcpiRequestCallback& callback, OdcpiPrioritytype priority);
void (*odcpiInject)(const Location& location);
void (*blockCPI)(double latitude, double longitude, float accuracy,
int blockDurationMsec, double latLonDiffThreshold);
void (*getGnssEnergyConsumed)(GnssEnergyConsumedCallback energyConsumedCb);
void (*enableNfwLocationAccess)(bool enable);
void (*nfwInit)(const NfwCbInfo& cbInfo);
void (*getPowerStateChanges)(std::function<void(bool)> powerStateCb);
void (*injectLocationExt)(const GnssLocationInfoNotification &locationInfo);
void (*updateBatteryStatus)(bool charging);
void (*updateSystemPowerState)(PowerStateType systemPowerState);
uint32_t (*setConstrainedTunc) (bool enable, float tuncConstraint, uint32_t energyBudget);
uint32_t (*setPositionAssistedClockEstimator) (bool enable);
uint32_t (*gnssUpdateSvConfig)(const GnssSvTypeConfig& constellationEnablementConfig,
const GnssSvIdConfig& blacklistSvConfig);
uint32_t (*configLeverArm)(const LeverArmConfigInfo& configInfo);
bool (*measCorrInit)(const measCorrSetCapabilitiesCb setCapabilitiesCb);
bool (*measCorrSetCorrections)(const GnssMeasurementCorrections gnssMeasCorr);
void (*measCorrClose)();
uint32_t (*antennaInfoInit)(const antennaInfoCb antennaInfoCallback);
void (*antennaInfoClose) ();
uint32_t (*configRobustLocation)(bool enable, bool enableForE911);
uint32_t (*configMinGpsWeek)(uint16_t minGpsWeek);
uint32_t (*configDeadReckoningEngineParams)(const DeadReckoningEngineConfig& dreConfig);
void (*updateNTRIPGGAConsent)(bool consentAccepted);
void (*enablePPENtripStream)(const GnssNtripConnectionParams& params, bool enableRTKEngine);
void (*disablePPENtripStream)();
uint32_t (*gnssUpdateSecondaryBandConfig)(const GnssSvTypeConfig& secondaryBandConfig);
uint32_t (*gnssGetSecondaryBandConfig)();
void (*resetNetworkInfo)();
};
struct BatchingInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
void (*requestCapabilities)(LocationAPI* client);
uint32_t (*startBatching)(LocationAPI* client, BatchingOptions&);
void (*stopBatching)(LocationAPI* client, uint32_t id);
void (*updateBatchingOptions)(LocationAPI* client, uint32_t id, BatchingOptions&);
void (*getBatchedLocations)(LocationAPI* client, uint32_t id, size_t count);
};
struct GeofenceInterface {
size_t size;
void (*initialize)(void);
void (*deinitialize)(void);
void (*addClient)(LocationAPI* client, const LocationCallbacks& callbacks);
void (*removeClient)(LocationAPI* client, removeClientCompleteCallback rmClientCb);
void (*requestCapabilities)(LocationAPI* client);
uint32_t* (*addGeofences)(LocationAPI* client, size_t count, GeofenceOption*, GeofenceInfo*);
void (*removeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
void (*modifyGeofences)(LocationAPI* client, size_t count, uint32_t* ids,
GeofenceOption* options);
void (*pauseGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
void (*resumeGeofences)(LocationAPI* client, size_t count, uint32_t* ids);
};
#endif /* LOCATION_INTERFACE_H */
|
SharmagRit/device_xiaomi_whyred
|
gps/pla/android/loc_pla.h
|
<filename>gps/pla/android/loc_pla.h
/* Copyright (c) 2014, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __LOC_PLA__
#define __LOC_PLA__
#ifdef __cplusplus
#include <utils/SystemClock.h>
#define uptimeMillis() android::uptimeMillis()
#define elapsedRealtime() android::elapsedRealtime()
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include <cutils/properties.h>
#include <cutils/threads.h>
#include <cutils/sched_policy.h>
#include <cutils/android_filesystem_config.h>
#include <string.h>
#include <stdlib.h>
#define UID_GPS (AID_GPS)
#define GID_GPS (AID_GPS)
#define UID_LOCCLIENT (4021)
#define GID_LOCCLIENT (4021)
#define LOC_PATH_GPS_CONF_STR "/vendor/etc/gps.conf"
#define LOC_PATH_IZAT_CONF_STR "/vendor/etc/izat.conf"
#define LOC_PATH_FLP_CONF_STR "/vendor/etc/flp.conf"
#define LOC_PATH_LOWI_CONF_STR "/vendor/etc/lowi.conf"
#define LOC_PATH_SAP_CONF_STR "/vendor/etc/sap.conf"
#define LOC_PATH_APDR_CONF_STR "/vendor/etc/apdr.conf"
#define LOC_PATH_XTWIFI_CONF_STR "/vendor/etc/xtwifi.conf"
#define LOC_PATH_QUIPC_CONF_STR "/vendor/etc/quipc.conf"
#define LOC_PATH_ANT_CORR_STR "/vendor/etc/gnss_antenna_info.conf"
#define LOC_PATH_SLIM_CONF_STR "/vendor/etc/slim.conf"
#define LOC_PATH_VPE_CONF_STR "/vendor/etc/vpeglue.conf"
/*!
* @brief Function for memory block copy
*
* @param[out] p_Dest Destination buffer.
* @param[in] q_DestSize Destination buffer size.
* @param[in] p_Src Source buffer.
* @param[in] q_SrcSize Source buffer size.
*
* @return Number of bytes copied.
*/
static inline size_t memscpy (void *p_Dest, size_t q_DestSize, const void *p_Src, size_t q_SrcSize)
{
size_t res = (q_DestSize < q_SrcSize) ? q_DestSize : q_SrcSize;
if (p_Dest && p_Src && q_DestSize > 0 && q_SrcSize > 0) {
memcpy(p_Dest, p_Src, res);
} else {
res = 0;
}
return res;
}
/*API for boot kpi marker prints */
inline int loc_boot_kpi_marker(const char * pFmt, ...)
{
return -1;
}
#ifdef __cplusplus
}
#endif /*__cplusplus */
#endif /* __LOC_PLA__ */
|
SharmagRit/device_xiaomi_whyred
|
gps/utils/LocHeap.h
|
<filename>gps/utils/LocHeap.h
/* Copyright (c) 2015, 2020 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of The Linux Foundation, nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __LOC_HEAP__
#define __LOC_HEAP__
#include <stddef.h>
#include <string.h>
namespace loc_util {
// abstract class to be implemented by client to provide a rankable class
class LocRankable {
public:
virtual inline ~LocRankable() {}
// method to rank objects of such type for sorting purposes.
// The pointer of the input node would be stored in the heap.
// >0 if ranks higher than the input;
// ==0 if equally ranks with the input;
// <0 if ranks lower than the input
virtual int ranks(LocRankable& rankable) = 0;
// convenient method to rank objects of such type for sorting purposes.
inline bool outRanks(LocRankable& rankable) { return ranks(rankable) > 0; }
};
// opaque class to provide service implementation.
class LocHeapNode;
// a heap whose left and right children are not sorted. It is sorted only vertically,
// i.e. parent always ranks higher than children, if they exist. Ranking algorithm is
// implemented in Rankable. The reason that there is no sort between children is to
// help beter balance the tree with lower cost. When a node is pushed to the tree,
// it is guaranteed that the subtree that is smaller gets to have the new node.
class LocHeap {
protected:
LocHeapNode* mTree;
public:
inline LocHeap() : mTree(NULL) {}
~LocHeap();
// push keeps the tree sorted by rank, it also tries to balance the
// tree by adding the new node to the smaller of the subtrees.
// node is reference to an obj that is managed by client, that client
// creates and destroyes. The destroy should happen after the
// node is popped out from the heap.
void push(LocRankable& node);
// Peeks the node data on tree top, which has currently the highest ranking
// There is no change the tree structure with this operation
// Returns NULL if the tree is empty, otherwise pointer to the node data of
// the tree top.
LocRankable* peek();
// pop keeps the tree sorted by rank, but it does not try to balance
// the tree.
// Return - pointer to the node popped out, or NULL if heap is already empty
LocRankable* pop();
// navigating through the tree and find the node that ranks the same
// as the input data, then remove it from the tree. Rank is implemented
// by rankable obj.
// returns the pointer to the node removed; or NULL (if failed).
LocRankable* remove(LocRankable& rankable);
#ifdef __LOC_UNIT_TEST__
bool checkTree();
uint32_t getTreeSize();
#endif
};
} // namespace loc_util
#endif //__LOC_HEAP__
|
zyndor/windows-dependencies
|
include/dali/preprocessor-definitions.h
|
/*
* Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef DALI_CORE_PREPROCESSOR_DEFINITIONS_H
#define DALI_CORE_PREPROCESSOR_DEFINITIONS_H
#define __attribute__(x)
#ifdef NORMAL
#undef NORMAL
#endif
#define M_E 2.71828182845904523536
#define M_LOG2E 1.44269504088896340736
#define M_LOG10E 0.434294481903251827651
#define M_LN2 0.693147180559945309417
#define M_LN10 2.30258509299404568402
#define M_PI 3.14159265358979323846
#define M_PI_2 1.57079632679489661923
#define M_PI_4 0.785398163397448309616
#define M_1_PI 0.318309886183790671538
#define M_2_PI 0.636619772367581343076
#define M_2_SQRTPI 1.12837916709551257390
#define M_SQRT2 1.41421356237309504880
#define M_SQRT1_2 0.707106781186547524401
#define __atomic_base atomic
#define strtok_r strtok_s
#define PTW32_STATIC_LIB 1
#define __restrict__
#define S_ISREG
#define lstat stat
#ifdef __cplusplus
#define _CPP11
#endif
#define CLOCK_MONOTONIC 0
#define TIMER_ABSTIME 0
#define S_IRWXU 0
#define S_IRGRP 0
#define S_IXGRP 0
#define S_IROTH 0
#define S_IXOTH 0
#endif // DALI_CORE_PREPROCESSOR_DEFINITIONS_H
|
zyndor/windows-dependencies
|
include/dali/extern-definitions.h
|
/*
* Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef DALI_CORE_EXTERN_DEFINITIONS_H
#define DALI_CORE_EXTERN_DEFINITIONS_H
#include <cstdarg>
#include <cstdint>
#include <cstdio>
#include <ctime>
#ifndef strerror_r
#define strerror_r(errno, buf, len) strerror_s(buf, len, errno)
#endif
#ifdef __cplusplus
template <typename T>
T __sync_add_and_fetch( volatile T *oldValue, int value )
{
*oldValue += value;
return *oldValue;
}
template <typename T>
T __sync_sub_and_fetch( volatile T *oldValue, int value )
{
*oldValue -= value;
return *oldValue;
}
template <typename T>
T __sync_fetch_and_or( volatile T *originalValue, T value )
{
T ret = *originalValue;
*originalValue = (T)( *originalValue | value );
return ret;
}
template <typename T>
T __sync_val_compare_and_swap( volatile T *originalValue, T value1, T value2 )
{
T ret = *originalValue;
if( *originalValue == value1 )
{
*originalValue = value2;
}
return ret;
}
template <typename T>
bool __sync_bool_compare_and_swap( volatile T *originalValue, T value1, T value2 )
{
if( *originalValue == value1 )
{
*originalValue = value2;
return true;
}
else
{
return false;
}
}
template <typename T>
T __sync_lock_test_and_set( volatile T *originalValue, T value )
{
T ret = *originalValue;
*originalValue = value;
return ret;
}
template <typename T>
T __sync_fetch_and_xor( T *originalValue, T value )
{
T ret = *originalValue;
*originalValue = (T)( *originalValue ^ value );
return ret;
}
static unsigned int __sync_fetch_and_xor( unsigned int *originalValue, int value )
{
unsigned int ret = *originalValue;
*originalValue = (int)( *originalValue ^ value );
return ret;
}
#endif // __cplusplus
int vasprintf(char** strp, const char* fmt, va_list ap);
int asprintf(char** strp, const char* fmt, ...);
int rand_r( unsigned int* seed );
int setenv( const char* __name, const char* __value, int __replace );
typedef size_t ssize_t;
int mkdir(const char *pathname, unsigned int mode);
#endif // DALI_CORE_EXTERN_DEFINITIONS_H
|
zyndor/windows-dependencies
|
include/dali-windows-dependencies.h
|
<reponame>zyndor/windows-dependencies
#ifndef DALI_WINDOWS_DEPENDENCIES_H
#define DALI_WINDOWS_DEPENDENCIES_H
#include <dali/preprocessor-definitions.h>
#include <dali/extern-definitions.h>
#endif // DALI_WINDOWS_DEPENDENCIES_H
|
andimoto/stm32f1xx-cmake-cpp
|
stm32lib/tools/itm_write.c
|
#include "itm_write.h"
#include "stm32f1xx.h"
int printf(const char* format, ...)
{
char str[128];
char *s = str; // pointer for the buffer
int ch_count = 0;
va_list args; // holds args
va_start(args, format); // format - last defined param name
vsprintf(str, format, args); // formatting
while (*s)
{
ITM_SendChar((*s++));
ch_count++;
}
va_end(args);
return ch_count;
}
|
klauty/uController
|
MEGA_RAMPS_MENU/Menu.h
|
const char *menu_setup[] = {"Criar Agendamento","Configurar relogio","Listar Agendamentos","<- Voltar" }; // id=1
|
bit4bit/mod_global_vars
|
mod_global_vars.c
|
<filename>mod_global_vars.c
#include <switch.h>
SWITCH_MODULE_LOAD_FUNCTION(mod_global_vars_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_global_vars_shutdown);
SWITCH_MODULE_DEFINITION(mod_global_vars, mod_global_vars_load, mod_global_vars_shutdown, NULL);
static switch_status_t load_variables_from_config(void)
{
char *cf = "global_vars.conf";
switch_xml_t cfg, xml, variables_tag, variable_tag;
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
}
if (!(variables_tag = switch_xml_child(cfg, "variables"))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing <variables> tag!\n");
goto done;
}
for (variable_tag = switch_xml_child(variables_tag, "variable"); variable_tag; variable_tag = variable_tag->next) {
char *vname = (char *) switch_xml_attr_soft(variable_tag, "name");
char *vvalue = (char *) switch_xml_attr_soft(variable_tag, "value");
switch_core_set_variable(vname, vvalue);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "global_vars set variable %s\n", vname);
}
done:
switch_xml_free(xml);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_LOAD_FUNCTION(mod_global_vars_load)
{
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
if (load_variables_from_config() != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_global_vars_shutdown)
{
return SWITCH_STATUS_UNLOAD;
}
/* For Emacs:
* Local Variables:
* mode:c
* indent-tabs-mode:t
* tab-width:4
* c-basic-offset:4
* End:
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
*/
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.