summaryrefslogtreecommitdiff
path: root/deps/v8/test/common
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2019-03-12 09:01:49 +0100
committerMichaël Zasso <targos@protonmail.com>2019-03-14 18:49:21 +0100
commit7b48713334469818661fe276cf571de9c7899f2d (patch)
tree4dbda49ac88db76ce09dc330a0cb587e68e139ba /deps/v8/test/common
parent8549ac09b256666cf5275224ec58fab9939ff32e (diff)
downloadandroid-node-v8-7b48713334469818661fe276cf571de9c7899f2d.tar.gz
android-node-v8-7b48713334469818661fe276cf571de9c7899f2d.tar.bz2
android-node-v8-7b48713334469818661fe276cf571de9c7899f2d.zip
deps: update V8 to 7.3.492.25
PR-URL: https://github.com/nodejs/node/pull/25852 Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Diffstat (limited to 'deps/v8/test/common')
-rw-r--r--deps/v8/test/common/assembler-tester.h95
-rw-r--r--deps/v8/test/common/wasm/test-signatures.h3
-rw-r--r--deps/v8/test/common/wasm/wasm-macro-gen.h32
-rw-r--r--deps/v8/test/common/wasm/wasm-module-runner.cc43
-rw-r--r--deps/v8/test/common/wasm/wasm-module-runner.h43
5 files changed, 154 insertions, 62 deletions
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<uint8_t*>(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<int>(alloc_size);
+ buffer_ = static_cast<byte*>(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<AssemblerBuffer> Grow(int new_size) override {
+ FATAL("Cannot grow TestingAssemblerBuffer");
+ }
+
+ std::unique_ptr<AssemblerBuffer> 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<TestingAssemblerBuffer> AllocateAssemblerBuffer(
+ size_t requested = v8::internal::AssemblerBase::kMinimalBufferSize,
+ void* address = nullptr) {
+ return base::make_unique<TestingAssemblerBuffer>(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<ValueType> 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<WasmModule> 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<WasmModuleObject> module =
+ MaybeHandle<AsmWasmData> data =
isolate->wasm_engine()->SyncCompileTranslatedAsmJs(
isolate, &thrower, ModuleWireBytes(module_start, module_end),
- Handle<Script>::null(), Vector<const byte>());
- DCHECK_EQ(thrower.error(), module.is_null());
- if (module.is_null()) return -1;
+ Vector<const byte>(), Handle<HeapNumber>());
+ DCHECK_EQ(thrower.error(), data.is_null());
+ if (data.is_null()) return -1;
+
+ MaybeHandle<WasmModuleObject> module =
+ isolate->wasm_engine()->FinalizeTranslatedAsmJs(
+ isolate, data.ToHandleChecked(), Handle<Script>::null());
MaybeHandle<WasmInstanceObject> instance =
isolate->wasm_engine()->SyncInstantiate(
@@ -160,10 +164,9 @@ int32_t CompileAndRunAsmWasmModule(Isolate* isolate, const byte* module_start,
return RunWasmModuleForTesting(isolate, instance.ToHandleChecked(), 0,
nullptr);
}
-int32_t InterpretWasmModule(Isolate* isolate,
- Handle<WasmInstanceObject> instance,
- ErrorThrower* thrower, int32_t function_index,
- WasmValue* args, bool* possible_nondeterminism) {
+WasmInterpretationResult InterpretWasmModule(
+ Isolate* isolate, Handle<WasmInstanceObject> instance,
+ int32_t function_index, WasmValue* args) {
// Don't execute more than 16k steps.
constexpr int kMaxNumSteps = 16 * 1024;
@@ -186,17 +189,19 @@ int32_t InterpretWasmModule(Isolate* isolate,
bool stack_overflow = isolate->has_pending_exception();
isolate->clear_pending_exception();
- *possible_nondeterminism = thread->PossibleNondeterminism();
- if (stack_overflow) return 0xDEADBEEF;
+ if (stack_overflow) return WasmInterpretationResult::Stopped();
- if (thread->state() == WasmInterpreter::TRAPPED) return 0xDEADBEEF;
+ if (thread->state() == WasmInterpreter::TRAPPED) {
+ return WasmInterpretationResult::Trapped(thread->PossibleNondeterminism());
+ }
- if (interpreter_result == WasmInterpreter::FINISHED)
- return thread->GetReturnValue().to<int32_t>();
+ if (interpreter_result == WasmInterpreter::FINISHED) {
+ return WasmInterpretationResult::Finished(
+ thread->GetReturnValue().to<int32_t>(),
+ thread->PossibleNondeterminism());
+ }
- thrower->RangeError(
- "Interpreter did not finish execution within its step bound");
- return -1;
+ return WasmInterpretationResult::Stopped();
}
MaybeHandle<WasmExportedFunction> GetExportedFunction(
diff --git a/deps/v8/test/common/wasm/wasm-module-runner.h b/deps/v8/test/common/wasm/wasm-module-runner.h
index 7aa40bc6f1..f3ed508e40 100644
--- a/deps/v8/test/common/wasm/wasm-module-runner.h
+++ b/deps/v8/test/common/wasm/wasm-module-runner.h
@@ -61,13 +61,48 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
MaybeHandle<WasmInstanceObject> CompileAndInstantiateForTesting(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes);
+class WasmInterpretationResult {
+ public:
+ static WasmInterpretationResult Stopped() { return {kStopped, 0, false}; }
+ static WasmInterpretationResult Trapped(bool possible_nondeterminism) {
+ return {kTrapped, 0, possible_nondeterminism};
+ }
+ static WasmInterpretationResult Finished(int32_t result,
+ bool possible_nondeterminism) {
+ return {kFinished, result, possible_nondeterminism};
+ }
+
+ bool stopped() const { return status_ == kStopped; }
+ bool trapped() const { return status_ == kTrapped; }
+ bool finished() const { return status_ == kFinished; }
+
+ int32_t result() const {
+ DCHECK_EQ(status_, kFinished);
+ return result_;
+ }
+
+ bool possible_nondeterminism() const { return possible_nondeterminism_; }
+
+ private:
+ enum Status { kFinished, kTrapped, kStopped };
+
+ const Status status_;
+ const int32_t result_;
+ const bool possible_nondeterminism_;
+
+ WasmInterpretationResult(Status status, int32_t result,
+ bool possible_nondeterminism)
+ : status_(status),
+ result_(result),
+ possible_nondeterminism_(possible_nondeterminism) {}
+};
+
// Interprets the given module, starting at the function specified by
// {function_index}. The return type of the function has to be int32. The module
// should not have any imports or exports
-int32_t InterpretWasmModule(Isolate* isolate,
- Handle<WasmInstanceObject> instance,
- ErrorThrower* thrower, int32_t function_index,
- WasmValue* args, bool* possible_nondeterminism);
+WasmInterpretationResult InterpretWasmModule(
+ Isolate* isolate, Handle<WasmInstanceObject> instance,
+ int32_t function_index, WasmValue* args);
// Runs the module instance with arguments.
int32_t RunWasmModuleForTesting(Isolate* isolate,