From 5ec65b7c993ef271f791d851ebaf2c4ec3f19068 Mon Sep 17 00:00:00 2001 From: Jan Vrany Date: Wed, 4 Sep 2024 10:57:23 +0100 Subject: [PATCH] Cache binary encoding in ProcessorInstructionDeclaration This commit caches encoding bitvector in ProcessorInstructionDeclaration instead of creating it on demand. This change speeds up decoding of ~170 instructions from ~35secs to ~15 secs (which is still appalling). --- src/ArchC-Core/ProcessorInstruction.class.st | 3 --- src/ArchC-Core/ProcessorInstructionDeclaration.class.st | 8 ++++++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ArchC-Core/ProcessorInstruction.class.st b/src/ArchC-Core/ProcessorInstruction.class.st index 86af1bb..b026871 100644 --- a/src/ArchC-Core/ProcessorInstruction.class.st +++ b/src/ArchC-Core/ProcessorInstruction.class.st @@ -6,9 +6,6 @@ When the PDL spec is initially parsed, the ""instrictions"" Dictionary is filled Class { #name : #ProcessorInstruction, #superclass : #ProcessorInstructionDeclaration, - #instVars : [ - 'binaryEncoding' - ], #category : #'ArchC-Core-Core' } diff --git a/src/ArchC-Core/ProcessorInstructionDeclaration.class.st b/src/ArchC-Core/ProcessorInstructionDeclaration.class.st index e38c8da..9764e50 100644 --- a/src/ArchC-Core/ProcessorInstructionDeclaration.class.st +++ b/src/ArchC-Core/ProcessorInstructionDeclaration.class.st @@ -12,7 +12,8 @@ Class { 'format', 'internalBindings', 'syntax', - 'isa' + 'isa', + 'binaryEncoding' ], #classVars : [ 'EmptyBindings' @@ -132,7 +133,10 @@ ProcessorInstructionDeclaration >> assertInvariants [ { #category : #accessing } ProcessorInstructionDeclaration >> binaryEncoding [ - ^format binaryEncoding inEnvironment: internalBindings + binaryEncoding isNil ifTrue: [ + binaryEncoding := format binaryEncoding inEnvironment: internalBindings. + ]. + ^ binaryEncoding ] { #category : #accessing }