Debian Codegraph @

src/3rdparty/javascriptcore/JavaScriptCore/runtime/Arguments.h

raw symbols SCIP
1 /*
2 * Copyright (C) 1999-2000 Harri Porten ([email protected])
3 * Copyright (C) 2003, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Cameron Zwarich ([email protected])
5 * Copyright (C) 2007 Maks Orlovich
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 *
22 */
23
24 #ifndef Arguments_h
25 #define Arguments_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/Arguments.h:25:9`!
26
27 #include "JSActivation.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSActivation.h`/
28 #include "JSFunction.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSFunction.h`/
29 #include "JSGlobalObject.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/JSGlobalObject.h`/
30 #include "Interpreter.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/interpreter/Interpreter.h`/
31 #include "ObjectConstructor.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/ObjectConstructor.h`/
32 #include "PrototypeFunction.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/PrototypeFunction.h`/
33
34 namespace JSCcxx . . $ QTJSC/ {
35
36 struct ArgumentsDatacxx . . $ QTJSC/ArgumentsData# : Noncopyablecxx . . $ Noncopyable# {
37 JSActivationcxx . . $ QTJSC/JSActivation#* activationcxx . . $ QTJSC/ArgumentsData#activation.;
38
39 unsigned numParameterscxx . . $ QTJSC/ArgumentsData#numParameters.;
40 ptrdiff_t firstParameterIndexcxx . . $ QTJSC/ArgumentsData#firstParameterIndex.;
41 unsigned numArgumentscxx . . $ QTJSC/ArgumentsData#numArguments.;
42
43 Registercxx . . $ QTJSC/Register#* registerscxx . . $ QTJSC/ArgumentsData#registers.;
44 OwnArrayPtrcxx . . $ OwnArrayPtr#<Registercxx . . $ QTJSC/Register#> registerArraycxx . . $ QTJSC/ArgumentsData#registerArray.;
45
46 Registercxx . . $ QTJSC/Register#* extraArgumentscxx . . $ QTJSC/ArgumentsData#extraArguments.;
47 OwnArrayPtrcxx . . $ OwnArrayPtr#<bool> deletedArgumentscxx . . $ QTJSC/ArgumentsData#deletedArguments.;
48 Registercxx . . $ QTJSC/Register# extraArgumentsFixedBuffercxx . . $ QTJSC/ArgumentsData#extraArgumentsFixedBuffer.[4];
49
50 JSObjectcxx . . $ QTJSC/JSObject#* calleecxx . . $ QTJSC/ArgumentsData#callee.;
51 bool overrodeLengthcxx . . $ QTJSC/ArgumentsData#overrodeLength. : 1;
52 bool overrodeCalleecxx . . $ QTJSC/ArgumentsData#overrodeCallee. : 1;
53 };
54
55
56 class Argumentscxx . . $ QTJSC/Arguments# : public JSObjectcxx . . $ QTJSC/JSObject# {
57 public:
58 enum NoParametersTypecxx . . $ QTJSC/Arguments#NoParametersType# { NoParameterscxx . . $ QTJSC/Arguments#NoParameters. };
59
60 Argumentscxx . . $ QTJSC/Arguments#Arguments(d2cb180e190a9680).(CallFramecxx . . $ QTJSC/CallFrame#*);
61 Argumentscxx . . $ QTJSC/Arguments#Arguments(609af0602dfd3f4e).(CallFramecxx . . $ QTJSC/CallFrame#*, NoParametersTypecxx . . $ QTJSC/Arguments#NoParametersType#);
62 virtual ~cxx . . $ QTJSC/Arguments#`~Arguments`(49f6e7a06ebc5aa8).Argumentscxx . . $ QTJSC/Arguments#();
63
64 static const ClassInfocxx . . $ QTJSC/ClassInfo# infocxx . . $ QTJSC/Arguments#info.;
65
66 virtual void markChildrencxx . . $ QTJSC/Arguments#markChildren(bd9cae851d80a865).(MarkStackcxx . . $ QTJSC/MarkStack#&);
67
68 void fillArgListcxx . . $ QTJSC/Arguments#fillArgList(eebde0cafc55d4c7).(ExecStatecxx . . $ QTJSC/ExecState#*, MarkedArgumentBuffercxx . . $ QTJSC/MarkedArgumentBuffer#&);
69
70 uint32_tcxx . . $ uint32_t# numProvidedArgumentscxx . . $ QTJSC/Arguments#numProvidedArguments(fedcfd78cee4cc89).(ExecStatecxx . . $ QTJSC/ExecState#* exec) const
71 {
72 if (UNLIKELYcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:45:9`!(d->overrodeLength))
73 return getcxx . . $ QTJSC/JSObject#get(2d9c2221088d2593).(exec, exec->propertyNamescxx . . $ QTJSC/ExecState#propertyNames(16296db726e31f87).().length).toUInt32(exec);
74 return d->numArguments;
75 }
76
77 void copyToRegisterscxx . . $ QTJSC/Arguments#copyToRegisters(d632f462723cc6fe).(ExecStatecxx . . $ QTJSC/ExecState#* exec, Registercxx . . $ QTJSC/Register#* buffer, uint32_tcxx . . $ uint32_t# maxSize);
78 void copyRegisterscxx . . $ QTJSC/Arguments#copyRegisters(49f6e7a06ebc5aa8).();
79 bool isTornOffcxx . . $ QTJSC/Arguments#isTornOff(50ce9a9e25b4a850).() const { return d->registerArray; }
80 void setActivationcxx . . $ QTJSC/Arguments#setActivation(9f5abfcb43cd6e2).(JSActivationcxx . . $ QTJSC/JSActivation#* activation)
81 {
82 d->activation = activation;
83 d->registers = &activation->registerAt(0);
84 }
85
86 static PassRefPtrcxx . . $ PassRefPtr#<Structurecxx . . $ QTJSC/Structure#> createStructurecxx . . $ QTJSC/Arguments#createStructure(da75fbe5e97e240f).(JSValuecxx . . $ QTJSC/JSValue# prototype)
87 {
88 return Structure::create(prototype, TypeInfocxx . . $ QTJSC/TypeInfo#(ObjectTypecxx . . $ QTJSC/ObjectType., StructureFlagscxx . . $ QTJSC/Arguments#StructureFlags.));
89 }
90
91 protected:
92 static const unsigned StructureFlagscxx . . $ QTJSC/Arguments#StructureFlags. = OverridesGetOwnPropertySlotcxx . . $ QTJSC/OverridesGetOwnPropertySlot. | OverridesMarkChildrencxx . . $ QTJSC/OverridesMarkChildren. | OverridesGetPropertyNamescxx . . $ QTJSC/OverridesGetPropertyNames. | JSObjectcxx . . $ QTJSC/JSObject#::StructureFlagscxx . . $ QTJSC/JSObject#StructureFlags.;
93
94 private:
95 void getArgumentsDatacxx . . $ QTJSC/Arguments#getArgumentsData(2b466da6de96feb6).(CallFramecxx . . $ QTJSC/CallFrame#*, JSObjectcxx . . $ QTJSC/JSObject#*&, ptrdiff_t& firstParameterIndex, Registercxx . . $ QTJSC/Register#*& argv, int& argc);
96 virtual bool getOwnPropertySlotcxx . . $ QTJSC/Arguments#getOwnPropertySlot(6f4ef3dbfe7d5ab9).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, PropertySlotcxx . . $ QTJSC/PropertySlot#&);
97 virtual bool getOwnPropertySlotcxx . . $ QTJSC/Arguments#getOwnPropertySlot(d57d1c8d4b24d235).(ExecStatecxx . . $ QTJSC/ExecState#*, unsigned propertyName, PropertySlotcxx . . $ QTJSC/PropertySlot#&);
98 virtual bool getOwnPropertyDescriptorcxx . . $ QTJSC/Arguments#getOwnPropertyDescriptor(dce4ef7012294c32).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#&, PropertyDescriptorcxx . . $ QTJSC/PropertyDescriptor#&);
99 virtual void getOwnPropertyNamescxx . . $ QTJSC/Arguments#getOwnPropertyNames(2f9e3f18de200b4e).(ExecStatecxx . . $ QTJSC/ExecState#*, PropertyNameArraycxx . . $ QTJSC/PropertyNameArray#&, EnumerationModecxx . . $ QTJSC/EnumerationMode# mode = ExcludeDontEnumPropertiescxx . . $ QTJSC/ExcludeDontEnumProperties.);
100 virtual void putcxx . . $ QTJSC/Arguments#put(dfb3133dafbe9ff4).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#& propertyName, JSValuecxx . . $ QTJSC/JSValue#, PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#&);
101 virtual void putcxx . . $ QTJSC/Arguments#put(5d385f3b1a779840).(ExecStatecxx . . $ QTJSC/ExecState#*, unsigned propertyName, JSValuecxx . . $ QTJSC/JSValue#, PutPropertySlotcxx . . $ QTJSC/PutPropertySlot#&);
102 virtual bool deletePropertycxx . . $ QTJSC/Arguments#deleteProperty(13154ef9bddc9416).(ExecStatecxx . . $ QTJSC/ExecState#*, const Identifiercxx . . $ QTJSC/Identifier#& propertyName);
103 virtual bool deletePropertycxx . . $ QTJSC/Arguments#deleteProperty(2f8cbeb04562a47b).(ExecStatecxx . . $ QTJSC/ExecState#*, unsigned propertyName);
104
105 virtual const ClassInfocxx . . $ QTJSC/ClassInfo#* classInfocxx . . $ QTJSC/Arguments#classInfo(f90fb4cda7a7c2e2).() const { return &infocxx . . $ QTJSC/Arguments#info.; }
106
107 void initcxx . . $ QTJSC/Arguments#init(d2cb180e190a9680).(CallFramecxx . . $ QTJSC/CallFrame#*);
108
109 OwnPtrcxx . . $ OwnPtr#<ArgumentsDatacxx . . $ QTJSC/ArgumentsData#> dcxx . . $ QTJSC/Arguments#d.;
110 };
111
112 Argumentscxx . . $ QTJSC/Arguments#* asArgumentscxx . . $ QTJSC/asArguments(1c88538561753616).(JSValuecxx . . $ QTJSC/JSValue#);
113
114 inline Argumentscxx . . $ QTJSC/Arguments#* asArgumentscxx . . $ QTJSC/asArguments(1c88538561753616).(JSValuecxx . . $ QTJSC/JSValue# value)
115 {
116 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(asObject(value)->inherits(&Arguments::info));
117 return static_cast<Arguments*>(asObject(value));
118 }
119
120 ALWAYS_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! void Argumentscxx . . $ QTJSC/Arguments#::getArgumentsDatacxx . . $ QTJSC/Arguments#getArgumentsData(2b466da6de96feb6).(CallFramecxx . . $ QTJSC/CallFrame#* callFrame, JSObjectcxx . . $ QTJSC/JSObject#*& callee, ptrdiff_t& firstParameterIndex, Registercxx . . $ QTJSC/Register#*& argv, int& argc)
121 {
122 callee = callFrame->calleecxx . . $ QTJSC/ExecState#callee(8ac23ea934d7a115).();
123
124 int numParameters;
125 if (callee->inheritscxx . . $ QTJSC/JSCell#inherits(7eca403b06d48463).(&JSFunctioncxx . . $ QTJSC/JSFunction#::infocxx . . $ QTJSC/JSFunction#info.))
126 numParameters = JSCcxx . . $ `<built-in>:463:9`!::asFunctioncxx . . $ QTJSC/asFunction(deffc94ad83de35f).(callee)->jsExecutable()->parameterCount();
127 else
128 numParameters = 0;
129
130 argc = callFrame->argumentCountcxx . . $ QTJSC/ExecState#argumentCount(455f465bc33b4cdf).();
131
132 if (argc <= numParameters)
133 argv = callFrame->registerscxx . . $ QTJSC/ExecState#registers(b2e4df52de7a0262).() - RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize. - numParameters;
134 else
135 argv = callFrame->registerscxx . . $ QTJSC/ExecState#registers(b2e4df52de7a0262).() - RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize. - numParameters - argc;
136
137 argc -= 1; // - 1 to skip "this"
138 firstParameterIndex = -RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize. - numParameters;
139 }
140
141 inline Argumentscxx . . $ QTJSC/Arguments#::Argumentscxx . . $ QTJSC/Arguments#Arguments(d2cb180e190a9680).(CallFramecxx . . $ QTJSC/CallFrame#* callFrame)
142 : JSObjectcxx . . $ QTJSC/JSObject#(callFrame->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->argumentsStructurecxx . . $ QTJSC/JSGlobalObject#argumentsStructure(a25848528202c7a).())
143 , d(new ArgumentsData)
144 {
145 JSObjectcxx . . $ QTJSC/JSObject#* callee;
146 ptrdiff_t firstParameterIndex;
147 Registercxx . . $ QTJSC/Register#* argv;
148 int numArguments;
149 getArgumentsDatacxx . . $ QTJSC/Arguments#getArgumentsData(2b466da6de96feb6).(callFrame, callee, firstParameterIndex, argv, numArguments);
150
151 if (callee->inherits(&JSFunction::info))
152 d->numParameters = JSCcxx . . $ `<built-in>:463:9`!::asFunction(callee)->jsExecutable()->parameterCount();
153 else
154 d->numParameters = 0;
155 d->firstParameterIndex = firstParameterIndex;
156 d->numArguments = numArguments;
157
158 d->activation = 0;
159 d->registers = callFrame->registers();
160
161 Registercxx . . $ QTJSC/Register#* extraArguments;
162 if (d->numArguments <= d->numParameters)
163 extraArguments = 0;
164 else {
165 unsigned numExtraArguments = d->numArguments - d->numParameters;
166 if (numExtraArguments > sizeof(d->extraArgumentsFixedBuffer) / sizeof(Register))
167 extraArguments = new Registercxx . . $ QTJSC/Register#Register(49f6e7a06ebc5aa8).[numExtraArguments];
168 else
169 extraArguments = d->extraArgumentsFixedBuffer;
170 for (unsigned i = 0; i < numExtraArguments; ++i)
171 extraArguments[i] = argv[d->numParameters + i];
172 }
173
174 d->extraArguments = extraArguments;
175
176 d->callee = callee;
177 d->overrodeLength = false;
178 d->overrodeCallee = false;
179 }
180
181 inline Argumentscxx . . $ QTJSC/Arguments#::Argumentscxx . . $ QTJSC/Arguments#Arguments(609af0602dfd3f4e).(CallFramecxx . . $ QTJSC/CallFrame#* callFrame, NoParametersTypecxx . . $ QTJSC/Arguments#NoParametersType#)
182 : JSObjectcxx . . $ QTJSC/JSObject#(callFrame->lexicalGlobalObjectcxx . . $ QTJSC/ExecState#lexicalGlobalObject(3d50c730b5e26899).()->argumentsStructurecxx . . $ QTJSC/JSGlobalObject#argumentsStructure(a25848528202c7a).())
183 , d(new ArgumentsData)
184 {
185 if (callFrame->calleecxx . . $ QTJSC/ExecState#callee(8ac23ea934d7a115).() && callFrame->calleecxx . . $ QTJSC/ExecState#callee(8ac23ea934d7a115).()->inheritscxx . . $ QTJSC/JSCell#inherits(7eca403b06d48463).(&JSCcxx . . $ QTJSC/::JSFunctioncxx . . $ QTJSC/JSFunction#::infocxx . . $ QTJSC/JSFunction#info.))
186 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!asFunction(callFrame->callee())->jsExecutable()->parameterCount());
187
188 unsigned numArguments = callFrame->argumentCountcxx . . $ QTJSC/ExecState#argumentCount(455f465bc33b4cdf).() - 1;
189
190 d->numParameters = 0;
191 d->numArguments = numArguments;
192 d->activation = 0;
193
194 Registercxx . . $ QTJSC/Register#* extraArguments;
195 if (numArguments > sizeof(d->extraArgumentsFixedBuffer) / sizeof(Register))
196 extraArguments = new Registercxx . . $ QTJSC/Register#[numArguments];
197 else
198 extraArguments = d->extraArgumentsFixedBuffer;
199
200 Registercxx . . $ QTJSC/Register#* argv = callFrame->registerscxx . . $ QTJSC/ExecState#registers(b2e4df52de7a0262).() - RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize. - numArguments - 1;
201 if (callFrame->calleecxx . . $ QTJSC/ExecState#callee(8ac23ea934d7a115).() && !callFrame->calleecxx . . $ QTJSC/ExecState#callee(8ac23ea934d7a115).()->inheritscxx . . $ QTJSC/JSCell#inherits(7eca403b06d48463).(&JSCcxx . . $ `<built-in>:463:9`!::JSFunctioncxx . . $ QTJSC/JSFunction#::infocxx . . $ QTJSC/JSFunction#info.))
202 ++argv; // ### off-by-one issue with native functions
203 for (unsigned i = 0; i < numArguments; ++i)
204 extraArguments[i] =cxx . . $ QTJSC/Register#`operator=`(46bd610ee0b85185). argv[i];
205
206 d->extraArguments = extraArguments;
207
208 d->callee = callFrame->callee();
209 d->overrodeLength = false;
210 d->overrodeCallee = false;
211 }
212
213 inline void Argumentscxx . . $ QTJSC/Arguments#::copyRegisterscxx . . $ QTJSC/Arguments#copyRegisters(49f6e7a06ebc5aa8).()
214 {
215 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!isTornOff());
216
217 if (!d->numParameters)
218 return;
219
220 int registerOffset = d->numParameters + RegisterFile::CallFrameHeaderSize;
221 size_tcxx . . $ size_t# registerArraySize = d->numParameters;
222
223 Registercxx . . $ QTJSC/Register#* registerArray = new Registercxx . . $ QTJSC/Register#[registerArraySize];
224 memcpy(registerArray, d->registers - registerOffset, registerArraySize * sizeof(Registercxx . . $ QTJSC/Register#));
225 d->registerArray.set(registerArray);
226 d->registers = registerArray + registerOffset;
227 }
228
229 // This JSActivation function is defined here so it can get at Arguments::setRegisters.
230 inline void JSActivationcxx . . $ QTJSC/JSActivation#::copyRegisterscxx . . $ QTJSC/JSActivation#copyRegisters(b3923e289cde62a5).(Argumentscxx . . $ QTJSC/Arguments#* arguments)
231 {
232 ASSERTcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/wtf/Assertions.h:184:9`!(!d()->registerArray);
233
234 size_tcxx . . $ size_t# numParametersMinusThis = dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->generatedBytecode().m_numParameters -cxx . . $ operator-(9247d7e2a6536fa6). 1;
235 size_tcxx . . $ size_t# numVars = dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->functionExecutable->generatedBytecode().m_numVars;
236 size_tcxx . . $ size_t# numLocals = numVars + numParametersMinusThis;
237
238 if (!numLocals)
239 return;
240
241 int registerOffset = numParametersMinusThis + RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize.;
242 size_tcxx . . $ size_t# registerArraySize = numLocals + RegisterFilecxx . . $ QTJSC/RegisterFile#::CallFrameHeaderSizecxx . . $ QTJSC/RegisterFile#CallFrameHeaderSize.;
243
244 Registercxx . . $ QTJSC/Register#* registerArray = copyRegisterArraycxx . . $ QTJSC/JSVariableObject#copyRegisterArray(f138834e99c40dca).(dcxx . . $ QTJSC/JSActivation#d(b05c7bd1e432b963).()->registers -cxx . . $ operator-(bea4db219b453aae). registerOffset, registerArraySize);
245 setRegisterscxx . . $ QTJSC/JSVariableObject#setRegisters(db765aed4a7dcca8).(registerArray + registerOffset, registerArray);
246 if (arguments && !arguments->isTornOffcxx . . $ QTJSC/Arguments#isTornOff(50ce9a9e25b4a850).())
247 static_cast<Argumentscxx . . $ QTJSC/Arguments#*>(arguments)->setActivationcxx . . $ QTJSC/Arguments#setActivation(9f5abfcb43cd6e2).(this);
248 }
249
250 ALWAYS_INLINEcxx . . $ `../3rdparty/javascriptcore/JavaScriptCore/wtf/AlwaysInline.h:25:9`! Argumentscxx . . $ QTJSC/Arguments#* Registercxx . . $ QTJSC/Register#::argumentscxx . . $ QTJSC/Register#arguments(66a58788709e4d3d).() const
251 {
252 if (jsValuecxx . . $ QTJSC/Register#jsValue(888c053acf364da1).() ==cxx . . $ QTJSC/JSValue#`operator==`(b7c0ea8ebb120a64). JSValuecxx . . $ QTJSC/JSValue#JSValue(49f6e7a06ebc5aa8).())
253 return 0;
254 return asArgumentscxx . . $ QTJSC/asArguments(1c88538561753616).(jsValuecxx . . $ QTJSC/Register#jsValue(888c053acf364da1).());
255 }
256
257
258 } // namespace JSC
259
260 #endif // Arguments_h