1/* 2 * Copyright (C) 2008, 2012, 2013 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 "MacroAssembler.h" 33#include "Opcode.h" 34#include "PropertySlot.h" 35#include "SpecialPointer.h" 36#include "Structure.h" 37#include "StructureChain.h" 38#include "VirtualRegister.h" 39#include <wtf/VectorTraits.h> 40 41namespace JSC { 42 43class ArrayAllocationProfile; 44class ArrayProfile; 45class ObjectAllocationProfile; 46class VariableWatchpointSet; 47struct LLIntCallLinkInfo; 48struct ValueProfile; 49 50struct Instruction { 51 Instruction() 52 { 53 u.jsCell.clear(); 54 } 55 56 Instruction(Opcode opcode) 57 { 58#if !ENABLE(COMPUTED_GOTO_OPCODES) 59 // We have to initialize one of the pointer members to ensure that 60 // the entire struct is initialized, when opcode is not a pointer. 61 u.jsCell.clear(); 62#endif 63 u.opcode = opcode; 64 } 65 66 Instruction(int operand) 67 { 68 // We have to initialize one of the pointer members to ensure that 69 // the entire struct is initialized in 64-bit. 70 u.jsCell.clear(); 71 u.operand = operand; 72 } 73 74 Instruction(VM& vm, JSCell* owner, Structure* structure) 75 { 76 u.structure.clear(); 77 u.structure.set(vm, owner, structure); 78 } 79 Instruction(VM& vm, JSCell* owner, StructureChain* structureChain) 80 { 81 u.structureChain.clear(); 82 u.structureChain.set(vm, owner, structureChain); 83 } 84 Instruction(VM& vm, JSCell* owner, JSCell* jsCell) 85 { 86 u.jsCell.clear(); 87 u.jsCell.set(vm, owner, jsCell); 88 } 89 90 Instruction(PropertySlot::GetValueFunc getterFunc) { u.getterFunc = getterFunc; } 91 92 Instruction(LLIntCallLinkInfo* callLinkInfo) { u.callLinkInfo = callLinkInfo; } 93 Instruction(ValueProfile* profile) { u.profile = profile; } 94 Instruction(ArrayProfile* profile) { u.arrayProfile = profile; } 95 Instruction(ArrayAllocationProfile* profile) { u.arrayAllocationProfile = profile; } 96 Instruction(ObjectAllocationProfile* profile) { u.objectAllocationProfile = profile; } 97 Instruction(WriteBarrier<Unknown>* registerPointer) { u.registerPointer = registerPointer; } 98 Instruction(Special::Pointer pointer) { u.specialPointer = pointer; } 99 Instruction(StringImpl* uid) { u.uid = uid; } 100 Instruction(bool* predicatePointer) { u.predicatePointer = predicatePointer; } 101 102 union { 103 Opcode opcode; 104 int operand; 105 WriteBarrierBase<Structure> structure; 106 WriteBarrierBase<StructureChain> structureChain; 107 WriteBarrierBase<JSCell> jsCell; 108 WriteBarrier<Unknown>* registerPointer; 109 Special::Pointer specialPointer; 110 PropertySlot::GetValueFunc getterFunc; 111 LLIntCallLinkInfo* callLinkInfo; 112 StringImpl* uid; 113 ValueProfile* profile; 114 ArrayProfile* arrayProfile; 115 ArrayAllocationProfile* arrayAllocationProfile; 116 ObjectAllocationProfile* objectAllocationProfile; 117 VariableWatchpointSet* watchpointSet; 118 WriteBarrierBase<JSActivation> activation; 119 void* pointer; 120 bool* predicatePointer; 121 } u; 122 123private: 124 Instruction(StructureChain*); 125 Instruction(Structure*); 126}; 127 128} // namespace JSC 129 130namespace WTF { 131 132template<> struct VectorTraits<JSC::Instruction> : VectorTraitsBase<true, JSC::Instruction> { }; 133 134} // namespace WTF 135 136#endif // Instruction_h 137