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 |
|
---|
37 | namespace JSC {
|
---|
38 |
|
---|
39 | static const int access_get_by_id_self = 0;
|
---|
40 | static const int access_get_by_id_proto = 1;
|
---|
41 | static const int access_get_by_id_chain = 2;
|
---|
42 | static const int access_get_by_id_self_list = 3;
|
---|
43 | static const int access_get_by_id_proto_list = 4;
|
---|
44 | static const int access_put_by_id_transition = 5;
|
---|
45 | static const int access_put_by_id_replace = 6;
|
---|
46 | static const int access_get_by_id = 7;
|
---|
47 | static const int access_put_by_id = 8;
|
---|
48 | static const int access_get_by_id_generic = 9;
|
---|
49 | static const int access_put_by_id_generic = 10;
|
---|
50 | static const int access_get_array_length = 11;
|
---|
51 | static const int access_get_string_length = 12;
|
---|
52 |
|
---|
53 | struct StructureStubInfo {
|
---|
54 | StructureStubInfo(int accessType)
|
---|
55 | : accessType(accessType)
|
---|
56 | , seen(false)
|
---|
57 | {
|
---|
58 | }
|
---|
59 |
|
---|
60 | void initGetByIdSelf(Structure* baseObjectStructure)
|
---|
61 | {
|
---|
62 | accessType = access_get_by_id_self;
|
---|
63 |
|
---|
64 | u.getByIdSelf.baseObjectStructure = baseObjectStructure;
|
---|
65 | baseObjectStructure->ref();
|
---|
66 | }
|
---|
67 |
|
---|
68 | void initGetByIdProto(Structure* baseObjectStructure, Structure* prototypeStructure)
|
---|
69 | {
|
---|
70 | accessType = access_get_by_id_proto;
|
---|
71 |
|
---|
72 | u.getByIdProto.baseObjectStructure = baseObjectStructure;
|
---|
73 | baseObjectStructure->ref();
|
---|
74 |
|
---|
75 | u.getByIdProto.prototypeStructure = prototypeStructure;
|
---|
76 | prototypeStructure->ref();
|
---|
77 | }
|
---|
78 |
|
---|
79 | void initGetByIdChain(Structure* baseObjectStructure, StructureChain* chain)
|
---|
80 | {
|
---|
81 | accessType = access_get_by_id_chain;
|
---|
82 |
|
---|
83 | u.getByIdChain.baseObjectStructure = baseObjectStructure;
|
---|
84 | baseObjectStructure->ref();
|
---|
85 |
|
---|
86 | u.getByIdChain.chain = chain;
|
---|
87 | chain->ref();
|
---|
88 | }
|
---|
89 |
|
---|
90 | void initGetByIdSelfList(PolymorphicAccessStructureList* structureList, int listSize)
|
---|
91 | {
|
---|
92 | accessType = access_get_by_id_self_list;
|
---|
93 |
|
---|
94 | u.getByIdProtoList.structureList = structureList;
|
---|
95 | u.getByIdProtoList.listSize = listSize;
|
---|
96 | }
|
---|
97 |
|
---|
98 | void initGetByIdProtoList(PolymorphicAccessStructureList* structureList, int listSize)
|
---|
99 | {
|
---|
100 | accessType = access_get_by_id_proto_list;
|
---|
101 |
|
---|
102 | u.getByIdProtoList.structureList = structureList;
|
---|
103 | u.getByIdProtoList.listSize = listSize;
|
---|
104 | }
|
---|
105 |
|
---|
106 | // PutById*
|
---|
107 |
|
---|
108 | void initPutByIdTransition(Structure* previousStructure, Structure* structure, StructureChain* chain)
|
---|
109 | {
|
---|
110 | accessType = access_put_by_id_transition;
|
---|
111 |
|
---|
112 | u.putByIdTransition.previousStructure = previousStructure;
|
---|
113 | previousStructure->ref();
|
---|
114 |
|
---|
115 | u.putByIdTransition.structure = structure;
|
---|
116 | structure->ref();
|
---|
117 |
|
---|
118 | u.putByIdTransition.chain = chain;
|
---|
119 | chain->ref();
|
---|
120 | }
|
---|
121 |
|
---|
122 | void initPutByIdReplace(Structure* baseObjectStructure)
|
---|
123 | {
|
---|
124 | accessType = access_put_by_id_replace;
|
---|
125 |
|
---|
126 | u.putByIdReplace.baseObjectStructure = baseObjectStructure;
|
---|
127 | baseObjectStructure->ref();
|
---|
128 | }
|
---|
129 |
|
---|
130 | void deref();
|
---|
131 |
|
---|
132 | bool seenOnce()
|
---|
133 | {
|
---|
134 | return seen;
|
---|
135 | }
|
---|
136 |
|
---|
137 | void setSeen()
|
---|
138 | {
|
---|
139 | seen = true;
|
---|
140 | }
|
---|
141 |
|
---|
142 | int accessType : 31;
|
---|
143 | int seen : 1;
|
---|
144 |
|
---|
145 | union {
|
---|
146 | struct {
|
---|
147 | Structure* baseObjectStructure;
|
---|
148 | } getByIdSelf;
|
---|
149 | struct {
|
---|
150 | Structure* baseObjectStructure;
|
---|
151 | Structure* prototypeStructure;
|
---|
152 | } getByIdProto;
|
---|
153 | struct {
|
---|
154 | Structure* baseObjectStructure;
|
---|
155 | StructureChain* chain;
|
---|
156 | } getByIdChain;
|
---|
157 | struct {
|
---|
158 | PolymorphicAccessStructureList* structureList;
|
---|
159 | int listSize;
|
---|
160 | } getByIdSelfList;
|
---|
161 | struct {
|
---|
162 | PolymorphicAccessStructureList* structureList;
|
---|
163 | int listSize;
|
---|
164 | } getByIdProtoList;
|
---|
165 | struct {
|
---|
166 | Structure* previousStructure;
|
---|
167 | Structure* structure;
|
---|
168 | StructureChain* chain;
|
---|
169 | } putByIdTransition;
|
---|
170 | struct {
|
---|
171 | Structure* baseObjectStructure;
|
---|
172 | } putByIdReplace;
|
---|
173 | } u;
|
---|
174 |
|
---|
175 | CodeLocationLabel stubRoutine;
|
---|
176 | CodeLocationCall callReturnLocation;
|
---|
177 | CodeLocationLabel hotPathBegin;
|
---|
178 | };
|
---|
179 |
|
---|
180 | } // namespace JSC
|
---|
181 |
|
---|
182 | #endif
|
---|
183 |
|
---|
184 | #endif // StructureStubInfo_h
|
---|