BackEndOpcodeAttrAsmJs.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "BackEnd.h"
  6. namespace OpCodeAttrAsmJs
  7. {
  8. // OpSideEffect:
  9. // Opcode has side effect not just to the dst/src on the instruction.
  10. // The opcode cannot be deadstored. (e.g. StFld, LdFld from DOM, call valueOf/toString/getter/setter)
  11. // Doesn't include all "exit" script (e.g. LdThis doesn't have side effect for HostDispatch for exiting script to getting the name space parent)
  12. // OpHasImplicitCall:
  13. // Include all possible exit scripts, call valueOf/toString/getter/setter
  14. // OpSerialized:
  15. // Op is a serialized (indirected) variant of another op code
  16. enum OpCodeAttrEnum
  17. {
  18. None = 0,
  19. OpNoFallThrough = 1 << 0, // Opcode doesn't fallthrough in flow and its always jump to the return from this opcode.
  20. OpHasMultiSizeLayout = 1 << 1,
  21. };
  22. static const int OpcodeAttributesAsmJs[] =
  23. {
  24. #define DEF_OP(name, jnLayout, attrib, ...) attrib,
  25. #include "ByteCode\OpCodeListAsmJs.h"
  26. #undef DEF_OP
  27. };
  28. static const int ExtendedOpcodeAttributesAsmJs[] =
  29. {
  30. #define DEF_OP(name, jnLayout, attrib, ...) attrib,
  31. #include "ByteCode\ExtendedOpCodeListAsmJs.h"
  32. #undef DEF_OP
  33. };
  34. static const int GetOpCodeAttributes( Js::OpCodeAsmJs op )
  35. {
  36. uint opIndex = (uint)op;
  37. if (opIndex <= (uint)Js::OpCodeAsmJs::MaxByteSizedOpcodes)
  38. {
  39. AnalysisAssert(opIndex < _countof(OpcodeAttributesAsmJs));
  40. return OpcodeAttributesAsmJs[opIndex];
  41. }
  42. opIndex -= ( Js::OpCodeAsmJs::MaxByteSizedOpcodes + 1 );
  43. AnalysisAssert(opIndex < _countof(ExtendedOpcodeAttributesAsmJs));
  44. return ExtendedOpcodeAttributesAsmJs[opIndex];
  45. }
  46. #define CheckHasFlag(flag) (!!(GetOpCodeAttributes(opcode) & flag))
  47. #define CheckNoHasFlag(flag) (!(GetOpCodeAttributes(opcode) & flag))
  48. bool HasFallThrough( Js::OpCodeAsmJs opcode )
  49. {
  50. return CheckNoHasFlag( OpNoFallThrough );
  51. }
  52. bool HasMultiSizeLayout( Js::OpCodeAsmJs opcode )
  53. {
  54. return CheckHasFlag( OpHasMultiSizeLayout );
  55. }
  56. }; // OpCodeAttrAsmJs