Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

native unboxed types #14

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

native unboxed types #14

rurban opened this issue Sep 11, 2015 · 0 comments

Comments

@rurban
Copy link
Member

rurban commented Sep 11, 2015

a major memory and performance 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 this to the v5.24.0 milestone Sep 13, 2015
@rurban rurban modified the milestones: v5.26.0, v5.24.0 May 10, 2016
@rurban rurban removed this from the v5.26.0c milestone Mar 2, 2017
@rurban rurban added this to the v5.26.0c milestone Mar 30, 2017
@rurban rurban removed this from the v5.26.0c milestone Apr 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant