-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
Copy pathBackendOpCodeAttrAsmJs.cpp
72 lines (61 loc) · 2.21 KB
/
BackendOpCodeAttrAsmJs.cpp
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
//-------------------------------------------------------------------------------------------------------
// 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"
#ifdef ASMJS_PLAT
namespace OpCodeAttrAsmJs
{
enum OpCodeAttrEnum
{
None = 0,
OpNoFallThrough = 1 << 0, // Opcode doesn't fallthrough in flow and its always jump to the return from this opcode.
OpHasMultiSizeLayout = 1 << 1,
OpHasProfiled = 1 << 2,
OpProfiled = 1 << 3,
OpByteCodeOnly = 1 << 4
};
static const int OpcodeAttributesAsmJs[] =
{
#define DEF_OP(name, jnLayout, attrib, ...) attrib,
#include "ByteCode/OpCodeListAsmJs.h"
#undef DEF_OP
};
static const int ExtendedOpcodeAttributesAsmJs[] =
{
#define DEF_OP(name, jnLayout, attrib, ...) attrib,
#include "ByteCode/ExtendedOpCodeListAsmJs.h"
#undef DEF_OP
};
static const int GetOpCodeAttributes( Js::OpCodeAsmJs op )
{
uint opIndex = (uint)op;
if (opIndex <= (uint)Js::OpCodeAsmJs::MaxByteSizedOpcodes)
{
AnalysisAssert(opIndex < _countof(OpcodeAttributesAsmJs));
return OpcodeAttributesAsmJs[opIndex];
}
opIndex -= ( Js::OpCodeAsmJs::MaxByteSizedOpcodes + 1 );
AnalysisAssert(opIndex < _countof(ExtendedOpcodeAttributesAsmJs));
return ExtendedOpcodeAttributesAsmJs[opIndex];
}
#define CheckHasFlag(flag) (!!(GetOpCodeAttributes(opcode) & flag))
#define CheckNoHasFlag(flag) (!(GetOpCodeAttributes(opcode) & flag))
bool HasFallThrough( Js::OpCodeAsmJs opcode )
{
return CheckNoHasFlag( OpNoFallThrough );
}
bool HasMultiSizeLayout( Js::OpCodeAsmJs opcode )
{
return CheckHasFlag( OpHasMultiSizeLayout );
}
bool HasProfiledOp(Js::OpCodeAsmJs opcode)
{
return ((GetOpCodeAttributes(opcode) & OpHasProfiled) != 0);
}
bool IsProfiledOp(Js::OpCodeAsmJs opcode)
{
return ((GetOpCodeAttributes(opcode) & OpProfiled) != 0);
}
}; // OpCodeAttrAsmJs
#endif