js/src/jit/StupidAllocator.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.

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * vim: set ts=8 sts=4 et sw=4 tw=99:
     3  * This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this
     5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef jit_StupidAllocator_h
     8 #define jit_StupidAllocator_h
    10 #include "jit/RegisterAllocator.h"
    12 // Simple register allocator that only carries registers within basic blocks.
    14 namespace js {
    15 namespace jit {
    17 class StupidAllocator : public RegisterAllocator
    18 {
    19     static const uint32_t MAX_REGISTERS = Registers::Allocatable + FloatRegisters::Allocatable;
    20     static const uint32_t MISSING_ALLOCATION = UINT32_MAX;
    22     struct AllocatedRegister {
    23         AnyRegister reg;
    25         // The type of the value in the register.
    26         LDefinition::Type type;
    28         // Virtual register this physical reg backs, or MISSING_ALLOCATION.
    29         uint32_t vreg;
    31         // id of the instruction which most recently used this register.
    32         uint32_t age;
    34         // Whether the physical register is not synced with the backing stack slot.
    35         bool dirty;
    37         void set(uint32_t vreg, LInstruction *ins = nullptr, bool dirty = false) {
    38             this->vreg = vreg;
    39             this->age = ins ? ins->id() : 0;
    40             this->dirty = dirty;
    41         }
    42     };
    44     // Active allocation for the current code position.
    45     mozilla::Array<AllocatedRegister, MAX_REGISTERS> registers;
    46     uint32_t registerCount;
    48     // Type indicating an index into registers.
    49     typedef uint32_t RegisterIndex;
    51     // Information about each virtual register.
    52     Vector<LDefinition*, 0, SystemAllocPolicy> virtualRegisters;
    54   public:
    55     StupidAllocator(MIRGenerator *mir, LIRGenerator *lir, LIRGraph &graph)
    56       : RegisterAllocator(mir, lir, graph)
    57     {
    58     }
    60     bool go();
    62   private:
    63     bool init();
    65     void syncForBlockEnd(LBlock *block, LInstruction *ins);
    66     void allocateForInstruction(LInstruction *ins);
    67     void allocateForDefinition(LInstruction *ins, LDefinition *def);
    69     LAllocation *stackLocation(uint32_t vreg);
    71     RegisterIndex registerIndex(AnyRegister reg);
    73     AnyRegister ensureHasRegister(LInstruction *ins, uint32_t vreg);
    74     RegisterIndex allocateRegister(LInstruction *ins, uint32_t vreg);
    76     void syncRegister(LInstruction *ins, RegisterIndex index);
    77     void evictRegister(LInstruction *ins, RegisterIndex index);
    78     void loadRegister(LInstruction *ins, uint32_t vreg, RegisterIndex index, LDefinition::Type type);
    80     RegisterIndex findExistingRegister(uint32_t vreg);
    82     bool allocationRequiresRegister(const LAllocation *alloc, AnyRegister reg);
    83     bool registerIsReserved(LInstruction *ins, AnyRegister reg);
    84 };
    86 } // namespace jit
    87 } // namespace js
    89 #endif /* jit_StupidAllocator_h */

mercurial