forked from chakra-core/ChakraCore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFixedFieldInfo.cpp
More file actions
102 lines (88 loc) · 2.48 KB
/
FixedFieldInfo.cpp
File metadata and controls
102 lines (88 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
#include "Backend.h"
CompileAssert(sizeof(FixedFieldIDL) == sizeof(FixedFieldInfo));
/* static */
void
FixedFieldInfo::PopulateFixedField(_In_opt_ Js::Type * type, _In_opt_ Js::Var var, _Out_ FixedFieldInfo * fixed)
{
FixedFieldIDL * rawFF = fixed->GetRaw();
rawFF->fieldValue = var;
rawFF->nextHasSameFixedField = false;
if (var != nullptr && Js::VarIs<Js::JavascriptFunction>(var))
{
Js::JavascriptFunction * funcObj = Js::VarTo<Js::JavascriptFunction>(var);
rawFF->valueType = ValueType::FromObject(funcObj).GetRawData();
rawFF->funcInfoAddr = (void*)funcObj->GetFunctionInfo();
rawFF->isClassCtor = funcObj->GetFunctionInfo()->IsClassConstructor();
rawFF->localFuncId = funcObj->GetFunctionInfo()->GetLocalFunctionId();
if (Js::VarIs<Js::ScriptFunction>(var))
{
rawFF->environmentAddr = (void*)Js::VarTo<Js::ScriptFunction>(funcObj)->GetEnvironment();
}
}
if (type != nullptr)
{
JITType::BuildFromJsType(type, (JITType*)&rawFF->type);
}
}
void
FixedFieldInfo::SetNextHasSameFixedField()
{
m_data.nextHasSameFixedField = TRUE;
}
bool
FixedFieldInfo::IsClassCtor() const
{
return m_data.isClassCtor != FALSE;
}
bool
FixedFieldInfo::NextHasSameFixedField() const
{
return m_data.nextHasSameFixedField != FALSE;
}
Js::LocalFunctionId
FixedFieldInfo::GetLocalFuncId() const
{
return m_data.localFuncId;
}
ValueType
FixedFieldInfo::GetValueType() const
{
CompileAssert(sizeof(ValueType) == sizeof(uint16));
return *(ValueType*)&m_data.valueType;
}
intptr_t
FixedFieldInfo::GetFieldValue() const
{
return (intptr_t)PointerValue(m_data.fieldValue);
}
intptr_t
FixedFieldInfo::GetFuncInfoAddr() const
{
return (intptr_t)PointerValue(m_data.funcInfoAddr);
}
intptr_t
FixedFieldInfo::GetEnvironmentAddr() const
{
return (intptr_t)PointerValue(m_data.environmentAddr);
}
JITType *
FixedFieldInfo::GetType() const
{
if (m_data.type.exists)
{
return (JITType*)&m_data.type;
}
else
{
return nullptr;
}
}
FixedFieldIDL *
FixedFieldInfo::GetRaw()
{
return &m_data;
}