Hash :
01971113
Author :
Date :
2015-07-10T14:54:00
Cache TTypes. *re-land with build fix for Win/Release* This change saves us ~70KiB per compiler with just ~3KiB of cache. BUG=492725 Change-Id: I4382c55b2480f70b00c5d117fcb7e0c51d0dfbb4 Reviewed-on: https://chromium-review.googlesource.com/284735 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Dmitry Skiba <dskiba@google.com> Reviewed-by: Alexis Hétu <sugoi@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Cache.h: Implements a cache for various commonly created objects.
#ifndef COMPILER_TRANSLATOR_CACHE_H_
#define COMPILER_TRANSLATOR_CACHE_H_
#include <stdint.h>
#include <string.h>
#include <map>
#include "compiler/translator/Types.h"
#include "compiler/translator/PoolAlloc.h"
class TCache
{
public:
static void initialize();
static void destroy();
static const TType *getType(TBasicType basicType,
TPrecision precision)
{
return getType(basicType, precision, EvqTemporary,
1, 1);
}
static const TType *getType(TBasicType basicType,
unsigned char primarySize = 1,
unsigned char secondarySize = 1)
{
return getType(basicType, EbpUndefined, EvqGlobal,
primarySize, secondarySize);
}
static const TType *getType(TBasicType basicType,
TQualifier qualifier,
unsigned char primarySize = 1,
unsigned char secondarySize = 1)
{
return getType(basicType, EbpUndefined, qualifier,
primarySize, secondarySize);
}
static const TType *getType(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize);
private:
TCache()
{
}
union TypeKey
{
TypeKey(TBasicType basicType,
TPrecision precision,
TQualifier qualifier,
unsigned char primarySize,
unsigned char secondarySize);
typedef uint8_t EnumComponentType;
struct
{
EnumComponentType basicType;
EnumComponentType precision;
EnumComponentType qualifier;
unsigned char primarySize;
unsigned char secondarySize;
} components;
uint64_t value;
bool operator < (const TypeKey &other) const
{
return value < other.value;
}
};
typedef std::map<TypeKey, const TType*> TypeMap;
TypeMap mTypes;
TPoolAllocator mAllocator;
static TCache *sCache;
};
#endif // COMPILER_TRANSLATOR_CACHE_H_