From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30454 invoked by alias); 3 Oct 2007 19:43:58 -0000 Received: (qmail 30443 invoked by uid 22791); 3 Oct 2007 19:43:56 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 03 Oct 2007 19:43:51 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id l93JhnZK001204 for ; Wed, 3 Oct 2007 15:43:49 -0400 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l93Jhn1U030752; Wed, 3 Oct 2007 15:43:49 -0400 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id l93Jhmsn028548; Wed, 3 Oct 2007 15:43:48 -0400 Message-ID: <4703F084.8050301@redhat.com> Date: Wed, 03 Oct 2007 19:43:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Phil Muldoon CC: Frysk Hackers Subject: Re: ISA checks for factories References: <4703549C.30709@redhat.com> In-Reply-To: <4703549C.30709@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00014.txt.bz2 Phil, unfortunate timing, we crossed e-mails during the night, Phil Muldoon wrote: > I've written several factories to decide what class to instantiate > depending on the ISA. These usually end up as hacks, probably because > I do not understand something quite right, or there is no real decent > "What ISA does this task/proc belong" discovery. > > I can instance check an ISA with: > > Isa isa = proc.getIsa(); There is now also: ISA isa = task.getISA() which returns a frysk.isa.ISA, which looks smells and behaves like an ENUM. This new ISA just the following attributes: - family (i386, x8664, PPC) - word size (4, 8) - byte order (little, big) leading to the combinations: IA32, X8664, PPC32LE, PPC32BE, PPC64LE, PPC64BE. > if (isa instanceof IsaIA32) .... It can then be used as either: if (isa == ISA.IA32) .. else if (isa = ISA.X8664) .. or better?: ISAMap map = new ISAMap("why am I here") .put(ISA.IA32, new My(IA32)) .put(ISA.X8664, new My(X8664)) ; ... // Throws a RuntimeException if ISA missing My o = (My) map.get(task.getISA); which could easily be wrapped up in a factory. Andrew > > and so on, but that will not work for 32 on 64 ISAs. For example, on a > 32 bit process on a 64 bit system, the instance returned would be > > LinuxIa32On64 > > And those cannot be instance checked as they are package private, > while the "native" ISAs are public. > > So what is the solution here? Open the scope of the xxOnxx ISAs? I get > the feeling that instanceof checks tell me that we need to work on a > better solution anyway. Reverting to reflection screams hack to me. > > Regards > > Phil