PropertyString.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. namespace Js
  7. {
  8. DEFINE_RECYCLER_TRACKER_PERF_COUNTER(PropertyString);
  9. DEFINE_RECYCLER_TRACKER_WEAKREF_PERF_COUNTER(PropertyString);
  10. PropertyString::PropertyString(StaticType* type, const Js::PropertyRecord* propertyRecord) :
  11. JavascriptString(type, propertyRecord->GetLength(), propertyRecord->GetBuffer()),
  12. propertyRecordUsageCache(type, propertyRecord)
  13. {
  14. }
  15. PropertyString* PropertyString::New(StaticType* type, const Js::PropertyRecord* propertyRecord, Recycler *recycler)
  16. {
  17. return RecyclerNewZ(recycler, PropertyString, type, propertyRecord);
  18. }
  19. PolymorphicInlineCache * PropertyString::GetLdElemInlineCache() const
  20. {
  21. return this->propertyRecordUsageCache.GetLdElemInlineCache();
  22. }
  23. PolymorphicInlineCache * PropertyString::GetStElemInlineCache() const
  24. {
  25. return this->propertyRecordUsageCache.GetStElemInlineCache();
  26. }
  27. PropertyRecordUsageCache * PropertyString::GetPropertyRecordUsageCache()
  28. {
  29. return &this->propertyRecordUsageCache;
  30. }
  31. template <> bool VarIsImpl<PropertyString>(RecyclableObject * obj)
  32. {
  33. return VirtualTableInfo<Js::PropertyString>::HasVirtualTable(obj);
  34. }
  35. const void * PropertyString::GetOriginalStringReference()
  36. {
  37. // Property record is the allocation containing the string buffer
  38. return this->propertyRecordUsageCache.GetPropertyRecord();
  39. }
  40. bool PropertyString::TrySetPropertyFromCache(
  41. _In_ RecyclableObject *const object,
  42. _In_ Var propertyValue,
  43. _In_ ScriptContext *const requestContext,
  44. const PropertyOperationFlags propertyOperationFlags,
  45. _Inout_ PropertyValueInfo *const propertyValueInfo)
  46. {
  47. return this->propertyRecordUsageCache.TrySetPropertyFromCache<false /* ReturnOperationInfo */>(object, propertyValue, requestContext, propertyOperationFlags, propertyValueInfo, this, nullptr);
  48. }
  49. RecyclableObject * PropertyString::CloneToScriptContext(ScriptContext* requestContext)
  50. {
  51. return requestContext->GetPropertyString(this->propertyRecordUsageCache.GetPropertyRecord());
  52. }
  53. }