| 1 | /* | 
| 2 |  * Copyright (C) 2008 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 |  * 1. Redistributions of source code must retain the above copyright | 
| 8 |  *    notice, this list of conditions and the following disclaimer. | 
| 9 |  * 2. Redistributions in binary form must reproduce the above copyright | 
| 10 |  *    notice, this list of conditions and the following disclaimer in the | 
| 11 |  *    documentation and/or other materials provided with the distribution. | 
| 12 |  * | 
| 13 |  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 
| 14 |  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 
| 15 |  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 
| 16 |  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR | 
| 17 |  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 
| 18 |  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 
| 19 |  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 
| 20 |  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 
| 21 |  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 
| 22 |  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
| 23 |  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  | 
| 24 |  */ | 
| 25 |  | 
| 26 | #ifndef StructureStubInfo_h | 
| 27 | #define StructureStubInfo_h | 
| 28 |  | 
| 29 | #if ENABLE(JIT) | 
| 30 |  | 
| 31 | #include "Instruction.h" | 
| 32 | #include "MacroAssembler.h" | 
| 33 | #include "Opcode.h" | 
| 34 | #include "Structure.h" | 
| 35 |  | 
| 36 | namespace JSC { | 
| 37 |  | 
| 38 |     enum AccessType { | 
| 39 |         access_get_by_id_self, | 
| 40 |         access_get_by_id_proto, | 
| 41 |         access_get_by_id_chain, | 
| 42 |         access_get_by_id_self_list, | 
| 43 |         access_get_by_id_proto_list, | 
| 44 |         access_put_by_id_transition, | 
| 45 |         access_put_by_id_replace, | 
| 46 |         access_get_by_id, | 
| 47 |         access_put_by_id, | 
| 48 |         access_get_by_id_generic, | 
| 49 |         access_put_by_id_generic, | 
| 50 |         access_get_array_length, | 
| 51 |         access_get_string_length, | 
| 52 |     }; | 
| 53 |  | 
| 54 |     struct StructureStubInfo { | 
| 55 |         StructureStubInfo(AccessType accessType) | 
| 56 |             : accessType(accessType) | 
| 57 |             , seen(false) | 
| 58 |         { | 
| 59 |         } | 
| 60 |  | 
| 61 |         void initGetByIdSelf(Structure* baseObjectStructure) | 
| 62 |         { | 
| 63 |             accessType = access_get_by_id_self; | 
| 64 |  | 
| 65 |             u.getByIdSelf.baseObjectStructure = baseObjectStructure; | 
| 66 |             baseObjectStructure->ref(); | 
| 67 |         } | 
| 68 |  | 
| 69 |         void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure) | 
| 70 |         { | 
| 71 |             accessType = access_get_by_id_proto; | 
| 72 |  | 
| 73 |             u.getByIdProto.baseObjectStructure = baseObjectStructure; | 
| 74 |             baseObjectStructure->ref(); | 
| 75 |  | 
| 76 |             u.getByIdProto.prototypeStructure = prototypeStructure; | 
| 77 |             prototypeStructure->ref(); | 
| 78 |         } | 
| 79 |  | 
| 80 |         void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain) | 
| 81 |         { | 
| 82 |             accessType = access_get_by_id_chain; | 
| 83 |  | 
| 84 |             u.getByIdChain.baseObjectStructure = baseObjectStructure; | 
| 85 |             baseObjectStructure->ref(); | 
| 86 |  | 
| 87 |             u.getByIdChain.chain = chain; | 
| 88 |             chain->ref(); | 
| 89 |         } | 
| 90 |  | 
| 91 |         void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize) | 
| 92 |         { | 
| 93 |             accessType = access_get_by_id_self_list; | 
| 94 |  | 
| 95 |             u.getByIdProtoList.structureList = structureList; | 
| 96 |             u.getByIdProtoList.listSize = listSize; | 
| 97 |         } | 
| 98 |  | 
| 99 |         void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize) | 
| 100 |         { | 
| 101 |             accessType = access_get_by_id_proto_list; | 
| 102 |  | 
| 103 |             u.getByIdProtoList.structureList = structureList; | 
| 104 |             u.getByIdProtoList.listSize = listSize; | 
| 105 |         } | 
| 106 |  | 
| 107 |         // PutById* | 
| 108 |  | 
| 109 |         void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain) | 
| 110 |         { | 
| 111 |             accessType = access_put_by_id_transition; | 
| 112 |  | 
| 113 |             u.putByIdTransition.previousStructure = previousStructure; | 
| 114 |             previousStructure->ref(); | 
| 115 |  | 
| 116 |             u.putByIdTransition.structure = structure; | 
| 117 |             structure->ref(); | 
| 118 |  | 
| 119 |             u.putByIdTransition.chain = chain; | 
| 120 |             chain->ref(); | 
| 121 |         } | 
| 122 |  | 
| 123 |         void initPutByIdReplace(Structure* baseObjectStructure) | 
| 124 |         { | 
| 125 |             accessType = access_put_by_id_replace; | 
| 126 |      | 
| 127 |             u.putByIdReplace.baseObjectStructure = baseObjectStructure; | 
| 128 |             baseObjectStructure->ref(); | 
| 129 |         } | 
| 130 |  | 
| 131 |         void deref(); | 
| 132 |  | 
| 133 |         bool seenOnce() | 
| 134 |         { | 
| 135 |             return seen; | 
| 136 |         } | 
| 137 |  | 
| 138 |         void setSeen() | 
| 139 |         { | 
| 140 |             seen = true; | 
| 141 |         } | 
| 142 |  | 
| 143 |         int accessType : 31; | 
| 144 |         int seen : 1; | 
| 145 |  | 
| 146 |         union { | 
| 147 |             struct { | 
| 148 |                 Structure* baseObjectStructure; | 
| 149 |             } getByIdSelf; | 
| 150 |             struct { | 
| 151 |                 Structure* baseObjectStructure; | 
| 152 |                 Structure* prototypeStructure; | 
| 153 |             } getByIdProto; | 
| 154 |             struct { | 
| 155 |                 Structure* baseObjectStructure; | 
| 156 |                 StructureChain* chain; | 
| 157 |             } getByIdChain; | 
| 158 |             struct { | 
| 159 |                 PolymorphicAccessStructureList* structureList; | 
| 160 |                 int listSize; | 
| 161 |             } getByIdSelfList; | 
| 162 |             struct { | 
| 163 |                 PolymorphicAccessStructureList* structureList; | 
| 164 |                 int listSize; | 
| 165 |             } getByIdProtoList; | 
| 166 |             struct { | 
| 167 |                 Structure* previousStructure; | 
| 168 |                 Structure* structure; | 
| 169 |                 StructureChain* chain; | 
| 170 |             } putByIdTransition; | 
| 171 |             struct { | 
| 172 |                 Structure* baseObjectStructure; | 
| 173 |             } putByIdReplace; | 
| 174 |         } u; | 
| 175 |  | 
| 176 |         CodeLocationLabel stubRoutine; | 
| 177 |         CodeLocationCall callReturnLocation; | 
| 178 |         CodeLocationLabel hotPathBegin; | 
| 179 |     }; | 
| 180 |  | 
| 181 | } // namespace JSC | 
| 182 |  | 
| 183 | #endif | 
| 184 |  | 
| 185 | #endif // StructureStubInfo_h | 
| 186 |  |