mirror of https://github.com/icedland/iced.git
Add IcedFeatures.Initialize()
This commit is contained in:
parent
08b38c2634
commit
ffe451afe7
|
@ -21,6 +21,8 @@ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Iced.Intel {
|
||||
/// <summary>
|
||||
/// Gets the available features
|
||||
|
@ -129,5 +131,22 @@ namespace Iced.Intel {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes some static constructors related to the decoder and instruction info. If those
|
||||
/// static constructors are initialized, the jitter generates faster code since it doesn't have
|
||||
/// to add runtime checks to see if those static constructors must be called.
|
||||
///
|
||||
/// This method should be called before using the decoder and instruction info classes and
|
||||
/// should *not* be called from the same method as any code that uses the decoder / instruction
|
||||
/// info classes. Eg. call this method from Main() and decode instructions / get instruction info
|
||||
/// in a method called by Main().
|
||||
/// </summary>
|
||||
public static void Initialize() {
|
||||
#if (!NO_DECODER32 || !NO_DECODER64) && !NO_DECODER
|
||||
// The decoder already initializes this stuff, but when it's called, it's a little bit too late.
|
||||
RuntimeHelpers.RunClassConstructor(typeof(Decoder).TypeHandle);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ Decoder:
|
|||
- `ByteArrayCodeReader`
|
||||
- `InstructionList`
|
||||
- `ConstantOffsets`
|
||||
- `IcedFeatures.Initialize()`
|
||||
|
||||
Formatters:
|
||||
|
||||
|
@ -73,6 +74,7 @@ namespace Iced.Examples {
|
|||
const int HEXBYTES_COLUMN_BYTE_LENGTH = 10;
|
||||
|
||||
static void Main(string[] args) {
|
||||
IcedFeatures.Initialize();
|
||||
DecoderFormatterExample();
|
||||
EncoderExample();
|
||||
CreateInstructionsExample();
|
||||
|
|
Loading…
Reference in New Issue