<div dir="ltr">Just confirming that no fields changed names.<div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Nov 6, 2018 at 6:37 AM Sebastian Huber <<a href="mailto:sebh@rtems.org">sebh@rtems.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Module: rtems<br>
Branch: master<br>
Commit: 878487b024578e887f27719887d7cada84db23bc<br>
Changeset: <a href="http://git.rtems.org/rtems/commit/?id=878487b024578e887f27719887d7cada84db23bc" rel="noreferrer" target="_blank">http://git.rtems.org/rtems/commit/?id=878487b024578e887f27719887d7cada84db23bc</a><br>
<br>
Author: Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de" target="_blank">sebastian.huber@embedded-brains.de</a>><br>
Date: Mon Nov 5 09:53:04 2018 +0100<br>
<br>
score: Optimize Objects_Information<br>
<br>
Reduce structure internal padding. Group members used by _Objects_Get()<br>
together. Reduce size of some members.<br>
<br>
Format and simplify _Objects_Extend_information().<br>
<br>
---<br>
<br>
cpukit/include/rtems/score/objectimpl.h | 28 +++----<br>
cpukit/score/src/objectextendinformation.c | 116 +++++++++++++----------------<br>
2 files changed, 66 insertions(+), 78 deletions(-)<br>
<br>
diff --git a/cpukit/include/rtems/score/objectimpl.h b/cpukit/include/rtems/score/objectimpl.h<br>
index 1bef14b..bf4d45d 100644<br>
--- a/cpukit/include/rtems/score/objectimpl.h<br>
+++ b/cpukit/include/rtems/score/objectimpl.h<br>
@@ -120,36 +120,36 @@ typedef void ( *Objects_Thread_queue_Extract_callout )(<br>
* manage each class of objects.<br>
*/<br>
typedef struct {<br>
- /** This field indicates the API of this object class. */<br>
- Objects_APIs the_api;<br>
- /** This is the class of this object set. */<br>
- uint16_t the_class;<br>
/** This is the minimum valid id of this object class. */<br>
Objects_Id minimum_id;<br>
/** This is the maximum valid id of this object class. */<br>
Objects_Id maximum_id;<br>
+ /** This points to the table of local objects. */<br>
+ Objects_Control **local_table;<br>
/** This is the maximum number of objects in this class. */<br>
Objects_Maximum maximum;<br>
+ /** This is the number of objects on the Inactive list. */<br>
+ Objects_Maximum inactive;<br>
+ /** This is the number of objects in a block. */<br>
+ Objects_Maximum allocation_size;<br>
+ /** This is the maximum length of names. */<br>
+ uint16_t name_length;<br>
+ /** This field indicates the API of this object class. */<br>
+ uint8_t the_api;<br>
+ /** This is the class of this object set. */<br>
+ uint8_t the_class;<br>
/** This is true if names are strings. */<br>
bool is_string;<br>
/** This is the true if unlimited objects in this class. */<br>
bool auto_extend;<br>
- /** This is the number of objects in a block. */<br>
- Objects_Maximum allocation_size;<br>
/** This is the size in bytes of each object instance. */<br>
size_t size;<br>
- /** This points to the table of local objects. */<br>
- Objects_Control **local_table;<br>
/** This is the chain of inactive control blocks. */<br>
Chain_Control Inactive;<br>
- /** This is the number of objects on the Inactive list. */<br>
- Objects_Maximum inactive;<br>
/** This is the number of inactive objects per block. */<br>
- uint32_t *inactive_per_block;<br>
+ Objects_Maximum *inactive_per_block;<br>
/** This is a table to the chain of inactive object memory blocks. */<br>
- void **object_blocks;<br>
- /** This is the maximum length of names. */<br>
- uint16_t name_length;<br>
+ Objects_Control **object_blocks;<br>
#if defined(RTEMS_MULTIPROCESSING)<br>
/** This is this object class' method called when extracting a thread. */<br>
Objects_Thread_queue_Extract_callout extract;<br>
diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c<br>
index f4ac11b..d2ee7fd 100644<br>
--- a/cpukit/score/src/objectextendinformation.c<br>
+++ b/cpukit/score/src/objectextendinformation.c<br>
@@ -51,8 +51,8 @@ void _Objects_Extend_information(<br>
uint32_t minimum_index;<br>
uint32_t index;<br>
uint32_t maximum;<br>
- size_t block_size;<br>
- void *new_object_block;<br>
+ size_t object_block_size;<br>
+ Objects_Control *new_object_block;<br>
bool do_extend;<br>
<br>
_Assert(<br>
@@ -100,13 +100,13 @@ void _Objects_Extend_information(<br>
* Allocate the name table, and the objects and if it fails either return or<br>
* generate a fatal error depending on auto-extending being active.<br>
*/<br>
- block_size = information->allocation_size * information->size;<br>
+ object_block_size = information->allocation_size * information->size;<br>
if ( information->auto_extend ) {<br>
- new_object_block = _Workspace_Allocate( block_size );<br>
+ new_object_block = _Workspace_Allocate( object_block_size );<br>
if ( !new_object_block )<br>
return;<br>
} else {<br>
- new_object_block = _Workspace_Allocate_or_fatal_error( block_size );<br>
+ new_object_block = _Workspace_Allocate_or_fatal_error( object_block_size );<br>
}<br>
<br>
/*<br>
@@ -114,13 +114,13 @@ void _Objects_Extend_information(<br>
*/<br>
if ( do_extend ) {<br>
ISR_lock_Context lock_context;<br>
- void **object_blocks;<br>
- uint32_t *inactive_per_block;<br>
+ Objects_Control **object_blocks;<br>
Objects_Control **local_table;<br>
+ Objects_Maximum *inactive_per_block;<br>
void *old_tables;<br>
- size_t block_size;<br>
+ size_t table_size;<br>
uintptr_t object_blocks_size;<br>
- uintptr_t inactive_per_block_size;<br>
+ uintptr_t local_table_size;<br>
<br>
/*<br>
* Growing the tables means allocating a new area, doing a copy and<br>
@@ -129,58 +129,49 @@ void _Objects_Extend_information(<br>
* If the maximum is minimum we do not have a table to copy. First<br>
* time through.<br>
*<br>
- * The allocation has :<br>
+ * The allocation has:<br>
*<br>
- * void *objects[block_count];<br>
- * uint32_t inactive_count[block_count];<br>
- * Objects_Control *local_table[maximum];<br>
+ * Objects_Control *object_blocks[ block_count ];<br>
+ * Objects_Control *local_table[ maximum ];<br>
+ * Objects_Maximum inactive_count[ block_count ];<br>
*<br>
* This is the order in memory. Watch changing the order. See the memcpy<br>
* below.<br>
*/<br>
<br>
/*<br>
- * Up the block count and maximum<br>
+ * Up the block count and maximum.<br>
*/<br>
block_count++;<br>
<br>
/*<br>
- * Allocate the tables and break it up. The tables are:<br>
- * 1. object_blocks : void*<br>
- * 2. inactive_per_blocks : uint32_t<br>
- * 3. local_table : Objects_Name*<br>
+ * Allocate the tables and break it up.<br>
*/<br>
- object_blocks_size = (uintptr_t)_Addresses_Align_up(<br>
- (void*)(block_count * sizeof(void*)),<br>
- CPU_ALIGNMENT<br>
- );<br>
- inactive_per_block_size =<br>
- (uintptr_t)_Addresses_Align_up(<br>
- (void*)(block_count * sizeof(uint32_t)),<br>
- CPU_ALIGNMENT<br>
- );<br>
- block_size = object_blocks_size + inactive_per_block_size +<br>
- ((maximum + minimum_index) * sizeof(Objects_Control *));<br>
+ object_blocks_size = block_count * sizeof( *object_blocks );<br>
+ local_table_size = ( maximum + minimum_index ) * sizeof( *local_table );<br>
+ table_size = object_blocks_size<br>
+ + local_table_size<br>
+ + block_count * sizeof( *inactive_per_block );<br>
if ( information->auto_extend ) {<br>
- object_blocks = _Workspace_Allocate( block_size );<br>
+ object_blocks = _Workspace_Allocate( table_size );<br>
if ( !object_blocks ) {<br>
_Workspace_Free( new_object_block );<br>
return;<br>
}<br>
} else {<br>
- object_blocks = _Workspace_Allocate_or_fatal_error( block_size );<br>
+ object_blocks = _Workspace_Allocate_or_fatal_error( table_size );<br>
}<br>
<br>
/*<br>
* Break the block into the various sections.<br>
*/<br>
- inactive_per_block = (uint32_t *) _Addresses_Add_offset(<br>
- object_blocks,<br>
- object_blocks_size<br>
+ local_table = _Addresses_Add_offset(<br>
+ object_blocks,<br>
+ object_blocks_size<br>
);<br>
- local_table = (Objects_Control **) _Addresses_Add_offset(<br>
- inactive_per_block,<br>
- inactive_per_block_size<br>
+ inactive_per_block = _Addresses_Add_offset(<br>
+ local_table,<br>
+ local_table_size<br>
);<br>
<br>
/*<br>
@@ -190,23 +181,26 @@ void _Objects_Extend_information(<br>
block_count--;<br>
<br>
if ( information->maximum > minimum_index ) {<br>
-<br>
/*<br>
* Copy each section of the table over. This has to be performed as<br>
* separate parts as size of each block has changed.<br>
*/<br>
-<br>
- memcpy( object_blocks,<br>
- information->object_blocks,<br>
- block_count * sizeof(void*) );<br>
- memcpy( inactive_per_block,<br>
- information->inactive_per_block,<br>
- block_count * sizeof(uint32_t) );<br>
- memcpy( local_table,<br>
- information->local_table,<br>
- (information->maximum + minimum_index) * sizeof(Objects_Control *) );<br>
+ memcpy(<br>
+ object_blocks,<br>
+ information->object_blocks,<br>
+ block_count * sizeof( *object_blocks )<br>
+ );<br>
+ memcpy(<br>
+ inactive_per_block,<br>
+ information->inactive_per_block,<br>
+ block_count * sizeof( *inactive_per_block )<br>
+ );<br>
+ memcpy(<br>
+ local_table,<br>
+ information->local_table,<br>
+ ( information->maximum + minimum_index ) * sizeof( *local_table )<br>
+ );<br>
} else {<br>
-<br>
/*<br>
* Deal with the special case of the 0 to minimum_index<br>
*/<br>
@@ -218,9 +212,6 @@ void _Objects_Extend_information(<br>
/*<br>
* Initialise the new entries in the table.<br>
*/<br>
- object_blocks[block_count] = NULL;<br>
- inactive_per_block[block_count] = 0;<br>
-<br>
for ( index = index_base ; index < index_end ; ++index ) {<br>
local_table[ index ] = NULL;<br>
}<br>
@@ -235,11 +226,11 @@ void _Objects_Extend_information(<br>
information->local_table = local_table;<br>
information->maximum = (Objects_Maximum) maximum;<br>
information->maximum_id = _Objects_Build_id(<br>
- information->the_api,<br>
- information->the_class,<br>
- _Objects_Local_node,<br>
- information->maximum<br>
- );<br>
+ information->the_api,<br>
+ information->the_class,<br>
+ _Objects_Local_node,<br>
+ information->maximum<br>
+ );<br>
<br>
_ISR_lock_ISR_enable( &lock_context );<br>
<br>
@@ -252,11 +243,13 @@ void _Objects_Extend_information(<br>
* Assign the new object block to the object block table.<br>
*/<br>
information->object_blocks[ block ] = new_object_block;<br>
+ information->inactive_per_block[ block ] = information->allocation_size;<br>
+ information->inactive += information->allocation_size;<br>
<br>
/*<br>
* Append to inactive chain.<br>
*/<br>
- the_object = information->object_blocks[ block ];<br>
+ the_object = new_object_block;<br>
for ( index = index_base ; index < index_end ; ++index ) {<br>
the_object->id = _Objects_Build_id(<br>
information->the_api,<br>
@@ -268,11 +261,6 @@ void _Objects_Extend_information(<br>
_Chain_Initialize_node( &the_object->Node );<br>
_Chain_Append_unprotected( &information->Inactive, &the_object->Node );<br>
<br>
- the_object = (Objects_Control *)<br>
- ( (char *) the_object + information->size );<br>
+ the_object = _Addresses_Add_offset( the_object, information->size );<br>
}<br>
-<br>
- information->inactive_per_block[ block ] = information->allocation_size;<br>
- information->inactive =<br>
- (Objects_Maximum)(information->inactive + information->allocation_size);<br>
}<br>
<br>
_______________________________________________<br>
vc mailing list<br>
<a href="mailto:vc@rtems.org" target="_blank">vc@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/vc" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/vc</a><br>
</blockquote></div>