From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Noah Lavine Newsgroups: gmane.lisp.guile.devel Subject: Troubles with Objcode and Storing JIT Pointers Date: Mon, 21 Jun 2010 14:19:31 -0400 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: dough.gmane.org 1277144385 5408 80.91.229.12 (21 Jun 2010 18:19:45 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 21 Jun 2010 18:19:45 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jun 21 20:19:44 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OQlat-00042h-4h for guile-devel@m.gmane.org; Mon, 21 Jun 2010 20:19:39 +0200 Original-Received: from localhost ([127.0.0.1]:52810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQlas-0000e3-D6 for guile-devel@m.gmane.org; Mon, 21 Jun 2010 14:19:38 -0400 Original-Received: from [140.186.70.92] (port=50606 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQlan-0000d0-Re for guile-devel@gnu.org; Mon, 21 Jun 2010 14:19:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQlam-0007yK-Eq for guile-devel@gnu.org; Mon, 21 Jun 2010 14:19:33 -0400 Original-Received: from mail-iw0-f169.google.com ([209.85.214.169]:32829) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQlam-0007yC-Bx for guile-devel@gnu.org; Mon, 21 Jun 2010 14:19:32 -0400 Original-Received: by iwn39 with SMTP id 39so2132621iwn.0 for ; Mon, 21 Jun 2010 11:19:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=JCCtrui/nDHqo9R0YafYt7NlQzsdBW/GQ+cashD+I0Q=; b=T5sEDV7Z8Oab9HLYr39D+29aVbtGIx9lPvQbHzveI0hYT3yj4PxDhE80VzUOKfy6j/ 6a3+C2GJS7A481iJ2WU7XPraeQkJ1j3Bk7gYE1hkB/gDxufMwLSEH5jsq6eCPxSFlkS5 FpUtdyFdlFx3hnjvn/sC63ym6dxNSYYBZI0pk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=xU6O310njFDKrfaqy4zYHGUr4UeU9zQTOmELcXECCKitU2Ag++nV4mo4orqK/WkUIa UKy8PeCPw2PA0XHYJ7j0BRKg7smelMeFK/CmjYo5zaii3nE/VVj/lnRTL3Ic5weImAPe UbfQ07CzhO01Kszj5fuQwaHg8tdvQpORg3Ylo= Original-Received: by 10.231.196.151 with SMTP id eg23mr5282261ibb.179.1277144371481; Mon, 21 Jun 2010 11:19:31 -0700 (PDT) Original-Received: by 10.231.12.67 with HTTP; Mon, 21 Jun 2010 11:19:31 -0700 (PDT) X-Google-Sender-Auth: 6OJ4VO-xGYCBBouu-gP47OhrgQo X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10532 Archived-At: Hello all, I have hit a snag in my attempt to add a JIT backend to Guile: I don't know where to store the JITed code. There was a discussion of this a few weeks ago in which it was decided to try to make a simple and quick JIT engine that would be invisible to Scheme, hoping to eventually make a full AOT compilation engine using GCC. I am working on this JIT engine. What I need in this is some way to stash the JIT code I've made for a procedure in such a way that I can get it back again if I need to run the same procedure again. My current attempt tries to put it in the struct scm_objcode structure as an extra pointer, but the trouble is that scm_objcodes are made directly from bytecode, by just casting the bytecode to a struct scm_objcode. That by itself wouldn't be a terrible problem, because I can rearrange things in memory behind-the-scenes to hide the extra pointer, but objcodes can also be embedded in other objcodes. In order to make this work correctly, I'd either have to scan every bytecode that becomes an objcode, find any embedded objcodes, and add space for the new pointer, or modify the bytecode compiler to leave extra room. Of these two, I think the second option would be best because it would be faster, but then the fact that the objcode structure has an extra pointer is trickling up to Scheme code, and I'm not sure where the abstraction leakage would stop. (Bytecode? Assembly code?) I could fix this by not allowing objcode slices, and instead having some sort of indirection, but that removes some efficiency that might be important. Another option is to store the JITed code with the procedure object, but a procedure is already four machine words, and making it any bigger could mess up the machine cache. Can anyone suggest a solution? Thanks Noah