English 中文(简体)
JIT 基本原理
原标题:JITs fundamentals

我在一定程度上理解,如何将“int a = b+abs(c)”转化为简单的组装指示,然后将其转化为一些双龙虾。 但是,如何开展这项工作,与记忆中的动态互动?

纽约总部

我知道C.C.t有切身之处。 但是,它所汇编的正是这样做的。 我指的是,使 Java像JITs那样做什么,为此,编码注射不可能做到。 例如, a( a)功能只是指点器,可根据dec(dec)议定书加以规定。 新的职能应当能够通过dec机暴露。 我不理解的是,这一新法典如何能够在时间上注入。

我要求这种治疗更长时间,从而最有效地解决实际问题。

————————

Say我有一套根植的假装成像法,从土生土方案中有许多,也称为具有土著约束力的通知:

def add(a, b):
    notify()
    return a+b

For this to be a point in doing, the function should probably contain quite a bit more code (and way more usefull), but bear with me. A profiler (or hints from the c-bindings) has also identified that all calls are with with integers both with all parameters and return value. This matches:

int add(int a, int b) {
    notify();
    return a + b;
}

可归入类似于下列内容的x86 c:

:_add
push ebp ;setting up scope
mov ebp, esp
call _notify ;or more likely by a pointer reference
mov eax, [ebp + 8]
mov edx, [ebp + 12]
add eax, edx
pop ebp
ret

之后,终于聚集到双轨迹中。 当然,为了达到这一目的,必须执行每个平台的基本汇编者。 但是,除了这个问题外,我现在还有这个有效的双亲×86法典的char点。 是否有可能从这种方式中抽取用于土著方案的dec功能点?

出于对我问题不明确意图的担忧

最佳回答

假设你们的法典已经编成一个记忆栏,而且你有这个栏目的地址,可以投向一个功能点:

typedef int (*func)(int, int);
...
char * compiledCode = ...;
func f = (func) compiledCode;

职能可以称为:

int x = f(2, 3);
问题回答

C 缺乏任何类型的“阀”特征,既是一种限制,也是一种允许其有效发挥作用的因素。 如果你们都能够做,那么,用一组固定的数学功能,如<代码>abs(<>/code>,而不是任意的C代码,对数学表述进行评估,那么这种表述评价就比较容易。

Here s a link to a past SO thread on a similar topic: c expression Evaluator

该方案必须是能够执行的方案的记忆区。

关键是:

void *address;
functype proc;
int prot, flags;

prot = PROT_READ|PROT_WRITE|PROT_EXEC;
flags = MAP_PRIVATE|MAP_ANONYMOUS;
address = mmap(NULL, length, prot, flags, -1, 0);
if (address == NULL) error;

memcpy(address, program, length);
link(address, program_info);

proc = (functype)address;




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签