native unboxed types #14

Open
rurban opened this Issue Sep 11, 2015 · 0 comments

Projects

None yet

1 participant

@rurban
Member
rurban commented Sep 11, 2015

a major memory and perfomance win.

as native types in Perl6
new box_{int,num,str} and unbox_{int,num,str} ops, and all the arithmetic ops for int and num, and for const and padsv (padav for native arrays later).

Allow native int, double and ASCIIZ pointers on the stack, and provide optimized ops for those.
Maybe uni strings later.

Check in the compiler (op.c) for safe ranges to use unboxed sequences of ops, and box the stack values when escaping: sub calls, exceptions, jumps outside.

I needed to extend opcodes and opcode.pl to mark the ops with new arg types, change msgrcv and sockpair, because there's no room for 5 op args anymore (no, undone.)

type num (double) can only be used when IVSIZE==NVSIZE, i.e. 32bit with NV=float and 64bit with double. The compiler needs to emits different code when unboxed num is avail. or not.

Optimizer:
native types strength reduction:
Change ops with typed or const args into typed.
e.g. padsv[$a:int] const(iv) add => i_add

With more than 2 ops with unboxable args, maybe unbox it.
e.g. padsv[$a:int] const(iv) add padsv[$b:int] multiply
=>

 padsv[$a:int] const(iv) unbox[2] int_add
 padsv[$b:int] unbox int_multiply[b]

[b] meaning box result as in box_int

native ops can have OPpBOXRET and UNBOX_* can have the number of stack elements in op_private. Extend B::Concise to display those, and also display the types of pads, like
padsv[$a:int 63,64]

I had a major thinko btw. Those ops can only refer to other ops, never to data directly. The data ops are const and padsv. Either the native arith ops replace in the optimizer the padsv/const ops by the unboxed variants, where op_first/op_last points to an unboxed data (ptr or literal const?, ptr tagging cannot be used as we need all bits for the literal, which might end with 0b00)
so we need new types const_int, pad_int, ... which hold the unboxed data.

int_padsv holds the data in special curpad[] SVs with SVf_NATIVE. Or keep it there unboxed, but then we need to assure that all the padops referring to this targ are changed to be properly typed.

See feature/CM-713-cperl-native-types

@rurban rurban added the enhancement label Sep 11, 2015
@rurban rurban added this to the v5.24.0 milestone Sep 13, 2015
@rurban rurban modified the milestone: v5.26.0, v5.24.0 May 10, 2016
@rurban rurban added the in progress label Dec 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment