]> git.saurik.com Git - apple/javascriptcore.git/blob - bytecode/Instruction.h
JavaScriptCore-7601.1.46.3.tar.gz
[apple/javascriptcore.git] / bytecode / Instruction.h
1 /*
2 * Copyright (C) 2008, 2012-2015 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef Instruction_h
30 #define Instruction_h
31
32 #include "BasicBlockLocation.h"
33 #include "MacroAssembler.h"
34 #include "Opcode.h"
35 #include "SymbolTable.h"
36 #include "TypeLocation.h"
37 #include "PropertySlot.h"
38 #include "SpecialPointer.h"
39 #include "Structure.h"
40 #include "StructureChain.h"
41 #include "ToThisStatus.h"
42 #include "VirtualRegister.h"
43 #include <wtf/VectorTraits.h>
44
45 namespace JSC {
46
47 class ArrayAllocationProfile;
48 class ArrayProfile;
49 class ObjectAllocationProfile;
50 class WatchpointSet;
51 struct LLIntCallLinkInfo;
52 struct ValueProfile;
53
54 struct Instruction {
55 Instruction()
56 {
57 u.jsCell.clear();
58 }
59
60 Instruction(Opcode opcode)
61 {
62 #if !ENABLE(COMPUTED_GOTO_OPCODES)
63 // We have to initialize one of the pointer members to ensure that
64 // the entire struct is initialized, when opcode is not a pointer.
65 u.jsCell.clear();
66 #endif
67 u.opcode = opcode;
68 }
69
70 Instruction(int operand)
71 {
72 // We have to initialize one of the pointer members to ensure that
73 // the entire struct is initialized in 64-bit.
74 u.jsCell.clear();
75 u.operand = operand;
76 }
77
78 Instruction(VM& vm, JSCell* owner, Structure* structure)
79 {
80 u.structure.clear();
81 u.structure.set(vm, owner, structure);
82 }
83 Instruction(VM& vm, JSCell* owner, StructureChain* structureChain)
84 {
85 u.structureChain.clear();
86 u.structureChain.set(vm, owner, structureChain);
87 }
88 Instruction(VM& vm, JSCell* owner, JSCell* jsCell)
89 {
90 u.jsCell.clear();
91 u.jsCell.set(vm, owner, jsCell);
92 }
93
94 Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; }
95
96 Instruction(LLIntCallLinkInfo* callLinkInfo) { u.callLinkInfo = callLinkInfo; }
97 Instruction(ValueProfile* profile) { u.profile = profile; }
98 Instruction(ArrayProfile* profile) { u.arrayProfile = profile; }
99 Instruction(ArrayAllocationProfile* profile) { u.arrayAllocationProfile = profile; }
100 Instruction(ObjectAllocationProfile* profile) { u.objectAllocationProfile = profile; }
101 Instruction(WriteBarrier<Unknown>* variablePointer) { u.variablePointer = variablePointer; }
102 Instruction(Special::Pointer pointer) { u.specialPointer = pointer; }
103 Instruction(UniquedStringImpl* uid) { u.uid = uid; }
104 Instruction(bool* predicatePointer) { u.predicatePointer = predicatePointer; }
105
106 union {
107 Opcode opcode;
108 int operand;
109 WriteBarrierBase<Structure> structure;
110 WriteBarrierBase<SymbolTable> symbolTable;
111 WriteBarrierBase<StructureChain> structureChain;
112 WriteBarrierBase<JSCell> jsCell;
113 WriteBarrier<Unknown>* variablePointer;
114 Special::Pointer specialPointer;
115 PropertySlot::GetValueFunc getterFunc;
116 LLIntCallLinkInfo* callLinkInfo;
117 UniquedStringImpl* uid;
118 ValueProfile* profile;
119 ArrayProfile* arrayProfile;
120 ArrayAllocationProfile* arrayAllocationProfile;
121 ObjectAllocationProfile* objectAllocationProfile;
122 WatchpointSet* watchpointSet;
123 void* pointer;
124 bool* predicatePointer;
125 ToThisStatus toThisStatus;
126 TypeLocation* location;
127 BasicBlockLocation* basicBlockLocation;
128 } u;
129
130 private:
131 Instruction(StructureChain*);
132 Instruction(Structure*);
133 };
134
135 } // namespace JSC
136
137 namespace WTF {
138
139 template<> struct VectorTraits<JSC::Instruction> : VectorTraitsBase<true, JSC::Instruction> { };
140
141 } // namespace WTF
142
143 #endif // Instruction_h