|
| 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 | + |
| 6 | +#include "Backend.h" |
| 7 | + |
| 8 | +CompileAssert(sizeof(FixedFieldIDL) == sizeof(FixedFieldInfo)); |
| 9 | + |
| 10 | +/* static */ |
| 11 | +void |
| 12 | +FixedFieldInfo::PopulateFixedField(_In_opt_ Js::Type * type, _In_opt_ Js::Var var, _Out_ FixedFieldInfo * fixed) |
| 13 | +{ |
| 14 | + FixedFieldIDL * rawFF = fixed->GetRaw(); |
| 15 | + rawFF->fieldValue = (intptr_t)var; |
| 16 | + rawFF->nextHasSameFixedField = false; |
| 17 | + if (var != nullptr && Js::JavascriptFunction::Is(var)) |
| 18 | + { |
| 19 | + Js::JavascriptFunction * funcObj = Js::JavascriptFunction::FromVar(var); |
| 20 | + rawFF->valueType = ValueType::FromObject(funcObj).GetRawData(); |
| 21 | + rawFF->funcInfoAddr = (intptr_t)funcObj->GetFunctionInfo(); |
| 22 | + rawFF->isClassCtor = funcObj->GetFunctionInfo()->IsClassConstructor(); |
| 23 | + rawFF->localFuncId = (intptr_t)funcObj->GetFunctionInfo()->GetLocalFunctionId(); |
| 24 | + if (Js::ScriptFunction::Is(var)) |
| 25 | + { |
| 26 | + rawFF->environmentAddr = (intptr_t)Js::ScriptFunction::FromVar(funcObj)->GetEnvironment(); |
| 27 | + } |
| 28 | + } |
| 29 | + if (type != nullptr) |
| 30 | + { |
| 31 | + JITType::BuildFromJsType(type, (JITType*)&rawFF->type); |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +void |
| 36 | +FixedFieldInfo::SetNextHasSameFixedField() |
| 37 | +{ |
| 38 | + m_data.nextHasSameFixedField = TRUE; |
| 39 | +} |
| 40 | + |
| 41 | +bool |
| 42 | +FixedFieldInfo::IsClassCtor() const |
| 43 | +{ |
| 44 | + return m_data.isClassCtor != FALSE; |
| 45 | +} |
| 46 | + |
| 47 | +bool |
| 48 | +FixedFieldInfo::NextHasSameFixedField() const |
| 49 | +{ |
| 50 | + return m_data.nextHasSameFixedField != FALSE; |
| 51 | +} |
| 52 | + |
| 53 | +uint |
| 54 | +FixedFieldInfo::GetLocalFuncId() const |
| 55 | +{ |
| 56 | + return m_data.localFuncId; |
| 57 | +} |
| 58 | + |
| 59 | +ValueType |
| 60 | +FixedFieldInfo::GetValueType() const |
| 61 | +{ |
| 62 | + CompileAssert(sizeof(ValueType) == sizeof(uint16)); |
| 63 | + return *(ValueType*)&m_data.valueType; |
| 64 | +} |
| 65 | + |
| 66 | +intptr_t |
| 67 | +FixedFieldInfo::GetFieldValue() const |
| 68 | +{ |
| 69 | + return m_data.fieldValue; |
| 70 | +} |
| 71 | + |
| 72 | +intptr_t |
| 73 | +FixedFieldInfo::GetFuncInfoAddr() const |
| 74 | +{ |
| 75 | + return m_data.funcInfoAddr; |
| 76 | +} |
| 77 | + |
| 78 | +intptr_t |
| 79 | +FixedFieldInfo::GetEnvironmentAddr() const |
| 80 | +{ |
| 81 | + return m_data.environmentAddr; |
| 82 | +} |
| 83 | + |
| 84 | +JITType * |
| 85 | +FixedFieldInfo::GetType() const |
| 86 | +{ |
| 87 | + return (JITType*)&m_data.type; |
| 88 | +} |
| 89 | + |
| 90 | +FixedFieldIDL * |
| 91 | +FixedFieldInfo::GetRaw() |
| 92 | +{ |
| 93 | + return &m_data; |
| 94 | +} |
| 95 | + |
0 commit comments