2 +----------------------------------------------------------------------+
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 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_JIT_VASM_TEXT_H_
18 #define incl_HPHP_JIT_VASM_TEXT_H_
20 #include "hphp/runtime/vm/jit/types.h"
21 #include "hphp/runtime/vm/jit/containers.h"
23 #include "hphp/util/data-block.h"
25 namespace HPHP
{ namespace jit
{
27 ///////////////////////////////////////////////////////////////////////////////
30 * An area into which code is emitted.
32 * This is a light wrapper around CodeBlock, which additionally saves the
33 * original `start' address to measure the size of code emitted.
35 * All Vareas are instantiated by gen-time, so `start' (or `code.base()`) can
36 * be used to detect aliased CodeBlocks when we emit.
39 /* implicit */ Varea(CodeBlock
& cb
)
41 , start(cb
.frontier())
44 bool operator==(const Varea
& area
) const { return start
== area
.start
; }
45 bool operator!=(const Varea
& area
) const { return start
!= area
.start
; }
51 ///////////////////////////////////////////////////////////////////////////////
54 * Represents all the code areas to emit to.
56 * Vtext is a lightweight container for Vareas.
59 explicit Vtext(CodeBlock
& main
, DataBlock
& data
)
63 Vtext(CodeBlock
& main
, CodeBlock
& cold
, DataBlock
& data
)
67 Vtext(CodeBlock
& main
, CodeBlock
& cold
, CodeBlock
& frozen
, DataBlock
& data
)
68 : m_areas
{main
, cold
, frozen
}
71 // Main and frozen aren't allowed to alias each other unless cold is /also/
72 // the same code region.
73 assertx(this->main() != this->frozen() ||
74 this->main() == this->cold());
78 * Get an existing area.
80 const Varea
& area(AreaIndex i
) const;
81 Varea
& area(AreaIndex i
);
82 Varea
& main() { return area(AreaIndex::Main
); }
83 Varea
& cold() { return area(AreaIndex::Cold
); }
84 Varea
& frozen() { return area(AreaIndex::Frozen
); }
86 DataBlock
& data() { return m_data
; }
89 * The vector of areas.
91 const jit::vector
<Varea
>& areas() const { return m_areas
; }
94 jit::vector
<Varea
> m_areas
; // indexed by AreaIndex
98 ///////////////////////////////////////////////////////////////////////////////
102 #include "hphp/runtime/vm/jit/vasm-text-inl.h"