VerifyMarkFalseReference.cpp 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 "RuntimeLibraryPch.h"
  6. #if DBG && defined(RECYCLER_VERIFY_MARK)
  7. #include "ByteCode/ScopeInfo.h"
  8. bool IsLikelyRuntimeFalseReference(char* objectStartAddress, size_t offset,
  9. const char* typeName)
  10. {
  11. // Js::DynamicProfileInfo allocate with non-Leaf in test/chk build
  12. // TODO: (leish)(swb) find a way to set barrier for the Js::DynamicProfileInfo plus allocation
  13. if (strstr(typeName, "Js::DynamicProfileInfo"))
  14. {
  15. return true;
  16. }
  17. // the fields on Js::DateImplementation can easily form a false positive
  18. // TODO: (leish)(swb) find a way to tag these
  19. if (VirtualTableInfo<Js::JavascriptDate>::HasVirtualTable(objectStartAddress) ||
  20. VirtualTableInfo<Js::CrossSiteObject<Js::JavascriptDate>>::HasVirtualTable(objectStartAddress))
  21. {
  22. return offset >= offsetof(Js::JavascriptDate, m_date);
  23. }
  24. // symbol array at the end of scopeInfo, can point to arena allocated propertyRecord
  25. if (offset >= offsetof(Js::ScopeInfo, symbols) && strstr(typeName, "Js::ScopeInfo"))
  26. {
  27. return true;
  28. }
  29. // Js::Type::entryPoint may contain outdated data uncleared, and reused by recycler
  30. // Most often occurs with script function Type
  31. if (offset == Js::Type::GetOffsetOfEntryPoint() && strstr(typeName, "Js::ScriptFunctionType"))
  32. {
  33. return true;
  34. }
  35. if (strstr(typeName, "Js::SparseArraySegment"))
  36. {
  37. // Js::SparseArraySegmentBase left, length and size can easily form a false positive
  38. // TODO: (leish)(swb) find a way to tag these fields
  39. if (offset < Js::SparseArraySegmentBase::GetOffsetOfNext()) // left, length, size
  40. {
  41. return true;
  42. }
  43. // Native array elements may form false positives
  44. if (offset > Js::SparseArraySegmentBase::GetOffsetOfNext() && // elements
  45. (strstr(typeName, "<double>") || strstr(typeName, "<int>")))
  46. {
  47. return true;
  48. }
  49. }
  50. // On x86 some int32/uint32 fields may look like GC pointers
  51. #if TARGET_32
  52. if (strstr(typeName, "Js::TypedArray<") && offset == Js::Int8Array::GetOffsetOfLength())
  53. {
  54. return true;
  55. }
  56. if (strstr(typeName, "Js::ScriptContextPolymorphicInlineCache")
  57. && offset == offsetof(Js::ScriptContextPolymorphicInlineCache, inlineCachesFillInfo))
  58. {
  59. return true;
  60. }
  61. #endif
  62. return false;
  63. }
  64. #endif // DBG && defined(RECYCLER_VERIFY_MARK)