From 7b48713334469818661fe276cf571de9c7899f2d Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Tue, 12 Mar 2019 09:01:49 +0100 Subject: deps: update V8 to 7.3.492.25 PR-URL: https://github.com/nodejs/node/pull/25852 Reviewed-By: Ujjwal Sharma Reviewed-By: Matteo Collina Reviewed-By: Ali Ijaz Sheikh --- deps/v8/test/common/assembler-tester.h | 95 +++++++++++++++++--------- deps/v8/test/common/wasm/test-signatures.h | 3 +- deps/v8/test/common/wasm/wasm-macro-gen.h | 32 +++++++-- deps/v8/test/common/wasm/wasm-module-runner.cc | 43 ++++++------ deps/v8/test/common/wasm/wasm-module-runner.h | 43 ++++++++++-- 5 files changed, 154 insertions(+), 62 deletions(-) (limited to 'deps/v8/test/common') diff --git a/deps/v8/test/common/assembler-tester.h b/deps/v8/test/common/assembler-tester.h index eca34c5521..5861acd71e 100644 --- a/deps/v8/test/common/assembler-tester.h +++ b/deps/v8/test/common/assembler-tester.h @@ -10,41 +10,70 @@ namespace v8 { namespace internal { -static inline uint8_t* AllocateAssemblerBuffer( - size_t* allocated, - size_t requested = v8::internal::AssemblerBase::kMinimalBufferSize, - void* address = nullptr) { - size_t page_size = v8::internal::AllocatePageSize(); - size_t alloc_size = RoundUp(requested, page_size); - void* result = v8::internal::AllocatePages( - GetPlatformPageAllocator(), address, alloc_size, page_size, - v8::PageAllocator::kReadWriteExecute); - CHECK(result); - *allocated = alloc_size; - return static_cast(result); -} +class TestingAssemblerBuffer : public AssemblerBuffer { + public: + TestingAssemblerBuffer(size_t requested, void* address) { + size_t page_size = v8::internal::AllocatePageSize(); + size_t alloc_size = RoundUp(requested, page_size); + CHECK_GE(kMaxInt, alloc_size); + size_ = static_cast(alloc_size); + buffer_ = static_cast(AllocatePages(GetPlatformPageAllocator(), + address, alloc_size, page_size, + v8::PageAllocator::kReadWrite)); + CHECK_NOT_NULL(buffer_); + } -static inline void MakeAssemblerBufferExecutable(uint8_t* buffer, - size_t allocated) { - // Flush the instruction cache as part of making the buffer executable. - // Note: we do this before setting permissions to ReadExecute because on - // some older Arm64 kernels there is a bug which causes an access error on - // cache flush instructions to trigger access error on non-writable memory. - // See https://bugs.chromium.org/p/v8/issues/detail?id=8157 - Assembler::FlushICache(buffer, allocated); - - bool result = - v8::internal::SetPermissions(GetPlatformPageAllocator(), buffer, - allocated, v8::PageAllocator::kReadExecute); - CHECK(result); -} + ~TestingAssemblerBuffer() { + CHECK(FreePages(GetPlatformPageAllocator(), buffer_, size_)); + } + + byte* start() const override { return buffer_; } + + int size() const override { return size_; } + + std::unique_ptr Grow(int new_size) override { + FATAL("Cannot grow TestingAssemblerBuffer"); + } + + std::unique_ptr CreateView() const { + return ExternalAssemblerBuffer(buffer_, size_); + } -static inline void MakeAssemblerBufferWritable(uint8_t* buffer, - size_t allocated) { - bool result = - v8::internal::SetPermissions(GetPlatformPageAllocator(), buffer, - allocated, v8::PageAllocator::kReadWrite); - CHECK(result); + void MakeExecutable() { + // Flush the instruction cache as part of making the buffer executable. + // Note: we do this before setting permissions to ReadExecute because on + // some older ARM kernels there is a bug which causes an access error on + // cache flush instructions to trigger access error on non-writable memory. + // See https://bugs.chromium.org/p/v8/issues/detail?id=8157 + Assembler::FlushICache(buffer_, size_); + + bool result = SetPermissions(GetPlatformPageAllocator(), buffer_, size_, + v8::PageAllocator::kReadExecute); + CHECK(result); + } + + void MakeWritable() { + bool result = SetPermissions(GetPlatformPageAllocator(), buffer_, size_, + v8::PageAllocator::kReadWrite); + CHECK(result); + } + + // TODO(wasm): Only needed for the "test-jump-table-assembler.cc" tests. + void MakeWritableAndExecutable() { + bool result = SetPermissions(GetPlatformPageAllocator(), buffer_, size_, + v8::PageAllocator::kReadWriteExecute); + CHECK(result); + } + + private: + byte* buffer_; + int size_; +}; + +static inline std::unique_ptr AllocateAssemblerBuffer( + size_t requested = v8::internal::AssemblerBase::kMinimalBufferSize, + void* address = nullptr) { + return base::make_unique(requested, address); } } // namespace internal diff --git a/deps/v8/test/common/wasm/test-signatures.h b/deps/v8/test/common/wasm/test-signatures.h index 1b24a3b3cd..8b47720870 100644 --- a/deps/v8/test/common/wasm/test-signatures.h +++ b/deps/v8/test/common/wasm/test-signatures.h @@ -6,14 +6,13 @@ #define TEST_SIGNATURES_H #include "src/signature.h" +#include "src/wasm/value-type.h" #include "src/wasm/wasm-opcodes.h" namespace v8 { namespace internal { namespace wasm { -typedef Signature FunctionSig; - // A helper class with many useful signatures in order to simplify tests. class TestSignatures { public: diff --git a/deps/v8/test/common/wasm/wasm-macro-gen.h b/deps/v8/test/common/wasm/wasm-macro-gen.h index f722062662..17045ac325 100644 --- a/deps/v8/test/common/wasm/wasm-macro-gen.h +++ b/deps/v8/test/common/wasm/wasm-macro-gen.h @@ -17,14 +17,23 @@ #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion) -#define IMPORT_SIG_INDEX(v) U32V_1(v) +#define SIG_INDEX(v) U32V_1(v) #define FUNC_INDEX(v) U32V_1(v) -#define TABLE_INDEX(v) U32V_1(v) #define EXCEPTION_INDEX(v) U32V_1(v) #define NO_NAME U32V_1(0) -#define NAME_LENGTH(v) U32V_1(v) #define ENTRY_COUNT(v) U32V_1(v) +// Segment flags +#define ACTIVE_NO_INDEX 0 +#define PASSIVE 1 +#define ACTIVE_WITH_INDEX 2 + +// The table index field in an element segment was repurposed as a flags field. +// To specify a table index, we have to set the flag value to 2, followed by +// the table index. +#define TABLE_INDEX0 U32V_1(ACTIVE_NO_INDEX) +#define TABLE_INDEX(v) U32V_1(ACTIVE_WITH_INDEX), U32V_1(v) + #define ZERO_ALIGNMENT 0 #define ZERO_OFFSET 0 @@ -573,10 +582,25 @@ inline WasmOpcode LoadStoreOpcodeOf(MachineType type, bool store) { #define WASM_I64_SCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI64SConvertSatF64) #define WASM_I64_UCONVERT_SAT_F64(x) x, WASM_NUMERIC_OP(kExprI64UConvertSatF64) +#define MEMORY_ZERO 0 + +#define WASM_MEMORY_INIT(seg, dst, src, size) \ + dst, src, size, WASM_NUMERIC_OP(kExprMemoryInit), MEMORY_ZERO, U32V_1(seg) +#define WASM_MEMORY_DROP(seg) WASM_NUMERIC_OP(kExprMemoryDrop), U32V_1(seg) +#define WASM_MEMORY_COPY(dst, src, size) \ + dst, src, size, WASM_NUMERIC_OP(kExprMemoryCopy), MEMORY_ZERO +#define WASM_MEMORY_FILL(dst, val, size) \ + dst, val, size, WASM_NUMERIC_OP(kExprMemoryFill), MEMORY_ZERO +#define WASM_TABLE_INIT(seg, dst, src, size) \ + dst, src, size, WASM_NUMERIC_OP(kExprTableInit), TABLE_ZERO, U32V_1(seg) +#define WASM_TABLE_DROP(seg) WASM_NUMERIC_OP(kExprTableDrop), U32V_1(seg) +#define WASM_TABLE_COPY(dst, src, size) \ + dst, src, size, WASM_NUMERIC_OP(kExprTableCopy), TABLE_ZERO + //------------------------------------------------------------------------------ // Memory Operations. //------------------------------------------------------------------------------ -#define WASM_GROW_MEMORY(x) x, kExprGrowMemory, 0 +#define WASM_GROW_MEMORY(x) x, kExprMemoryGrow, 0 #define WASM_MEMORY_SIZE kExprMemorySize, 0 #define SIG_ENTRY_v_v kWasmFunctionTypeCode, 0, 0 diff --git a/deps/v8/test/common/wasm/wasm-module-runner.cc b/deps/v8/test/common/wasm/wasm-module-runner.cc index 9dfbe6fe1a..15e71b017d 100644 --- a/deps/v8/test/common/wasm/wasm-module-runner.cc +++ b/deps/v8/test/common/wasm/wasm-module-runner.cc @@ -7,7 +7,7 @@ #include "src/handles.h" #include "src/isolate.h" #include "src/objects-inl.h" -#include "src/objects.h" +#include "src/objects/heap-number-inl.h" #include "src/property-descriptor.h" #include "src/wasm/module-decoder.h" #include "src/wasm/wasm-engine.h" @@ -51,10 +51,10 @@ std::shared_ptr DecodeWasmModuleForTesting( if (decoding_result.failed()) { // Module verification failed. throw. thrower->CompileError("DecodeWasmModule failed: %s", - decoding_result.error_msg().c_str()); + decoding_result.error().message().c_str()); } - return std::move(decoding_result.val); + return std::move(decoding_result).value(); } bool InterpretWasmModuleForTesting(Isolate* isolate, @@ -143,12 +143,16 @@ int32_t CompileAndRunAsmWasmModule(Isolate* isolate, const byte* module_start, const byte* module_end) { HandleScope scope(isolate); ErrorThrower thrower(isolate, "CompileAndRunAsmWasmModule"); - MaybeHandle module = + MaybeHandle data = isolate->wasm_engine()->SyncCompileTranslatedAsmJs( isolate, &thrower, ModuleWireBytes(module_start, module_end), - Handle