Forum

Forum

Robbert Haarman

2014-02-15

Posted by inglorion
at 2016-01-06 17:56:48

DataDraw looks very interesting. It claims to be so fast that it even beats native C data structures, and it can be both in-memory and persisted to disk. I have been meaning to experiment with it, but haven't gotten around to it yet.

  • View this thread (0 comments)
Posted by inglorion
at 2015-09-09 20:24:17

Crystal is a programming language with syntax and expressiveness inspired by Ruby, but with static typing, macros, and an implementation that compiles programs to native code. Types are automatically inferred, so code can be written without type annotations, although annotations can be added to restrict the types accepted by methods or to implement ad-hoc polymorphism. Macros allow a fixed subset of the language to be used to transform source code, allowing metaprogramming without run-time overhead. Ruby programs can often be transformed to Crystal programs with small modifications.

There is a self-hosting implementation of Crystal, using LLVM to generate native code. An foreign function interface is available to allow Crystal code to call C code and vice versa.

  • View this thread (0 comments)
Posted by inglorion
at 2014-11-10 02:28:17

I just released version 1.1.4 of the Voodoo Compiler. This is a maintenance release, and contains the following bug fixes and improvements:

- References to symbols are now always position-independent, even if the symbol is not exported or imported. This means shared libraries can now have symbols that are not externally visible.

- On AMD64, tail-call now restores all callee-save registers in the active frame to their saved values before transferring control to the function being called. Before this fix, calling code generated by the Voodoo compiler from code generated by a different compiler would, under certain circumstances, cause callee-save registers to have wrong values upon return to the code from the other compiler.

- On AMD64, rbx is now a callee-save register, as required by the ABI.

- More rigorous tests for expressions have been added. These exposed some bugs in the generated code on AMD64, which have been fixed.

- The ARM code generator now emits constant pools as necessary to keep them within limited distance from the code that uses them. Previously, constant pools were only emitted at the end of blocks, which could cause the offset between a constant and an instruction that uses that constant to be larger than what can be encoded in the instruction.

  • View this thread (0 comments)
Posted by inglorion
at 2014-10-28 12:51:23

As on other architectures, position-independent code for MIPS on GNU/Linux is accomplished with the help of a global offset table. This table contains the addresses of symbols used by the code. Instead of using the address of a symbol directly, as one would in non-position-independent code, a reference to a symbol is resolved by looking up the symbol's entry in the global offset table and then using the address stored there. Of course, we still need to find the address of the global offset table (abbreviated GOT).

On Mips on GNU/Linux, functions are passed the address of their entry point in register $25. The global offset table is at a fixed offset to this. By convention, $28 is used to hold the address of the GOT. The correct value can be computed as follows:


lui $28, %hi(_gp_disp)
addiu $28, %lo(_gp_disp)
addu $28, $28, $25

This is what the GNU assembler's .cpload $25 pseudo-op expands to.

Once you have the address of the global offset table in $28, you can get the address of a symbol that your object imports or exports by doing something like


lw $2, %got(foo)($28)

where foo is the name of your symbol. This would store the address foo is at in register $2, assuming $28 holds the address of the GOT.

However, for symbols that are defined in your object but not exported, the situation is slightly different. For such symbols, you need to also add the %lo of your symbol's address to the address you get from the GOT. So, for symbols that aren't imported or exported, but defined in the same object as your code, the position-independent way to get the address of the symbol is


lw $2, %got(foo)($28)
addiu $2, %lo(foo)

  • View this thread (0 comments)
Posted by inglorion
at 2014-04-04 00:16:01

Discovery of the day: "less +F". It's something I've been looking for, but hadn't found until recently. Some background: "tail" shows the last couple of lines in a file. "tail -f" does the same, but also "follows" the file, showing new lines as they are added to the file. "less" is a pager, it allows you to view a file screenful by screenful. It also allows you to scroll up, search, and a number of other useful things. One of those is a follow function, which basically does the same as "tail -f", but allows you to go back to less's normal mode of operation, so you can scroll back, etc.

Often, I want to see new lines being added to a file, with the option to scroll back, search, etc. if something interesting happens (e.g. an error message is printed). The way I used to do this is by running "less $filename", then typing an uppercase F, which invokes the follow function. Today, I discovered that you can do this in one go by doing "less +F $filename". This also works for other less commands, e.g. "less +G $filename" will run less on a file, but start at the end of the file, rather than at the beginning. "less +/foo $filename" will open the file and scroll to the first occurrence of "foo".

  • View this thread (0 comments)

View previous 5 threads