Remove SH_MAP_LONG_VARIABLE_NAMES
We use hashing to map all variables/strcuture field names, etc,
so we no longer need this option.
Checked with Firefox and WebKit, they no longer use this option
either. Time to remove it.
Change-Id: Ie3e79b91a05258b04af419a9c42b2fd1b00e67c4
Reviewed-on: https://chromium-review.googlesource.com/189236
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Zhenyao Mo <zmo@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/189568
diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp
index 9b920a2..a42ef62 100644
--- a/src/compiler/translator/Compiler.cpp
+++ b/src/compiler/translator/Compiler.cpp
@@ -10,7 +10,6 @@
#include "compiler/translator/Initialize.h"
#include "compiler/translator/InitializeParseContext.h"
#include "compiler/translator/InitializeVariables.h"
-#include "compiler/translator/MapLongVariableNames.h"
#include "compiler/translator/ParseContext.h"
#include "compiler/translator/RenameFunction.h"
#include "compiler/translator/ShHandle.h"
@@ -104,13 +103,10 @@
clampingStrategy(SH_CLAMP_WITH_CLAMP_INTRINSIC),
builtInFunctionEmulator(type)
{
- longNameMap = LongNameMap::GetInstance();
}
TCompiler::~TCompiler()
{
- ASSERT(longNameMap);
- longNameMap->Release();
}
bool TCompiler::Init(const ShBuiltInResources& resources)
@@ -201,13 +197,13 @@
// Unroll for-loop markup needs to happen after validateLimitations pass.
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
- {
- ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex);
+ {
+ ForLoopUnrollMarker marker(ForLoopUnrollMarker::kIntegerIndex);
root->traverse(&marker);
}
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_SAMPLER_ARRAY_INDEX))
- {
- ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex);
+ {
+ ForLoopUnrollMarker marker(ForLoopUnrollMarker::kSamplerArrayIndex);
root->traverse(&marker);
if (marker.samplerArrayIndexIsFloatLoopIndex())
{
@@ -229,13 +225,6 @@
if (success && (compileOptions & SH_LIMIT_EXPRESSION_COMPLEXITY))
success = limitExpressionComplexity(root);
- // Call mapLongVariableNames() before collectAttribsUniforms() so in
- // collectAttribsUniforms() we already have the mapped symbol names and
- // we could composite mapped and original variable names.
- // Also, if we hash all the names, then no need to do this for long names.
- if (success && (compileOptions & SH_MAP_LONG_VARIABLE_NAMES) && hashFunction == NULL)
- mapLongVariableNames(root);
-
if (success && shaderType == SH_VERTEX_SHADER && (compileOptions & SH_INIT_GL_POSITION))
initializeGLPosition(root);
@@ -535,18 +524,6 @@
root->traverse(&initializer);
}
-void TCompiler::mapLongVariableNames(TIntermNode* root)
-{
- ASSERT(longNameMap);
- MapLongVariableNames map(longNameMap);
- root->traverse(&map);
-}
-
-int TCompiler::getMappedNameMaxLength() const
-{
- return MAX_SHORTENED_IDENTIFIER_SIZE + 1;
-}
-
const TExtensionBehavior& TCompiler::getExtensionBehavior() const
{
return extensionBehavior;
diff --git a/src/compiler/translator/MapLongVariableNames.cpp b/src/compiler/translator/MapLongVariableNames.cpp
deleted file mode 100644
index ef629c2..0000000
--- a/src/compiler/translator/MapLongVariableNames.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-//
-// Copyright (c) 2002-2012 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.
-//
-
-#include "compiler/translator/MapLongVariableNames.h"
-
-namespace {
-
-TString mapLongName(size_t id, const TString& name, bool isGlobal)
-{
- ASSERT(name.size() > MAX_SHORTENED_IDENTIFIER_SIZE);
- TStringStream stream;
- stream << "webgl_";
- if (isGlobal)
- stream << "g";
- stream << id;
- if (name[0] != '_')
- stream << "_";
- stream << name.substr(0, MAX_SHORTENED_IDENTIFIER_SIZE - stream.str().size());
- return stream.str();
-}
-
-LongNameMap* gLongNameMapInstance = NULL;
-
-} // anonymous namespace
-
-LongNameMap::LongNameMap()
- : refCount(0)
-{
-}
-
-LongNameMap::~LongNameMap()
-{
-}
-
-// static
-LongNameMap* LongNameMap::GetInstance()
-{
- if (gLongNameMapInstance == NULL)
- gLongNameMapInstance = new LongNameMap;
- gLongNameMapInstance->refCount++;
- return gLongNameMapInstance;
-}
-
-void LongNameMap::Release()
-{
- ASSERT(gLongNameMapInstance == this);
- ASSERT(refCount > 0);
- refCount--;
- if (refCount == 0) {
- delete gLongNameMapInstance;
- gLongNameMapInstance = NULL;
- }
-}
-
-const char* LongNameMap::Find(const char* originalName) const
-{
- std::map<std::string, std::string>::const_iterator it = mLongNameMap.find(
- originalName);
- if (it != mLongNameMap.end())
- return (*it).second.c_str();
- return NULL;
-}
-
-void LongNameMap::Insert(const char* originalName, const char* mappedName)
-{
- mLongNameMap.insert(std::map<std::string, std::string>::value_type(
- originalName, mappedName));
-}
-
-size_t LongNameMap::Size() const
-{
- return mLongNameMap.size();
-}
-
-MapLongVariableNames::MapLongVariableNames(LongNameMap* globalMap)
-{
- ASSERT(globalMap);
- mGlobalMap = globalMap;
-}
-
-void MapLongVariableNames::visitSymbol(TIntermSymbol* symbol)
-{
- ASSERT(symbol != NULL);
- if (symbol->getSymbol().size() > MAX_SHORTENED_IDENTIFIER_SIZE) {
- switch (symbol->getQualifier()) {
- case EvqVaryingIn:
- case EvqVaryingOut:
- case EvqInvariantVaryingIn:
- case EvqInvariantVaryingOut:
- case EvqUniform:
- symbol->setSymbol(
- mapGlobalLongName(symbol->getSymbol()));
- break;
- default:
- symbol->setSymbol(
- mapLongName(symbol->getId(), symbol->getSymbol(), false));
- break;
- };
- }
-}
-
-TString MapLongVariableNames::mapGlobalLongName(const TString& name)
-{
- ASSERT(mGlobalMap);
- const char* mappedName = mGlobalMap->Find(name.c_str());
- if (mappedName != NULL)
- return mappedName;
- size_t id = mGlobalMap->Size();
- TString rt = mapLongName(id, name, true);
- mGlobalMap->Insert(name.c_str(), rt.c_str());
- return rt;
-}
diff --git a/src/compiler/translator/MapLongVariableNames.h b/src/compiler/translator/MapLongVariableNames.h
deleted file mode 100644
index 3b085a3..0000000
--- a/src/compiler/translator/MapLongVariableNames.h
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-// Copyright (c) 2002-2012 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.
-//
-
-#ifndef COMPILER_MAP_LONG_VARIABLE_NAMES_H_
-#define COMPILER_MAP_LONG_VARIABLE_NAMES_H_
-
-#include "GLSLANG/ShaderLang.h"
-
-#include "compiler/translator/intermediate.h"
-#include "compiler/translator/VariableInfo.h"
-
-// This size does not include '\0' in the end.
-#define MAX_SHORTENED_IDENTIFIER_SIZE 32
-
-// This is a ref-counted singleton. GetInstance() returns a pointer to the
-// singleton, and after use, call Release(). GetInstance() and Release() should
-// be paired.
-class LongNameMap {
-public:
- static LongNameMap* GetInstance();
- void Release();
-
- // Return the mapped name if <originalName, mappedName> is in the map;
- // otherwise, return NULL.
- const char* Find(const char* originalName) const;
-
- // Insert a pair into the map.
- void Insert(const char* originalName, const char* mappedName);
-
- // Return the number of entries in the map.
- size_t Size() const;
-
-private:
- LongNameMap();
- ~LongNameMap();
-
- size_t refCount;
- std::map<std::string, std::string> mLongNameMap;
-};
-
-// Traverses intermediate tree to map attributes and uniforms names that are
-// longer than MAX_SHORTENED_IDENTIFIER_SIZE to MAX_SHORTENED_IDENTIFIER_SIZE.
-class MapLongVariableNames : public TIntermTraverser {
-public:
- MapLongVariableNames(LongNameMap* globalMap);
-
- virtual void visitSymbol(TIntermSymbol*);
-
-private:
- TString mapGlobalLongName(const TString& name);
-
- LongNameMap* mGlobalMap;
-};
-
-#endif // COMPILER_MAP_LONG_VARIABLE_NAMES_H_
diff --git a/src/compiler/translator/ShHandle.h b/src/compiler/translator/ShHandle.h
index e34971d..5991c5e 100644
--- a/src/compiler/translator/ShHandle.h
+++ b/src/compiler/translator/ShHandle.h
@@ -24,7 +24,6 @@
#include "compiler/translator/VariableInfo.h"
#include "third_party/compiler/ArrayBoundsClamper.h"
-class LongNameMap;
class TCompiler;
class TDependencyGraph;
class TranslatorHLSL;
@@ -72,7 +71,6 @@
const TVariableInfoList& getAttribs() const { return attribs; }
const TVariableInfoList& getUniforms() const { return uniforms; }
const TVariableInfoList& getVaryings() const { return varyings; }
- int getMappedNameMaxLength() const;
ShHashFunction64 getHashFunction() const { return hashFunction; }
NameMap& getNameMap() { return nameMap; }
@@ -96,8 +94,6 @@
bool validateLimitations(TIntermNode* root);
// Collect info for all attribs, uniforms, varyings.
void collectVariables(TIntermNode* root);
- // Map long variable names into shorter ones.
- void mapLongVariableNames(TIntermNode* root);
// Translate to object code.
virtual void translate(TIntermNode* root) = 0;
// Returns true if, after applying the packing rules in the GLSL 1.017 spec
@@ -159,9 +155,6 @@
TVariableInfoList uniforms; // Active uniforms in the compiled shader.
TVariableInfoList varyings; // Varyings in the compiled shader.
- // Cached copy of the ref-counted singleton.
- LongNameMap* longNameMap;
-
// name hashing.
ShHashFunction64 hashFunction;
NameMap nameMap;
diff --git a/src/compiler/translator/VariableInfo.cpp b/src/compiler/translator/VariableInfo.cpp
index fdaef29..2d21134 100644
--- a/src/compiler/translator/VariableInfo.cpp
+++ b/src/compiler/translator/VariableInfo.cpp
@@ -354,9 +354,9 @@
if (mHashFunction == NULL)
processedSymbol = variable->getSymbol();
else
- processedSymbol = TIntermTraverser::hash(variable->getOriginalSymbol(), mHashFunction);
+ processedSymbol = TIntermTraverser::hash(variable->getSymbol(), mHashFunction);
getVariableInfo(variable->getType(),
- variable->getOriginalSymbol(),
+ variable->getSymbol(),
processedSymbol,
*infoList,
mHashFunction);
diff --git a/src/compiler/translator/intermediate.h b/src/compiler/translator/intermediate.h
index 041eb86..db3481c 100644
--- a/src/compiler/translator/intermediate.h
+++ b/src/compiler/translator/intermediate.h
@@ -368,7 +368,7 @@
// per process globalpoolallocator, then it causes increased memory usage per compile
// it is essential to use "symbol = sym" to assign to symbol
TIntermSymbol(int i, const TString& sym, const TType& t) :
- TIntermTyped(t), id(i) { symbol = sym; originalSymbol = sym; }
+ TIntermTyped(t), id(i) { symbol = sym; }
virtual bool hasSideEffects() const { return false; }
@@ -376,9 +376,6 @@
const TString& getSymbol() const { return symbol; }
void setId(int newId) { id = newId; }
- void setSymbol(const TString& sym) { symbol = sym; }
-
- const TString& getOriginalSymbol() const { return originalSymbol; }
virtual void traverse(TIntermTraverser*);
virtual TIntermSymbol* getAsSymbolNode() { return this; }
@@ -387,7 +384,6 @@
protected:
int id;
TString symbol;
- TString originalSymbol;
};
class TIntermConstantUnion : public TIntermTyped {