2
0

BackendOpCodeAttrAsmJs.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #ifdef ASMJS_PLAT
  7. namespace OpCodeAttrAsmJs
  8. {
  9. enum OpCodeAttrEnum
  10. {
  11. None = 0,
  12. OpNoFallThrough = 1 << 0, // Opcode doesn't fallthrough in flow and its always jump to the return from this opcode.
  13. OpHasMultiSizeLayout = 1 << 1,
  14. OpHasProfiled = 1 << 2,
  15. OpProfiled = 1 << 3
  16. };
  17. static const int OpcodeAttributesAsmJs[] =
  18. {
  19. #define DEF_OP(name, jnLayout, attrib, ...) attrib,
  20. #include "ByteCode/OpCodeListAsmJs.h"
  21. #undef DEF_OP
  22. };
  23. static const int ExtendedOpcodeAttributesAsmJs[] =
  24. {
  25. #define DEF_OP(name, jnLayout, attrib, ...) attrib,
  26. #include "ByteCode/ExtendedOpCodeListAsmJs.h"
  27. #undef DEF_OP
  28. };
  29. static const int GetOpCodeAttributes( Js::OpCodeAsmJs op )
  30. {
  31. uint opIndex = (uint)op;
  32. if (opIndex <= (uint)Js::OpCodeAsmJs::MaxByteSizedOpcodes)
  33. {
  34. AnalysisAssert(opIndex < _countof(OpcodeAttributesAsmJs));
  35. return OpcodeAttributesAsmJs[opIndex];
  36. }
  37. opIndex -= ( Js::OpCodeAsmJs::MaxByteSizedOpcodes + 1 );
  38. AnalysisAssert(opIndex < _countof(ExtendedOpcodeAttributesAsmJs));
  39. return ExtendedOpcodeAttributesAsmJs[opIndex];
  40. }
  41. #define CheckHasFlag(flag) (!!(GetOpCodeAttributes(opcode) & flag))
  42. #define CheckNoHasFlag(flag) (!(GetOpCodeAttributes(opcode) & flag))
  43. bool HasFallThrough( Js::OpCodeAsmJs opcode )
  44. {
  45. return CheckNoHasFlag( OpNoFallThrough );
  46. }
  47. bool HasMultiSizeLayout( Js::OpCodeAsmJs opcode )
  48. {
  49. return CheckHasFlag( OpHasMultiSizeLayout );
  50. }
  51. bool HasProfiledOp(Js::OpCodeAsmJs opcode)
  52. {
  53. return ((GetOpCodeAttributes(opcode) & OpHasProfiled) != 0);
  54. }
  55. bool IsProfiledOp(Js::OpCodeAsmJs opcode)
  56. {
  57. return ((GetOpCodeAttributes(opcode) & OpProfiled) != 0);
  58. }
  59. }; // OpCodeAttrAsmJs
  60. #endif