aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_spark.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-08-20 09:48:33 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-08-20 09:48:33 +0000
commit98cbc7e489ced8092e110777c119751f245ad116 (patch)
treeab6094d07f2fb6054eb06f98d82d1bf1d63ad42f /gcc/ada/sem_spark.adb
parenta89a0dd3b7ae2180dbfdc609fc9d7c61f250b32c (diff)
downloadgcc-98cbc7e489ced8092e110777c119751f245ad116.zip
gcc-98cbc7e489ced8092e110777c119751f245ad116.tar.gz
gcc-98cbc7e489ced8092e110777c119751f245ad116.tar.bz2
[Ada] Get rid of linear searches in Lib
This change is aimed at removing a couple of linear searches in the units management code that can become problematic performance-wise when the number of loaded units is in the several hundreds, which can happen for large files even at -O0 without any inlining. It introduces an auxiliary hash table to record a mapping between the name of units and their entry in the units table, and then replaces the linear searches by lookups in this names table. This can save up to 2% of the compilation time spent in the front-end in some cases. There should be no functional changes, except in the error message issued for circular unit dependencies in very peculiar and convoluted cases. 2019-08-20 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * lib.ads: Add with clause for GNAT.HTable. Add pragma Inline for Is_Loaded and alphabetize the list. (Unit_Name_Table_Size): New constant. (Unit_Name_Header_Num): New subtype. (Unit_Name_Hash): New function declaration. (Unit_Names): New simple hash table. (Init_Unit_Name): New procedure declaration. * lib.adb (Set_Unit_Name): Unregister the old name in the table, if any, and then register the new name. (Init_Unit_Name): New procedure. (Is_Loaded): Reimplement using a lookup in the names table. (Remove_Unit): Unregister the name. (Unit_Name_Hash): New function. * lib-load.adb (Create_Dummy_Package_Unit): Call Init_Unit_Name. (Load_Unit): Use a lookup in the names table to find out whether the unit has already been loaded. Call Init_Unit_Name and then Remove_Unit if the loading has failed. (Make_Child_Decl_Unit): Call Init_Unit_Name. (Make_Instance_Unit): Likewise. * lib-writ.adb (Ensure_System_Dependency): Likewise. From-SVN: r274720
Diffstat (limited to 'gcc/ada/sem_spark.adb')
0 files changed, 0 insertions, 0 deletions