AsmJsJITInfo.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. AsmJsJITInfo::AsmJsJITInfo(AsmJsDataIDL * data) :
  8. m_data(*data)
  9. {
  10. CompileAssert(sizeof(AsmJsJITInfo) == sizeof(AsmJsDataIDL));
  11. }
  12. WAsmJs::TypedSlotInfo
  13. AsmJsJITInfo::GetTypedSlotInfo(WAsmJs::Types type) const
  14. {
  15. WAsmJs::TypedSlotInfo info;
  16. if (type >= 0 && type < WAsmJs::LIMIT)
  17. {
  18. info.byteOffset = m_data.typedSlotInfos[type].byteOffset;
  19. info.constCount = m_data.typedSlotInfos[type].constCount;
  20. info.constSrcByteOffset = m_data.typedSlotInfos[type].constSrcByteOffset;
  21. info.tmpCount = m_data.typedSlotInfos[type].tmpCount;
  22. info.varCount = m_data.typedSlotInfos[type].varCount;
  23. }
  24. return info;
  25. }
  26. int
  27. AsmJsJITInfo::GetTotalSizeInBytes() const
  28. {
  29. return m_data.totalSizeInBytes;
  30. }
  31. Js::ArgSlot
  32. AsmJsJITInfo::GetArgCount() const
  33. {
  34. return m_data.argCount;
  35. }
  36. Js::ArgSlot
  37. AsmJsJITInfo::GetArgByteSize() const
  38. {
  39. return m_data.argByteSize;
  40. }
  41. Js::AsmJsRetType::Which
  42. AsmJsJITInfo::GetRetType() const
  43. {
  44. return static_cast<Js::AsmJsRetType::Which>(m_data.retType);
  45. }
  46. Js::AsmJsVarType::Which *
  47. AsmJsJITInfo::GetArgTypeArray() const
  48. {
  49. return reinterpret_cast<Js::AsmJsVarType::Which *>(m_data.argTypeArray);
  50. }
  51. Js::AsmJsVarType::Which
  52. AsmJsJITInfo::GetArgType(Js::ArgSlot argNum) const
  53. {
  54. AssertOrFailFast(argNum < GetArgCount());
  55. return GetArgTypeArray()[argNum];
  56. }
  57. #ifdef ENABLE_WASM
  58. Wasm::WasmSignature *
  59. AsmJsJITInfo::GetWasmSignature(uint index) const
  60. {
  61. Assert(index < m_data.wasmSignatureCount);
  62. return Wasm::WasmSignature::FromIDL(&m_data.wasmSignatures[index]);
  63. }
  64. intptr_t
  65. AsmJsJITInfo::GetWasmSignatureAddr(uint index) const
  66. {
  67. Assert(index < m_data.wasmSignatureCount);
  68. return m_data.wasmSignaturesBaseAddr + index * sizeof(Wasm::WasmSignature);
  69. }
  70. bool AsmJsJITInfo::IsSharedMemory() const
  71. {
  72. return !!m_data.wasmIsSharedMemory;
  73. }
  74. #endif
  75. bool
  76. AsmJsJITInfo::UsesHeapBuffer() const
  77. {
  78. return m_data.usesHeapBuffer != FALSE;
  79. }
  80. bool
  81. AsmJsJITInfo::AccessNeedsBoundCheck(uint offset) const
  82. {
  83. return offset >= 0x10000;
  84. }
  85. #endif