From 2a2c881df3bbcede5abb49704157703c8f862d46 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 29 Jan 2018 16:00:52 +0100 Subject: [PATCH] v8: make building addons with VS2013 work again Work around some C++11 shortcomings in Visual Studio 2013: 1. Replace `constexpr` with `const`, and 2. Remove default move constructors and assignment operators. PR-URL: https://github.com/nodejs/node/pull/16413 --- deps/v8/include/v8-version.h | 2 +- deps/v8/include/v8.h | 21 ++++++++----------- deps/v8/src/api.cc | 39 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 14 deletions(-) diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 953b2d19ac43a8..25ce5d071e71c3 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 6 #define V8_MINOR_VERSION 2 #define V8_BUILD_NUMBER 414 -#define V8_PATCH_LEVEL 49 +#define V8_PATCH_LEVEL 50 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index a4134ad54229c7..c70154fd710e0c 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -2452,7 +2452,7 @@ enum class NewStringType { */ class V8_EXPORT String : public Name { public: - static constexpr int kMaxLength = + static const int kMaxLength = sizeof(void*) == 4 ? (1 << 28) - 16 : (1 << 30) - 1 - 24; enum Encoding { @@ -4122,10 +4122,10 @@ class V8_EXPORT WasmCompiledModule : public Object { // supports move semantics, and does not support copy semantics. class TransferrableModule final { public: - TransferrableModule(TransferrableModule&& src) = default; + TransferrableModule(TransferrableModule&& src); TransferrableModule(const TransferrableModule& src) = delete; - TransferrableModule& operator=(TransferrableModule&& src) = default; + TransferrableModule& operator=(TransferrableModule&& src); TransferrableModule& operator=(const TransferrableModule& src) = delete; private: @@ -4200,24 +4200,19 @@ class V8_EXPORT WasmModuleObjectBuilderStreaming final { WasmModuleObjectBuilderStreaming(const WasmModuleObjectBuilderStreaming&) = delete; - WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&) = - default; + WasmModuleObjectBuilderStreaming(WasmModuleObjectBuilderStreaming&&); WasmModuleObjectBuilderStreaming& operator=( const WasmModuleObjectBuilderStreaming&) = delete; WasmModuleObjectBuilderStreaming& operator=( - WasmModuleObjectBuilderStreaming&&) = default; + WasmModuleObjectBuilderStreaming&&); Isolate* isolate_ = nullptr; -#if V8_CC_MSVC // We don't need the static Copy API, so the default // NonCopyablePersistentTraits would be sufficient, however, // MSVC eagerly instantiates the Copy. // We ensure we don't use Copy, however, by compiling with the // defaults everywhere else. Persistent> promise_; -#else - Persistent promise_; -#endif std::vector received_buffers_; size_t total_size_ = 0; }; @@ -4238,9 +4233,9 @@ class V8_EXPORT WasmModuleObjectBuilder final { // Disable copy semantics *in this implementation*. We can choose to // relax this, albeit it's not clear why. WasmModuleObjectBuilder(const WasmModuleObjectBuilder&) = delete; - WasmModuleObjectBuilder(WasmModuleObjectBuilder&&) = default; + WasmModuleObjectBuilder(WasmModuleObjectBuilder&&); WasmModuleObjectBuilder& operator=(const WasmModuleObjectBuilder&) = delete; - WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&) = default; + WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&); std::vector received_buffers_; size_t total_size_ = 0; @@ -4502,7 +4497,7 @@ class V8_EXPORT TypedArray : public ArrayBufferView { /* * The largest typed array size that can be constructed using New. */ - static constexpr size_t kMaxLength = + static const size_t kMaxLength = sizeof(void*) == 4 ? (1u << 30) - 1 : (1u << 31) - 1; /** diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 561a571516a22f..078796f5dbb4f2 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -7714,6 +7714,18 @@ MaybeLocal Proxy::New(Local context, Local local_target, RETURN_ESCAPED(result); } +WasmCompiledModule::TransferrableModule::TransferrableModule( + TransferrableModule&& src) + : compiled_code(std::move(src.compiled_code)) + , wire_bytes(std::move(src.wire_bytes)) {} + +WasmCompiledModule::TransferrableModule& +WasmCompiledModule::TransferrableModule::operator=(TransferrableModule&& src) { + compiled_code = std::move(src.compiled_code); + wire_bytes = std::move(src.wire_bytes); + return *this; +} + Local WasmCompiledModule::GetWasmWireBytes() { i::Handle obj = i::Handle::cast(Utils::OpenHandle(this)); @@ -7826,6 +7838,22 @@ WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming( } } +WasmModuleObjectBuilderStreaming::WasmModuleObjectBuilderStreaming( + WasmModuleObjectBuilderStreaming&& src) + : isolate_(std::move(src.isolate_)) + , promise_(std::move(src.promise_)) + , received_buffers_(std::move(src.received_buffers_)) + , total_size_(std::move(src.total_size_)) {} + +WasmModuleObjectBuilderStreaming& WasmModuleObjectBuilderStreaming::operator=( + WasmModuleObjectBuilderStreaming&& src) { + isolate_ = std::move(src.isolate_); + promise_ = std::move(src.promise_); + received_buffers_ = std::move(src.received_buffers_); + total_size_ = std::move(src.total_size_); + return *this; +} + Local WasmModuleObjectBuilderStreaming::GetPromise() { return promise_.Get(isolate_); } @@ -7871,6 +7899,17 @@ WasmModuleObjectBuilderStreaming::~WasmModuleObjectBuilderStreaming() { promise_.Reset(); } +WasmModuleObjectBuilder::WasmModuleObjectBuilder(WasmModuleObjectBuilder&& src) + : received_buffers_(std::move(src.received_buffers_)) + , total_size_(std::move(src.total_size_)) {} + +WasmModuleObjectBuilder& +WasmModuleObjectBuilder::operator=(WasmModuleObjectBuilder&& src) { + received_buffers_ = std::move(src.received_buffers_); + total_size_ = std::move(src.total_size_); + return *this; +} + void WasmModuleObjectBuilder::OnBytesReceived(const uint8_t* bytes, size_t size) { std::unique_ptr cloned_bytes(new uint8_t[size]);