Page 3 of 6
Re: Code optimization
Posted: Thu Jan 02, 2014 11:51 am
by c4s
Danilo wrote:20% - 30% is a big thing when fighting against
BLOATED .EXEs from competitors...
Together with the correctness of compilation and runtime speed of the generated code, it is an indication of the quality of a compiler.
I totally agree.
Would it be possible to integrate your optimizer in the IDE as a "tool"?
Re: Code optimization
Posted: Thu Jan 02, 2014 9:45 pm
by Danilo
c4s wrote:Would it be possible to integrate your optimizer in the IDE as a "tool"?
Use this version:
DeadProcedureRemover_IDE.zip and follow the 3 steps in readme.txt
Re: Code optimization
Posted: Fri Jan 03, 2014 5:22 am
by Danilo
skywalk wrote:Just need to verify all version info/icon is retained(from IDE settings), otherwise I have to start using resource files.

If you install
DeadProcedureRemover_IDE.zip, everything works automatically from within the IDE.
Just compile your project from IDE and unused procedures get removed automatically.
Re: Code optimization
Posted: Fri Jan 03, 2014 5:39 am
by skywalk
Hi Danilo,
I only used the IDE to build my apps and therefore used the Version info and icon stuff in the IDE menu. It adds that to the end of the source file.
If I use 'pbcompiler purebasic.asm /reasm' then I lose that stuff in the final exe.
So now I am making resource files.
But, now I get a new compiler error I don't see from the IDE for the same compiler options.

C:\Program Files\PureBasic\Compilers\pbcompiler.exe purebasic.asm /reasm /xp /thread /resource myres.rc /exe myapp.exe wrote:******************************************
PureBasic 5.21 LTS (Windows - x86)
******************************************
Compiling purebasic.asm
Loading external libraries...
ReAssembling source code...
Creating executable "myapp.exe".
Error: Linker
POLINK: error: Unresolved external symbol '_PB_StringBasePosition'.
POLINK: fatal error: 1 unresolved external(s).
If I drop '/thread', the error goes away. This is true for both shrunk and original asm files.
But, I can compile the original pb source code with /thread.
So, it looks like /reasm does not work with /thread?
Re: Code optimization
Posted: Fri Jan 03, 2014 6:10 am
by Danilo
skywalk wrote:Hi Danilo,
I only used the IDE to build my apps and therefore used the Version info and icon stuff in the IDE menu. It adds that to the end of the source file.
If I use 'pbcompiler purebasic.asm /reasm' then I lose that stuff in the final exe.
If you use 'DeadProcedureRemover_IDE.zip' you don't need to do /REASM anymore,
so your version info and icon etc. just work as before. Why still do the /REASM thing?
Re: Code optimization
Posted: Fri Jan 03, 2014 6:35 am
by skywalk
Cool, I did not try the latest DeadProcedureRemover_IDE.zip file. I will give it a go. I was spending time in boring resource files.

But, I had planned this anyway to add more automation to the build process and include source control updates to fossil and push files to release folders for innosetup packaging. I am down to a few clicks now to compile new exe and push updates to source control repo and create a new installer and push that to server. Of course, all my bugs go along for the ride.

Re: Code optimization
Posted: Fri Jan 03, 2014 10:48 am
by c4s
Danilo wrote:skywalk wrote:Just need to verify all version info/icon is retained(from IDE settings), otherwise I have to start using resource files.

If you install
DeadProcedureRemover_IDE.zip, everything works automatically from within the IDE.
Just compile your project from IDE and unused procedures get removed automatically.
Thanks! I'll give it a try as soon as I have enough time.
Re: Code optimization
Posted: Sun Jan 05, 2014 4:18 pm
by skywalk
Argg, Danilo. I am now stuck when trying the same approach for mydll.asm?
There is no main line code to compare against defined ProcedureDLL's.
Does this mean we have to edit the source code to drop orphan procedures?
Re: Code optimization
Posted: Sun Jan 05, 2014 8:14 pm
by Danilo
skywalk wrote:Argg, Danilo. I am now stuck when trying the same approach for mydll.asm?
There is no main line code to compare against defined ProcedureDLL's.
I tested DeadProcedureRemover_IDE.zip also with DLLs. It worked because I'm looking
for references in the form of "_ProcedureXXX" and ProcedureDLL functions are referenced
outside MPXXX{} macros at the beginning of the ASM output:
Code: Select all
public _Procedure6
public _Procedure8
public _Procedure10
public _Procedure12
public _Procedure2
Those "public _ProcedureXXX" are ProcedureDLL functions and get included by default.
Other procedures get included only if they are referenced by one of the public _ProcedureXXX
functions, or in data sections etc.
EDIT:
Simple test, compile to DLL from within the IDE:
Code: Select all
ProcedureDLL Init()
EndProcedure
Procedure DoIt(x=0)
if x = 123
procedurereturn DoIt()
endif
EndProcedure
ProcedureDLL Func1()
; DoIt()
EndProcedure
ProcedureDLL Func2()
; DoIt()
EndProcedure
It can remove DoIt() because it is not referenced by any other function,
and it is a "Procedure", not "ProcedureDLL".
ProcedureDLL are always included, because the are exported, so they
can be called by external programs. ProcedureDLL can not get removed.
Output in the IDE log window for the above DLL test (with installed
DeadProcedureRemover_IDE.zip):
Code: Select all
Analyzing 'PureBasic.asm'
- Found 4 procedure macros.
- Removed 1 out of 4 used procedure macros.
The procedure that got removed is DoIt().
Re: Code optimization
Posted: Wed Mar 26, 2014 11:35 am
by c4s
Danilo, thanks again. I love your Dead Procedure Remover tool!
I wonder why something like this isn't officially integrated in the compiler yet. Because when looking at your source the implementation seems to be rather easy too.
Just one question: Currently the "installation" is a little uncomfortable - especially when working with different compiler/OS versions etc. Is it possible to integrate it into the IDE as a tool without having to rename fasm.exe?
Re: Code optimization
Posted: Wed Mar 26, 2014 2:11 pm
by Tenaja
Danilo wrote:skywalk wrote:Just need to verify all version info/icon is retained(from IDE settings), otherwise I have to start using resource files.

If you install
DeadProcedureRemover_IDE.zip, everything works automatically from within the IDE.
Just compile your project from IDE and unused procedures get removed automatically.
Danilo, would you mind sharing the source to that Dead Procedure Remover program?
Re: Code optimization
Posted: Wed Mar 26, 2014 8:08 pm
by Danilo
Tenaja wrote:Danilo, would you mind sharing the source to that Dead Procedure Remover program?
It is already included in
DeadProcedureRemover.zip.
The FASM/IDE version is there:
DeadProcedureRemover_IDE_SRC.zip
Re: Code optimization
Posted: Wed Mar 26, 2014 9:18 pm
by Danilo
c4s wrote:Just one question: Currently the "installation" is a little uncomfortable - especially when working with different compiler/OS versions etc. Is it possible to integrate it into the IDE as a tool without having to rename fasm.exe?
Could you write a small tool that automates the process of replacing FAsm.exe for all installed PB versions?
I think that would be the simplest solution.
Re: Code optimization
Posted: Thu Mar 27, 2014 3:49 am
by Tenaja
Thanks. The one I had (files dated 1/1/14) did not include it.
Re: Code optimization
Posted: Thu Mar 27, 2014 10:18 am
by c4s
@Danilo
I was looking for a more "integrated" solution. Replacing files of the compiler just doesn't feel right, plus the functionality cannot easily be enabled/disabled. Thanks for your suggestion though.