codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / runtime / ext / std / ext_std_intrinsics.cpp
blobb2f3bb11dbb97e873a1deae25668bf7528b64423
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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 +----------------------------------------------------------------------+
17 #include "hphp/runtime/ext/std/ext_std_intrinsics.h"
19 #include "hphp/runtime/base/builtin-functions.h"
20 #include "hphp/runtime/base/surprise-flags.h"
21 #include "hphp/runtime/vm/jit/inlining-decider.h"
22 #include "hphp/runtime/vm/vm-regs.h"
24 namespace HPHP {
25 ///////////////////////////////////////////////////////////////////////////////
27 void HHVM_FUNCTION(disable_inlining, const Variant& function) {
28 ObjectData* obj = nullptr;
29 HPHP::Class* cls = nullptr;
30 StringData* invName = nullptr;
31 const HPHP::Func* f = vm_decode_function(function, GetCallerFrame(),
32 false, obj, cls, invName,
33 DecodeFlags::LookupOnly);
34 if (f == nullptr || f->isAbstract()) {
35 raise_warning("disable_inlining(): undefined function");
36 return;
39 jit::InliningDecider::forbidInliningOf(f);
42 void HHVM_FUNCTION(trigger_oom, bool oom) {
43 if (oom) setSurpriseFlag(MemExceededFlag);
46 void StandardExtension::initIntrinsics() {
47 if (!RuntimeOption::EnableIntrinsicsExtension) return;
49 HHVM_FALIAS(__hhvm_intrinsics\\disable_inlining, disable_inlining);
50 HHVM_FALIAS(__hhvm_intrinsics\\trigger_oom, trigger_oom);
51 loadSystemlib("std_intrinsics");
54 ///////////////////////////////////////////////////////////////////////////////
55 } // namespace HPHP