From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48942 invoked by alias); 15 Jun 2015 09:03:35 -0000 Mailing-List: contact jit-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Subscribe: Sender: jit-owner@gcc.gnu.org Received: (qmail 48931 invoked by uid 89); 15 Jun 2015 09:03:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.98.7 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-Spam-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: mail-yh0-f47.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=KonSlEY1Db3bFetIzwVf+HCigoV+RwhzEM2iIqCs4v8=; b=ZfnEL8kLmejcDwTNnl2IfW4vOYuc4P2ZddgO5yXyvq2z7XOaQ1NAyAZ9tAo6nvuABj /5Tygw39d/HLkgMLM7WRYLO0/8AqhHn08QGP80lP7GdnDcURqlDIHK09Aq64Lj3GawN/ K95Netn2B4gPTc5/fG+R0lffpvUGoboE1p6ZM4D1jPktguNC1Y0qZ4wuEua1E2hginw6 Mmkoo02bwxBu1wjZ9hyrxc3dtPJwzvSQhjeu1109yykxSC631GdzEzMxc3t1qaPPGdvP qW+zLut4NUP+7o6uXzmWLQtQDcAlov1gWI+AABQrFIb8DdxYJf+WCfzNin4cqnraI7Ap 1Xbg== X-Gm-Message-State: ALoCoQlXDuMAINdfgECWFEXqA/ZF3fnLX91FPkLje9fQKe0y8Sf8vtgcaE5favr/OFR8QSeY8Y55 X-Received: by 10.13.219.198 with SMTP id d189mr33575380ywe.171.1434359010704; Mon, 15 Jun 2015 02:03:30 -0700 (PDT) MIME-Version: 1.0 From: Dibyendu Majumdar Date: Thu, 01 Jan 2015 00:00:00 -0000 Message-ID: <-6632011183799580559@unknownmsgid> Subject: RE: First bytecode compiled in Ravi/Lua To: David Malcolm Cc: "jit@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SW-Source: 2015-q2/txt/msg00066.txt.bz2 Yes it runs! Took couple of hours of bug fixing (my code) to get from compiles to runs. Will respond to other points later tonight. From: David Malcolm Sent: =E2=80=8E15/=E2=80=8E06/=E2=80=8E2015 04:57 To: Dibyendu Majumdar Cc: jit@gcc.gnu.org Subject: Re: First bytecode compiled in Ravi/Lua On Sun, 2015-06-14 at 23:38 +0100, Dibyendu Majumdar wrote: > I am pleased to report that I can JIT compile the following minimal > Lua function: > > x=3Dfunction() return; end Excellent! > I faced following problems that I had to work around: > > 1. libgccjit fails when there are unreachable blocks - I had to patch > libgccjit to disable this validation. As explained in my previous post > this is a show stopper issue. (noted; we'll keep that discussion in the other thread) > 2. I had to make the compiled function exported - I didn't think this > should be necessary given that the function is JIT compiled, but I > suspect it is the result of the JITed function being part of a > temporary shared library? Yes, it has to be GCC_JIT_FUNCTION_EXPORTED to be accessible via gcc_jit_result_get_code(), and this is indeed because internally we're going through a shared library: https://gcc.gnu.org/onlinedocs/jit/topics/functions.html#gcc_jit_function_k= ind > ------------ > > The compiled output looks like this: > > extern int > ravif1 (struct ravi_lua_State * L) > { > struct ravi_TValue * base; > struct ravi_LClosure * cl; > > entry: > cl =3D (struct ravi_LClosure *)L->ci->func->value_.gc; > base =3D L->ci->u.l.base; > base =3D L->ci->u.l.base; > L->top =3D &base[(int)0]; > if (cl->p->sizep > (int)0) goto ; else goto > ; > > : > (void)luaF_close (L, base); > goto ; > > : > (void)luaD_poscall (L, &base[(int)0]); > return (int)1; > > : > base =3D L->ci->u.l.base; > L->top =3D &base[(int)0]; > if (cl->p->sizep > (int)0) goto ; else goto > ; > > : > (void)luaF_close (L, base); > goto ; > > : > (void)luaD_poscall (L, &base[(int)0]); > return (int)1; > } Does it run? :) Note that if you're running under gdb, you ought to be able to: (gdb) breakpoint ravif1 and gdb ought to notice when the shared library is loaded and set the breakpoint on the generated code (one advantage of doing it as a shared library internally); the notes on faking debuginfo here: https://gcc.gnu.org/onlinedocs/jit/topics/locations.html#faking-it may be pertinent; you'll also need: gcc_jit_context_set_bool_option ( ctxt, GCC_JIT_BOOL_OPTION_DEBUGINFO, 1); Dave