Reviewers: Jakob,
Message:
plz review
Description:
Initialize ICU data files in d8 and disable i18n for other code samples
BUG=v8:2745
[email protected]
Please review this at https://codereview.chromium.org/18899002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M samples/lineprocessor.cc
M samples/process.cc
M samples/shell.cc
M src/d8.cc
M src/d8.gyp
A + src/icu_util.h
A + src/icu_util.cc
Index: samples/lineprocessor.cc
diff --git a/samples/lineprocessor.cc b/samples/lineprocessor.cc
index
adc5b13e4d25be8841638fa30c8adcfe0b3613c5..0c84419d3a8abe8533fb43ef48d35d752de1b011
100644
--- a/samples/lineprocessor.cc
+++ b/samples/lineprocessor.cc
@@ -137,6 +137,8 @@ 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);
Index: samples/process.cc
diff --git a/samples/process.cc b/samples/process.cc
index
1f1f92b5f5e0fe1928a8ad926b689d1bd9caf7c1..80805d2c294935ca05890c4d2e1784dd14126417
100644
--- a/samples/process.cc
+++ b/samples/process.cc
@@ -27,6 +27,7 @@
#include <v8.h>
+#include <cstring>
#include <string>
#include <map>
@@ -634,6 +635,8 @@ 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/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index
a0af931b2314ba41abcf64ba3ae6560313c1e9fd..5c5f056ed1c8b1593efd31a6a5f2ad8deedaaee0
100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -67,6 +67,8 @@ static bool run_shell;
int main(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();
run_shell = (argc == 1);
int result;
Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index
cb43d2f9c2ca0ce72310ea4938871667abd398b5..21daa0bf5c81dfcd5257d6050f35c336cc0a591f
100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -68,6 +68,10 @@
#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
@@ -1582,6 +1586,9 @@ 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
#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
47a7cc01187b00203b4881c826e7a3a1a85aa042..40d2f14daba21c9d80416bd4c843a57386fa126f
100644
--- a/src/d8.gyp
+++ b/src/d8.gyp
@@ -31,6 +31,7 @@
'console%': '',
# Enable support for Intel VTune. Supported on ia32/x64 only
'v8_enable_vtunejit%': 0,
+ 'v8_enable_i18n_support%': 0,
},
'includes': ['../build/common.gypi'],
'targets': [
@@ -78,6 +79,15 @@
'../src/third_party/vtune/v8vtune.gyp:v8_vtune',
],
}],
+ ['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/hydrogen-dce.h b/src/icu_util.cc
similarity index 68%
copy from src/hydrogen-dce.h
copy to src/icu_util.cc
index
19749f279a2e1cb632ba5a300033e5a9f038638f..1505d3014afeecb59b2cb279fbfbe9b393dac131
100644
--- a/src/hydrogen-dce.h
+++ b/src/icu_util.cc
@@ -25,32 +25,38 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#ifndef V8_HYDROGEN_DCE_H_
-#define V8_HYDROGEN_DCE_H_
+#include "icu_util.h"
-#include "hydrogen.h"
+#if defined(_WIN32)
+#include <windows.h>
-namespace v8 {
-namespace internal {
-
-
-class HDeadCodeEliminationPhase : public HPhase {
- public:
- explicit HDeadCodeEliminationPhase(HGraph* graph)
- : HPhase("H_Dead code elimination", graph) { }
+#include "unicode/putil.h"
+#include "unicode/udata.h"
- void Run() {
- MarkLiveInstructions();
- RemoveDeadInstructions();
- }
+#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
+#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
+#endif
- private:
- bool MarkLive(HValue* ref, HValue* instr);
- void MarkLiveInstructions();
- void RemoveDeadInstructions();
-};
-
-
-} } // namespace v8::internal
+namespace v8 {
-#endif // V8_HYDROGEN_DCE_H_
+bool InitializeICU() {
+#if defined(_WIN32)
+ // 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;
+
+ FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
+ if (!addr)
+ return false;
+
+ UErrorCode err = U_ZERO_ERROR;
+ udata_setCommonData(reinterpret_cast<void*>(addr), &err);
+ return err == U_ZERO_ERROR;
+#else
+ // Mac/Linux bundle the ICU data in.
+ return true;
+#endif
+}
+
+} // namespace v8
Index: src/icu_util.h
diff --git a/test/mjsunit/regress/regress-237617.js b/src/icu_util.h
similarity index 86%
copy from test/mjsunit/regress/regress-237617.js
copy to src/icu_util.h
index
dabf828ae8bbfa3223e56664a97780098e6c5e3e..d7961b9d3650a3fdfc47334555a63850fb3aae46
100644
--- a/test/mjsunit/regress/regress-237617.js
+++ b/src/icu_util.h
@@ -25,19 +25,16 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"use strict"
-function f() {
- throw new Error("test stack");
-}
+#ifndef V8_ICU_UTIL_H_
+#define V8_ICU_UTIL_H_
-var error_stack = "";
-try {
- f.call(null);
-} catch (e) {
- error_stack = e.stack;
-}
+namespace v8 {
-assertTrue(error_stack.indexOf("test stack") > 0);
-assertTrue(error_stack.indexOf("illegal") < 0);
+// 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
+
+#endif // V8_ICU_UTIL_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.