1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 // State machine header used ONLY in the JIT.
14 extern const SMState* gp_SMStates;
15 extern const JumpTableCell* gp_SMJumpTableCells;
16 extern const short* gp_StateWeights;
18 class CodeSeqSM // Represent a particualr run of the state machine
19 // For example, it maintains the array of counts for the terminated states.
20 // These counts should be stored in per method based for them to be correct
21 // under multithreadeded environment.
26 const SMState* States;
27 const JumpTableCell* JumpTableCells;
28 const short* StateWeights; // Weight for each state. Including non-terminate states.
32 int NativeSize; // This is a signed integer!
34 void Start(Compiler* comp);
37 void Run(SM_OPCODE opcode DEBUGARG(int level));
39 SM_STATE_ID GetDestState(SM_STATE_ID srcState, SM_OPCODE opcode);
41 // Matched a termination state
42 inline void TermStateMatch(SM_STATE_ID stateID DEBUGARG(bool verbose))
44 assert(States[stateID].term);
49 printf("weight=%3d : state %3d [ %s ]\n", StateWeights[stateID], stateID, StateDesc(stateID));
51 #endif // SMGEN_COMPILE
54 NativeSize += StateWeights[stateID];
57 // Given an SM opcode retrieve the weight for this single opcode state.
58 // For example, ID for single opcode state SM_NOSHOW is 2.
59 inline short GetWeightForOpcode(SM_OPCODE opcode)
61 SM_STATE_ID stateID = ((SM_STATE_ID)opcode) + SM_STATE_ID_START + 1;
62 return StateWeights[stateID];
66 const char* StateDesc(SM_STATE_ID stateID);
69 static SM_OPCODE MapToSMOpcode(OPCODE opcode);