From 5556a39abedc53316798c0ef76ef3b9b5b0819eb Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 30 May 2016 17:29:02 -0700 Subject: [PATCH] deps: Expose `--harmony-simd` in node+chakracore Exposed `--harmony-simd` through `chakrashim` and pass it down to chakracore. This fix most of the basic scenario failures post merge. PR-URL: nodejs/node-chakracore#74 Reviewed-By: Jianchun Xu --- deps/chakrashim/src/jsrtisolateshim.cc | 8 +++++--- deps/chakrashim/src/jsrtisolateshim.h | 2 +- deps/chakrashim/src/v8isolate.cc | 3 ++- deps/chakrashim/src/v8v8.cc | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/deps/chakrashim/src/jsrtisolateshim.cc b/deps/chakrashim/src/jsrtisolateshim.cc index 2c4971774eb..764fddcaba1 100644 --- a/deps/chakrashim/src/jsrtisolateshim.cc +++ b/deps/chakrashim/src/jsrtisolateshim.cc @@ -50,7 +50,7 @@ IsolateShim::~IsolateShim() { assert(this->prevnext == nullptr); } -/* static */ v8::Isolate * IsolateShim::New() { +/* static */ v8::Isolate * IsolateShim::New(bool enableSimd) { // CHAKRA-TODO: Disable multiple isolate for now until it is fully implemented if (s_isolateList != nullptr) { CHAKRA_UNIMPLEMENTED_("multiple isolate"); @@ -60,8 +60,10 @@ IsolateShim::~IsolateShim() { JsRuntimeHandle runtime; JsErrorCode error = JsCreateRuntime(static_cast( - JsRuntimeAttributeAllowScriptInterrupt | - JsRuntimeAttributeEnableExperimentalFeatures), + JsRuntimeAttributeAllowScriptInterrupt | + JsRuntimeAttributeEnableExperimentalFeatures | + (enableSimd? JsRuntimeAttributeEnableSimdjsFeature : + JsRuntimeAttributeNone)), nullptr, &runtime); if (error != JsNoError) { return nullptr; diff --git a/deps/chakrashim/src/jsrtisolateshim.h b/deps/chakrashim/src/jsrtisolateshim.h index 8c9f9556b4a..2b0a7d6b330 100644 --- a/deps/chakrashim/src/jsrtisolateshim.h +++ b/deps/chakrashim/src/jsrtisolateshim.h @@ -51,7 +51,7 @@ class IsolateShim { bool Dispose(); bool IsDisposing(); - static v8::Isolate * New(); + static v8::Isolate * New(bool enableSimd = false); static v8::Isolate * GetCurrentAsIsolate(); static IsolateShim * GetCurrent(); static IsolateShim * FromIsolate(v8::Isolate * isolate); diff --git a/deps/chakrashim/src/v8isolate.cc b/deps/chakrashim/src/v8isolate.cc index c11ba578e01..7c1a7a4dc7b 100644 --- a/deps/chakrashim/src/v8isolate.cc +++ b/deps/chakrashim/src/v8isolate.cc @@ -26,9 +26,10 @@ namespace v8 { HeapProfiler dummyHeapProfiler; CpuProfiler dummyCpuProfiler; +extern bool g_enableSimdjs; Isolate* Isolate::New(const CreateParams& params) { - Isolate* iso = jsrt::IsolateShim::New(); + Isolate* iso = jsrt::IsolateShim::New(g_enableSimdjs); if (params.array_buffer_allocator) { V8::SetArrayBufferAllocator(params.array_buffer_allocator); } diff --git a/deps/chakrashim/src/v8v8.cc b/deps/chakrashim/src/v8v8.cc index dc59ea74429..bc2eab0f110 100644 --- a/deps/chakrashim/src/v8v8.cc +++ b/deps/chakrashim/src/v8v8.cc @@ -29,6 +29,7 @@ namespace v8 { bool g_disposed = false; bool g_exposeGC = false; bool g_useStrict = false; +bool g_enableSimdjs = false; ArrayBuffer::Allocator* g_arrayBufferAllocator = nullptr; const char *V8::GetVersion() { @@ -97,6 +98,11 @@ void V8::SetFlagsFromCommandLine(int *argc, char **argv, bool remove_flags) { if (remove_flags) { argv[i] = nullptr; } + } else if (equals("--harmony-simd", arg) || equals("--harmony_simd", arg)) { + g_enableSimdjs = true; + if (remove_flags) { + argv[i] = nullptr; + } } else if (remove_flags && (startsWith( arg, "--debug") // Ignore some flags to reduce unit test noise