Move vmfp, vmsp, and vmpc into RDS
[hiphop-php.git] / hphp / runtime / base / rds-header.h
blob1d1fb963e34162465275cfaf00626a518611bd1c
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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_RUNTIME_RDS_HEADER_H_
18 #define incl_HPHP_RUNTIME_RDS_HEADER_H_
20 #include <atomic>
21 #include <cstddef>
23 #include "hphp/runtime/base/rds.h"
24 #include "hphp/runtime/base/types.h"
25 #include "hphp/runtime/vm/bytecode.h"
27 namespace HPHP {
30 * Do not access this struct directly from RDS::header(). Use the accessors in
31 * runtime/vm/vm-regs.h.
33 struct VMRegs {
34 /* VM evaluation stack. Grows down in memory in multiples of 16 bytes - the
35 * size of a TypedValue. */
36 Stack stack;
38 /* VM frame pointer. Contains information about the current executing
39 * function, class context, caller, and a base pointer for accessing local
40 * variables. */
41 ActRec* fp;
43 /* VM program counter. Points to the beginning of the currently executing
44 * bytecode instruction. */
45 PC pc;
48 namespace RDS {
51 * Statically layed-out header that goes at the front of RDS.
53 struct Header {
55 * Surprise flags. May be written by other threads. At various
56 * points, the runtime will check whether this word is non-zero, and
57 * if so go to a slow path to handle unusual conditions (e.g. OOM).
59 std::atomic<ssize_t> conditionFlags;
61 VMRegs vmRegs;
65 * Access to the statically layed out header.
67 inline Header* header() {
68 return static_cast<Header*>(tl_base);
71 constexpr ptrdiff_t kConditionFlagsOff = offsetof(Header, conditionFlags);
72 constexpr ptrdiff_t kVmRegsOff = offsetof(Header, vmRegs);
73 constexpr ptrdiff_t kVmspOff = kVmRegsOff + offsetof(VMRegs, stack) +
74 Stack::topOfStackOffset();
75 constexpr ptrdiff_t kVmfpOff = kVmRegsOff + offsetof(VMRegs, fp);
76 constexpr ptrdiff_t kVmpcOff = kVmRegsOff + offsetof(VMRegs, pc);
78 } }
80 #endif