CallInfo.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 "RuntimeBasePch.h"
  6. namespace Js
  7. {
  8. const ushort CallInfo::ksizeofCount = 24;
  9. const ushort CallInfo::ksizeofCallFlags = 8;
  10. const uint CallInfo::kMaxCountArgs = (1 << ksizeofCount) - 1 ;
  11. // For Eval calls the FrameDisplay is passed in as an extra argument.
  12. // This is not counted in Info.Count. Use this API to get the updated count.
  13. ArgSlot CallInfo::GetArgCountWithExtraArgs(CallFlags flags, uint count)
  14. {
  15. AssertOrFailFastMsg(count < Constants::UShortMaxValue - 1, "ArgList too large");
  16. ArgSlot argSlotCount = (ArgSlot)count;
  17. if (flags & CallFlags_ExtraArg)
  18. {
  19. argSlotCount++;
  20. }
  21. return argSlotCount;
  22. }
  23. uint CallInfo::GetLargeArgCountWithExtraArgs(CallFlags flags, uint count)
  24. {
  25. if (flags & CallFlags_ExtraArg)
  26. {
  27. UInt32Math::Inc(count);
  28. }
  29. return count;
  30. }
  31. ArgSlot CallInfo::GetArgCountWithoutExtraArgs(CallFlags flags, ArgSlot count)
  32. {
  33. ArgSlot newCount = count;
  34. if (flags & Js::CallFlags_ExtraArg)
  35. {
  36. if (count == 0)
  37. {
  38. ::Math::DefaultOverflowPolicy();
  39. }
  40. newCount = count - 1;
  41. }
  42. return newCount;
  43. }
  44. }