Shop OBEX P1 Docs P2 Docs Learn Events
I have a question. — Parallax Forums

I have a question.

James LongJames Long Posts: 1,181
edited 2006-09-22 19:22 in Propeller 1
Ok....So I'm propping right along....and something pops into my head.

Does the Prop....include all of an external object that is started?

Or just the needed parts?

I know the answer (I Think) , but I'm just making sure.

James L

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-15 04:17
    I believe the Propeller Tool eliminates methods that are not called or otherwise referenced. It certainly eliminates duplicate copies of the same object that may be included (but keeps separate copies of their VAR data areas). The Propeller Tool can't know what's needed, but it can determine what absolutely isn't needed.

    For example, you can declare an array of FullDuplexSerial objects, say a 4 element array. There are 4 copies of the VAR area for the object allocated, but only one copy of the code and DAT area.
  • James LongJames Long Posts: 1,181
    edited 2006-09-15 18:00
    Mike said...
    I believe the Propeller Tool eliminates methods that are not called or otherwise referenced. It certainly eliminates duplicate copies of the same object that may be included (but keeps separate copies of their VAR data areas). The Propeller Tool can't know what's needed, but it can determine what absolutely isn't needed.

    For example, you can declare an array of FullDuplexSerial objects, say a 4 element array. There are 4 copies of the VAR area for the object allocated, but only one copy of the code and DAT area.
    My question here is.......say I use the FullDuplexSerial.spin.· Will it include all of the instructions contained within...or will it only include the·instructions needed for my use?

    This is not really important....unless you get some fluffy objects floating around in the object exchange.

    I'm just asking.....because it may be worth while for some of the Propeller guys to insure(read with the time they have allowed) the objects are optimized. This is a matter of opinion, I guess, optimized code for one person is too complicated for another.

    I know the project I'm working on is quite large and will have a bunch of communication. This will not be bad because of the way the objects are used in multiples...but not really multiplied.

    But I also have an enormous number of calculations to go along with those communications.

    Just trying to learn before I get too deep.

    James L

    Post Edited (James Long) : 9/15/2006 6:04:13 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-15 18:16
    The trick here is the term "needed". Some optimizers actually trace through your program interpretively, trying to see if there are places that simply cannot be "reached" through any combination of data inputs. This is often useful in C where there's a lot of macro use and sometimes the macro substitutions create "nonsense" code that can never actually be executed. This isn't the case in SPIN, but, with the use of object libraries, there are often "methods" (routines) that are included, but never referenced. I believe the Propeller Tool will leave out any methods that are never referenced. It's not sophisticated enough to figure out whether a method is referenced, but not needed for some reason. The notion of referenced is recursive, so, if a method is only referenced by other methods that are not referenced, they're not included either. Does this help?
  • James LongJames Long Posts: 1,181
    edited 2006-09-15 18:45
    Mike,

    I guess I get your point.....basically....the IDE only includes the·routines that are called. And excludes the routines that are not invoked.

    I was confused about the difference in an Object and a Routine. I see that·an Object consist of different routines or blocks of code.

    Sometimes our verbage makes the meaning.

    Do I have that right?

    I'm impressed that the program removes the fluff (routines) not being "used".

    Thanks for the very·specific·information,

    James L
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-15 20:05
    Yep, the Propeller Tool removes the fluff.

    One person's fluff is another person's "meat".
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-09-19 19:25
    ...and another persons jelly....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd

    ·
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-09-19 19:30
    ...and another persons jelly....
    I'v done some test...
    Code that isnt called that is inside a called routine is indeed compiled and sent out...
    Code that isnt called and is in it's own sub (aka PRI or PUB) isn't compiled...
    Obj's that are defined but are never used (stated) aren't compiled and sent out.
    All vars that are declaired are compiled (used or not) <- my biggest problem!
    Unused sub in a defined and started OBJ are not compiled or sent.
    Lastly...
    All vars, cons and dats are compiled and sent.
    Remarks (aka my peanut butter!) are not compiled.

    Ok, just some EMF's from my desktop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd

    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-19 19:45
    Yeah, that's the way it's supposed to work. The granularity is on the PRI/PUB basis
    and a routine (method) is included if it's referenced by an included routine. The first
    PUB routine in the main file (object) is implicitly called by the SPIN interpreter so it's
    always included.

    All VARS in an object are included each time the object is declared in another object
    (with the main object always included once). Object arrays are what you'd expect -
    multiple instances of the VARS of the object.

    CONs are not really included in the binary, they're only used at compile time.
    DATs are included once only when the object is included.

    Good that you've done some testing.

    One of the ways I've found to save on VARs is to use a lot of local variables. They're
    allocated in the stack and only exist when the routine (method) is executing. The
    local variables are allocated strictly in order so you can create small arrays by allocating
    several local (long) variables in a group. As an example, I needed a 32 byte buffer for
    some text and declared 8 local variables in order, then referenced them using byte[noparse]/noparse:
    PRI bufferIt | j, c, b0, b1, b2, b3, b4, b5, b6, b7
      j := 0
      repeat until (c := serial.rx) == 13 or j == 31
        byte[noparse][[/noparse]@b0][noparse][[/noparse]j++] := c
      byte[noparse][[/noparse]@b0][noparse][[/noparse]j] := 0
      display.str(string("Received: "))
      display.str(@b0)
      display.out(13)
    
    
  • James LongJames Long Posts: 1,181
    edited 2006-09-19 20:47
    Kaos Kidd said...
    ...and another persons jelly....
    I'v done some test...
    Code that isnt called that is inside a called routine is indeed compiled and sent out...
    Code that isnt called and is in it's own sub (aka PRI or PUB) isn't compiled...
    Obj's that are defined but are never used (stated) aren't compiled and sent out.
    All vars that are declaired are compiled (used or not) <- my biggest problem!
    Unused sub in a defined and started OBJ are not compiled or sent.
    Lastly...
    All vars, cons and dats are compiled and sent.
    Remarks (aka my peanut butter!) are not compiled.

    Ok, just some EMF's from my desktop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Wow....that is actually really cool....so we can use objects and not worry about the inflated overhead of unused commands.

    James L
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-09-22 16:11
    SOmething pointed out to me in a IM:
    An empty PUB/PRI (no code it it) that wasn't called by any other PUB/PRI did increase the program size by two longs.
    I didn't go into that depth when I looked at things.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

    Propeller + Hardware - extra bits for the bit bucket =· 1 Coffeeless KaosKidd

    ·
  • MacGeek117MacGeek117 Posts: 747
    edited 2006-09-22 19:22
    I'm liking SPIN more and more! It's relatively easy to understand.
    RoboGeek

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "I reject your reality and subsitute my own!"

    Adam Savage, Mythbusters
    www.parallax.com
    www.goldmine-elec.com
    www.expresspcb.com
    www.startrek.com
    ·
Sign In or Register to comment.