Reviewers: Jakob,
Description:
Move InitializeICU() to the V8 API and use it.
I can't get rid of the enable_i18n flag yet, as we need to be able to
turn off all extensions for creating the snapshot.
BUG=v8:2745
[email protected]
Please review this at https://codereview.chromium.org/18860007/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M include/v8.h
M samples/lineprocessor.cc
M samples/process.cc
M samples/samples.gyp
M samples/shell.cc
M src/api.cc
M src/d8.cc
M src/d8.gyp
M src/icu_util.h
M src/icu_util.cc
M src/mksnapshot.cc
M tools/gyp/v8.gyp
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index
55059015b19113e71a1859902c28c5f88e3780f7..d4d333e43998bd1932188577b562fbfbda28613b
100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -4699,6 +4699,12 @@ class V8EXPORT V8 {
*/
static int ContextDisposedNotification();
+ /**
+ * Initialize the ICU library bundled with V8. The embedder should only
+ * invoke this method when using the bundled ICU. Returns true on
success.
+ */
+ static bool InitializeICU();
+
private:
V8();
Index: samples/lineprocessor.cc
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index
0c84419d3a8abe8533fb43ef48d35d752de1b011..42048202fdd6e75a186312df8ac447d25cf29aae
100644
--- a/samples/lineprocessor.cc
+++ b/samples/lineprocessor.cc
@@ -137,8 +137,6 @@ void DispatchDebugMessages() {
int RunMain(int argc, char* argv[]) {
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
- v8::V8::SetFlagsFromString("--noenable_i18n",
- static_cast<int>(strlen("--noenable_i18n")));
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate);
@@ -326,6 +324,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script,
int main(int argc, char* argv[]) {
+ v8::V8::InitializeICU();
int result = RunMain(argc, argv);
v8::V8::Dispose();
return result;
Index: samples/process.cc
diff --git a/samples/process.cc b/samples/process.cc
index
80805d2c294935ca05890c4d2e1784dd14126417..844aee3d45fde306914dff0d4e8bf9173f4c3e52
100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -27,7 +27,6 @@
#include <v8.h>
-#include <cstring>
#include <string>
#include <map>
@@ -628,6 +627,7 @@ void PrintMap(map<string, string>* m) {
int main(int argc, char* argv[]) {
+ v8::V8::InitializeICU();
map<string, string> options;
string file;
ParseOptions(argc, argv, options, &file);
@@ -635,8 +635,6 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "No script was specified.\n");
return 1;
}
- V8::SetFlagsFromString("--noenable_i18n",
- static_cast<int>(strlen("--noenable_i18n")));
Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate);
Handle<String> source = ReadFile(file);
Index: samples/samples.gyp
diff --git a/samples/samples.gyp b/samples/samples.gyp
index
cd2d15b4026463b35a36e392eacdc0fb6d3df966..6af37fcc284be18658dcfaccf1ae94c528087dcd
100644
--- a/samples/samples.gyp
+++ b/samples/samples.gyp
@@ -28,6 +28,7 @@
{
'variables': {
'v8_code': 1,
+ 'v8_enable_i18n_support%': 0,
},
'includes': ['../build/toolchain.gypi', '../build/features.gypi'],
'target_defaults': {
@@ -38,6 +39,13 @@
'include_dirs': [
'../include',
],
+ 'conditions': [
+ ['v8_enable_i18n_support==1', {
+ 'dependencies': [
+ '<(DEPTH)/third_party/icu/icu.gyp:*',
+ ],
+ }],
+ ],
},
'targets': [
{
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index
5c5f056ed1c8b1593efd31a6a5f2ad8deedaaee0..710547c341979eaa6f42194a1b10d2ee183a561f
100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -66,9 +66,8 @@ static bool run_shell;
int main(int argc, char* argv[]) {
+ v8::V8::InitializeICU();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
- v8::V8::SetFlagsFromString("--noenable_i18n",
- static_cast<int>(strlen("--noenable_i18n")));
v8::Isolate* isolate = v8::Isolate::GetCurrent();
run_shell = (argc == 1);
int result;
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index
c56bc05601e06f20607e0147b0eed429e5e28816..10e69fc2641e30d41580876e4872a996ef720d95
100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -45,6 +45,7 @@
#include "global-handles.h"
#include "heap-profiler.h"
#include "heap-snapshot-generator-inl.h"
+#include "icu_util.h"
#include "messages.h"
#ifdef COMPRESS_STARTUP_DATA_BZ2
#include "natives.h"
@@ -5426,6 +5427,11 @@ int v8::V8::ContextDisposedNotification() {
}
+bool v8::V8::InitializeICU() {
+ return i::InitializeICU();
+}
+
+
const char* v8::V8::GetVersion() {
return i::Version::GetVersion();
}
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
21daa0bf5c81dfcd5257d6050f35c336cc0a591f..3ac8db09625b76b67dcaefc59b0901c91c815911
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -68,10 +68,6 @@
#include "v8.h"
#endif // V8_SHARED
-#if defined(V8_I18N_SUPPORT)
-#include "icu_util.h"
-#endif
-
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT
#endif
@@ -1586,9 +1582,7 @@ class ShellArrayBufferAllocator : public
v8::ArrayBuffer::Allocator {
int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1;
-#if defined(V8_I18N_SUPPORT)
- InitializeICU();
-#endif
+ v8::V8::InitializeICU();
#ifndef V8_SHARED
i::FLAG_harmony_array_buffer = true;
i::FLAG_harmony_typed_arrays = true;
Index: src/d8.gyp
diff --git a/src/d8.gyp b/src/d8.gyp
index
6a57e122fe7d0a98e60c439fd1ce418437b13d43..85c9d53e69901d2483ac06b644ed6c462d83b2e1
100644
--- a/src/d8.gyp
+++ b/src/d8.gyp
@@ -80,10 +80,6 @@
],
}],
['v8_enable_i18n_support==1', {
- 'sources': [
- 'icu_util.cc',
- 'icu_util.h',
- ],
'dependencies': [
'<(DEPTH)/third_party/icu/icu.gyp:*',
],
Index: src/icu_util.cc
diff --git a/src/icu_util.cc b/src/icu_util.cc
index
aaafadc3eea2af9a598da66e5f358541934b0379..91f45278ee546d3b10db7321cbfdb3b1dcd3f4f4
100644
--- a/src/icu_util.cc
+++ b/src/icu_util.cc
@@ -27,7 +27,7 @@
#include "icu_util.h"
-#if defined(_WIN32)
+#if defined(_WIN32) && defined(ENABLE_I18N_SUPPORT)
#include <windows.h>
#include "unicode/putil.h"
@@ -39,8 +39,10 @@
namespace v8 {
+namespace internal {
+
bool InitializeICU() {
-#if defined(_WIN32)
+#if defined(_WIN32) && defined(ENABLE_I18N_SUPPORT)
// 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;
@@ -57,4 +59,4 @@ bool InitializeICU() {
#endif
}
-} // namespace v8
+} } // namespace v8::internal
Index: src/icu_util.h
diff --git a/src/icu_util.h b/src/icu_util.h
index
d7961b9d3650a3fdfc47334555a63850fb3aae46..478abce508cc69a74b83028e19ddc66f9ea1d641
100644
--- a/src/icu_util.h
+++ b/src/icu_util.h
@@ -31,10 +31,12 @@
namespace v8 {
+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();
-} // namespace v8
+} } // namespace v8::internal
#endif // V8_ICU_UTIL_H_
Index: src/mksnapshot.cc
diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc
index
a8d9b35f3be4a81f4bd6bccc7a520100511cc725..c1edcb1b3a149d462dd9e071e0f9fad043c913bd
100644
--- a/src/mksnapshot.cc
+++ b/src/mksnapshot.cc
@@ -309,6 +309,8 @@ void DumpException(Handle<Message> message) {
int main(int argc, char** argv) {
+ V8::InitializeICU();
+
// By default, log code create information in the snapshot.
i::FLAG_log_code = true;
Index: tools/gyp/v8.gyp
diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp
index
7a75be8e2363f62cf4481356e8b6acf05697b197..f0c09778821002eafc183e84e1d2644cd3e32a6c
100644
--- a/tools/gyp/v8.gyp
+++ b/tools/gyp/v8.gyp
@@ -369,6 +369,8 @@
'../../src/hydrogen-uint32-analysis.h',
'../../src/hydrogen-osr.cc',
'../../src/hydrogen-osr.h',
+ '../../src/icu_util.cc',
+ '../../src/icu_util.h',
'../../src/ic-inl.h',
'../../src/ic.cc',
'../../src/ic.h',
--
--
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/groups/opt_out.