Newsgroups: perl.perl6.internals Path: archiver1.google.com!news1.google.com!news.glorb.com!logbridge.uoregon.edu!newsfeed.stanford.edu!nntp.perl.org Return-Path: Mailing-List: contact perl6-internals-h...@perl.org; run by ezmlm Delivered-To: mailing list perl6-intern...@perl.org Received: (qmail 43975 invoked by uid 76); 20 Apr 2004 15:21:02 -0000 Received: from x1.develooper.com (HELO x1.develooper.com) (63.251.223.170) by onion.perl.org (qpsmtpd/0.27.1) with SMTP; Tue, 20 Apr 2004 08:21:02 -0700 Received: (qmail 13628 invoked by uid 225); 20 Apr 2004 15:21:00 -0000 Delivered-To: perl6-intern...@perl.org Received: (qmail 13623 invoked by alias); 20 Apr 2004 15:20:59 -0000 X-Spam-Status: No, hits=0.0 required=7.0 tests= X-Spam-Check-By: la.mx.develooper.com Received: from mail.nextra.at (HELO mail.nextra.at) (195.170.70.67) by la.mx.develooper.com (qpsmtpd/0.27.1) with ESMTP; Tue, 20 Apr 2004 08:20:59 -0700 Received: from lux.leo.home (at24a01-dial-143.nextranet.at [195.170.73.143]) by mail.nextra.at (20030919/20030919/nextra) with ESMTP id i3KEcptQ008030 for ; Tue, 20 Apr 2004 16:38:51 +0200 (MEST) X-nextra-mail01-rcpt: Received: from toetsch.at (thu8.leo.home [192.168.1.5]) by lux.leo.home (Postfix on linux 2.0.36 (i386)) with ESMTP id A8E25118023 for ; Tue, 20 Apr 2004 16:28:57 +0200 (MEST) Message-ID: <408533A9.80909@toetsch.at> Date: Tue, 20 Apr 2004 16:28:57 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20011129 X-Accept-Language: en-us MIME-Version: 1.0 To: P6I Subject: hyper op - proof of concept Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Approved: n...@nntp.perl.org From: l...@toetsch.at (Leopold Toetsch) I've implemented a (rather hackish and incomplete) new opcode called C. Usage looks like: ar = new IntList ar = 1000000 hyper ar = 10 or hyper ar += 10 The atached tests fill an integer array with one Meg int constants and then increment each value 5 times. Here are the timing results (unoptimized parrot) $ time parrot -j i.imc 6060 real 0m1.927s $ time parrot ih.imc 6060 real 0m0.328s Plain run core or JIT doesn't matter for the hyper version. Only the set and add opcodes with constants are done. But it's not hard to extend the scheme and generalize it. Comments welcome, leo $ cat ih.imc .sub _main @MAIN loadlib P11, "myops_ops" .local pmc ar ar = new IntList ar = 1000000 hyper ar = 10 .local int j j = 0 lp1: hyper ar += 10 inc j if j < 5 goto lp1 set $I0, ar[0] print $I0 set $I0, ar[999999] print $I0 print "\n" .end $ cat i.imc .sub _main @MAIN .local pmc ar ar = new IntList ar = 1000000 .local int i i = 0 lp: ar[i] = 10 inc i if i < 1000000 goto lp .local int j j = 0 lp1: i = 0 lp2: $I0 = ar[i] $I0 += 10 ar[i] = $I0 inc i if i < 1000000 goto lp2 inc j if j < 5 goto lp1 set $I0, ar[0] print $I0 set $I0, ar[999999] print $I0 print "\n" .end # from dynops/myops.ops op hyper() { opcode_t *pc = expr NEXT(); INTVAL i,l; UINTVAL c; op_info_t *opinfo = &interpreter->op_info_table[*pc]; PMC *ar = REG_PMC(pc[1]); /* TODO inspect opcode */ List *list = PMC_data(ar); List_chunk *chunk; INTVAL v = pc[2], *p; int op = *pc; l = list_length(interpreter, list); i = 0; for (chunk = list->first; chunk; chunk = chunk->next) { if (chunk->flags & sparse) goto slow; p = PObj_bufstart(&chunk->data); for (c = 0; c < chunk->items; ++c, ++p) { switch (op) { case 906: /* set_p_ic */ *(INTVAL*) p = v; break; case 460: /* add_p_ic */ *(INTVAL*) p += v; break; } } i += c; } goto done; slow: for (i; i < l; ++i) list_assign(interpreter, list, i, INTVAL2PTR(void*, v), enum_type_INTVAL); done: pc += opinfo->arg_count; goto ADDRESS(pc); } PS needs latest CVS for a missing intlist vtable.