FunctionInfo.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. FunctionInfo::FunctionInfo(JavascriptMethod entryPoint, Attributes attributes, LocalFunctionId functionId, FunctionProxy* functionBodyImpl)
  9. : originalEntryPoint(entryPoint), attributes(attributes), functionBodyImpl(functionBodyImpl), functionId(functionId), compileCount(0)
  10. {
  11. #if !DYNAMIC_INTERPRETER_THUNK
  12. Assert(entryPoint != nullptr);
  13. #endif
  14. }
  15. FunctionInfo::FunctionInfo(JavascriptMethod entryPoint, _no_write_barrier_tag, Attributes attributes, LocalFunctionId functionId, FunctionProxy* functionBodyImpl)
  16. : originalEntryPoint(entryPoint), attributes(attributes), functionBodyImpl(FORCE_NO_WRITE_BARRIER_TAG(functionBodyImpl)), functionId(functionId), compileCount(0)
  17. {
  18. #if !DYNAMIC_INTERPRETER_THUNK
  19. Assert(entryPoint != nullptr);
  20. #endif
  21. }
  22. FunctionInfo::FunctionInfo(FunctionInfo& that)
  23. : originalEntryPoint(that.originalEntryPoint), attributes(that.attributes),
  24. functionBodyImpl(FORCE_NO_WRITE_BARRIER_TAG(that.functionBodyImpl)), functionId(that.functionId), compileCount(that.compileCount)
  25. {
  26. }
  27. void FunctionInfo::VerifyOriginalEntryPoint() const
  28. {
  29. Assert(!this->HasBody() || this->IsDeferredParseFunction() || this->IsDeferredDeserializeFunction() || this->GetFunctionProxy()->HasValidEntryPoint());
  30. }
  31. JavascriptMethod
  32. FunctionInfo::GetOriginalEntryPoint() const
  33. {
  34. VerifyOriginalEntryPoint();
  35. return GetOriginalEntryPoint_Unchecked();
  36. }
  37. JavascriptMethod FunctionInfo::GetOriginalEntryPoint_Unchecked() const
  38. {
  39. return originalEntryPoint;
  40. }
  41. void FunctionInfo::SetOriginalEntryPoint(const JavascriptMethod originalEntryPoint)
  42. {
  43. Assert(originalEntryPoint);
  44. this->originalEntryPoint = originalEntryPoint;
  45. }
  46. FunctionBody *
  47. FunctionInfo::GetFunctionBody() const
  48. {
  49. return functionBodyImpl == nullptr ? nullptr : functionBodyImpl->GetFunctionBody();
  50. }
  51. FunctionInfo::Attributes FunctionInfo::GetAttributes(Js::RecyclableObject * function)
  52. {
  53. return function->GetTypeId() == Js::TypeIds_Function ?
  54. Js::UnsafeVarTo<Js::JavascriptFunction>(function)->GetFunctionInfo()->GetAttributes() : Js::FunctionInfo::None;
  55. }
  56. }