Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=8 sts=4 et sw=4 tw=99: |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef jit_Snapshot_h |
michael@0 | 8 | #define jit_Snapshot_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/Alignment.h" |
michael@0 | 11 | |
michael@0 | 12 | #include "jsalloc.h" |
michael@0 | 13 | #include "jsbytecode.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "jit/CompactBuffer.h" |
michael@0 | 16 | #include "jit/IonTypes.h" |
michael@0 | 17 | #include "jit/Registers.h" |
michael@0 | 18 | |
michael@0 | 19 | #include "js/HashTable.h" |
michael@0 | 20 | |
michael@0 | 21 | namespace js { |
michael@0 | 22 | namespace jit { |
michael@0 | 23 | |
michael@0 | 24 | class RValueAllocation; |
michael@0 | 25 | |
michael@0 | 26 | // A Recover Value Allocation mirror what is known at compiled time as being the |
michael@0 | 27 | // MIRType and the LAllocation. This is read out of the snapshot to recover the |
michael@0 | 28 | // value which would be there if this frame was an interpreter frame instead of |
michael@0 | 29 | // an Ion frame. |
michael@0 | 30 | // |
michael@0 | 31 | // It is used with the SnapshotIterator to recover a Value from the stack, |
michael@0 | 32 | // spilled registers or the list of constant of the compiled script. |
michael@0 | 33 | // |
michael@0 | 34 | // Unit tests are located in jsapi-tests/testJitRValueAlloc.cpp. |
michael@0 | 35 | class RValueAllocation |
michael@0 | 36 | { |
michael@0 | 37 | public: |
michael@0 | 38 | |
michael@0 | 39 | // See RValueAllocation encoding in Snapshots.cpp |
michael@0 | 40 | enum Mode |
michael@0 | 41 | { |
michael@0 | 42 | CONSTANT = 0x00, |
michael@0 | 43 | CST_UNDEFINED = 0x01, |
michael@0 | 44 | CST_NULL = 0x02, |
michael@0 | 45 | DOUBLE_REG = 0x03, |
michael@0 | 46 | FLOAT32_REG = 0x04, |
michael@0 | 47 | FLOAT32_STACK = 0x05, |
michael@0 | 48 | #if defined(JS_NUNBOX32) |
michael@0 | 49 | UNTYPED_REG_REG = 0x06, |
michael@0 | 50 | UNTYPED_REG_STACK = 0x07, |
michael@0 | 51 | UNTYPED_STACK_REG = 0x08, |
michael@0 | 52 | UNTYPED_STACK_STACK = 0x09, |
michael@0 | 53 | #elif defined(JS_PUNBOX64) |
michael@0 | 54 | UNTYPED_REG = 0x06, |
michael@0 | 55 | UNTYPED_STACK = 0x07, |
michael@0 | 56 | #endif |
michael@0 | 57 | // The JSValueType is packed in the Mode. |
michael@0 | 58 | TYPED_REG_MIN = 0x10, |
michael@0 | 59 | TYPED_REG_MAX = 0x17, |
michael@0 | 60 | TYPED_REG = TYPED_REG_MIN, |
michael@0 | 61 | |
michael@0 | 62 | // The JSValueType is packed in the Mode. |
michael@0 | 63 | TYPED_STACK_MIN = 0x18, |
michael@0 | 64 | TYPED_STACK_MAX = 0x1f, |
michael@0 | 65 | TYPED_STACK = TYPED_STACK_MIN, |
michael@0 | 66 | |
michael@0 | 67 | INVALID = 0x100, |
michael@0 | 68 | }; |
michael@0 | 69 | |
michael@0 | 70 | // See Payload encoding in Snapshots.cpp |
michael@0 | 71 | enum PayloadType { |
michael@0 | 72 | PAYLOAD_NONE, |
michael@0 | 73 | PAYLOAD_INDEX, |
michael@0 | 74 | PAYLOAD_STACK_OFFSET, |
michael@0 | 75 | PAYLOAD_GPR, |
michael@0 | 76 | PAYLOAD_FPU, |
michael@0 | 77 | PAYLOAD_PACKED_TAG |
michael@0 | 78 | }; |
michael@0 | 79 | |
michael@0 | 80 | struct Layout { |
michael@0 | 81 | PayloadType type1; |
michael@0 | 82 | PayloadType type2; |
michael@0 | 83 | const char *name; |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | private: |
michael@0 | 87 | Mode mode_; |
michael@0 | 88 | |
michael@0 | 89 | // Additional information to recover the content of the allocation. |
michael@0 | 90 | union Payload { |
michael@0 | 91 | uint32_t index; |
michael@0 | 92 | int32_t stackOffset; |
michael@0 | 93 | Register gpr; |
michael@0 | 94 | FloatRegister fpu; |
michael@0 | 95 | JSValueType type; |
michael@0 | 96 | }; |
michael@0 | 97 | |
michael@0 | 98 | Payload arg1_; |
michael@0 | 99 | Payload arg2_; |
michael@0 | 100 | |
michael@0 | 101 | static Payload payloadOfIndex(uint32_t index) { |
michael@0 | 102 | Payload p; |
michael@0 | 103 | p.index = index; |
michael@0 | 104 | return p; |
michael@0 | 105 | } |
michael@0 | 106 | static Payload payloadOfStackOffset(int32_t offset) { |
michael@0 | 107 | Payload p; |
michael@0 | 108 | p.stackOffset = offset; |
michael@0 | 109 | return p; |
michael@0 | 110 | } |
michael@0 | 111 | static Payload payloadOfRegister(Register reg) { |
michael@0 | 112 | Payload p; |
michael@0 | 113 | p.gpr = reg; |
michael@0 | 114 | return p; |
michael@0 | 115 | } |
michael@0 | 116 | static Payload payloadOfFloatRegister(FloatRegister reg) { |
michael@0 | 117 | Payload p; |
michael@0 | 118 | p.fpu = reg; |
michael@0 | 119 | return p; |
michael@0 | 120 | } |
michael@0 | 121 | static Payload payloadOfValueType(JSValueType type) { |
michael@0 | 122 | Payload p; |
michael@0 | 123 | p.type = type; |
michael@0 | 124 | return p; |
michael@0 | 125 | } |
michael@0 | 126 | |
michael@0 | 127 | static const Layout &layoutFromMode(Mode mode); |
michael@0 | 128 | |
michael@0 | 129 | static void readPayload(CompactBufferReader &reader, PayloadType t, |
michael@0 | 130 | uint8_t *mode, Payload *p); |
michael@0 | 131 | static void writePayload(CompactBufferWriter &writer, PayloadType t, |
michael@0 | 132 | Payload p); |
michael@0 | 133 | static void writePadding(CompactBufferWriter &writer); |
michael@0 | 134 | static void dumpPayload(FILE *fp, PayloadType t, Payload p); |
michael@0 | 135 | static bool equalPayloads(PayloadType t, Payload lhs, Payload rhs); |
michael@0 | 136 | |
michael@0 | 137 | RValueAllocation(Mode mode, Payload a1, Payload a2) |
michael@0 | 138 | : mode_(mode), |
michael@0 | 139 | arg1_(a1), |
michael@0 | 140 | arg2_(a2) |
michael@0 | 141 | { |
michael@0 | 142 | } |
michael@0 | 143 | |
michael@0 | 144 | RValueAllocation(Mode mode, Payload a1) |
michael@0 | 145 | : mode_(mode), |
michael@0 | 146 | arg1_(a1) |
michael@0 | 147 | { |
michael@0 | 148 | } |
michael@0 | 149 | |
michael@0 | 150 | RValueAllocation(Mode mode) |
michael@0 | 151 | : mode_(mode) |
michael@0 | 152 | { |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | public: |
michael@0 | 156 | RValueAllocation() |
michael@0 | 157 | : mode_(INVALID) |
michael@0 | 158 | { } |
michael@0 | 159 | |
michael@0 | 160 | // DOUBLE_REG |
michael@0 | 161 | static RValueAllocation Double(const FloatRegister ®) { |
michael@0 | 162 | return RValueAllocation(DOUBLE_REG, payloadOfFloatRegister(reg)); |
michael@0 | 163 | } |
michael@0 | 164 | |
michael@0 | 165 | // FLOAT32_REG or FLOAT32_STACK |
michael@0 | 166 | static RValueAllocation Float32(const FloatRegister ®) { |
michael@0 | 167 | return RValueAllocation(FLOAT32_REG, payloadOfFloatRegister(reg)); |
michael@0 | 168 | } |
michael@0 | 169 | static RValueAllocation Float32(int32_t offset) { |
michael@0 | 170 | return RValueAllocation(FLOAT32_STACK, payloadOfStackOffset(offset)); |
michael@0 | 171 | } |
michael@0 | 172 | |
michael@0 | 173 | // TYPED_REG or TYPED_STACK |
michael@0 | 174 | static RValueAllocation Typed(JSValueType type, const Register ®) { |
michael@0 | 175 | JS_ASSERT(type != JSVAL_TYPE_DOUBLE && |
michael@0 | 176 | type != JSVAL_TYPE_MAGIC && |
michael@0 | 177 | type != JSVAL_TYPE_NULL && |
michael@0 | 178 | type != JSVAL_TYPE_UNDEFINED); |
michael@0 | 179 | return RValueAllocation(TYPED_REG, payloadOfValueType(type), |
michael@0 | 180 | payloadOfRegister(reg)); |
michael@0 | 181 | } |
michael@0 | 182 | static RValueAllocation Typed(JSValueType type, int32_t offset) { |
michael@0 | 183 | JS_ASSERT(type != JSVAL_TYPE_MAGIC && |
michael@0 | 184 | type != JSVAL_TYPE_NULL && |
michael@0 | 185 | type != JSVAL_TYPE_UNDEFINED); |
michael@0 | 186 | return RValueAllocation(TYPED_STACK, payloadOfValueType(type), |
michael@0 | 187 | payloadOfStackOffset(offset)); |
michael@0 | 188 | } |
michael@0 | 189 | |
michael@0 | 190 | // UNTYPED |
michael@0 | 191 | #if defined(JS_NUNBOX32) |
michael@0 | 192 | static RValueAllocation Untyped(const Register &type, const Register &payload) { |
michael@0 | 193 | return RValueAllocation(UNTYPED_REG_REG, |
michael@0 | 194 | payloadOfRegister(type), |
michael@0 | 195 | payloadOfRegister(payload)); |
michael@0 | 196 | } |
michael@0 | 197 | |
michael@0 | 198 | static RValueAllocation Untyped(const Register &type, int32_t payloadStackOffset) { |
michael@0 | 199 | return RValueAllocation(UNTYPED_REG_STACK, |
michael@0 | 200 | payloadOfRegister(type), |
michael@0 | 201 | payloadOfStackOffset(payloadStackOffset)); |
michael@0 | 202 | } |
michael@0 | 203 | |
michael@0 | 204 | static RValueAllocation Untyped(int32_t typeStackOffset, const Register &payload) { |
michael@0 | 205 | return RValueAllocation(UNTYPED_STACK_REG, |
michael@0 | 206 | payloadOfStackOffset(typeStackOffset), |
michael@0 | 207 | payloadOfRegister(payload)); |
michael@0 | 208 | } |
michael@0 | 209 | |
michael@0 | 210 | static RValueAllocation Untyped(int32_t typeStackOffset, int32_t payloadStackOffset) { |
michael@0 | 211 | return RValueAllocation(UNTYPED_STACK_STACK, |
michael@0 | 212 | payloadOfStackOffset(typeStackOffset), |
michael@0 | 213 | payloadOfStackOffset(payloadStackOffset)); |
michael@0 | 214 | } |
michael@0 | 215 | |
michael@0 | 216 | #elif defined(JS_PUNBOX64) |
michael@0 | 217 | static RValueAllocation Untyped(const Register ®) { |
michael@0 | 218 | return RValueAllocation(UNTYPED_REG, payloadOfRegister(reg)); |
michael@0 | 219 | } |
michael@0 | 220 | |
michael@0 | 221 | static RValueAllocation Untyped(int32_t stackOffset) { |
michael@0 | 222 | return RValueAllocation(UNTYPED_STACK, payloadOfStackOffset(stackOffset)); |
michael@0 | 223 | } |
michael@0 | 224 | #endif |
michael@0 | 225 | |
michael@0 | 226 | // common constants. |
michael@0 | 227 | static RValueAllocation Undefined() { |
michael@0 | 228 | return RValueAllocation(CST_UNDEFINED); |
michael@0 | 229 | } |
michael@0 | 230 | static RValueAllocation Null() { |
michael@0 | 231 | return RValueAllocation(CST_NULL); |
michael@0 | 232 | } |
michael@0 | 233 | |
michael@0 | 234 | // CONSTANT's index |
michael@0 | 235 | static RValueAllocation ConstantPool(uint32_t index) { |
michael@0 | 236 | return RValueAllocation(CONSTANT, payloadOfIndex(index)); |
michael@0 | 237 | } |
michael@0 | 238 | |
michael@0 | 239 | void writeHeader(CompactBufferWriter &writer, JSValueType type, uint32_t regCode) const; |
michael@0 | 240 | public: |
michael@0 | 241 | static RValueAllocation read(CompactBufferReader &reader); |
michael@0 | 242 | void write(CompactBufferWriter &writer) const; |
michael@0 | 243 | |
michael@0 | 244 | public: |
michael@0 | 245 | Mode mode() const { |
michael@0 | 246 | return mode_; |
michael@0 | 247 | } |
michael@0 | 248 | |
michael@0 | 249 | uint32_t index() const { |
michael@0 | 250 | JS_ASSERT(layoutFromMode(mode()).type1 == PAYLOAD_INDEX); |
michael@0 | 251 | return arg1_.index; |
michael@0 | 252 | } |
michael@0 | 253 | int32_t stackOffset() const { |
michael@0 | 254 | JS_ASSERT(layoutFromMode(mode()).type1 == PAYLOAD_STACK_OFFSET); |
michael@0 | 255 | return arg1_.stackOffset; |
michael@0 | 256 | } |
michael@0 | 257 | Register reg() const { |
michael@0 | 258 | JS_ASSERT(layoutFromMode(mode()).type1 == PAYLOAD_GPR); |
michael@0 | 259 | return arg1_.gpr; |
michael@0 | 260 | } |
michael@0 | 261 | FloatRegister fpuReg() const { |
michael@0 | 262 | JS_ASSERT(layoutFromMode(mode()).type1 == PAYLOAD_FPU); |
michael@0 | 263 | return arg1_.fpu; |
michael@0 | 264 | } |
michael@0 | 265 | JSValueType knownType() const { |
michael@0 | 266 | JS_ASSERT(layoutFromMode(mode()).type1 == PAYLOAD_PACKED_TAG); |
michael@0 | 267 | return arg1_.type; |
michael@0 | 268 | } |
michael@0 | 269 | |
michael@0 | 270 | int32_t stackOffset2() const { |
michael@0 | 271 | JS_ASSERT(layoutFromMode(mode()).type2 == PAYLOAD_STACK_OFFSET); |
michael@0 | 272 | return arg2_.stackOffset; |
michael@0 | 273 | } |
michael@0 | 274 | Register reg2() const { |
michael@0 | 275 | JS_ASSERT(layoutFromMode(mode()).type2 == PAYLOAD_GPR); |
michael@0 | 276 | return arg2_.gpr; |
michael@0 | 277 | } |
michael@0 | 278 | |
michael@0 | 279 | public: |
michael@0 | 280 | void dump(FILE *fp) const; |
michael@0 | 281 | |
michael@0 | 282 | public: |
michael@0 | 283 | bool operator==(const RValueAllocation &rhs) const { |
michael@0 | 284 | if (mode_ != rhs.mode_) |
michael@0 | 285 | return false; |
michael@0 | 286 | |
michael@0 | 287 | const Layout &layout = layoutFromMode(mode()); |
michael@0 | 288 | return equalPayloads(layout.type1, arg1_, rhs.arg1_) && |
michael@0 | 289 | equalPayloads(layout.type2, arg2_, rhs.arg2_); |
michael@0 | 290 | } |
michael@0 | 291 | |
michael@0 | 292 | HashNumber hash() const; |
michael@0 | 293 | |
michael@0 | 294 | struct Hasher |
michael@0 | 295 | { |
michael@0 | 296 | typedef RValueAllocation Key; |
michael@0 | 297 | typedef Key Lookup; |
michael@0 | 298 | static HashNumber hash(const Lookup &v) { |
michael@0 | 299 | return v.hash(); |
michael@0 | 300 | } |
michael@0 | 301 | static bool match(const Key &k, const Lookup &l) { |
michael@0 | 302 | return k == l; |
michael@0 | 303 | } |
michael@0 | 304 | }; |
michael@0 | 305 | }; |
michael@0 | 306 | |
michael@0 | 307 | class RecoverWriter; |
michael@0 | 308 | |
michael@0 | 309 | // Collects snapshots in a contiguous buffer, which is copied into IonScript |
michael@0 | 310 | // memory after code generation. |
michael@0 | 311 | class SnapshotWriter |
michael@0 | 312 | { |
michael@0 | 313 | CompactBufferWriter writer_; |
michael@0 | 314 | CompactBufferWriter allocWriter_; |
michael@0 | 315 | |
michael@0 | 316 | // Map RValueAllocations to an offset in the allocWriter_ buffer. This is |
michael@0 | 317 | // useful as value allocations are repeated frequently. |
michael@0 | 318 | typedef RValueAllocation RVA; |
michael@0 | 319 | typedef HashMap<RVA, uint32_t, RVA::Hasher, SystemAllocPolicy> RValueAllocMap; |
michael@0 | 320 | RValueAllocMap allocMap_; |
michael@0 | 321 | |
michael@0 | 322 | // This is only used to assert sanity. |
michael@0 | 323 | uint32_t allocWritten_; |
michael@0 | 324 | |
michael@0 | 325 | // Used to report size of the snapshot in the spew messages. |
michael@0 | 326 | SnapshotOffset lastStart_; |
michael@0 | 327 | |
michael@0 | 328 | public: |
michael@0 | 329 | bool init(); |
michael@0 | 330 | |
michael@0 | 331 | SnapshotOffset startSnapshot(RecoverOffset recoverOffset, BailoutKind kind); |
michael@0 | 332 | #ifdef TRACK_SNAPSHOTS |
michael@0 | 333 | void trackSnapshot(uint32_t pcOpcode, uint32_t mirOpcode, uint32_t mirId, |
michael@0 | 334 | uint32_t lirOpcode, uint32_t lirId); |
michael@0 | 335 | #endif |
michael@0 | 336 | bool add(const RValueAllocation &slot); |
michael@0 | 337 | |
michael@0 | 338 | uint32_t allocWritten() const { |
michael@0 | 339 | return allocWritten_; |
michael@0 | 340 | } |
michael@0 | 341 | void endSnapshot(); |
michael@0 | 342 | |
michael@0 | 343 | bool oom() const { |
michael@0 | 344 | return writer_.oom() || writer_.length() >= MAX_BUFFER_SIZE || |
michael@0 | 345 | allocWriter_.oom() || allocWriter_.length() >= MAX_BUFFER_SIZE; |
michael@0 | 346 | } |
michael@0 | 347 | |
michael@0 | 348 | size_t listSize() const { |
michael@0 | 349 | return writer_.length(); |
michael@0 | 350 | } |
michael@0 | 351 | const uint8_t *listBuffer() const { |
michael@0 | 352 | return writer_.buffer(); |
michael@0 | 353 | } |
michael@0 | 354 | |
michael@0 | 355 | size_t RVATableSize() const { |
michael@0 | 356 | return allocWriter_.length(); |
michael@0 | 357 | } |
michael@0 | 358 | const uint8_t *RVATableBuffer() const { |
michael@0 | 359 | return allocWriter_.buffer(); |
michael@0 | 360 | } |
michael@0 | 361 | }; |
michael@0 | 362 | |
michael@0 | 363 | class MResumePoint; |
michael@0 | 364 | |
michael@0 | 365 | class RecoverWriter |
michael@0 | 366 | { |
michael@0 | 367 | CompactBufferWriter writer_; |
michael@0 | 368 | |
michael@0 | 369 | uint32_t nframes_; |
michael@0 | 370 | uint32_t framesWritten_; |
michael@0 | 371 | |
michael@0 | 372 | public: |
michael@0 | 373 | SnapshotOffset startRecover(uint32_t frameCount, bool resumeAfter); |
michael@0 | 374 | |
michael@0 | 375 | bool writeFrame(const MResumePoint *rp); |
michael@0 | 376 | |
michael@0 | 377 | void endRecover(); |
michael@0 | 378 | |
michael@0 | 379 | size_t size() const { |
michael@0 | 380 | return writer_.length(); |
michael@0 | 381 | } |
michael@0 | 382 | const uint8_t *buffer() const { |
michael@0 | 383 | return writer_.buffer(); |
michael@0 | 384 | } |
michael@0 | 385 | |
michael@0 | 386 | bool oom() const { |
michael@0 | 387 | return writer_.oom() || writer_.length() >= MAX_BUFFER_SIZE; |
michael@0 | 388 | } |
michael@0 | 389 | }; |
michael@0 | 390 | |
michael@0 | 391 | class RecoverReader; |
michael@0 | 392 | |
michael@0 | 393 | // A snapshot reader reads the entries out of the compressed snapshot buffer in |
michael@0 | 394 | // a script. These entries describe the equivalent interpreter frames at a given |
michael@0 | 395 | // position in JIT code. Each entry is an Ion's value allocations, used to |
michael@0 | 396 | // recover the corresponding Value from an Ion frame. |
michael@0 | 397 | class SnapshotReader |
michael@0 | 398 | { |
michael@0 | 399 | CompactBufferReader reader_; |
michael@0 | 400 | CompactBufferReader allocReader_; |
michael@0 | 401 | const uint8_t* allocTable_; |
michael@0 | 402 | |
michael@0 | 403 | BailoutKind bailoutKind_; |
michael@0 | 404 | uint32_t allocRead_; // Number of slots that have been read. |
michael@0 | 405 | RecoverOffset recoverOffset_; // Offset of the recover instructions. |
michael@0 | 406 | |
michael@0 | 407 | #ifdef TRACK_SNAPSHOTS |
michael@0 | 408 | private: |
michael@0 | 409 | uint32_t pcOpcode_; |
michael@0 | 410 | uint32_t mirOpcode_; |
michael@0 | 411 | uint32_t mirId_; |
michael@0 | 412 | uint32_t lirOpcode_; |
michael@0 | 413 | uint32_t lirId_; |
michael@0 | 414 | |
michael@0 | 415 | public: |
michael@0 | 416 | void readTrackSnapshot(); |
michael@0 | 417 | void spewBailingFrom() const; |
michael@0 | 418 | #endif |
michael@0 | 419 | |
michael@0 | 420 | private: |
michael@0 | 421 | void readSnapshotHeader(); |
michael@0 | 422 | uint32_t readAllocationIndex(); |
michael@0 | 423 | |
michael@0 | 424 | public: |
michael@0 | 425 | SnapshotReader(const uint8_t *snapshots, uint32_t offset, |
michael@0 | 426 | uint32_t RVATableSize, uint32_t listSize); |
michael@0 | 427 | |
michael@0 | 428 | RValueAllocation readAllocation(); |
michael@0 | 429 | void skipAllocation() { |
michael@0 | 430 | readAllocationIndex(); |
michael@0 | 431 | } |
michael@0 | 432 | |
michael@0 | 433 | BailoutKind bailoutKind() const { |
michael@0 | 434 | return bailoutKind_; |
michael@0 | 435 | } |
michael@0 | 436 | RecoverOffset recoverOffset() const { |
michael@0 | 437 | return recoverOffset_; |
michael@0 | 438 | } |
michael@0 | 439 | |
michael@0 | 440 | uint32_t numAllocationsRead() const { |
michael@0 | 441 | return allocRead_; |
michael@0 | 442 | } |
michael@0 | 443 | void resetNumAllocationsRead() { |
michael@0 | 444 | allocRead_ = 0; |
michael@0 | 445 | } |
michael@0 | 446 | }; |
michael@0 | 447 | |
michael@0 | 448 | typedef mozilla::AlignedStorage<4 * sizeof(uint32_t)> RInstructionStorage; |
michael@0 | 449 | class RInstruction; |
michael@0 | 450 | |
michael@0 | 451 | class RecoverReader |
michael@0 | 452 | { |
michael@0 | 453 | CompactBufferReader reader_; |
michael@0 | 454 | |
michael@0 | 455 | // Number of encoded instructions. |
michael@0 | 456 | uint32_t numInstructions_; |
michael@0 | 457 | |
michael@0 | 458 | // Number of instruction read. |
michael@0 | 459 | uint32_t numInstructionsRead_; |
michael@0 | 460 | |
michael@0 | 461 | // True if we need to resume after the Resume Point instruction of the |
michael@0 | 462 | // innermost frame. |
michael@0 | 463 | bool resumeAfter_; |
michael@0 | 464 | |
michael@0 | 465 | // Space is reserved as part of the RecoverReader to avoid allocations of |
michael@0 | 466 | // data which is needed to decode the current instruction. |
michael@0 | 467 | RInstructionStorage rawData_; |
michael@0 | 468 | |
michael@0 | 469 | private: |
michael@0 | 470 | void readRecoverHeader(); |
michael@0 | 471 | void readInstruction(); |
michael@0 | 472 | |
michael@0 | 473 | public: |
michael@0 | 474 | RecoverReader(SnapshotReader &snapshot, const uint8_t *recovers, uint32_t size); |
michael@0 | 475 | |
michael@0 | 476 | bool moreInstructions() const { |
michael@0 | 477 | return numInstructionsRead_ < numInstructions_; |
michael@0 | 478 | } |
michael@0 | 479 | void nextInstruction() { |
michael@0 | 480 | readInstruction(); |
michael@0 | 481 | } |
michael@0 | 482 | |
michael@0 | 483 | const RInstruction *instruction() const { |
michael@0 | 484 | return reinterpret_cast<const RInstruction *>(rawData_.addr()); |
michael@0 | 485 | } |
michael@0 | 486 | |
michael@0 | 487 | bool resumeAfter() const { |
michael@0 | 488 | return resumeAfter_; |
michael@0 | 489 | } |
michael@0 | 490 | }; |
michael@0 | 491 | |
michael@0 | 492 | } |
michael@0 | 493 | } |
michael@0 | 494 | |
michael@0 | 495 | #endif /* jit_Snapshot_h */ |