1. routine_id questions

What does it mean when routine_id() returns 0 in a translated/compiled program, but a positive value in a bound program?

I suspect some routines are being deleted because they are only called by routine ID, never directly. Does a call to routine_id() tell the interpreter to mark a routine as used so it doesn't get deleted?

Is it possible that a routine is used as in-lined only somewhere in the program but the actual routine gets deleted so it can't be called by routine ID?

Why would a routine ID be valid in a bound program but not in a translated program?

Is there a way to tell euc to not delete certain routines?

new topic     » topic index » view message » categorize

2. Re: routine_id questions

Wow, i can't read. The manual says a valid routine id value is "zero or more". My routine isn't being called because of bad logic: if aDoProcs[idx] > 0 then. Oops!

New question: why is routine_id 0 when translated, but 302 when interpreted or bound? Is there a difference in how/what order routine ids are created?

new topic     » goto parent     » topic index » view message » categorize

3. Re: routine_id questions

ryanj said...

New question: why is routine_id 0 when translated, but 302 when interpreted or bound? Is there a difference in how/what order routine ids are created?

I can't speak for OE, but when Phix interprets a program, it re-uses several dozen builtins that are already in memory (besides, it absolutely has to for trace/profile).
So when it starts interpreting your program, builtins such as routine_id will actually have been used many times already.
In contrast, when it compiles it writes fresh copies of the builtins to the exe, so when you app calls it, it'll be the first.

Pete

PS Not that it matters, but in Phix routine_id()s are actually always >=26 (1..15 are type masks, plus there is some other fixed stuff), whereas define_c_func/proc()'s are >=1.

new topic     » goto parent     » topic index » view message » categorize

4. Re: routine_id questions

petelomax said...
ryanj said...

New question: why is routine_id 0 when translated, but 302 when interpreted or bound? Is there a difference in how/what order routine ids are created?

I can't speak for OE, but when Phix interprets a program, it re-uses several dozen builtins that are already in memory (besides, it absolutely has to for trace/profile).
So when it starts interpreting your program, builtins such as routine_id will actually have been used many times already.
In contrast, when it compiles it writes fresh copies of the builtins to the exe, so when you app calls it, it'll be the first.

Pete

PS Not that it matters, but in Phix routine_id()s are actually always >=26 (1..15 are type masks, plus there is some other fixed stuff), whereas define_c_func/proc()'s are >=1.

I see. Interesting.

It's funny how some bugs go unnoticed for a long time until a program is run in a different environment or configuration. Expecting routine_id to return >0 instead of >= 0 in redylib worked fine for many months. The only reason i found it was File New was silently ignored when translated to C, apparently because it was the very first procedure referenced by routine_id() in the top level code. lol

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu