sync the repo
[hiphop-php.git] / hphp / hhbbc / optimize.h
blob7771571f9e28005e4a59c3e8d56cd94adb41477e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
16 #pragma once
18 #include "hphp/hhbbc/context.h"
20 namespace HPHP::HHBBC {
22 //////////////////////////////////////////////////////////////////////
24 struct Index;
25 struct FuncAnalysis;
26 struct Bytecode;
27 struct BlockUpdateInfo;
29 using BlockUpdates = CompactVector<std::pair<BlockId, CompressedBlockUpdate>>;
32 * Use information from an analyze call to perform various
33 * optimizations on a function.
35 * The Index should be unchanged since the one that was provided to
36 * the corresponding analyze_func call.
38 * This routine may modify the php::Blocks attached to the passed-in
39 * php::Func, and may renumber the php::Func's locals, but won't update
40 * any of the func's other metadata.
42 void optimize_func(const Index&, FuncAnalysis&&, php::WideFunc&);
44 enum class UpdateBCResult {
45 None, // No changes
46 Changed, // Changes
47 ChangedAnalyze // Changes, and should analyze this function again
49 UpdateBCResult update_bytecode(php::WideFunc&,
50 BlockUpdates,
51 FuncAnalysis* = nullptr);
54 * Return a bytecode to generate the value in cell
56 Bytecode gen_constant(const TypedValue& cell);
58 //////////////////////////////////////////////////////////////////////