Reviewers: danno,
Description:
Roll ICU 239289:258359 and add support for external ICU data tables
The only binary that supports ICU data tables is d8. The location of the
data table file has to be passed via a command line switch:
$ out/x64.optdebug/d8 --icu-data-file=out/x64.optdebug/icudtl.dat
BUG=72633,v8:3142
[email protected]
LOG=y
Please review this at https://codereview.chromium.org/209323014/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+64, -12 lines):
M DEPS
M Makefile
M include/v8.h
M src/api.cc
M src/d8.h
M src/d8.cc
M src/icu_util.h
M src/icu_util.cc
M tools/gyp/v8.gyp
Index: DEPS
diff --git a/DEPS b/DEPS
index
66d21eb3649ba4d0652fc8a640fcdb80fb6303bf..353c5c8b346f1939376629cf7a460364d199f610
100644
--- a/DEPS
+++ b/DEPS
@@ -8,7 +8,7 @@ deps = {
"http://gyp.googlecode.com/svn/trunk@1831",
"v8/third_party/icu":
- "https://src.chromium.org/chrome/trunk/deps/third_party/icu46@239289",
+ "https://src.chromium.org/chrome/trunk/deps/third_party/icu46@258359",
}
deps_os = {
Index: Makefile
diff --git a/Makefile b/Makefile
index
6bd9bac8a8541027560b279fad56875e49501135..f3900286cbd33b5534e0b7d96a483a08a9a1dc74
100644
--- a/Makefile
+++ b/Makefile
@@ -465,4 +465,4 @@ dependencies:
--revision 1831
svn checkout --force \
https://src.chromium.org/chrome/trunk/deps/third_party/icu46 \
- third_party/icu --revision 239289
+ third_party/icu --revision 258359
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
3bcea9aec112691593cd36c4dea1cb31479f1a5b..f467ed4d887a593f9708993d36a514ec20bcaf75
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4954,8 +4954,11 @@ class V8_EXPORT V8 {
/**
* Initialize the ICU library bundled with V8. The embedder should only
* invoke this method when using the bundled ICU. Returns true on
success.
+ *
+ * If V8 was compiled with the ICU data in an external file, the location
+ * of the data file as to be passed.
*/
- static bool InitializeICU();
+ static bool InitializeICU(const char* icu_data_file = NULL);
/**
* Sets the v8::Platform to use. This should be invoked before V8 is
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
c89b61937923f99f49bf44da5de976038c850901..6003b6629595f9a645441054ee1649ed47d1e877
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5112,8 +5112,8 @@ int v8::V8::ContextDisposedNotification() {
}
-bool v8::V8::InitializeICU() {
- return i::InitializeICU();
+bool v8::V8::InitializeICU(const char* icu_data_file) {
+ return i::InitializeICU(icu_data_file);
}
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
d0711056e1bf80066908697aaff1a9729d4c3cb3..7ac0c6546aae188ed931306095f824568a7049b1
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -1440,6 +1440,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strcmp(argv[i], "--throws") == 0) {
options.expected_to_throw = true;
argv[i] = NULL;
+ } else if (strncmp(argv[i], "--icu-data-file=", 16) == 0) {
+ options.icu_data_file = argv[i] + 16;
+ argv[i] = NULL;
}
#ifdef V8_SHARED
else if (strcmp(argv[i], "--dump-counters") == 0) {
@@ -1674,7 +1677,7 @@ class MockArrayBufferAllocator : public
v8::ArrayBuffer::Allocator {
int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1;
- v8::V8::InitializeICU();
+ v8::V8::InitializeICU(options.icu_data_file);
#ifndef V8_SHARED
i::FLAG_trace_hydrogen_file = "hydrogen.cfg";
i::FLAG_redirect_code_traces_to = "code.asm";
Index: src/d8.h
diff --git a/src/d8.h b/src/d8.h
index
db2edb93c98e5be4650447487c4e9130fd5776c2..3edd8a730722813ea9888fe1373f4e647705834b
100644
--- a/src/d8.h
+++ b/src/d8.h
@@ -233,7 +233,8 @@ class ShellOptions {
expected_to_throw(false),
mock_arraybuffer_allocator(false),
num_isolates(1),
- isolate_sources(NULL) { }
+ isolate_sources(NULL),
+ icu_data_file(NULL) { }
~ShellOptions() {
#ifndef V8_SHARED
@@ -258,6 +259,7 @@ class ShellOptions {
bool mock_arraybuffer_allocator;
int num_isolates;
SourceGroup* isolate_sources;
+ const char* icu_data_file;
};
#ifdef V8_SHARED
Index: src/icu_util.cc
diff --git a/src/icu_util.cc b/src/icu_util.cc
index
b9bd65edc69ecb680a9cae4efc96ed3158543285..6441dbdd9f5fd98392a720d174fb7b4cebed7510
100644
--- a/src/icu_util.cc
+++ b/src/icu_util.cc
@@ -27,12 +27,20 @@
#include "icu_util.h"
-#if defined(_WIN32) && defined(V8_I18N_SUPPORT)
+#if defined(_WIN32)
#include <windows.h>
+#endif
+
+#if defined(V8_I18N_SUPPORT)
+#include <stdio.h>
#include "unicode/putil.h"
#include "unicode/udata.h"
+#define ICU_UTIL_DATA_FILE 0
+#define ICU_UTIL_DATA_SHARED 1
+#define ICU_UTIL_DATA_STATIC 2
+
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
#endif
@@ -41,8 +49,11 @@ namespace v8 {
namespace internal {
-bool InitializeICU() {
-#if defined(_WIN32) && defined(V8_I18N_SUPPORT)
+bool InitializeICU(const char* icu_data_file) {
+#if !defined(V8_I18N_SUPPORT)
+ return true;
+#else
+#if ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_SHARED
// We expect to find the ICU data module alongside the current module.
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) return false;
@@ -53,9 +64,30 @@ bool InitializeICU() {
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
return err == U_ZERO_ERROR;
-#else
+#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_STATIC
// Mac/Linux bundle the ICU data in.
return true;
+#elif ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE
+ if (!icu_data_file) return false;
+
+ FILE* inf = fopen(icu_data_file, "rb");
+ if (!inf) return false;
+
+ fseek(inf, 0, SEEK_END);
+ size_t size = ftell(inf);
+ rewind(inf);
+
+ char* addr = new char[size];
+ if (fread(addr, 1, size, inf) != size) {
+ delete[] addr;
+ fclose(inf);
+ return false;
+ }
+ fclose(inf);
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setCommonData(reinterpret_cast<void*>(addr), &err);
+ return err == U_ZERO_ERROR;
+#endif
#endif
}
Index: src/icu_util.h
diff --git a/src/icu_util.h b/src/icu_util.h
index
478abce508cc69a74b83028e19ddc66f9ea1d641..6b50c185c513297c149d0eff2a78b831dd561bbb
100644
--- a/src/icu_util.h
+++ b/src/icu_util.h
@@ -35,7 +35,7 @@ namespace internal {
// Call this function to load ICU's data tables for the current process.
This
// function should be called before ICU is used.
-bool InitializeICU();
+bool InitializeICU(const char* icu_data_file);
} } // namespace v8::internal
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index
6f97defe04f5e2525846c7275ca952be90c1b3a4..be6faf4fb4c0ac3655e0760365a3ab2f64aa90b8
100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -27,6 +27,7 @@
{
'variables': {
+ 'icu_use_data_file_flag%': 0,
'v8_code': 1,
'v8_random_seed%': 314159265,
},
@@ -1018,6 +1019,17 @@
'../../src/default-platform.h',
],
}],
+ ['icu_use_data_file_flag==1', {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE'],
+ }, { # else icu_use_data_file_flag !=1
+ 'conditions': [
+ ['OS=="win"', {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_SHARED'],
+ }, {
+ 'defines': ['ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_STATIC'],
+ }],
+ ],
+ }],
],
},
{
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.