summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Dawson <brucedawson@google.com>2014-12-12 21:30:37 -0800
committerBruce Dawson <brucedawson@google.com>2014-12-12 21:30:37 -0800
commit7be67b2e4f496cb638b365264ce835e3b23a555e (patch)
tree57df1cf6bab44afd4cf0d84542cf3435e8f264bf
parentf6505100fc132ef866adaf3ff1fb7f06d0ca7a9b (diff)
downloadpdfium-7be67b2e4f496cb638b365264ce835e3b23a555e.tar.xz
Avoid duplicate definitions of JSCONST_n*Hash and QeTable variables.
QeTable is a 752 byte array that was defined in a header file. This caused it to be instantiated by the VC++ compiler 12 times, wasting 8,272 bytes of space in the data segment. Because 'const' implies 'static' this did not cause any duplicate symbol errors. JSCONST_n*HASH are a set of eight variables that are defined in a header file. This causes them to be replicated 15 times. The variables themselves are tiny but they are dynamically initialized and this dynamic initialization code is replicated 15 times. When tested on pdfium_test.exe the effect of this change is to: Reduce the .text (code) segment by 3,616 bytes. Reduce the .rdata section by 8,656 bytes. Reduce the total binary file size by 13312 bytes. These are the worst offenders for pdf.dll as shown in: https://drive.google.com/open?id=1BvubxoA2SU_2e4T5cq7jHTjc1TlT0qOndpIfX3DMeA8&authuser=0 This will also drastically simplify the list of work to be done for bug 441899 (getting rid of initializers). BUG=441988 R=bo_xu@foxitsoftware.com Review URL: https://codereview.chromium.org/802013002
-rw-r--r--core/src/fxcodec/jbig2/JBig2_ArithQe.h50
-rw-r--r--core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp51
-rw-r--r--fpdfsdk/include/javascript/JS_Define.h16
-rw-r--r--fpdfsdk/src/javascript/global.cpp9
4 files changed, 69 insertions, 57 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_ArithQe.h b/core/src/fxcodec/jbig2/JBig2_ArithQe.h
index 60fbbc9ac3..5405e425b0 100644
--- a/core/src/fxcodec/jbig2/JBig2_ArithQe.h
+++ b/core/src/fxcodec/jbig2/JBig2_ArithQe.h
@@ -12,53 +12,5 @@ typedef struct {
unsigned int NLPS;
unsigned int nSwitch;
} JBig2ArithQe;
-const JBig2ArithQe QeTable[] = {
- { 0x5601, 1, 1, 1 },
- { 0x3401, 2, 6, 0 },
- { 0x1801, 3, 9, 0 },
- { 0x0AC1, 4, 12, 0 },
- { 0x0521, 5, 29, 0 },
- { 0x0221, 38, 33, 0 },
- { 0x5601, 7, 6, 1 },
- { 0x5401, 8, 14, 0 },
- { 0x4801, 9, 14, 0 },
- { 0x3801, 10, 14, 0 },
- { 0x3001, 11, 17, 0 },
- { 0x2401, 12, 18, 0 },
- { 0x1C01, 13, 20, 0 },
- { 0x1601, 29, 21, 0 },
- { 0x5601, 15, 14, 1 },
- { 0x5401, 16, 14, 0 },
- { 0x5101, 17, 15, 0 },
- { 0x4801, 18, 16, 0 },
- { 0x3801, 19, 17, 0 },
- { 0x3401, 20, 18, 0 },
- { 0x3001, 21, 19, 0 },
- { 0x2801, 22, 19, 0 },
- { 0x2401, 23, 20, 0 },
- { 0x2201, 24, 21, 0 },
- { 0x1C01, 25, 22, 0 },
- { 0x1801, 26, 23, 0 },
- { 0x1601, 27, 24, 0 },
- { 0x1401, 28, 25, 0 },
- { 0x1201, 29, 26, 0 },
- { 0x1101, 30, 27, 0 },
- { 0x0AC1, 31, 28, 0 },
- { 0x09C1, 32, 29, 0 },
- { 0x08A1, 33, 30, 0 },
- { 0x0521, 34, 31, 0 },
- { 0x0441, 35, 32, 0 },
- { 0x02A1, 36, 33, 0 },
- { 0x0221, 37, 34, 0 },
- { 0x0141, 38, 35, 0 },
- { 0x0111, 39, 36, 0 },
- { 0x0085, 40, 37, 0 },
- { 0x0049, 41, 38, 0 },
- { 0x0025, 42, 39, 0 },
- { 0x0015, 43, 40, 0 },
- { 0x0009, 44, 41, 0 },
- { 0x0005, 45, 42, 0 },
- { 0x0001, 45, 43, 0 },
- { 0x5601, 46, 46, 0 }
-};
+extern const JBig2ArithQe QeTable[];
#endif
diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
index 5847b20a93..6179317890 100644
--- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
@@ -10,6 +10,57 @@
#include "JBig2_HuffmanDecoder.h"
#include "JBig2_HuffmanTable.h"
#include "JBig2_PatternDict.h"
+
+extern const JBig2ArithQe QeTable[] = {
+ { 0x5601, 1, 1, 1 },
+ { 0x3401, 2, 6, 0 },
+ { 0x1801, 3, 9, 0 },
+ { 0x0AC1, 4, 12, 0 },
+ { 0x0521, 5, 29, 0 },
+ { 0x0221, 38, 33, 0 },
+ { 0x5601, 7, 6, 1 },
+ { 0x5401, 8, 14, 0 },
+ { 0x4801, 9, 14, 0 },
+ { 0x3801, 10, 14, 0 },
+ { 0x3001, 11, 17, 0 },
+ { 0x2401, 12, 18, 0 },
+ { 0x1C01, 13, 20, 0 },
+ { 0x1601, 29, 21, 0 },
+ { 0x5601, 15, 14, 1 },
+ { 0x5401, 16, 14, 0 },
+ { 0x5101, 17, 15, 0 },
+ { 0x4801, 18, 16, 0 },
+ { 0x3801, 19, 17, 0 },
+ { 0x3401, 20, 18, 0 },
+ { 0x3001, 21, 19, 0 },
+ { 0x2801, 22, 19, 0 },
+ { 0x2401, 23, 20, 0 },
+ { 0x2201, 24, 21, 0 },
+ { 0x1C01, 25, 22, 0 },
+ { 0x1801, 26, 23, 0 },
+ { 0x1601, 27, 24, 0 },
+ { 0x1401, 28, 25, 0 },
+ { 0x1201, 29, 26, 0 },
+ { 0x1101, 30, 27, 0 },
+ { 0x0AC1, 31, 28, 0 },
+ { 0x09C1, 32, 29, 0 },
+ { 0x08A1, 33, 30, 0 },
+ { 0x0521, 34, 31, 0 },
+ { 0x0441, 35, 32, 0 },
+ { 0x02A1, 36, 33, 0 },
+ { 0x0221, 37, 34, 0 },
+ { 0x0141, 38, 35, 0 },
+ { 0x0111, 39, 36, 0 },
+ { 0x0085, 40, 37, 0 },
+ { 0x0049, 41, 38, 0 },
+ { 0x0025, 42, 39, 0 },
+ { 0x0015, 43, 40, 0 },
+ { 0x0009, 44, 41, 0 },
+ { 0x0005, 45, 42, 0 },
+ { 0x0001, 45, 43, 0 },
+ { 0x5601, 46, 46, 0 }
+};
+
CJBig2_Image *CJBig2_GRDProc::decode_Arith(CJBig2_ArithDecoder *pArithDecoder, JBig2ArithCtx *gbContext)
{
if (GBW == 0 || GBH == 0) {
diff --git a/fpdfsdk/include/javascript/JS_Define.h b/fpdfsdk/include/javascript/JS_Define.h
index 0821b6238b..9a51f69c81 100644
--- a/fpdfsdk/include/javascript/JS_Define.h
+++ b/fpdfsdk/include/javascript/JS_Define.h
@@ -648,14 +648,14 @@ if (JS_DefineGlobalConst(pRuntime, (const wchar_t*)ArrayName, prop.ToJSValue())
#define CLASSNAME_DATE L"Date"
#define CLASSNAME_STRING L"v8::String"
-const unsigned int JSCONST_nStringHash = JS_CalcHash(VALUE_NAME_STRING,wcslen(VALUE_NAME_STRING));
-const unsigned int JSCONST_nNumberHash = JS_CalcHash(VALUE_NAME_NUMBER,wcslen(VALUE_NAME_NUMBER));
-const unsigned int JSCONST_nBoolHash = JS_CalcHash(VALUE_NAME_BOOLEAN,wcslen(VALUE_NAME_BOOLEAN));
-const unsigned int JSCONST_nDateHash = JS_CalcHash(VALUE_NAME_DATE,wcslen(VALUE_NAME_DATE));
-const unsigned int JSCONST_nObjectHash = JS_CalcHash(VALUE_NAME_OBJECT,wcslen(VALUE_NAME_OBJECT));
-const unsigned int JSCONST_nFXobjHash = JS_CalcHash(VALUE_NAME_FXOBJ,wcslen(VALUE_NAME_FXOBJ));
-const unsigned int JSCONST_nNullHash = JS_CalcHash(VALUE_NAME_NULL,wcslen(VALUE_NAME_NULL));
-const unsigned int JSCONST_nUndefHash = JS_CalcHash(VALUE_NAME_UNDEFINED,wcslen(VALUE_NAME_UNDEFINED));
+extern const unsigned int JSCONST_nStringHash;
+extern const unsigned int JSCONST_nNumberHash;
+extern const unsigned int JSCONST_nBoolHash;
+extern const unsigned int JSCONST_nDateHash;
+extern const unsigned int JSCONST_nObjectHash;
+extern const unsigned int JSCONST_nFXobjHash;
+extern const unsigned int JSCONST_nNullHash;
+extern const unsigned int JSCONST_nUndefHash;
static FXJSVALUETYPE GET_VALUE_TYPE(v8::Handle<v8::Value> p)
{
diff --git a/fpdfsdk/src/javascript/global.cpp b/fpdfsdk/src/javascript/global.cpp
index 1d61571c8b..04f9ef9da3 100644
--- a/fpdfsdk/src/javascript/global.cpp
+++ b/fpdfsdk/src/javascript/global.cpp
@@ -16,6 +16,15 @@
/* ---------------------------- global ---------------------------- */
+extern const unsigned int JSCONST_nStringHash = JS_CalcHash(VALUE_NAME_STRING,wcslen(VALUE_NAME_STRING));
+extern const unsigned int JSCONST_nNumberHash = JS_CalcHash(VALUE_NAME_NUMBER,wcslen(VALUE_NAME_NUMBER));
+extern const unsigned int JSCONST_nBoolHash = JS_CalcHash(VALUE_NAME_BOOLEAN,wcslen(VALUE_NAME_BOOLEAN));
+extern const unsigned int JSCONST_nDateHash = JS_CalcHash(VALUE_NAME_DATE,wcslen(VALUE_NAME_DATE));
+extern const unsigned int JSCONST_nObjectHash = JS_CalcHash(VALUE_NAME_OBJECT,wcslen(VALUE_NAME_OBJECT));
+extern const unsigned int JSCONST_nFXobjHash = JS_CalcHash(VALUE_NAME_FXOBJ,wcslen(VALUE_NAME_FXOBJ));
+extern const unsigned int JSCONST_nNullHash = JS_CalcHash(VALUE_NAME_NULL,wcslen(VALUE_NAME_NULL));
+extern const unsigned int JSCONST_nUndefHash = JS_CalcHash(VALUE_NAME_UNDEFINED,wcslen(VALUE_NAME_UNDEFINED));
+
BEGIN_JS_STATIC_CONST(CJS_Global)
END_JS_STATIC_CONST()