Compare commits
2 Commits
update_0_9
...
regalloc_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c43d4984f | ||
|
|
cfe021ff88 |
134
mozilla/ef/Compiler/RegisterAllocator/BitSet.cpp
Normal file
@@ -0,0 +1,134 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
// Return the next bit after index set to true or -1 if none.
|
||||
//
|
||||
Int32 BitSet::nextOne(Int32 pos) const
|
||||
{
|
||||
++pos;
|
||||
|
||||
if (pos < 0 || Uint32(pos) >= universeSize)
|
||||
return -1;
|
||||
|
||||
Uint32 offset = getWordOffset(pos);
|
||||
Uint8 index = getBitOffset(pos);
|
||||
Word* ptr = &word[offset];
|
||||
Word currentWord = *ptr++ >> index;
|
||||
|
||||
if (currentWord != Word(0)) {
|
||||
while ((currentWord & Word(1)) == 0) {
|
||||
++index;
|
||||
currentWord >>= 1;
|
||||
}
|
||||
return (offset << nBitsInWordLog2) + index;
|
||||
}
|
||||
|
||||
Word* limit = &word[getSizeInWords(universeSize)];
|
||||
while (ptr < limit) {
|
||||
++offset;
|
||||
currentWord = *ptr++;
|
||||
if (currentWord != Word(0)) {
|
||||
index = 0;
|
||||
while ((currentWord & Word(1)) == 0) {
|
||||
++index;
|
||||
currentWord >>= 1;
|
||||
}
|
||||
return (offset << nBitsInWordLog2) + index;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Return the next bit after index set to false or -1 if none.
|
||||
//
|
||||
Int32 BitSet::nextZero(Int32 pos) const
|
||||
{
|
||||
++pos;
|
||||
|
||||
if (pos < 0 || Uint32(pos) >= universeSize)
|
||||
return -1;
|
||||
|
||||
Uint32 offset = getWordOffset(pos);
|
||||
Uint8 index = getBitOffset(pos);
|
||||
Word* ptr = &word[offset];
|
||||
Word currentWord = *ptr++ >> index;
|
||||
|
||||
if (currentWord != Word(~0)) {
|
||||
for (; index < nBitsInWord; ++index) {
|
||||
if ((currentWord & Word(1)) == 0) {
|
||||
Int32 ret = (offset << nBitsInWordLog2) + index;
|
||||
return (Uint32(ret) < universeSize) ? ret : -1;
|
||||
}
|
||||
currentWord >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
Word* limit = &word[getSizeInWords(universeSize)];
|
||||
while (ptr < limit) {
|
||||
++offset;
|
||||
currentWord = *ptr++;
|
||||
if (currentWord != Word(~0)) {
|
||||
for (index = 0; index < nBitsInWord; ++index) {
|
||||
if ((currentWord & Word(1)) == 0) {
|
||||
Int32 ret = (offset << nBitsInWordLog2) + index;
|
||||
return (Uint32(ret) < universeSize) ? ret : -1;
|
||||
}
|
||||
currentWord >>= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
|
||||
// Print the set.
|
||||
//
|
||||
void BitSet::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("[ "));
|
||||
|
||||
for (Int32 i = firstOne(); i != -1; i = nextOne(i)) {
|
||||
Int32 currentBit = i;
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", currentBit));
|
||||
|
||||
Int32 nextBit = nextOne(currentBit);
|
||||
if (nextBit != currentBit + 1) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" "));
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((nextBit != -1) && (nextBit == (currentBit + 1))) {
|
||||
currentBit = nextBit;
|
||||
nextBit = nextOne(nextBit);
|
||||
}
|
||||
|
||||
if (currentBit > (i+1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("-%d ", currentBit));
|
||||
else
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" %d ", currentBit));
|
||||
|
||||
i = currentBit;
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("]\n"));
|
||||
}
|
||||
|
||||
#endif // DEBUG_LOG
|
||||
195
mozilla/ef/Compiler/RegisterAllocator/BitSet.h
Normal file
@@ -0,0 +1,195 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _BITSET_H_
|
||||
#define _BITSET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "Pool.h"
|
||||
#include <string.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// BitSet -
|
||||
|
||||
class BitSet
|
||||
{
|
||||
private:
|
||||
|
||||
#if (PR_BITS_PER_WORD == 64)
|
||||
typedef Uint64 Word;
|
||||
#elif (PR_BITS_PER_WORD == 32)
|
||||
typedef Uint32 Word;
|
||||
#endif
|
||||
|
||||
static const nBitsInWord = PR_BITS_PER_WORD;
|
||||
static const nBytesInWord = PR_BYTES_PER_WORD;
|
||||
static const nBitsInWordLog2 = PR_BITS_PER_WORD_LOG2;
|
||||
static const nBytesInWordLog2 = PR_BYTES_PER_WORD_LOG2;
|
||||
|
||||
// Return the number of Word need to store the universe.
|
||||
static Uint32 getSizeInWords(Uint32 sizeOfUniverse) {return (sizeOfUniverse + (nBitsInWord - 1)) >> nBitsInWordLog2;}
|
||||
// Return the given element offset in its containing Word.
|
||||
static Uint32 getBitOffset(Uint32 element) {return element & (nBitsInWord - 1);}
|
||||
// Return the Word offset for the given element int the universe.
|
||||
static Uint32 getWordOffset(Uint32 element) {return element >> nBitsInWordLog2;}
|
||||
// Return the mask for the given bit index.
|
||||
static Word getMask(Uint8 index) {return Word(1) << index;}
|
||||
|
||||
private:
|
||||
|
||||
Uint32 universeSize; // Size of the universe
|
||||
Word* word; // universe memory.
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
BitSet(const BitSet&);
|
||||
|
||||
// Check if the given set's universe is of the same size than this universe.
|
||||
void checkUniverseCompatibility(const BitSet& set) const {assert(set.universeSize == universeSize);}
|
||||
// Check if pos is valid for this set's universe.
|
||||
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
|
||||
|
||||
public:
|
||||
|
||||
// Create a bitset of universeSize bits.
|
||||
BitSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {word = new(pool) Word[getSizeInWords(universeSize)]; clear();}
|
||||
|
||||
// Return the size of this bitset.
|
||||
Uint32 getSize() const {return universeSize;}
|
||||
|
||||
// Clear the bitset.
|
||||
void clear() {memset(word, 0x00, getSizeInWords(universeSize) << nBytesInWordLog2);}
|
||||
// Clear the bit at index.
|
||||
void clear(Uint32 index) {checkMember(index); word[getWordOffset(index)] &= ~getMask(index);}
|
||||
// Set the bitset.
|
||||
void set() {memset(word, 0xFF, getSizeInWords(universeSize) << nBytesInWordLog2);}
|
||||
// Set the bit at index.
|
||||
void set(Uint32 index) {checkMember(index); word[getWordOffset(index)] |= getMask(index);}
|
||||
// Return true if the bit at index is set.
|
||||
bool test(Uint32 index) const {checkMember(index); return (word[getWordOffset(index)] & getMask(index)) != 0;}
|
||||
// Union with the given bitset.
|
||||
inline void or(const BitSet& set);
|
||||
// Intersection with the given bitset.
|
||||
inline void and(const BitSet& set);
|
||||
// Difference with the given bitset.
|
||||
inline void difference(const BitSet& set);
|
||||
// Copy set.
|
||||
inline BitSet& operator = (const BitSet& set);
|
||||
// Return true if the bitset are identical.
|
||||
friend bool operator == (const BitSet& set1, const BitSet& set2);
|
||||
// Return true if the bitset are different.
|
||||
friend bool operator != (const BitSet& set1, const BitSet& set2);
|
||||
|
||||
// Logical operators.
|
||||
BitSet& operator |= (const BitSet& set) {or(set); return *this;}
|
||||
BitSet& operator &= (const BitSet& set) {and(set); return *this;}
|
||||
BitSet& operator -= (const BitSet& set) {difference(set); return *this;}
|
||||
|
||||
// Return the first bit at set to true or -1 if none.
|
||||
Int32 firstOne() const {return nextOne(-1);}
|
||||
// Return the next bit after index set to true or -1 if none.
|
||||
Int32 nextOne(Int32 pos) const;
|
||||
// Return the first bit at set to false or -1 if none.
|
||||
Int32 firstZero() const {return nextZero(-1);}
|
||||
// Return the next bit after index set to false or -1 if none.
|
||||
Int32 nextZero(Int32 pos) const;
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef Int32 iterator;
|
||||
// Return true if the walk is ordered.
|
||||
static bool isOrdered() {return true;}
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const {return firstOne();}
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const {return nextOne(pos);}
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos == -1;}
|
||||
// Return the element corresponding to the given iterator.
|
||||
Uint32 get(iterator pos) const {return pos;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
// Union with the given bitset.
|
||||
//
|
||||
inline void BitSet::or(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ |= *src++;
|
||||
}
|
||||
|
||||
// Intersection with the given bitset.
|
||||
//
|
||||
inline void BitSet::and(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ &= *src++;
|
||||
}
|
||||
|
||||
// Difference with the given bitset.
|
||||
//
|
||||
inline void BitSet::difference(const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Word* src = set.word;
|
||||
Word* dst = word;
|
||||
Word* limit = &src[getSizeInWords(universeSize)];
|
||||
|
||||
while (src < limit)
|
||||
*dst++ &= ~*src++;
|
||||
}
|
||||
|
||||
// Copy the given set into this set.
|
||||
//
|
||||
inline BitSet& BitSet::operator = (const BitSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
if (this != &set)
|
||||
memcpy(word, set.word, getSizeInWords(universeSize) << nBytesInWordLog2);
|
||||
return *this;
|
||||
}
|
||||
|
||||
// Return true if the given set is identical to this set.
|
||||
inline bool operator == (const BitSet& set1, const BitSet& set2)
|
||||
{
|
||||
set1.checkUniverseCompatibility(set2);
|
||||
|
||||
if (&set1 == &set2)
|
||||
return true;
|
||||
|
||||
return memcmp(set1.word, set2.word, BitSet::getSizeInWords(set1.universeSize) << BitSet::nBytesInWordLog2) == 0;
|
||||
}
|
||||
|
||||
inline bool operator != (const BitSet& set1, const BitSet& set2) {return !(set1 == set2);}
|
||||
|
||||
#endif // _BITSET_H
|
||||
159
mozilla/ef/Compiler/RegisterAllocator/Coalescing.h
Normal file
@@ -0,0 +1,159 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _COALESCING_H_
|
||||
#define _COALESCING_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "SparseSet.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
#if 1
|
||||
// Performing an ultra conservative coalescing meens that when we look at
|
||||
// candidates (source,destination) for coalescing we need to make sure
|
||||
// that the combined interference of the source and destination register
|
||||
// will not exceed the total number of register available for the register
|
||||
// class.
|
||||
#define ULTRA_CONSERVATIVE_COALESCING
|
||||
#else
|
||||
// If we are not doing an ultra conservative coalescing we have to make sure
|
||||
// that the total number of neighbor whose degree is greater than the total
|
||||
// number of register is not greater than the total number of register.
|
||||
#undef ULTRA_CONSERVATIVE_COALESCING
|
||||
#endif
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Coalescing
|
||||
{
|
||||
static bool coalesce(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coalescing<RegisterPressure>::coalesce(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
|
||||
// Initialize the lookup table
|
||||
//
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* newRange = new RegisterName[2 * rangeCount];
|
||||
RegisterName* coalescedRange = &newRange[rangeCount];
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
init(coalescedRange, rangeCount);
|
||||
|
||||
SparseSet interferences(pool, rangeCount);
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
bool removedInstructions = false;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.lndList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
|
||||
// Walk the nodes in the loop nesting depth list.
|
||||
for (Int32 n = nNodes - 1; n >= 0; n--) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
InstructionList::iterator it = instructions.begin();
|
||||
while (!instructions.done(it)) {
|
||||
Instruction& instruction = instructions.get(it);
|
||||
it = instructions.advance(it);
|
||||
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
|
||||
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
|
||||
|
||||
RegisterName source = findRoot(name2range[instruction.getInstructionUseBegin()[0].getRegisterName()], coalescedRange);
|
||||
RegisterName destination = findRoot(name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()], coalescedRange);
|
||||
|
||||
if (source == destination) {
|
||||
instruction.remove();
|
||||
} else if (!iGraph.interfere(source, destination)) {
|
||||
InterferenceVector* sourceVector = iGraph.getInterferenceVector(source);
|
||||
InterferenceVector* destinationVector = iGraph.getInterferenceVector(destination);
|
||||
|
||||
#ifdef ULTRA_CONSERVATIVE_COALESCING
|
||||
interferences.clear();
|
||||
|
||||
InterferenceVector* vector;
|
||||
for (vector = sourceVector; vector != NULL; vector = vector->next) {
|
||||
RegisterName* neighbors = vector->neighbors;
|
||||
for (Uint32 i = 0; i < vector->count; i++)
|
||||
interferences.set(findRoot(neighbors[i], coalescedRange));
|
||||
}
|
||||
for (vector = destinationVector; vector != NULL; vector = vector->next) {
|
||||
RegisterName* neighbors = vector->neighbors;
|
||||
for (Uint32 i = 0; i < vector->count; i++)
|
||||
interferences.set(findRoot(neighbors[i], coalescedRange));
|
||||
}
|
||||
|
||||
Uint32 count = interferences.getSize();
|
||||
#else // ULTRA_CONSERVATIVE_COALESCING
|
||||
trespass("not implemented");
|
||||
Uint32 count = 0;
|
||||
#endif // ULTRA_CONSERVATIVE_COALESCING
|
||||
|
||||
if (count < 6 /* FIX: should get the number from the class */) {
|
||||
// Update the interferences vector.
|
||||
if (sourceVector == NULL) {
|
||||
iGraph.setInterferenceVector(source, destinationVector);
|
||||
sourceVector = destinationVector;
|
||||
} else if (destinationVector == NULL)
|
||||
iGraph.setInterferenceVector(destination, sourceVector);
|
||||
else {
|
||||
InterferenceVector* last = NULL;
|
||||
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next)
|
||||
last = v;
|
||||
assert(last);
|
||||
last->next = destinationVector;
|
||||
iGraph.setInterferenceVector(destination, sourceVector);
|
||||
}
|
||||
// Update the interference matrix.
|
||||
for (InterferenceVector* v = sourceVector; v != NULL; v = v->next) {
|
||||
RegisterName* neighbors = v->neighbors;
|
||||
for (Uint32 i = 0; i < v->count; i++) {
|
||||
RegisterName neighbor = findRoot(neighbors[i], coalescedRange);
|
||||
iGraph.setInterference(neighbor, source);
|
||||
iGraph.setInterference(neighbor, destination);
|
||||
}
|
||||
}
|
||||
|
||||
instruction.remove();
|
||||
coalescedRange[source] = destination;
|
||||
removedInstructions = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerAllocator.rangeCount = compress(registerAllocator.name2range, coalescedRange, registerAllocator.nameCount, rangeCount);
|
||||
delete newRange;
|
||||
|
||||
return removedInstructions;
|
||||
}
|
||||
|
||||
#endif // _COALESCING_H_
|
||||
283
mozilla/ef/Compiler/RegisterAllocator/Coloring.cpp
Normal file
@@ -0,0 +1,283 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NEW_LAURENTM_CODE
|
||||
|
||||
#include "Coloring.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "FastBitSet.h"
|
||||
#include "FastBitMatrix.h"
|
||||
#include "CpuInfo.h"
|
||||
|
||||
bool Coloring::
|
||||
assignRegisters(FastBitMatrix& interferenceMatrix)
|
||||
{
|
||||
PRUint32 *stackPtr = new(pool) PRUint32[vRegManager.count()];
|
||||
|
||||
return select(interferenceMatrix, stackPtr, simplify(interferenceMatrix, stackPtr));
|
||||
}
|
||||
|
||||
PRInt32 Coloring::
|
||||
getLowestSpillCostRegister(FastBitSet& bitset)
|
||||
{
|
||||
PRInt32 lowest = bitset.firstOne();
|
||||
if (lowest != -1)
|
||||
{
|
||||
Flt32 cost = vRegManager.getVirtualRegister(lowest).spillInfo.spillCost;
|
||||
for (PRInt32 r = bitset.nextOne(lowest); r != -1; r = bitset.nextOne(r))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
if (!vReg.spillInfo.infiniteSpillCost && (vReg.spillInfo.spillCost < cost))
|
||||
{
|
||||
cost = vReg.spillInfo.spillCost;
|
||||
lowest = r;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lowest;
|
||||
}
|
||||
|
||||
PRUint32* Coloring::
|
||||
simplify(FastBitMatrix interferenceMatrix, PRUint32* stackPtr)
|
||||
{
|
||||
// first we construct the sets low and high. low contains all nodes of degree
|
||||
// inferior to the number of register available on the processor. All the
|
||||
// nodes with an high degree and a finite spill cost are placed in high.
|
||||
// Nodes of high degree and infinite spill cost are not included in either sets.
|
||||
|
||||
PRUint32 nRegisters = vRegManager.count();
|
||||
FastBitSet low(pool, nRegisters);
|
||||
FastBitSet high(pool, nRegisters);
|
||||
FastBitSet stack(pool, nRegisters);
|
||||
|
||||
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
|
||||
|
||||
if (vReg.getClass() == vrcStackSlot)
|
||||
{
|
||||
stack.set(i);
|
||||
vReg.colorRegister(nRegisters);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vReg.colorInfo.interferenceDegree < NUMBER_OF_REGISTERS)
|
||||
low.set(i);
|
||||
else // if (!vReg.spillInfo.infiniteSpillCost)
|
||||
high.set(i);
|
||||
|
||||
// Set coloring info.
|
||||
vReg.spillInfo.willSpill = false;
|
||||
|
||||
switch(vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
vReg.colorRegister(LAST_GREGISTER + 1);
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
vReg.colorRegister(LAST_FPREGISTER + 1);
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false); // Cannot happen.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// push the stack registers
|
||||
PRInt32 j;
|
||||
for (j = stack.firstOne(); j != -1; j = stack.nextOne(j))
|
||||
*stackPtr++ = j;
|
||||
|
||||
// simplify
|
||||
while (true)
|
||||
{
|
||||
PRInt32 r;
|
||||
while ((r = getLowestSpillCostRegister(low)) != -1)
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
|
||||
/* update low and high */
|
||||
FastBitSet inter(interferenceMatrix.getRow(r), nRegisters);
|
||||
for (j = inter.firstOne(); j != -1; j = inter.nextOne(j))
|
||||
{
|
||||
VirtualRegister& neighbor = vRegManager.getVirtualRegister(j);
|
||||
// if the new interference degree of one of his neighbor becomes
|
||||
// NUMBER_OF_REGISTERS - 1 then it is added to the set 'low'.
|
||||
|
||||
PRUint32 maxInterference = 0;
|
||||
switch (neighbor.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
maxInterference = NUMBER_OF_GREGISTERS;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
maxInterference = NUMBER_OF_FPREGISTERS;
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false);
|
||||
}
|
||||
if ((vRegManager.getVirtualRegister(j).colorInfo.interferenceDegree-- == maxInterference))
|
||||
{
|
||||
high.clear(j);
|
||||
low.set(j);
|
||||
}
|
||||
vReg.colorInfo.interferenceDegree--;
|
||||
interferenceMatrix.clear(r, j);
|
||||
interferenceMatrix.clear(j, r);
|
||||
}
|
||||
low.clear(r);
|
||||
|
||||
// Push this register.
|
||||
*stackPtr++ = r;
|
||||
}
|
||||
if ((r = getLowestSpillCostRegister(high)) != -1)
|
||||
{
|
||||
high.clear(r);
|
||||
low.set(r);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
return stackPtr;
|
||||
}
|
||||
|
||||
bool Coloring::
|
||||
select(FastBitMatrix& interferenceMatrix, PRUint32* stackBase, PRUint32* stackPtr)
|
||||
{
|
||||
PRUint32 nRegisters = vRegManager.count();
|
||||
FastBitSet usedRegisters(NUMBER_OF_REGISTERS + 1); // usedRegisters if used for both GR & FPR.
|
||||
FastBitSet preColoredRegisters(NUMBER_OF_REGISTERS + 1);
|
||||
FastBitSet usedStack(nRegisters + 1);
|
||||
bool success = true;
|
||||
Int32 lastUsedSSR = -1;
|
||||
|
||||
// select
|
||||
while (stackPtr != stackBase)
|
||||
{
|
||||
// Pop one register.
|
||||
PRUint32 r = *--stackPtr;
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(r);
|
||||
|
||||
FastBitSet neighbors(interferenceMatrix.getRow(r), nRegisters);
|
||||
|
||||
if (vReg.getClass() == vrcStackSlot)
|
||||
// Stack slots coloring.
|
||||
{
|
||||
usedStack.clear();
|
||||
|
||||
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
|
||||
usedStack.set(vRegManager.getVirtualRegister(i).getColor());
|
||||
|
||||
Int32 color = usedStack.firstZero();
|
||||
vReg.colorRegister(color);
|
||||
if (color > lastUsedSSR)
|
||||
lastUsedSSR = color;
|
||||
}
|
||||
else
|
||||
// Integer & Floating point register coloring.
|
||||
{
|
||||
usedRegisters.clear();
|
||||
preColoredRegisters.clear();
|
||||
|
||||
for (PRInt32 i = neighbors.firstOne(); i != -1; i = neighbors.nextOne(i))
|
||||
{
|
||||
VirtualRegister& nvReg = vRegManager.getVirtualRegister(i);
|
||||
usedRegisters.set(nvReg.getColor());
|
||||
if (nvReg.isPreColored())
|
||||
preColoredRegisters.set(nvReg.getPreColor());
|
||||
}
|
||||
if (vReg.hasSpecialInterference)
|
||||
usedRegisters |= vReg.specialInterference;
|
||||
|
||||
PRInt8 c = -1;
|
||||
PRInt8 maxColor = 0;
|
||||
PRInt8 firstColor = 0;
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
firstColor = FIRST_GREGISTER;
|
||||
maxColor = LAST_GREGISTER;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
firstColor = FIRST_FPREGISTER;
|
||||
maxColor = LAST_FPREGISTER;
|
||||
break;
|
||||
default:
|
||||
PR_ASSERT(false);
|
||||
}
|
||||
|
||||
if (vReg.isPreColored())
|
||||
{
|
||||
c = vReg.getPreColor();
|
||||
if (usedRegisters.test(c))
|
||||
c = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (c = usedRegisters.nextZero(firstColor - 1); (c >= 0) && (c <= maxColor) && (preColoredRegisters.test(c));
|
||||
c = usedRegisters.nextZero(c)) {}
|
||||
}
|
||||
|
||||
if ((c >= 0) && (c <= maxColor))
|
||||
{
|
||||
vReg.colorRegister(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
VirtualRegister& stackRegister = vRegManager.newVirtualRegister(vrcStackSlot);
|
||||
vReg.equivalentRegister[vrcStackSlot] = &stackRegister;
|
||||
vReg.spillInfo.willSpill = true;
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (success)
|
||||
{
|
||||
for (VirtualRegisterManager::iterator i = vRegManager.begin(); !vRegManager.done(i); i = vRegManager.advance(i))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(i);
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
if (vReg.getColor() > LAST_GREGISTER)
|
||||
PR_ASSERT(false);
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
#if NUMBER_OF_FPREGISTERS != 0
|
||||
if (vReg.getColor() > LAST_FPREGISTER)
|
||||
PR_ASSERT(false);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
vRegManager.nUsedStackSlots = lastUsedSSR + 1;
|
||||
return success;
|
||||
}
|
||||
#endif // NEW_LAURENTM_CODE
|
||||
284
mozilla/ef/Compiler/RegisterAllocator/Coloring.h
Normal file
@@ -0,0 +1,284 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "SparseSet.h"
|
||||
#include "Spilling.h"
|
||||
#include "Splits.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
template <class RegisterPressure>
|
||||
class Coloring
|
||||
{
|
||||
private:
|
||||
static RegisterName* simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack);
|
||||
static bool select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr);
|
||||
|
||||
public:
|
||||
static bool color(RegisterAllocator& registerAllocator);
|
||||
static void finalColoring(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Coloring<RegisterPressure>::finalColoring(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
RegisterName* color = registerAllocator.color;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
usePtr->setRegisterName(color[name2range[usePtr->getRegisterName()]]);
|
||||
#ifdef DEBUG
|
||||
RegisterID rid = usePtr->getRegisterID();
|
||||
setColoredRegister(rid);
|
||||
usePtr->setRegisterID(rid);
|
||||
#endif // DEBUG
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
definePtr->setRegisterName(color[name2range[definePtr->getRegisterName()]]);
|
||||
#ifdef DEBUG
|
||||
RegisterID rid = definePtr->getRegisterID();
|
||||
setColoredRegister(rid);
|
||||
definePtr->setRegisterID(rid);
|
||||
#endif // DEBUG
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coloring<RegisterPressure>::select(RegisterAllocator& registerAllocator, RegisterName* coloringStack, RegisterName* coloringStackPtr)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* color = new RegisterName[rangeCount];
|
||||
registerAllocator.color = color;
|
||||
|
||||
for (Uint32 r = 1; r < rangeCount; r++)
|
||||
color[r] = RegisterName(6); // FIX;
|
||||
|
||||
// Color the preColored registers.
|
||||
//
|
||||
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
|
||||
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
|
||||
if (machinePtr->id != invalidID) {
|
||||
color[name2range[getName(machinePtr->id)]] = machinePtr->color;
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill preColor range %d as %d\n", name2range[getName(machinePtr->id)], machinePtr->color));
|
||||
}
|
||||
|
||||
SpillCost* cost = registerAllocator.spillCost;
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet& spill = *new(pool) SparseSet(pool, rangeCount);
|
||||
registerAllocator.willSpill = &spill;
|
||||
SparseSet neighborColors(pool, 6); // FIX
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
|
||||
bool coloringFailed = false;
|
||||
while (coloringStackPtr > coloringStack) {
|
||||
RegisterName range = *--coloringStackPtr;
|
||||
|
||||
if (!cost[range].infinite && cost[range].cost < 0) {
|
||||
coloringFailed = true;
|
||||
spill.set(range);
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, will spill.\n", range));
|
||||
} else {
|
||||
neighborColors.clear();
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = vector->count - 1; i >= 0; --i) {
|
||||
RegisterName neighborColor = color[vector->neighbors[i]];
|
||||
if (neighborColor < 6) // FIX
|
||||
neighborColors.set(neighborColor);
|
||||
}
|
||||
|
||||
if (neighborColors.getSize() == 6) { // FIX
|
||||
coloringFailed = true;
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tfailed to color %d, ", range));
|
||||
|
||||
if (!Splits<RegisterPressure>::findSplit(registerAllocator, color, range)) {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will spill.\n"));
|
||||
spill.set(range);
|
||||
} else
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("will split.\n"));
|
||||
} else {
|
||||
for (Uint32 i = 0; i < 6; i++) // FIX
|
||||
if (!neighborColors.test(i)) {
|
||||
fprintf(stdout, "\twill color %d as %d\n", range, i);
|
||||
color[range] = RegisterName(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
if (coloringFailed) {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring failed:\n"));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\twill spill: "));
|
||||
spill.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
} else {
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring succeeded:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\trange %d colored as %d\n", i, color[i]));
|
||||
}
|
||||
#endif
|
||||
|
||||
return !coloringFailed;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
RegisterName* Coloring<RegisterPressure>::simplify(RegisterAllocator& registerAllocator, RegisterName* coloringStack)
|
||||
{
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
SpillCost* spillCost = registerAllocator.spillCost;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
|
||||
Uint32* degree = new Uint32[rangeCount];
|
||||
for (RegisterName i = RegisterName(1); i < rangeCount; i = RegisterName(i + 1)) {
|
||||
InterferenceVector* vector = iGraph.getInterferenceVector(i);
|
||||
degree[i] = (vector != NULL) ? vector->count : 0;
|
||||
}
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet low(pool, rangeCount);
|
||||
SparseSet high(pool, rangeCount);
|
||||
SparseSet highInfinite(pool, rangeCount);
|
||||
SparseSet preColored(pool, rangeCount);
|
||||
|
||||
// Get the precolored registers.
|
||||
//
|
||||
VirtualRegisterManager& vrManager = registerAllocator.vrManager;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
PreColoredRegister* machineEnd = vrManager.getMachineRegistersEnd();
|
||||
for (PreColoredRegister* machinePtr = vrManager.getMachineRegistersBegin(); machinePtr < machineEnd; machinePtr++)
|
||||
if (machinePtr->id != invalidID)
|
||||
preColored.set(name2range[getName(machinePtr->id)]);
|
||||
|
||||
// Insert the live ranges in the sets.
|
||||
//
|
||||
for (Uint32 range = 1; range < rangeCount; range++)
|
||||
if (!preColored.test(range))
|
||||
if (degree[range] < 6) // FIX
|
||||
low.set(range);
|
||||
else if (!spillCost[range].infinite)
|
||||
high.set(range);
|
||||
else
|
||||
highInfinite.set(range);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring sets:\n\tlow = "));
|
||||
low.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thigh = "));
|
||||
high.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\thighInfinite = "));
|
||||
highInfinite.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tpreColored = "));
|
||||
preColored.printPretty(UT_LOG_MODULE(RegAlloc));
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
RegisterName* coloringStackPtr = coloringStack;
|
||||
|
||||
while (low.getSize() != 0 || high.getSize() != 0) {
|
||||
while (low.getSize() != 0) {
|
||||
RegisterName range = RegisterName(low.getOne());
|
||||
low.clear(range);
|
||||
*coloringStackPtr++ = range;
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = (vector->count - 1); i >= 0; --i) {
|
||||
RegisterName neighbor = vector->neighbors[i];
|
||||
degree[neighbor]--;
|
||||
|
||||
if (degree[neighbor] < 6) // FIX
|
||||
if (high.test(neighbor)) {
|
||||
high.clear(neighbor);
|
||||
low.set(neighbor);
|
||||
} else if (highInfinite.test(neighbor)) {
|
||||
highInfinite.clear(neighbor);
|
||||
low.set(neighbor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (high.getSize() != 0) {
|
||||
RegisterName best = RegisterName(high.getOne());
|
||||
double bestCost = spillCost[best].cost;
|
||||
double bestDegree = degree[best];
|
||||
|
||||
// Choose the next best candidate.
|
||||
//
|
||||
for (SparseSet::iterator i = high.begin(); !high.done(i); i = high.advance(i)) {
|
||||
RegisterName range = RegisterName(high.get(i));
|
||||
double thisCost = spillCost[range].cost;
|
||||
double thisDegree = degree[range];
|
||||
|
||||
if (thisCost * bestDegree < bestCost * thisDegree) {
|
||||
best = range;
|
||||
bestCost = thisCost;
|
||||
bestDegree = thisDegree;
|
||||
}
|
||||
}
|
||||
|
||||
high.clear(best);
|
||||
low.set(best);
|
||||
}
|
||||
}
|
||||
assert(highInfinite.getSize() == 0);
|
||||
|
||||
delete degree;
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("Coloring stack:\n\t"));
|
||||
for (RegisterName* sp = coloringStack; sp < coloringStackPtr; ++sp)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("%d ", *sp));
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\n"));
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
return coloringStackPtr;
|
||||
}
|
||||
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Coloring<RegisterPressure>::color(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
RegisterName* coloringStack = new RegisterName[registerAllocator.rangeCount];
|
||||
return select(registerAllocator, coloringStack, simplify(registerAllocator, coloringStack));
|
||||
}
|
||||
212
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
|
||||
#include "DominatorGraph.h"
|
||||
|
||||
DominatorGraph::DominatorGraph(ControlGraph& controlGraph) : controlGraph(controlGraph)
|
||||
{
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
GtoV = new Uint32[nNodes + 1];
|
||||
VtoG = new Uint32[nNodes + 1];
|
||||
|
||||
Uint32 v = 1;
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
VtoG[v] = n;
|
||||
GtoV[n] = v++;
|
||||
}
|
||||
|
||||
// Initialize all the 1-based arrays.
|
||||
//
|
||||
parent = new Uint32[v];
|
||||
semi = new Uint32[v];
|
||||
vertex = new Uint32[v];
|
||||
label = new Uint32[v];
|
||||
size = new Uint32[v];
|
||||
ancestor = new Uint32[v];
|
||||
child = new Uint32[v];
|
||||
dom = new Uint32[v];
|
||||
bucket = new DGLinkedList*[v];
|
||||
|
||||
memset(semi, '\0', v * sizeof(Uint32));
|
||||
memset(bucket, '\0', v * sizeof(DGLinkedList*));
|
||||
|
||||
vCount = v;
|
||||
|
||||
build();
|
||||
|
||||
delete parent;
|
||||
delete semi;
|
||||
delete vertex;
|
||||
delete label;
|
||||
delete size;
|
||||
delete ancestor;
|
||||
delete child;
|
||||
delete dom;
|
||||
delete bucket;
|
||||
}
|
||||
|
||||
Uint32 DominatorGraph::DFS(Uint32 vx, Uint32 n)
|
||||
{
|
||||
semi[vx] = ++n;
|
||||
vertex[n] = label[vx] = vx;
|
||||
ancestor[vx] = child[vx] = 0;
|
||||
size[vx] = 1;
|
||||
|
||||
|
||||
ControlNode& node = *controlGraph.dfsList[VtoG[vx]];
|
||||
ControlEdge* successorEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorPtr = node.getSuccessorsBegin(); successorPtr < successorEnd; successorPtr++) {
|
||||
Uint32 w = GtoV[successorPtr->getTarget().dfsNum];
|
||||
if (semi[w] == 0) {
|
||||
parent[w] = vx;
|
||||
n = DFS(w, n);
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
void DominatorGraph::LINK(Uint32 vx, Uint32 w)
|
||||
{
|
||||
Uint32 s = w;
|
||||
|
||||
while (semi[label[w]] < semi[label[child[s]]]) {
|
||||
if (size[s] + size[child[child[s]]] >= (size[child[s]] << 1)) {
|
||||
ancestor[child[s]] = s;
|
||||
child[s] = child[child[s]];
|
||||
} else {
|
||||
size[child[s]] = size[s];
|
||||
s = ancestor[s] = child[s];
|
||||
}
|
||||
}
|
||||
label[s] = label[w];
|
||||
size[vx] += size[w];
|
||||
if(size[vx] < (size[w] << 1)) {
|
||||
Uint32 t = s;
|
||||
s = child[vx];
|
||||
child[vx] = t;
|
||||
}
|
||||
while( s != 0 ) {
|
||||
ancestor[s] = vx;
|
||||
s = child[s];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DominatorGraph::COMPRESS(Uint32 vx)
|
||||
{
|
||||
if(ancestor[ancestor[vx]] != 0) {
|
||||
COMPRESS(ancestor[vx]);
|
||||
if(semi[label[ancestor[vx]]] < semi[label[vx]])
|
||||
label[vx] = label[ancestor[vx]];
|
||||
ancestor[vx] = ancestor[ancestor[vx]];
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 DominatorGraph::EVAL(Uint32 vx)
|
||||
{
|
||||
if(ancestor[vx] == 0)
|
||||
return label[vx];
|
||||
COMPRESS(vx);
|
||||
return (semi[label[ancestor[vx]]] >= semi[label[vx]]) ? label[vx] : label[ancestor[vx]];
|
||||
}
|
||||
|
||||
void DominatorGraph::build()
|
||||
{
|
||||
Uint32 n = DFS(GtoV[0], 0);
|
||||
size[0] = label[0] = semi[0];
|
||||
|
||||
for (Uint32 i = n; i >= 2; i--) {
|
||||
Uint32 w = vertex[i];
|
||||
|
||||
ControlNode& node = *controlGraph.dfsList[VtoG[w]];
|
||||
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
|
||||
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p)) {
|
||||
Uint32 vx = GtoV[predecessors.get(p).getSource().dfsNum];
|
||||
Uint32 u = EVAL(vx);
|
||||
|
||||
if(semi[u] < semi[w])
|
||||
semi[w] = semi[u];
|
||||
}
|
||||
|
||||
DGLinkedList* elem = new DGLinkedList();
|
||||
elem->next = bucket[vertex[semi[w]]];
|
||||
elem->index = w;
|
||||
bucket[vertex[semi[w]]] = elem;
|
||||
|
||||
LINK(parent[w], w);
|
||||
|
||||
elem = bucket[parent[w]];
|
||||
while(elem != NULL) {
|
||||
Uint32 vx = elem->index;
|
||||
Uint32 u = EVAL(vx);
|
||||
dom[vx] = (semi[u] < semi[vx]) ? u : parent[w];
|
||||
elem = elem->next;
|
||||
}
|
||||
}
|
||||
|
||||
memset(size, '\0', n * sizeof(Uint32));
|
||||
Pool& pool = controlGraph.pool;
|
||||
nodes = new(pool) DGNode[n];
|
||||
|
||||
for(Uint32 j = 2; j <= n; j++) {
|
||||
Uint32 w = vertex[j];
|
||||
Uint32 d = dom[w];
|
||||
if(d != vertex[semi[w]]) {
|
||||
d = dom[d];
|
||||
dom[w] = d;
|
||||
}
|
||||
size[d]++;
|
||||
}
|
||||
dom[GtoV[0]] = 0;
|
||||
|
||||
for (Uint32 k = 1; k <= n; k++) {
|
||||
DGNode& node = nodes[VtoG[k]];
|
||||
Uint32 count = size[k];
|
||||
node.successorsEnd = node.successorsBegin = (count) ? new(pool) Uint32[count] : (Uint32*) 0;
|
||||
}
|
||||
|
||||
for (Uint32 l = 2; l <= n; l++)
|
||||
*(nodes[VtoG[dom[l]]].successorsEnd)++ = VtoG[l];
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void DominatorGraph::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Dominator Graph:\n"));
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
for (Uint32 i = 0; i < nNodes; i++) {
|
||||
DGNode& node = nodes[i];
|
||||
if (node.successorsBegin != node.successorsEnd) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tN%d dominates ", i));
|
||||
for (Uint32* successorsPtr = node.successorsBegin; successorsPtr < node.successorsEnd; successorsPtr++)
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d ", *successorsPtr));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
|
||||
|
||||
80
mozilla/ef/Compiler/RegisterAllocator/DominatorGraph.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _DOMINATOR_GRAPH_H_
|
||||
#define _DOMINATOR_GRAPH_H_
|
||||
|
||||
#include "LogModule.h"
|
||||
|
||||
class ControlGraph;
|
||||
|
||||
struct DGNode
|
||||
{
|
||||
Uint32* successorsBegin;
|
||||
Uint32* successorsEnd;
|
||||
};
|
||||
|
||||
struct DGLinkedList
|
||||
{
|
||||
DGLinkedList* next;
|
||||
Uint32 index;
|
||||
};
|
||||
|
||||
class DominatorGraph
|
||||
{
|
||||
private:
|
||||
|
||||
ControlGraph& controlGraph;
|
||||
|
||||
Uint32 vCount;
|
||||
|
||||
Uint32* VtoG;
|
||||
Uint32* GtoV;
|
||||
Uint32* parent;
|
||||
Uint32* semi;
|
||||
Uint32* vertex;
|
||||
Uint32* label;
|
||||
Uint32* size;
|
||||
Uint32* ancestor;
|
||||
Uint32* child;
|
||||
Uint32* dom;
|
||||
DGLinkedList** bucket;
|
||||
DGNode* nodes;
|
||||
|
||||
private:
|
||||
|
||||
void build();
|
||||
|
||||
Uint32 DFS(Uint32 vx, Uint32 n);
|
||||
void LINK(Uint32 vx, Uint32 w);
|
||||
void COMPRESS(Uint32 vx);
|
||||
Uint32 EVAL(Uint32 vx);
|
||||
|
||||
public:
|
||||
|
||||
DominatorGraph(ControlGraph& controlGraph);
|
||||
|
||||
Uint32* getSuccessorsBegin(Uint32 n) const {return nodes[n].successorsBegin;}
|
||||
Uint32* getSuccessorsEnd(Uint32 n) const {return nodes[n].successorsEnd;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
#endif // _DOMINATOR_GRAPH_H_
|
||||
20
mozilla/ef/Compiler/RegisterAllocator/HashSet.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashSet.h"
|
||||
97
mozilla/ef/Compiler/RegisterAllocator/HashSet.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _HASH_SET_H_
|
||||
#define _HASH_SET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include <string.h>
|
||||
|
||||
struct HashSetElement
|
||||
{
|
||||
Uint32 index;
|
||||
HashSetElement* next;
|
||||
};
|
||||
|
||||
class HashSet
|
||||
{
|
||||
private:
|
||||
|
||||
static const hashSize = 64;
|
||||
|
||||
// Return the hash code for the given element index.
|
||||
static Uint32 getHashCode(Uint32 index) {return index & (hashSize - 1);} // Could be better !
|
||||
|
||||
private:
|
||||
|
||||
Pool& allocationPool;
|
||||
HashSetElement** bucket;
|
||||
HashSetElement* free;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
HashSet(const HashSet&);
|
||||
// No copy operator.
|
||||
void operator = (const HashSet&);
|
||||
|
||||
public:
|
||||
|
||||
// Create a new HashSet.
|
||||
inline HashSet(Pool& pool, Uint32 universeSize);
|
||||
|
||||
// Clear the hashset.
|
||||
void clear();
|
||||
// Clear the element for the given index.
|
||||
void clear(Uint32 index);
|
||||
// Set the element for the given index.
|
||||
void set(Uint32 index);
|
||||
// Return true if the element at index is a member.
|
||||
bool test(Uint32 index) const;
|
||||
// Union with the given hashset.
|
||||
inline void or(const HashSet& set);
|
||||
// Intersection with the given hashset.
|
||||
inline void and(const HashSet& set);
|
||||
// Difference with the given hashset.
|
||||
inline void difference(const HashSet& set);
|
||||
|
||||
// Logical operators.
|
||||
HashSet& operator |= (const HashSet& set) {or(set); return *this;}
|
||||
HashSet& operator &= (const HashSet& set) {and(set); return *this;}
|
||||
HashSet& operator -= (const HashSet& set) {difference(set); return *this;}
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef HashSetElement* iterator;
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const;
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const;
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos == NULL;}
|
||||
};
|
||||
|
||||
|
||||
inline HashSet::HashSet(Pool& pool, Uint32 /*universeSize*/)
|
||||
: allocationPool(pool), free(NULL)
|
||||
{
|
||||
bucket = new(pool) HashSetElement*[hashSize];
|
||||
memset(bucket, '\0', sizeof(HashSetElement*));
|
||||
}
|
||||
|
||||
#endif // _HASH_SET_H_
|
||||
213
mozilla/ef/Compiler/RegisterAllocator/IndexedPool.h
Normal file
@@ -0,0 +1,213 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _INDEXED_POOL_H_
|
||||
#define _INDEXED_POOL_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedPool<IndexedObjectSubclass> is an indexed pool of objects. The
|
||||
// template parameter 'IndexedObjectSubclass' must be a subclass of the struct
|
||||
// IndexedObject.
|
||||
//
|
||||
// When the indexed pool is ask to allocate and initialize a new object (using
|
||||
// the operator new(anIndexedPool) it will zero the memory used to store the
|
||||
// object and initialize the field 'index' of this object to its position in
|
||||
// the pool.
|
||||
//
|
||||
// An object allocated by the indexed pool can be freed by calling the method
|
||||
// IndexedPool::release(IndexedElement& objectIndex).
|
||||
//
|
||||
// example:
|
||||
//
|
||||
// IndexedPool<IndexedElement> elementPool;
|
||||
//
|
||||
// IndexedElement& element1 = *new(elementPool) IndexedElement();
|
||||
// IndexedElement& element2 = *new(elementPool) IndexedElement();
|
||||
//
|
||||
// indexedPool.release(element1);
|
||||
// IndexedElement& element3 = *new(elementPool) IndexedElement();
|
||||
//
|
||||
// At this point element1 is no longer a valid object, element2 is at
|
||||
// index 2 and element3 is at index 1.
|
||||
//
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedObject -
|
||||
//
|
||||
|
||||
template<class Object>
|
||||
struct IndexedObject
|
||||
{
|
||||
Uint32 index; // Index in the pool.
|
||||
Object* next; // Used to link IndexedObject together.
|
||||
|
||||
Uint32 getIndex() {return index;}
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// IndexedPool<IndexedObject> -
|
||||
//
|
||||
|
||||
template <class IndexedObject>
|
||||
class IndexedPool
|
||||
{
|
||||
private:
|
||||
|
||||
static const blockSize = 4; // Size of one block.
|
||||
|
||||
Uint32 nBlocks; // Number of blocks in the pool.
|
||||
IndexedObject** block; // Array of block pointers.
|
||||
IndexedObject* freeObjects; // Chained list of free IndexedObjects.
|
||||
Uint32 nextIndex; // Index of the next free object in the last block.
|
||||
|
||||
private:
|
||||
|
||||
void allocateAnotherBlock();
|
||||
IndexedObject& newObject();
|
||||
|
||||
public:
|
||||
|
||||
IndexedPool() : nBlocks(0), block(NULL), freeObjects(NULL), nextIndex(1) {}
|
||||
~IndexedPool();
|
||||
|
||||
IndexedObject& get(Uint32 index) const;
|
||||
void release(IndexedObject& object);
|
||||
|
||||
void setSize(Uint32 size) {assert(size < nextIndex); nextIndex = size;}
|
||||
|
||||
// Return the universe size.
|
||||
Uint32 getSize() {return nextIndex;}
|
||||
|
||||
friend void* operator new(size_t, IndexedPool<IndexedObject>& pool); // Needs to call newObject().
|
||||
};
|
||||
|
||||
// Free all the memory allocated for this object.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedPool<IndexedObject>::~IndexedPool()
|
||||
{
|
||||
for (Uint32 n = 0; n < nBlocks; n++)
|
||||
free(&((IndexedObject **) &block[n][n*blockSize])[-(n + 1)]);
|
||||
}
|
||||
|
||||
// Release the given. This object will be iserted in the chained
|
||||
// list of free IndexedObjects. To minimize the fragmentation the chained list
|
||||
// is ordered by ascending indexes.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void IndexedPool<IndexedObject>::release(IndexedObject& object)
|
||||
{
|
||||
Uint32 index = object.index;
|
||||
IndexedObject* list = freeObjects;
|
||||
|
||||
assert(&object == &get(index)); // Make sure that object is owned by this pool.
|
||||
|
||||
if (list == NULL) { // The list is empty.
|
||||
freeObjects = &object;
|
||||
object.next = NULL;
|
||||
} else { // The list contains at least 1 element.
|
||||
if (index < list->index) { // insert as first element.
|
||||
freeObjects = &object;
|
||||
object.next = list;
|
||||
} else { // Find this object's place.
|
||||
while ((list->next) != NULL && (list->next->index < index))
|
||||
list = list->next;
|
||||
|
||||
object.next = list->next;
|
||||
list->next = &object;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Sanity check to be sure that the list is correctly ordered.
|
||||
for (IndexedObject* obj = freeObjects; obj != NULL; obj = obj->next)
|
||||
if (obj->next != NULL)
|
||||
assert(obj->index < obj->next->index);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Create a new block of IndexedObjects. We will allocate the memory to
|
||||
// store IndexedPool::blockSize IndexedObject and the new Array of block
|
||||
// pointers.
|
||||
// The newly created IndexedObjects will not be initialized.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void IndexedPool<IndexedObject>::allocateAnotherBlock()
|
||||
{
|
||||
void* memory = (void *) malloc((nBlocks + 1) * sizeof(Uint32) + blockSize * sizeof(IndexedObject));
|
||||
|
||||
memcpy(memory, block, nBlocks * sizeof(Uint32));
|
||||
|
||||
block = (IndexedObject **) memory;
|
||||
IndexedObject* objects = (IndexedObject *) &block[nBlocks + 1];
|
||||
|
||||
block[nBlocks] = &objects[-(nBlocks * blockSize)];
|
||||
nBlocks++;
|
||||
}
|
||||
|
||||
// Return the IndexedObject at the position 'index' in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedObject& IndexedPool<IndexedObject>::get(Uint32 index) const
|
||||
{
|
||||
Uint32 blockIndex = index / blockSize;
|
||||
assert(blockIndex < nBlocks);
|
||||
|
||||
return block[blockIndex][index];
|
||||
}
|
||||
|
||||
// Return the reference of an unused object in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
IndexedObject& IndexedPool<IndexedObject>::newObject()
|
||||
{
|
||||
if (freeObjects != NULL) {
|
||||
IndexedObject& newObject = *freeObjects;
|
||||
freeObjects = newObject.next;
|
||||
return newObject;
|
||||
}
|
||||
|
||||
Uint32 nextIndex = this->nextIndex++;
|
||||
Uint32 blockIndex = nextIndex / blockSize;
|
||||
|
||||
while (blockIndex >= nBlocks)
|
||||
allocateAnotherBlock();
|
||||
|
||||
IndexedObject& newObject = block[blockIndex][nextIndex];
|
||||
newObject.index = nextIndex;
|
||||
|
||||
return newObject;
|
||||
}
|
||||
|
||||
// Return the address of the next unsused object in the given
|
||||
// indexed pool. The field index of the newly allocated object
|
||||
// will be initialized to the corresponding index of this object
|
||||
// in the pool.
|
||||
//
|
||||
template <class IndexedObject>
|
||||
void* operator new(size_t size, IndexedPool<IndexedObject>& pool)
|
||||
{
|
||||
assert(size == sizeof(IndexedObject));
|
||||
return (void *) &pool.newObject();
|
||||
}
|
||||
|
||||
#endif // _INDEXED_POOL_H_
|
||||
258
mozilla/ef/Compiler/RegisterAllocator/InterferenceGraph.h
Normal file
@@ -0,0 +1,258 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _INTERFERENCE_GRAPH_H_
|
||||
#define _INTERFERENCE_GRAPH_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "Primitives.h"
|
||||
#include "Instruction.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "SparseSet.h"
|
||||
#include <string.h>
|
||||
|
||||
struct InterferenceVector
|
||||
{
|
||||
Uint32 count;
|
||||
InterferenceVector* next;
|
||||
RegisterName* neighbors;
|
||||
|
||||
InterferenceVector() : count(0), next(NULL) {}
|
||||
};
|
||||
|
||||
class RegisterAllocator;
|
||||
|
||||
template <class RegisterPressure>
|
||||
class InterferenceGraph
|
||||
{
|
||||
private:
|
||||
|
||||
RegisterAllocator& registerAllocator;
|
||||
|
||||
RegisterPressure::Set* interferences;
|
||||
InterferenceVector** vector;
|
||||
Uint32* offset;
|
||||
Uint32 rangeCount;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
InterferenceGraph(const InterferenceGraph&);
|
||||
// No copy operator.
|
||||
void operator = (const InterferenceGraph&);
|
||||
|
||||
// Check if reg is a member of the universe.
|
||||
void checkMember(RegisterName name) {assert(name < rangeCount);}
|
||||
// Return the edge index for the interference between name1 and name2.
|
||||
Uint32 getEdgeIndex(RegisterName name1, RegisterName name2);
|
||||
|
||||
public:
|
||||
InterferenceGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
|
||||
|
||||
// Calculate the interferences.
|
||||
void build();
|
||||
// Return true if reg1 and reg2 interfere.
|
||||
bool interfere(RegisterName name1, RegisterName name2);
|
||||
// Return the interference vector for the given register or NULL if there is none.
|
||||
InterferenceVector* getInterferenceVector(RegisterName name) {return vector[name];}
|
||||
// Set the interference between name1 and name2.
|
||||
void setInterference(RegisterName name1, RegisterName name2);
|
||||
// Set the interference vector for the given register.
|
||||
void setInterferenceVector(RegisterName name, InterferenceVector* v) {vector[name] = v;}
|
||||
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the interferences.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::build()
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
this->rangeCount = rangeCount;
|
||||
|
||||
// Initialize the structures.
|
||||
//
|
||||
offset = new(pool) Uint32[rangeCount + 1];
|
||||
vector = new(pool) InterferenceVector*[rangeCount];
|
||||
memset(vector, '\0', sizeof(InterferenceVector*) * rangeCount);
|
||||
|
||||
Uint32 o = 0;
|
||||
offset[0] = 0;
|
||||
for (Uint32 i = 1; i <= rangeCount; ++i) {
|
||||
offset[i] = o;
|
||||
o += i;
|
||||
}
|
||||
|
||||
interferences = new(pool) RegisterPressure::Set(pool, (rangeCount * rangeCount) / 2);
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
LivenessInfo<RegisterPressure> liveness = Liveness<RegisterPressure>::analysis(controlGraph, rangeCount, name2range);
|
||||
registerAllocator.liveness = liveness;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
currentLive = liveness.liveOut[n];
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
// Handle the copy instruction to avoid unnecessary interference between the 2 registers.
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
|
||||
}
|
||||
|
||||
// Create the interferences.
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName define = name2range[definePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator e = currentLive.begin(); !currentLive.done(e); e = currentLive.advance(e)) {
|
||||
RegisterName live = RegisterName(currentLive.get(e));
|
||||
|
||||
if ((live != define) && !interfere(live, define) && registerAllocator.canInterfere(live, define)) {
|
||||
|
||||
if (vector[define] == NULL)
|
||||
vector[define] = new(pool) InterferenceVector();
|
||||
vector[define]->count++;
|
||||
|
||||
if (vector[live] == NULL)
|
||||
vector[live] = new(pool) InterferenceVector();
|
||||
vector[live]->count++;
|
||||
|
||||
setInterference(live, define);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Now update the liveness.
|
||||
//
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
currentLive.set(name2range[usePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Allocate the memory to store the interferences.
|
||||
//
|
||||
for (Uint32 e = 0; e < rangeCount; e++)
|
||||
if (vector[e] != NULL) {
|
||||
InterferenceVector& v = *vector[e];
|
||||
v.neighbors = new(pool) RegisterName[v.count];
|
||||
v.count = 0;
|
||||
}
|
||||
|
||||
// Initialize the edges.
|
||||
//
|
||||
if (RegisterPressure::Set::isOrdered()) {
|
||||
RegisterName name1 = RegisterName(0);
|
||||
|
||||
for (RegisterPressure::Set::iterator i = interferences->begin(); !interferences->done(i); i = interferences->advance(i)) {
|
||||
Uint32 interferenceIndex = interferences->get(i);
|
||||
|
||||
while(interferenceIndex >= offset[name1 + 1])
|
||||
name1 = RegisterName(name1 + 1);
|
||||
|
||||
assert((interferenceIndex >= offset[name1]) && (interferenceIndex < offset[name1 + 1]));
|
||||
|
||||
RegisterName name2 = RegisterName(interferenceIndex - offset[name1]);
|
||||
|
||||
assert(interfere(name1, name2));
|
||||
|
||||
InterferenceVector& vector1 = *vector[name1];
|
||||
vector1.neighbors[vector1.count++] = name2;
|
||||
|
||||
InterferenceVector& vector2 = *vector[name2];
|
||||
vector2.neighbors[vector2.count++] = name1;
|
||||
}
|
||||
} else {
|
||||
trespass("not Implemented"); // FIX: need one more pass to initialize the vectors.
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
Uint32 InterferenceGraph<RegisterPressure>::getEdgeIndex(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
checkMember(name1); checkMember(name2);
|
||||
assert(name1 != name2); // This is not possible.
|
||||
return (name1 < name2) ? offset[name2] + name1 : offset[name1] + name2;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::setInterference(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
interferences->set(getEdgeIndex(name1, name2));
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool InterferenceGraph<RegisterPressure>::interfere(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
return interferences->test(getEdgeIndex(name1, name2));
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void InterferenceGraph<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Vectors:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
if (vector[i] != NULL) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tvr%d: (", i));
|
||||
for (InterferenceVector* v = vector[i]; v != NULL; v = v->next)
|
||||
for (Uint32 j = 0; j < v->count; j++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%d", v->neighbors[j]));
|
||||
if (v->next != NULL || j != (v->count - 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (","));
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (")\n"));
|
||||
}
|
||||
}
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Interference Matrix:\n"));
|
||||
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
|
||||
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && interfere(name1, name2)) ? '1' : '0'));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _INTERFERENCE_GRAPH_H_
|
||||
87
mozilla/ef/Compiler/RegisterAllocator/LiveRange.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVE_RANGE_H_
|
||||
#define _LIVE_RANGE_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Primitives.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct LiveRange
|
||||
{
|
||||
static void build(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRange<RegisterPressure>::build(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
// Intialize the lookup table.
|
||||
//
|
||||
Uint32 nameCount = registerAllocator.nameCount;
|
||||
RegisterName* nameTable = new(registerAllocator.pool) RegisterName[2*nameCount];
|
||||
RegisterName* rangeName = &nameTable[nameCount];
|
||||
|
||||
init(rangeName, nameCount);
|
||||
|
||||
// Walk the graph.
|
||||
//
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
SparseSet destination(registerAllocator.pool, nameCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
|
||||
destination.clear();
|
||||
for (InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
Instruction& phiNode = phiNodes.get(i);
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
destination.set(findRoot(phiNode.getInstructionDefineBegin()[0].getRegisterName(), rangeName));
|
||||
}
|
||||
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
RegisterName destinationName = phiNode.getInstructionDefineBegin()[0].getRegisterName();
|
||||
RegisterName destinationRoot = findRoot(destinationName, rangeName);
|
||||
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
|
||||
assert(usePtr->isRegister());
|
||||
RegisterName sourceName = usePtr->getRegisterName();
|
||||
RegisterName sourceRoot = findRoot(sourceName, rangeName);
|
||||
|
||||
if (sourceRoot != destinationRoot && !destination.test(sourceRoot))
|
||||
rangeName[sourceRoot] = destinationRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerAllocator.rangeCount = compress(registerAllocator.name2range, rangeName, nameCount, nameCount);
|
||||
}
|
||||
|
||||
#endif // _LIVE_RANGE_H_
|
||||
163
mozilla/ef/Compiler/RegisterAllocator/LiveRangeGraph.h
Normal file
@@ -0,0 +1,163 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVE_RANGE_GRAPH_
|
||||
#define _LIVE_RANGE_GRAPH_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
class RegisterAllocator;
|
||||
|
||||
template <class RegisterPressure>
|
||||
class LiveRangeGraph
|
||||
{
|
||||
private:
|
||||
|
||||
RegisterAllocator& registerAllocator;
|
||||
|
||||
RegisterPressure::Set* edges;
|
||||
Uint32 rangeCount;
|
||||
|
||||
public:
|
||||
//
|
||||
//
|
||||
LiveRangeGraph(RegisterAllocator& registerAllocator) : registerAllocator(registerAllocator) {}
|
||||
|
||||
//
|
||||
//
|
||||
void build();
|
||||
|
||||
//
|
||||
//
|
||||
void addEdge(RegisterName name1, RegisterName name2);
|
||||
|
||||
//
|
||||
//
|
||||
bool haveEdge(RegisterName name1, RegisterName name2);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
//
|
||||
//
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::build()
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
this->rangeCount = rangeCount;
|
||||
|
||||
edges = new(pool) RegisterPressure::Set(pool, rangeCount * rangeCount);
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
LivenessInfo<RegisterPressure>& liveness = registerAllocator.liveness;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
currentLive = liveness.liveOut[n];
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
if ((instruction.getFlags() & ifCopy) != 0) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
currentLive.clear(name2range[useBegin[0].getRegisterName()]);
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName define = name2range[definePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
|
||||
RegisterName live = RegisterName(currentLive.get(l));
|
||||
if (define != live && registerAllocator.canInterfere(define, live))
|
||||
addEdge(define, live);
|
||||
}
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
currentLive.set(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName use = name2range[usePtr->getRegisterName()];
|
||||
|
||||
for (SparseSet::iterator l = currentLive.begin(); !currentLive.done(l); l = currentLive.advance(l)) {
|
||||
RegisterName live = RegisterName(currentLive.get(l));
|
||||
if (use != live && registerAllocator.canInterfere(use, live))
|
||||
addEdge(use, live);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::addEdge(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
assert(name1 != name2);
|
||||
edges->set(name1 * rangeCount + name2);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool LiveRangeGraph<RegisterPressure>::haveEdge(RegisterName name1, RegisterName name2)
|
||||
{
|
||||
assert(name1 != name2);
|
||||
return edges->test(name1 * rangeCount + name2);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void LiveRangeGraph<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Live ranges graph:\n"));
|
||||
for (RegisterName name1 = RegisterName(1); name1 < rangeCount; name1 = RegisterName(name1 + 1)) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\t%d:\t", name1));
|
||||
for (RegisterName name2 = RegisterName(1); name2 < rangeCount; name2 = RegisterName(name2 + 1))
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%c", ((name1 != name2) && haveEdge(name1, name2)) ? '1' : '0'));
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _LIVE_RANGE_GRAPH_
|
||||
21
mozilla/ef/Compiler/RegisterAllocator/Liveness.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Liveness.h"
|
||||
|
||||
301
mozilla/ef/Compiler/RegisterAllocator/Liveness.h
Normal file
@@ -0,0 +1,301 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _LIVENESS_H_
|
||||
#define _LIVENESS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// LivenessInfo -
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct LivenessInfo
|
||||
{
|
||||
RegisterPressure::Set* liveIn;
|
||||
RegisterPressure::Set* liveOut;
|
||||
DEBUG_LOG_ONLY(Uint32 size);
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Liveness
|
||||
//
|
||||
// The liveness is defined by the following data-flow equations:
|
||||
//
|
||||
// LiveIn(n) = LocalLive(n) U (LiveOut(n) - Killed(n)).
|
||||
// LiveOut(n) = U LiveIn(s) (s a successor of n).
|
||||
//
|
||||
// where LocalLive(n) is the set of used registers in the block n, Killed(n)
|
||||
// is the set of defined registers in the block n, LiveIn(n) is the set of
|
||||
// live registers at the begining of the block n and LiveOut(n) is the set
|
||||
// of live registers at the end of the block n.
|
||||
//
|
||||
//
|
||||
// We will compute the liveness analysis in two stages:
|
||||
//
|
||||
// 1- Build LocalLive(n) (wich is an approximation of LiveIn(n)) and Killed(n)
|
||||
// for each block n.
|
||||
// 2- Perform a backward data-flow analysis to propagate the liveness information
|
||||
// through the entire control-flow graph.
|
||||
//
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Liveness
|
||||
{
|
||||
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range);
|
||||
static LivenessInfo<RegisterPressure> analysis(ControlGraph& controlGraph, Uint32 nameCount);
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 rangeCount, const RegisterName* name2range)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Allocate the temporary sets.
|
||||
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
|
||||
// Allocate the globals sets.
|
||||
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, rangeCount);
|
||||
|
||||
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
|
||||
//
|
||||
for (Uint32 n = 0; n < (nNodes - 1); n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLocalLive = liveIn[n];
|
||||
RegisterPressure::Set& currentKilled = killed[n];
|
||||
|
||||
// Find the instructions contributions to the sets LocalLive and Killed.
|
||||
//
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
Uint32 index = name2range[usePtr->getRegisterName()];
|
||||
|
||||
if (!currentKilled.test(index))
|
||||
currentLocalLive.set(index);
|
||||
}
|
||||
|
||||
// If a Virtualregister is 'defined' then we add it to the set Killed.
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentKilled.set(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
|
||||
// control-flow graph.
|
||||
//
|
||||
RegisterPressure::Set temp(pool, rangeCount);
|
||||
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
// For all nodes is this graph except the endNode.
|
||||
for (Int32 n = (nNodes - 2); n >= 0; n--) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLiveIn = liveIn[n];
|
||||
RegisterPressure::Set& currentLiveOut = liveOut[n];
|
||||
|
||||
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
|
||||
// temp will be the new LiveOut(n).
|
||||
Uint32 nSuccessors = node.nSuccessors();
|
||||
if (nSuccessors != 0) {
|
||||
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
|
||||
for (Uint32 s = 1; s < nSuccessors; s++)
|
||||
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
|
||||
} else
|
||||
temp.clear();
|
||||
|
||||
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
|
||||
// new LiveIn(n).
|
||||
if (currentLiveOut != temp) {
|
||||
currentLiveOut = temp;
|
||||
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
|
||||
temp |= currentLiveIn;
|
||||
|
||||
if (currentLiveIn != temp) {
|
||||
currentLiveIn = temp;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(changed);
|
||||
|
||||
LivenessInfo<RegisterPressure> liveness;
|
||||
liveness.liveIn = liveIn;
|
||||
liveness.liveOut = liveOut;
|
||||
DEBUG_LOG_ONLY(liveness.size = nNodes);
|
||||
return liveness;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
LivenessInfo<RegisterPressure> Liveness<RegisterPressure>::analysis(ControlGraph& controlGraph, Uint32 nameCount)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Allocate the temporary sets.
|
||||
RegisterPressure::Set* killed = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
RegisterPressure::Set* usedByPhiNodes = NULL;
|
||||
|
||||
// Allocate the globals sets.
|
||||
RegisterPressure::Set* liveIn = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
RegisterPressure::Set* liveOut = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
|
||||
// First stage of the liveness analysis: Compute the sets LocalLive(stored in LiveIn) and Killed.
|
||||
//
|
||||
for (Uint32 n = 0; n < (nNodes - 1); n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLocalLive = liveIn[n];
|
||||
RegisterPressure::Set& currentKilled = killed[n];
|
||||
|
||||
InstructionList& phiNodes = node.getPhiNodeInstructions();
|
||||
|
||||
if ((usedByPhiNodes == NULL) && !phiNodes.empty())
|
||||
usedByPhiNodes = new(pool) RegisterPressure::Set[nNodes](pool, nameCount);
|
||||
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
InstructionDefine& define = phiNode.getInstructionDefineBegin()[0];
|
||||
currentKilled.set(define.getRegisterName());
|
||||
|
||||
typedef DoublyLinkedList<ControlEdge> ControlEdgeList;
|
||||
const ControlEdgeList& predecessors = node.getPredecessors();
|
||||
ControlEdgeList::iterator p = predecessors.begin();
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++, p = predecessors.advance(p))
|
||||
if (usePtr->isRegister())
|
||||
usedByPhiNodes[predecessors.get(p).getSource().dfsNum].set(usePtr->getRegisterName());
|
||||
}
|
||||
|
||||
// Find the instructions contributions to the sets LocalLive and Killed.
|
||||
//
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
// If a VirtualRegister is 'used' before being 'defined' then we add it to set LocalLive.
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
Uint32 index = usePtr->getRegisterName();
|
||||
|
||||
if (!currentKilled.test(index))
|
||||
currentLocalLive.set(index);
|
||||
}
|
||||
|
||||
// If a Virtualregister is 'defined' then we add it to the set Killed.
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentKilled.set(definePtr->getRegisterName());
|
||||
}
|
||||
}
|
||||
|
||||
// Second stage of the liveness analysis: We propagate the LiveIn & LiveOut through the entire
|
||||
// control-flow graph.
|
||||
//
|
||||
RegisterPressure::Set temp(pool, nameCount);
|
||||
|
||||
bool changed;
|
||||
do {
|
||||
changed = false;
|
||||
|
||||
// For all nodes is this graph except the endNode.
|
||||
for (Int32 n = (nNodes - 2); n >= 0; n--) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
RegisterPressure::Set& currentLiveIn = liveIn[n];
|
||||
RegisterPressure::Set& currentLiveOut = liveOut[n];
|
||||
|
||||
// Compute temp = Union of LiveIn(s) (s a successor of this node) | usedByPhiNodes(n).
|
||||
// temp will be the new LiveOut(n).
|
||||
Uint32 nSuccessors = node.nSuccessors();
|
||||
if (nSuccessors != 0) {
|
||||
temp = liveIn[node.nthSuccessor(0).getTarget().dfsNum];
|
||||
for (Uint32 s = 1; s < nSuccessors; s++)
|
||||
temp |= liveIn[node.nthSuccessor(s).getTarget().dfsNum];
|
||||
} else
|
||||
temp.clear();
|
||||
|
||||
// Insert the phiNodes contribution.
|
||||
if (usedByPhiNodes != NULL)
|
||||
temp |= usedByPhiNodes[n];
|
||||
|
||||
// If temp and LiveOut(n) differ then set LiveOut(n) = temp and recalculate the
|
||||
// new LiveIn(n).
|
||||
if (currentLiveOut != temp) {
|
||||
currentLiveOut = temp;
|
||||
temp -= killed[n]; // FIX: could be optimized with one call to unionDiff !
|
||||
temp |= currentLiveIn;
|
||||
|
||||
if (currentLiveIn != temp) {
|
||||
currentLiveIn = temp;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(changed);
|
||||
|
||||
LivenessInfo<RegisterPressure> liveness;
|
||||
liveness.liveIn = liveIn;
|
||||
liveness.liveOut = liveOut;
|
||||
DEBUG_LOG_ONLY(liveness.size = nNodes);
|
||||
return liveness;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
template <class RegisterPressure>
|
||||
void LivenessInfo<RegisterPressure>::printPretty(LogModuleObject log)
|
||||
{
|
||||
for (Uint32 n = 0; n < size; n++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Node N%d:\n\tliveIn = ", n));
|
||||
liveIn[n].printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\tliveOut = "));
|
||||
liveOut[n].printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
|
||||
#endif // _LIVENESS_H_
|
||||
40
mozilla/ef/Compiler/RegisterAllocator/Makefile
Normal file
@@ -0,0 +1,40 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
MODULE_NAME = RegisterAllocator
|
||||
|
||||
include $(DEPTH)/config/config.mk
|
||||
|
||||
INCLUDES += \
|
||||
-I$(DEPTH)/Utilities/General \
|
||||
-I$(DEPTH)/Utilities/zlib \
|
||||
-I$(DEPTH)/Runtime/ClassReader \
|
||||
-I$(DEPTH)/Runtime/NativeMethods \
|
||||
-I$(DEPTH)/Runtime/System \
|
||||
-I$(DEPTH)/Runtime/ClassInfo \
|
||||
-I$(DEPTH)/Runtime/FileReader \
|
||||
-I$(DEPTH)/Compiler/PrimitiveGraph \
|
||||
-I$(DEPTH)/Compiler/FrontEnd \
|
||||
-I$(DEPTH)/Compiler/Optimizer \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator/md \
|
||||
-I$(DEPTH)/Compiler/CodeGenerator/md/$(CPU_ARCH) \
|
||||
-I$(DEPTH)/Compiler/RegisterAllocator \
|
||||
-I$(DEPTH)/Driver/StandAloneJava \
|
||||
-I$(DEPTH)/Debugger \
|
||||
$(NULL)
|
||||
|
||||
CXXSRCS = \
|
||||
RegisterAllocator.cpp \
|
||||
RegisterAllocatorTools.cpp \
|
||||
DominatorGraph.cpp \
|
||||
VirtualRegister.cpp \
|
||||
BitSet.cpp \
|
||||
SparseSet.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
libs:: $(MODULE)
|
||||
392
mozilla/ef/Compiler/RegisterAllocator/PhiNodeRemover.h
Normal file
@@ -0,0 +1,392 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _PHI_NODE_REMOVER_H_
|
||||
#define _PHI_NODE_REMOVER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "DominatorGraph.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "Liveness.h"
|
||||
#include "Instruction.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "SparseSet.h"
|
||||
#include <string.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterNameNode -
|
||||
|
||||
struct RegisterNameNode
|
||||
{
|
||||
RegisterNameNode* next;
|
||||
RegisterName newName;
|
||||
Uint32 nextPushed;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// CopyData -
|
||||
|
||||
struct CopyData
|
||||
{
|
||||
RegisterName source;
|
||||
RegisterClassKind classKind;
|
||||
Uint32 useCount;
|
||||
bool isLiveOut;
|
||||
RegisterName sourceNameToUse;
|
||||
RegisterName temporaryName;
|
||||
RegisterNameNode* newName;
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// PhiNodeRemover<RegisterPressure> -
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct PhiNodeRemover
|
||||
{
|
||||
// Replace the phi nodes by copy instructions.
|
||||
static void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
};
|
||||
|
||||
// Split some of the critical edges and return true if there are still some
|
||||
// in the graph after that.
|
||||
//
|
||||
static bool splitCriticalEdges(ControlGraph& /*cg*/)
|
||||
{
|
||||
// FIX: not implemented.
|
||||
return true;
|
||||
}
|
||||
|
||||
inline void pushName(Pool& pool, RegisterNameNode** stack, SparseSet& pushed, Uint32* nodeListPointer, RegisterName oldName, RegisterName newName)
|
||||
{
|
||||
RegisterNameNode& newNode = *new(pool) RegisterNameNode();
|
||||
|
||||
if (pushed.test(oldName))
|
||||
(*stack)->newName = newName;
|
||||
else {
|
||||
newNode.newName = newName;
|
||||
newNode.nextPushed = *nodeListPointer;
|
||||
*nodeListPointer = oldName;
|
||||
newNode.next = *stack;
|
||||
*stack = &newNode;
|
||||
pushed.set(oldName);
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void PhiNodeRemover<RegisterPressure>::replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
// Initialize the local variables.
|
||||
//
|
||||
|
||||
// When we insert the copies we will also need to create new VirtualRegisters for
|
||||
// the insertion of temporaries. The maximum number of temporary register will not
|
||||
// exceed the number of phiNodes in the primitive graph.
|
||||
Uint32 nameCount = vrManager.getSize();
|
||||
Uint32 maxNameCount = nameCount;
|
||||
for (Uint32 n = 0; n < nNodes; n++)
|
||||
maxNameCount += nodes[n]->getPhiNodes().length();
|
||||
|
||||
// If the CFG contains some critical edges (backward edge which source has more than one
|
||||
// outgoing edge and destination has more than one incomimg edge) then we need the liveness
|
||||
// information to be able to insert temporary copies.
|
||||
RegisterPressure::Set* liveOut = NULL;
|
||||
if (splitCriticalEdges(controlGraph))
|
||||
liveOut = Liveness<LowRegisterPressure>::analysis(controlGraph, nameCount).liveOut;
|
||||
|
||||
DominatorGraph dGraph(controlGraph);
|
||||
|
||||
SparseSet pushed(pool, maxNameCount);
|
||||
SparseSet destinationList(pool, maxNameCount);
|
||||
SparseSet workList(pool, maxNameCount);
|
||||
|
||||
CopyData* copyStats = new(pool) CopyData[maxNameCount];
|
||||
memset(copyStats, '\0', maxNameCount*sizeof(CopyData));
|
||||
|
||||
struct NodeStack {
|
||||
Uint32* next;
|
||||
Uint32* limit;
|
||||
Uint32 pushedList;
|
||||
};
|
||||
|
||||
// Allocate the node stack and initialize the node stack pointer.
|
||||
NodeStack* nodeStack = new(pool) NodeStack[nNodes + 1];
|
||||
NodeStack* nodeStackPtr = nodeStack;
|
||||
|
||||
// We start by the begin node.
|
||||
Uint32 startNode = 0;
|
||||
Uint32* next = &startNode;
|
||||
Uint32* limit = &startNode + 1;
|
||||
|
||||
while (true) {
|
||||
|
||||
if (next == limit) {
|
||||
// If there are no more node in the sibling, we have to pop the current
|
||||
// frame from the stack and update the copyStats of the pushed nodes.
|
||||
//
|
||||
if (nodeStackPtr == nodeStack)
|
||||
// We are at the bottom of the stack and there are no more nodes
|
||||
// to look at. We are done !
|
||||
break;
|
||||
|
||||
--nodeStackPtr;
|
||||
// We are done with all the children of this node in the dominator tree.
|
||||
// We need to update the copy information of all the new names pushed
|
||||
// during the walk over this node.
|
||||
Uint32 pushedList = nodeStackPtr->pushedList;
|
||||
while (pushedList != 0) {
|
||||
Uint32 nextName = copyStats[pushedList].newName->nextPushed;
|
||||
copyStats[pushedList].newName = copyStats[pushedList].newName->next;
|
||||
pushedList = nextName;
|
||||
}
|
||||
|
||||
// restore the previous frame.
|
||||
next = nodeStackPtr->next;
|
||||
limit = nodeStackPtr->limit;
|
||||
} else {
|
||||
Uint32 currentNode = *next++;
|
||||
Uint32 pushedList = 0;
|
||||
|
||||
|
||||
// Initialize the sets.
|
||||
pushed.clear();
|
||||
destinationList.clear();
|
||||
|
||||
// STEP1:
|
||||
// Walk the instruction list and to replace all the instruction uses with their new name.
|
||||
// If the instruction is a phi node and its defined register is alive at the end of this
|
||||
// block then we push the defined register into the stack.
|
||||
//
|
||||
ControlNode& node = *nodes[currentNode];
|
||||
RegisterPressure::Set* currentLiveOut = (liveOut != NULL) ? &liveOut[currentNode] : (RegisterPressure::Set*) 0;
|
||||
|
||||
InstructionList& phiNodes = node.getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = phiNode.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = phiNode.getInstructionUseBegin(); usePtr < useEnd; usePtr++) {
|
||||
assert(usePtr->isRegister());
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
|
||||
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
|
||||
usePtr->setRegisterName(copyStats[name].newName->newName);
|
||||
}
|
||||
|
||||
if (currentLiveOut != NULL) {
|
||||
// This is a phi node and we have to push its defined name if it is live
|
||||
// at the end of the node. We only need to do this if the CFG has critical edges.
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd() && phiNode.getInstructionDefineBegin()[0].isRegister());
|
||||
RegisterName name = phiNode.getInstructionDefineBegin()[0].getRegisterName();
|
||||
|
||||
if (currentLiveOut->test(name))
|
||||
pushName(pool, &(copyStats[name].newName), pushed, &pushedList, name, name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
|
||||
if (copyStats[name].newName != NULL && copyStats[name].newName->newName != name)
|
||||
usePtr->setRegisterName(copyStats[name].newName->newName);
|
||||
}
|
||||
}
|
||||
|
||||
// STEP2:
|
||||
// Look at this node's successors' phiNodes. We keep track of the number of time
|
||||
// a VR will be used by another copy instruction and insert each definition into the
|
||||
// destinationList. This is the only pass over this node's successors as we will
|
||||
// get all the information we need in the CopyData structures.
|
||||
//
|
||||
ControlEdge* successorEdgeEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorEdgePtr = node.getSuccessorsBegin(); successorEdgePtr < successorEdgeEnd; successorEdgePtr++) {
|
||||
Uint32 useIndex = successorEdgePtr->getIndex();
|
||||
ControlNode& successor = successorEdgePtr->getTarget();
|
||||
|
||||
// Look at its phi nodes. The phi nodes are at the top of the instruction list. We exit
|
||||
// as soon as we find an instruction which is not a phi node
|
||||
InstructionList& phiNodes = successor.getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& phiNode = phiNodes.get(p);
|
||||
|
||||
assert((phiNode.getInstructionUseBegin() + useIndex) < phiNode.getInstructionUseEnd());
|
||||
assert(phiNode.getInstructionDefineBegin() != phiNode.getInstructionDefineEnd());
|
||||
|
||||
InstructionUse& source = phiNode.getInstructionUseBegin()[useIndex];
|
||||
InstructionDefine& destination = phiNode.getInstructionDefineBegin()[0];
|
||||
|
||||
assert(source.isRegister() && destination.isRegister());
|
||||
|
||||
RegisterName sourceName = source.getRegisterName();
|
||||
RegisterName destinationName = destination.getRegisterName();
|
||||
|
||||
// Get the correct name for the source.
|
||||
if (copyStats[sourceName].newName != NULL)
|
||||
sourceName = copyStats[sourceName].newName->newName;
|
||||
|
||||
// Update the CopyData structures.
|
||||
if ((sourceName != rnInvalid) && (sourceName != destinationName)) {
|
||||
copyStats[destinationName].source = sourceName;
|
||||
copyStats[destinationName].classKind = destination.getRegisterClass();
|
||||
copyStats[destinationName].isLiveOut = (currentLiveOut != NULL) ? currentLiveOut->test(destinationName) : false;
|
||||
copyStats[destinationName].sourceNameToUse = destinationName;
|
||||
copyStats[sourceName].sourceNameToUse = sourceName;
|
||||
copyStats[sourceName].useCount++;
|
||||
destinationList.set(destinationName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// STEP3:
|
||||
// Insert into the worklist only the destination registers that will be not used in
|
||||
// another copy instruction in this block.
|
||||
//
|
||||
assert(workList.getSize() == 0);
|
||||
for (SparseSet::iterator d = destinationList.begin(); !destinationList.done(d); d = destinationList.advance(d)) {
|
||||
Uint32 dest = destinationList.get(d);
|
||||
if (copyStats[dest].useCount == 0)
|
||||
workList.set(dest);
|
||||
}
|
||||
|
||||
// STEP4:
|
||||
// Insert the copy instructions.
|
||||
//
|
||||
Uint32 destinationListSize = destinationList.getSize();
|
||||
InstructionList::iterator endOfTheNode = instructions.end();
|
||||
|
||||
// Find the right place to insert the copy instructions.
|
||||
if (destinationListSize != 0)
|
||||
while (instructions.get(endOfTheNode).getFlags() & ifControl)
|
||||
endOfTheNode = instructions.retreat(endOfTheNode);
|
||||
|
||||
while (destinationListSize != 0) {
|
||||
while(workList.getSize()) {
|
||||
RegisterName destinationName = RegisterName(workList.getOne());
|
||||
RegisterName sourceName = copyStats[destinationName].source;
|
||||
|
||||
workList.clear(destinationName);
|
||||
if (copyStats[destinationName].isLiveOut && !copyStats[destinationName].temporaryName) {
|
||||
// Lost copy problem.
|
||||
copyStats[destinationName].isLiveOut = false;
|
||||
|
||||
RegisterName sourceName = destinationName;
|
||||
RegisterClassKind classKind = copyStats[sourceName].classKind;
|
||||
RegisterName destinationName = getName(vrManager.newVirtualRegister(classKind));
|
||||
assert(destinationName < maxNameCount);
|
||||
|
||||
copyStats[destinationName].classKind = classKind;
|
||||
copyStats[sourceName].useCount = 0;
|
||||
|
||||
// We need to insert a copy to a temporary register to keep the
|
||||
// source register valid at the end of the node defining it.
|
||||
// This copy will be inserted right after the phi node defining it.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
Instruction* definingPhiNode = vrManager.getVirtualRegister(from).getDefiningInstruction();
|
||||
assert(definingPhiNode && (definingPhiNode->getFlags() & ifPhiNode) != 0);
|
||||
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*definingPhiNode->getPrimitive(), fromID, toID);
|
||||
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
|
||||
definingPhiNode->getPrimitive()->getContainer()->getInstructions().addFirst(copy);
|
||||
|
||||
copyStats[sourceName].temporaryName = destinationName;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
}
|
||||
|
||||
// Insert the copy instruction at the end of the current node.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
|
||||
RegisterClassKind classKind = copyStats[destinationName].classKind;
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
|
||||
instructions.insertAfter(copy, endOfTheNode);
|
||||
endOfTheNode = instructions.advance(endOfTheNode);
|
||||
|
||||
copyStats[sourceName].useCount = 0;
|
||||
if (destinationList.test(sourceName) && copyStats[sourceName].isLiveOut)
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
copyStats[sourceName].isLiveOut = false;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
|
||||
if (destinationList.test(sourceName))
|
||||
workList.set(sourceName);
|
||||
destinationList.clear(destinationName);
|
||||
}
|
||||
|
||||
destinationListSize = destinationList.getSize();
|
||||
if (destinationListSize != 0) {
|
||||
RegisterName sourceName = RegisterName(destinationList.getOne());
|
||||
RegisterName destinationName;
|
||||
|
||||
if (!copyStats[sourceName].temporaryName) {
|
||||
// Cycle problem.
|
||||
RegisterClassKind classKind = copyStats[sourceName].classKind;
|
||||
destinationName = getName(vrManager.newVirtualRegister(classKind));
|
||||
assert(destinationName < maxNameCount);
|
||||
|
||||
copyStats[destinationName].classKind = classKind;
|
||||
copyStats[sourceName].temporaryName = destinationName;
|
||||
|
||||
// Insert the copy instruction at the end of the current node.
|
||||
RegisterName from = copyStats[sourceName].sourceNameToUse;
|
||||
|
||||
RegisterID fromID = buildRegisterID(from, classKind);
|
||||
RegisterID toID = buildRegisterID(destinationName, classKind);
|
||||
Instruction& copy = emitter.newCopy(*vrManager.getVirtualRegister(from).getDefiningInstruction()->getPrimitive(), fromID, toID);
|
||||
vrManager.getVirtualRegister(destinationName).setDefiningInstruction(copy);
|
||||
instructions.insertAfter(copy, endOfTheNode);
|
||||
endOfTheNode = instructions.advance(endOfTheNode);
|
||||
} else
|
||||
destinationName = copyStats[sourceName].temporaryName;
|
||||
|
||||
copyStats[sourceName].useCount = 0;
|
||||
copyStats[sourceName].isLiveOut = false;
|
||||
copyStats[sourceName].sourceNameToUse = destinationName;
|
||||
pushName(pool, &(copyStats[sourceName].newName), pushed, &pushedList, sourceName, destinationName);
|
||||
|
||||
workList.set(sourceName);
|
||||
}
|
||||
}
|
||||
|
||||
nodeStackPtr->pushedList = pushedList;
|
||||
nodeStackPtr->next = next;
|
||||
nodeStackPtr->limit = limit;
|
||||
++nodeStackPtr;
|
||||
next = dGraph.getSuccessorsBegin(currentNode);
|
||||
limit = dGraph.getSuccessorsEnd(currentNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _PHI_NODE_REMOVER_H_
|
||||
155
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterPressure.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "PhiNodeRemover.h"
|
||||
#include "LiveRange.h"
|
||||
#include "Liveness.h"
|
||||
#include "InterferenceGraph.h"
|
||||
#include "LiveRangeGraph.h"
|
||||
#include "Coalescing.h"
|
||||
#include "Spilling.h"
|
||||
#include "Coloring.h"
|
||||
#include "Splits.h"
|
||||
|
||||
class Pool;
|
||||
class ControlGraph;
|
||||
class VirtualRegisterManager;
|
||||
class InstructionEmitter;
|
||||
|
||||
UT_DEFINE_LOG_MODULE(RegAlloc);
|
||||
|
||||
void RegisterAllocator::allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
{
|
||||
// Insert the phi node instructions. We want to do this to have a single defined register per instruction.
|
||||
// If we keep the PhiNode (as a DataNode) and a PhiNode is of DoubleWordKind then we have to execute
|
||||
// some special code for the high word annotation.
|
||||
//
|
||||
RegisterAllocatorTools::insertPhiNodeInstructions(controlGraph, emitter);
|
||||
|
||||
// Perform some tests on the instruction graph.
|
||||
//
|
||||
DEBUG_ONLY(RegisterAllocatorTools::testTheInstructionGraph(controlGraph, vrManager));
|
||||
|
||||
// Replace the phi node instructions by their equivalent copy instructions.
|
||||
//
|
||||
PhiNodeRemover<LowRegisterPressure>::replacePhiNodes(controlGraph, vrManager, emitter);
|
||||
|
||||
// Do the register allocation.
|
||||
//
|
||||
RegisterAllocator registerAllocator(pool, controlGraph, vrManager, emitter);
|
||||
registerAllocator.doGraphColoring();
|
||||
}
|
||||
|
||||
void RegisterAllocator::doGraphColoring()
|
||||
{
|
||||
// Initialize the liverange map.
|
||||
//
|
||||
initLiveRanges();
|
||||
|
||||
// Build the live ranges. We do this to compress the number of RegisterNames
|
||||
// used in the insterference graph.
|
||||
//
|
||||
LiveRange<LowRegisterPressure>::build(*this);
|
||||
|
||||
// Remove unnecessary copies.
|
||||
//
|
||||
RegisterAllocatorTools::removeUnnecessaryCopies(*this);
|
||||
|
||||
for (Uint8 loop = 0; loop < 10; loop++) {
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********* RegisterAllocator loop %d *********\n", loop));
|
||||
|
||||
while(true) {
|
||||
// Build the interference graph.
|
||||
//
|
||||
iGraph.build();
|
||||
|
||||
// Coalesce the copy instructions.
|
||||
//
|
||||
if (!Coalescing<LowRegisterPressure>::coalesce(*this))
|
||||
break;
|
||||
}
|
||||
|
||||
// Print the interference graph.
|
||||
//
|
||||
DEBUG_LOG_ONLY(iGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
|
||||
|
||||
// Calculate the spill costs.
|
||||
//
|
||||
Spilling<LowRegisterPressure>::calculateSpillCosts(*this);
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSpillCosts(*this));
|
||||
|
||||
// Calculate the split costs.
|
||||
//
|
||||
Splits<LowRegisterPressure>::calculateSplitCosts(*this);
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printSplitCosts(*this));
|
||||
|
||||
// Build the live range graph.
|
||||
//
|
||||
lGraph.build();
|
||||
DEBUG_LOG_ONLY(lGraph.printPretty(UT_LOG_MODULE(RegAlloc)));
|
||||
|
||||
// Color the graph. If it succeeds then we're done with the
|
||||
// register allocation.
|
||||
//
|
||||
if (Coloring<LowRegisterPressure>::color(*this)) {
|
||||
// Write the final colors in the instruction graph.
|
||||
//
|
||||
Coloring<LowRegisterPressure>::finalColoring(*this);
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("********** RegisterAllocator done **********\n"));
|
||||
DEBUG_LOG_ONLY(RegisterAllocatorTools::printInstructions(*this));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to spill some registers.
|
||||
//
|
||||
Spilling<LowRegisterPressure>::insertSpillCode(*this);
|
||||
|
||||
// Insert the split instructions.
|
||||
//
|
||||
Splits<LowRegisterPressure>::insertSplitCode(*this);
|
||||
|
||||
// Update the live ranges.
|
||||
//
|
||||
// FIX
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
RegisterAllocatorTools::updateInstructionGraph(*this);
|
||||
RegisterAllocatorTools::printInstructions(*this);
|
||||
#endif
|
||||
fprintf(stderr, "!!! Coloring failed after 10 loops !!!\n");
|
||||
abort();
|
||||
}
|
||||
|
||||
void RegisterAllocator::initLiveRanges()
|
||||
{
|
||||
Uint32 count = this->nameCount;
|
||||
RegisterName* name2range = new(pool) RegisterName[nameCount];
|
||||
for (RegisterName r = RegisterName(1); r < count; r = RegisterName(r + 1))
|
||||
name2range[r] = r;
|
||||
this->name2range = name2range;
|
||||
rangeCount = count;
|
||||
}
|
||||
88
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocator.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_ALLOCATOR_H_
|
||||
#define _REGISTER_ALLOCATOR_H_
|
||||
|
||||
class Pool;
|
||||
class ControlGraph;
|
||||
class InstructionEmitter;
|
||||
struct SpillCost;
|
||||
struct SplitCost;
|
||||
|
||||
#include "Liveness.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "RegisterPressure.h" // This should included by Backend.cpp
|
||||
#include "InterferenceGraph.h"
|
||||
#include "LiveRangeGraph.h"
|
||||
|
||||
//template <class RegisterPressure>
|
||||
class RegisterAllocator
|
||||
{
|
||||
public:
|
||||
|
||||
Pool& pool; //
|
||||
ControlGraph& controlGraph; //
|
||||
VirtualRegisterManager& vrManager; //
|
||||
InstructionEmitter& emitter; //
|
||||
|
||||
RegisterName* name2range; //
|
||||
RegisterName* color; //
|
||||
SpillCost* spillCost; //
|
||||
SparseSet* willSpill; //
|
||||
SplitCost* splitCost; //
|
||||
NameLinkedList** splitAround; //
|
||||
InterferenceGraph<LowRegisterPressure> iGraph; //
|
||||
LiveRangeGraph<LowRegisterPressure> lGraph; //
|
||||
LivenessInfo<LowRegisterPressure> liveness; //
|
||||
Uint32 nameCount; //
|
||||
Uint32 rangeCount; //
|
||||
bool splitFound; //
|
||||
|
||||
private:
|
||||
|
||||
//
|
||||
//
|
||||
void doGraphColoring();
|
||||
|
||||
public:
|
||||
|
||||
//
|
||||
//
|
||||
inline RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
|
||||
//
|
||||
//
|
||||
bool canInterfere(RegisterName /*name1*/, RegisterName /*name2*/) const {return true;}
|
||||
|
||||
//
|
||||
//
|
||||
void initLiveRanges();
|
||||
|
||||
//
|
||||
//
|
||||
static void allocateRegisters(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter);
|
||||
};
|
||||
|
||||
//
|
||||
//
|
||||
inline RegisterAllocator::RegisterAllocator(Pool& pool, ControlGraph& controlGraph, VirtualRegisterManager& vrManager, InstructionEmitter& emitter)
|
||||
: pool(pool), controlGraph(controlGraph), vrManager(vrManager), emitter(emitter), iGraph(*this), lGraph(*this), nameCount(vrManager.getSize()) {}
|
||||
|
||||
#endif // _REGISTER_ALLOCATOR_H_
|
||||
|
||||
355
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.cpp
Normal file
@@ -0,0 +1,355 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "LogModule.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Primitives.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "Spilling.h"
|
||||
#include "Splits.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
#ifdef DEBUG
|
||||
void RegisterAllocatorTools::testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
|
||||
{
|
||||
// Test the declared VirtualRegisters. The register allocator tries to condense the register universe.
|
||||
// Any gap in the VirtualRegister names will be a loss of efficiency !!!!
|
||||
|
||||
Uint32 nameCount = vrManager.getSize();
|
||||
BitSet registerSeen(controlGraph.pool, nameCount);
|
||||
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
registerSeen.set(usePtr->getRegisterName());
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
registerSeen.set(definePtr->getRegisterName());
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
registerSeen.set(usePtr->getRegisterName());
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
registerSeen.set(definePtr->getRegisterName());
|
||||
}
|
||||
}
|
||||
|
||||
bool renameRegisters = false;
|
||||
for (BitSet::iterator i = registerSeen.nextZero(0); !registerSeen.done(i); i = registerSeen.nextZero(i)) {
|
||||
renameRegisters = true;
|
||||
fprintf(stderr,
|
||||
"WARNING: The VirtualRegister vr%d has been allocated during CodeGeneration but\n"
|
||||
" is never used nor defined by any instruction in the instruction graph\n"
|
||||
" PLEASE FIX \n",
|
||||
i);
|
||||
}
|
||||
if (renameRegisters) {
|
||||
Instruction** definingInstruction = new Instruction*[nameCount];
|
||||
memset(definingInstruction, '\0', nameCount * sizeof(Instruction*));
|
||||
RegisterName* newName = new RegisterName[nameCount];
|
||||
memset(newName, '\0', nameCount * sizeof(RegisterName));
|
||||
RegisterName nextName = RegisterName(1);
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
usePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName name = definePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
definePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName name = usePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
usePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName name = definePtr->getRegisterName();
|
||||
if (newName[name] == rnInvalid) {
|
||||
newName[name] = nextName;
|
||||
definingInstruction[nextName] = vrManager.getVirtualRegister(name).getDefiningInstruction();
|
||||
nextName = RegisterName(nextName + 1);
|
||||
}
|
||||
definePtr->setRegisterName(newName[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vrManager.setSize(nextName);
|
||||
|
||||
for (RegisterName r = RegisterName(1); r < nextName; r = RegisterName(r + 1))
|
||||
vrManager.getVirtualRegister(r).definingInstruction = definingInstruction[r];
|
||||
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("RegisterMap:\n"));
|
||||
for (Uint32 i = 1; i < nameCount; i++)
|
||||
if (newName[i] != 0)
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d becomes vr%d.\n", i, newName[i]));
|
||||
else
|
||||
UT_OBJECTLOG(UT_LOG_MODULE(RegAlloc), PR_LOG_ALWAYS, ("\tvr%d is dead.\n", i));
|
||||
|
||||
|
||||
delete newName;
|
||||
delete definingInstruction;
|
||||
}
|
||||
|
||||
}
|
||||
#endif // DEBUG
|
||||
|
||||
void RegisterAllocatorTools::removeUnnecessaryCopies(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i);) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
i = instructions.advance(i);
|
||||
|
||||
if (instruction.getFlags() & ifCopy) {
|
||||
assert(instruction.getInstructionUseBegin() != instruction.getInstructionUseEnd() && instruction.getInstructionUseBegin()[0].isRegister());
|
||||
assert(instruction.getInstructionDefineBegin() != instruction.getInstructionDefineEnd() && instruction.getInstructionDefineBegin()[0].isRegister());
|
||||
|
||||
RegisterName source = name2range[instruction.getInstructionUseBegin()[0].getRegisterName()];
|
||||
RegisterName destination = name2range[instruction.getInstructionDefineBegin()[0].getRegisterName()];
|
||||
|
||||
if (source == destination)
|
||||
instruction.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegisterAllocatorTools::updateInstructionGraph(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
for (InstructionList::iterator p = phiNodes.begin(); !phiNodes.done(p); p = phiNodes.advance(p)) {
|
||||
Instruction& instruction = phiNodes.get(p);
|
||||
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
for (InstructionUse* usePtr = instruction.getInstructionUseBegin(); usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
usePtr->setRegisterName(name2range[usePtr->getRegisterName()]);
|
||||
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
for (InstructionDefine* definePtr = instruction.getInstructionDefineBegin(); definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
definePtr->setRegisterName(name2range[definePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void RegisterAllocatorTools::insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter)
|
||||
{
|
||||
Pool& pool = controlGraph.pool;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
DoublyLinkedList<PhiNode>& phiNodes = node.getPhiNodes();
|
||||
|
||||
if (!phiNodes.empty()) {
|
||||
|
||||
// Set the index of the incoming edges.
|
||||
Uint32 index = 0;
|
||||
const DoublyLinkedList<ControlEdge>& predecessors = node.getPredecessors();
|
||||
for (DoublyLinkedList<ControlEdge>::iterator p = predecessors.begin(); !predecessors.done(p); p = predecessors.advance(p))
|
||||
predecessors.get(p).setIndex(index++);
|
||||
|
||||
// Insert the phi node instruction in the instruction list.
|
||||
for (DoublyLinkedList<PhiNode>::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
PhiNode& phiNode = phiNodes.get(i);
|
||||
ValueKind kind = phiNode.getKind();
|
||||
|
||||
if (!isStorableKind(kind))
|
||||
continue;
|
||||
|
||||
RegisterClassKind classKind = rckGeneral; // FIX: get class kind from phi node kind.
|
||||
Uint32 nInputs = phiNode.nInputs();
|
||||
|
||||
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
|
||||
|
||||
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drLow);
|
||||
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
|
||||
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drLow);
|
||||
|
||||
node.addPhiNodeInstruction(phiNodeInstruction);
|
||||
|
||||
if (isDoublewordKind(kind)) {
|
||||
PhiNodeInstruction& phiNodeInstruction = *new(pool) PhiNodeInstruction(&phiNode, pool, nInputs);
|
||||
|
||||
emitter.defineProducer(phiNode, phiNodeInstruction, 0, classKind, drHigh);
|
||||
for (Uint32 whichInput = 0; whichInput < nInputs; whichInput++)
|
||||
emitter.useProducer(phiNode.nthInputVariable(whichInput), phiNodeInstruction, whichInput, classKind, drHigh);
|
||||
|
||||
node.addPhiNodeInstruction(phiNodeInstruction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
|
||||
void RegisterAllocatorTools::printSpillCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
SpillCost* cost = registerAllocator.spillCost;
|
||||
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Spill costs:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : ", i));
|
||||
if (cost[i].infinite)
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("infinite\n"));
|
||||
else
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("%f\n", cost[i].cost));
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAllocatorTools::printSplitCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
SplitCost* cost = registerAllocator.splitCost;
|
||||
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("Split costs:\n"));
|
||||
for (Uint32 i = 1; i < rangeCount; i++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\trange %d : loads = %f stores = %f\n", i, cost[i].loads, cost[i].stores));
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterAllocatorTools::printInstructions(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
LogModuleObject log = UT_LOG_MODULE(RegAlloc);
|
||||
ControlNode** nodes = registerAllocator.controlGraph.dfsList;
|
||||
Uint32 nNodes = registerAllocator.controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("N%d:\n", n));
|
||||
|
||||
InstructionList& phiNodes = nodes[n]->getPhiNodeInstructions();
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
|
||||
if (!phiNodes.empty()) {
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" PhiNodes:\n", n));
|
||||
for(InstructionList::iterator i = phiNodes.begin(); !phiNodes.done(i); i = phiNodes.advance(i)) {
|
||||
phiNodes.get(i).printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
if (!instructions.empty())
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, (" Instructions:\n", n));
|
||||
}
|
||||
|
||||
for(InstructionList::iterator i = instructions.begin(); !instructions.done(i); i = instructions.advance(i)) {
|
||||
instructions.get(i).printPretty(log);
|
||||
UT_OBJECTLOG(log, PR_LOG_ALWAYS, ("\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
117
mozilla/ef/Compiler/RegisterAllocator/RegisterAllocatorTools.h
Normal file
@@ -0,0 +1,117 @@
|
||||
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
|
||||
//
|
||||
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
// NETSCAPE COMMUNICATIONS CORPORATION
|
||||
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
|
||||
// Reserved. Use of this Source Code is subject to the terms of the
|
||||
// applicable license agreement from Netscape Communications Corporation.
|
||||
// The copyright notice(s) in this Source Code does not indicate actual or
|
||||
// intended publication of this Source Code.
|
||||
//
|
||||
// $Id: RegisterAllocatorTools.h,v 1.1.2.1 1999-03-02 16:12:05 fur%netscape.com Exp $
|
||||
//
|
||||
|
||||
#ifndef _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
#define _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
|
||||
#include "LogModule.h"
|
||||
#include "RegisterTypes.h"
|
||||
#include <string.h>
|
||||
|
||||
class RegisterAllocator;
|
||||
class ControlGraph;
|
||||
class InstructionEmitter;
|
||||
class VirtualRegisterManager;
|
||||
|
||||
struct RegisterAllocatorTools
|
||||
{
|
||||
//
|
||||
//
|
||||
static void insertPhiNodeInstructions(ControlGraph& controlGraph, InstructionEmitter& emitter);
|
||||
|
||||
//
|
||||
//
|
||||
static void updateInstructionGraph(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void removeUnnecessaryCopies(RegisterAllocator& registerAllocator);
|
||||
|
||||
#ifdef DEBUG
|
||||
//
|
||||
//
|
||||
static void testTheInstructionGraph(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
|
||||
#endif // DEBUG
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
//
|
||||
//
|
||||
static void printInstructions(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void printSpillCosts(RegisterAllocator& registerAllocator);
|
||||
|
||||
//
|
||||
//
|
||||
static void printSplitCosts(RegisterAllocator& registerAllocator);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
//
|
||||
// FIX: this should go in a class (LookupTable ?)
|
||||
//
|
||||
|
||||
inline RegisterName findRoot(RegisterName name, RegisterName* table)
|
||||
{
|
||||
RegisterName* stack = table;
|
||||
RegisterName* stackPtr = stack;
|
||||
|
||||
RegisterName newName;
|
||||
while((newName = table[name]) != name) {
|
||||
*--stackPtr = name;
|
||||
name = newName;
|
||||
}
|
||||
|
||||
while (stackPtr != stack)
|
||||
table[*stackPtr++] = name;
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
inline void init(RegisterName* table, Uint32 nameCount)
|
||||
{
|
||||
for (RegisterName r = RegisterName(0); r < nameCount; r = RegisterName(r + 1))
|
||||
table[r] = r;
|
||||
}
|
||||
|
||||
inline Uint32 compress(RegisterName* name2range, RegisterName* table, Uint32 nameCount, Uint32 tableSize)
|
||||
{
|
||||
RegisterName* liveRange = new RegisterName[tableSize];
|
||||
memset(liveRange, '\0', tableSize * sizeof(RegisterName));
|
||||
|
||||
// Update the lookup table.
|
||||
for (RegisterName r = RegisterName(1); r < tableSize; r = RegisterName(r + 1))
|
||||
findRoot(r, table);
|
||||
|
||||
// Count the liveranges.
|
||||
Uint32 liveRangeCount = 1;
|
||||
for (RegisterName s = RegisterName(1); s < tableSize; s = RegisterName(s + 1))
|
||||
if (table[s] == s)
|
||||
liveRange[s] = RegisterName(liveRangeCount++);
|
||||
|
||||
for (RegisterName t = RegisterName(1); t < nameCount; t = RegisterName(t + 1))
|
||||
name2range[t] = liveRange[table[name2range[t]]];
|
||||
|
||||
return liveRangeCount;
|
||||
}
|
||||
|
||||
inline double doLog10(Uint32 power)
|
||||
{
|
||||
double log = 1.0;
|
||||
while (power--)
|
||||
log *= 10.0;
|
||||
return log;
|
||||
}
|
||||
|
||||
#endif // _REGISTER_ALLOCATOR_TOOLS_H_
|
||||
38
mozilla/ef/Compiler/RegisterAllocator/RegisterAssigner.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_ASSIGNER_H_
|
||||
#define _REGISTER_ASSIGNER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "VirtualRegister.h"
|
||||
|
||||
class FastBitMatrix;
|
||||
|
||||
class RegisterAssigner
|
||||
{
|
||||
protected:
|
||||
VirtualRegisterManager& vRegManager;
|
||||
|
||||
public:
|
||||
RegisterAssigner(VirtualRegisterManager& vrMan) : vRegManager(vrMan) {}
|
||||
|
||||
virtual bool assignRegisters(FastBitMatrix& interferenceMatrix) = 0;
|
||||
};
|
||||
|
||||
#endif /* _REGISTER_ASSIGNER_H_ */
|
||||
25
mozilla/ef/Compiler/RegisterAllocator/RegisterClass.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_CLASS_H_
|
||||
#define _REGISTER_CLASS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "RegisterTypes.h"
|
||||
|
||||
#endif // _REGISTER_CLASS_H_
|
||||
37
mozilla/ef/Compiler/RegisterAllocator/RegisterPressure.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_PRESSURE_H_
|
||||
#define _REGISTER_PRESSURE_H_
|
||||
|
||||
#include "BitSet.h"
|
||||
#include "HashSet.h"
|
||||
|
||||
struct LowRegisterPressure
|
||||
{
|
||||
typedef BitSet Set;
|
||||
static const bool setIsOrdered = true;
|
||||
};
|
||||
|
||||
struct HighRegisterPressure
|
||||
{
|
||||
typedef HashSet Set;
|
||||
static const bool setIsOrdered = false;
|
||||
};
|
||||
|
||||
#endif // _REGISTER_PRESSURE_H_
|
||||
104
mozilla/ef/Compiler/RegisterAllocator/RegisterTypes.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _REGISTER_TYPES_H_
|
||||
#define _REGISTER_TYPES_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterName -
|
||||
//
|
||||
|
||||
enum RegisterName {
|
||||
rnInvalid = 0,
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterClassKind -
|
||||
//
|
||||
|
||||
enum RegisterClassKind {
|
||||
rckInvalid = 0,
|
||||
rckGeneral,
|
||||
rckStackSlot,
|
||||
|
||||
nRegisterClassKind
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterID -
|
||||
//
|
||||
|
||||
enum RegisterID {
|
||||
invalidID = 0
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// RegisterKind -
|
||||
//
|
||||
|
||||
enum RegisterKind {
|
||||
rkCallerSave = 0,
|
||||
rkCalleeSave,
|
||||
};
|
||||
|
||||
struct NameLinkedList {
|
||||
RegisterName name;
|
||||
NameLinkedList* next;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
const registerNameMask = 0x03ffffff;
|
||||
const coloredRegisterMask = 0x04000000;
|
||||
const machineRegisterMask = 0x08000000;
|
||||
const registerClassMask = 0xf0000000;
|
||||
|
||||
const registerNameShift = 0;
|
||||
const coloredRegisterShift = 26;
|
||||
const machineRegisterShift = 27;
|
||||
const registerClassShift = 28;
|
||||
|
||||
#else // DEBUG
|
||||
|
||||
const registerNameMask = 0x0fffffff;
|
||||
const registerClassMask = 0xf0000000;
|
||||
|
||||
const registerNameShift = 0;
|
||||
const registerClassShift = 28;
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
inline RegisterClassKind getClass(RegisterID registerID) {return RegisterClassKind((registerID & registerClassMask) >> registerClassShift);}
|
||||
inline RegisterName getName(RegisterID registerID) {return RegisterName((registerID & registerNameMask) >> registerNameShift);}
|
||||
inline void setClass(RegisterID& registerID, RegisterClassKind classKind) {registerID = RegisterID((registerID & ~registerClassMask) | ((classKind << registerClassShift) & registerClassMask));}
|
||||
inline void setName(RegisterID& registerID, RegisterName name) {assert((name & ~registerNameMask) == 0); registerID = RegisterID((registerID & ~registerNameMask) | ((name << registerNameShift) & registerNameMask));}
|
||||
inline RegisterID buildRegisterID(RegisterName name, RegisterClassKind classKind) {return RegisterID(((classKind << registerClassShift) & registerClassMask) | ((name << registerNameShift) & registerNameMask));}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
inline bool isMachineRegister(RegisterID rid) {return (rid & machineRegisterMask) != 0;}
|
||||
inline void setMachineRegister(RegisterID& rid) {rid = RegisterID(rid | machineRegisterMask);}
|
||||
inline bool isColoredRegister(RegisterID rid) {return (rid & coloredRegisterMask) != 0;}
|
||||
inline void setColoredRegister(RegisterID& rid) {rid = RegisterID(rid | coloredRegisterMask);}
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
#endif // _REGISTER_TYPES_H_
|
||||
32
mozilla/ef/Compiler/RegisterAllocator/SSATools.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "SSATools.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "Liveness.h"
|
||||
|
||||
void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager)
|
||||
{
|
||||
if (!controlGraph.hasBackEdges)
|
||||
return;
|
||||
|
||||
Liveness liveness(controlGraph.pool);
|
||||
liveness.buildLivenessAnalysis(controlGraph, vrManager);
|
||||
}
|
||||
29
mozilla/ef/Compiler/RegisterAllocator/SSATools.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SSA_TOOLS_H_
|
||||
#define _SSA_TOOLS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
|
||||
class ControlGraph;
|
||||
class VirtualRegisterManager;
|
||||
|
||||
extern void replacePhiNodes(ControlGraph& controlGraph, VirtualRegisterManager& vrManager);
|
||||
|
||||
#endif // _SSA_TOOLS_H_
|
||||
37
mozilla/ef/Compiler/RegisterAllocator/SparseSet.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "SparseSet.h"
|
||||
#include "BitSet.h"
|
||||
#include "Pool.h"
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
//
|
||||
void SparseSet::printPretty(LogModuleObject log)
|
||||
{
|
||||
Pool pool;
|
||||
BitSet set(pool, universeSize);
|
||||
|
||||
for (Uint32 i = 0; i < count; i++)
|
||||
set.set(node[i].element);
|
||||
|
||||
set.printPretty(log);
|
||||
}
|
||||
#endif // DEBUG_LOG
|
||||
168
mozilla/ef/Compiler/RegisterAllocator/SparseSet.h
Normal file
@@ -0,0 +1,168 @@
|
||||
// -*- mode:C++; tab-width:4; truncate-lines:t -*-
|
||||
//
|
||||
// CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
|
||||
// NETSCAPE COMMUNICATIONS CORPORATION
|
||||
// Copyright © 1996, 1997 Netscape Communications Corporation. All Rights
|
||||
// Reserved. Use of this Source Code is subject to the terms of the
|
||||
// applicable license agreement from Netscape Communications Corporation.
|
||||
// The copyright notice(s) in this Source Code does not indicate actual or
|
||||
// intended publication of this Source Code.
|
||||
//
|
||||
// $Id: SparseSet.h,v 1.1.2.1 1999-03-02 16:12:07 fur%netscape.com Exp $
|
||||
//
|
||||
|
||||
#ifndef _SPARSE_SET_H_
|
||||
#define _SPARSE_SET_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "Pool.h"
|
||||
#include "LogModule.h"
|
||||
#include "BitSet.h"
|
||||
|
||||
class SparseSet
|
||||
{
|
||||
private:
|
||||
|
||||
struct Node {
|
||||
Uint32 element;
|
||||
Uint32 stackIndex;
|
||||
};
|
||||
|
||||
Node* node;
|
||||
Uint32 count;
|
||||
Uint32 universeSize;
|
||||
|
||||
private:
|
||||
|
||||
// No copy constructor.
|
||||
SparseSet(const SparseSet&);
|
||||
|
||||
// Check if the given set's universe is of the same size than this universe.
|
||||
void checkUniverseCompatibility(const SparseSet& set) const {assert(set.universeSize == universeSize);}
|
||||
// Check if pos is valid for this set's universe.
|
||||
void checkMember(Int32 pos) const {assert(pos >=0 && Uint32(pos) < universeSize);}
|
||||
|
||||
public:
|
||||
|
||||
SparseSet(Pool& pool, Uint32 universeSize) : universeSize(universeSize) {node = new(pool) Node[universeSize]; clear();}
|
||||
|
||||
// Clear the sparse set.
|
||||
void clear() {count = 0;}
|
||||
// Clear the element at index.
|
||||
inline void clear(Uint32 index);
|
||||
// Set the element at index.
|
||||
inline void set(Uint32 index);
|
||||
// Return true if the element at index is set.
|
||||
inline bool test(Uint32 index) const;
|
||||
// Union with the given sparse set.
|
||||
inline void or(const SparseSet& set);
|
||||
// Intersection with the given sparse set.
|
||||
inline void and(const SparseSet& set);
|
||||
// Difference with the given sparse set.
|
||||
inline void difference(const SparseSet& set);
|
||||
// Copy set.
|
||||
inline SparseSet& operator = (const SparseSet& set);
|
||||
inline SparseSet& operator = (const BitSet& set);
|
||||
// Return true if the sparse sets are identical.
|
||||
friend bool operator == (const SparseSet& set1, const SparseSet& set2);
|
||||
// Return true if the sparse sets are different.
|
||||
friend bool operator != (const SparseSet& set1, const SparseSet& set2);
|
||||
|
||||
// Logical operators.
|
||||
SparseSet& operator |= (const SparseSet& set) {or(set); return *this;}
|
||||
SparseSet& operator &= (const SparseSet& set) {and(set); return *this;}
|
||||
SparseSet& operator -= (const SparseSet& set) {difference(set); return *this;}
|
||||
|
||||
// Iterator to conform with the set API.
|
||||
typedef Int32 iterator;
|
||||
// Return the iterator for the first element of this set.
|
||||
iterator begin() const {return count - 1;}
|
||||
// Return the next iterator.
|
||||
iterator advance(iterator pos) const {return --pos;}
|
||||
// Return true if the iterator is at the end of the set.
|
||||
bool done(iterator pos) const {return pos < 0;}
|
||||
// Return the element for the given iterator;
|
||||
Uint32 get(iterator pos) const {return node[pos].element;}
|
||||
// Return one element of this set.
|
||||
Uint32 getOne() const {assert(count > 0); return node[0].element;}
|
||||
// Return the size of this set.
|
||||
Uint32 getSize() const {return count;}
|
||||
|
||||
#ifdef DEBUG_LOG
|
||||
// Print the set.
|
||||
void printPretty(LogModuleObject log);
|
||||
#endif // DEBUG_LOG
|
||||
};
|
||||
|
||||
inline void SparseSet::clear(Uint32 element)
|
||||
{
|
||||
checkMember(element);
|
||||
Uint32 count = this->count;
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
|
||||
if ((stackIndex < count) && (node[stackIndex].element == element)) {
|
||||
Uint32 stackTop = node[count - 1].element;
|
||||
|
||||
node[stackIndex].element = stackTop;
|
||||
node[stackTop].stackIndex = stackIndex;
|
||||
this->count = count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline void SparseSet::set(Uint32 element)
|
||||
{
|
||||
checkMember(element);
|
||||
Uint32 count = this->count;
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
|
||||
if ((stackIndex >= count) || (node[stackIndex].element != element)) {
|
||||
node[count].element = element;
|
||||
node[element].stackIndex = count;
|
||||
this->count = count + 1;
|
||||
}
|
||||
}
|
||||
|
||||
inline bool SparseSet::test(Uint32 element) const
|
||||
{
|
||||
checkMember(element);
|
||||
Node* node = this->node;
|
||||
|
||||
Uint32 stackIndex = node[element].stackIndex;
|
||||
return ((stackIndex < count) && (node[stackIndex].element == element));
|
||||
}
|
||||
|
||||
inline SparseSet& SparseSet::operator = (const SparseSet& set)
|
||||
{
|
||||
checkUniverseCompatibility(set);
|
||||
Uint32 sourceCount = set.getSize();
|
||||
Node* node = this->node;
|
||||
|
||||
memcpy(node, set.node, sourceCount * sizeof(Node));
|
||||
|
||||
for (Uint32 i = 0; i < sourceCount; i++) {
|
||||
Uint32 element = node[i].element;
|
||||
node[element].stackIndex = i;
|
||||
}
|
||||
|
||||
count = sourceCount;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
inline SparseSet& SparseSet::operator = (const BitSet& set)
|
||||
{
|
||||
// FIX: there's room for optimization here.
|
||||
assert(universeSize == set.getSize());
|
||||
|
||||
clear();
|
||||
for (Int32 i = set.firstOne(); i != -1; i = set.nextOne(i))
|
||||
this->set(i);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // _SPARSE_SET_H_
|
||||
270
mozilla/ef/Compiler/RegisterAllocator/Spilling.cpp
Normal file
@@ -0,0 +1,270 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef NEW_LAURENTM_CODE
|
||||
#define INCLUDE_EMITTER
|
||||
#include "CpuInfo.h"
|
||||
#include "Fundamentals.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "InstructionEmitter.h"
|
||||
#include "Spilling.h"
|
||||
|
||||
|
||||
void Spilling::
|
||||
insertSpillCode(ControlNode** dfsList, Uint32 nNodes)
|
||||
{
|
||||
PRUint32 nVirtualRegisters = vRegManager.count();
|
||||
FastBitSet currentLive(vRegManager.pool, nVirtualRegisters);
|
||||
FastBitSet usedInThisInstruction(vRegManager.pool, nVirtualRegisters);
|
||||
RegisterFifo grNeedLoad(nVirtualRegisters);
|
||||
RegisterFifo fpNeedLoad(nVirtualRegisters);
|
||||
|
||||
for (PRInt32 n = nNodes - 1; n >= 0; n--)
|
||||
{
|
||||
PR_ASSERT(grNeedLoad.empty() & fpNeedLoad.empty());
|
||||
ControlNode& node = *dfsList[n];
|
||||
|
||||
currentLive = node.liveAtEnd;
|
||||
|
||||
PRUint32 nGeneralAlive = 0;
|
||||
PRUint32 nFloatingPointAlive = 0;
|
||||
|
||||
// Get the number of registers alive at the end of this node.
|
||||
for (PRInt32 j = currentLive.firstOne(); j != -1; j = currentLive.nextOne(j))
|
||||
{
|
||||
VirtualRegister& vReg = vRegManager.getVirtualRegister(j);
|
||||
if (vReg.spillInfo.willSpill)
|
||||
{
|
||||
currentLive.clear(j);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive++;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if(node.dfsNum == 8) printf("\n________Begin Node %d________\n", node.dfsNum);
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i))
|
||||
{
|
||||
Instruction& instruction = instructions.get(i);
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* defPtr;
|
||||
|
||||
// if(node.dfsNum == 8) { printf("\n");
|
||||
// instruction.printPretty(stdout);
|
||||
// printf("\n"); }
|
||||
|
||||
// Handle definitions
|
||||
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
|
||||
if (defPtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = defPtr->getVirtualRegister();
|
||||
currentLive.clear(vReg.getRegisterIndex());
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive--;
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for deaths
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = usePtr->getVirtualRegister();
|
||||
if (!currentLive.test(vReg.getRegisterIndex()))
|
||||
// This is the last use of this register.
|
||||
{
|
||||
currentLive.set(vReg.getRegisterIndex());
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
nGeneralAlive++;
|
||||
while (/*(nGeneralAlive > NUMBER_OF_GREGISTERS) &&*/ !grNeedLoad.empty())
|
||||
{
|
||||
PRUint32 toLoad = grNeedLoad.get();
|
||||
currentLive.clear(toLoad);
|
||||
nGeneralAlive--;
|
||||
|
||||
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
|
||||
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
|
||||
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
|
||||
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
|
||||
nReg.releaseSelf();
|
||||
}
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
nFloatingPointAlive++;
|
||||
while (/*(nFloatingPointAlive > NUMBER_OF_FPREGISTERS) &&*/ !fpNeedLoad.empty())
|
||||
{
|
||||
PRUint32 toLoad = fpNeedLoad.get();
|
||||
currentLive.clear(toLoad);
|
||||
nFloatingPointAlive--;
|
||||
|
||||
VirtualRegister& nReg = vRegManager.getVirtualRegister(toLoad);
|
||||
Instruction& lastUsingInstruction = *nReg.spillInfo.lastUsingInstruction;
|
||||
emitter.emitLoadAfter(*lastUsingInstruction.getPrimitive(), lastUsingInstruction.getLinks().prev,
|
||||
nReg.getAlias(), *nReg.equivalentRegister[vrcStackSlot]);
|
||||
nReg.releaseSelf();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle uses
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = usePtr->getVirtualRegister();
|
||||
PRUint32 registerIndex = vReg.getRegisterIndex();
|
||||
|
||||
if (vReg.spillInfo.willSpill) {
|
||||
#if defined(GENERATE_FOR_X86)
|
||||
if (!instruction.switchUseToSpill((usePtr - useBegin), *vReg.equivalentRegister[vrcStackSlot]))
|
||||
#endif
|
||||
{
|
||||
switch (vReg.getClass())
|
||||
{
|
||||
case vrcInteger:
|
||||
if (!grNeedLoad.test(registerIndex))
|
||||
{
|
||||
grNeedLoad.put(registerIndex);
|
||||
VirtualRegister& alias = vRegManager.newVirtualRegister(vrcInteger);
|
||||
if (vReg.isPreColored())
|
||||
alias.preColorRegister(vReg.getPreColor());
|
||||
/* if (vReg.hasSpecialInterference) {
|
||||
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
|
||||
alias.specialInterference = vReg.specialInterference;
|
||||
alias.hasSpecialInterference = true;
|
||||
} */
|
||||
vReg.setAlias(alias);
|
||||
vReg.retainSelf();
|
||||
}
|
||||
break;
|
||||
case vrcFloatingPoint:
|
||||
case vrcFixedPoint:
|
||||
if (!fpNeedLoad.test(registerIndex))
|
||||
{
|
||||
fpNeedLoad.put(registerIndex);
|
||||
VirtualRegister& alias = vRegManager.newVirtualRegister(vReg.getClass());
|
||||
if (vReg.isPreColored())
|
||||
alias.preColorRegister(vReg.getPreColor());
|
||||
/*if (vReg.hasSpecialInterference) {
|
||||
alias.specialInterference.sizeTo(NUMBER_OF_REGISTERS);
|
||||
alias.specialInterference = vReg.specialInterference;
|
||||
alias.hasSpecialInterference = true;
|
||||
} */
|
||||
vReg.setAlias(alias);
|
||||
vReg.retainSelf();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
usePtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
|
||||
usedInThisInstruction.set(registerIndex);
|
||||
vReg.spillInfo.lastUsingInstruction = &instruction;
|
||||
}
|
||||
currentLive.clear(registerIndex);
|
||||
} else { // will not spill
|
||||
currentLive.set(registerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Handle definitions
|
||||
for (defPtr = defBegin; defPtr < defEnd; defPtr++)
|
||||
if (defPtr->isVirtualRegister())
|
||||
{
|
||||
VirtualRegister& vReg = defPtr->getVirtualRegister();
|
||||
|
||||
if (vReg.spillInfo.willSpill)
|
||||
#if defined(GENERATE_FOR_X86)
|
||||
if (!instruction.switchDefineToSpill((defPtr - defBegin), *vReg.equivalentRegister[vrcStackSlot]))
|
||||
#endif
|
||||
{
|
||||
if (usedInThisInstruction.test(vReg.getRegisterIndex()))
|
||||
// this virtualRegister was used in this instruction and is also defined. We need to move
|
||||
// this virtual register to its alias first and then save it to memory.
|
||||
{
|
||||
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
|
||||
vReg.getAlias(), *vReg.equivalentRegister[vrcStackSlot]);
|
||||
defPtr->getVirtualRegisterPtr().initialize(vReg.getAlias());
|
||||
}
|
||||
else
|
||||
{
|
||||
emitter.emitStoreAfter(*instruction.getPrimitive(), &instruction.getLinks(),
|
||||
vReg, *vReg.equivalentRegister[vrcStackSlot]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (!grNeedLoad.empty())
|
||||
{
|
||||
PRUint32 nl = grNeedLoad.get();
|
||||
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
|
||||
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
|
||||
|
||||
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
|
||||
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
|
||||
nlReg.releaseSelf();
|
||||
}
|
||||
while (!fpNeedLoad.empty())
|
||||
{
|
||||
PRUint32 nl = fpNeedLoad.get();
|
||||
VirtualRegister& nlReg = vRegManager.getVirtualRegister(nl);
|
||||
Instruction& lastUse = *nlReg.spillInfo.lastUsingInstruction;
|
||||
|
||||
emitter.emitLoadAfter(*lastUse.getPrimitive(), lastUse.getLinks().prev,
|
||||
nlReg.getAlias(), *nlReg.equivalentRegister[vrcStackSlot]);
|
||||
nlReg.releaseSelf();
|
||||
}
|
||||
|
||||
// if(node.dfsNum == 8) printf("\n________End Node %d________\n", node.dfsNum);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
269
mozilla/ef/Compiler/RegisterAllocator/Spilling.h
Normal file
@@ -0,0 +1,269 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SPILLING_H_
|
||||
#define _SPILLING_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "SparseSet.h"
|
||||
|
||||
template <class RegisterPressure>
|
||||
class Spilling
|
||||
{
|
||||
private:
|
||||
static void insertStoreAfter(Instruction& instruction, RegisterName name);
|
||||
static void insertLoadBefore(Instruction& instruction, RegisterName name);
|
||||
|
||||
public:
|
||||
static void calculateSpillCosts(RegisterAllocator& registerAllocator);
|
||||
static void insertSpillCode(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
struct SpillCost
|
||||
{
|
||||
double loads;
|
||||
double stores;
|
||||
double copies;
|
||||
double cost;
|
||||
bool infinite;
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertSpillCode(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet currentLive(pool, rangeCount);
|
||||
SparseSet needLoad(pool, rangeCount);
|
||||
SparseSet mustSpill(pool, rangeCount);
|
||||
SparseSet& willSpill = *registerAllocator.willSpill;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
|
||||
needLoad.clear();
|
||||
currentLive = liveOut[n];
|
||||
mustSpill = currentLive;
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i);) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
i = instructions.retreat(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
bool foundLiveDefine = false;
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
if (currentLive.test(name2range[definePtr->getRegisterName()])) {
|
||||
foundLiveDefine = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
foundLiveDefine = true;
|
||||
break;
|
||||
}
|
||||
if (defineBegin != defineEnd && !foundLiveDefine) {
|
||||
fprintf(stderr, "!!! Removed instruction because it was only defining unused registers !!!\n");
|
||||
instruction.remove();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName range = name2range[definePtr->getRegisterName()];
|
||||
#ifdef DEBUG
|
||||
if (needLoad.test(range))
|
||||
if (!mustSpill.test(range) && registerAllocator.spillCost[range].infinite && willSpill.test(range)) {
|
||||
fprintf(stderr, "Tried to spill a register with infinite spill cost\n");
|
||||
abort();
|
||||
}
|
||||
#endif // DEBUG
|
||||
if (willSpill.test(range))
|
||||
insertStoreAfter(instruction, range);
|
||||
|
||||
needLoad.clear(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy)
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
if (!currentLive.test(range))
|
||||
for (SparseSet::iterator r = needLoad.begin(); !needLoad.done(r); r = needLoad.advance(r)) {
|
||||
RegisterName load = RegisterName(needLoad.get(r));
|
||||
if (willSpill.test(load))
|
||||
insertLoadBefore(instruction, load);
|
||||
mustSpill.set(load);
|
||||
}
|
||||
needLoad.clear();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
currentLive.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
currentLive.set(range);
|
||||
needLoad.set(range);
|
||||
}
|
||||
}
|
||||
|
||||
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
|
||||
RegisterName load = RegisterName(needLoad.get(l));
|
||||
if (willSpill.test(load))
|
||||
insertLoadBefore(instructions.first(), load);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertLoadBefore(Instruction& /*instruction*/, RegisterName name)
|
||||
{
|
||||
fprintf(stdout, "will insert load for range %d\n", name);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::insertStoreAfter(Instruction& /*instruction*/, RegisterName name)
|
||||
{
|
||||
fprintf(stdout, "will insert store for range %d\n", name);
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Spilling<RegisterPressure>::calculateSpillCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
Pool& pool = registerAllocator.pool;
|
||||
SparseSet live(pool, rangeCount);
|
||||
SparseSet needLoad(pool, rangeCount);
|
||||
SparseSet mustSpill(pool, rangeCount);
|
||||
|
||||
SparseSet alreadyStored(pool, rangeCount); // FIX: should get this from previous spilling.
|
||||
|
||||
SpillCost* cost = new SpillCost[rangeCount];
|
||||
memset(cost, '\0', rangeCount * sizeof(SpillCost));
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
|
||||
double weight = doLog10(node.loopDepth);
|
||||
|
||||
needLoad.clear();
|
||||
live = liveOut[n];
|
||||
mustSpill = live;
|
||||
|
||||
InstructionList& instructions = nodes[n]->getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister()) {
|
||||
RegisterName range = name2range[definePtr->getRegisterName()];
|
||||
|
||||
if (needLoad.test(range))
|
||||
if (!mustSpill.test(range))
|
||||
cost[range].infinite = true;
|
||||
|
||||
if ((false /* !rematerializable(range) */ || !needLoad.test(range)) && !alreadyStored.test(range))
|
||||
cost[range].stores += weight;
|
||||
|
||||
needLoad.clear(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy)
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
if (!live.test(name2range[usePtr->getRegisterName()])) {
|
||||
for (SparseSet::iterator l = needLoad.begin(); !needLoad.done(l); l = needLoad.advance(l)) {
|
||||
Uint32 range = needLoad.get(l);
|
||||
cost[range].loads += weight;
|
||||
mustSpill.set(range);
|
||||
}
|
||||
needLoad.clear();
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
live.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
|
||||
live.set(range);
|
||||
needLoad.set(range);
|
||||
}
|
||||
|
||||
if (instruction.getFlags() & ifCopy) {
|
||||
assert(useBegin != useEnd && useBegin[0].isRegister());
|
||||
assert(defineBegin != defineEnd && defineBegin[0].isRegister());
|
||||
|
||||
RegisterName source = name2range[useBegin[0].getRegisterName()];
|
||||
RegisterName destination = name2range[defineBegin[0].getRegisterName()];
|
||||
|
||||
cost[source].copies += weight;
|
||||
cost[destination].copies += weight;
|
||||
}
|
||||
}
|
||||
|
||||
for (SparseSet::iterator s = needLoad.begin(); !needLoad.done(s); s = needLoad.advance(s))
|
||||
cost[needLoad.get(s)].loads += weight;
|
||||
}
|
||||
|
||||
for (Uint32 r = 0; r < rangeCount; r++) {
|
||||
SpillCost& c = cost[r];
|
||||
c.cost = 2 * (c.loads + c.stores) - c.copies;
|
||||
}
|
||||
|
||||
registerAllocator.spillCost = cost;
|
||||
}
|
||||
|
||||
#endif // _SPILLING_H_
|
||||
239
mozilla/ef/Compiler/RegisterAllocator/Splits.h
Normal file
@@ -0,0 +1,239 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _SPLITS_H_
|
||||
#define _SPLITS_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include <string.h>
|
||||
#include "Pool.h"
|
||||
#include "ControlGraph.h"
|
||||
#include "ControlNodes.h"
|
||||
#include "Instruction.h"
|
||||
#include "RegisterAllocator.h"
|
||||
#include "RegisterAllocatorTools.h"
|
||||
|
||||
UT_EXTERN_LOG_MODULE(RegAlloc);
|
||||
|
||||
template <class RegisterPressure>
|
||||
struct Splits
|
||||
{
|
||||
static void calculateSplitCosts(RegisterAllocator& registerAllocator);
|
||||
static bool findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range);
|
||||
static void insertSplitCode(RegisterAllocator& registerAllocator);
|
||||
};
|
||||
|
||||
struct SplitCost
|
||||
{
|
||||
double loads;
|
||||
double stores;
|
||||
};
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Splits<RegisterPressure>::insertSplitCode(RegisterAllocator& /*registerAllocator*/)
|
||||
{
|
||||
// FIX
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
bool Splits<RegisterPressure>::findSplit(RegisterAllocator& registerAllocator, RegisterName* color, RegisterName range)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
NameLinkedList** neighborsWithColor = new(pool) NameLinkedList*[6]; // FIX
|
||||
memset(neighborsWithColor, '\0', 6 * sizeof(NameLinkedList*));
|
||||
|
||||
InterferenceGraph<RegisterPressure>& iGraph = registerAllocator.iGraph;
|
||||
|
||||
for (InterferenceVector* vector = iGraph.getInterferenceVector(range); vector != NULL; vector = vector->next)
|
||||
for (Int32 i = vector->count - 1; i >=0; --i) {
|
||||
RegisterName neighbor = vector->neighbors[i];
|
||||
RegisterName c = color[neighbor];
|
||||
|
||||
if (c < 6) { // FIX
|
||||
NameLinkedList* node = new(pool) NameLinkedList();
|
||||
node->name = neighbor;
|
||||
node->next = neighborsWithColor[c];
|
||||
neighborsWithColor[c] = node;
|
||||
}
|
||||
}
|
||||
|
||||
bool splitAroundName = true;
|
||||
|
||||
LiveRangeGraph<RegisterPressure>& lGraph = registerAllocator.lGraph;
|
||||
RegisterName bestColor = RegisterName(6); // FIX
|
||||
double bestCost = registerAllocator.spillCost[range].cost;
|
||||
SplitCost* splitCost = registerAllocator.splitCost;
|
||||
|
||||
for (RegisterName i = RegisterName(0); i < 6; i = RegisterName(i + 1)) { // FIX
|
||||
|
||||
double splitAroundNameCost = 0.0;
|
||||
bool canSplitAroundName = true;
|
||||
|
||||
SplitCost& sCost = splitCost[range];
|
||||
double addedCost = 2.0 * (sCost.stores + sCost.loads);
|
||||
|
||||
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
|
||||
RegisterName neighbor = node->name;
|
||||
if (lGraph.haveEdge(neighbor, range)) {
|
||||
canSplitAroundName = false;
|
||||
break;
|
||||
} else
|
||||
splitAroundNameCost += addedCost;
|
||||
}
|
||||
if (canSplitAroundName && splitAroundNameCost < bestCost) {
|
||||
bestCost = splitAroundNameCost;
|
||||
bestColor = i;
|
||||
splitAroundName = true;
|
||||
}
|
||||
|
||||
double splitAroundColorCost = 0.0;
|
||||
bool canSplitAroundColor = true;
|
||||
|
||||
for (NameLinkedList* node = neighborsWithColor[i]; node != NULL; node = node->next) {
|
||||
RegisterName neighbor = node->name;
|
||||
if (lGraph.haveEdge(range, neighbor)) {
|
||||
canSplitAroundColor = false;
|
||||
break;
|
||||
} else {
|
||||
SplitCost& sCost = splitCost[neighbor];
|
||||
double addedCost = 2.0 * (sCost.stores + sCost.loads);
|
||||
splitAroundColorCost += addedCost;
|
||||
}
|
||||
}
|
||||
if (canSplitAroundColor && splitAroundColorCost < bestCost) {
|
||||
bestCost = splitAroundColorCost;
|
||||
bestColor = i;
|
||||
splitAroundName = false;
|
||||
}
|
||||
}
|
||||
if (bestColor < RegisterName(6)) {
|
||||
color[range] = bestColor;
|
||||
registerAllocator.splitFound = true;
|
||||
|
||||
NameLinkedList** splitAround = registerAllocator.splitAround;
|
||||
|
||||
if (splitAroundName)
|
||||
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
|
||||
NameLinkedList* newNode = new(pool) NameLinkedList();
|
||||
newNode->name = node->name;
|
||||
newNode->next = splitAround[range];
|
||||
splitAround[range] = newNode;
|
||||
}
|
||||
else
|
||||
for (NameLinkedList* node = neighborsWithColor[bestColor]; node != NULL; node = node->next) {
|
||||
NameLinkedList* newNode = new(pool) NameLinkedList();
|
||||
RegisterName neighbor = node->name;
|
||||
newNode->name = range;
|
||||
newNode->next = splitAround[neighbor];
|
||||
splitAround[neighbor] = newNode;
|
||||
}
|
||||
|
||||
trespass("Found a split");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class RegisterPressure>
|
||||
void Splits<RegisterPressure>::calculateSplitCosts(RegisterAllocator& registerAllocator)
|
||||
{
|
||||
Pool& pool = registerAllocator.pool;
|
||||
Uint32 rangeCount = registerAllocator.rangeCount;
|
||||
RegisterName* name2range = registerAllocator.name2range;
|
||||
|
||||
SplitCost* splitCost = new(pool) SplitCost[rangeCount];
|
||||
memset(splitCost, '\0', rangeCount * sizeof(SplitCost));
|
||||
|
||||
SparseSet live(pool, rangeCount);
|
||||
RegisterPressure::Set* liveIn = registerAllocator.liveness.liveIn;
|
||||
RegisterPressure::Set* liveOut = registerAllocator.liveness.liveOut;
|
||||
|
||||
ControlGraph& controlGraph = registerAllocator.controlGraph;
|
||||
ControlNode** nodes = controlGraph.dfsList;
|
||||
Uint32 nNodes = controlGraph.nNodes;
|
||||
|
||||
for (Uint32 n = 0; n < nNodes; n++) {
|
||||
ControlNode& node = *nodes[n];
|
||||
double weight = doLog10(node.loopDepth);
|
||||
|
||||
live = liveOut[n];
|
||||
|
||||
ControlEdge* successorsEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++) {
|
||||
ControlNode& successor = successorsPtr->getTarget();
|
||||
|
||||
if (successor.getControlKind() != ckEnd) {
|
||||
RegisterPressure::Set& successorLiveIn = liveIn[successor.dfsNum];
|
||||
|
||||
for (SparseSet::iterator i = live.begin(); !live.done(i); i = live.advance(i)) {
|
||||
RegisterName name = RegisterName(live.get(i));
|
||||
if (!successorLiveIn.test(name))
|
||||
splitCost[name].loads += doLog10(successor.loopDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InstructionList& instructions = node.getInstructions();
|
||||
for (InstructionList::iterator i = instructions.end(); !instructions.done(i); i = instructions.retreat(i)) {
|
||||
Instruction& instruction = instructions.get(i);
|
||||
|
||||
InstructionUse* useBegin = instruction.getInstructionUseBegin();
|
||||
InstructionUse* useEnd = instruction.getInstructionUseEnd();
|
||||
InstructionUse* usePtr;
|
||||
InstructionDefine* defineBegin = instruction.getInstructionDefineBegin();
|
||||
InstructionDefine* defineEnd = instruction.getInstructionDefineEnd();
|
||||
InstructionDefine* definePtr;
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
splitCost[name2range[definePtr->getRegisterName()]].stores += weight;
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister()) {
|
||||
RegisterName range = name2range[usePtr->getRegisterName()];
|
||||
if (!live.test(range)) {
|
||||
if (&instruction != &instructions.last())
|
||||
splitCost[range].loads += weight;
|
||||
else {
|
||||
ControlEdge* successorsEnd = node.getSuccessorsEnd();
|
||||
for (ControlEdge* successorsPtr = node.getSuccessorsBegin(); successorsPtr < successorsEnd; successorsPtr++)
|
||||
splitCost[range].loads += doLog10(successorsPtr->getTarget().loopDepth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (definePtr = defineBegin; definePtr < defineEnd; definePtr++)
|
||||
if (definePtr->isRegister())
|
||||
live.clear(name2range[definePtr->getRegisterName()]);
|
||||
|
||||
for (usePtr = useBegin; usePtr < useEnd; usePtr++)
|
||||
if (usePtr->isRegister())
|
||||
live.set(name2range[usePtr->getRegisterName()]);
|
||||
}
|
||||
}
|
||||
|
||||
NameLinkedList** splitAround = new(pool) NameLinkedList*[rangeCount];
|
||||
memset(splitAround, '\0', rangeCount * sizeof(NameLinkedList*));
|
||||
registerAllocator.splitAround = splitAround;
|
||||
|
||||
registerAllocator.splitCost = splitCost;
|
||||
registerAllocator.splitFound = false;
|
||||
}
|
||||
|
||||
#endif // _SPLITS_H_
|
||||
186
mozilla/ef/Compiler/RegisterAllocator/Timer.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashTable.h"
|
||||
#include "Timer.h"
|
||||
#include "Pool.h"
|
||||
|
||||
static Pool pool; // Pool for the Timer class.
|
||||
static HashTable<TimerEntry*> timerEntries(pool); // Timers hashtable.
|
||||
|
||||
const nTimersInABlock = 128; // Number of timers in a block.
|
||||
static PRTime *timers = new(pool) PRTime[nTimersInABlock]; // A block of timers.
|
||||
static Uint8 nextTimer = 0; // nextAvailableTimer.
|
||||
|
||||
//
|
||||
// Calibrate the call to PR_Now().
|
||||
//
|
||||
static PRTime calibrate()
|
||||
{
|
||||
PRTime t = PR_Now();
|
||||
PRTime& a = *new(pool) PRTime();
|
||||
|
||||
// Call 10 times the PR_Now() function.
|
||||
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
|
||||
a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now(); a = PR_Now();
|
||||
t = (PR_Now() - t + 9) / 10;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static PRTime adjust = calibrate();
|
||||
|
||||
//
|
||||
// Return the named timer..
|
||||
//
|
||||
TimerEntry& Timer::getTimerEntry(const char* name)
|
||||
{
|
||||
if (!timerEntries.exists(name)) {
|
||||
TimerEntry* newEntry = new(pool) TimerEntry();
|
||||
newEntry->accumulator = 0;
|
||||
newEntry->running = false;
|
||||
timerEntries.add(name, newEntry);
|
||||
}
|
||||
|
||||
return *timerEntries[name];
|
||||
}
|
||||
|
||||
//
|
||||
// Return a reference to a new timer.
|
||||
//
|
||||
PRTime& Timer::getNewTimer()
|
||||
{
|
||||
if (nextTimer >= nTimersInABlock) {
|
||||
timers = new(pool) PRTime[nTimersInABlock];
|
||||
nextTimer = 0;
|
||||
}
|
||||
return timers[nextTimer++];
|
||||
}
|
||||
|
||||
static Uint32 timersAreFrozen = 0;
|
||||
|
||||
//
|
||||
// Start the named timer.
|
||||
//
|
||||
void Timer::start(const char* name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
PR_ASSERT(!timer.running);
|
||||
|
||||
timer.accumulator = 0;
|
||||
timer.running = true;
|
||||
timer.done = false;
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
//
|
||||
// Stop the named timer.
|
||||
//
|
||||
void Timer::stop(const char* name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
PR_ASSERT(timer.running);
|
||||
timer.running = false;
|
||||
timer.done = true;
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
//
|
||||
// Freeze all the running timers.
|
||||
//
|
||||
void Timer::freezeTimers()
|
||||
{
|
||||
PRTime when = PR_Now() - adjust;
|
||||
|
||||
if (timersAreFrozen == 0) {
|
||||
Vector<TimerEntry*> entries = timerEntries;
|
||||
Uint32 count = entries.size();
|
||||
|
||||
for (Uint32 i = 0; i < count; i++) {
|
||||
TimerEntry& entry = *entries[i];
|
||||
if (entry.running) {
|
||||
entry.accumulator += (when - *entry.startTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
timersAreFrozen++;
|
||||
}
|
||||
|
||||
//
|
||||
// Unfreeze all the running timers.
|
||||
//
|
||||
void Timer::unfreezeTimers()
|
||||
{
|
||||
PR_ASSERT(timersAreFrozen != 0);
|
||||
timersAreFrozen--;
|
||||
|
||||
if (timersAreFrozen == 0) {
|
||||
Vector<TimerEntry *> entries = timerEntries;
|
||||
Uint32 count = entries.size();
|
||||
|
||||
PRTime& newStart = getNewTimer();
|
||||
|
||||
for (Uint32 i = 0; i < count; i++) {
|
||||
TimerEntry& entry = *entries[i];
|
||||
if (entry.running) {
|
||||
entry.startTime = &newStart;
|
||||
}
|
||||
}
|
||||
|
||||
newStart = PR_Now();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Print the named timer in the file f.
|
||||
//
|
||||
void Timer::print(FILE* f, const char *name)
|
||||
{
|
||||
if (timersAreFrozen)
|
||||
return;
|
||||
|
||||
freezeTimers();
|
||||
|
||||
TimerEntry& timer = getTimerEntry(name);
|
||||
|
||||
PR_ASSERT(timer.done);
|
||||
PRTime elapsed = timer.accumulator;
|
||||
|
||||
if (elapsed >> 32) {
|
||||
fprintf(f, "[timer %s out of range]\n", name);
|
||||
} else {
|
||||
fprintf(f, "[%dus in %s]\n", Uint32(elapsed), name);
|
||||
}
|
||||
fflush(f);
|
||||
|
||||
unfreezeTimers();
|
||||
}
|
||||
|
||||
80
mozilla/ef/Compiler/RegisterAllocator/Timer.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _TIMER_H_
|
||||
#define _TIMER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "HashTable.h"
|
||||
#include "prtime.h"
|
||||
|
||||
//
|
||||
// Naming convention:
|
||||
// As the class Timer contains only static methods, the timer's name should start with the
|
||||
// module name. Otherwise starting 2 timers with the same name will assert.
|
||||
//
|
||||
|
||||
#ifndef NO_TIMER
|
||||
|
||||
struct TimerEntry
|
||||
{
|
||||
PRTime *startTime; // Current time when we start the timer.
|
||||
PRTime accumulator; // Time spent in this timer.
|
||||
bool running; // True if the timer is running.
|
||||
bool done; // True if the timer was running and was stopped.
|
||||
};
|
||||
|
||||
class Timer
|
||||
{
|
||||
private:
|
||||
|
||||
// Return the named timer.
|
||||
static TimerEntry& getTimerEntry(const char* name);
|
||||
// Return a reference to a new Timer.
|
||||
static PRTime& getNewTimer();
|
||||
|
||||
public:
|
||||
|
||||
// Start the timer.
|
||||
static void start(const char* name);
|
||||
// Stop the timer.
|
||||
static void stop(const char* name);
|
||||
// Freeze all the running timers.
|
||||
static void freezeTimers();
|
||||
// Unfreeze all the running timers.
|
||||
static void unfreezeTimers();
|
||||
// Print the timer.
|
||||
static void print(FILE* f, const char *name);
|
||||
};
|
||||
|
||||
inline void startTimer(const char* name) {Timer::start(name);}
|
||||
inline void stopTimer(const char* name) {Timer::stop(name); Timer::print(stdout, name);}
|
||||
#define START_TIMER_SAFE Timer::freezeTimers();
|
||||
#define END_TIMER_SAFE Timer::unfreezeTimers();
|
||||
#define TIMER_SAFE(x) START_TIMER_SAFE x; END_TIMER_SAFE
|
||||
|
||||
#else /* NO_TIMER */
|
||||
|
||||
inline void startTimer(const char* /*name*/) {}
|
||||
inline void stopTimer(const char* /*name*/) {}
|
||||
#define START_TIMER_SAFE
|
||||
#define END_TIMER_SAFE
|
||||
#define TIMER_SAFE(x) x;
|
||||
|
||||
#endif /* NO_TIMER */
|
||||
#endif /* _TIMER_H_ */
|
||||
40
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "VirtualRegister.h"
|
||||
#include "Instruction.h"
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegister -
|
||||
|
||||
#ifdef MANUAL_TEMPLATES
|
||||
template class IndexedPool<VirtualRegister>;
|
||||
#endif
|
||||
|
||||
// Set the defining instruction.
|
||||
//
|
||||
void VirtualRegister::setDefiningInstruction(Instruction& instruction)
|
||||
{
|
||||
if (definingInstruction != NULL) {
|
||||
if ((instruction.getFlags() & ifCopy) && (definingInstruction->getFlags() & ifPhiNode))
|
||||
return;
|
||||
}
|
||||
definingInstruction = &instruction;
|
||||
}
|
||||
|
||||
116
mozilla/ef/Compiler/RegisterAllocator/VirtualRegister.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _VIRTUAL_REGISTER_H_
|
||||
#define _VIRTUAL_REGISTER_H_
|
||||
|
||||
#include "Fundamentals.h"
|
||||
#include "IndexedPool.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "RegisterTypes.h"
|
||||
#include "RegisterClass.h"
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegister - 24b
|
||||
|
||||
class Instruction;
|
||||
|
||||
class VirtualRegister : public IndexedObject<VirtualRegister>
|
||||
{
|
||||
public:
|
||||
|
||||
Instruction* definingInstruction; // Instruction defining this VR.
|
||||
|
||||
// Initialize a VR of the given classKind.
|
||||
VirtualRegister(RegisterClassKind /*classKind*/) : definingInstruction(NULL) {}
|
||||
|
||||
// Return the defining instruction for this VR.
|
||||
Instruction* getDefiningInstruction() const {return definingInstruction;}
|
||||
// Set the defining instruction.
|
||||
void setDefiningInstruction(Instruction& insn);
|
||||
};
|
||||
|
||||
// Return true if the VirtualRegisters are equals. The only way 2 VRs can be equal is if
|
||||
// they have the same index. If they have the same index then they are at the same
|
||||
// address in the indexed pool.
|
||||
//
|
||||
inline bool operator == (const VirtualRegister& regA, const VirtualRegister& regB) {return ®A == ®B;}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// VirtualRegisterManager -
|
||||
|
||||
struct PreColoredRegister
|
||||
{
|
||||
RegisterID id;
|
||||
RegisterName color;
|
||||
};
|
||||
|
||||
class VirtualRegisterManager
|
||||
{
|
||||
private:
|
||||
|
||||
IndexedPool<VirtualRegister> registerPool;
|
||||
PreColoredRegister machineRegister[6];
|
||||
|
||||
public:
|
||||
VirtualRegisterManager()
|
||||
{
|
||||
for (Uint32 i = 0; i < 6; i++)
|
||||
machineRegister[i].id = invalidID;
|
||||
}
|
||||
|
||||
// Return the VirtualRegister at the given index.
|
||||
VirtualRegister& getVirtualRegister(RegisterName name) const {return registerPool.get(name);}
|
||||
|
||||
// Return a new VirtualRegister.
|
||||
RegisterID newVirtualRegister(RegisterClassKind classKind)
|
||||
{
|
||||
VirtualRegister& vReg = *new(registerPool) VirtualRegister(classKind);
|
||||
RegisterID rid;
|
||||
|
||||
setName(rid, RegisterName(vReg.getIndex()));
|
||||
setClass(rid, classKind);
|
||||
return rid;
|
||||
}
|
||||
|
||||
RegisterID newMachineRegister(RegisterName name, RegisterClassKind classKind)
|
||||
{
|
||||
RegisterID rid = machineRegister[name].id;
|
||||
|
||||
if (rid == invalidID) {
|
||||
rid = newVirtualRegister(classKind);
|
||||
DEBUG_ONLY(setMachineRegister(rid));
|
||||
machineRegister[name].id = rid;
|
||||
machineRegister[name].color = name;
|
||||
}
|
||||
|
||||
return rid;
|
||||
}
|
||||
|
||||
PreColoredRegister* getMachineRegistersBegin() const {return (PreColoredRegister*) machineRegister;} // FIX
|
||||
PreColoredRegister* getMachineRegistersEnd() const {return (PreColoredRegister*) &machineRegister[6];} // FIX
|
||||
|
||||
// Return the VirtualRegister universe size.
|
||||
Uint32 getSize() {return registerPool.getSize();}
|
||||
|
||||
void setSize(Uint32 size) {registerPool.setSize(size);}
|
||||
};
|
||||
|
||||
#endif // _VIRTUAL_REGISTER_H_
|
||||
@@ -1,419 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Script Name: Full Featured PHP Browser/OS detection
|
||||
Author: Harald Hope, Website: http://tech.ratmachines.com/
|
||||
Script Source URI: http://tech.ratmachines.com/downloads/browser_detection.php
|
||||
Version 4.2.7
|
||||
Copyright (C) 04 March 2004
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
Lesser GPL license text:
|
||||
http://www.gnu.org/licenses/lgpl.txt
|
||||
|
||||
Coding conventions:
|
||||
http://cvs.sourceforge.net/viewcvs.py/phpbb/phpBB2/docs/codingstandards.htm?rev=1.3
|
||||
*/
|
||||
|
||||
/******************************************
|
||||
this is currently set to accept 9 parameters, although you can add as many as you want:
|
||||
1. safe - returns true/false, you can determine what makes the browser be safe lower down,
|
||||
currently it's set for ns4 and pre version 1 mozillas not being safe, plus all older browsers
|
||||
2. ie_version - tests to see what general IE it is, ie5x-6, ie4, or macIE, returns these values.
|
||||
3. moz_version - returns array of moz version, version number (includes full version, + etc), rv number (for math
|
||||
comparison), rv number (for full rv, including alpha and beta versions), and release date
|
||||
4. dom - returns true/false if it is a basic dom browser, ie >= 5, opera >= 5, all new mozillas, safaris, konquerors
|
||||
5. os - returns which os is being used
|
||||
6. os_number - returns windows versions, 95, 98, me, nt 4, nt 5 [windows 2000], nt 5.1 [windows xp],
|
||||
otherwise returns false
|
||||
7. browser - returns the browser name, in shorthand: ie, ie4, ie5x, op, moz, konq, saf, ns4
|
||||
8. number - returns the browser version number, if available, otherwise returns '' [not available]
|
||||
9. full - returns this array: $browser_name, $version_number, $ie_version, $dom_browser, $safe_browser, $os, $os_number
|
||||
*******************************************/
|
||||
|
||||
// main script, uses two other functions, which_os() and browser_version() as needed
|
||||
function browser_detection( $which_test ) {
|
||||
/*
|
||||
uncomment the global variable declaration if you want the variables to be available on a global level
|
||||
throughout your php page, make sure that php is configured to support the use of globals first!
|
||||
Use of globals should be avoided however, and they are not necessary with this script
|
||||
*/
|
||||
|
||||
/*global $dom_browser, $safe_browser, $browser_user_agent, $os, $browser_name, $ie_version,
|
||||
$version_number, $os_number, $b_repeat, $moz_version, $moz_version_number, $moz_rv, $moz_rv_full, $moz_release;*/
|
||||
|
||||
static $dom_browser, $safe_browser, $browser_user_agent, $os, $browser_name, $ie_version,
|
||||
$version_number, $os_number, $b_repeat, $moz_version, $moz_version_number, $moz_rv, $moz_rv_full, $moz_release;
|
||||
|
||||
/*
|
||||
this makes the test only run once no matter how many times you call it
|
||||
since all the variables are filled on the first run through, it's only a matter of returning the
|
||||
the right ones
|
||||
*/
|
||||
if ( !$b_repeat )
|
||||
{
|
||||
//initialize all variables with default values to prevent error
|
||||
$dom_browser = false;
|
||||
$safe_browser = false;
|
||||
$os = '';
|
||||
$os_number = '';
|
||||
$a_os_data = '';
|
||||
$browser_name = '';
|
||||
$version_number = '';
|
||||
$ie_version = '';
|
||||
$moz_version = '';
|
||||
$moz_version_number = '';
|
||||
$moz_rv = '';
|
||||
$moz_rv_full = '';
|
||||
$moz_release = '';
|
||||
|
||||
//make navigator user agent string lower case to make sure all versions get caught
|
||||
$browser_user_agent = strtolower( $_SERVER['HTTP_USER_AGENT'] );
|
||||
|
||||
$a_os_data = which_os( $browser_user_agent );// get os/number array
|
||||
$os = $a_os_data[0];// os name, abbreviated
|
||||
$os_number = $a_os_data[1];// os number if windows
|
||||
|
||||
/*
|
||||
pack the browser type array, in this order
|
||||
the order is important, because opera must be tested first, and ie4 tested for before ie general
|
||||
same for konqueror, then safari, then gecko, since safari navigator user agent id's with 'gecko' in string.
|
||||
note that $dom_browser is set for all modern dom browsers, this gives you a default to use.
|
||||
|
||||
array[0] = id string for useragent, array[1] is if dom capable, array[2] is working name for browser
|
||||
|
||||
Note: all browser strings are in lower case to match the strtolower output, this avoids possible detection
|
||||
errors
|
||||
*/
|
||||
$a_browser_types[] = array( 'opera', true, 'op' );
|
||||
$a_browser_types[] = array( 'msie', true, 'ie' );
|
||||
$a_browser_types[] = array( 'konqueror', true, 'konq' );
|
||||
$a_browser_types[] = array( 'safari', true, 'saf' );
|
||||
// covers Netscape 6-7, K-Meleon, Most linux versions
|
||||
// the 3 is for the rv: number, the release date is hardcoded
|
||||
$a_browser_types[] = array( 'gecko', true, 'moz' );
|
||||
// netscape 4 test: this has to be last or else ie or opera might register true
|
||||
$a_browser_types[] = array( 'mozilla/4', false, 'ns4' );
|
||||
$a_browser_types[] = array( 'lynx', false, 'lynx' );
|
||||
$a_browser_types[] = array( 'webtv', true, 'webtv' );
|
||||
// search engine spider bots:
|
||||
$a_browser_types[] = array( 'googlebot', false, 'google' );// google
|
||||
$a_browser_types[] = array( 'fast-webcrawler', false, 'fast' );// Fast AllTheWeb
|
||||
$a_browser_types[] = array( 'msnbot', false, 'msn' );// msn search
|
||||
$a_browser_types[] = array( 'scooter', false, 'scooter' );// altavista
|
||||
//$a_browser_types[] = array( '', false ); // browser array template
|
||||
|
||||
/*
|
||||
moz types array
|
||||
note the order, netscape6 must come before netscape, which is how netscape 7 id's itself.
|
||||
rv comes last in case it is plain old mozilla
|
||||
*/
|
||||
$moz_types = array( 'firebird', 'phoenix', 'firefox', 'galeon', 'k-meleon', 'camino', 'netscape6',
|
||||
'netscape', 'rv' );
|
||||
|
||||
/*
|
||||
run through the browser_types array, break if you hit a match, if no match, assume old browser
|
||||
or non dom browser, assigns false value to $b_success.
|
||||
*/
|
||||
for ($i = 0; $i < count($a_browser_types); $i++)
|
||||
{
|
||||
//unpacks browser array, assigns to variables
|
||||
$s_browser = $a_browser_types[$i][0];// text string to id browser from array
|
||||
$b_dom = $a_browser_types[$i][1];// hardcoded dom support from array
|
||||
$browser_name = $a_browser_types[$i][2];// working name for browser
|
||||
$b_success = false;
|
||||
|
||||
if (stristr($browser_user_agent, $s_browser))
|
||||
{
|
||||
// it defaults to true, will become false below if needed
|
||||
// this keeps it easier to keep track of what is safe, only explicit false assignment will make it false.
|
||||
$safe_browser = true;
|
||||
switch ( $browser_name )
|
||||
{
|
||||
case 'ns4':
|
||||
$safe_browser = false;
|
||||
break;
|
||||
case 'moz':
|
||||
/*
|
||||
note: The 'rv' test is not absolute since the rv number is very different on
|
||||
different versions, for example Galean doesn't use the same rv version as Mozilla,
|
||||
neither do later Netscapes, like 7.x. For more on this, read the full mozilla numbering
|
||||
conventions here:
|
||||
http://www.mozilla.org/releases/cvstags.html
|
||||
*/
|
||||
|
||||
// this will return alpha and beta version numbers, if present
|
||||
$moz_rv_full = browser_version( $browser_user_agent, 'rv' );
|
||||
// this slices them back off for math comparisons
|
||||
$moz_rv = substr( $moz_rv_full, 0, 3 );
|
||||
|
||||
// this is to pull out specific mozilla versions, firebird, netscape etc..
|
||||
for ( $i = 0; $i < count( $moz_types ); $i++ )
|
||||
{
|
||||
if ( stristr( $browser_user_agent, $moz_types[$i] ) )
|
||||
{
|
||||
$moz_version = $moz_types[$i];
|
||||
$moz_version_number = browser_version( $browser_user_agent, $moz_version );
|
||||
break;
|
||||
}
|
||||
}
|
||||
// this is necesary to protect against false id'ed moz'es and new moz'es.
|
||||
// this corrects for galeon, or any other moz browser without an rv number
|
||||
if ( !$moz_rv )
|
||||
{
|
||||
$moz_rv = substr( $moz_version_number, 0, 3 );
|
||||
$moz_rv_full = $moz_version_number;
|
||||
/*
|
||||
// you can use this instead if you are running php >= 4.2
|
||||
$moz_rv = floatval( $moz_version_number );
|
||||
$moz_rv_full = $moz_version_number;
|
||||
*/
|
||||
}
|
||||
// this corrects the version name in case it went to the default 'rv' for the test
|
||||
if ( $moz_version == 'rv' )
|
||||
{
|
||||
$moz_version = 'mozilla';
|
||||
}
|
||||
|
||||
//the moz version will be taken from the rv number, see notes above for rv problems
|
||||
$version_number = $moz_rv;
|
||||
// gets the actual release date, necessary if you need to do functionality tests
|
||||
$moz_release = browser_version( $browser_user_agent, 'gecko/' );
|
||||
/*
|
||||
Test for mozilla 0.9.x / netscape 6.x
|
||||
test your javascript/CSS to see if it works in these mozilla releases, if it does, just default it to:
|
||||
$safe_browser = true;
|
||||
*/
|
||||
if ( ( $moz_release < 20020400 ) || ( $moz_rv < 1 ) )
|
||||
{
|
||||
$safe_browser = false;
|
||||
}
|
||||
break;
|
||||
case 'ie':
|
||||
//$version_number = browser_version( $browser_user_agent, $s_browser, $substring_length );
|
||||
$version_number = browser_version( $browser_user_agent, $s_browser );
|
||||
if ( $os == 'mac' )
|
||||
{
|
||||
$ie_version = 'ieMac';
|
||||
}
|
||||
// this assigns a general ie id to the $ie_version variable
|
||||
if ( $version_number >= 5 )
|
||||
{
|
||||
$ie_version = 'ie5x';
|
||||
}
|
||||
elseif ( ( $version_number > 3 ) && $version_number < 5 )
|
||||
{
|
||||
$dom_browser = false;
|
||||
$ie_version = 'ie4';
|
||||
$safe_browser = true; // this depends on what you're using the script for, make sure this fits your needs
|
||||
}
|
||||
else
|
||||
{
|
||||
$ie_version = 'old';
|
||||
$safe_browser = false;
|
||||
}
|
||||
break;
|
||||
case 'op':
|
||||
//$version_number = browser_version( $browser_user_agent, $s_browser, $substring_length );
|
||||
$version_number = browser_version( $browser_user_agent, $s_browser );
|
||||
if ( $version_number < 5 )// opera 4 wasn't very useable.
|
||||
{
|
||||
$safe_browser = false;
|
||||
}
|
||||
break;
|
||||
case 'saf':
|
||||
//$version_number = browser_version( $browser_user_agent, $s_browser, $substring_length );
|
||||
$version_number = browser_version( $browser_user_agent, $s_browser );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
$dom_browser = $b_dom;
|
||||
$b_success = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
//assigns defaults if the browser was not found in the loop test
|
||||
if ( !$b_success )
|
||||
{
|
||||
$safe_browser = false;
|
||||
$dom_browser = false;
|
||||
$browser_name = '';
|
||||
}
|
||||
// this ends the run through once if clause, set the boolean
|
||||
//to true so the function won't retest everything
|
||||
$b_repeat = true;
|
||||
}
|
||||
/*
|
||||
This is where you return values based on what parameter you used to call the function
|
||||
$which_test is the passed parameter in the initial browser_detection('os') for example call
|
||||
*/
|
||||
switch ( $which_test )
|
||||
{
|
||||
case 'safe':// returns true/false if your tests determine it's a safe browser
|
||||
// you can change the tests to determine what is a safeBrowser for your scripts
|
||||
// in this case sub rv 1 Mozillas and Netscape 4x's trigger the unsafe condition
|
||||
return $safe_browser;
|
||||
break;
|
||||
case 'ie_version': // returns iemac or ie5x
|
||||
return $ie_version;
|
||||
break;
|
||||
case 'moz_version':// returns array of all relevant moz information
|
||||
$moz_array = array( $moz_version, $moz_version_number, $moz_rv, $moz_rv_full, $moz_release );
|
||||
return $moz_array;
|
||||
break;
|
||||
case 'dom':// returns true/fale if a DOM capable browser
|
||||
return $dom_browser;
|
||||
break;
|
||||
case 'os':// returns os name
|
||||
return $os;
|
||||
break;
|
||||
case 'os_number':// returns os number if windows
|
||||
return $os_number;
|
||||
break;
|
||||
case 'browser':// returns browser name
|
||||
return $browser_name;
|
||||
break;
|
||||
case 'number':// returns browser number
|
||||
return $version_number;
|
||||
break;
|
||||
case 'full':// returns all relevant browser information in an array
|
||||
$full_array = array( $browser_name, $version_number, $ie_version, $dom_browser, $safe_browser, $os, $os_number );
|
||||
return $full_array;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// gets which os from the browser string
|
||||
function which_os ( $browser_string )
|
||||
{
|
||||
// initialize variables
|
||||
$os = '';
|
||||
$os_version = '';
|
||||
/*
|
||||
packs the os array
|
||||
use this order since some navigator user agents will put 'macintosh' in the navigator user agent string
|
||||
which would make the nt test register true
|
||||
*/
|
||||
$a_os = array('lin', 'mac', 'unix', 'sunos', 'bsd', 'nt', 'win');
|
||||
|
||||
//os tester
|
||||
for ($i = 0; $i < count($a_os); $i++)
|
||||
{
|
||||
//unpacks os array, assigns to variable
|
||||
$s_os = $a_os[$i];
|
||||
|
||||
//assign os to global os variable, os flag true on success
|
||||
if (stristr( $browser_string, $s_os ))
|
||||
{
|
||||
$os = $s_os;
|
||||
|
||||
switch ( $os )
|
||||
{
|
||||
case 'win':
|
||||
if ( strstr( $browser_string, '95' ) )
|
||||
{
|
||||
$os_version = '95';
|
||||
}
|
||||
elseif ( strstr( $browser_string, '98' ) )
|
||||
{
|
||||
$os_version = '98';
|
||||
}
|
||||
elseif ( strstr( $browser_string, 'me' ) )
|
||||
{
|
||||
$os_version = 'me';
|
||||
}
|
||||
elseif ( strstr( $browser_string, '2000' ) )// windows 2000, for opera ID
|
||||
{
|
||||
$os_version = '5.0';
|
||||
$os = 'nt';
|
||||
}
|
||||
elseif ( strstr( $browser_string, 'xp' ) )// windows 2000, for opera ID
|
||||
{
|
||||
$os_version = '5.1';
|
||||
$os = 'nt';
|
||||
}
|
||||
break;
|
||||
case 'nt':
|
||||
if ( strstr( $browser_string, 'nt 5.1' || strstr( $browser_string, 'xp' )) )// windows xp
|
||||
{
|
||||
$os_version = '5.1';//
|
||||
}
|
||||
elseif ( strstr( $browser_string, 'nt 5' ) || strstr( $browser_string, '2000' ) )// windows 2000
|
||||
{
|
||||
$os_version = '5.0';
|
||||
}
|
||||
elseif ( strstr( $browser_string, 'nt 4' ) )// nt 4
|
||||
{
|
||||
$os_version = '4';
|
||||
}
|
||||
elseif ( strstr( $browser_string, 'nt 3' ) )// nt 4
|
||||
{
|
||||
$os_version = '3';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// pack the os data array for return to main function
|
||||
$os_data = array( $os, $os_version );
|
||||
return $os_data;
|
||||
}
|
||||
|
||||
// function returns browser number, gecko rv number, or gecko release date
|
||||
//function browser_version( $browser_user_agent, $search_string, $substring_length )
|
||||
function browser_version( $browser_user_agent, $search_string )
|
||||
{
|
||||
// 8 is the longest that will be required, handles release dates: 20020323; 0.8.0+
|
||||
$substring_length = 8;
|
||||
//initialize browser number, will return '' if not found
|
||||
$browser_number = '';
|
||||
|
||||
// use the passed parameter for $search_string
|
||||
// start the substring slice right after these moz search strings
|
||||
$start_pos = strpos( $browser_user_agent, $search_string ) + strlen( $search_string );
|
||||
|
||||
// this is just to get the release date, not other moz information
|
||||
if ( ( $search_string != 'gecko/' ) )
|
||||
{
|
||||
$start_pos++;
|
||||
}
|
||||
|
||||
// Initial trimming
|
||||
$browser_number = substr( $browser_user_agent, $start_pos, $substring_length );
|
||||
|
||||
// Find the space, ;, or parentheses that ends the number
|
||||
$browser_number = substr( $browser_number, 0, strcspn($browser_number, ' );') );
|
||||
|
||||
//make sure the returned value is actually the id number and not a string
|
||||
// otherwise return ''
|
||||
if ( !is_numeric( substr( $browser_number, 0, 1 ) ) )
|
||||
{
|
||||
$browser_number = '';
|
||||
}
|
||||
|
||||
return $browser_number;
|
||||
}
|
||||
|
||||
/*
|
||||
Here are some typical navigator.userAgent strings so you can see where the data comes from
|
||||
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.5) Gecko/20031007 Firebird/0.7
|
||||
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1
|
||||
*/
|
||||
?>
|
||||
@@ -1,73 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
// Mozilla Update -- PHP Configuration File
|
||||
// All common PHP Variables/functions are defined here
|
||||
|
||||
//-- Site Timing :: Function and Start... --//
|
||||
function getmicrotime() {
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$time_start = getmicrotime();
|
||||
|
||||
//-- Website Variables--//
|
||||
$websitepath = "/opt/update"; // Local Path to Site Files
|
||||
$sitehostname = "update.mozilla.org"; // DNS Hostname
|
||||
|
||||
//-- MySQL Server/Database Properties/Connection --//
|
||||
$mysqlServer="localhost";
|
||||
$mysqlData="update"; //MySQL Server Database Name
|
||||
$mysqlLogin=""; //MySQL Server UserName
|
||||
$mysqlPass=""; //MySQL Server Password
|
||||
|
||||
|
||||
$connection = mysql_connect("$mysqlServer","$mysqlLogin","$mysqlPass") or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR);
|
||||
$db = mysql_select_db("$mysqlData", $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_ERROR);
|
||||
|
||||
//-- Page Header & Footer --//
|
||||
$page_header = "$websitepath/core/inc_header.php";
|
||||
$page_footer = "$websitepath/core/inc_footer.php";
|
||||
|
||||
|
||||
//includes
|
||||
include"inc_guids.php"; // GUID Handler
|
||||
include"inc_global.php"; // Global Functions
|
||||
include"sessionconfig.php"; //Start Session
|
||||
|
||||
?>
|
||||
@@ -1,145 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
//Various Sample User_Agents, uncomment to debug detection for one. :-)
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Photon; U; QNX x86pc; en-US; rv:1.6a) Gecko/20030122";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (BeOS; U; BeOS BePC; en-US; rv:1.4a) Gecko/20030305";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.7b) Gecko/20040302";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040206 Lightninglizard/0.8";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7b) Gecko/20040322 Nuclearunicorn/0.8.0+ (Firefox/0.8.0+ rebrand)";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040626 Firefox/0.9";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3";
|
||||
//$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.2) Gecko/20040818 Firefox/0.9.1+";
|
||||
|
||||
include"browser_detection.php"; //Script that defines the browser_detection() function
|
||||
|
||||
$OS = browser_detection('os');
|
||||
$moz_array = browser_detection('moz_version');
|
||||
|
||||
//Turn $OS into something usable.
|
||||
if ( $moz_array[0] !== '' )
|
||||
{
|
||||
switch ( $OS )
|
||||
{
|
||||
case 'win':
|
||||
case 'nt':
|
||||
$OS = 'Windows';
|
||||
break;
|
||||
case 'lin':
|
||||
$OS = 'Linux';
|
||||
break;
|
||||
case 'solaris':
|
||||
case 'sunos':
|
||||
$OS = 'Solaris';
|
||||
break;
|
||||
case 'unix':
|
||||
case 'bsd':
|
||||
$OS = 'BSD';
|
||||
break;
|
||||
case 'mac':
|
||||
$OS = 'MacOSX';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Print what it's found, debug item.
|
||||
//echo ( 'Your Mozilla product is ' . $moz_array[0] . ' ' . $moz_array[1] . ' running on '. $OS . ' ');
|
||||
|
||||
$application = $moz_array[0];
|
||||
$app_version = $moz_array[1];
|
||||
|
||||
// XXX hack for 10.1 security release -- we need to munge
|
||||
// versions to just check major.minor and ignore release/etc. bits
|
||||
if ($app_version == "0.10.1") {
|
||||
$app_version = "0.10";
|
||||
}
|
||||
|
||||
// XXX hack for 1.0RC1/1.0RC2 release. browser detection needs to be more customizeable per release. heh.
|
||||
// This changes the displayed UA, to the app.extensions.ver internal.
|
||||
if ($app_version == "1.0rc1" or $app_version == "1.0rc2") {
|
||||
$app_version = "1.0";
|
||||
}
|
||||
|
||||
} else {
|
||||
//If it's not a Mozilla product, then return nothing and let the default app code work..
|
||||
}
|
||||
|
||||
//----------------------------
|
||||
//Browser & OS Detection (Default Code)
|
||||
//----------------------------
|
||||
|
||||
//if (!$_GET["application"] or ($_GET["application"]==$application && $_GET["version"]==$moz_array[1])) {
|
||||
//$app_version = $moz_array[1]; //Set app_version from Detection
|
||||
//}
|
||||
|
||||
//Application
|
||||
if (!$application) { $application="firefox"; } //Default App is Firefox
|
||||
|
||||
//App_Version
|
||||
//if ($_GET["version"]) {$app_version = $_GET["version"]; }
|
||||
|
||||
if ($detection_force_version=="true") {$application=$_SESSION["application"];}
|
||||
//Get Max Version for App Specified
|
||||
$sql = "SELECT `major`,`minor`,`release`,`SubVer` FROM `t_applications` WHERE `AppName` = '$application' ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$release = "$row[major].$row[minor]";
|
||||
if ($row["release"]) {$release = ".$release$row[release]";}
|
||||
$subver = $row["SubVer"];
|
||||
if ($subver !=="final") {$release="$release$subver";}
|
||||
|
||||
if (!$app_version OR $detection_force_version=="true") { $app_version = $release; }
|
||||
unset($release, $subver);
|
||||
|
||||
//OS
|
||||
if ($_GET["os"]) {$OS = $_GET["os"];} //If Defined, set.
|
||||
|
||||
// 1.0PR support
|
||||
if ($app_version=="1.0PR") {$app_version="0.10"; }
|
||||
|
||||
// 0.9.x branch support -- All non-branch (+) builds should be 0.9.
|
||||
if (strpos($app_version, "+")=== false AND strpos($app_version, "0.9")===0) { $app_version="0.9";}
|
||||
|
||||
|
||||
|
||||
//Register Browser Detection Values with the session
|
||||
if (!$_SESSION["application"]) { $_SESSION["application"] = $application; }
|
||||
if (!$_SESSION["app_version"]) { $_SESSION["app_version"] = $app_version; }
|
||||
if (!$_SESSION["app_os"]) { $_SESSION["app_os"] = $OS; }
|
||||
?>
|
||||
@@ -1,57 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<!--Page Footer-->
|
||||
<?php
|
||||
//Site Timer Counter :: Debug-Mode Item Only
|
||||
$time_end = getmicrotime();
|
||||
//Returns in format: sss.mmmuuunnnppp ;-)
|
||||
// m = millisec, u=microsec, n=nansec, p=picosec
|
||||
$time = round($time_end - $time_start,"6");
|
||||
|
||||
echo"<DIV class=\"footer\">© 2004 <A HREF=\"http://www.mozilla.org\">The Mozilla Organization</A>"; if ($_SESSION["debug"]=="true") {echo" | Page Created in $time seconds"; } echo" | Terms of Use | Top</DIV>"; //Debug Time
|
||||
|
||||
if ($pos !== false) {
|
||||
echo"</div>\n";
|
||||
}
|
||||
if ($_SESSION["debug"]=="true") {
|
||||
print(session_id());
|
||||
echo"<PRE>";print_r($_SESSION); echo"</PRE><Br>\n";
|
||||
echo"Current application data: $application - $app_version - $OS ";
|
||||
}
|
||||
?>
|
||||
@@ -1,102 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
//inc_global.php -- Stuff that needs to be done globally to all of Mozilla Update
|
||||
|
||||
//Cache Control Headers
|
||||
$expstr = gmdate("D, d M Y H:i:s", time() + 1800) . " GMT";
|
||||
header("Expires: $expstr");
|
||||
header("Cache-Control: public, pre-check=0, post-check=0, max-age=1800");
|
||||
|
||||
|
||||
//Attempt to fix Bug 246743 (strip_tags) and Bug 248242 (htmlentities)
|
||||
foreach ($_GET as $key => $val) {
|
||||
$_GET["$key"] = htmlentities(str_replace("\\","",strip_tags($_GET["$key"])));
|
||||
}
|
||||
|
||||
//Set Debug Mode session Variable
|
||||
if ($_GET["debug"]=="true") {$_SESSION["debug"]=$_GET["debug"]; } else if ($_GET["debug"]=="false") {unset($_SESSION["debug"]);}
|
||||
|
||||
// Bug 250596 Fixes for incoming $_GET variables.
|
||||
if ($_GET["application"]) {
|
||||
$_GET["application"] = strtolower($_GET["application"]);
|
||||
$sql = "SELECT AppID FROM `t_applications` WHERE `AppName` = '".ucwords(strtolower($_GET["application"]))."' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)===0) {unset($_GET["application"]);}
|
||||
}
|
||||
|
||||
//if ($_GET["version"]) {
|
||||
//$sql = "SELECT AppID FROM `t_applications` WHERE `Release` = '$_GET[version]' LIMIT 1";
|
||||
// $sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
// if (mysql_num_rows($sql_result)===0) {unset($_GET["application"]);}
|
||||
//}
|
||||
|
||||
if ($_GET["category"] AND $_GET["category"] !=="All"
|
||||
AND $_GET["category"] !=="Editors Pick" AND $_GET["category"] !=="Popular"
|
||||
AND $_GET["category"] !=="Top Rated" AND $_GET["category"] !=="Newest") {
|
||||
$sql = "SELECT CatName FROM `t_categories` WHERE `CatName` = '".ucwords(strtolower($_GET["category"]))."' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)===0) {unset($_GET["category"]);}
|
||||
}
|
||||
|
||||
if (!is_numeric($_GET["id"])) { unset($_GET["id"]); }
|
||||
if (!is_numeric($_GET["vid"])) { unset($_GET["vid"]); }
|
||||
if (!is_numeric($_GET["pageid"])) { unset($_GET["pageid"]); }
|
||||
if (!is_numeric($_GET["numpg"])) { unset($_GET["numpg"]); }
|
||||
|
||||
// page_error() function
|
||||
|
||||
function page_error($reason, $custom_message) {
|
||||
global $page_header, $page_footer;
|
||||
echo"<TITLE>Mozilla Update :: Error</TITLE>\n";
|
||||
echo"<LINK REL=\"STYLESHEET\" TYPE=\"text/css\" HREF=\"/core/update.css\">\n";
|
||||
include"$page_header";
|
||||
|
||||
echo"<DIV class=\"contentbox\" style=\"border-color: #F00; width: 90%; margin: auto; min-height: 250px; margin-bottom: 5px\">\n";
|
||||
echo"<DIV class=\"boxheader\">Mozilla Update :: Error</DIV>\n";
|
||||
echo"<SPAN style=\"font-size: 12pt\">\n";
|
||||
echo"Mozilla Update has encountered an error and is unable to fulfill your request. Please try your request again later. If the
|
||||
problem continues, please contact the Mozilla Update staff. More information about the error may be found at the end of this
|
||||
message.<BR><BR>
|
||||
Error $reason: $custom_message<BR><BR>
|
||||
<A HREF=\"javascript:history.back()\">«« Go Back to Previous Page</A>";
|
||||
echo"</SPAN></DIV>\n";
|
||||
include"$page_footer";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
//Reset GUIDs to something human-readable
|
||||
if ($_GET["application"]=="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}") {
|
||||
$_GET["application"]="firefox";
|
||||
|
||||
} else if ($_GET["application"]=="{3550f703-e582-4d05-9a08-453d09bdfdc6}") {
|
||||
$_GET["application"]="thunderbird";
|
||||
|
||||
} else if ($_GET["application"]=="{86c18b42-e466-45a9-ae7a-9b95ba6f5640}") {
|
||||
$_GET["application"]="mozilla";
|
||||
}
|
||||
?>
|
||||
@@ -1,82 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
$pos = strpos($_SERVER["REQUEST_URI"], "/admin");
|
||||
if ($pos !== false) {
|
||||
echo'<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/mozupdates.bak.css">';
|
||||
$application="login";
|
||||
}
|
||||
?>
|
||||
<DIV class="header">
|
||||
<?php //if ($_GET["application"]) {$application=$_GET["application"]; } else {$application="firefox"; } ?>
|
||||
<DIV class="logo"><IMG SRC="/images/<?php echo"$application"; ?>-cornerlogo.png" BORDER=0 ALT=""></DIV>
|
||||
<DIV class="header-top"><A HREF="/"><IMG SRC="/images/updatelogo.png" BORDER=0 HEIGHT=55 WIDTH=270 ALT="Mozilla Update"></A></DIV>
|
||||
<DIV class="tabbar">
|
||||
<A HREF="/?application=mozilla"><IMG SRC="/images/tab-mozilla<?php if ($application=="mozilla") {echo"-selected"; } ?>.png" BORDER=0 HEIGHT=20 WIDTH=98 ALT="[Mozilla] "></A><A HREF="/?application=firefox"><IMG SRC="/images/tab-firefox<?php if ($application=="firefox") {echo"-selected"; } ?>.png" BORDER=0 HEIGHT=20 WIDTH=98 ALT="[Firefox] "></A><A HREF="/?application=thunderbird"><IMG SRC="/images/tab-thunderbird<?php if ($application=="thunderbird") {echo"-selected"; } ?>.png" BORDER=0 HEIGHT=20 WIDTH=105 ALT="[Thunderbird] "></A><A HREF="/developercp.php"><IMG SRC="/images/tab-login<?php if ($application=="login") {echo"-selected"; } ?>.png" BORDER=0 HEIGHT=20 WIDTH=98 ALT="[Login]"></A>
|
||||
</DIV>
|
||||
</DIV>
|
||||
<DIV class="bar"></DIV>
|
||||
<DIV class="nav">
|
||||
<?php if ($application !=="login") { ?>
|
||||
<A HREF="/?application=<?php echo"$application"; ?>">Home</A>
|
||||
| <A HREF="/faq/?application=<?php echo"$application"; ?>">FAQ</A>
|
||||
<?php
|
||||
// Types
|
||||
$types = array("E"=>"Extensions","T"=>"Themes");
|
||||
foreach($types as $typeid => $typename) {
|
||||
echo" | <A HREF=\"/".strtolower($typename)."/?application=$application\">$typename</A>";
|
||||
}
|
||||
//echo"<BR>\n";
|
||||
|
||||
} else { echo" "; }
|
||||
?>
|
||||
</DIV>
|
||||
|
||||
<?php
|
||||
if ($pos !== false) {
|
||||
?>
|
||||
<?php if ($_SESSION["logoncheck"] =="YES" && $headerline !="none") { ?>
|
||||
<DIV class="adminheading">
|
||||
Welcome<?php echo" $_SESSION[name]"; ?>!
|
||||
<a href="usermanager.php?function=edituser&userid=<?php echo"$_SESSION[uid]"; ?>">Your Profile</a> | <A HREF="main.php">Home</A> |<A HREF="logout.php">Logout</A>
|
||||
<?php } ?>
|
||||
</DIV>
|
||||
<div id="mainContent">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -1,103 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
//Submit Review/Rating Feedback to Table
|
||||
require"../core/config.php";
|
||||
if (!$_POST[rating] && $_POST[rating] !=="0") {
|
||||
//No Rating Defined, send user back...
|
||||
$return_path="extensions/moreinfo.php?id=$_POST[id]&vid=$_POST[vid]&page=opinion&error=norating";
|
||||
header("Location: http://$_SERVER[HTTP_HOST]/$return_path");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!$_POST[comments]) {
|
||||
$_POST[comments]="NULL";
|
||||
} else {
|
||||
//Comments is not null, format comments and get default name/title.. if needed.
|
||||
$_POST["comments"]="'$_POST[comments]'";
|
||||
if (!$_POST[name]) {$_POST[name]=="Anonymous"; }
|
||||
if (!$_POST[title]) {$_POST[title]=="My Comments..."; }
|
||||
}
|
||||
|
||||
$_POST["name"] = strip_tags($_POST["name"]);
|
||||
$_POST["title"] = strip_tags($_POST["title"]);
|
||||
$_POST["comments"] = strip_tags($_POST["comments"]);
|
||||
|
||||
//Are we behind a proxy and given the IP via an alternate enviroment variable? If so, use it.
|
||||
if ($_SERVER["HTTP_X_FORWARDED_FOR"]) {
|
||||
$remote_addr = $_SERVER["HTTP_X_FORWARDED_FOR"];
|
||||
} else {
|
||||
$remote_addr = $_SERVER["REMOTE_ADDR"];
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `t_feedback` (`ID`, `CommentName`, `CommentVote`, `CommentTitle`, `CommentNote`, `CommentDate`, `commentip`) VALUES ('$_POST[id]', '$_POST[name]', '$_POST[rating]', '$_POST[title]', $_POST[comments], NOW(NULL), '$remote_addr');";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
|
||||
//Get Rating Data and Create $ratingarray
|
||||
$sql = "SELECT ID, CommentVote FROM `t_feedback` WHERE `ID` = '$_POST[id]' AND `CommentVote` IS NOT NULL AND `CommentNote` IS NOT NULL ORDER BY `CommentDate` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$ratingarray[$row[ID]][] = $row["CommentVote"];
|
||||
}
|
||||
|
||||
//Compile Rating Average
|
||||
$id = $_POST[id];
|
||||
if (!$ratingarray[$id]) {$ratingarray[$id] = array(); }
|
||||
$numratings = count($ratingarray[$id]);
|
||||
$sumratings = array_sum($ratingarray[$id]);
|
||||
if ($numratings>0) {
|
||||
$rating = round($sumratings/$numratings, 1);
|
||||
} else {
|
||||
$rating="0"; } //Default Rating
|
||||
|
||||
|
||||
$sql = "UPDATE `t_main` SET `Rating`='$rating' WHERE `ID`='$id' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
|
||||
if ($_POST["type"]=="E") {
|
||||
$type="extensions";
|
||||
} else if ($_POST["type"]=="T") {
|
||||
$type="themes";
|
||||
}
|
||||
|
||||
$return_path="$type/moreinfo.php?id=$_POST[id]&vid=$_POST[vid]&page=comments&action=postsuccessfull";
|
||||
header("Location: http://$sitehostname/$return_path");
|
||||
exit;
|
||||
?>
|
||||
@@ -1,94 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
|
||||
//session_name('sid');
|
||||
//session_name();
|
||||
//session_start();
|
||||
|
||||
if ($_GET["version"]=="auto-detect") {$_GET["version"]=""; unset($_SESSION["app_version"]);}//Clear Versioning in Session For AutoDetect
|
||||
if ($_GET["application"] AND $_GET["application"] != $_SESSION["application"]) {
|
||||
$_SESSION["application"] = $_GET["application"]; //Put the selected app into session. skip detection. ;-)
|
||||
unset($_SESSION["app_version"]);
|
||||
$detection_force_version = "true"; //Skip application checking, just fill in the version.
|
||||
}
|
||||
|
||||
//Get Browser Detection Data if it's not in the Session vars already
|
||||
if (!$_SESSION["application"] OR !$_SESSION["app_version"]) {
|
||||
include"inc_browserdetection.php";
|
||||
}
|
||||
|
||||
//Change OS Support for showlist.php
|
||||
switch ( $_GET["os"] )
|
||||
{
|
||||
case 'windows':
|
||||
$_GET["os"] = 'Windows';
|
||||
break;
|
||||
case 'linux':
|
||||
$_GET["os"] = 'Linux';
|
||||
break;
|
||||
case 'solaris':
|
||||
$_GET["os"] = 'Solaris';
|
||||
break;
|
||||
case 'bsd':
|
||||
$_GET["os"] = 'BSD';
|
||||
break;
|
||||
case 'macosx':
|
||||
$_GET["os"] = 'MacOSX';
|
||||
break;
|
||||
case 'all':
|
||||
$_GET["os"] = 'ALL';
|
||||
break;
|
||||
default:
|
||||
unset($_GET["os"]);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (($_GET["os"] and $_SESSION["app_os"]) AND $_GET["os"] !== $_SESSION["app_os"]) {
|
||||
$_SESSION["app_os"]=$_GET["os"];
|
||||
|
||||
}
|
||||
|
||||
//Got session data for browser/app detection, populate the variables
|
||||
$application = $_SESSION["application"];
|
||||
$app_version = $_SESSION["app_version"];
|
||||
$OS = $_SESSION["app_os"];
|
||||
|
||||
|
||||
if ($_GET["debug"]=="killappdata") { unset($_SESSION["application"],$_SESSION["app_version"]); }
|
||||
?>
|
||||
@@ -1,226 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Update.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Chris "Wolf" Crews.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
BODY {
|
||||
MARGIN: 0px 0px 5px; FONT-FAMILY: Arial; BACKGROUND-COLOR: #fff
|
||||
}
|
||||
A {
|
||||
COLOR: #00129c; TEXT-DECORATION: none
|
||||
}
|
||||
A:visited {
|
||||
COLOR: #00129c; TEXT-DECORATION: none
|
||||
}
|
||||
A:hover {
|
||||
COLOR: #fc5900
|
||||
}
|
||||
DIV.header {
|
||||
BACKGROUND-IMAGE: url(/images/header.png); BACKGROUND-REPEAT: repeat-x; HEIGHT: 77px
|
||||
}
|
||||
DIV.header-top {
|
||||
HEIGHT: 57px
|
||||
}
|
||||
DIV.logo {
|
||||
z-index: 1; position: absolute; right: 0px
|
||||
}
|
||||
DIV.tabbar {
|
||||
PADDING-LEFT: 26px; HEIGHT: 20px
|
||||
}
|
||||
|
||||
DIV.nav {
|
||||
BACKGROUND-IMAGE: url(/images/orangebar.png); background-repeat: repeat-x; PADDING-TOP: 3px; PADDING-LEFT: 10px; FONT-WEIGHT: bold; MARGIN-BOTTOM: 10px; COLOR: #fff; BACKGROUND-COLOR: #0F67C1; a:VISITED: #fff
|
||||
}
|
||||
DIV.nav A:visited {
|
||||
COLOR: #FFF;
|
||||
}
|
||||
DIV.nav A {
|
||||
COLOR: #fff
|
||||
}
|
||||
DIV.adminheading {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN-RIGHT: 10px; HEIGHT: 25px; TEXT-ALIGN: right
|
||||
}
|
||||
.box {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 2px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; FONT-SIZE: 14pt; MARGIN-BOTTOM: 15px; PADDING-BOTTOM: 5px; POSITION: relative; LEFT: 150px; BORDER-LEFT: #ccc 2px solid; WIDTH: 78%; PADDING-TOP: 5px; BORDER-BOTTOM: #ccc 2px solid; -moz-border-radius: 10px
|
||||
}
|
||||
.boxheader {
|
||||
MARGIN-BOTTOM: 6px; BORDER-BOTTOM: #000 1px solid
|
||||
}
|
||||
.boxcolumns {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 2px; BORDER-TOP: #ccc 2px solid; PADDING-LEFT: 2px; FONT-SIZE: 12pt; MIN-HEIGHT: 200px; FLOAT: left; PADDING-BOTTOM: 2px; MARGIN-LEFT: 2px; BORDER-LEFT: #ccc 2px solid; WIDTH: 31%; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 2px solid; -moz-border-radius: 10px
|
||||
}
|
||||
DIV.sidelinks {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 2px; BORDER-TOP: #ccc 2px solid; MARGIN-TOP: 10px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; MARGIN-LEFT: 3px; BORDER-LEFT: #ccc 2px solid; WIDTH: 135px; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 2px solid; POSITION: absolute; -moz-border-radius: 10px
|
||||
}
|
||||
.sidebartitle {
|
||||
FONT-WEIGHT: bold
|
||||
}
|
||||
.sidebartext {
|
||||
MARGIN-LEFT: 4px
|
||||
}
|
||||
.updatebox {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 2px solid; MARGIN-TOP: 3px; PADDING-LEFT: 5px; FONT-WEIGHT: bold; FONT-SIZE: 14pt; MIN-HEIGHT: 200px; MARGIN-BOTTOM: 15px; PADDING-BOTTOM: 5px; MARGIN-LEFT: 1px; BORDER-LEFT: #ccc 2px solid; WIDTH: 230px; PADDING-TOP: 5px; BORDER-BOTTOM: #ccc 2px solid; POSITION: absolute; -moz-border-radius: 10px
|
||||
}
|
||||
.frontpagecontainer {
|
||||
MIN-HEIGHT: 150px; WIDTH: 100%
|
||||
}
|
||||
.contentbox {
|
||||
BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; FONT-SIZE: 14pt; PADDING-BOTTOM: 5px; MARGIN: 0px 5px 15px 0px; BORDER-LEFT: #ccc 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #ccc 1px solid; -moz-border-radius: 10px
|
||||
}
|
||||
.contentcolumns {
|
||||
FLOAT: left; WIDTH: 48%
|
||||
}
|
||||
|
||||
#content {
|
||||
PADDING-LEFT: 5px; POSITION: relative; LEFT: 145px; WIDTH: 85%;
|
||||
}
|
||||
|
||||
DIV.item {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 8px; BORDER-TOP: #ccc 2px solid; PADDING-LEFT: 8px; PADDING-BOTTOM: 0px; MARGIN: 0px auto 15px; BORDER-LEFT: #ccc 2px solid; WIDTH: 95%; PADDING-TOP: 8px; BORDER-BOTTOM: #ccc 2px solid; -moz-border-radius: 10px
|
||||
}
|
||||
#listnav {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 6px; BORDER-TOP: #ccc 2px solid; PADDING-LEFT: 6px; FONT-WEIGHT: bold; FONT-SIZE: 10pt; PADDING-BOTTOM: 6px; MARGIN: 3px auto; BORDER-LEFT: #ccc 2px solid; WIDTH: 95%; PADDING-TOP: 6px; BORDER-BOTTOM: #ccc 2px solid; TEXT-ALIGN: left; -moz-border-radius: 10px
|
||||
}
|
||||
.listform {
|
||||
BORDER-RIGHT: #3d97c0 1px dotted; PADDING-RIGHT: 2px; BORDER-TOP: #3d97c0 1px dotted; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; MARGIN: 10px auto auto; BORDER-LEFT: #3d97c0 1px dotted; WIDTH: 90%; PADDING-TOP: 2px; BORDER-BOTTOM: #3d97c0 1px dotted; HEIGHT: 25px; BACKGROUND-COLOR: #d4e9f2; TEXT-ALIGN: center
|
||||
}
|
||||
.title A {
|
||||
COLOR: #fc5900
|
||||
}
|
||||
.title A:visited {
|
||||
COLOR: #fc5900
|
||||
}
|
||||
.liststars {
|
||||
FLOAT: right; WIDTH: 80px; HEIGHT: 20px
|
||||
}
|
||||
.listtitle {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 11pt
|
||||
}
|
||||
.itemtitle {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 14pt; MARGIN-BOTTOM: 10px; MARGIN-LEFT: 30px
|
||||
}
|
||||
.authorline {
|
||||
FONT-SIZE: 10pt; MARGIN-LEFT: 15px
|
||||
}
|
||||
.itemdescription {
|
||||
FONT-SIZE: 10pt
|
||||
}
|
||||
.iconbar {
|
||||
PADDING-RIGHT: 5px; FONT-WEIGHT: normal; FONT-SIZE: 9pt; FLOAT: right; WIDTH: 125px; HEIGHT: 34px; TEXT-ALIGN: left
|
||||
}
|
||||
.filesize {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 8pt
|
||||
}
|
||||
.smallfont {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 8pt
|
||||
}
|
||||
.baseline {
|
||||
BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 10px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; COLOR: #333
|
||||
}
|
||||
.noitems {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 60px; TEXT-ALIGN: center
|
||||
}
|
||||
.pagenum {
|
||||
FONT-SIZE: 9pt; FLOAT: right
|
||||
}
|
||||
DIV.tabbar {
|
||||
PADDING-RIGHT: 8px; PADDING-LEFT: 8px; PADDING-BOTTOM: 0px; MARGIN: 0px auto auto; WIDTH: 85%; PADDING-TOP: 0px; HEIGHT: 20px
|
||||
}
|
||||
DIV.tab {
|
||||
BORDER-RIGHT: #ccc 2px solid; PADDING-RIGHT: 3px; BORDER-TOP: #ccc 2px solid; PADDING-LEFT: 3px; FONT-SIZE: 11pt; FLOAT: left; MARGIN: 0px 3px; VERTICAL-ALIGN: middle; BORDER-LEFT: #ccc 2px solid; BORDER-BOTTOM: #ccc 2px solid; HEIGHT: 20px; BACKGROUND-COLOR: #ddd; TEXT-ALIGN: center; -moz-border-radius: 10px
|
||||
}
|
||||
.downloadbox {
|
||||
BORDER-RIGHT: #ccc 1px dotted; BORDER-TOP: #ccc 1px dotted; FONT-WEIGHT: bold; FLOAT: left; BORDER-LEFT: #ccc 1px dotted; BORDER-BOTTOM: #ccc 1px dotted; max-width: 395px;
|
||||
}
|
||||
.moreinfoinstall {
|
||||
MARGIN-LEFT: 18px; WIDTH: 250px; HEIGHT: 34px
|
||||
}
|
||||
.commentbox {
|
||||
BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; FONT-SIZE: 10pt; MIN-HEIGHT: 260px; PADDING-BOTTOM: 6px; MARGIN: auto 0px 5px auto; BORDER-LEFT: #ccc 1px solid; WIDTH: 50%; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 1px solid
|
||||
}
|
||||
.commenttitlebar {
|
||||
PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 11pt; HEIGHT: 20px; BACKGROUND-COLOR: #eee
|
||||
}
|
||||
.commenttitle {
|
||||
PADDING-LEFT: 0px; FONT-WEIGHT: bold; FONT-SIZE: 11pt; POSITION: absolute
|
||||
}
|
||||
.commentfooter {
|
||||
PADDING-RIGHT: 5px; FONT-SIZE: 8pt; TEXT-ALIGN: right
|
||||
}
|
||||
.nocomment {
|
||||
MARGIN-LEFT: 30px
|
||||
}
|
||||
.mipageheading {
|
||||
BORDER-TOP: #ccc 1px solid; MARGIN-TOP: 5px; PADDING-LEFT: 4px; FONT-WEIGHT: bold; FONT-SIZE: 11pt; MARGIN-BOTTOM: 5px; COLOR: #333
|
||||
}
|
||||
.reviewbox {
|
||||
BORDER-RIGHT: #bbb 1px dotted; BORDER-TOP: #bbb 1px dotted; FONT-WEIGHT: bold; MARGIN: auto auto 10px; BORDER-LEFT: #bbb 1px dotted; WIDTH: 70%; BORDER-BOTTOM: #bbb 1px dotted
|
||||
};
|
||||
.opinionform {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN: auto 30px; WIDTH: 80%; LINE-HEIGHT: 30px
|
||||
}
|
||||
.errorbox {
|
||||
BORDER-RIGHT: #f00 1px solid; PADDING-RIGHT: 3px; BORDER-TOP: #f00 1px solid; PADDING-LEFT: 3px; PADDING-BOTTOM: 3px; MARGIN: auto auto 20px; BORDER-LEFT: #f00 1px solid; WIDTH: 80%; PADDING-TOP: 3px; BORDER-BOTTOM: #f00 1px solid
|
||||
}
|
||||
.boxheader2 {
|
||||
BORDER-TOP: #2e64ff 4px solid; HEIGHT: 4px
|
||||
}
|
||||
.boldfont {
|
||||
FONT-WEIGHT: bold
|
||||
}
|
||||
.disabled {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: #ccc; FONT-STYLE: italic
|
||||
}
|
||||
.emailactive {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-STYLE: italic
|
||||
}
|
||||
.profileitemdesc {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN-BOTTOM: 4px; MARGIN-LEFT: 20px
|
||||
}
|
||||
.mailresult {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 14pt; MARGIN: auto; WIDTH: 650px; HEIGHT: 30px; TEXT-ALIGN: center
|
||||
}
|
||||
.faqtitle {
|
||||
FONT-WEIGHT: normal; FONT-SIZE: 24pt; COLOR: #0065CA; TEXT-ALIGN: center
|
||||
}
|
||||
.faqitemtitle {
|
||||
FONT-WEIGHT: bold; FONT-SIZE: 12pt
|
||||
}
|
||||
.faqitemtext {
|
||||
MARGIN-LEFT: 5px
|
||||
}
|
||||
.footer {
|
||||
PADDING-RIGHT: 30px; FONT-WEIGHT: bold; FONT-SIZE: 10pt; MARGIN-LEFT: 200px; TEXT-ALIGN: right
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
The files contained in this directory are schema for the Mozilla Update MySQL Database.
|
||||
This directory does not have to be on the webserver for the site to function, in fact, it should not be.
|
||||
|
||||
Mozilla Update requires MySQL 4.0 or higher w/ InnoDB support.
|
||||
@@ -1,348 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http:#www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla Update.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Chris "Wolf" Crews.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
# Alan Starr <alanjstarr@yahoo.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 2.6.0-rc1
|
||||
-- http://www.phpmyadmin.net
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Sep 12, 2004 at 05:07 AM
|
||||
-- Server version: 4.0.18
|
||||
-- PHP Version: 4.3.8
|
||||
--
|
||||
-- Database: `mozillaupdate`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_applications`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_applications` (
|
||||
`AppID` int(11) NOT NULL auto_increment,
|
||||
`AppName` varchar(30) NOT NULL default '',
|
||||
`Version` varchar(10) NOT NULL default '',
|
||||
`major` int(3) NOT NULL default '0',
|
||||
`minor` int(3) NOT NULL default '0',
|
||||
`release` int(3) NOT NULL default '0',
|
||||
`build` int(14) NOT NULL default '0',
|
||||
`SubVer` enum('a','b','final','','+') NOT NULL default 'final',
|
||||
`GUID` varchar(50) NOT NULL default '',
|
||||
PRIMARY KEY (`AppID`),
|
||||
KEY `AppName` (`AppName`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=25 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_approvallog`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_approvallog` (
|
||||
`LogID` int(5) NOT NULL auto_increment,
|
||||
`ID` varchar(11) NOT NULL default '',
|
||||
`vID` varchar(11) NOT NULL default '',
|
||||
`UserID` varchar(11) NOT NULL default '',
|
||||
`action` varchar(255) NOT NULL default '',
|
||||
`date` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`comments` text NOT NULL,
|
||||
PRIMARY KEY (`LogID`),
|
||||
KEY `ID` (`ID`),
|
||||
KEY `vID` (`vID`),
|
||||
KEY `UserID` (`UserID`),
|
||||
KEY `UserID_2` (`UserID`)
|
||||
) TYPE=InnoDB AUTO_INCREMENT=430 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_authorxref`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_authorxref` (
|
||||
`ID` int(11) NOT NULL default '0',
|
||||
`UserID` int(11) NOT NULL default '0',
|
||||
KEY `ID` (`ID`),
|
||||
KEY `UserID` (`UserID`)
|
||||
) TYPE=InnoDB;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_categories`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_categories` (
|
||||
`CategoryID` int(11) NOT NULL auto_increment,
|
||||
`CatName` varchar(30) NOT NULL default '',
|
||||
`CatDesc` varchar(100) NOT NULL default '',
|
||||
`CatType` enum('E','T','P') NOT NULL default 'E',
|
||||
PRIMARY KEY (`CategoryID`)
|
||||
) TYPE=InnoDB AUTO_INCREMENT=28 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_categoryxref`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_categoryxref` (
|
||||
`ID` int(11) NOT NULL default '0',
|
||||
`CategoryID` int(11) NOT NULL default '0',
|
||||
KEY `IDIndex` (`ID`,`CategoryID`),
|
||||
KEY `CategoryID` (`CategoryID`)
|
||||
) TYPE=InnoDB;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_downloads`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_downloads` (
|
||||
`dID` int(11) NOT NULL auto_increment,
|
||||
`ID` varchar(5) NOT NULL default '',
|
||||
`date` varchar(14) default NULL,
|
||||
`downloadcount` int(15) NOT NULL default '0',
|
||||
`vID` varchar(5) NOT NULL default '',
|
||||
`user_ip` varchar(15) NOT NULL default '',
|
||||
`user_agent` text NOT NULL,
|
||||
`type` enum('count','download') NOT NULL default 'download',
|
||||
PRIMARY KEY (`dID`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=3 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_faq`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_faq` (
|
||||
`id` int(3) NOT NULL auto_increment,
|
||||
`index` varchar(5) NOT NULL default '1',
|
||||
`alias` varchar(12) NOT NULL default '',
|
||||
`title` varchar(150) NOT NULL default '',
|
||||
`text` text NOT NULL,
|
||||
`lastupdated` timestamp(14) NOT NULL,
|
||||
`active` enum('YES','NO') NOT NULL default 'YES',
|
||||
PRIMARY KEY (`id`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=7 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_feedback`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_feedback` (
|
||||
`CommentID` int(11) NOT NULL auto_increment,
|
||||
`ID` int(11) NOT NULL default '0',
|
||||
`CommentName` varchar(100) default NULL,
|
||||
`CommentVote` enum('0','1','2','3','4','5') default NULL,
|
||||
`CommentTitle` varchar(75) NOT NULL default '',
|
||||
`CommentNote` text,
|
||||
`CommentDate` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`commentip` varchar(15) NOT NULL default '',
|
||||
PRIMARY KEY (`CommentID`),
|
||||
KEY `ID` (`ID`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=15487 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_main`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_main` (
|
||||
`ID` int(11) NOT NULL auto_increment,
|
||||
`GUID` varchar(50) NOT NULL default '',
|
||||
`Name` varchar(100) NOT NULL default '',
|
||||
`Type` enum('T','E','P') NOT NULL default 'T',
|
||||
`DateAdded` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`DateUpdated` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`Homepage` varchar(200) default NULL,
|
||||
`Description` varchar(255) NOT NULL default '',
|
||||
`Rating` varchar(4) NOT NULL default '0',
|
||||
`downloadcount` int(15) NOT NULL default '0',
|
||||
`TotalDownloads` int(18) NOT NULL default '0',
|
||||
PRIMARY KEY (`ID`),
|
||||
KEY `Type` (`Type`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=218 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_os`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_os` (
|
||||
`OSID` int(11) NOT NULL auto_increment,
|
||||
`OSName` varchar(20) NOT NULL default '',
|
||||
PRIMARY KEY (`OSID`),
|
||||
UNIQUE KEY `OSName` (`OSName`)
|
||||
) TYPE=InnoDB AUTO_INCREMENT=7 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_previews`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_previews` (
|
||||
`PreviewID` int(11) NOT NULL auto_increment,
|
||||
`PreviewURI` varchar(200) NOT NULL default '',
|
||||
`vID` int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (`PreviewID`),
|
||||
KEY `vID` (`vID`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=24 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_reviews`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_reviews` (
|
||||
`rID` int(11) NOT NULL auto_increment,
|
||||
`ID` int(11) NOT NULL default '0',
|
||||
`AppID` int(11) NOT NULL default '0',
|
||||
`DateAdded` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`AuthorID` int(11) NOT NULL default '0',
|
||||
`Title` varchar(60) NOT NULL default '',
|
||||
`Body` text,
|
||||
`pick` enum('YES','NO') NOT NULL default 'NO',
|
||||
`featured` enum('YES','NO') NOT NULL default 'NO',
|
||||
PRIMARY KEY (`rID`),
|
||||
KEY `ID` (`ID`),
|
||||
KEY `AppID` (`AppID`),
|
||||
KEY `AuthorID` (`AuthorID`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=3 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_userprofiles`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_userprofiles` (
|
||||
`UserID` int(11) NOT NULL auto_increment,
|
||||
`UserName` varchar(100) NOT NULL default '',
|
||||
`UserEmail` varchar(100) NOT NULL default '',
|
||||
`UserWebsite` varchar(100) default NULL,
|
||||
`UserPass` varchar(200) NOT NULL default '',
|
||||
`UserMode` enum('A','E','U','D') NOT NULL default 'U',
|
||||
`UserTrusted` enum('TRUE','FALSE') NOT NULL default 'FALSE',
|
||||
`UserEmailHide` tinyint(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`UserID`),
|
||||
UNIQUE KEY `UserEmail` (`UserEmail`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=142 ;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `t_version`
|
||||
--
|
||||
|
||||
CREATE TABLE `t_version` (
|
||||
`vID` int(11) NOT NULL auto_increment,
|
||||
`ID` int(11) NOT NULL default '0',
|
||||
`Version` varchar(30) NOT NULL default '0',
|
||||
`OSID` int(11) NOT NULL default '0',
|
||||
`AppID` int(11) NOT NULL default '0',
|
||||
`MinAppVer` varchar(10) NOT NULL default '',
|
||||
`MinAppVer_int` varchar(10) NOT NULL default '',
|
||||
`MaxAppVer` varchar(10) NOT NULL default '',
|
||||
`MaxAppVer_int` varchar(10) NOT NULL default '',
|
||||
`Size` int(11) NOT NULL default '0',
|
||||
`DateAdded` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`DateUpdated` datetime NOT NULL default '0000-00-00 00:00:00',
|
||||
`URI` varchar(255) NOT NULL default '',
|
||||
`Notes` text,
|
||||
`approved` enum('YES','NO','?') NOT NULL default '?',
|
||||
PRIMARY KEY (`vID`),
|
||||
KEY `ID` (`ID`),
|
||||
KEY `AppID` (`AppID`),
|
||||
KEY `OSID` (`OSID`),
|
||||
KEY `Version` (`Version`)
|
||||
) TYPE=InnoDB PACK_KEYS=0 AUTO_INCREMENT=558 ;
|
||||
|
||||
--
|
||||
-- Constraints for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Constraints for table `t_authorxref`
|
||||
--
|
||||
ALTER TABLE `t_authorxref`
|
||||
ADD CONSTRAINT `0_125` FOREIGN KEY (`ID`) REFERENCES `t_main` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `0_126` FOREIGN KEY (`UserID`) REFERENCES `t_userprofiles` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `t_categoryxref`
|
||||
--
|
||||
ALTER TABLE `t_categoryxref`
|
||||
ADD CONSTRAINT `0_128` FOREIGN KEY (`ID`) REFERENCES `t_main` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `0_129` FOREIGN KEY (`CategoryID`) REFERENCES `t_categories` (`CategoryID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `t_feedback`
|
||||
--
|
||||
ALTER TABLE `t_feedback`
|
||||
ADD CONSTRAINT `0_131` FOREIGN KEY (`ID`) REFERENCES `t_main` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `t_previews`
|
||||
--
|
||||
ALTER TABLE `t_previews`
|
||||
ADD CONSTRAINT `0_133` FOREIGN KEY (`vID`) REFERENCES `t_version` (`vID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `t_reviews`
|
||||
--
|
||||
ALTER TABLE `t_reviews`
|
||||
ADD CONSTRAINT `0_135` FOREIGN KEY (`ID`) REFERENCES `t_main` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `0_136` FOREIGN KEY (`AppID`) REFERENCES `t_applications` (`AppID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
--
|
||||
-- Constraints for table `t_version`
|
||||
--
|
||||
ALTER TABLE `t_version`
|
||||
ADD CONSTRAINT `0_139` FOREIGN KEY (`ID`) REFERENCES `t_main` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `0_140` FOREIGN KEY (`AppID`) REFERENCES `t_applications` (`AppID`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -1,77 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<TITLE>Mozilla Update :: Developer Control Panel - Coming Soon</TITLE>
|
||||
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
$application="login";
|
||||
include"$page_header";
|
||||
?>
|
||||
<DIV class="faqtitle">Developer Control Panel - Coming Soon</DIV>
|
||||
|
||||
<DIV style="width: 75%; margin: auto; margin-top: 20px; border: 1px dotted #0065CA; padding: 5px">
|
||||
In the next version of Mozilla Update, Mozilla Update will have a new section for Extension/Theme authors to login to. This new section
|
||||
will give them the ability to manage their extensions and themes that're hosted on Mozilla Update themselves.<BR>
|
||||
<BR>
|
||||
Authors will have the ability to add a new extension or theme themselves, as well as adding new versions of that extension or theme,
|
||||
updating an existing listing (including being able to change the application-compatibility settings w/o needing a new file), and if
|
||||
they so desire, the ability to remove entirely an old version of an extension or theme or the entire listing.<BR>
|
||||
<BR>
|
||||
Other features that will be available include the capability of adding and managing preview images of their extension or theme,
|
||||
a developer comments feature, so they can easily communicate to end-users known problems with the extension/theme.
|
||||
<BR>
|
||||
</DIV>
|
||||
|
||||
<P>
|
||||
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,194 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<?php
|
||||
//Bookmarking-Friendly Page Title
|
||||
$sql = "SELECT UserName FROM `t_userprofiles` WHERE UserID = '$_GET[id]' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)===0) {
|
||||
$return = page_error("2","Author ID is Invalid or Missing.");
|
||||
exit;
|
||||
|
||||
}
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
?>
|
||||
|
||||
<TITLE>Mozilla Update :: Extensions - Author Profile: <?php echo"$row[UserName]"; ?></TITLE>
|
||||
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
include"$page_header";
|
||||
|
||||
$type = "E";
|
||||
$category = $_GET["category"];
|
||||
include"inc_sidebar.php";
|
||||
?>
|
||||
<DIV id="content">
|
||||
<?php
|
||||
$userid = $_GET["id"];
|
||||
$sql = "SELECT * FROM `t_userprofiles` WHERE `UserID` = '$userid' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$userid = $row["UserID"];
|
||||
$username = $row["UserName"];
|
||||
$useremail = $row["UserEmail"];
|
||||
$userwebsite = $row["UserWebsite"];
|
||||
$userpass = $row["UserPass"];
|
||||
$userrole = $row["UserRole"];
|
||||
$useremailhide = $row["UserEmailHide"];
|
||||
?>
|
||||
<DIV class="item">
|
||||
<SPAN class="boldfont">Profile for <?php echo"$username"; ?></SPAN><BR>
|
||||
<DIV class="boxheader2"></DIV>
|
||||
<SPAN class="boldfont">Homepage:</SPAN> <?php
|
||||
if ($userwebsite) {echo"<A HREF=\"$userwebsite\" target=\"_blank\">$userwebsite</A>";
|
||||
} else {
|
||||
echo"<SPAN CLASS=\"disabled\">Not Available for this Author</SPAN>";
|
||||
}
|
||||
?><BR>
|
||||
<SPAN class="boldfont">E-Mail:</SPAN> <?php if ($useremailhide=="1") {
|
||||
echo"<SPAN class=\"disabled\">Not Disclosed by Author</SPAN>";
|
||||
} else {
|
||||
echo"<SPAN class=\"emailactive\">Contact this Author via the <A HREF=\"#email\">E-Mail form</A> below</SPAN>";
|
||||
}
|
||||
?>
|
||||
</DIV>
|
||||
<BR>
|
||||
<DIV class="item">
|
||||
<SPAN class="boldfont">All Extensions and Themes by <?php echo"$username"; ?></SPAN><BR>
|
||||
<DIV class="boxheader2"></DIV>
|
||||
<?php
|
||||
$sql = "SELECT TM.ID, TM.Type, TM.Name, TM.Description, TM.DateUpdated, TM.TotalDownloads, TU.UserEmail FROM `t_main` TM
|
||||
LEFT JOIN t_authorxref TAX ON TM.ID = TAX.ID
|
||||
INNER JOIN t_userprofiles TU ON TAX.UserID = TU.UserID
|
||||
WHERE TU.UserID = '$userid' AND TM.Type !='P'
|
||||
ORDER BY `Type` , `Name` ";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$numresults = mysql_num_rows($sql_result);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
|
||||
|
||||
$sql2 = "SELECT `vID`, `Version` FROM `t_version` WHERE `ID` = '$row[ID]' AND `approved` = 'YES' ORDER BY `Version` ASC LIMIT 1";
|
||||
$sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row2 = mysql_fetch_array($sql_result2)) {
|
||||
$vid = $row2["vID"];
|
||||
$version = $row2["Version"];
|
||||
|
||||
$v++;
|
||||
$id = $row["ID"];
|
||||
$type = $row["Type"];
|
||||
$name = $row["Name"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$dateupdated = $row["DateUpdated"];
|
||||
$homepage = $row["Homepage"];
|
||||
$description = $row["Description"];
|
||||
$authors = $row["UserEmail"];
|
||||
$downloadcount = $row["TotalDownloads"];
|
||||
|
||||
$day=substr($dateupdated,8,2); //get the day
|
||||
$month=substr($dateupdated,5,2); //get the month
|
||||
$year=substr($dateupdated,0,4); //get the year
|
||||
$hour=substr($dateupdated,11,2); //get the hour
|
||||
$minute=substr($dateupdated,14,2); //get the minute
|
||||
$second=substr($dateupdated,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$dateupdated = gmdate("F d, Y g:i:sa", $timestamp); //gmdate("F d, Y", $dutimestamp);
|
||||
|
||||
echo"<DIV CLASS=\"item\">";
|
||||
echo"<SPAN class=\"title itemtitle\" style=\"margin-left: 0px\"><A HREF=\"moreinfo.php?application=$application&id=$id\">$name</A></SPAN><BR>";
|
||||
echo"<DIV class=\"profileitemdesc\">$description</DIV>\n";
|
||||
echo"<DIV class=\"baseline\">Updated: $dateupdated | Downloads: $downloadcount</DIV>\n";
|
||||
|
||||
echo"</DIV>\n";
|
||||
echo"<BR>\n";
|
||||
}
|
||||
}
|
||||
if ($numresults=="0") {
|
||||
echo"<DIV class=\"noitems\">No Extensions or Themes in the Database for $username yet...</DIV>";
|
||||
}
|
||||
?>
|
||||
</DIV>
|
||||
<BR>
|
||||
<?php if ($useremailhide !=="1") { ?>
|
||||
<A NAME="email"></A>
|
||||
<DIV class="item">
|
||||
<SPAN class="boldfont">Send an E-Mail to <?php echo"$username"; ?></SPAN><BR>
|
||||
<DIV class="boxheader2"></DIV>
|
||||
<?php
|
||||
//SendMail Returned Message Section
|
||||
if ($_GET["mail"]) {
|
||||
$mail = $_GET["mail"];
|
||||
echo"<DIV class=\"mailresult\">";
|
||||
if ($mail=="successful") {
|
||||
echo"Your message has been sent successfully...";
|
||||
} else if ($mail=="unsuccessful") {
|
||||
echo"An error occured, your message was not sent... Please try again...";
|
||||
}
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
?>
|
||||
<FORM NAME="sendmail" METHOD="POST" ACTION="sendmail.php">
|
||||
<INPUT NAME="senduserid" TYPE="HIDDEN" VALUE="<?php echo"$userid"; ?>">
|
||||
Your Name: <INPUT NAME="fromname" TYPE="TEXT" SIZE=40 MAXLENGTH=100> Email: <INPUT NAME="fromemail" TYPE="TEXT" SIZE=40 MAXLENGTH=100><BR>
|
||||
Subject: <INPUT NAME="subject" TYPE="TEXT" SIZE=40 MAXLENGTH=100><BR>
|
||||
Message:<BR>
|
||||
<CENTER><TEXTAREA NAME="body" ROWS=20 COLS=65></TEXTAREA><BR>
|
||||
<INPUT NAME="submit" TYPE="SUBMIT" VALUE="Send Message"> <INPUT NAME="reset" TYPE="RESET" VALUE="Reset Form"><BR>
|
||||
</CENTER>
|
||||
</FORM>
|
||||
</DIV>
|
||||
<BR>
|
||||
<?php } ?>
|
||||
</DIV>
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,88 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<DIV class="sidelinks">
|
||||
<?php
|
||||
unset($typename);
|
||||
$types = array("E"=>"Extensions","T"=>"Themes","U"=>"Updates");
|
||||
$typename = $types["$type"];
|
||||
echo"<DIV CLASS=\"sidebartitle\">Categories:</DIV>\n";
|
||||
echo"<DIV class=\"sidebartext\">";
|
||||
if (!$category AND $index !="yes") {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<SPAN class=\"sidebartitle\"><A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=All\" TITLE=\"Show All ".ucwords($typename)." Alphabetically\">All</A></SPAN><BR>\n";
|
||||
if (!$category AND $index !="yes") {echo"</SPAN>"; }
|
||||
|
||||
// Object Categories
|
||||
$sql = "SELECT `CatName`,`CatDesc` FROM `t_categories` WHERE `CatType` = '$type' ORDER BY `CatName`";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$catname = $row["CatName"];
|
||||
$catdesc = $row["CatDesc"];
|
||||
if (strtolower($category) == strtolower($catname)) {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=$catname\" TITLE=\"$catdesc\">$catname</A><BR>\n";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"</SPAN>"; }
|
||||
}
|
||||
?>
|
||||
<BR>
|
||||
<?php
|
||||
$catname = "Editors Pick";
|
||||
$catdesc = ucwords($typename)." picked by the Mozilla Update Editors";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=$catname\" TITLE=\"$catdesc\">Editor's Pick</A><BR>\n";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"</SPAN>"; }
|
||||
|
||||
$catname = "Popular";
|
||||
$catdesc = ucwords($typename)." downloaded the most";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=$catname\" TITLE=\"$catdesc\">$catname</A><BR>\n";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"</SPAN>"; }
|
||||
|
||||
$catname = "Top Rated";
|
||||
$catdesc = ucwords($typename)." rated the highest";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=$catname\" TITLE=\"$catdesc\">$catname</A><BR>\n";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"</SPAN>"; }
|
||||
|
||||
$catname = "Newest";
|
||||
$catdesc = "Most recent ".ucwords($typename);
|
||||
if (strtolower($category) == strtolower($catname)) {echo"<SPAN CLASS=\"title\">"; }
|
||||
echo"<A HREF=\"showlist.php?application=$application&version=$app_version&numpg=$items_per_page&category=$catname\" TITLE=\"$catdesc\">$catname</A><BR>\n";
|
||||
if (strtolower($category) == strtolower($catname)) {echo"</SPAN>"; }
|
||||
?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
@@ -1,229 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<TITLE>Mozilla Update :: Extensions - Add Features to Mozilla Software</TITLE>
|
||||
|
||||
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
$type = "E";
|
||||
if ($_GET["application"]) {$application=$_GET["application"]; }
|
||||
include"$page_header";
|
||||
$index="yes";
|
||||
include"inc_sidebar.php";
|
||||
?>
|
||||
<DIV class="box">
|
||||
<DIV class="boxheader" style="width: 100%">What is an Extension?</DIV>
|
||||
<SPAN class="itemdescription">Extensions are small add-ons that add new functionality to <?php print(ucwords($application)); ?>.
|
||||
They can add anything from a toolbar button to a completely new feature. They allow the browser to be customized to fit the
|
||||
personal needs of each user if they need additional features<?php if ($application !=="mozilla") { ?>, while keeping <?php print(ucwords($application)); ?> small
|
||||
to download <?php } ?>.</SPAN>
|
||||
</DIV>
|
||||
|
||||
<DIV class="box">
|
||||
<DIV class="boxheader" style="width: 100%">Featured <?php print(ucwords($application)); ?> Extension</DIV>
|
||||
<?php
|
||||
$sql = "SELECT TR.ID, TM.Name, `Title`, TR.DateAdded, `Body`, `Type`, `pick` FROM `t_reviews` TR
|
||||
INNER JOIN t_main TM ON TR.ID = TM.ID
|
||||
INNER JOIN t_version TV ON TV.ID = TM.ID
|
||||
INNER JOIN t_applications TA ON TA.AppID = TV.AppID
|
||||
WHERE `Type` = '$type' AND `AppName` = '$application' AND `featured`='YES' ORDER BY `rID` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$id = $row["ID"];
|
||||
$name = $row["Name"];
|
||||
$title = $row["Title"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$pick = $row["pick"];
|
||||
$body = $row["Body"];
|
||||
$bodylength = strlen($body);
|
||||
if ($bodylength>"250") {
|
||||
$body = substr($body,0,250);
|
||||
$body .= " <a href=\"moreinfo.php?id=$id&application=$application&page=staffreview\">[More...]</a>";
|
||||
|
||||
}
|
||||
|
||||
//Create Customizeable Timestamp
|
||||
$day=substr($dateadded,8,2); //get the day
|
||||
$month=substr($dateadded,5,2); //get the month
|
||||
$year=substr($dateadded,0,4); //get the year
|
||||
$hour=substr($dateadded,11,2); //get the hour
|
||||
$minute=substr($dateadded,14,2); //get the minute
|
||||
$second=substr($dateadded,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$date = gmdate("F, Y", $timestamp);
|
||||
|
||||
echo"<a href=\"moreinfo.php?id=$id\">$name</A> -- $title";
|
||||
if ($pick=="YES") {echo" - $date Editors Pick"; }
|
||||
echo"<BR>\n";
|
||||
echo"<SPAN class=\"itemdescription\">$body</SPAN><BR>\n";
|
||||
}
|
||||
?>
|
||||
</DIV>
|
||||
<?php
|
||||
//Temporary!! Current Version Array Code
|
||||
$currentver_array = array("firefox"=>"1.0", "thunderbird"=>"1.0", "mozilla"=>"1.7");
|
||||
$currentver_display_array = array("firefox"=>"1.0", "thunderbird"=>"1.0", "mozilla"=>"1.7.x");
|
||||
$currentver = $currentver_array[$application];
|
||||
$currentver_display = $currentver_display_array[$application];
|
||||
?>
|
||||
<DIV class="box" style="width: 80%; min-height: 200px; border: 0px">
|
||||
<DIV class="boxcolumns">
|
||||
<DIV class="boxheader"><A HREF="showlist.php?application=<?php echo"$application"; ?>&category=Popular">Most Popular</A>:</DIV>
|
||||
<?php
|
||||
$i=0;
|
||||
$sql = "SELECT TM.ID, TV.vID,TM.Name, TV.Version, TM.TotalDownloads, TM.downloadcount
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
WHERE `Type` = '$type' AND `AppName` = '$application' AND `minAppVer_int` <='$currentver' AND `maxAppVer_int` >= '$currentver' AND `downloadcount` > '0' AND `approved` = 'YES' ORDER BY `downloadcount` DESC ";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$i++;
|
||||
$id = $row["ID"];
|
||||
$vid = $row["vID"];
|
||||
$name = $row["Name"];
|
||||
$version = $row["Version"];
|
||||
$downloadcount = $row["downloadcount"];
|
||||
$totaldownloads = $row["TotalDownloads"];
|
||||
if ($lastname == $name) {$i--; continue; }
|
||||
echo"$i - <a href=\"moreinfo.php?application=$application&id=$id\">$name</a><br>\n";
|
||||
echo"<SPAN class=\"smallfont nocomment\">($downloadcount downloads)</SPAN><BR>\n";
|
||||
|
||||
$lastname = $name;
|
||||
if ($i >= "5") {break;}
|
||||
}
|
||||
?>
|
||||
<BR>
|
||||
</DIV>
|
||||
<DIV class="boxcolumns">
|
||||
<DIV class="boxheader"><A HREF="showlist.php?category=Top Rated">Top Rated</A>:</DIV>
|
||||
<?php
|
||||
$r=0;
|
||||
$usednames = array();
|
||||
$sql = "SELECT TM.ID, TV.vID, TM.Name, TV.Version, TM.Rating, TU.UserName
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_authorxref TAX ON TAX.ID = TM.ID
|
||||
INNER JOIN t_userprofiles TU ON TU.UserID = TAX.UserID
|
||||
WHERE `Type` = '$type' AND `AppName` = '$application' AND `minAppVer_int` <='$currentver' AND `maxAppVer_int` >= '$currentver' AND `Rating` > '0' AND `approved` = 'YES' ORDER BY `Rating` DESC, `Name` ASC, `Version` DESC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$r++; $s++;
|
||||
$id = $row["ID"];
|
||||
$vid = $row["vID"];
|
||||
$name = $row["Name"];
|
||||
$version = $row["Version"];
|
||||
$rating = $row["Rating"];
|
||||
$arraysearch = array_search("$name", $usednames);
|
||||
if ($arraysearch !== false AND $usedversions[$arraysearch]['version']<$version) {$r--; continue; } //
|
||||
echo"$r - <a href=\"moreinfo.php?application=$application&id=$id\">$name</a> ";
|
||||
|
||||
//$rating = round($rating);
|
||||
echo"<SPAN title=\"Rated: $rating of 5\" style=\"font-size: 8pt\">";
|
||||
for ($i = 1; $i <= floor($rating); $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/star_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
if ($rating>floor($rating)) {
|
||||
$val = ($rating-floor($rating))*10;
|
||||
echo"<IMG SRC=\"/images/stars/star_0$val.png\" BORDER=0 ALT=\"\">";
|
||||
$i++;
|
||||
}
|
||||
for ($i = $i; $i <= 5; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/graystar_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
echo"</SPAN><br>\n";
|
||||
//echo"<SPAN class=\"smallfont nocomment\">By $author</SPAN><BR>\n";
|
||||
$usednames[$s] = $name;
|
||||
$usedversions[$s] = $version;
|
||||
if ($r >= "5") {break;}
|
||||
}
|
||||
unset($usednames, $usedversions, $r, $s, $i);
|
||||
?>
|
||||
</DIV>
|
||||
<DIV class="boxcolumns">
|
||||
<DIV class="boxheader"><A HREF="showlist.php?category=Newest">Most Recent</A>:</DIV>
|
||||
<?php
|
||||
$i=0;
|
||||
$sql = "SELECT TM.ID, TV.vID, TM.Name, TV.Version, TV.DateAdded
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_os TOS ON TV.OSID = TOS.OSID
|
||||
WHERE `Type` = '$type' AND `AppName` = '$application' AND `minAppVer_int` <='$currentver' AND `maxAppVer_int` >= '$currentver' AND (`OSName` = '$_SESSION[app_os]' OR `OSName` = 'ALL') AND `approved` = 'YES' ORDER BY `DateAdded` DESC ";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$i++;
|
||||
$id = $row["ID"];
|
||||
$vid = $row["vID"];
|
||||
$name = $row["Name"];
|
||||
$version = $row["Version"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
//Create Customizeable Datestamp
|
||||
$timestamp = strtotime("$dateadded");
|
||||
$dateadded = gmdate("F d, Y g:i:sa", $timestamp); // $dateupdated = gmdate("F d, Y g:i:sa T", $timestamp);
|
||||
|
||||
if ($lastname == $name) {$i--; continue; }
|
||||
echo"$i - <a href=\"moreinfo.php?application=$application&id=$id&vid=$vid\">$name $version</a><BR>\n";
|
||||
echo"<SPAN class=\"smallfont nocomment\">($dateadded)</SPAN><BR>\n";
|
||||
|
||||
$lastname = $name;
|
||||
if ($i >= "5") {break;}
|
||||
}
|
||||
?>
|
||||
</DIV>
|
||||
</DIV>
|
||||
<BR>
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,106 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
//Get Full Information for the file requested.
|
||||
$sql = "SELECT `URI` FROM `t_version` WHERE `ID`='$_GET[id]' AND `vID`='$_GET[vid]' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$uri=$row["URI"];
|
||||
|
||||
header("Location: $uri");
|
||||
exit;
|
||||
|
||||
//XXX This codepath sucks performance wise and has been disabled. See Bug 267822.
|
||||
|
||||
// New DownloadCount management Code..
|
||||
//Check for user, to see if they recently accessed this file (filters duplicate/triplicate+ requests in a short period).
|
||||
$maxlife = date("YmdHis", mktime(date("H"), date("i")-10, date("s"), date("m"), date("d"), date("Y")));
|
||||
$sql = "SELECT `dID` FROM `t_downloads` WHERE `ID`='$_GET[id]' AND `vID`='$_GET[vid]' AND `user_ip`='$_SERVER[REMOTE_ADDR]' AND `user_agent` = '$_SERVER[HTTP_USER_AGENT]' AND `date`>'$maxlife' AND `type`='download' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)=="0") {
|
||||
//Insert a record of this download for the next 10 minutes anyway. :-)
|
||||
$today=date("YmdHis");
|
||||
$sql = "INSERT INTO `t_downloads` (`ID`,`date`,`vID`, `user_ip`, `user_agent`, `type`) VALUES ('$_GET[id]','$today','$_GET[vid]', '$_SERVER[REMOTE_ADDR]', '$_SERVER[HTTP_USER_AGENT]', 'download');";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
//Cleanup the Individual Downloads part of the table for old records
|
||||
$sql = "DELETE FROM `t_downloads` WHERE `date`<'$maxlife' AND `type`='download'";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
$today=date("Ymd")."000000";
|
||||
//Per day download tracking -- Record hits for this day in the record (if it doesn't exist create it)
|
||||
$sql = "SELECT `dID` FROM `t_downloads` WHERE `ID`='$_GET[id]' AND `date`='$today' AND `type`='count' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)=="0") {
|
||||
$sql = "INSERT INTO `t_downloads` (`ID`,`date`,`downloadcount`,`type`) VALUES ('$_GET[id]','$today','1','count');";
|
||||
} else {
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$sql = "UPDATE `t_downloads` SET `downloadcount`=downloadcount+1 WHERE `dID`='$row[dID]' LIMIT 1";
|
||||
}
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
|
||||
//Download Statistic Management Code
|
||||
// Maintain the last 7 days record count
|
||||
// This is also where the weekly w/e code would go. if that feature is ever created.
|
||||
$mindate = date("Ymd", mktime(0, 0, 0, date("m"), date("d")-7, date("Y")))."000000";
|
||||
$downloadcount="0";
|
||||
$sql = "SELECT `downloadcount` FROM `t_downloads` WHERE `ID`='$_GET[id]' AND `date`>='$mindate' AND `type`='count' ORDER BY `date` DESC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$downloadcount = $downloadcount+$row["downloadcount"];
|
||||
}
|
||||
//Update the 7 day count in the main record.
|
||||
$sql = "UPDATE `t_main` SET `downloadcount`='$downloadcount' WHERE `ID`='$_GET[id]' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
//Update the total downloadcount in the main record.
|
||||
$sql = "UPDATE `t_main` SET `TotalDownloads`=TotalDownloads+1 WHERE `ID`='$_GET[id]' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
//Clean up the Counts per day for >8 days. (and in the future, compile the week/ending records for this data)
|
||||
$sql = "DELETE FROM `t_downloads` WHERE `ID`='$_GET[id]' AND `date`<'$mindate' AND `type`='count'";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
|
||||
}
|
||||
|
||||
//Send User on their way to the file...
|
||||
header("Location: $uri")
|
||||
?>
|
||||
@@ -1,550 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<?php
|
||||
//Bookmarking-Friendly Page Title
|
||||
$sql = "SELECT Name FROM `t_main` WHERE ID = '$_GET[id]' AND Type = 'E' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
if (mysql_num_rows($sql_result)===0) {
|
||||
$return = page_error("1","Extension ID is Invalid or Missing.");
|
||||
exit;
|
||||
|
||||
}
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
|
||||
//Page Titles
|
||||
$pagetitles = array("releases"=>"All Releases", "comments"=>"User Comments", "staffreview"=>"Editor Review", "opinion"=>" My Opinion");
|
||||
$pagetitle = $pagetitles[$_GET["page"]];
|
||||
?>
|
||||
|
||||
<TITLE>Mozilla Update :: Extensions -- More Info: <?php echo"$row[Name]"; if ($pagetitle) {echo" - $pagetitle"; } ?></TITLE>
|
||||
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
include"$page_header";
|
||||
$type = "E";
|
||||
$category=$_GET["category"];
|
||||
include"inc_sidebar.php";
|
||||
?>
|
||||
<DIV id="content">
|
||||
<?php
|
||||
//Get Author Data
|
||||
$sql2 = "SELECT TM.Name, TU.UserName, TU.UserID, TU.UserEmail FROM `t_main` TM
|
||||
LEFT JOIN t_authorxref TAX ON TM.ID = TAX.ID
|
||||
INNER JOIN t_userprofiles TU ON TAX.UserID = TU.UserID
|
||||
WHERE TM.ID = '$_GET[id]'
|
||||
ORDER BY `Type` , `Name` ASC ";
|
||||
$sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row2 = mysql_fetch_array($sql_result2)) {
|
||||
$authorarray[$row2[Name]][] = $row2["UserName"];
|
||||
$authorids[$row2[UserName]] = $row2["UserID"];
|
||||
}
|
||||
|
||||
|
||||
//Run Query and Create List
|
||||
$s = "0";
|
||||
$sql = "SELECT TM.ID, TM.Name, TM.DateAdded, TM.DateUpdated, TM.Homepage, TM.Description, TM.Rating, TV.vID, TV.Version, TV.MinAppVer, TV.MaxAppVer, TV.Size, TV.DateAdded AS VerDateAdded, TV.DateUpdated AS VerDateUpdated, TV.URI, TV.Notes, TM.TotalDownloads, TA.AppName, TOS.OSName, TP.PreviewURI
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_os TOS ON TV.OSID = TOS.OSID
|
||||
LEFT JOIN t_previews TP ON TV.vID = TP.vID
|
||||
WHERE TM.ID = '$_GET[id]' AND `approved` = 'YES' ";
|
||||
if ($_GET["vid"]) { $sql .=" AND TV.vID = '$_GET[vid]' "; }
|
||||
$sql .= "ORDER BY `Name` , `Version` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
|
||||
|
||||
$v++;
|
||||
$id = $row["ID"];
|
||||
$type = $row["Type"];
|
||||
$name = $row["Name"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$dateupdated = $row["DateUpdated"];
|
||||
$homepage = $row["Homepage"];
|
||||
$description = $row["Description"];
|
||||
$rating = $row["Rating"];
|
||||
$authors = $authorarray[$name];
|
||||
$osname = $row["OSName"];
|
||||
|
||||
$vid = $row["vID"];
|
||||
if (!$_GET['vid']) {$_GET['vid']=$vid;}
|
||||
$appname = $row["AppName"];
|
||||
$minappver = $row["MinAppVer"];
|
||||
$maxappver = $row["MaxAppVer"];
|
||||
$verdateadded = $row["VerDateAdded"];
|
||||
$verdateupdated = $row["VerDateUpdated"];
|
||||
$filesize = $row["Size"];
|
||||
$notes = $row["Notes"];
|
||||
$version = $row["Version"];
|
||||
$uri = $row["URI"];
|
||||
$previewuri = $row["PreviewURI"];
|
||||
$downloadcount = $row["TotalDownloads"];
|
||||
|
||||
if ($VerDateAdded > $dateadded) {$dateadded = $VerDateAdded; }
|
||||
if ($VerDateUpdated > $dateupdated) {$dateupdated = $VerDateUpdated; }
|
||||
|
||||
|
||||
|
||||
//Turn Authors Array into readable string...
|
||||
$authorcount = count($authors);
|
||||
foreach ($authors as $author) {
|
||||
$userid = $authorids[$author];
|
||||
$n++;
|
||||
$authorstring .= "<A HREF=\"authorprofiles.php?application=$application&id=$userid\">$author</A>";
|
||||
if ($authorcount != $n) {$authorstring .=", "; }
|
||||
|
||||
}
|
||||
$authors = $authorstring;
|
||||
unset($authorstring, $n); // Clear used Vars..
|
||||
|
||||
//Create Customizeable Timestamp for DateAdded/DateUpdated
|
||||
$day=substr($dateadded,8,2); //get the day
|
||||
$month=substr($dateadded,5,2); //get the month
|
||||
$year=substr($dateadded,0,4); //get the year
|
||||
$hour=substr($dateadded,11,2); //get the hour
|
||||
$minute=substr($dateadded,14,2); //get the minute
|
||||
$second=substr($dateadded,17,2); //get the sec
|
||||
$datimestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
|
||||
$day=substr($dateupdated,8,2); //get the day
|
||||
$month=substr($dateupdated,5,2); //get the month
|
||||
$year=substr($dateupdated,0,4); //get the year
|
||||
$hour=substr($dateupdated,11,2); //get the hour
|
||||
$minute=substr($dateupdated,14,2); //get the minute
|
||||
$second=substr($dateupdated,17,2); //get the sec
|
||||
$dutimestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
|
||||
$dateadded = gmdate("F d, Y g:i:sa", $datimestamp); //gmdate("F d, Y", $datimestamp);
|
||||
$dateupdated = gmdate("F d, Y g:i:sa", $dutimestamp); //gmdate("F d, Y", $dutimestamp);
|
||||
|
||||
//Rating
|
||||
if (!$rating) { $rating="0"; }
|
||||
?>
|
||||
|
||||
|
||||
<DIV class="tabbar">
|
||||
<DIV class="tab"><A HREF="?<?php echo"application=$application&id=$id&vid=$vid"; ?>">More Info</A></DIV>
|
||||
<DIV class="tab"><A HREF="?<?php echo"application=$application&id=$id&vid=$vid&page=releases"; ?>">All Releases</A></DIV>
|
||||
<DIV class="tab"><A HREF="?<?php echo"application=$application&id=$id&vid=$vid&page=comments"; ?>">Comments</A></DIV>
|
||||
<DIV class="tab"><A HREF="?<?php echo"application=$application&id=$id&vid=$vid&page=staffreview"; ?>">Editor Review</A></DIV>
|
||||
<DIV class="tab"><A HREF="?<?php echo"application=$application&id=$id&vid=$vid&page=opinion"; ?>">My Opinion</A></DIV>
|
||||
</DIV>
|
||||
<?php
|
||||
echo"<DIV class=\"item\">\n";
|
||||
//echo"<DIV style=\"height: 100px\">"; //Why?!?
|
||||
if ($previewuri) {
|
||||
list($width, $height, $imagetype, $attr) = getimagesize("$websitepath"."$previewuri");
|
||||
|
||||
echo"<IMG SRC=\"$previewuri\" BORDER=0 HEIGHT=$height WIDTH=$width STYLE=\"float: right; padding-right: 5px\" ALT=\"$name preview\">";
|
||||
}
|
||||
|
||||
//Upper-Right Side Box
|
||||
echo"<DIV class=\"liststars\" title=\"$rating of 5 stars\" style=\"font-size: 8pt\"><A HREF=\"moreinfo.php?application=$application&id=$id&page=comments\">";
|
||||
for ($i = 1; $i <= floor($rating); $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/star_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
if ($rating>floor($rating)) {
|
||||
$val = ($rating-floor($rating))*10;
|
||||
echo"<IMG SRC=\"/images/stars/star_0$val.png\" BORDER=0 ALT=\"\">";
|
||||
$i++;
|
||||
}
|
||||
for ($i = $i; $i <= 5; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/graystar_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
echo"</A></DIV>\n";
|
||||
|
||||
echo"<DIV class=\"itemtitle\">";
|
||||
echo"<SPAN class=\"title\"><A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid\">$name $version</A></SPAN><BR>";
|
||||
echo"<SPAN class=\"authorline\">By $authors</SPAN><br>";
|
||||
echo"</DIV>";
|
||||
|
||||
//Description & Version Notes
|
||||
echo"<SPAN class=\"itemdescription\">";
|
||||
echo"$description<BR>";
|
||||
if ($notes) {echo"$notes"; }
|
||||
echo"</SPAN>\n";
|
||||
|
||||
//echo"</DIV>\n";
|
||||
echo"<BR>\n\n";
|
||||
|
||||
$page = $_GET["page"];
|
||||
if (!$page or $page=="general") {
|
||||
?>
|
||||
<DIV class="downloadbox">
|
||||
<?php
|
||||
//Create DateStamp for Version Release Date ($verdateadded)
|
||||
$day=substr($verdateadded,8,2); //get the day
|
||||
$month=substr($verdateadded,5,2); //get the month
|
||||
$year=substr($verdateadded,0,4); //get the year
|
||||
$hour=substr($verdateadded,11,2); //get the hour
|
||||
$minute=substr($verdateadded,14,2); //get the minute
|
||||
$second=substr($verdateadded,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$verdateadded = gmdate("F d, Y", $timestamp);
|
||||
|
||||
//Calculate Download Time
|
||||
$speed = "56"; //In Kbit/s
|
||||
$speedinkb = "5.5"; //$speedinkb = $speed/8; //In KB/s
|
||||
$timeinsecs = round($filesize/$speedinkb);
|
||||
$time_minutes = floor($timeinsecs/60);
|
||||
$time_seconds = round($timeinsecs-($time_minutes*60),-1);
|
||||
$time_seconds = $time_seconds+2; //Compensate for mirror overhead
|
||||
|
||||
$time = "About ";
|
||||
if ($time_minutes>0) {
|
||||
$time .= "$time_minutes minutes ";
|
||||
}
|
||||
$time .="$time_seconds seconds";
|
||||
|
||||
$filename = basename($uri);
|
||||
|
||||
echo"
|
||||
<SPAN style=\"itemdescription\">Released on $verdateadded</SPAN><BR>
|
||||
|
||||
|
||||
<DIV class=\"moreinfoinstall\">";
|
||||
if ($appname=="Thunderbird") {
|
||||
echo"<A HREF=\"install.php/$filename?id=$id&vid=$vid\" TITLE=\"Download $name $version (Right-Click to Download)\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" ALT=\"\"> ( Download Now )</A><BR>";
|
||||
} else {
|
||||
echo"<A HREF=\"javascript:void(InstallTrigger.install({'$name $version':'$uri'}))\" TITLE=\"Install $name $version\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" ALT=\"\"> ( Install Now )</A><BR>";
|
||||
//echo"<A HREF=\"install.php/$filename?id=$id&vid=$vid\" TITLE=\"Install $name $version (Right-Click to Download)\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" ALT=\"\"> ( Install Now )</A><BR>";
|
||||
}
|
||||
echo"
|
||||
<SPAN class=\"filesize\"> $filesize KB, ($time @ $speed"."k)</SPAN></DIV>
|
||||
<BR>";
|
||||
if ($application=="thunderbird") {
|
||||
echo"<SPAN style=\"font-size: 10pt; color: #00F\">Extension Install Instructions for Thunderbird Users:</SPAN><BR>
|
||||
<SPAN style=\"font-size: 8pt;\">(1) Right-Click the link above and choose \"Save Link As...\" to Download and save the file to your hard disk.<BR>
|
||||
(2) In Mozilla Thunderbird, open the extension manager (Tools Menu/Extensions)<BR>
|
||||
(3) Click the Install button, and locate/select the file you downloaded and click \"OK\"</SPAN><BR>
|
||||
";
|
||||
}
|
||||
if ($homepage) {echo"<SPAN style=\"font-size:10pt\">Having a problem with this Extension? For Help and Technical Support, visit the <A HREF=\"$homepage\">Extension's Homepage</A>.</SPAN>";}
|
||||
|
||||
echo"<UL style=\"font-size:10pt\">";
|
||||
if ($homepage) {echo"<LI> <A HREF=\"$homepage\">Extension Home Page</A>"; }
|
||||
if ($appname !="Thunderbird") {echo"<LI> <a href=\"install.php/$filename?id=$id&vid=$vid\" TITLE=\"Right-click to Save\">Download Extension</A>"; }
|
||||
echo"<LI> <A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid&page=releases\">Other Versions</A>";
|
||||
?>
|
||||
</UL>
|
||||
</DIV>
|
||||
|
||||
<DIV class="commentbox">
|
||||
<DIV class="boxheader">User Comments:</DIV>
|
||||
<BR>
|
||||
<?php
|
||||
$sql = "SELECT CommentName, CommentTitle, CommentNote, CommentDate, CommentVote FROM `t_feedback` WHERE ID = '$_GET[id]' AND CommentNote IS NOT NULL ORDER BY `CommentDate` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$num_results = mysql_num_rows($sql_result);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$commentname = $row["CommentName"];
|
||||
$commenttitle = $row["CommentTitle"];
|
||||
$commentnotes = $row["CommentNote"];
|
||||
$commentdate = $row["CommentDate"];
|
||||
$rating = $row["CommentVote"];
|
||||
|
||||
//Create Customizeable Datestamp
|
||||
$day=substr($commentdate,8,2); //get the day
|
||||
$month=substr($commentdate,5,2); //get the month
|
||||
$year=substr($commentdate,0,4); //get the year
|
||||
$hour=substr($commentdate,11,2); //get the hour
|
||||
$minute=substr($commentdate,14,2); //get the minute
|
||||
$second=substr($commentdate,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$commentdate = gmdate("F d, Y g:ia", $timestamp);
|
||||
|
||||
echo"<DIV class=\"commenttitlebar\">";
|
||||
echo"<SPAN class=\"commenttitle\">$commenttitle</SPAN>";
|
||||
echo"<SPAN class=\"liststars\">";
|
||||
|
||||
for ($i = 1; $i <= $rating; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/star_icon.png\" BORDER=0 WIDTH=16 HEIGHT=16 ALT=\"*\">";
|
||||
}
|
||||
for ($i = $i; $i <= 5; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/graystar_icon.png\" BORDER=0 WIDTH=16 HEIGHT=16 ALT=\"\">";
|
||||
}
|
||||
echo"</SPAN>";
|
||||
echo"</DIV>";
|
||||
echo" By $commentname<BR>\n";
|
||||
echo" <BR>\n";
|
||||
echo"$commentnotes<BR>\n\n";
|
||||
echo" <BR>\n";
|
||||
echo"<DIV class=\"commentfooter\">\n";
|
||||
echo"$commentdate | <A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid&page=comments\">More Comments...</A> | <A HREF=\"moreinfo.php?id=$id&vid=$vid&category=$category&vid=$vid&page=opinion\">Rate It!</A>\n";
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
|
||||
if ($num_results=="0") {
|
||||
echo"<DIV class=\"nocomment\">";
|
||||
echo"Nobody's Commented on this Extension Yet<BR>";
|
||||
echo"Be the First! <A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid&page=opinion\">Rate It!</A>";
|
||||
echo"</DIV>";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</DIV>
|
||||
|
||||
<?php
|
||||
} else if ($page=="releases") {
|
||||
|
||||
echo"<DIV class=\"mipageheading\">";
|
||||
echo"Recent Releases:<BR>";
|
||||
echo"</DIV>";
|
||||
|
||||
$sql = "SELECT TV.vID, TV.Version, TV.MinAppVer, TV.MaxAppVer, TV.Size, TV.URI, TV.Notes, TA.AppName, TOS.OSName
|
||||
FROM `t_version` TV
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_os TOS ON TV.OSID = TOS.OSID
|
||||
WHERE TV.ID = '$_GET[id]' AND `approved` = 'YES'
|
||||
ORDER BY `Version` DESC, `OSName` ASC
|
||||
LIMIT 0, 10";
|
||||
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$vid = $row["vID"];
|
||||
$minappver = $row["MinAppVer"];
|
||||
$maxappver = $row["MaxAppVer"];
|
||||
$filesize = $row["Size"];
|
||||
$notes = $row["Notes"];
|
||||
$version = $row["Version"];
|
||||
$uri = $row["URI"];
|
||||
$osname = $row["OSName"];
|
||||
$appname = $row["AppName"];
|
||||
$filename = basename($uri);
|
||||
|
||||
echo"<DIV>"; //Open Version DIV
|
||||
|
||||
//Description & Version Notes
|
||||
echo"<SPAN class=\"itemdescription\">";
|
||||
echo"<SPAN class=\"listtitle\"><A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid\">Version $version</A></SPAN><br>\n";
|
||||
if ($notes) {echo"$notes"; }
|
||||
echo"</SPAN>\n";
|
||||
|
||||
//Icon Bar Modules
|
||||
echo"<DIV style=\"height: 34px\">";
|
||||
echo"<DIV class=\"iconbar\" style=\"width: 100px;\">";
|
||||
|
||||
if ($appname=="Thunderbird") {
|
||||
echo"<A HREF=\"install.php/$filename?id=$id&vid=$vid\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"Install $name (Right-Click to Download)\" ALT=\"\">Download</A>";
|
||||
} else {
|
||||
echo"<A HREF=\"javascript:void(InstallTrigger.install({'$name $version':'$uri'}))\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"Install $name (Right-Click to Download)\" ALT=\"\">Install</A>";
|
||||
}
|
||||
|
||||
echo"<BR><SPAN class=\"filesize\">Size: $filesize kb</SPAN></DIV>";
|
||||
//echo"<DIV class=\"iconbar\" style=\"width: 100px;\"><A HREF=\"install.php/$filename?id=$id&vid=$vid\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"Install $name (Right-Click to Download)\" ALT=\"\">Install</A><BR><SPAN class=\"filesize\">Size: $filesize kb</SPAN></DIV>";
|
||||
echo"<DIV class=\"iconbar\"><IMG SRC=\"/images/".strtolower($appname)."_icon.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float: left\" ALT=\"$appname\"> Works with:<BR> $minappver - $maxappver</DIV>";
|
||||
echo"<DIV class=\"iconbar\" style=\"width: 90px;\"><IMG SRC=\"/images/".strtolower($osname)."_icon.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float: left\" ALT=\"\">OS:<BR>"; if($osname=="ALL") {echo"All OSes";} else {echo"$osname";} echo"</DIV>";
|
||||
echo"</DIV>";
|
||||
|
||||
echo"</DIV>";
|
||||
}
|
||||
|
||||
//End General Page
|
||||
} else if ($page=="comments") {
|
||||
//Comments/Ratings Page
|
||||
echo"<DIV class=\"mipageheading\">";
|
||||
echo"User Comments:<BR>";
|
||||
echo"</DIV>";
|
||||
$sql = "SELECT CommentName, CommentTitle, CommentNote, CommentDate, CommentVote FROM `t_feedback` WHERE ID = '$_GET[id]' AND CommentNote IS NOT NULL ORDER BY `CommentDate` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$num_results = mysql_num_rows($sql_result);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$name = $row["CommentName"];
|
||||
$title = $row["CommentTitle"];
|
||||
$notes = $row["CommentNote"];
|
||||
$date = $row["CommentDate"];
|
||||
$rating = $row["CommentVote"];
|
||||
|
||||
echo"<DIV class=\"commenttitlebar\">";
|
||||
echo"<SPAN class=\"commenttitle\">$title</SPAN>";
|
||||
echo"<SPAN class=\"liststars\">";
|
||||
|
||||
for ($i = 1; $i <= $rating; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/star_icon.png\" BORDER=0 WIDTH=16 HEIGHT=16 ALT=\"*\">";
|
||||
}
|
||||
for ($i = $i; $i <= 5; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/graystar_icon.png\" BORDER=0 WIDTH=16 HEIGHT=16 ALT=\"\">";
|
||||
}
|
||||
echo"</SPAN>";
|
||||
echo"</DIV>";
|
||||
echo"$notes<BR>\n\n";
|
||||
|
||||
echo"<DIV class=\"commentfooter\">\n";
|
||||
echo"<SPAN style=\"padding-left: 30px; font-size: 8pt; font-weight: bold\">Posted on $date by $name</SPAN><br>";
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
|
||||
if ($num_results=="0") {
|
||||
echo"<DIV class=\"nocomment\">";
|
||||
echo"Nobody has commented on this extension yet...<BR>
|
||||
Be the First!
|
||||
<A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid&page=opinion\">Leave your comments</A>...";
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
|
||||
|
||||
echo"<DIV style=\"height: 5px;\"></DIV>";
|
||||
|
||||
} else if ($page=="staffreview") {
|
||||
//Staff/Editor Review Tab
|
||||
echo"<DIV class=\"mipageheading\">";
|
||||
echo"Editor Review:<BR>";
|
||||
echo"</DIV>";
|
||||
|
||||
echo"<DIV class=\"reviewbox\">\n";
|
||||
$sql = "SELECT TR.ID, `Title`, TR.DateAdded, `Body`, `Type`, `Pick`, TU.UserName FROM `t_reviews` TR
|
||||
INNER JOIN t_main TM ON TR.ID = TM.ID
|
||||
INNER JOIN t_userprofiles TU ON TR.AuthorID = TU.UserID
|
||||
WHERE `Type` = 'E' AND TR.ID = '$_GET[id]' ORDER BY `rID` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$num_results = mysql_num_rows($sql_result);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$id = $row["ID"];
|
||||
$title = $row["Title"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$body = $row["Body"];
|
||||
$pick = $row["Pick"];
|
||||
$username = $row["UserName"];
|
||||
|
||||
//Create Customizeable Timestamp
|
||||
// $day=substr($dateadded,8,2); //get the day
|
||||
// $month=substr($dateadded,5,2); //get the month
|
||||
// $year=substr($dateadded,0,4); //get the year
|
||||
// $hour=substr($dateadded,11,2); //get the hour
|
||||
// $minute=substr($dateadded,14,2); //get the minute
|
||||
// $second=substr($dateadded,17,2); //get the sec
|
||||
// $timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$timestamp = strtotime("$dateadded");
|
||||
$date = gmdate("F, Y", $timestamp);
|
||||
$posteddate = date("F j Y, g:i:sa", $timestamp);
|
||||
|
||||
|
||||
echo"$title<br>\n";
|
||||
if ($pick=="YES") {echo"<SPAN class=\"itemdescription\"> $date Editors Pick<BR>\n"; }
|
||||
echo"<BR>\n";
|
||||
echo"$body</SPAN><BR>\n";
|
||||
echo"<DIV class=\"commentfooter\">Posted on $posteddate by $username</DIV>\n";
|
||||
}
|
||||
$typename = "extension";
|
||||
if ($num_results=="0") {
|
||||
echo"
|
||||
<SPAN style=\"font-weight: bold\">
|
||||
This $typename has not yet been reviewed.<BR><BR>
|
||||
|
||||
To see what other users think of this extension, view the <A HREF=\"moreinfo.php?application=$application&id=$id&page=comments\">User Comments...</A>
|
||||
</SPAN>
|
||||
";
|
||||
|
||||
|
||||
}
|
||||
echo"</DIV>\n";
|
||||
|
||||
} else if ($page=="opinion") {
|
||||
//My Opinion Tab
|
||||
echo"<DIV class=\"mipageheading\">";
|
||||
echo"Your Rating / Feedback:<BR>";
|
||||
echo"</DIV>";
|
||||
?>
|
||||
<?php
|
||||
if ($_GET["error"]=="norating") {
|
||||
echo"<DIV class=\"errorbox\">\n
|
||||
Your comment submission had the following error(s), please fix these errors and try again.<br>\n
|
||||
Rating field cannot be left blank.<br>\n
|
||||
</DIV>\n";
|
||||
}
|
||||
?>
|
||||
<DIV class="opinionform">
|
||||
<FORM NAME="opinon" METHOD="POST" ACTION="../core/postfeedback.php">
|
||||
<INPUT NAME="id" TYPE="HIDDEN" VALUE="<?php echo"$id"; ?>">
|
||||
<INPUT NAME="vid" TYPE="HIDDEN" VALUE="<?php echo"$vid"; ?>">
|
||||
<INPUT NAME="type" TYPE="HIDDEN" value="E">
|
||||
Your Name:<BR>
|
||||
<INPUT NAME="name" TYPE="TEXT" SIZE=30 MAXLENGTH=30><BR>
|
||||
|
||||
Rating:*<BR>
|
||||
<SELECT NAME="rating">
|
||||
<OPTION value="">Rating:
|
||||
<OPTION value="5">5 Stars
|
||||
<OPTION value="4">4 Stars
|
||||
<OPTION value="3">3 Stars
|
||||
<OPTION value="2">2 Stars
|
||||
<OPTION value="1">1 Star
|
||||
<OPTION value="0">0 Stars
|
||||
</SELECT><BR>
|
||||
|
||||
Title:<BR>
|
||||
<INPUT NAME="title" TYPE="TEXT" SIZE=30 MAXLENGTH=50><BR>
|
||||
|
||||
Review/Comments:<BR>
|
||||
<TEXTAREA NAME="comments" ROWS=5 COLS=55></TEXTAREA><BR>
|
||||
<SPAN class="smallfont">No Comment?<INPUT NAME="commententered" TYPE="CHECKBOX" VALUE="FALSE"></SPAN><BR>
|
||||
<INPUT NAME="submit" TYPE="SUBMIT" VALUE="Post"> <INPUT NAME="reset" TYPE="RESET" VALUE="Reset"><BR>
|
||||
<SPAN class="smallfont">* Required Fields</SPAN>
|
||||
</FORM>
|
||||
|
||||
</DIV>
|
||||
<?php
|
||||
} // End Pages
|
||||
echo"<DIV class=\"baseline\">";
|
||||
echo"Date Added: $dateadded | Last Updated: $dateupdated | ";
|
||||
echo"Total Downloads: $downloadcount<BR>";
|
||||
echo"</DIV>\n";
|
||||
echo"</DIV>\n";
|
||||
echo"<BR>\n";
|
||||
?>
|
||||
</DIV>
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
//Mozilla Update Message System
|
||||
//Send Mail script...
|
||||
exit;
|
||||
require"../core/config.php";
|
||||
|
||||
if (!$_POST["senduserid"]) {
|
||||
exit("<B>Error: no valid user to e-mail, possible attempt to spam detected...</B>");
|
||||
}
|
||||
|
||||
//Get E-Mail Address from DB based on passed data..
|
||||
$sql = "SELECT `UserEmail` FROM `t_userprofiles` WHERE `UserID` = '$_POST[senduserid]' AND `UserEmailHide`='0' LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("<FONT COLOR=\"#FF0000\"><B>MySQL Error ".mysql_errno().": ".mysql_error()."</B></FONT>", E_USER_NOTICE);
|
||||
$row = mysql_fetch_array($sql_result);
|
||||
$to_address=$row["UserEmail"];
|
||||
|
||||
|
||||
//All From_, To_, and subject variables are passed from the form
|
||||
// and do not need to be defined here.. unless debugging..
|
||||
|
||||
$from_name = $_POST["fromname"];
|
||||
$from_address = $_POST["fromemail"];
|
||||
$subject = $_POST["subject"];
|
||||
|
||||
//Anti-Abuse
|
||||
$findme = '@';
|
||||
$pos = strpos($to_address, $findme);
|
||||
|
||||
if ($pos === false) {
|
||||
//This isn't a valid e-mail address being passed...
|
||||
//Send the e-mail message to the $from_address, just for fun..
|
||||
$to_address = $from_address;
|
||||
}
|
||||
|
||||
$message = $_POST["body"];
|
||||
|
||||
//Message Footer (Auto-Appended to Messages sent using this form.
|
||||
$message .= "\n\n";
|
||||
$message .= "____________________________________\n";
|
||||
$message .= "Message sent through the Mozilla Update Message system.\n
|
||||
The system allows visitors to send you e-mail without revealing your e-mail address to them.
|
||||
If you no longer wish to receive e-mail from visitors, you may change your preferences online at http;//update.mozilla.org.\n";
|
||||
|
||||
|
||||
$headers .= "MIME-Version: 1.0\r\n";
|
||||
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
|
||||
$headers .= "From: ".$from_name." <".$from_address.">\r\n";
|
||||
$headers .= "Reply-To: ".$from_name." <".$from_address.">\r\n";
|
||||
$headers .= "X-Priority: 3\r\n";
|
||||
$headers .= "X-MSMail-Priority: Normal\r\n";
|
||||
$headers .= "X-Mailer: Mozilla Update Message System 1.0";
|
||||
|
||||
$mailstatus = mail($to_address, $subject, $message, $headers);
|
||||
|
||||
|
||||
|
||||
if ($mailstatus===FALSE) {
|
||||
//Message Unsuccessful
|
||||
$return_path="extensions/authorprofiles.php?id=$_POST[senduserid]&mail=unsuccessful";
|
||||
|
||||
} else if ($mailstatus===TRUE) {
|
||||
//Message Successful
|
||||
$return_path="extensions/authorprofiles.php?id=$_POST[senduserid]&mail=successful";
|
||||
|
||||
}
|
||||
header("Location: http://$_SERVER[HTTP_HOST]/$return_path#email");
|
||||
exit;
|
||||
|
||||
?>
|
||||
@@ -1,484 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
|
||||
<?php
|
||||
//----------------------------
|
||||
//Global General $_GET variables
|
||||
//----------------------------
|
||||
//Detection Override
|
||||
if ($_GET["version"]) {$app_version=$_GET["version"]; $_SESSION["app_version"]=$_GET["version"];}
|
||||
|
||||
if ($_GET["numpg"]) {$_SESSION["items_per_page"]=$_GET["numpg"]; }
|
||||
if ($_SESSION["items_per_page"]) {$items_per_page = $_SESSION["items_per_page"];} else {$items_per_page="10";}//Default Num per Page is 10
|
||||
|
||||
if ($_GET["category"]) { $_SESSION["category"] = $_GET["category"]; }
|
||||
if ($_SESSION["category"]) {$category = $_SESSION["category"];}
|
||||
if ($category=="All") {$category="";}
|
||||
|
||||
|
||||
if (!$_GET["pageid"]) {$pageid="1"; } else { $pageid = $_GET["pageid"]; } //Default PageID is 1
|
||||
$type="E"; //Default Type is E
|
||||
|
||||
unset($typename);
|
||||
$types = array("E"=>"Extensions","T"=>"Themes","U"=>"Updates");
|
||||
$typename = $types["$type"];
|
||||
|
||||
//RSS Autodiscovery Link Stuff
|
||||
switch ($_SESSION["category"]) {
|
||||
case "Newest":
|
||||
$rsslist = "newest";
|
||||
break;
|
||||
case "Popular":
|
||||
$rsslist = "popular";
|
||||
break;
|
||||
case "Top Rated":
|
||||
$rsslist = "rated";
|
||||
break;
|
||||
}
|
||||
|
||||
$rssfeed = "rss/?application=" . $application . "&type=" . $type . "&list=" . $rsslist;
|
||||
|
||||
if (!$category) {$categoryname = "All $typename"; } else {$categoryname = $category; }
|
||||
?>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<TITLE>Mozilla Update :: Extensions - List - <?php echo"$categoryname"; if ($pageid) {echo" - Page $pageid"; } ?></TITLE>
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
<?php
|
||||
if ($rsslist) {
|
||||
echo"<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS\" href=\"http://$_SERVER[HTTP_HOST]/$rssfeed\">";
|
||||
}
|
||||
?>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
include"$page_header";
|
||||
|
||||
// -----------------------------------------------
|
||||
// Begin Content of the Page Here
|
||||
// -----------------------------------------------
|
||||
|
||||
include"inc_sidebar.php";
|
||||
|
||||
echo"<DIV id=\"content\">\n"; // Begin Content Area
|
||||
//Query for List Creation
|
||||
$s = "0";
|
||||
$startpoint = ($pageid-1)*$items_per_page;
|
||||
if ($category=="Editors Pick" or $category=="Newest" or $category=="Popular" or $category=="Top Rated") {
|
||||
if ($category =="Editors Pick") {
|
||||
$editorpick="true";
|
||||
} else if ($category =="Newest") {
|
||||
$orderby = "TV.DateAdded DESC, `Name` ASC";
|
||||
} else if ($category =="Popular") {
|
||||
$orderby = "TM.TotalDownloads DESC, `Name` ASC";
|
||||
} else if ($category =="Top Rated") {
|
||||
$orderby = "TM.Rating DESC, `Name` ASC";
|
||||
}
|
||||
$catname = $category;
|
||||
$category = "%";
|
||||
}
|
||||
if ($app_version=="0.10") {$app_version="0.95"; }
|
||||
$sql = "SELECT TM.ID, TM.Name, TM.DateAdded, TM.DateUpdated, TM.Homepage, TM.Description, TM.Rating, TM.TotalDownloads, TV.vID,
|
||||
SUBSTRING(MAX(CONCAT(LPAD(TV.Version, 6, '0'), TV.vID)), 7) AS MAXvID,
|
||||
MAX(TV.Version) AS Version,
|
||||
TA.AppName, TOS.OSName
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_os TOS ON TV.OSID = TOS.OSID ";
|
||||
if ($category && $category !=="%") { $sql .="INNER JOIN t_categoryxref TCX ON TM.ID = TCX.ID
|
||||
INNER JOIN t_categories TC ON TCX.CategoryID = TC.CategoryID "; }
|
||||
if ($editorpick=="true") { $sql .="INNER JOIN t_reviews TR ON TM.ID = TR.ID "; }
|
||||
$sql .="WHERE Type = '$type' AND AppName = '$application' AND `approved` = 'YES' ";
|
||||
if ($editorpick=="true") { $sql .="AND TR.Pick = 'YES' "; }
|
||||
if ($category && $category !=="%") {$sql .="AND CatName LIKE '$category' ";}
|
||||
if ($app_version) { $sql .=" AND TV.MinAppVer_int <= '".strtolower($app_version)."' AND TV.MaxAppVer_int >= '".strtolower($app_version)."' ";}
|
||||
if ($OS) { $sql .=" AND (TOS.OSName = '$OS' OR TOS.OSName = 'All') "; }
|
||||
$sql .="GROUP BY `Name` ";
|
||||
if ($orderby) {
|
||||
$sql .="ORDER BY $orderby";
|
||||
} else {
|
||||
$sql .="ORDER BY `Name` , `Version` DESC ";
|
||||
}
|
||||
|
||||
$resultsquery = $sql;
|
||||
unset($sql);
|
||||
|
||||
//Get Total Results from Result Query & Populate Page Control Vars.
|
||||
$sql_result = mysql_query($resultsquery, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$totalresults = mysql_num_rows($sql_result);
|
||||
|
||||
$num_pages = ceil($totalresults/$items_per_page); //Total # of Pages
|
||||
if ($pageid>$num_pages) {$pageid=$num_pages;} //Check PageId for Validity
|
||||
$startpoint = ($pageid-1)*$items_per_page;
|
||||
if ($startpoint<0) {$startpoint=0; $startitem=0;}
|
||||
$startitem = $startpoint+1;
|
||||
$enditem = $startpoint+$items_per_page;
|
||||
if ($totalresults=="0") {$startitem = "0"; }
|
||||
if ($enditem>$totalresults) {$enditem=$totalresults;} //Verify EndItem
|
||||
|
||||
|
||||
if ($_GET[nextnum]) {$startpoint = $_GET["nextnum"]; }
|
||||
//$resultsquery = str_replace("GROUP BY `Name` ", "", $resultsquery);
|
||||
$resultsquery .= " LIMIT $startpoint , $items_per_page"; //Append LIMIT clause to result query
|
||||
|
||||
if ($category=="%") {$category = $catname; unset($catname); }
|
||||
|
||||
//Now Showing Box
|
||||
echo"<DIV id=\"listnav\">";
|
||||
if (!$OS) {$OS="all";}
|
||||
if (!$category) {$categoryname="All"; } else {$categoryname = $category;}
|
||||
echo"<DIV class=\"pagenum\" "; if ($application!="mozilla") {echo" style=\"margin-right: 58%;\""; } echo">";
|
||||
$previd=$pageid-1;
|
||||
if ($previd >"0") {
|
||||
echo"<a href=\"?application=$application&version=$app_version&category=$category&numpg=$items_per_page&pageid=$previd\">« Previous</A> • ";
|
||||
}
|
||||
echo"Page $pageid of $num_pages";
|
||||
|
||||
$nextid=$pageid+1;
|
||||
if ($pageid <$num_pages) {
|
||||
echo" • <a href=\"?application=$application&version=$app_version&category=$category&numpg=$items_per_page&pageid=$nextid\">Next »</a>";
|
||||
}
|
||||
|
||||
echo"</DIV>\n";
|
||||
|
||||
echo"<SPAN class=\"listtitle\">".ucwords("$application $typename » $categoryname ")."</SPAN><br>";
|
||||
echo"".ucwords("$typename")." $startitem - $enditem of $totalresults";
|
||||
|
||||
|
||||
// Modify List Form
|
||||
|
||||
echo"<DIV class=\"listform\">";
|
||||
echo"<FORM NAME=\"listviews\" METHOD=\"GET\" ACTION=\"showlist.php\">\n";
|
||||
echo"<INPUT NAME=\"application\" TYPE=\"hidden\" VALUE=\"$application\">\n";
|
||||
//Items-Per-Page
|
||||
echo"Show/Page: ";
|
||||
$perpage = array("5","10","20","50");
|
||||
echo"<SELECT name=\"numpg\">";
|
||||
foreach ($perpage as $value) {
|
||||
echo"<OPTION value=\"$value\"";
|
||||
if ($items_per_page==$value) {echo" SELECTED"; }
|
||||
echo">$value</OPTION>";
|
||||
}
|
||||
echo"</SELECT>\n";
|
||||
|
||||
|
||||
// Operating Systems
|
||||
echo" OS: ";
|
||||
echo"<SELECT name=\"os\">\n";
|
||||
$sql = "SELECT `OSName` FROM `t_os` ORDER BY `OSName`";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$osname = $row["OSName"];
|
||||
echo"<OPTION value=\"".strtolower($osname)."\"";
|
||||
if (strtolower($OS) == strtolower($osname)) {echo" SELECTED";}
|
||||
echo">$osname</OPTION>";
|
||||
}
|
||||
echo"</SELECT>\n";
|
||||
|
||||
|
||||
//Versions of Application
|
||||
echo"Versions: ";
|
||||
echo"<SELECT name=\"version\">";
|
||||
if ($application != "thunderbird") {echo"<OPTION value=\"auto-detect\">Auto-Detect</OPTION>";}
|
||||
$app_orig = $application; //Store original to protect against possible corruption
|
||||
$sql = "SELECT `Version`, `major`, `minor`, `release`, `SubVer` FROM `t_applications` WHERE `AppName` = '$application' ORDER BY `major` DESC, `minor` DESC, `release` DESC, `SubVer` DESC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$version = $row["Version"];
|
||||
$subver = $row["SubVer"];
|
||||
$release = "$row[major].$row[minor]";
|
||||
if ($row["release"]) {$release = ".$release$row[release]";}
|
||||
if ($app_version=="0.95") {$app_version="0.10"; }
|
||||
//Firesomething Support
|
||||
if ($application=="firefox") { if ($release == "0.7") {$application="firebird";} else {$application="firefox";} }
|
||||
|
||||
if ($subver !=="final") {$release="$release$subver";}
|
||||
echo"<OPTION value=\"$release\"";
|
||||
if ($app_version == $release) {echo" SELECTED"; }
|
||||
echo">".ucwords($application)." $version</OPTION>";
|
||||
|
||||
if ($app_version=="0.10") {$app_version="0.95"; }
|
||||
}
|
||||
$application = $app_orig; unset($app_orig);
|
||||
|
||||
|
||||
echo"</SELECT>\n";
|
||||
echo"<INPUT NAME=\"submit\" TYPE=\"SUBMIT\" VALUE=\"Update\">";
|
||||
echo"</FORM>";
|
||||
echo"</DIV>";
|
||||
|
||||
echo"</DIV>\n";
|
||||
|
||||
|
||||
//---------------------------------
|
||||
// Begin List
|
||||
//---------------------------------
|
||||
//Get Author Data and Create $authorarray and $authorids
|
||||
$sql = "SELECT TM.Name, TU.UserName, TU.UserID, TU.UserEmail FROM `t_main` TM
|
||||
LEFT JOIN t_authorxref TAX ON TM.ID = TAX.ID
|
||||
INNER JOIN t_userprofiles TU ON TAX.UserID = TU.UserID
|
||||
ORDER BY `Type` , `Name` ASC "; // TM.Type = 'E'
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$authorarray[$row[Name]][] = $row["UserName"];
|
||||
$authorids[$row[UserName]] = $row["UserID"];
|
||||
}
|
||||
|
||||
//Assemble a display application version array
|
||||
$sql = "SELECT `Version`, `major`, `minor`, `release`, `SubVer` FROM `t_applications` WHERE `AppName`='$application' ORDER BY `major`,`minor`";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$version = $row["Version"];
|
||||
$subver = $row["SubVer"];
|
||||
$release = "$row[major].$row[minor]";
|
||||
if ($row["release"]) {$release = ".$release$row[release]";}
|
||||
if ($subver !=="final") {$release="$release$subver";}
|
||||
|
||||
$appvernames[$release] = $version;
|
||||
}
|
||||
|
||||
//Query to Generate List..
|
||||
$sql = "$resultsquery";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
|
||||
$id = $row["ID"];
|
||||
$type = $row["Type"];
|
||||
$name = $row["Name"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$dateupdated = $row["DateUpdated"];
|
||||
$homepage = $row["Homepage"];
|
||||
$description = $row["Description"];
|
||||
$rating = $row["Rating"];
|
||||
$authors = $authorarray[$name];
|
||||
$osname = $row["OSName"];
|
||||
$appname = $row["AppName"];
|
||||
$downloadcount = $row["TotalDownloads"];
|
||||
|
||||
//Get Version Record for Referenced MAXvID from list query
|
||||
$sql2 = "SELECT TV.vID, TV.Version, TV.MinAppVer, TV.MaxAppVer, TV.Size, TV.DateAdded AS VerDateAdded, TV.DateUpdated AS VerDateUpdated, TV.URI, TV.Notes, TP.PreviewURI FROM `t_version` TV
|
||||
LEFT JOIN t_previews TP ON TV.vID = TP.vID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
INNER JOIN t_os TOS ON TV.OSID = TOS.OSID
|
||||
WHERE TV.ID = '$id' AND TV.Version = '$row[Version]' AND TA.AppName = '$appname' AND TOS.OSName = '$osname' LIMIT 1";
|
||||
$sql_result2 = mysql_query($sql2, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$vid = $row[MAXvID];
|
||||
$row = mysql_fetch_array($sql_result2);
|
||||
|
||||
$vid = $row["vID"];
|
||||
if ($appvernames[$row["MinAppVer"]]) {$minappver = $appvernames[$row["MinAppVer"]]; } else { $minappver = $row["MinAppVer"]; }
|
||||
if ($appvernames[$row["MaxAppVer"]]) {$maxappver = $appvernames[$row["MaxAppVer"]]; } else { $maxappver = $row["MaxAppVer"]; }
|
||||
$VerDateAdded = $row["VerDateAdded"];
|
||||
$VerDateUpdated = $row["VerDateUpdated"];
|
||||
$filesize = $row["Size"];
|
||||
$notes = $row["Notes"];
|
||||
$version = $row["Version"];
|
||||
$uri = $row["URI"];
|
||||
$previewuri = $row["PreviewURI"];
|
||||
|
||||
$filename = basename($uri);
|
||||
|
||||
if ($VerDateAdded > $dateadded) {$dateadded = $VerDateAdded; }
|
||||
if ($VerDateUpdated > $dateupdated) {$dateupdated = $VerDateUpdated; }
|
||||
|
||||
//Turn Authors Array into readable string...
|
||||
$authorcount = count($authors);
|
||||
foreach ($authors as $author) {
|
||||
$userid = $authorids[$author];
|
||||
$n++;
|
||||
$authorstring .= "<A HREF=\"authorprofiles.php?application=$application&id=$userid\">$author</A>";
|
||||
if ($authorcount != $n) {$authorstring .=", "; }
|
||||
|
||||
}
|
||||
$authors = $authorstring;
|
||||
unset($authorstring, $n); // Clear used Vars..
|
||||
|
||||
//Create Customizeable Timestamp
|
||||
$day=substr($dateupdated,8,2); //get the day
|
||||
$month=substr($dateupdated,5,2); //get the month
|
||||
$year=substr($dateupdated,0,4); //get the year
|
||||
$hour=substr($dateupdated,11,2); //get the hour
|
||||
$minute=substr($dateupdated,14,2); //get the minute
|
||||
$second=substr($dateupdated,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$dateupdated = gmdate("F d, Y g:i:sa", $timestamp); //gmdate("F d, Y g:i:sa T", $timestamp);
|
||||
|
||||
|
||||
echo"<DIV class=\"item\">\n";
|
||||
//echo"<DIV style=\"height: 100px\">"; //Not sure why this is here, it caused text to flood out of the box though.
|
||||
|
||||
if ($previewuri) {
|
||||
list($width, $height, $type, $attr) = getimagesize("$websitepath"."$previewuri");
|
||||
|
||||
echo"<IMG SRC=\"$previewuri\" BORDER=0 HEIGHT=$height WIDTH=$width STYLE=\"float: right; padding-right: 5px\" ALT=\"$name preview\">";
|
||||
}
|
||||
|
||||
|
||||
//Upper-Right Side Box
|
||||
echo"<DIV class=\"liststars\" title=\"$rating of 5 stars\" style=\"font-size: 8pt\"><A HREF=\"moreinfo.php?application=$application&id=$id&page=comments\">";
|
||||
for ($i = 1; $i <= floor($rating); $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/star_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
if ($rating>floor($rating)) {
|
||||
$val = ($rating-floor($rating))*10;
|
||||
echo"<IMG SRC=\"/images/stars/star_0$val.png\" BORDER=0 ALT=\"\">";
|
||||
$i++;
|
||||
}
|
||||
for ($i = $i; $i <= 5; $i++) {
|
||||
echo"<IMG SRC=\"/images/stars/graystar_icon.png\" BORDER=0 ALT=\""; if ($i==1) {echo"$rating of 5 stars";} echo"\">";
|
||||
}
|
||||
echo"</A></DIV>\n";
|
||||
|
||||
|
||||
echo"<DIV class=\"itemtitle\">";
|
||||
echo"<SPAN class=\"title\"><A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid\">$name $version</A></SPAN><BR>";
|
||||
echo"<SPAN class=\"authorline\">By $authors</SPAN><br>";
|
||||
echo"</DIV>";
|
||||
|
||||
//Description & Version Notes
|
||||
echo"<SPAN class=\"itemdescription\">";
|
||||
echo"$description<BR>";
|
||||
if ($notes) {echo"$notes"; }
|
||||
echo"</SPAN>\n";
|
||||
echo"<BR>";
|
||||
//echo"</DIV>";
|
||||
|
||||
//Icon Bar Modules
|
||||
echo"<DIV style=\"height: 34px\">";
|
||||
echo"<DIV class=\"iconbar\" style=\"width: 104px;\">";
|
||||
if ($appname=="Thunderbird") {
|
||||
echo"<A HREF=\"moreinfo.php?application=$application&id=$id&vid=$vid\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"More Info about $name\" ALT=\"\">More Info</A>";
|
||||
} else {
|
||||
//echo"<A HREF=\"install.php/$filename?id=$id&vid=$vid\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"Install $name\" ALT=\"\">Install</A>";
|
||||
echo"<A HREF=\"javascript:void(InstallTrigger.install({'$name $version':'$uri'}))\"><IMG SRC=\"/images/download.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"Install $name\" ALT=\"\">Install</A>";
|
||||
}
|
||||
echo"<BR><SPAN class=\"filesize\">Size: $filesize kb</SPAN></DIV>";
|
||||
if ($homepage) {echo"<DIV class=\"iconbar\" style=\"width: 98px;\"><A HREF=\"$homepage\"><IMG SRC=\"/images/home.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float:left;\" TITLE=\"$name Homepage\" ALT=\"\">Homepage</A></DIV>";}
|
||||
echo"<DIV class=\"iconbar\"><IMG SRC=\"/images/".strtolower($appname)."_icon.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float: left\" ALT=\"$appname\"> Works with:<BR> $minappver - $maxappver</DIV>";
|
||||
if($osname !=="ALL") { echo"<DIV class=\"iconbar\" style=\"width: 85px;\"><IMG SRC=\"/images/".strtolower($osname)."_icon.png\" BORDER=0 HEIGHT=34 WIDTH=34 STYLE=\"float: left\" ALT=\"\">OS:<BR>$osname</DIV>"; }
|
||||
echo"</DIV>";
|
||||
|
||||
echo"<DIV class=\"baseline\">Updated: $dateupdated | Total Downloads: $downloadcount<BR></DIV>\n";
|
||||
echo"</DIV>\n";
|
||||
|
||||
} //End While Loop
|
||||
if ($totalresults=="0") {
|
||||
echo"<DIV class=\"item noitems\">\n";
|
||||
echo"No extensions found in this category for ".ucwords($application).".\n";
|
||||
echo"</DIV>\n";
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
// Begin PHP Code for Dynamic Navbars
|
||||
if ($pageid <=$num_pages) {
|
||||
echo"<DIV id=\"listnav\">";
|
||||
|
||||
|
||||
echo"<DIV class=\"pagenum\">";
|
||||
$previd=$pageid-1;
|
||||
if ($previd >"0") {
|
||||
echo"<a href=\"?application=$application&version=$app_version&category=$category&numpg=$items_per_page&pageid=$previd\">« Previous</A> • ";
|
||||
}
|
||||
echo"Page $pageid of $num_pages";
|
||||
|
||||
|
||||
$nextid=$pageid+1;
|
||||
if ($pageid <$num_pages) {
|
||||
echo" • <a href=\"?application=$application&version=$app_version&category=$category&numpg=$items_per_page&pageid=$nextid\">Next »</a>";
|
||||
}
|
||||
echo"<BR>\n";
|
||||
|
||||
|
||||
//Skip to Page...
|
||||
if ($num_pages>1) {
|
||||
echo"Jump to: ";
|
||||
$pagesperpage=9; //Plus 1 by default..
|
||||
$i = 01;
|
||||
//Dynamic Starting Point
|
||||
if ($pageid>11) {
|
||||
$nextpage=$pageid-10;
|
||||
}
|
||||
$i=$nextpage;
|
||||
|
||||
//Dynamic Ending Point
|
||||
$maxpagesonpage=$pageid+$pagesperpage;
|
||||
//Page #s
|
||||
while ($i <= $maxpagesonpage && $i <= $num_pages) {
|
||||
|
||||
if ($i==$pageid) {
|
||||
echo"<SPAN style=\"color: #FF0000\">$i</SPAN> ";
|
||||
} else {
|
||||
echo"<A HREF=\"?application=$application&version=$app_version&category=$category&numpg=$items_per_page&pageid=$i\">$i</A> ";
|
||||
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
echo"</DIV>\n";
|
||||
|
||||
echo"<SPAN class=\"listtitle\">".ucwords("$application $typename » $categoryname ")."</SPAN><br>";
|
||||
echo"".ucwords("$typename")." $startitem - $enditem of $totalresults";
|
||||
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
|
||||
echo"</DIV>\n"; //End Content
|
||||
?>
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<TITLE>Mozilla Update :: Frequently Asked Questions</TITLE>
|
||||
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
include"$page_header";
|
||||
?>
|
||||
<DIV class="faqtitle">Frequently Asked Questions</DIV>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT `title`, `text` FROM `t_faq` WHERE `active` = 'YES' ORDER BY `index` ASC, `title` ASC";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$title = $row["title"];
|
||||
$text = nl2br($row["text"]);
|
||||
|
||||
echo"<DIV class=\"item\">\n";
|
||||
echo"<DIV class=\"boxheader faqitemtitle\">$title</DIV>\n";
|
||||
echo"<DIV class=\"faqitemtext\">$text</DIV>\n";
|
||||
echo"</DIV>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
Before Width: | Height: | Size: 181 B |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 2.6 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.7 KiB |
|
Before Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 913 B |
|
Before Width: | Height: | Size: 242 B |
|
Before Width: | Height: | Size: 19 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 484 B |
|
Before Width: | Height: | Size: 820 B |
|
Before Width: | Height: | Size: 616 B |
|
Before Width: | Height: | Size: 628 B |
|
Before Width: | Height: | Size: 654 B |
|
Before Width: | Height: | Size: 666 B |
|
Before Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 702 B |
|
Before Width: | Height: | Size: 706 B |
|
Before Width: | Height: | Size: 712 B |
|
Before Width: | Height: | Size: 726 B |
|
Before Width: | Height: | Size: 837 B |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1,76 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
|
||||
<DIV class="contentbox" style="margin-left: 2px; border-color: #00E;">
|
||||
<DIV class="boxheader">Thunderbird 1.0 Released!</DIV>
|
||||
<SPAN class="itemdescription">
|
||||
<P><IMG SRC="images/product-front-thunderbird.png" width="96" height="105" alt="" align=left border=0>Thunderbird 1.0 is now available for download! New features include Saved Search Folders (aka Virtual Folders)
|
||||
which allow you to display messages based on previously set search criteria across multiple folders. Message Grouping
|
||||
allows you to organize e-mail in a folder by grouping them based on various attributes like Date, Sender, Label, etc.
|
||||
Thunderbird 1.0 also includes numerous bug fixes and other improvements.</P>
|
||||
|
||||
<SPAN style="font-size: 16pt; text-align: center;">
|
||||
<a href="http://www.mozilla.org/products/thunderbird/">Get Thunderbird 1.0!</a></SPAN><BR>
|
||||
|
||||
<a href="http://www.mozilla.org/products/thunderbird/releases/">Thunderbird Release Notes</a> | <a href="http://www.mozilla.org/press/mozilla-2004-12-7.html">Press Release</a><BR>
|
||||
|
||||
|
||||
</SPAN>
|
||||
</DIV>
|
||||
|
||||
<DIV class="contentbox" style="margin-left: 2px; border-color: #E00;">
|
||||
<DIV class="boxheader">Firefox 1.0 Released!</DIV>
|
||||
<SPAN class="itemdescription">
|
||||
<P><IMG SRC="images/product-front-firefox.png" width="112" height="112" alt="" align=left border=0>
|
||||
The wait is over. Get Firefox 1.0, the most standards compliant, flexible, and user-centric web-browsing platform on Earth.
|
||||
Firefox 1.0 is the culmination of almost 7 years of work by thousands of independent hackers and companies through Mozilla.org,
|
||||
and over two years of intense focus on a streamlined browser made for the masses hungry for a better web experience.
|
||||
Firefox 1.0 Features include Tabbed Browsing, Smarter Search and FastFind, Hassle-Free Downloading, Live Bookmarks,
|
||||
Extension and Theme Support, and more.
|
||||
|
||||
</P>
|
||||
|
||||
<SPAN style="font-size: 16pt; text-align: center;">
|
||||
<a href="http://www.mozilla.org/products/firefox/">Get Firefox 1.0!</a></SPAN><BR>
|
||||
|
||||
<a href="http://www.mozilla.org/products/firefox/releases/1.0.html">Firefox Release Notes</a> | <a href="http://www.mozilla.org/press/mozilla-2004-11-09.html">Press Release</a><BR>
|
||||
|
||||
|
||||
</SPAN>
|
||||
</DIV>
|
||||
@@ -1,192 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"core/config.php";
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
|
||||
<html lang="EN" dir="ltr">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta http-equiv="Content-Language" content="en">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<TITLE>Mozilla Update</TITLE>
|
||||
<LINK REL="STYLESHEET" TYPE="text/css" HREF="/core/update.css">
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<?php
|
||||
include"$page_header";
|
||||
?>
|
||||
|
||||
<DIV class="contentbox" style="margin-left: 2px;">
|
||||
<DIV class="boxheader">Welcome to Mozilla Update</DIV>
|
||||
<SPAN class="itemdescription">
|
||||
Mozilla Update hosts Extensions and Themes for Mozilla software. On this site you can find Extensions and Themes for Mozilla Firefox,
|
||||
Mozilla Thunderbird and the Mozilla 1.x suite, with more to come. The site is broken up into sections for each product, with the
|
||||
extensions and themes categorized to be easy to find. They're also sorted by what version of the product you're using, so you can
|
||||
browse only for Firefox 0.9 compatible extensions, for example. For more information about Mozilla Update, please read our <A HREF="/faq/">Frequently Asked Questions...</A>
|
||||
|
||||
</SPAN>
|
||||
</DIV>
|
||||
<?php include"inc_featuredupdate.php"; ?>
|
||||
|
||||
<?php
|
||||
//include"inc_softwareupdate.php";
|
||||
if ($_GET["application"]) {$application=$_GET["application"]; }
|
||||
?>
|
||||
<?php
|
||||
//Temporary!! Current Version Array Code
|
||||
$currentver_array = array("firefox"=>"1.0", "thunderbird"=>"1.0", "mozilla"=>"1.7");
|
||||
$currentver_display_array = array("firefox"=>"1.0", "thunderbird"=>"1.0", "mozilla"=>"1.7.x");
|
||||
$currentver = $currentver_array[$application];
|
||||
$currentver_display = $currentver_display_array[$application];
|
||||
?>
|
||||
|
||||
|
||||
<DIV class="frontpagecontainer">
|
||||
<DIV class="contentbox contentcolumns">
|
||||
<DIV class="boxheader"><?php print(ucwords($application)); echo" $currentver_display"; ?> Extensions</DIV>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT TM.ID
|
||||
FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
WHERE `Type` = 'E' AND `AppName` = '$application' AND `minAppVer_int`<='$currentver' AND `maxAppVer_int` >='$currentver' AND `approved` = 'YES' GROUP BY TM.ID";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$numextensions = mysql_num_rows($sql_result);
|
||||
?>
|
||||
<a href="/extensions/?application=<?php echo"$application"; ?>">Browse extensions</a> (<?php echo"$numextensions"; ?> available)<BR>
|
||||
<BR>
|
||||
<?php
|
||||
$sql = "SELECT TR.ID, `Title`, TR.DateAdded, `Body`, `Type`, `pick` FROM `t_reviews` TR
|
||||
INNER JOIN t_main TM ON TR.ID = TM.ID
|
||||
INNER JOIN t_version TV ON TV.ID = TM.ID
|
||||
INNER JOIN t_applications TA ON TA.AppID = TV.AppID
|
||||
WHERE `Type` = 'E' AND `AppName` = '$application' AND `pick`='YES' ORDER BY `rID` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$id = $row["ID"];
|
||||
$title = $row["Title"];
|
||||
$pick = $row["pick"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$body = $row["Body"];
|
||||
$bodylength = strlen($body);
|
||||
if ($bodylength>"250") {
|
||||
$body = substr($body,0,250);
|
||||
$body .= " <a href=\"/extensions/moreinfo.php?id=$id&application=$application&page=staffreview\">[More...]</a>";
|
||||
|
||||
}
|
||||
|
||||
//Create Customizeable Timestamp
|
||||
$day=substr($dateadded,8,2); //get the day
|
||||
$month=substr($dateadded,5,2); //get the month
|
||||
$year=substr($dateadded,0,4); //get the year
|
||||
$hour=substr($dateadded,11,2); //get the hour
|
||||
$minute=substr($dateadded,14,2); //get the minute
|
||||
$second=substr($dateadded,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$date = gmdate("F, Y", $timestamp);
|
||||
|
||||
|
||||
echo"$title<br> $date";
|
||||
if ($pick=="YES") {echo" Editors Pick";}
|
||||
echo"<BR><BR>\n";
|
||||
echo"<SPAN class=\"itemdescription\">$body</SPAN><BR>\n";
|
||||
}
|
||||
?>
|
||||
<BR>
|
||||
</DIV>
|
||||
|
||||
<DIV class="contentbox contentcolumns">
|
||||
<DIV class="boxheader"><?php print(ucwords($application)); echo" $currentver_display"; ?> Themes</DIV>
|
||||
<?php
|
||||
$sql = "SELECT TM.ID FROM `t_main` TM
|
||||
INNER JOIN t_version TV ON TM.ID = TV.ID
|
||||
INNER JOIN t_applications TA ON TV.AppID = TA.AppID
|
||||
WHERE `Type` = 'T' AND `AppName` = '$application' AND `minAppVer_int` <='$currentver' AND `maxAppVer_int` >= '$currentver' AND `approved` = 'YES' GROUP BY TM.ID";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
$numthemes = mysql_num_rows($sql_result);
|
||||
?>
|
||||
<a href="/themes/?application=<?php echo"$application"; ?>">Browse themes</a> (<?php echo"$numthemes"; ?> available)<BR>
|
||||
<BR>
|
||||
<?php
|
||||
$sql = "SELECT TR.ID, `Title`, TR.DateAdded, `Body`, `Type`, `pick` FROM `t_reviews` TR
|
||||
INNER JOIN t_main TM ON TR.ID = TM.ID
|
||||
INNER JOIN t_version TV ON TV.ID = TM.ID
|
||||
INNER JOIN t_applications TA ON TA.AppID = TV.AppID
|
||||
WHERE `Type` = 'T' AND `AppName` = '$application' AND `pick`='YES' ORDER BY `rID` DESC LIMIT 1";
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$id = $row["ID"];
|
||||
$title = $row["Title"];
|
||||
$pick = $row["pick"];
|
||||
$dateadded = $row["DateAdded"];
|
||||
$body = $row["Body"];
|
||||
$bodylength = strlen($body);
|
||||
if ($bodylength>"250") {
|
||||
$body = substr($body,0,250);
|
||||
$body .= " <a href=\"/moreinfo.php?id=$id&application=$application&page=staffreview\">[More...]</a>";
|
||||
|
||||
}
|
||||
|
||||
//Create Customizeable Timestamp
|
||||
$day=substr($dateadded,8,2); //get the day
|
||||
$month=substr($dateadded,5,2); //get the month
|
||||
$year=substr($dateadded,0,4); //get the year
|
||||
$hour=substr($dateadded,11,2); //get the hour
|
||||
$minute=substr($dateadded,14,2); //get the minute
|
||||
$second=substr($dateadded,17,2); //get the sec
|
||||
$timestamp = strtotime("$year-$month-$day $hour:$minute:$second");
|
||||
$date = gmdate("F, Y", $timestamp);
|
||||
|
||||
echo"$title - $date";
|
||||
if ($pick=="YES") {echo" Editors Pick<BR><BR>\n";}
|
||||
echo"<BR><BR>\n";
|
||||
echo"$body<BR>\n";
|
||||
}
|
||||
?>
|
||||
<BR>
|
||||
</DIV>
|
||||
</DIV>
|
||||
<?php
|
||||
include"$page_footer";
|
||||
?>
|
||||
</BODY>
|
||||
</HTML>
|
||||
@@ -1,95 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
// Alan Starr <alanjstarr@yahoo.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
// http://blogs.law.harvard.edu/tech/rss
|
||||
|
||||
switch ($type) {
|
||||
case "E":
|
||||
$listType = "Extensions";
|
||||
break;
|
||||
case "P":
|
||||
$listType = "Plugins";
|
||||
break;
|
||||
case "T":
|
||||
$listType = "Themes";
|
||||
break;
|
||||
}
|
||||
|
||||
echo "<rss version=\"2.0\">\n";
|
||||
echo "<channel>\n";
|
||||
|
||||
echo " <title>" . htmlentities($sitetitle) . "::" . htmlentities($list) . " " . $listType . "</title>\n";
|
||||
echo " <link>" . htmlentities($siteurl) . "</link>\n";
|
||||
echo " <description>" . htmlentities($description) . "</description>\n";
|
||||
echo " <language>" . htmlentities($sitelanguage) . "</language>\n";
|
||||
echo " <copyright>" . htmlentities($sitecopyright) . "</copyright>\n";
|
||||
echo " <lastBuildDate>" . $currenttime . "</lastBuildDate>\n";
|
||||
echo " <ttl>" . $rssttl . "</ttl>\n";
|
||||
echo " <image>\n";
|
||||
echo " <title>" . htmlentities($sitetitle) . "</title>\n";
|
||||
echo " <link>" . htmlentities($siteurl) . "</link>\n";
|
||||
echo " <url>" . htmlentities($siteicon) . "</url>\n";
|
||||
echo " <width>16</width>\n";
|
||||
echo " <height>16</height>\n";
|
||||
echo " </image>\n";
|
||||
|
||||
$sql_result = mysql_query($sql, $connection) or trigger_error("MySQL Error ".mysql_errno().": ".mysql_error()."", E_USER_NOTICE);
|
||||
while ($row = mysql_fetch_array($sql_result)) {
|
||||
$id = $row["ID"];
|
||||
$title = htmlentities($row["Title"]);
|
||||
$description = htmlentities($row["Description"]);
|
||||
$dateupdated = gmdate("r", strtotime($row["DateStamp"]));
|
||||
$version = $row["Version"];
|
||||
$vid = $row["vID"];
|
||||
$appname = $row["AppName"];
|
||||
|
||||
echo " <item>\n";
|
||||
echo " <pubDate>" . $dateupdated . "</pubDate>\n";
|
||||
echo " <title>" . $title . " " . $version . " for " . $appname . "</title>\n";
|
||||
echo " <link>http://$sitehostname/" . strtolower($listType) . "/moreinfo.php?id=" . $id . "&vid=" . $vid . "</link>\n";
|
||||
echo " <description>" . $description . "</description>\n";
|
||||
echo " </item>\n";
|
||||
|
||||
}
|
||||
|
||||
echo "</channel>\n";
|
||||
echo "</rss>\n";
|
||||
|
||||
?>
|
||||
@@ -1,107 +0,0 @@
|
||||
<?php
|
||||
// ***** BEGIN LICENSE BLOCK *****
|
||||
// Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
//
|
||||
// The contents of this file are subject to the Mozilla Public License Version
|
||||
// 1.1 (the "License"); you may not use this file except in compliance with
|
||||
// the License. You may obtain a copy of the License at
|
||||
// http://www.mozilla.org/MPL/
|
||||
//
|
||||
// Software distributed under the License is distributed on an "AS IS" basis,
|
||||
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
// for the specific language governing rights and limitations under the
|
||||
// License.
|
||||
//
|
||||
// The Original Code is Mozilla Update.
|
||||
//
|
||||
// The Initial Developer of the Original Code is
|
||||
// Chris "Wolf" Crews.
|
||||
// Portions created by the Initial Developer are Copyright (C) 2004
|
||||
// the Initial Developer. All Rights Reserved.
|
||||
//
|
||||
// Contributor(s):
|
||||
// Chris "Wolf" Crews <psychoticwolf@carolina.rr.com>
|
||||
// Alan Starr <alanjstarr@yahoo.com>
|
||||
//
|
||||
// Alternatively, the contents of this file may be used under the terms of
|
||||
// either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
// in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
// of those above. If you wish to allow use of your version of this file only
|
||||
// under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
// use your version of this file under the terms of the MPL, indicate your
|
||||
// decision by deleting the provisions above and replace them with the notice
|
||||
// and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
// the provisions above, a recipient may use your version of this file under
|
||||
// the terms of any one of the MPL, the GPL or the LGPL.
|
||||
//
|
||||
// ***** END LICENSE BLOCK *****
|
||||
?>
|
||||
<?php
|
||||
require"../core/config.php";
|
||||
|
||||
$app = strtolower($_GET["application"]); // Firefox, Thunderbird, Mozilla
|
||||
$type = $_GET["type"]; //E, T, [P]
|
||||
$list = ucwords(strtolower($_GET["list"])); // Newest, Updated, [Editors], Popular
|
||||
|
||||
$sitetitle = "Mozilla Update";
|
||||
$siteicon = "http://www.mozilla.org/images/mozilla-16.png";
|
||||
$siteurl = "http://update.mozilla.org";
|
||||
$sitedescription = "the way to keep your mozilla software up-to-date";
|
||||
$sitelanguage = "en-us";
|
||||
$sitecopyright = "Creative Commons?";
|
||||
$currenttime = gmdate(r);// GMT
|
||||
$rssttl = "120"; //Life of feed in minutes
|
||||
|
||||
//header("Content-Type: application/octet-stream");
|
||||
header("Content-Type: text/xml");
|
||||
|
||||
// Firefox, extensions, by date added
|
||||
|
||||
$select = "SELECT DISTINCT
|
||||
t_main.ID,
|
||||
t_main.Name AS Title,
|
||||
t_main.Description,
|
||||
t_version.Version,
|
||||
t_version.vID,
|
||||
t_version.DateUpdated AS DateStamp,
|
||||
t_applications.AppName";
|
||||
|
||||
$from = "FROM t_main
|
||||
INNER JOIN t_version ON t_main.ID = t_version.ID
|
||||
INNER JOIN t_applications ON t_version.AppID = t_applications.AppID";
|
||||
|
||||
$where = "`approved` = 'YES'"; // Always have a WHERE
|
||||
|
||||
if ($app == 'firefox' || $app == 'thunderbird' || $app == 'mozilla') {
|
||||
$where .= " AND t_applications.AppName = '$app'";
|
||||
}
|
||||
|
||||
if ($type == 'E' || $type == 'T' || $type == 'P') {
|
||||
$where .= " AND t_main.Type = '$type'";
|
||||
}
|
||||
|
||||
switch ($list) {
|
||||
case "Popular":
|
||||
$orderby = "t_main.DownloadCount DESC";
|
||||
break;
|
||||
case "Updated":
|
||||
$orderby = "t_main.DateUpdated DESC";
|
||||
break;
|
||||
case "Rated":
|
||||
$orderby = "t_main.Rating DESC";
|
||||
break;
|
||||
case "Newest":
|
||||
default:
|
||||
$orderby = "t_main.DateAdded DESC";
|
||||
break;
|
||||
}
|
||||
|
||||
$sql = $select . " " . $from . " WHERE " . $where . " ORDER BY " . $orderby . " LIMIT 0, 10";
|
||||
|
||||
//echo $sql;
|
||||
|
||||
include"inc_rssfeed.php";
|
||||
|
||||
|
||||
?>
|
||||