GP-6545 Switch to using deque for PcodeCacher::issued

This commit is contained in:
caheckman
2026-03-09 21:34:46 +00:00
committed by Ryan Kurtz
parent bcea8f547f
commit 4a9b40c453
3 changed files with 14 additions and 12 deletions

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -29,6 +29,7 @@
#include <set> #include <set>
#include <list> #include <list>
#include <vector> #include <vector>
#include <deque>
#include <algorithm> #include <algorithm>
#include <cstring> #include <cstring>
#include <cctype> #include <cctype>
@@ -40,6 +41,7 @@ using std::map;
using std::set; using std::set;
using std::list; using std::list;
using std::vector; using std::vector;
using std::deque;
using std::pair; using std::pair;
using std::make_pair; using std::make_pair;
using std::ostream; using std::ostream;

View File

@@ -55,16 +55,16 @@ VarnodeData *PcodeCacher::expandPool(uint4 size)
for(uint4 i=0;i<cursize;++i) for(uint4 i=0;i<cursize;++i)
newpool[i] = poolstart[i]; // Copy old data newpool[i] = poolstart[i]; // Copy old data
// Update references to the old pool // Update references to the old pool
for(uint4 i=0;i<issued.size();++i) { for(deque<PcodeData>::iterator diter=issued.begin();diter!=issued.end();++diter) {
VarnodeData *outvar = issued[i].outvar; VarnodeData *outvar = (*diter).outvar;
if (outvar != (VarnodeData *)0) { if (outvar != (VarnodeData *)0) {
outvar = newpool + (outvar - poolstart); outvar = newpool + (outvar - poolstart);
issued[i].outvar = outvar; (*diter).outvar = outvar;
} }
VarnodeData *invar = issued[i].invar; VarnodeData *invar = (*diter).invar;
if (invar != (VarnodeData *)0) { if (invar != (VarnodeData *)0) {
invar = newpool + (invar - poolstart); invar = newpool + (invar - poolstart);
issued[i].invar = invar; (*diter).invar = invar;
} }
} }
list<RelativeRecord>::iterator iter; list<RelativeRecord>::iterator iter;
@@ -139,7 +139,7 @@ void PcodeCacher::resolveRelatives(void)
void PcodeCacher::emit(const Address &addr,PcodeEmit *emt) const void PcodeCacher::emit(const Address &addr,PcodeEmit *emt) const
{ {
vector<PcodeData>::const_iterator iter; deque<PcodeData>::const_iterator iter;
for(iter=issued.begin();iter!=issued.end();++iter) for(iter=issued.begin();iter!=issued.end();++iter)
emt->dump(addr,(*iter).opc,(*iter).outvar,(*iter).invar,(*iter).isize); emt->dump(addr,(*iter).opc,(*iter).outvar,(*iter).invar,(*iter).isize);

View File

@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -42,9 +42,9 @@ struct RelativeRecord {
/// ///
/// Raw data used by the emitter to produce a single PcodeOp /// Raw data used by the emitter to produce a single PcodeOp
struct PcodeData { struct PcodeData {
OpCode opc; ///< The op code
VarnodeData *outvar; ///< Output Varnode data (or null) VarnodeData *outvar; ///< Output Varnode data (or null)
VarnodeData *invar; ///< Array of input Varnode data VarnodeData *invar; ///< Array of input Varnode data
OpCode opc; ///< The op code
int4 isize; ///< Number of input Varnodes int4 isize; ///< Number of input Varnodes
}; };
@@ -59,7 +59,7 @@ class PcodeCacher {
VarnodeData *poolstart; ///< Start of the pool of VarnodeData objects VarnodeData *poolstart; ///< Start of the pool of VarnodeData objects
VarnodeData *curpool; ///< First unused VarnodeData VarnodeData *curpool; ///< First unused VarnodeData
VarnodeData *endpool; ///< End of the pool of VarnodeData objects VarnodeData *endpool; ///< End of the pool of VarnodeData objects
vector<PcodeData> issued; ///< P-code ops issued for the current instruction deque<PcodeData> issued; ///< P-code ops issued for the current instruction
list<RelativeRecord> label_refs; ///< References to labels list<RelativeRecord> label_refs; ///< References to labels
vector<uintb> labels; ///< Locations of labels vector<uintb> labels; ///< Locations of labels
VarnodeData *expandPool(uint4 size); ///< Expand the memory pool VarnodeData *expandPool(uint4 size); ///< Expand the memory pool