intermediate-language

Static analysis for partial C++ programs

穿精又带淫゛_ 提交于 2019-12-03 16:24:25
I'm thinking about doing some static analysis project over C++ code samples , as opposed to entire programs. In general static analysis requires some simpler intermediate representation, but such a representation cannot be accurately created without the entire program code. Still, I know there is such a tool for Java - it basically "guesses" missing information and thus allows static analysis to take place even though it's no longer sound or complete. Is there anything similar that can be used to convert partial C++ code into some intermediate form (e.g. LLVM bytecode)? Ira Baxter As a general

Making a language, need a good backend

左心房为你撑大大i 提交于 2019-12-03 16:15:58
I want to make a compiled language. I am currently evaluating backends. So far I am looking at C because of its speed of execution, compiling, and a small, easy to use compiler called TCC. Having read the discussions here about using it as an intermediate language, I am trying to think about how to make it compatible with garbage collection, and handling exceptions. So far, I think I can solve both, but with much overhead. Here are some of my thoughts on the other possible backends: Assembly: unportable and a total pain to program in. .NET: Feels really slow. 5 seconds to start up and 5

Why is it so easy to decompile .NET IL code?

别等时光非礼了梦想. 提交于 2019-12-03 08:54:03
问题 Why is it so easy to decompile .NET IL-code into source code, compared to decompiling native x86 binaries? (Reflector produces quite good source code most of the time, while decompiling the output of a C++ compiler is almost impossible.) Is it because IL contains a lot of meta data? Or is it because IL is a higher abstraction than x86 instructions? I did some research and found the following two usefull articles, but neither of them answers my question. MSIL Decompiler Theory C Decompiler -

Understanding STG

 ̄綄美尐妖づ 提交于 2019-12-03 01:37:56
问题 The design of GHC is based on something called STG, which stands for "spineless, tagless G-machine". Now G-machine is apparently short for "graph reduction machine", which defines how laziness is implemented. Unevaluated thunks are stored as an expression tree, and executing the program involves reducing these down to normal form. (A tree is an acyclic graph, but Haskell's pervasive recursion means that Haskell expressions form general graphs , hence graph-reduction and not tree-reduction.)

Why is it so easy to decompile .NET IL code?

∥☆過路亽.° 提交于 2019-12-02 22:50:28
Why is it so easy to decompile .NET IL-code into source code, compared to decompiling native x86 binaries? (Reflector produces quite good source code most of the time, while decompiling the output of a C++ compiler is almost impossible.) Is it because IL contains a lot of meta data? Or is it because IL is a higher abstraction than x86 instructions? I did some research and found the following two usefull articles, but neither of them answers my question. MSIL Decompiler Theory C Decompiler - Quick primer I think you've got the most important bits already. As you say, there's more metadata

Understanding STG

纵然是瞬间 提交于 2019-12-02 15:29:36
The design of GHC is based on something called STG, which stands for "spineless, tagless G-machine". Now G-machine is apparently short for "graph reduction machine", which defines how laziness is implemented. Unevaluated thunks are stored as an expression tree, and executing the program involves reducing these down to normal form. (A tree is an acyclic graph, but Haskell's pervasive recursion means that Haskell expressions form general graphs , hence graph-reduction and not tree-reduction.) What is less clear are the terms "spineless" and "tagless". I think that "spineless" refers to the fact

How do actually castings work at the CLR level?

安稳与你 提交于 2019-11-30 20:51:47
When doing an upcast or downcast, what does really happen behind the scenes? I had the idea that when doing something as: string myString = "abc"; object myObject = myString; string myStringBack = (string)myObject; the cast in the last line would have as only purpose tell the compiler we are safe we are not doing anything wrong. So, I had the idea that actually no casting code would be embedded in the code itself. It seems I was wrong: .maxstack 1 .locals init ( [0] string myString, [1] object myObject, [2] string myStringBack) L_0000: nop L_0001: ldstr "abc" L_0006: stloc.0 L_0007: ldloc.0 L

Can Mono.Cecil modify code already loaded in the AppDomain?

廉价感情. 提交于 2019-11-30 18:51:40
I want to add some behavior to a certain class at runtime. I know how to subclass at runtime using Reflection.Emit but thats not enough, Depending on some external configuration I need to inject opcodes in a method on a type T so all classes that inherit from it automatically gain this behavior.(I cant use the .NET Profiling API) Can something like this be done with Mono.Cecil? If it isnt possible to modify code on a loaded assembly, It is fine If I can make the modifications before the assembly is loaded and then load the modified assembly in memory, but I dont know how I can control assembly

Can Mono.Cecil modify code already loaded in the AppDomain?

巧了我就是萌 提交于 2019-11-30 16:54:13
问题 I want to add some behavior to a certain class at runtime. I know how to subclass at runtime using Reflection.Emit but thats not enough, Depending on some external configuration I need to inject opcodes in a method on a type T so all classes that inherit from it automatically gain this behavior.(I cant use the .NET Profiling API) Can something like this be done with Mono.Cecil? If it isnt possible to modify code on a loaded assembly, It is fine If I can make the modifications before the

How does the .NET IL .maxstack directive work?

不想你离开。 提交于 2019-11-30 10:55:21
I'd like to know how does .maxstack really work. I know it doesn't have to do with the actual size of the types you are declaring but with the number of them. My questions are: does this apply just for the function, or to all the functions that we are calling for? even if it's just for the function were .maxstack is being declared, how do you know what maxstack is if you have branching? You go and see all the "paths" and return the maximum value possible? What happens if I set it to 16 and actually there are 17 variables? Is there a too big of a penalty if I set it to 256? dtb .maxstack is