Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!tektronix!cae780!daniels From: daniels@cae780.UUCP Newsgroups: comp.arch Subject: Re: 32-bit CPUs ( NEC V70 ) and silly examples Message-ID: <3962@cae780.TEK.COM> Date: Tue, 19-May-87 18:16:27 EDT Article-I.D.: cae780.3962 Posted: Tue May 19 18:16:27 1987 Date-Received: Thu, 21-May-87 03:18:43 EDT References: <3810030@nucsrl.UUCP> <491@necis.UUCP> <3530@spool.WISC.EDU> <1526@drivax.UUCP> <166@auvax.UUCP> Reply-To: daniels@cae780.UUCP (Scott Daniels) Distribution: na Organization: Tektronix, Inc., Beaverton, OR. Lines: 44 Keywords: V60, V70, not so silly examples Summary: multiple subfields levels may not be from source In article <166@auvax.UUCP> rwa@auvax.UUCP (Ross Alexander) writes: [ discussion about the frequency of a->b->c->d ] >365 occurences of 'a->b->c' >5 occurences of 'a->b->c->d' >0 occurences of >'a->b->c->d->e' >My conclusion from this evidence is that deep levels of indirection >a la a->b->c... are a lightly used feature. One thing that is being overlooked here is the layers of effective "p->f" which are not in the source code. Typically each procedure has a "frame pointer" which points to its argument and local variables area. This means that code like: prog(ptr) struct some_type *ptr; { ptr->field->link_field = 0; } translates to: frame_ptr->arg_offset_ptr->field->link_field = 0; The problem is worse when you consider languages like Algol and Pascal Which provide definitions of functions inside functions and allow up-level access of the containing functions variables. For example: some_function( ptr : Pascal_pointer_type ): int inner_function(): int begin with ptr^ do inner_function := 12 + numeric_field end; begin some_function := Another_function( inner_function ) end; The code for inner function is like: return 12 + ptr^.numeric_field == return 12 + ptr->numeric_field == return 12 + inner_function_frame->parent_ptr->arg_offset_ptr->field So the multi-level structure offset is not quite so wierd as it seems at first glimmer (the compiler is generating some extra layers). FROM: Scott Daniels, Tektronix CAE 5302 Betsy Ross Drive, Santa Clara, CA 95054 UUCP: tektronix!teklds!cae780!daniels {ihnp4, decvax!decwrl}!amdcad!cae780!daniels {nsc, hplabs, resonex, qubix, leadsv}!cae780!daniels