js/src/jit/Registers.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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_Registers_h
michael@0 8 #define jit_Registers_h
michael@0 9
michael@0 10 #include "mozilla/Array.h"
michael@0 11
michael@0 12 #include "jit/IonTypes.h"
michael@0 13 #if defined(JS_CODEGEN_X86)
michael@0 14 # include "jit/x86/Architecture-x86.h"
michael@0 15 #elif defined(JS_CODEGEN_X64)
michael@0 16 # include "jit/x64/Architecture-x64.h"
michael@0 17 #elif defined(JS_CODEGEN_ARM)
michael@0 18 # include "jit/arm/Architecture-arm.h"
michael@0 19 #elif defined(JS_CODEGEN_MIPS)
michael@0 20 # include "jit/mips/Architecture-mips.h"
michael@0 21 #else
michael@0 22 # error "Unknown architecture!"
michael@0 23 #endif
michael@0 24
michael@0 25 namespace js {
michael@0 26 namespace jit {
michael@0 27
michael@0 28 struct Register {
michael@0 29 typedef Registers Codes;
michael@0 30 typedef Codes::Code Code;
michael@0 31 Code code_;
michael@0 32
michael@0 33 static Register FromCode(uint32_t i) {
michael@0 34 JS_ASSERT(i < Registers::Total);
michael@0 35 Register r = { (Registers::Code)i };
michael@0 36 return r;
michael@0 37 }
michael@0 38 static Register FromName(const char *name) {
michael@0 39 Registers::Code code = Registers::FromName(name);
michael@0 40 Register r = { code };
michael@0 41 return r;
michael@0 42 }
michael@0 43 Code code() const {
michael@0 44 JS_ASSERT((uint32_t)code_ < Registers::Total);
michael@0 45 return code_;
michael@0 46 }
michael@0 47 const char *name() const {
michael@0 48 return Registers::GetName(code());
michael@0 49 }
michael@0 50 bool operator ==(const Register &other) const {
michael@0 51 return code_ == other.code_;
michael@0 52 }
michael@0 53 bool operator !=(const Register &other) const {
michael@0 54 return code_ != other.code_;
michael@0 55 }
michael@0 56 bool volatile_() const {
michael@0 57 return !!((1 << code()) & Registers::VolatileMask);
michael@0 58 }
michael@0 59 };
michael@0 60
michael@0 61 struct FloatRegister {
michael@0 62 typedef FloatRegisters Codes;
michael@0 63 typedef Codes::Code Code;
michael@0 64
michael@0 65 Code code_;
michael@0 66
michael@0 67 static FloatRegister FromCode(uint32_t i) {
michael@0 68 JS_ASSERT(i < FloatRegisters::Total);
michael@0 69 FloatRegister r = { (FloatRegisters::Code)i };
michael@0 70 return r;
michael@0 71 }
michael@0 72 static FloatRegister FromName(const char *name) {
michael@0 73 FloatRegisters::Code code = FloatRegisters::FromName(name);
michael@0 74 FloatRegister r = { code };
michael@0 75 return r;
michael@0 76 }
michael@0 77 Code code() const {
michael@0 78 JS_ASSERT((uint32_t)code_ < FloatRegisters::Total);
michael@0 79 return code_;
michael@0 80 }
michael@0 81 const char *name() const {
michael@0 82 return FloatRegisters::GetName(code());
michael@0 83 }
michael@0 84 bool operator ==(const FloatRegister &other) const {
michael@0 85 return code_ == other.code_;
michael@0 86 }
michael@0 87 bool operator !=(const FloatRegister &other) const {
michael@0 88 return code_ != other.code_;
michael@0 89 }
michael@0 90 bool volatile_() const {
michael@0 91 return !!((1 << code()) & FloatRegisters::VolatileMask);
michael@0 92 }
michael@0 93 };
michael@0 94
michael@0 95 class RegisterDump
michael@0 96 {
michael@0 97 protected: // Silence Clang warning.
michael@0 98 mozilla::Array<uintptr_t, Registers::Total> regs_;
michael@0 99 mozilla::Array<double, FloatRegisters::Total> fpregs_;
michael@0 100
michael@0 101 public:
michael@0 102 static size_t offsetOfRegister(Register reg) {
michael@0 103 return offsetof(RegisterDump, regs_) + reg.code() * sizeof(uintptr_t);
michael@0 104 }
michael@0 105 static size_t offsetOfRegister(FloatRegister reg) {
michael@0 106 return offsetof(RegisterDump, fpregs_) + reg.code() * sizeof(double);
michael@0 107 }
michael@0 108 };
michael@0 109
michael@0 110 // Information needed to recover machine register state.
michael@0 111 class MachineState
michael@0 112 {
michael@0 113 mozilla::Array<uintptr_t *, Registers::Total> regs_;
michael@0 114 mozilla::Array<double *, FloatRegisters::Total> fpregs_;
michael@0 115
michael@0 116 public:
michael@0 117 static MachineState FromBailout(mozilla::Array<uintptr_t, Registers::Total> &regs,
michael@0 118 mozilla::Array<double, FloatRegisters::Total> &fpregs);
michael@0 119
michael@0 120 void setRegisterLocation(Register reg, uintptr_t *up) {
michael@0 121 regs_[reg.code()] = up;
michael@0 122 }
michael@0 123 void setRegisterLocation(FloatRegister reg, double *dp) {
michael@0 124 fpregs_[reg.code()] = dp;
michael@0 125 }
michael@0 126
michael@0 127 bool has(Register reg) const {
michael@0 128 return regs_[reg.code()] != nullptr;
michael@0 129 }
michael@0 130 bool has(FloatRegister reg) const {
michael@0 131 return fpregs_[reg.code()] != nullptr;
michael@0 132 }
michael@0 133 uintptr_t read(Register reg) const {
michael@0 134 return *regs_[reg.code()];
michael@0 135 }
michael@0 136 double read(FloatRegister reg) const {
michael@0 137 return *fpregs_[reg.code()];
michael@0 138 }
michael@0 139 void write(Register reg, uintptr_t value) const {
michael@0 140 *regs_[reg.code()] = value;
michael@0 141 }
michael@0 142 };
michael@0 143
michael@0 144 } // namespace jit
michael@0 145 } // namespace js
michael@0 146
michael@0 147 #endif /* jit_Registers_h */

mercurial