diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit/StupidAllocator.h | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit/StupidAllocator.h')
-rw-r--r-- | js/src/jit/StupidAllocator.h | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/js/src/jit/StupidAllocator.h b/js/src/jit/StupidAllocator.h new file mode 100644 index 000000000..053aa0595 --- /dev/null +++ b/js/src/jit/StupidAllocator.h @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sts=4 et sw=4 tw=99: + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef jit_StupidAllocator_h +#define jit_StupidAllocator_h + +#include "jit/RegisterAllocator.h" + +// Simple register allocator that only carries registers within basic blocks. + +namespace js { +namespace jit { + +class StupidAllocator : public RegisterAllocator +{ + static const uint32_t MAX_REGISTERS = AnyRegister::Total; + static const uint32_t MISSING_ALLOCATION = UINT32_MAX; + + struct AllocatedRegister { + AnyRegister reg; + + // The type of the value in the register. + LDefinition::Type type; + + // Virtual register this physical reg backs, or MISSING_ALLOCATION. + uint32_t vreg; + + // id of the instruction which most recently used this register. + uint32_t age; + + // Whether the physical register is not synced with the backing stack slot. + bool dirty; + + void set(uint32_t vreg, LInstruction* ins = nullptr, bool dirty = false) { + this->vreg = vreg; + this->age = ins ? ins->id() : 0; + this->dirty = dirty; + } + }; + + // Active allocation for the current code position. + mozilla::Array<AllocatedRegister, MAX_REGISTERS> registers; + uint32_t registerCount; + + // Type indicating an index into registers. + typedef uint32_t RegisterIndex; + + // Information about each virtual register. + Vector<LDefinition*, 0, SystemAllocPolicy> virtualRegisters; + + public: + StupidAllocator(MIRGenerator* mir, LIRGenerator* lir, LIRGraph& graph) + : RegisterAllocator(mir, lir, graph) + { + } + + MOZ_MUST_USE bool go(); + + private: + MOZ_MUST_USE bool init(); + + void syncForBlockEnd(LBlock* block, LInstruction* ins); + void allocateForInstruction(LInstruction* ins); + void allocateForDefinition(LInstruction* ins, LDefinition* def); + + LAllocation* stackLocation(uint32_t vreg); + + RegisterIndex registerIndex(AnyRegister reg); + + AnyRegister ensureHasRegister(LInstruction* ins, uint32_t vreg); + RegisterIndex allocateRegister(LInstruction* ins, uint32_t vreg); + + void syncRegister(LInstruction* ins, RegisterIndex index); + void evictRegister(LInstruction* ins, RegisterIndex index); + void evictAliasedRegister(LInstruction* ins, RegisterIndex index); + void loadRegister(LInstruction* ins, uint32_t vreg, RegisterIndex index, LDefinition::Type type); + + RegisterIndex findExistingRegister(uint32_t vreg); + + bool allocationRequiresRegister(const LAllocation* alloc, AnyRegister reg); + bool registerIsReserved(LInstruction* ins, AnyRegister reg); +}; + +} // namespace jit +} // namespace js + +#endif /* jit_StupidAllocator_h */ |