From 612ad11edbae3684ed5ca4863c993db0a790c0ca Mon Sep 17 00:00:00 2001 From: aystarik Date: Wed, 29 Jun 2005 16:12:31 +0000 Subject: [PATCH] Performance enhancement: Local "cache" of parse nodes. date 2001.05.11.17.22.00; author rmoore1; state Exp; --- source/compiler/asltree.c | 34 ++++++++++++++++++++++++++++++++-- source/compiler/aslutils.c | 20 +++++++++++--------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/source/compiler/asltree.c b/source/compiler/asltree.c index 8c7e70867..4d45c613d 100644 --- a/source/compiler/asltree.c +++ b/source/compiler/asltree.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: asltree - parse tree management - * $Revision: 1.29 $ + * $Revision: 1.30 $ * *****************************************************************************/ @@ -122,6 +122,36 @@ #define _COMPONENT ACPI_COMPILER MODULE_NAME ("asltree") + + +/******************************************************************************* + * + * FUNCTION: TrGetNextNode + * + * PARAMETERS: None + * + * RETURN: New parse node. Aborts on allocation failure + * + * DESCRIPTION: Allocate a new parse node for the parse tree. Bypass the local + * dynamic memory manager for performance reasons (This has a + * major impact on the speed of the compiler.) + * + ******************************************************************************/ + +ASL_PARSE_NODE * +TrGetNextNode (void) +{ + + if (Gbl_NodeCacheNext >= Gbl_NodeCacheLast) + { + Gbl_NodeCacheNext = UtLocalCalloc (sizeof (ASL_PARSE_NODE) * ASL_NODE_CACHE_SIZE); + Gbl_NodeCacheLast = Gbl_NodeCacheNext + ASL_NODE_CACHE_SIZE; + } + + return (Gbl_NodeCacheNext++); +} + + /******************************************************************************* * * FUNCTION: TrAllocateNode @@ -141,7 +171,7 @@ TrAllocateNode ( ASL_PARSE_NODE *Node; - Node = UtLocalCalloc (sizeof (ASL_PARSE_NODE)); + Node = TrGetNextNode (); Node->ParseOpcode = (UINT16) ParseOpcode; Node->Filename = Gbl_Files[ASL_FILE_INPUT].Filename; diff --git a/source/compiler/aslutils.c b/source/compiler/aslutils.c index fb257fa3e..27df30834 100644 --- a/source/compiler/aslutils.c +++ b/source/compiler/aslutils.c @@ -2,7 +2,7 @@ /****************************************************************************** * * Module Name: aslutils -- compiler utilities - * $Revision: 1.29 $ + * $Revision: 1.32 $ * *****************************************************************************/ @@ -130,7 +130,6 @@ extern const char * const yytname[]; #endif - /******************************************************************************* * * FUNCTION: UtLocalCalloc @@ -152,7 +151,7 @@ UtLocalCalloc ( void *Allocated; - Allocated = AcpiCmCallocate (Size); + Allocated = AcpiUtCallocate (Size); if (!Allocated) { AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION, @@ -162,6 +161,9 @@ UtLocalCalloc ( exit (1); } + TotalAllocations++; + TotalAllocated += Size; + return Allocated; } @@ -340,20 +342,20 @@ UtDisplaySummary ( { - FlPrintFile (FileId, + FlPrintFile (FileId, "Compilation complete. %d Errors %d Warnings\n", Gbl_ExceptionCount[ASL_ERROR], Gbl_ExceptionCount[ASL_WARNING]); - FlPrintFile (FileId, + FlPrintFile (FileId, "ASL Input: %s - %d lines, %d bytes, %d keywords\n", - Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, + Gbl_Files[ASL_FILE_INPUT].Filename, Gbl_CurrentLineNumber, Gbl_InputByteCount, TotalKeywords); if ((Gbl_ExceptionCount[ASL_ERROR] == 0) || (Gbl_IgnoreErrors)) { - FlPrintFile (FileId, + FlPrintFile (FileId, "AML Output: %s - %d bytes %d named objects %d executable opcodes\n\n", - Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, + Gbl_Files[ASL_FILE_AML_OUTPUT].Filename, Gbl_TableLength, TotalNamedObjects, TotalExecutableOpcodes); } } @@ -402,7 +404,7 @@ UtCheckIntegerRange ( { sprintf (Buffer, "%s 0x%X-0x%X", ParseError, LowValue, HighValue); AslCompilererror (Buffer); - AcpiCmFree (Node); + AcpiUtFree (Node); return NULL; }