Path: csiph.com!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail From: BGB Newsgroups: comp.lang.java.programmer Subject: Re: no more primitive data types in Java (JDK 10+). What do you think? Date: Fri, 20 Apr 2012 20:47:04 -0700 Organization: albasani.net Lines: 56 Message-ID: References: <4f90a788$0$286$14726298@news.sunsite.dk> <30566772.52.1334881887716.JavaMail.geo-discussion-forums@pbts20> <9vd7jjFn9sU1@mid.individual.net> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.albasani.net GQauR0YqSftWjGBuAScZPMK2wLM6IVOHta11fS8f0mT5bXzSnyQCZ4RdUefQLZ0wOiCH46TuJV8HSjw/qWGYjw== NNTP-Posting-Date: Sat, 21 Apr 2012 03:48:59 +0000 (UTC) Injection-Info: news.albasani.net; logging-data="MKGLiJJNSBrqixNnBTyPepQqQjQTGRlmuSJdkaFhZxc60yBHVJzSot6SFyWD/4or8FxsW5u5OkUHmBjPThA1P2efBzak3qA0ani1IxqCybeZb1e5d8d1L0Fw7tQcZKm6"; mail-complaints-to="abuse@albasani.net" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1 In-Reply-To: <9vd7jjFn9sU1@mid.individual.net> Cancel-Lock: sha1:Nwtl7XfOnci3WKfoEBfx/eb2ZWM= Xref: csiph.com comp.lang.java.programmer:13733 On 4/20/2012 6:45 AM, Robert Klemme wrote: > On 04/20/2012 02:31 AM, Lew wrote: > >> There's also the point that source distinctions might look different >> in bytecode or machine code. What we might think of as an 'int' object >> at the source level might be treated as an ordinary machine integer at >> the lower level. > > As an additional data point: Ruby MRI works like that. Basically > integers (instances of class Fixnum) look like ordinary objects but > under the hood the value is encoded in the reference and there is no > object on the heap. You get a nice consistent model for the language > user but avoid the overhead of GC. Ruby is still not a racing car > compared with other PL - usual trade offs apply. The concept is > described here: > http://en.wikipedia.org/wiki/Tagged_pointer > > It could require a signicifant (nice typo, sounds like an animal) change > in the JVM definition though. > AFAIK, in development versions of the JVM this is apparently already being worked on (I remember seeing it being talked about a few months back on one of the JVM development mailing lists). I am not really sure about the implementation specifics though. my own VM also has fixnums, although they don't use tagged pointers. the VM uses inaccessible address-ranges as types. on 32-bit x86 targets, this generally means the space between 0xC0000000 and 0xFFFFFFFF. on x86-64, a much bigger chunk of address space is used (currently a roughly 56-bit wide region, but on current HW this could be pushed actually to about 60 or 62 bits, given the actual accessible part of the space is relatively tiny). as-is, this currently means 28 bit fixnums on x86, and 48 bit fixnums on x86-64, rather than the 30 and 62 bits possible via tagged pointers. an advantage, however, is that this does not interfere with my ability to make use of unaligned pointers: I wanted a system where I could point a character pointer anywhere in a string, and still have the type-checking able to figure out that it was a string, and more so, also be able to tell me the address of the start of the string and the relative offset therein. it all works fairly well, although type-checking is potentially a little more costly, given that most such operations need to identify the base of the heap-object in question. luckily, these lookups are "approximately" constant time (it is not really constant, but roughly ranges from O(1) to O(log2 n) depending on various factors). or such...