Rewrite gen_ext_hhvm and gen_infotabs in C++
[hiphop-php.git] / hphp / runtime / ext / ext_apc.ext_hhvm.cpp
blobe1c9caf1e5244fb141b1c78b97f6f4b564d1a847
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 | Copyright (c) 1997-2010 The PHP Group |
7 +----------------------------------------------------------------------+
8 | This source file is subject to version 3.01 of the PHP license, |
9 | that is bundled with this package in the file LICENSE, and is |
10 | available through the world-wide-web at the following url: |
11 | http://www.php.net/license/3_01.txt |
12 | If you did not receive a copy of the PHP license and are unable to |
13 | obtain it through the world-wide-web, please send a note to |
14 | license@php.net so we can mail you a copy immediately. |
15 +----------------------------------------------------------------------+
18 #include "runtime/ext_hhvm/ext_hhvm.h"
19 #include "runtime/base/builtin_functions.h"
20 #include "runtime/base/array/array_init.h"
21 #include "runtime/ext/ext.h"
22 #include "runtime/vm/class.h"
23 #include "runtime/vm/runtime.h"
24 #include <exception>
26 namespace HPHP {
28 bool fh_apc_store(Value* key, TypedValue* var, long ttl, long cache_id) asm("_ZN4HPHP11f_apc_storeERKNS_6StringERKNS_7VariantEll");
30 void fg1_apc_store(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
31 void fg1_apc_store(TypedValue* rv, ActRec* ar, int32_t count) {
32 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
33 switch (count) {
34 default: // count >= 4
35 if ((args-3)->m_type != KindOfInt64) {
36 tvCastToInt64InPlace(args-3);
38 case 3:
39 if ((args-2)->m_type != KindOfInt64) {
40 tvCastToInt64InPlace(args-2);
42 case 2:
43 break;
45 if (!IS_STRING_TYPE((args-0)->m_type)) {
46 tvCastToStringInPlace(args-0);
48 rv->m_type = KindOfBoolean;
49 rv->m_data.num = (fh_apc_store(&args[-0].m_data, (args-1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
52 TypedValue* fg_apc_store(ActRec* ar) {
53 TypedValue rvSpace;
54 TypedValue* rv = &rvSpace;
55 int32_t count = ar->numArgs();
56 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
57 if (count >= 2 && count <= 4) {
58 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
59 (count <= 2 || (args - 2)->m_type == KindOfInt64) &&
60 IS_STRING_TYPE((args - 0)->m_type)) {
61 rv->m_type = KindOfBoolean;
62 rv->m_data.num = (fh_apc_store(&args[-0].m_data, (args-1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
63 } else {
64 fg1_apc_store(rv, ar, count);
66 } else {
67 throw_wrong_arguments_nr("apc_store", count, 2, 4, 1);
68 rv->m_data.num = 0LL;
69 rv->m_type = KindOfNull;
71 frame_free_locals_no_this_inl(ar, 4);
72 memcpy(&ar->m_r, rv, sizeof(TypedValue));
73 return &ar->m_r;
76 bool fh_apc_add(Value* key, TypedValue* var, long ttl, long cache_id) asm("_ZN4HPHP9f_apc_addERKNS_6StringERKNS_7VariantEll");
78 void fg1_apc_add(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
79 void fg1_apc_add(TypedValue* rv, ActRec* ar, int32_t count) {
80 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
81 switch (count) {
82 default: // count >= 4
83 if ((args-3)->m_type != KindOfInt64) {
84 tvCastToInt64InPlace(args-3);
86 case 3:
87 if ((args-2)->m_type != KindOfInt64) {
88 tvCastToInt64InPlace(args-2);
90 case 2:
91 break;
93 if (!IS_STRING_TYPE((args-0)->m_type)) {
94 tvCastToStringInPlace(args-0);
96 rv->m_type = KindOfBoolean;
97 rv->m_data.num = (fh_apc_add(&args[-0].m_data, (args-1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
100 TypedValue* fg_apc_add(ActRec* ar) {
101 TypedValue rvSpace;
102 TypedValue* rv = &rvSpace;
103 int32_t count = ar->numArgs();
104 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
105 if (count >= 2 && count <= 4) {
106 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
107 (count <= 2 || (args - 2)->m_type == KindOfInt64) &&
108 IS_STRING_TYPE((args - 0)->m_type)) {
109 rv->m_type = KindOfBoolean;
110 rv->m_data.num = (fh_apc_add(&args[-0].m_data, (args-1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
111 } else {
112 fg1_apc_add(rv, ar, count);
114 } else {
115 throw_wrong_arguments_nr("apc_add", count, 2, 4, 1);
116 rv->m_data.num = 0LL;
117 rv->m_type = KindOfNull;
119 frame_free_locals_no_this_inl(ar, 4);
120 memcpy(&ar->m_r, rv, sizeof(TypedValue));
121 return &ar->m_r;
124 TypedValue* fh_apc_fetch(TypedValue* _rv, TypedValue* key, TypedValue* success, long cache_id) asm("_ZN4HPHP11f_apc_fetchERKNS_7VariantERKNS_14VRefParamValueEl");
126 void fg1_apc_fetch(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
127 void fg1_apc_fetch(TypedValue* rv, ActRec* ar, int32_t count) {
128 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
129 tvCastToInt64InPlace(args-2);
130 VRefParamValue defVal1 = uninit_null();
131 fh_apc_fetch(rv, (args-0), (count > 1) ? (args-1) : (TypedValue*)(&defVal1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0));
132 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
135 TypedValue* fg_apc_fetch(ActRec* ar) {
136 TypedValue rvSpace;
137 TypedValue* rv = &rvSpace;
138 int32_t count = ar->numArgs();
139 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
140 if (count >= 1 && count <= 3) {
141 if ((count <= 2 || (args - 2)->m_type == KindOfInt64)) {
142 VRefParamValue defVal1 = uninit_null();
143 fh_apc_fetch(rv, (args-0), (count > 1) ? (args-1) : (TypedValue*)(&defVal1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0));
144 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
145 } else {
146 fg1_apc_fetch(rv, ar, count);
148 } else {
149 throw_wrong_arguments_nr("apc_fetch", count, 1, 3, 1);
150 rv->m_data.num = 0LL;
151 rv->m_type = KindOfNull;
153 frame_free_locals_no_this_inl(ar, 3);
154 memcpy(&ar->m_r, rv, sizeof(TypedValue));
155 return &ar->m_r;
158 TypedValue* fh_apc_delete(TypedValue* _rv, TypedValue* key, long cache_id) asm("_ZN4HPHP12f_apc_deleteERKNS_7VariantEl");
160 void fg1_apc_delete(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
161 void fg1_apc_delete(TypedValue* rv, ActRec* ar, int32_t count) {
162 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
163 tvCastToInt64InPlace(args-1);
164 fh_apc_delete(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
165 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
168 TypedValue* fg_apc_delete(ActRec* ar) {
169 TypedValue rvSpace;
170 TypedValue* rv = &rvSpace;
171 int32_t count = ar->numArgs();
172 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
173 if (count >= 1 && count <= 2) {
174 if ((count <= 1 || (args - 1)->m_type == KindOfInt64)) {
175 fh_apc_delete(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
176 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
177 } else {
178 fg1_apc_delete(rv, ar, count);
180 } else {
181 throw_wrong_arguments_nr("apc_delete", count, 1, 2, 1);
182 rv->m_data.num = 0LL;
183 rv->m_type = KindOfNull;
185 frame_free_locals_no_this_inl(ar, 2);
186 memcpy(&ar->m_r, rv, sizeof(TypedValue));
187 return &ar->m_r;
190 bool fh_apc_clear_cache(long cache_id) asm("_ZN4HPHP17f_apc_clear_cacheEl");
192 void fg1_apc_clear_cache(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
193 void fg1_apc_clear_cache(TypedValue* rv, ActRec* ar, int32_t count) {
194 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
195 tvCastToInt64InPlace(args-0);
196 rv->m_type = KindOfBoolean;
197 rv->m_data.num = (fh_apc_clear_cache((count > 0) ? (long)(args[-0].m_data.num) : (long)(0))) ? 1LL : 0LL;
200 TypedValue* fg_apc_clear_cache(ActRec* ar) {
201 TypedValue rvSpace;
202 TypedValue* rv = &rvSpace;
203 int32_t count = ar->numArgs();
204 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
205 if (count <= 1) {
206 if ((count <= 0 || (args - 0)->m_type == KindOfInt64)) {
207 rv->m_type = KindOfBoolean;
208 rv->m_data.num = (fh_apc_clear_cache((count > 0) ? (long)(args[-0].m_data.num) : (long)(0))) ? 1LL : 0LL;
209 } else {
210 fg1_apc_clear_cache(rv, ar, count);
212 } else {
213 throw_toomany_arguments_nr("apc_clear_cache", 1, 1);
214 rv->m_data.num = 0LL;
215 rv->m_type = KindOfNull;
217 frame_free_locals_no_this_inl(ar, 1);
218 memcpy(&ar->m_r, rv, sizeof(TypedValue));
219 return &ar->m_r;
222 TypedValue* fh_apc_inc(TypedValue* _rv, Value* key, long step, TypedValue* success, long cache_id) asm("_ZN4HPHP9f_apc_incERKNS_6StringElRKNS_14VRefParamValueEl");
224 void fg1_apc_inc(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
225 void fg1_apc_inc(TypedValue* rv, ActRec* ar, int32_t count) {
226 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
227 switch (count) {
228 default: // count >= 4
229 if ((args-3)->m_type != KindOfInt64) {
230 tvCastToInt64InPlace(args-3);
232 case 3:
233 case 2:
234 if ((args-1)->m_type != KindOfInt64) {
235 tvCastToInt64InPlace(args-1);
237 case 1:
238 break;
240 if (!IS_STRING_TYPE((args-0)->m_type)) {
241 tvCastToStringInPlace(args-0);
243 VRefParamValue defVal2 = uninit_null();
244 fh_apc_inc(rv, &args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0));
245 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
248 TypedValue* fg_apc_inc(ActRec* ar) {
249 TypedValue rvSpace;
250 TypedValue* rv = &rvSpace;
251 int32_t count = ar->numArgs();
252 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
253 if (count >= 1 && count <= 4) {
254 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
255 (count <= 1 || (args - 1)->m_type == KindOfInt64) &&
256 IS_STRING_TYPE((args - 0)->m_type)) {
257 VRefParamValue defVal2 = uninit_null();
258 fh_apc_inc(rv, &args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0));
259 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
260 } else {
261 fg1_apc_inc(rv, ar, count);
263 } else {
264 throw_wrong_arguments_nr("apc_inc", count, 1, 4, 1);
265 rv->m_data.num = 0LL;
266 rv->m_type = KindOfNull;
268 frame_free_locals_no_this_inl(ar, 4);
269 memcpy(&ar->m_r, rv, sizeof(TypedValue));
270 return &ar->m_r;
273 TypedValue* fh_apc_dec(TypedValue* _rv, Value* key, long step, TypedValue* success, long cache_id) asm("_ZN4HPHP9f_apc_decERKNS_6StringElRKNS_14VRefParamValueEl");
275 void fg1_apc_dec(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
276 void fg1_apc_dec(TypedValue* rv, ActRec* ar, int32_t count) {
277 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
278 switch (count) {
279 default: // count >= 4
280 if ((args-3)->m_type != KindOfInt64) {
281 tvCastToInt64InPlace(args-3);
283 case 3:
284 case 2:
285 if ((args-1)->m_type != KindOfInt64) {
286 tvCastToInt64InPlace(args-1);
288 case 1:
289 break;
291 if (!IS_STRING_TYPE((args-0)->m_type)) {
292 tvCastToStringInPlace(args-0);
294 VRefParamValue defVal2 = uninit_null();
295 fh_apc_dec(rv, &args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0));
296 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
299 TypedValue* fg_apc_dec(ActRec* ar) {
300 TypedValue rvSpace;
301 TypedValue* rv = &rvSpace;
302 int32_t count = ar->numArgs();
303 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
304 if (count >= 1 && count <= 4) {
305 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
306 (count <= 1 || (args - 1)->m_type == KindOfInt64) &&
307 IS_STRING_TYPE((args - 0)->m_type)) {
308 VRefParamValue defVal2 = uninit_null();
309 fh_apc_dec(rv, &args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(1), (count > 2) ? (args-2) : (TypedValue*)(&defVal2), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0));
310 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
311 } else {
312 fg1_apc_dec(rv, ar, count);
314 } else {
315 throw_wrong_arguments_nr("apc_dec", count, 1, 4, 1);
316 rv->m_data.num = 0LL;
317 rv->m_type = KindOfNull;
319 frame_free_locals_no_this_inl(ar, 4);
320 memcpy(&ar->m_r, rv, sizeof(TypedValue));
321 return &ar->m_r;
324 bool fh_apc_cas(Value* key, long old_cas, long new_cas, long cache_id) asm("_ZN4HPHP9f_apc_casERKNS_6StringElll");
326 void fg1_apc_cas(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
327 void fg1_apc_cas(TypedValue* rv, ActRec* ar, int32_t count) {
328 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
329 switch (count) {
330 default: // count >= 4
331 if ((args-3)->m_type != KindOfInt64) {
332 tvCastToInt64InPlace(args-3);
334 case 3:
335 break;
337 if ((args-2)->m_type != KindOfInt64) {
338 tvCastToInt64InPlace(args-2);
340 if ((args-1)->m_type != KindOfInt64) {
341 tvCastToInt64InPlace(args-1);
343 if (!IS_STRING_TYPE((args-0)->m_type)) {
344 tvCastToStringInPlace(args-0);
346 rv->m_type = KindOfBoolean;
347 rv->m_data.num = (fh_apc_cas(&args[-0].m_data, (long)(args[-1].m_data.num), (long)(args[-2].m_data.num), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
350 TypedValue* fg_apc_cas(ActRec* ar) {
351 TypedValue rvSpace;
352 TypedValue* rv = &rvSpace;
353 int32_t count = ar->numArgs();
354 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
355 if (count >= 3 && count <= 4) {
356 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
357 (args - 2)->m_type == KindOfInt64 &&
358 (args - 1)->m_type == KindOfInt64 &&
359 IS_STRING_TYPE((args - 0)->m_type)) {
360 rv->m_type = KindOfBoolean;
361 rv->m_data.num = (fh_apc_cas(&args[-0].m_data, (long)(args[-1].m_data.num), (long)(args[-2].m_data.num), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
362 } else {
363 fg1_apc_cas(rv, ar, count);
365 } else {
366 throw_wrong_arguments_nr("apc_cas", count, 3, 4, 1);
367 rv->m_data.num = 0LL;
368 rv->m_type = KindOfNull;
370 frame_free_locals_no_this_inl(ar, 4);
371 memcpy(&ar->m_r, rv, sizeof(TypedValue));
372 return &ar->m_r;
375 TypedValue* fh_apc_exists(TypedValue* _rv, TypedValue* key, long cache_id) asm("_ZN4HPHP12f_apc_existsERKNS_7VariantEl");
377 void fg1_apc_exists(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
378 void fg1_apc_exists(TypedValue* rv, ActRec* ar, int32_t count) {
379 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
380 tvCastToInt64InPlace(args-1);
381 fh_apc_exists(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
382 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
385 TypedValue* fg_apc_exists(ActRec* ar) {
386 TypedValue rvSpace;
387 TypedValue* rv = &rvSpace;
388 int32_t count = ar->numArgs();
389 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
390 if (count >= 1 && count <= 2) {
391 if ((count <= 1 || (args - 1)->m_type == KindOfInt64)) {
392 fh_apc_exists(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
393 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
394 } else {
395 fg1_apc_exists(rv, ar, count);
397 } else {
398 throw_wrong_arguments_nr("apc_exists", count, 1, 2, 1);
399 rv->m_data.num = 0LL;
400 rv->m_type = KindOfNull;
402 frame_free_locals_no_this_inl(ar, 2);
403 memcpy(&ar->m_r, rv, sizeof(TypedValue));
404 return &ar->m_r;
407 TypedValue* fh_apc_cache_info(TypedValue* _rv, long cache_id, bool limited) asm("_ZN4HPHP16f_apc_cache_infoElb");
409 void fg1_apc_cache_info(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
410 void fg1_apc_cache_info(TypedValue* rv, ActRec* ar, int32_t count) {
411 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
412 switch (count) {
413 default: // count >= 2
414 if ((args-1)->m_type != KindOfBoolean) {
415 tvCastToBooleanInPlace(args-1);
417 case 1:
418 if ((args-0)->m_type != KindOfInt64) {
419 tvCastToInt64InPlace(args-0);
421 case 0:
422 break;
424 fh_apc_cache_info(rv, (count > 0) ? (long)(args[-0].m_data.num) : (long)(0), (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(false));
425 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
428 TypedValue* fg_apc_cache_info(ActRec* ar) {
429 TypedValue rvSpace;
430 TypedValue* rv = &rvSpace;
431 int32_t count = ar->numArgs();
432 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
433 if (count <= 2) {
434 if ((count <= 1 || (args - 1)->m_type == KindOfBoolean) &&
435 (count <= 0 || (args - 0)->m_type == KindOfInt64)) {
436 fh_apc_cache_info(rv, (count > 0) ? (long)(args[-0].m_data.num) : (long)(0), (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(false));
437 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
438 } else {
439 fg1_apc_cache_info(rv, ar, count);
441 } else {
442 throw_toomany_arguments_nr("apc_cache_info", 2, 1);
443 rv->m_data.num = 0LL;
444 rv->m_type = KindOfNull;
446 frame_free_locals_no_this_inl(ar, 2);
447 memcpy(&ar->m_r, rv, sizeof(TypedValue));
448 return &ar->m_r;
451 Value* fh_apc_sma_info(Value* _rv, bool limited) asm("_ZN4HPHP14f_apc_sma_infoEb");
453 void fg1_apc_sma_info(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
454 void fg1_apc_sma_info(TypedValue* rv, ActRec* ar, int32_t count) {
455 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
456 tvCastToBooleanInPlace(args-0);
457 rv->m_type = KindOfArray;
458 fh_apc_sma_info(&(rv->m_data), (count > 0) ? (bool)(args[-0].m_data.num) : (bool)(false));
459 if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
462 TypedValue* fg_apc_sma_info(ActRec* ar) {
463 TypedValue rvSpace;
464 TypedValue* rv = &rvSpace;
465 int32_t count = ar->numArgs();
466 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
467 if (count <= 1) {
468 if ((count <= 0 || (args - 0)->m_type == KindOfBoolean)) {
469 rv->m_type = KindOfArray;
470 fh_apc_sma_info(&(rv->m_data), (count > 0) ? (bool)(args[-0].m_data.num) : (bool)(false));
471 if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
472 } else {
473 fg1_apc_sma_info(rv, ar, count);
475 } else {
476 throw_toomany_arguments_nr("apc_sma_info", 1, 1);
477 rv->m_data.num = 0LL;
478 rv->m_type = KindOfNull;
480 frame_free_locals_no_this_inl(ar, 1);
481 memcpy(&ar->m_r, rv, sizeof(TypedValue));
482 return &ar->m_r;
485 bool fh_apc_define_constants(Value* key, Value* constants, bool case_sensitive, long cache_id) asm("_ZN4HPHP22f_apc_define_constantsERKNS_6StringES2_bl");
487 void fg1_apc_define_constants(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
488 void fg1_apc_define_constants(TypedValue* rv, ActRec* ar, int32_t count) {
489 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
490 switch (count) {
491 default: // count >= 4
492 if ((args-3)->m_type != KindOfInt64) {
493 tvCastToInt64InPlace(args-3);
495 case 3:
496 if ((args-2)->m_type != KindOfBoolean) {
497 tvCastToBooleanInPlace(args-2);
499 case 2:
500 break;
502 if (!IS_STRING_TYPE((args-1)->m_type)) {
503 tvCastToStringInPlace(args-1);
505 if (!IS_STRING_TYPE((args-0)->m_type)) {
506 tvCastToStringInPlace(args-0);
508 rv->m_type = KindOfBoolean;
509 rv->m_data.num = (fh_apc_define_constants(&args[-0].m_data, &args[-1].m_data, (count > 2) ? (bool)(args[-2].m_data.num) : (bool)(true), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
512 TypedValue* fg_apc_define_constants(ActRec* ar) {
513 TypedValue rvSpace;
514 TypedValue* rv = &rvSpace;
515 int32_t count = ar->numArgs();
516 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
517 if (count >= 2 && count <= 4) {
518 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
519 (count <= 2 || (args - 2)->m_type == KindOfBoolean) &&
520 IS_STRING_TYPE((args - 1)->m_type) &&
521 IS_STRING_TYPE((args - 0)->m_type)) {
522 rv->m_type = KindOfBoolean;
523 rv->m_data.num = (fh_apc_define_constants(&args[-0].m_data, &args[-1].m_data, (count > 2) ? (bool)(args[-2].m_data.num) : (bool)(true), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
524 } else {
525 fg1_apc_define_constants(rv, ar, count);
527 } else {
528 throw_wrong_arguments_nr("apc_define_constants", count, 2, 4, 1);
529 rv->m_data.num = 0LL;
530 rv->m_type = KindOfNull;
532 frame_free_locals_no_this_inl(ar, 4);
533 memcpy(&ar->m_r, rv, sizeof(TypedValue));
534 return &ar->m_r;
537 bool fh_apc_load_constants(Value* key, bool case_sensitive, long cache_id) asm("_ZN4HPHP20f_apc_load_constantsERKNS_6StringEbl");
539 void fg1_apc_load_constants(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
540 void fg1_apc_load_constants(TypedValue* rv, ActRec* ar, int32_t count) {
541 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
542 switch (count) {
543 default: // count >= 3
544 if ((args-2)->m_type != KindOfInt64) {
545 tvCastToInt64InPlace(args-2);
547 case 2:
548 if ((args-1)->m_type != KindOfBoolean) {
549 tvCastToBooleanInPlace(args-1);
551 case 1:
552 break;
554 if (!IS_STRING_TYPE((args-0)->m_type)) {
555 tvCastToStringInPlace(args-0);
557 rv->m_type = KindOfBoolean;
558 rv->m_data.num = (fh_apc_load_constants(&args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(true), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
561 TypedValue* fg_apc_load_constants(ActRec* ar) {
562 TypedValue rvSpace;
563 TypedValue* rv = &rvSpace;
564 int32_t count = ar->numArgs();
565 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
566 if (count >= 1 && count <= 3) {
567 if ((count <= 2 || (args - 2)->m_type == KindOfInt64) &&
568 (count <= 1 || (args - 1)->m_type == KindOfBoolean) &&
569 IS_STRING_TYPE((args - 0)->m_type)) {
570 rv->m_type = KindOfBoolean;
571 rv->m_data.num = (fh_apc_load_constants(&args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(true), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
572 } else {
573 fg1_apc_load_constants(rv, ar, count);
575 } else {
576 throw_wrong_arguments_nr("apc_load_constants", count, 1, 3, 1);
577 rv->m_data.num = 0LL;
578 rv->m_type = KindOfNull;
580 frame_free_locals_no_this_inl(ar, 3);
581 memcpy(&ar->m_r, rv, sizeof(TypedValue));
582 return &ar->m_r;
585 bool fh_apc_compile_file(Value* filename, bool atomic, long cache_id) asm("_ZN4HPHP18f_apc_compile_fileERKNS_6StringEbl");
587 void fg1_apc_compile_file(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
588 void fg1_apc_compile_file(TypedValue* rv, ActRec* ar, int32_t count) {
589 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
590 switch (count) {
591 default: // count >= 3
592 if ((args-2)->m_type != KindOfInt64) {
593 tvCastToInt64InPlace(args-2);
595 case 2:
596 if ((args-1)->m_type != KindOfBoolean) {
597 tvCastToBooleanInPlace(args-1);
599 case 1:
600 break;
602 if (!IS_STRING_TYPE((args-0)->m_type)) {
603 tvCastToStringInPlace(args-0);
605 rv->m_type = KindOfBoolean;
606 rv->m_data.num = (fh_apc_compile_file(&args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(true), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
609 TypedValue* fg_apc_compile_file(ActRec* ar) {
610 TypedValue rvSpace;
611 TypedValue* rv = &rvSpace;
612 int32_t count = ar->numArgs();
613 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
614 if (count >= 1 && count <= 3) {
615 if ((count <= 2 || (args - 2)->m_type == KindOfInt64) &&
616 (count <= 1 || (args - 1)->m_type == KindOfBoolean) &&
617 IS_STRING_TYPE((args - 0)->m_type)) {
618 rv->m_type = KindOfBoolean;
619 rv->m_data.num = (fh_apc_compile_file(&args[-0].m_data, (count > 1) ? (bool)(args[-1].m_data.num) : (bool)(true), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
620 } else {
621 fg1_apc_compile_file(rv, ar, count);
623 } else {
624 throw_wrong_arguments_nr("apc_compile_file", count, 1, 3, 1);
625 rv->m_data.num = 0LL;
626 rv->m_type = KindOfNull;
628 frame_free_locals_no_this_inl(ar, 3);
629 memcpy(&ar->m_r, rv, sizeof(TypedValue));
630 return &ar->m_r;
633 Value* fh_apc_filehits(Value* _rv) asm("_ZN4HPHP14f_apc_filehitsEv");
635 TypedValue* fg_apc_filehits(ActRec* ar) {
636 TypedValue rvSpace;
637 TypedValue* rv = &rvSpace;
638 int32_t count = ar->numArgs();
639 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
640 if (count == 0) {
641 rv->m_type = KindOfArray;
642 fh_apc_filehits(&(rv->m_data));
643 if (rv->m_data.num == 0LL) rv->m_type = KindOfNull;
644 } else {
645 throw_toomany_arguments_nr("apc_filehits", 0, 1);
646 rv->m_data.num = 0LL;
647 rv->m_type = KindOfNull;
649 frame_free_locals_no_this_inl(ar, 0);
650 memcpy(&ar->m_r, rv, sizeof(TypedValue));
651 return &ar->m_r;
654 TypedValue* fh_apc_delete_file(TypedValue* _rv, TypedValue* keys, long cache_id) asm("_ZN4HPHP17f_apc_delete_fileERKNS_7VariantEl");
656 void fg1_apc_delete_file(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
657 void fg1_apc_delete_file(TypedValue* rv, ActRec* ar, int32_t count) {
658 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
659 tvCastToInt64InPlace(args-1);
660 fh_apc_delete_file(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
661 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
664 TypedValue* fg_apc_delete_file(ActRec* ar) {
665 TypedValue rvSpace;
666 TypedValue* rv = &rvSpace;
667 int32_t count = ar->numArgs();
668 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
669 if (count >= 1 && count <= 2) {
670 if ((count <= 1 || (args - 1)->m_type == KindOfInt64)) {
671 fh_apc_delete_file(rv, (args-0), (count > 1) ? (long)(args[-1].m_data.num) : (long)(0));
672 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
673 } else {
674 fg1_apc_delete_file(rv, ar, count);
676 } else {
677 throw_wrong_arguments_nr("apc_delete_file", count, 1, 2, 1);
678 rv->m_data.num = 0LL;
679 rv->m_type = KindOfNull;
681 frame_free_locals_no_this_inl(ar, 2);
682 memcpy(&ar->m_r, rv, sizeof(TypedValue));
683 return &ar->m_r;
686 TypedValue* fh_apc_bin_dump(TypedValue* _rv, long cache_id, TypedValue* filter) asm("_ZN4HPHP14f_apc_bin_dumpElRKNS_7VariantE");
688 void fg1_apc_bin_dump(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
689 void fg1_apc_bin_dump(TypedValue* rv, ActRec* ar, int32_t count) {
690 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
691 tvCastToInt64InPlace(args-0);
692 fh_apc_bin_dump(rv, (count > 0) ? (long)(args[-0].m_data.num) : (long)(0), (count > 1) ? (args-1) : (TypedValue*)(&null_variant));
693 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
696 TypedValue* fg_apc_bin_dump(ActRec* ar) {
697 TypedValue rvSpace;
698 TypedValue* rv = &rvSpace;
699 int32_t count = ar->numArgs();
700 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
701 if (count <= 2) {
702 if ((count <= 0 || (args - 0)->m_type == KindOfInt64)) {
703 fh_apc_bin_dump(rv, (count > 0) ? (long)(args[-0].m_data.num) : (long)(0), (count > 1) ? (args-1) : (TypedValue*)(&null_variant));
704 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
705 } else {
706 fg1_apc_bin_dump(rv, ar, count);
708 } else {
709 throw_toomany_arguments_nr("apc_bin_dump", 2, 1);
710 rv->m_data.num = 0LL;
711 rv->m_type = KindOfNull;
713 frame_free_locals_no_this_inl(ar, 2);
714 memcpy(&ar->m_r, rv, sizeof(TypedValue));
715 return &ar->m_r;
718 bool fh_apc_bin_load(Value* data, long flags, long cache_id) asm("_ZN4HPHP14f_apc_bin_loadERKNS_6StringEll");
720 void fg1_apc_bin_load(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
721 void fg1_apc_bin_load(TypedValue* rv, ActRec* ar, int32_t count) {
722 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
723 switch (count) {
724 default: // count >= 3
725 if ((args-2)->m_type != KindOfInt64) {
726 tvCastToInt64InPlace(args-2);
728 case 2:
729 if ((args-1)->m_type != KindOfInt64) {
730 tvCastToInt64InPlace(args-1);
732 case 1:
733 break;
735 if (!IS_STRING_TYPE((args-0)->m_type)) {
736 tvCastToStringInPlace(args-0);
738 rv->m_type = KindOfBoolean;
739 rv->m_data.num = (fh_apc_bin_load(&args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(0), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
742 TypedValue* fg_apc_bin_load(ActRec* ar) {
743 TypedValue rvSpace;
744 TypedValue* rv = &rvSpace;
745 int32_t count = ar->numArgs();
746 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
747 if (count >= 1 && count <= 3) {
748 if ((count <= 2 || (args - 2)->m_type == KindOfInt64) &&
749 (count <= 1 || (args - 1)->m_type == KindOfInt64) &&
750 IS_STRING_TYPE((args - 0)->m_type)) {
751 rv->m_type = KindOfBoolean;
752 rv->m_data.num = (fh_apc_bin_load(&args[-0].m_data, (count > 1) ? (long)(args[-1].m_data.num) : (long)(0), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0))) ? 1LL : 0LL;
753 } else {
754 fg1_apc_bin_load(rv, ar, count);
756 } else {
757 throw_wrong_arguments_nr("apc_bin_load", count, 1, 3, 1);
758 rv->m_data.num = 0LL;
759 rv->m_type = KindOfNull;
761 frame_free_locals_no_this_inl(ar, 3);
762 memcpy(&ar->m_r, rv, sizeof(TypedValue));
763 return &ar->m_r;
766 TypedValue* fh_apc_bin_dumpfile(TypedValue* _rv, long cache_id, TypedValue* filter, Value* filename, long flags, Value* context) asm("_ZN4HPHP18f_apc_bin_dumpfileElRKNS_7VariantERKNS_6StringElRKNS_6ObjectE");
768 void fg1_apc_bin_dumpfile(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
769 void fg1_apc_bin_dumpfile(TypedValue* rv, ActRec* ar, int32_t count) {
770 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
771 switch (count) {
772 default: // count >= 5
773 if ((args-4)->m_type != KindOfObject) {
774 tvCastToObjectInPlace(args-4);
776 case 4:
777 if ((args-3)->m_type != KindOfInt64) {
778 tvCastToInt64InPlace(args-3);
780 case 3:
781 break;
783 if (!IS_STRING_TYPE((args-2)->m_type)) {
784 tvCastToStringInPlace(args-2);
786 if ((args-0)->m_type != KindOfInt64) {
787 tvCastToInt64InPlace(args-0);
789 Object defVal4 = uninit_null();
790 fh_apc_bin_dumpfile(rv, (long)(args[-0].m_data.num), (args-1), &args[-2].m_data, (count > 3) ? (long)(args[-3].m_data.num) : (long)(0), (count > 4) ? &args[-4].m_data : (Value*)(&defVal4));
791 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
794 TypedValue* fg_apc_bin_dumpfile(ActRec* ar) {
795 TypedValue rvSpace;
796 TypedValue* rv = &rvSpace;
797 int32_t count = ar->numArgs();
798 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
799 if (count >= 3 && count <= 5) {
800 if ((count <= 4 || (args - 4)->m_type == KindOfObject) &&
801 (count <= 3 || (args - 3)->m_type == KindOfInt64) &&
802 IS_STRING_TYPE((args - 2)->m_type) &&
803 (args - 0)->m_type == KindOfInt64) {
804 Object defVal4 = uninit_null();
805 fh_apc_bin_dumpfile(rv, (long)(args[-0].m_data.num), (args-1), &args[-2].m_data, (count > 3) ? (long)(args[-3].m_data.num) : (long)(0), (count > 4) ? &args[-4].m_data : (Value*)(&defVal4));
806 if (rv->m_type == KindOfUninit) rv->m_type = KindOfNull;
807 } else {
808 fg1_apc_bin_dumpfile(rv, ar, count);
810 } else {
811 throw_wrong_arguments_nr("apc_bin_dumpfile", count, 3, 5, 1);
812 rv->m_data.num = 0LL;
813 rv->m_type = KindOfNull;
815 frame_free_locals_no_this_inl(ar, 5);
816 memcpy(&ar->m_r, rv, sizeof(TypedValue));
817 return &ar->m_r;
820 bool fh_apc_bin_loadfile(Value* filename, Value* context, long flags, long cache_id) asm("_ZN4HPHP18f_apc_bin_loadfileERKNS_6StringERKNS_6ObjectEll");
822 void fg1_apc_bin_loadfile(TypedValue* rv, ActRec* ar, int32_t count) __attribute__((noinline,cold));
823 void fg1_apc_bin_loadfile(TypedValue* rv, ActRec* ar, int32_t count) {
824 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
825 switch (count) {
826 default: // count >= 4
827 if ((args-3)->m_type != KindOfInt64) {
828 tvCastToInt64InPlace(args-3);
830 case 3:
831 if ((args-2)->m_type != KindOfInt64) {
832 tvCastToInt64InPlace(args-2);
834 case 2:
835 if ((args-1)->m_type != KindOfObject) {
836 tvCastToObjectInPlace(args-1);
838 case 1:
839 break;
841 if (!IS_STRING_TYPE((args-0)->m_type)) {
842 tvCastToStringInPlace(args-0);
844 rv->m_type = KindOfBoolean;
845 Object defVal1 = uninit_null();
846 rv->m_data.num = (fh_apc_bin_loadfile(&args[-0].m_data, (count > 1) ? &args[-1].m_data : (Value*)(&defVal1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
849 TypedValue* fg_apc_bin_loadfile(ActRec* ar) {
850 TypedValue rvSpace;
851 TypedValue* rv = &rvSpace;
852 int32_t count = ar->numArgs();
853 TypedValue* args UNUSED = ((TypedValue*)ar) - 1;
854 if (count >= 1 && count <= 4) {
855 if ((count <= 3 || (args - 3)->m_type == KindOfInt64) &&
856 (count <= 2 || (args - 2)->m_type == KindOfInt64) &&
857 (count <= 1 || (args - 1)->m_type == KindOfObject) &&
858 IS_STRING_TYPE((args - 0)->m_type)) {
859 rv->m_type = KindOfBoolean;
860 Object defVal1 = uninit_null();
861 rv->m_data.num = (fh_apc_bin_loadfile(&args[-0].m_data, (count > 1) ? &args[-1].m_data : (Value*)(&defVal1), (count > 2) ? (long)(args[-2].m_data.num) : (long)(0), (count > 3) ? (long)(args[-3].m_data.num) : (long)(0))) ? 1LL : 0LL;
862 } else {
863 fg1_apc_bin_loadfile(rv, ar, count);
865 } else {
866 throw_wrong_arguments_nr("apc_bin_loadfile", count, 1, 4, 1);
867 rv->m_data.num = 0LL;
868 rv->m_type = KindOfNull;
870 frame_free_locals_no_this_inl(ar, 4);
871 memcpy(&ar->m_r, rv, sizeof(TypedValue));
872 return &ar->m_r;
875 } // namespace HPHP