Instruction.h 4.76 KB
Newer Older
1
/*
2
 * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved.
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
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1.  Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 * 2.  Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in the
 *     documentation and/or other materials provided with the distribution.
 * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
 *     its contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
28

29 30 31
#ifndef Instruction_h
#define Instruction_h

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

41
namespace JSC {
42

43 44 45
class ArrayAllocationProfile;
class ArrayProfile;
class ObjectAllocationProfile;
46
class VariableWatchpointSet;
47 48
struct LLIntCallLinkInfo;
struct ValueProfile;
weinig@apple.com's avatar
weinig@apple.com committed
49

50 51 52 53 54
struct Instruction {
    Instruction()
    {
        u.jsCell.clear();
    }
55
        
56 57
    Instruction(Opcode opcode)
    {
58
#if !ENABLE(COMPUTED_GOTO_OPCODES)
59 60 61
        // We have to initialize one of the pointer members to ensure that
        // the entire struct is initialized, when opcode is not a pointer.
        u.jsCell.clear();
62
#endif
63 64 65 66 67 68 69 70 71 72 73
        u.opcode = opcode;
    }

    Instruction(int operand)
    {
        // We have to initialize one of the pointer members to ensure that
        // the entire struct is initialized in 64-bit.
        u.jsCell.clear();
        u.operand = operand;
    }

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 93 94 95 96 97 98
    Instruction(LLIntCallLinkInfo* callLinkInfo) { u.callLinkInfo = callLinkInfo; }
    Instruction(ValueProfile* profile) { u.profile = profile; }
    Instruction(ArrayProfile* profile) { u.arrayProfile = profile; }
    Instruction(ArrayAllocationProfile* profile) { u.arrayAllocationProfile = profile; }
    Instruction(ObjectAllocationProfile* profile) { u.objectAllocationProfile = profile; }
    Instruction(WriteBarrier<Unknown>* registerPointer) { u.registerPointer = registerPointer; }
    Instruction(Special::Pointer pointer) { u.specialPointer = pointer; }
99
    Instruction(StringImpl* uid) { u.uid = uid; }
100 101 102 103 104 105 106 107 108 109 110 111
    Instruction(bool* predicatePointer) { u.predicatePointer = predicatePointer; }

    union {
        Opcode opcode;
        int operand;
        WriteBarrierBase<Structure> structure;
        WriteBarrierBase<StructureChain> structureChain;
        WriteBarrierBase<JSCell> jsCell;
        WriteBarrier<Unknown>* registerPointer;
        Special::Pointer specialPointer;
        PropertySlot::GetValueFunc getterFunc;
        LLIntCallLinkInfo* callLinkInfo;
112
        StringImpl* uid;
113 114 115 116
        ValueProfile* profile;
        ArrayProfile* arrayProfile;
        ArrayAllocationProfile* arrayAllocationProfile;
        ObjectAllocationProfile* objectAllocationProfile;
117
        VariableWatchpointSet* watchpointSet;
fpizlo@apple.com's avatar
fpizlo@apple.com committed
118
        WriteBarrierBase<JSActivation> activation;
119 120 121
        void* pointer;
        bool* predicatePointer;
    } u;
oliver@apple.com's avatar
oliver@apple.com committed
122
        
123 124 125 126
private:
    Instruction(StructureChain*);
    Instruction(Structure*);
};
127

128
} // namespace JSC
129

130 131
namespace WTF {

132
template<> struct VectorTraits<JSC::Instruction> : VectorTraitsBase<true, JSC::Instruction> { };
133 134 135

} // namespace WTF

136
#endif // Instruction_h