Commit 97409c23 authored by jochen@chromium.org's avatar jochen@chromium.org

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
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/18860007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15618 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent b61dfd4a
...@@ -4699,6 +4699,12 @@ class V8EXPORT V8 { ...@@ -4699,6 +4699,12 @@ class V8EXPORT V8 {
*/ */
static int ContextDisposedNotification(); 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: private:
V8(); V8();
......
...@@ -137,8 +137,6 @@ void DispatchDebugMessages() { ...@@ -137,8 +137,6 @@ void DispatchDebugMessages() {
int RunMain(int argc, char* argv[]) { int RunMain(int argc, char* argv[]) {
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::SetFlagsFromString("--noenable_i18n",
static_cast<int>(strlen("--noenable_i18n")));
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handle_scope(isolate); v8::HandleScope handle_scope(isolate);
...@@ -326,6 +324,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script, ...@@ -326,6 +324,7 @@ bool RunCppCycle(v8::Handle<v8::Script> script,
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
int result = RunMain(argc, argv); int result = RunMain(argc, argv);
v8::V8::Dispose(); v8::V8::Dispose();
return result; return result;
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <v8.h> #include <v8.h>
#include <cstring>
#include <string> #include <string>
#include <map> #include <map>
...@@ -628,6 +627,7 @@ void PrintMap(map<string, string>* m) { ...@@ -628,6 +627,7 @@ void PrintMap(map<string, string>* m) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
map<string, string> options; map<string, string> options;
string file; string file;
ParseOptions(argc, argv, options, &file); ParseOptions(argc, argv, options, &file);
...@@ -635,8 +635,6 @@ int main(int argc, char* argv[]) { ...@@ -635,8 +635,6 @@ int main(int argc, char* argv[]) {
fprintf(stderr, "No script was specified.\n"); fprintf(stderr, "No script was specified.\n");
return 1; return 1;
} }
V8::SetFlagsFromString("--noenable_i18n",
static_cast<int>(strlen("--noenable_i18n")));
Isolate* isolate = Isolate::GetCurrent(); Isolate* isolate = Isolate::GetCurrent();
HandleScope scope(isolate); HandleScope scope(isolate);
Handle<String> source = ReadFile(file); Handle<String> source = ReadFile(file);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
{ {
'variables': { 'variables': {
'v8_code': 1, 'v8_code': 1,
'v8_enable_i18n_support%': 0,
}, },
'includes': ['../build/toolchain.gypi', '../build/features.gypi'], 'includes': ['../build/toolchain.gypi', '../build/features.gypi'],
'target_defaults': { 'target_defaults': {
...@@ -38,6 +39,13 @@ ...@@ -38,6 +39,13 @@
'include_dirs': [ 'include_dirs': [
'../include', '../include',
], ],
'conditions': [
['v8_enable_i18n_support==1', {
'dependencies': [
'<(DEPTH)/third_party/icu/icu.gyp:*',
],
}],
],
}, },
'targets': [ 'targets': [
{ {
......
...@@ -66,9 +66,8 @@ static bool run_shell; ...@@ -66,9 +66,8 @@ static bool run_shell;
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
v8::V8::InitializeICU();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true); v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
v8::V8::SetFlagsFromString("--noenable_i18n",
static_cast<int>(strlen("--noenable_i18n")));
v8::Isolate* isolate = v8::Isolate::GetCurrent(); v8::Isolate* isolate = v8::Isolate::GetCurrent();
run_shell = (argc == 1); run_shell = (argc == 1);
int result; int result;
......
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "global-handles.h" #include "global-handles.h"
#include "heap-profiler.h" #include "heap-profiler.h"
#include "heap-snapshot-generator-inl.h" #include "heap-snapshot-generator-inl.h"
#include "icu_util.h"
#include "messages.h" #include "messages.h"
#ifdef COMPRESS_STARTUP_DATA_BZ2 #ifdef COMPRESS_STARTUP_DATA_BZ2
#include "natives.h" #include "natives.h"
...@@ -5426,6 +5427,11 @@ int v8::V8::ContextDisposedNotification() { ...@@ -5426,6 +5427,11 @@ int v8::V8::ContextDisposedNotification() {
} }
bool v8::V8::InitializeICU() {
return i::InitializeICU();
}
const char* v8::V8::GetVersion() { const char* v8::V8::GetVersion() {
return i::Version::GetVersion(); return i::Version::GetVersion();
} }
......
...@@ -68,10 +68,6 @@ ...@@ -68,10 +68,6 @@
#include "v8.h" #include "v8.h"
#endif // V8_SHARED #endif // V8_SHARED
#if defined(V8_I18N_SUPPORT)
#include "icu_util.h"
#endif
#if !defined(_WIN32) && !defined(_WIN64) #if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h> // NOLINT #include <unistd.h> // NOLINT
#endif #endif
...@@ -1586,9 +1582,7 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { ...@@ -1586,9 +1582,7 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
int Shell::Main(int argc, char* argv[]) { int Shell::Main(int argc, char* argv[]) {
if (!SetOptions(argc, argv)) return 1; if (!SetOptions(argc, argv)) return 1;
#if defined(V8_I18N_SUPPORT) v8::V8::InitializeICU();
InitializeICU();
#endif
#ifndef V8_SHARED #ifndef V8_SHARED
i::FLAG_harmony_array_buffer = true; i::FLAG_harmony_array_buffer = true;
i::FLAG_harmony_typed_arrays = true; i::FLAG_harmony_typed_arrays = true;
......
...@@ -80,10 +80,6 @@ ...@@ -80,10 +80,6 @@
], ],
}], }],
['v8_enable_i18n_support==1', { ['v8_enable_i18n_support==1', {
'sources': [
'icu_util.cc',
'icu_util.h',
],
'dependencies': [ 'dependencies': [
'<(DEPTH)/third_party/icu/icu.gyp:*', '<(DEPTH)/third_party/icu/icu.gyp:*',
], ],
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "icu_util.h" #include "icu_util.h"
#if defined(_WIN32) #if defined(_WIN32) && defined(ENABLE_I18N_SUPPORT)
#include <windows.h> #include <windows.h>
#include "unicode/putil.h" #include "unicode/putil.h"
...@@ -39,8 +39,10 @@ ...@@ -39,8 +39,10 @@
namespace v8 { namespace v8 {
namespace internal {
bool InitializeICU() { bool InitializeICU() {
#if defined(_WIN32) #if defined(_WIN32) && defined(ENABLE_I18N_SUPPORT)
// We expect to find the ICU data module alongside the current module. // We expect to find the ICU data module alongside the current module.
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME); HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) return false; if (!module) return false;
...@@ -57,4 +59,4 @@ bool InitializeICU() { ...@@ -57,4 +59,4 @@ bool InitializeICU() {
#endif #endif
} }
} // namespace v8 } } // namespace v8::internal
...@@ -31,10 +31,12 @@ ...@@ -31,10 +31,12 @@
namespace v8 { namespace v8 {
namespace internal {
// Call this function to load ICU's data tables for the current process. This // Call this function to load ICU's data tables for the current process. This
// function should be called before ICU is used. // function should be called before ICU is used.
bool InitializeICU(); bool InitializeICU();
} // namespace v8 } } // namespace v8::internal
#endif // V8_ICU_UTIL_H_ #endif // V8_ICU_UTIL_H_
...@@ -309,6 +309,8 @@ void DumpException(Handle<Message> message) { ...@@ -309,6 +309,8 @@ void DumpException(Handle<Message> message) {
int main(int argc, char** argv) { int main(int argc, char** argv) {
V8::InitializeICU();
// By default, log code create information in the snapshot. // By default, log code create information in the snapshot.
i::FLAG_log_code = true; i::FLAG_log_code = true;
......
...@@ -371,6 +371,8 @@ ...@@ -371,6 +371,8 @@
'../../src/hydrogen-uint32-analysis.h', '../../src/hydrogen-uint32-analysis.h',
'../../src/hydrogen-osr.cc', '../../src/hydrogen-osr.cc',
'../../src/hydrogen-osr.h', '../../src/hydrogen-osr.h',
'../../src/icu_util.cc',
'../../src/icu_util.h',
'../../src/ic-inl.h', '../../src/ic-inl.h',
'../../src/ic.cc', '../../src/ic.cc',
'../../src/ic.h', '../../src/ic.h',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment