diff options
Diffstat (limited to 'deps/v8/test/cctest')
132 files changed, 5229 insertions, 2428 deletions
diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index 9072d6bed7..c4aa51b818 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -50,9 +50,10 @@ v8_source_set("cctest_sources") { "$target_gen_dir/resources.cc", ### gcmole(all) ### - "../../test/common/wasm/flag-utils.h", - "../../test/common/wasm/test-signatures.h", - "../../test/common/wasm/wasm-macro-gen.h", + "../common/assembler-tester.h", + "../common/wasm/flag-utils.h", + "../common/wasm/test-signatures.h", + "../common/wasm/wasm-macro-gen.h", "cctest.cc", "cctest.h", "compiler/c-signature.h", @@ -117,6 +118,7 @@ v8_source_set("cctest_sources") { "heap/test-compaction.cc", "heap/test-concurrent-marking.cc", "heap/test-embedder-tracing.cc", + "heap/test-external-string-tracker.cc", "heap/test-heap.cc", "heap/test-incremental-marking.cc", "heap/test-invalidated-slots.cc", @@ -237,9 +239,11 @@ v8_source_set("cctest_sources") { "types-fuzz.h", "unicode-helpers.h", "wasm/test-c-wasm-entry.cc", + "wasm/test-jump-table-assembler.cc", "wasm/test-run-wasm-64.cc", "wasm/test-run-wasm-asmjs.cc", "wasm/test-run-wasm-atomics.cc", + "wasm/test-run-wasm-atomics64.cc", "wasm/test-run-wasm-interpreter.cc", "wasm/test-run-wasm-js.cc", "wasm/test-run-wasm-module.cc", @@ -296,7 +300,6 @@ v8_source_set("cctest_sources") { "test-sync-primitives-arm64.cc", "test-utils-arm64.cc", "test-utils-arm64.h", - "wasm/test-run-wasm-atomics64.cc", ] } else if (v8_current_cpu == "x86") { sources += [ ### gcmole(arch:ia32) ### @@ -352,7 +355,6 @@ v8_source_set("cctest_sources") { "test-disasm-x64.cc", "test-log-stack-tracer.cc", "test-macro-assembler-x64.cc", - "wasm/test-run-wasm-atomics64.cc", ] } else if (v8_current_cpu == "ppc" || v8_current_cpu == "ppc64") { sources += [ ### gcmole(arch:ppc) ### diff --git a/deps/v8/test/cctest/OWNERS b/deps/v8/test/cctest/OWNERS index 87396a0535..43d91faf84 100644 --- a/deps/v8/test/cctest/OWNERS +++ b/deps/v8/test/cctest/OWNERS @@ -1,6 +1,5 @@ -per-file *-mips*=ivica.bogosavljevic@mips.com -per-file *-mips*=Miran.Karic@mips.com -per-file *-mips*=sreten.kovacevic@mips.com +per-file *-mips*=ibogosavljevic@wavecomp.com +per-file *-mips*=skovacevic@wavecomp.com per-file *-ppc*=dstence@us.ibm.com per-file *-ppc*=joransiu@ca.ibm.com per-file *-ppc*=jyan@ca.ibm.com diff --git a/deps/v8/test/cctest/cctest.h b/deps/v8/test/cctest/cctest.h index 8bae124ea1..383771710a 100644 --- a/deps/v8/test/cctest/cctest.h +++ b/deps/v8/test/cctest/cctest.h @@ -32,7 +32,6 @@ #include "include/libplatform/libplatform.h" #include "include/v8-platform.h" -#include "src/assembler.h" #include "src/debug/debug-interface.h" #include "src/flags.h" #include "src/heap/factory.h" @@ -548,32 +547,6 @@ static inline void CheckDoubleEquals(double expected, double actual) { CHECK_GE(expected, actual - kEpsilon); } -static inline uint8_t* AllocateAssemblerBuffer( - size_t* allocated, - size_t requested = v8::internal::AssemblerBase::kMinimalBufferSize) { - size_t page_size = v8::internal::AllocatePageSize(); - size_t alloc_size = RoundUp(requested, page_size); - void* result = v8::internal::AllocatePages( - nullptr, alloc_size, page_size, v8::PageAllocator::kReadWriteExecute); - CHECK(result); - *allocated = alloc_size; - return static_cast<uint8_t*>(result); -} - -static inline void MakeAssemblerBufferExecutable(uint8_t* buffer, - size_t allocated) { - bool result = v8::internal::SetPermissions(buffer, allocated, - v8::PageAllocator::kReadExecute); - CHECK(result); -} - -static inline void MakeAssemblerBufferWritable(uint8_t* buffer, - size_t allocated) { - bool result = v8::internal::SetPermissions(buffer, allocated, - v8::PageAllocator::kReadWrite); - CHECK(result); -} - static v8::debug::DebugDelegate dummy_delegate; static inline void EnableDebugger(v8::Isolate* isolate) { diff --git a/deps/v8/test/cctest/cctest.status b/deps/v8/test/cctest/cctest.status index a7fcb4f237..c59c443b06 100644 --- a/deps/v8/test/cctest/cctest.status +++ b/deps/v8/test/cctest/cctest.status @@ -345,6 +345,13 @@ }], # '(arch == mipsel or arch == mips64el or arch == mips or arch == mips64) and not simd_mips' ############################################################################## +['arch == mipsel or arch == mips64el or arch == mips or arch == mips64 or arch == ppc or arch == ppc64 or arch == s390 or arch == s390x', { + # TODO(mips-team): Implement I64Atomic operations on MIPS + # TODO(ppc-team, s390-team): Implement I64Atomic operations on PPC/s390 + 'test-run-wasm-atomics64/*': [SKIP], +}], # 'arch == mipsel or arch == mips64el or arch == mips or arch == mips64 or arch == ppc or arch == ppc64 or arch == s390 or arch == s390x' + +############################################################################## ['mips_arch_variant == r6', { # For MIPS[64] architecture release 6, fusion multiply-accumulate instructions # will cause failures on several tests that expect exact floating-point @@ -383,6 +390,7 @@ # TODO(ppc): Implement load/store reverse byte instructions 'test-run-wasm-simd/RunWasmCompiled_SimdLoadStoreLoad': [SKIP], 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad': [SKIP], + 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_turbofan': [SKIP], }], # 'system == aix or (arch == ppc64 and byteorder == big)' @@ -404,57 +412,6 @@ }], # 'arch == ppc or arch == ppc64 or arch == s390 or arch == s390x' ############################################################################## -['byteorder == big', { - - # BUG(7827). fix simd globals for big endian - 'test-run-wasm-simd/RunWasm_SimdI32x4GetGlobal_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdI32x4SetGlobal_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdF32x4GetGlobal_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdF32x4SetGlobal_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_simd_turbofan': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_SimdLoadStoreLoad_simd_lowered': [SKIP], - 'test-run-wasm-simd/RunWasm_I32x4AddHoriz_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_I16x8AddHoriz_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_F32x4AddHoriz_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4Dup_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4ZipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4ZipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4UnzipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4UnzipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4TransposeLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4TransposeRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x2Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S32x4Irregular_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8Dup_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8ZipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8ZipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8UnzipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8UnzipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8TransposeLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8TransposeRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x4Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x2Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S16x8Irregular_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16Dup_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16ZipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16ZipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16UnzipLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16UnzipRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16TransposeLeft_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16TransposeRight_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x8Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x4Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x2Reverse_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16Irregular_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16Blend_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_S8x16Concat_interpreter': [SKIP], - 'test-run-wasm-simd/RunWasm_I16x8ConvertI32x4*': [SKIP], - 'test-run-wasm-simd/RunWasm_I8x16ConvertI16x8*': [SKIP], - -}], # 'byteorder == big' - -############################################################################## ['variant == stress_incremental_marking', { 'test-heap-profiler/SamplingHeapProfiler': [SKIP], }], # variant == stress_incremental_marking diff --git a/deps/v8/test/cctest/compiler/code-assembler-tester.h b/deps/v8/test/cctest/compiler/code-assembler-tester.h index 1edb3fdf4b..7c88998f8a 100644 --- a/deps/v8/test/cctest/compiler/code-assembler-tester.h +++ b/deps/v8/test/cctest/compiler/code-assembler-tester.h @@ -60,6 +60,10 @@ class CodeAssemblerTester { &state_, AssemblerOptions::Default(scope_.isolate())); } + Handle<Code> GenerateCode(const AssemblerOptions& options) { + return CodeAssembler::GenerateCode(&state_, options); + } + Handle<Code> GenerateCodeCloseAndEscape() { return scope_.CloseAndEscape(GenerateCode()); } diff --git a/deps/v8/test/cctest/compiler/function-tester.cc b/deps/v8/test/cctest/compiler/function-tester.cc index c3abcf7a15..86678606d4 100644 --- a/deps/v8/test/cctest/compiler/function-tester.cc +++ b/deps/v8/test/cctest/compiler/function-tester.cc @@ -4,7 +4,7 @@ #include "test/cctest/compiler/function-tester.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/compiler.h" #include "src/compiler/linkage.h" #include "src/compiler/pipeline.h" @@ -21,6 +21,7 @@ namespace compiler { FunctionTester::FunctionTester(const char* source, uint32_t flags) : isolate(main_isolate()), + canonical(isolate), function((FLAG_allow_natives_syntax = true, NewFunction(source))), flags_(flags) { Compile(function); @@ -30,6 +31,7 @@ FunctionTester::FunctionTester(const char* source, uint32_t flags) FunctionTester::FunctionTester(Graph* graph, int param_count) : isolate(main_isolate()), + canonical(isolate), function(NewFunction(BuildFunction(param_count).c_str())), flags_(0) { CompileGraph(graph); @@ -37,6 +39,7 @@ FunctionTester::FunctionTester(Graph* graph, int param_count) FunctionTester::FunctionTester(Handle<Code> code, int param_count) : isolate(main_isolate()), + canonical(isolate), function((FLAG_allow_natives_syntax = true, NewFunction(BuildFunction(param_count).c_str()))), flags_(0) { diff --git a/deps/v8/test/cctest/compiler/function-tester.h b/deps/v8/test/cctest/compiler/function-tester.h index abcb924cec..6e0146958f 100644 --- a/deps/v8/test/cctest/compiler/function-tester.h +++ b/deps/v8/test/cctest/compiler/function-tester.h @@ -31,6 +31,7 @@ class FunctionTester : public InitializedHandleScope { explicit FunctionTester(Handle<Code> code); Isolate* isolate; + CanonicalHandleScope canonical; Handle<JSFunction> function; MaybeHandle<Object> Call() { diff --git a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc index 663b66b74d..f961021913 100644 --- a/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc +++ b/deps/v8/test/cctest/compiler/test-basic-block-profiler.cc @@ -18,12 +18,11 @@ class BasicBlockProfilerTest : public RawMachineAssemblerTester<int32_t> { FLAG_turbo_profiling = true; } - void ResetCounts() { isolate()->basic_block_profiler()->ResetCounts(); } + void ResetCounts() { BasicBlockProfiler::Get()->ResetCounts(); } void Expect(size_t size, uint32_t* expected) { - CHECK(isolate()->basic_block_profiler()); const BasicBlockProfiler::DataList* l = - isolate()->basic_block_profiler()->data_list(); + BasicBlockProfiler::Get()->data_list(); CHECK_NE(0, static_cast<int>(l->size())); const BasicBlockProfiler::Data* data = l->back(); CHECK_EQ(static_cast<int>(size), static_cast<int>(data->n_blocks())); diff --git a/deps/v8/test/cctest/compiler/test-code-generator.cc b/deps/v8/test/cctest/compiler/test-code-generator.cc index 9a7b590f5a..a3b80bc887 100644 --- a/deps/v8/test/cctest/compiler/test-code-generator.cc +++ b/deps/v8/test/cctest/compiler/test-code-generator.cc @@ -83,8 +83,8 @@ Handle<Code> BuildSetupFunction(Isolate* isolate, // First allocate the FixedArray which will hold the final results. Here we // should take care of all allocations, meaning we allocate HeapNumbers and // FixedArrays representing Simd128 values. - Node* state_out = __ AllocateFixedArray(PACKED_ELEMENTS, - __ IntPtrConstant(parameters.size())); + TNode<FixedArray> state_out = __ Cast(__ AllocateFixedArray( + PACKED_ELEMENTS, __ IntPtrConstant(parameters.size()))); for (int i = 0; i < static_cast<int>(parameters.size()); i++) { switch (parameters[i].representation()) { case MachineRepresentation::kTagged: @@ -94,8 +94,8 @@ Handle<Code> BuildSetupFunction(Isolate* isolate, __ StoreFixedArrayElement(state_out, i, __ AllocateHeapNumber()); break; case MachineRepresentation::kSimd128: { - Node* vector = - __ AllocateFixedArray(PACKED_SMI_ELEMENTS, __ IntPtrConstant(4)); + TNode<FixedArray> vector = __ Cast( + __ AllocateFixedArray(PACKED_SMI_ELEMENTS, __ IntPtrConstant(4))); for (int lane = 0; lane < 4; lane++) { __ StoreFixedArrayElement(vector, lane, __ SmiConstant(0)); } @@ -109,7 +109,7 @@ Handle<Code> BuildSetupFunction(Isolate* isolate, } params.push_back(state_out); // Then take each element of the initial state and pass them as arguments. - Node* state_in = __ Parameter(1); + TNode<FixedArray> state_in = __ Cast(__ Parameter(1)); for (int i = 0; i < static_cast<int>(parameters.size()); i++) { Node* element = __ LoadFixedArrayElement(state_in, __ IntPtrConstant(i)); // Unbox all elements before passing them as arguments. @@ -197,7 +197,7 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate, std::vector<AllocatedOperand> parameters) { CodeAssemblerTester tester(isolate, call_descriptor, "teardown"); CodeStubAssembler assembler(tester.state()); - Node* result_array = __ Parameter(1); + TNode<FixedArray> result_array = __ Cast(__ Parameter(1)); for (int i = 0; i < static_cast<int>(parameters.size()); i++) { // The first argument is not used and the second is "result_array". Node* param = __ Parameter(i + 2); @@ -216,7 +216,8 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate, param, MachineRepresentation::kFloat64); break; case MachineRepresentation::kSimd128: { - Node* vector = __ LoadFixedArrayElement(result_array, i); + TNode<FixedArray> vector = + __ Cast(__ LoadFixedArrayElement(result_array, i)); for (int lane = 0; lane < 4; lane++) { Node* lane_value = __ SmiFromInt32(tester.raw_assembler_for_testing()->AddNode( @@ -995,8 +996,7 @@ class CodeGeneratorTester { generator_ = new CodeGenerator( environment->main_zone(), &frame_, &linkage_, environment->code(), &info_, environment->main_isolate(), base::Optional<OsrHelper>(), - kNoSourcePosition, nullptr, nullptr, - PoisoningMitigationLevel::kDontPoison, + kNoSourcePosition, nullptr, PoisoningMitigationLevel::kDontPoison, AssemblerOptions::Default(environment->main_isolate()), Builtins::kNoBuiltinId); diff --git a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc index 5843c51698..a31700ede2 100644 --- a/deps/v8/test/cctest/compiler/test-js-constant-cache.cc +++ b/deps/v8/test/cctest/compiler/test-js-constant-cache.cc @@ -15,7 +15,7 @@ namespace compiler { class JSCacheTesterHelper { protected: - JSCacheTesterHelper(Isolate* isolate, Zone* zone) + explicit JSCacheTesterHelper(Zone* zone) : main_graph_(zone), main_common_(zone), main_javascript_(zone), @@ -33,7 +33,7 @@ class JSConstantCacheTester : public HandleAndZoneScope, public JSGraph { public: JSConstantCacheTester() - : JSCacheTesterHelper(main_isolate(), main_zone()), + : JSCacheTesterHelper(main_zone()), JSGraph(main_isolate(), &main_graph_, &main_common_, &main_javascript_, nullptr, &main_machine_) { main_graph_.SetStart(main_graph_.NewNode(common()->Start(0))); diff --git a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc index 6560bae096..7938c50069 100644 --- a/deps/v8/test/cctest/compiler/test-js-context-specialization.cc +++ b/deps/v8/test/cctest/compiler/test-js-context-specialization.cc @@ -22,7 +22,8 @@ namespace compiler { class ContextSpecializationTester : public HandleAndZoneScope { public: explicit ContextSpecializationTester(Maybe<OuterContext> context) - : graph_(new (main_zone()) Graph(main_zone())), + : canonical_(main_isolate()), + graph_(new (main_zone()) Graph(main_zone())), common_(main_zone()), javascript_(main_zone()), machine_(main_zone()), @@ -30,7 +31,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { jsgraph_(main_isolate(), graph(), common(), &javascript_, &simplified_, &machine_), reducer_(main_zone(), graph()), - js_heap_broker_(main_isolate()), + js_heap_broker_(main_isolate(), main_zone()), spec_(&reducer_, jsgraph(), &js_heap_broker_, context, MaybeHandle<JSFunction>()) {} @@ -50,6 +51,7 @@ class ContextSpecializationTester : public HandleAndZoneScope { size_t expected_new_depth); private: + CanonicalHandleScope canonical_; Graph* graph_; CommonOperatorBuilder common_; JSOperatorBuilder javascript_; @@ -106,6 +108,11 @@ void ContextSpecializationTester::CheckContextInputAndDepthChanges( static const int slot_index = Context::NATIVE_CONTEXT_INDEX; TEST(ReduceJSLoadContext0) { + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + ContextSpecializationTester t(Nothing<OuterContext>()); Node* start = t.graph()->NewNode(t.common()->Start(0)); @@ -170,6 +177,8 @@ TEST(ReduceJSLoadContext0) { CHECK(match.HasValue()); CHECK_EQ(*expected, *match.Value()); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(ReduceJSLoadContext1) { @@ -247,6 +256,11 @@ TEST(ReduceJSLoadContext2) { // context2 <-- context1 <-- context0 (= HeapConstant(context_object1)) // context_object1 <~~ context_object0 + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + ContextSpecializationTester t(Nothing<OuterContext>()); Node* start = t.graph()->NewNode(t.common()->Start(0)); @@ -317,6 +331,8 @@ TEST(ReduceJSLoadContext2) { t.javascript()->LoadContext(3, slot_index, true), context2, start); t.CheckChangesToValue(load, slot_value0); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(ReduceJSLoadContext3) { @@ -326,6 +342,11 @@ TEST(ReduceJSLoadContext3) { // context_object2 from ReduceJSLoadContext2 for this, so almost all test // expectations are the same as in ReduceJSLoadContext2. + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + HandleAndZoneScope handle_zone_scope; auto factory = handle_zone_scope.main_isolate()->factory(); @@ -400,9 +421,16 @@ TEST(ReduceJSLoadContext3) { t.javascript()->LoadContext(3, slot_index, true), context2, start); t.CheckChangesToValue(load, slot_value0); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(ReduceJSStoreContext0) { + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + ContextSpecializationTester t(Nothing<OuterContext>()); Node* start = t.graph()->NewNode(t.common()->Start(0)); @@ -462,6 +490,8 @@ TEST(ReduceJSStoreContext0) { CHECK_EQ(0, static_cast<int>(access.depth())); CHECK_EQ(false, access.immutable()); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(ReduceJSStoreContext1) { @@ -509,6 +539,11 @@ TEST(ReduceJSStoreContext1) { } TEST(ReduceJSStoreContext2) { + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + ContextSpecializationTester t(Nothing<OuterContext>()); Node* start = t.graph()->NewNode(t.common()->Start(0)); @@ -559,9 +594,16 @@ TEST(ReduceJSStoreContext2) { context2, context2, start, start); t.CheckContextInputAndDepthChanges(store, context_object0, 0); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(ReduceJSStoreContext3) { + // TODO(neis): The native context below does not have all the fields + // initialized that the heap broker wants to serialize. + bool concurrent_compiler_frontend = FLAG_concurrent_compiler_frontend; + FLAG_concurrent_compiler_frontend = false; + HandleAndZoneScope handle_zone_scope; auto factory = handle_zone_scope.main_isolate()->factory(); @@ -616,6 +658,8 @@ TEST(ReduceJSStoreContext3) { context2, context2, start, start); t.CheckContextInputAndDepthChanges(store, context_object0, 0); } + + FLAG_concurrent_compiler_frontend = concurrent_compiler_frontend; } TEST(SpecializeJSFunction_ToConstant1) { diff --git a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc index 3f969f8bfe..eec562cf36 100644 --- a/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc +++ b/deps/v8/test/cctest/compiler/test-js-typed-lowering.cc @@ -23,7 +23,8 @@ class JSTypedLoweringTester : public HandleAndZoneScope { public: explicit JSTypedLoweringTester(int num_parameters = 0) : isolate(main_isolate()), - js_heap_broker(isolate), + canonical(isolate), + js_heap_broker(isolate, main_zone()), binop(nullptr), unop(nullptr), javascript(main_zone()), @@ -39,6 +40,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope { } Isolate* isolate; + CanonicalHandleScope canonical; JSHeapBroker js_heap_broker; const Operator* binop; const Operator* unop; @@ -605,7 +607,8 @@ static void CheckIsConvertedToNumber(Node* val, Node* converted) { CHECK_EQ(val, converted); } else { if (converted->opcode() == IrOpcode::kNumberConstant) return; - CHECK_EQ(IrOpcode::kJSToNumber, converted->opcode()); + CHECK(IrOpcode::kJSToNumber == converted->opcode() || + IrOpcode::kJSToNumberConvertBigInt == converted->opcode()); CHECK_EQ(val, converted->InputAt(0)); } } diff --git a/deps/v8/test/cctest/compiler/test-linkage.cc b/deps/v8/test/cctest/compiler/test-linkage.cc index 39ef66c5eb..38c5d17b6b 100644 --- a/deps/v8/test/cctest/compiler/test-linkage.cc +++ b/deps/v8/test/cctest/compiler/test-linkage.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/code-factory.h" #include "src/code-stubs.h" #include "src/compiler.h" @@ -35,8 +35,9 @@ static Handle<JSFunction> Compile(const char* source) { .ToHandleChecked(); Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( - source_code, Compiler::ScriptDetails(), v8::ScriptOriginOptions(), - nullptr, nullptr, v8::ScriptCompiler::kNoCompileOptions, + isolate, source_code, Compiler::ScriptDetails(), + v8::ScriptOriginOptions(), nullptr, nullptr, + v8::ScriptCompiler::kNoCompileOptions, ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE) .ToHandleChecked(); return isolate->factory()->NewFunctionFromSharedFunctionInfo( diff --git a/deps/v8/test/cctest/compiler/test-multiple-return.cc b/deps/v8/test/cctest/compiler/test-multiple-return.cc index 13496ae829..b591d193e7 100644 --- a/deps/v8/test/cctest/compiler/test-multiple-return.cc +++ b/deps/v8/test/cctest/compiler/test-multiple-return.cc @@ -130,92 +130,104 @@ std::unique_ptr<wasm::NativeModule> AllocateNativeModule(Isolate* isolate, // WasmCallDescriptor assumes that code is on the native heap and not // within a code object. return isolate->wasm_engine()->code_manager()->NewNativeModule( - isolate, code_size, false, std::move(module), env); + isolate, wasm::kAllWasmFeatures, code_size, false, std::move(module), + env); } void TestReturnMultipleValues(MachineType type) { const int kMaxCount = 20; - for (int count = 0; count < kMaxCount; ++count) { - printf("\n==== type = %s, count = %d ====\n\n\n", - MachineReprToString(type.representation()), count); - v8::internal::AccountingAllocator allocator; - Zone zone(&allocator, ZONE_NAME); - CallDescriptor* desc = CreateCallDescriptor(&zone, count, 2, type); - HandleAndZoneScope handles; - RawMachineAssembler m(handles.main_isolate(), - new (handles.main_zone()) Graph(handles.main_zone()), - desc, MachineType::PointerRepresentation(), - InstructionSelector::SupportedMachineOperatorFlags()); - - // m.Parameter(0) is the WasmContext. - Node* p0 = m.Parameter(1); - Node* p1 = m.Parameter(2); - typedef Node* Node_ptr; - std::unique_ptr<Node_ptr[]> returns(new Node_ptr[count]); - for (int i = 0; i < count; ++i) { - if (i % 3 == 0) returns[i] = Add(m, type, p0, p1); - if (i % 3 == 1) returns[i] = Sub(m, type, p0, p1); - if (i % 3 == 2) returns[i] = Mul(m, type, p0, p1); - } - m.Return(count, returns.get()); - - OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(), - Code::WASM_FUNCTION); - Handle<Code> code = - Pipeline::GenerateCodeForTesting( - &info, handles.main_isolate(), desc, m.graph(), - AssemblerOptions::Default(handles.main_isolate()), m.Export()) - .ToHandleChecked(); + const int kMaxParamCount = 9; + // Use 9 parameters as a regression test or https://crbug.com/838098. + for (int param_count : {2, kMaxParamCount}) { + for (int count = 0; count < kMaxCount; ++count) { + printf("\n==== type = %s, count = %d ====\n\n\n", + MachineReprToString(type.representation()), count); + v8::internal::AccountingAllocator allocator; + Zone zone(&allocator, ZONE_NAME); + CallDescriptor* desc = + CreateCallDescriptor(&zone, count, param_count, type); + HandleAndZoneScope handles; + RawMachineAssembler m( + handles.main_isolate(), + new (handles.main_zone()) Graph(handles.main_zone()), desc, + MachineType::PointerRepresentation(), + InstructionSelector::SupportedMachineOperatorFlags()); + + // m.Parameter(0) is the WasmContext. + Node* p0 = m.Parameter(1); + Node* p1 = m.Parameter(2); + typedef Node* Node_ptr; + std::unique_ptr<Node_ptr[]> returns(new Node_ptr[count]); + for (int i = 0; i < count; ++i) { + if (i % 3 == 0) returns[i] = Add(m, type, p0, p1); + if (i % 3 == 1) returns[i] = Sub(m, type, p0, p1); + if (i % 3 == 2) returns[i] = Mul(m, type, p0, p1); + } + m.Return(count, returns.get()); + + OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(), + Code::WASM_FUNCTION); + Handle<Code> code = + Pipeline::GenerateCodeForTesting( + &info, handles.main_isolate(), desc, m.graph(), + AssemblerOptions::Default(handles.main_isolate()), m.Export()) + .ToHandleChecked(); #ifdef ENABLE_DISASSEMBLER - if (FLAG_print_code) { - StdoutStream os; - code->Disassemble("multi_value", os); - } + if (FLAG_print_code) { + StdoutStream os; + code->Disassemble("multi_value", os); + } #endif - const int a = 47, b = 12; - int expect = 0; - for (int i = 0, sign = +1; i < count; ++i) { - if (i % 3 == 0) expect += sign * (a + b); - if (i % 3 == 1) expect += sign * (a - b); - if (i % 3 == 2) expect += sign * (a * b); - if (i % 4 == 0) sign = -sign; - } - - std::unique_ptr<wasm::NativeModule> module = AllocateNativeModule( - handles.main_isolate(), code->raw_instruction_size()); - byte* code_start = module->AddCodeCopy(code, wasm::WasmCode::kFunction, 0) - ->instructions() - .start(); - - RawMachineAssemblerTester<int32_t> mt; - Node* call_inputs[] = {mt.PointerConstant(code_start), - // WasmContext dummy - mt.PointerConstant(nullptr), - // Inputs - MakeConstant(mt, type, a), - MakeConstant(mt, type, b)}; - - Node* ret_multi = mt.AddNode(mt.common()->Call(desc), - arraysize(call_inputs), call_inputs); - Node* ret = MakeConstant(mt, type, 0); - bool sign = false; - for (int i = 0; i < count; ++i) { - Node* x = (count == 1) - ? ret_multi - : mt.AddNode(mt.common()->Projection(i), ret_multi); - ret = sign ? Sub(mt, type, ret, x) : Add(mt, type, ret, x); - if (i % 4 == 0) sign = !sign; - } - mt.Return(ToInt32(mt, type, ret)); + const int a = 47, b = 12; + int expect = 0; + for (int i = 0, sign = +1; i < count; ++i) { + if (i % 3 == 0) expect += sign * (a + b); + if (i % 3 == 1) expect += sign * (a - b); + if (i % 3 == 2) expect += sign * (a * b); + if (i % 4 == 0) sign = -sign; + } + + std::unique_ptr<wasm::NativeModule> module = AllocateNativeModule( + handles.main_isolate(), code->raw_instruction_size()); + byte* code_start = module->AddCodeCopy(code, wasm::WasmCode::kFunction, 0) + ->instructions() + .start(); + + RawMachineAssemblerTester<int32_t> mt; + const int input_count = 2 + param_count; + Node* call_inputs[2 + kMaxParamCount]; + call_inputs[0] = mt.PointerConstant(code_start); + // WasmContext dummy + call_inputs[1] = mt.PointerConstant(nullptr); + // Special inputs for the test. + call_inputs[2] = MakeConstant(mt, type, a); + call_inputs[3] = MakeConstant(mt, type, b); + for (int i = 2; i < param_count; i++) { + call_inputs[2 + i] = MakeConstant(mt, type, i); + } + + Node* ret_multi = mt.AddNode(mt.common()->Call(desc), + input_count, call_inputs); + Node* ret = MakeConstant(mt, type, 0); + bool sign = false; + for (int i = 0; i < count; ++i) { + Node* x = (count == 1) + ? ret_multi + : mt.AddNode(mt.common()->Projection(i), ret_multi); + ret = sign ? Sub(mt, type, ret, x) : Add(mt, type, ret, x); + if (i % 4 == 0) sign = !sign; + } + mt.Return(ToInt32(mt, type, ret)); #ifdef ENABLE_DISASSEMBLER - Handle<Code> code2 = mt.GetCode(); - if (FLAG_print_code) { - StdoutStream os; - code2->Disassemble("multi_value_call", os); - } + Handle<Code> code2 = mt.GetCode(); + if (FLAG_print_code) { + StdoutStream os; + code2->Disassemble("multi_value_call", os); + } #endif - CHECK_EQ(expect, mt.Call()); + CHECK_EQ(expect, mt.Call()); + } } } diff --git a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc index 3e0e019fd2..c62ed69105 100644 --- a/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc +++ b/deps/v8/test/cctest/compiler/test-run-bytecode-graph-builder.cc @@ -4,7 +4,7 @@ #include <utility> -#include "src/api.h" +#include "src/api-inl.h" #include "src/compiler/pipeline.h" #include "src/debug/debug-interface.h" #include "src/execution.h" diff --git a/deps/v8/test/cctest/compiler/test-run-jscalls.cc b/deps/v8/test/cctest/compiler/test-run-jscalls.cc index 1b6d4fc49f..b1e9ddfce3 100644 --- a/deps/v8/test/cctest/compiler/test-run-jscalls.cc +++ b/deps/v8/test/cctest/compiler/test-run-jscalls.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" #include "src/contexts.h" #include "src/flags.h" #include "src/objects-inl.h" diff --git a/deps/v8/test/cctest/compiler/test-run-machops.cc b/deps/v8/test/cctest/compiler/test-run-machops.cc index 709c14e88e..71adbc738d 100644 --- a/deps/v8/test/cctest/compiler/test-run-machops.cc +++ b/deps/v8/test/cctest/compiler/test-run-machops.cc @@ -85,11 +85,7 @@ TEST(RunWord32ReverseBits) { TEST(RunWord32ReverseBytes) { BufferedRawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); - if (!m.machine()->Word32ReverseBytes().IsSupported()) { - // We can only test the operator if it exists on the testing platform. - return; - } - m.Return(m.AddNode(m.machine()->Word32ReverseBytes().op(), m.Parameter(0))); + m.Return(m.AddNode(m.machine()->Word32ReverseBytes(), m.Parameter(0))); CHECK_EQ(uint32_t(0x00000000), m.Call(uint32_t(0x00000000))); CHECK_EQ(uint32_t(0x12345678), m.Call(uint32_t(0x78563412))); @@ -224,11 +220,7 @@ TEST(RunWord64ReverseBits) { TEST(RunWord64ReverseBytes) { BufferedRawMachineAssemblerTester<uint64_t> m(MachineType::Uint64()); - if (!m.machine()->Word64ReverseBytes().IsSupported()) { - return; - } - - m.Return(m.AddNode(m.machine()->Word64ReverseBytes().op(), m.Parameter(0))); + m.Return(m.AddNode(m.machine()->Word64ReverseBytes(), m.Parameter(0))); CHECK_EQ(uint64_t(0x0000000000000000), m.Call(uint64_t(0x0000000000000000))); CHECK_EQ(uint64_t(0x1234567890ABCDEF), m.Call(uint64_t(0xEFCDAB9078563412))); @@ -2396,7 +2388,7 @@ TEST(RunWord32AndP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); - bt.AddReturn(m.Word32And(bt.param0, m.Word32Not(bt.param1))); + bt.AddReturn(m.Word32And(bt.param0, m.Word32BitwiseNot(bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = *i & ~(*j); @@ -2407,7 +2399,7 @@ TEST(RunWord32AndP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); - bt.AddReturn(m.Word32And(m.Word32Not(bt.param0), bt.param1)); + bt.AddReturn(m.Word32And(m.Word32BitwiseNot(bt.param0), bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { int32_t expected = ~(*i) & *j; @@ -2516,7 +2508,8 @@ TEST(RunWord32AndImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); - m.Return(m.Word32And(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); + m.Return( + m.Word32And(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i & ~(*j); CHECK_EQ(expected, m.Call(*j)); @@ -2709,7 +2702,7 @@ TEST(RunWord32OrP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); - bt.AddReturn(m.Word32Or(bt.param0, m.Word32Not(bt.param1))); + bt.AddReturn(m.Word32Or(bt.param0, m.Word32BitwiseNot(bt.param1))); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); @@ -2720,7 +2713,7 @@ TEST(RunWord32OrP) { { RawMachineAssemblerTester<int32_t> m; Uint32BinopTester bt(&m); - bt.AddReturn(m.Word32Or(m.Word32Not(bt.param0), bt.param1)); + bt.AddReturn(m.Word32Or(m.Word32BitwiseNot(bt.param0), bt.param1)); FOR_UINT32_INPUTS(i) { FOR_UINT32_INPUTS(j) { uint32_t expected = ~(*i) | *j; @@ -2745,7 +2738,8 @@ TEST(RunWord32OrImm) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); - m.Return(m.Word32Or(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); + m.Return( + m.Word32Or(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i | ~(*j); CHECK_EQ(expected, m.Call(*j)); @@ -2947,7 +2941,7 @@ TEST(RunWord32XorP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); - bt.AddReturn(m.Word32Xor(bt.param0, m.Word32Not(bt.param1))); + bt.AddReturn(m.Word32Xor(bt.param0, m.Word32BitwiseNot(bt.param1))); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = *i ^ ~(*j); @@ -2958,7 +2952,7 @@ TEST(RunWord32XorP) { { RawMachineAssemblerTester<int32_t> m; Int32BinopTester bt(&m); - bt.AddReturn(m.Word32Xor(m.Word32Not(bt.param0), bt.param1)); + bt.AddReturn(m.Word32Xor(m.Word32BitwiseNot(bt.param0), bt.param1)); FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { int32_t expected = ~(*i) ^ *j; @@ -2969,7 +2963,8 @@ TEST(RunWord32XorP) { { FOR_UINT32_INPUTS(i) { RawMachineAssemblerTester<uint32_t> m(MachineType::Uint32()); - m.Return(m.Word32Xor(m.Int32Constant(*i), m.Word32Not(m.Parameter(0)))); + m.Return( + m.Word32Xor(m.Int32Constant(*i), m.Word32BitwiseNot(m.Parameter(0)))); FOR_UINT32_INPUTS(j) { uint32_t expected = *i ^ ~(*j); CHECK_EQ(expected, m.Call(*j)); @@ -3454,10 +3449,9 @@ TEST(RunWord32RorInComparison) { } } - -TEST(RunWord32NotP) { +TEST(RunWord32BitwiseNotP) { RawMachineAssemblerTester<int32_t> m(MachineType::Int32()); - m.Return(m.Word32Not(m.Parameter(0))); + m.Return(m.Word32BitwiseNot(m.Parameter(0))); FOR_INT32_INPUTS(i) { int expected = ~(*i); CHECK_EQ(expected, m.Call(*i)); diff --git a/deps/v8/test/cctest/compiler/test-run-retpoline.cc b/deps/v8/test/cctest/compiler/test-run-retpoline.cc index 4e5f99f413..3bbab4265f 100644 --- a/deps/v8/test/cctest/compiler/test-run-retpoline.cc +++ b/deps/v8/test/cctest/compiler/test-run-retpoline.cc @@ -128,6 +128,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone, void TestHelper(int n, int m, bool tail) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); + CanonicalHandleScope canonical(isolate); Zone* zone = scope.main_zone(); CallDescriptor* caller_descriptor = CreateDescriptorForStackArguments(zone, n); diff --git a/deps/v8/test/cctest/compiler/test-run-stubs.cc b/deps/v8/test/cctest/compiler/test-run-stubs.cc index 1751ee0836..9c76f22b99 100644 --- a/deps/v8/test/cctest/compiler/test-run-stubs.cc +++ b/deps/v8/test/cctest/compiler/test-run-stubs.cc @@ -13,6 +13,7 @@ #include "src/compiler/machine-operator.h" #include "src/compiler/pipeline.h" #include "src/objects-inl.h" +#include "src/objects/js-array-inl.h" #include "src/optimized-compilation-info.h" #include "test/cctest/compiler/function-tester.h" @@ -22,7 +23,7 @@ namespace compiler { class StubTester { public: - StubTester(Isolate* isolate, Zone* zone, CodeStub* stub) + StubTester(Zone* zone, CodeStub* stub) : zone_(zone), info_(ArrayVector("test"), zone, Code::STUB), interface_descriptor_(stub->GetCallInterfaceDescriptor()), diff --git a/deps/v8/test/cctest/compiler/test-run-tail-calls.cc b/deps/v8/test/cctest/compiler/test-run-tail-calls.cc index 34d6212d73..b57b4fcbac 100644 --- a/deps/v8/test/cctest/compiler/test-run-tail-calls.cc +++ b/deps/v8/test/cctest/compiler/test-run-tail-calls.cc @@ -108,6 +108,7 @@ CallDescriptor* CreateDescriptorForStackArguments(Zone* zone, void TestHelper(int n, int m) { HandleAndZoneScope scope; Isolate* isolate = scope.main_isolate(); + CanonicalHandleScope canonical(isolate); Zone* zone = scope.main_zone(); CallDescriptor* caller_descriptor = CreateDescriptorForStackArguments(zone, n); diff --git a/deps/v8/test/cctest/compiler/test-run-variables.cc b/deps/v8/test/cctest/compiler/test-run-variables.cc index 728d60f491..e2539dc16c 100644 --- a/deps/v8/test/cctest/compiler/test-run-variables.cc +++ b/deps/v8/test/cctest/compiler/test-run-variables.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "test/cctest/compiler/function-tester.h" diff --git a/deps/v8/test/cctest/heap/heap-tester.h b/deps/v8/test/cctest/heap/heap-tester.h index 422560c773..a2e860a8a3 100644 --- a/deps/v8/test/cctest/heap/heap-tester.h +++ b/deps/v8/test/cctest/heap/heap-tester.h @@ -21,6 +21,10 @@ V(InvalidatedSlotsEvacuationCandidate) \ V(InvalidatedSlotsNoInvalidatedRanges) \ V(InvalidatedSlotsResetObjectRegression) \ + V(InvalidatedSlotsRightTrimFixedArray) \ + V(InvalidatedSlotsRightTrimLargeFixedArray) \ + V(InvalidatedSlotsLeftTrimFixedArray) \ + V(InvalidatedSlotsFastToSlow) \ V(InvalidatedSlotsSomeInvalidatedRanges) \ V(TestNewSpaceRefsInCopiedCode) \ V(GCFlags) \ diff --git a/deps/v8/test/cctest/heap/test-alloc.cc b/deps/v8/test/cctest/heap/test-alloc.cc index ee1a27d4e8..5a19f806bc 100644 --- a/deps/v8/test/cctest/heap/test-alloc.cc +++ b/deps/v8/test/cctest/heap/test-alloc.cc @@ -29,7 +29,7 @@ #include "test/cctest/cctest.h" #include "src/accessors.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/objects/api-callbacks.h" #include "src/property.h" diff --git a/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc b/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc index 31aff4f673..cb35a73126 100644 --- a/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc +++ b/deps/v8/test/cctest/heap/test-array-buffer-tracker.cc @@ -2,11 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/heap/array-buffer-tracker.h" +#include "src/heap/heap-inl.h" #include "src/heap/spaces.h" #include "src/isolate.h" #include "src/objects-inl.h" +#include "src/objects/js-array-buffer-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/heap/heap-utils.h" diff --git a/deps/v8/test/cctest/heap/test-embedder-tracing.cc b/deps/v8/test/cctest/heap/test-embedder-tracing.cc index 47f48c0c7a..d54ffcf377 100644 --- a/deps/v8/test/cctest/heap/test-embedder-tracing.cc +++ b/deps/v8/test/cctest/heap/test-embedder-tracing.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "include/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/objects/module.h" #include "src/objects/script.h" @@ -61,7 +61,7 @@ class TestEmbedderHeapTracer final : public v8::EmbedderHeapTracer { void TracePrologue() final {} void TraceEpilogue() final {} void AbortTracing() final {} - void EnterFinalPause() final {} + void EnterFinalPause(EmbedderStackState) final {} bool IsRegisteredFromV8(void* first_field) const { for (auto pair : registered_from_v8_) { @@ -251,6 +251,20 @@ TEST(FinalizeTracingWhenMarking) { CHECK(marking->IsStopped()); } +TEST(GarbageCollectionForTesting) { + ManualGCScope manual_gc; + i::FLAG_expose_gc = true; + CcTest::InitializeVM(); + v8::Isolate* isolate = CcTest::isolate(); + Isolate* i_isolate = CcTest::i_isolate(); + TestEmbedderHeapTracer tracer(isolate); + TemporaryEmbedderHeapTracerScope tracer_scope(isolate, &tracer); + + int saved_gc_counter = i_isolate->heap()->gc_count(); + tracer.GarbageCollectionForTesting(EmbedderHeapTracer::kUnknown); + CHECK_GT(i_isolate->heap()->gc_count(), saved_gc_counter); +} + } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/heap/test-external-string-tracker.cc b/deps/v8/test/cctest/heap/test-external-string-tracker.cc new file mode 100644 index 0000000000..501825a296 --- /dev/null +++ b/deps/v8/test/cctest/heap/test-external-string-tracker.cc @@ -0,0 +1,226 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/api-inl.h" +#include "src/api.h" +#include "src/heap/spaces.h" +#include "src/isolate.h" +#include "src/objects-inl.h" +#include "test/cctest/cctest.h" +#include "test/cctest/heap/heap-tester.h" +#include "test/cctest/heap/heap-utils.h" + +#define TEST_STR "tests are great!" + +namespace v8 { +namespace internal { +namespace heap { + +// Adapted from cctest/test-api.cc +class TestOneByteResource : public v8::String::ExternalOneByteStringResource { + public: + explicit TestOneByteResource(const char* data, int* counter = nullptr, + size_t offset = 0) + : orig_data_(data), + data_(data + offset), + length_(strlen(data) - offset), + counter_(counter) {} + + ~TestOneByteResource() { + i::DeleteArray(orig_data_); + if (counter_ != nullptr) ++*counter_; + } + + const char* data() const { return data_; } + + size_t length() const { return length_; } + + private: + const char* orig_data_; + const char* data_; + size_t length_; + int* counter_; +}; + +TEST(ExternalString_ExternalBackingStoreSizeIncreases) { + CcTest::InitializeVM(); + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap(); + ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString; + + const size_t backing_store_before = + heap->old_space()->ExternalBackingStoreBytes(type); + + { + v8::HandleScope handle_scope(isolate); + v8::Local<v8::String> es = v8::String::NewExternalOneByte( + isolate, new TestOneByteResource(i::StrDup(TEST_STR))).ToLocalChecked(); + USE(es); + + const size_t backing_store_after = + heap->old_space()->ExternalBackingStoreBytes(type); + + CHECK_EQ(es->Length(), backing_store_after - backing_store_before); + } +} + +TEST(ExternalString_ExternalBackingStoreSizeDecreases) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap(); + ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString; + + const size_t backing_store_before = + heap->old_space()->ExternalBackingStoreBytes(type); + + { + v8::HandleScope handle_scope(isolate); + v8::Local<v8::String> es = v8::String::NewExternalOneByte( + isolate, new TestOneByteResource(i::StrDup(TEST_STR))).ToLocalChecked(); + USE(es); + } + + heap::GcAndSweep(heap, OLD_SPACE); + + const size_t backing_store_after = + heap->old_space()->ExternalBackingStoreBytes(type); + + CHECK_EQ(0, backing_store_after - backing_store_before); +} + +TEST(ExternalString_ExternalBackingStoreSizeIncreasesMarkCompact) { + if (FLAG_never_compact) return; + ManualGCScope manual_gc_scope; + FLAG_manual_evacuation_candidates_selection = true; + CcTest::InitializeVM(); + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap(); + heap::AbandonCurrentlyFreeMemory(heap->old_space()); + ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString; + + const size_t backing_store_before = + heap->old_space()->ExternalBackingStoreBytes(type); + + { + v8::HandleScope handle_scope(isolate); + v8::Local<v8::String> es = v8::String::NewExternalOneByte( + isolate, new TestOneByteResource(i::StrDup(TEST_STR))).ToLocalChecked(); + v8::internal::Handle<v8::internal::String> esh = v8::Utils::OpenHandle(*es); + + Page* page_before_gc = Page::FromAddress(esh->address()); + heap::ForceEvacuationCandidate(page_before_gc); + + CcTest::CollectAllGarbage(); + + const size_t backing_store_after = + heap->old_space()->ExternalBackingStoreBytes(type); + CHECK_EQ(es->Length(), backing_store_after - backing_store_before); + } + + heap::GcAndSweep(heap, OLD_SPACE); + const size_t backing_store_after = + heap->old_space()->ExternalBackingStoreBytes(type); + CHECK_EQ(0, backing_store_after - backing_store_before); +} + +TEST(ExternalString_ExternalBackingStoreSizeIncreasesAfterExternalization) { + CcTest::InitializeVM(); + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + Heap* heap = reinterpret_cast<Isolate*>(isolate)->heap(); + ExternalBackingStoreType type = ExternalBackingStoreType::kExternalString; + size_t old_backing_store_before = 0, new_backing_store_before = 0; + + { + v8::HandleScope handle_scope(isolate); + + new_backing_store_before = + heap->new_space()->ExternalBackingStoreBytes(type); + old_backing_store_before = + heap->old_space()->ExternalBackingStoreBytes(type); + + // Allocate normal string in the new gen. + v8::Local<v8::String> str = + v8::String::NewFromUtf8(isolate, TEST_STR, v8::NewStringType::kNormal) + .ToLocalChecked(); + + CHECK_EQ(0, heap->new_space()->ExternalBackingStoreBytes(type) - + new_backing_store_before); + + // Trigger GCs so that the newly allocated string moves to old gen. + heap::GcAndSweep(heap, NEW_SPACE); // in survivor space now + heap::GcAndSweep(heap, NEW_SPACE); // in old gen now + + bool success = + str->MakeExternal(new TestOneByteResource(i::StrDup(TEST_STR))); + CHECK(success); + + CHECK_EQ(str->Length(), heap->old_space()->ExternalBackingStoreBytes(type) - + old_backing_store_before); + } + + heap::GcAndSweep(heap, OLD_SPACE); + + CHECK_EQ(0, heap->old_space()->ExternalBackingStoreBytes(type) - + old_backing_store_before); +} + +TEST(ExternalString_PromotedThinString) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = CcTest::i_isolate(); + i::Factory* factory = i_isolate->factory(); + Heap* heap = i_isolate->heap(); + + { + v8::HandleScope handle_scope(isolate); + + // New external string in the old space. + v8::internal::Handle<v8::internal::String> string1 = + factory + ->NewExternalStringFromOneByte( + new TestOneByteResource(i::StrDup(TEST_STR))) + .ToHandleChecked(); + + // Internalize external string. + i::Handle<i::String> isymbol1 = factory->InternalizeString(string1); + CHECK(isymbol1->IsInternalizedString()); + CHECK(string1->IsExternalString()); + CHECK(!heap->InNewSpace(*isymbol1)); + + // New external string in the young space. This string has the same content + // as the previous one (that was already internalized). + v8::Local<v8::String> string2 = + v8::String::NewFromUtf8(isolate, TEST_STR, v8::NewStringType::kNormal) + .ToLocalChecked(); + bool success = + string2->MakeExternal(new TestOneByteResource(i::StrDup(TEST_STR))); + CHECK(success); + + // Internalize (it will create a thin string in the new space). + i::Handle<i::String> istring = v8::Utils::OpenHandle(*string2); + i::Handle<i::String> isymbol2 = factory->InternalizeString(istring); + CHECK(isymbol2->IsInternalizedString()); + CHECK(istring->IsThinString()); + CHECK(heap->InNewSpace(*istring)); + + // Collect thin string. References to the thin string will be updated to + // point to the actual external string in the old space. + heap::GcAndSweep(heap, NEW_SPACE); + + USE(isymbol1); + USE(isymbol2); + } +} +} // namespace heap +} // namespace internal +} // namespace v8 + +#undef TEST_STR diff --git a/deps/v8/test/cctest/heap/test-heap.cc b/deps/v8/test/cctest/heap/test-heap.cc index 80b361034d..f73f6f0195 100644 --- a/deps/v8/test/cctest/heap/test-heap.cc +++ b/deps/v8/test/cctest/heap/test-heap.cc @@ -28,7 +28,7 @@ #include <stdlib.h> #include <utility> -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/code-stubs.h" #include "src/compilation-cache.h" @@ -43,9 +43,11 @@ #include "src/heap/incremental-marking.h" #include "src/heap/mark-compact.h" #include "src/heap/memory-reducer.h" +#include "src/heap/remembered-set.h" #include "src/ic/ic.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" +#include "src/objects/js-array-inl.h" #include "src/objects/js-collection-inl.h" #include "src/objects/managed.h" #include "src/regexp/jsregexp.h" @@ -787,7 +789,7 @@ TEST(BytecodeArray) { CHECK_GE(array->address() + array->BytecodeArraySize(), array->GetFirstBytecodeAddress() + array->length()); for (int i = 0; i < kRawBytesSize; i++) { - CHECK_EQ(Memory::uint8_at(array->GetFirstBytecodeAddress() + i), + CHECK_EQ(Memory<uint8_t>(array->GetFirstBytecodeAddress() + i), kRawBytes[i]); CHECK_EQ(array->get(i), kRawBytes[i]); } @@ -805,7 +807,7 @@ TEST(BytecodeArray) { CHECK_EQ(array->frame_size(), kFrameSize); for (int i = 0; i < kRawBytesSize; i++) { CHECK_EQ(array->get(i), kRawBytes[i]); - CHECK_EQ(Memory::uint8_at(array->GetFirstBytecodeAddress() + i), + CHECK_EQ(Memory<uint8_t>(array->GetFirstBytecodeAddress() + i), kRawBytes[i]); } @@ -3628,15 +3630,15 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { int dependency_group_count = 0; DependentCode* dependency = site->dependent_code(); - while (dependency != ReadOnlyRoots(heap).empty_fixed_array()) { + while (dependency != ReadOnlyRoots(heap).empty_weak_fixed_array()) { CHECK(dependency->group() == DependentCode::kAllocationSiteTransitionChangedGroup || dependency->group() == DependentCode::kAllocationSiteTenuringChangedGroup); CHECK_EQ(1, dependency->count()); - CHECK(dependency->object_at(0)->IsWeakCell()); + CHECK(dependency->object_at(0)->IsWeakHeapObject()); Code* function_bar = - Code::cast(WeakCell::cast(dependency->object_at(0))->value()); + Code::cast(dependency->object_at(0)->ToWeakHeapObject()); CHECK_EQ(bar_handle->code(), function_bar); dependency = dependency->next_link(); dependency_group_count++; @@ -3653,8 +3655,7 @@ TEST(EnsureAllocationSiteDependentCodesProcessed) { // The site still exists because of our global handle, but the code is no // longer referred to by dependent_code(). - CHECK(site->dependent_code()->object_at(0)->IsWeakCell() && - WeakCell::cast(site->dependent_code()->object_at(0))->cleared()); + CHECK(site->dependent_code()->object_at(0)->IsClearedWeakHeapObject()); } void CheckNumberOfAllocations(Heap* heap, const char* source, @@ -3678,20 +3679,51 @@ TEST(AllocationSiteCreation) { Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); + i::FLAG_enable_one_shot_optimization = true; // Array literals. - CheckNumberOfAllocations(heap, "(function f1() { return []; })()", 1, 0); - CheckNumberOfAllocations(heap, "(function f2() { return [1, 2]; })()", 1, 0); - CheckNumberOfAllocations(heap, "(function f3() { return [[1], [2]]; })()", 1, - 2); + CheckNumberOfAllocations(heap, "function f1() { return []; }; f1()", 1, 0); + CheckNumberOfAllocations(heap, "function f2() { return [1, 2]; }; f2()", 1, + 0); + CheckNumberOfAllocations(heap, "function f3() { return [[1], [2]]; }; f3()", + 1, 2); CheckNumberOfAllocations(heap, - "(function f4() { " + "function f4() { " "return [0, [1, 1.1, 1.2, " "], 1.5, [2.1, 2.2], 3];" - "})()", + "}; f4();", 1, 2); + // No allocation sites within IIFE/top-level + CheckNumberOfAllocations(heap, + R"( + (function f4() { + return [ 0, [ 1, 1.1, 1.2,], 1.5, [2.1, 2.2], 3 ]; + })(); + )", + 0, 0); + + CheckNumberOfAllocations(heap, + R"( + l = [ 1, 2, 3, 4]; + )", + 0, 0); + + CheckNumberOfAllocations(heap, + R"( + a = []; + )", + 0, 0); + + CheckNumberOfAllocations(heap, + R"( + (function f4() { + return []; + })(); + )", + 0, 0); + // Object literals have lazy AllocationSites CheckNumberOfAllocations(heap, "function f5() { return {}; }; f5(); ", 0, 0); @@ -3727,6 +3759,52 @@ TEST(AllocationSiteCreation) { // No new AllocationSites created on the second invocation. CheckNumberOfAllocations(heap, "f9(); ", 0, 0); + + // No allocation sites for literals in an iife/top level code even if it has + // array subliterals + CheckNumberOfAllocations(heap, + R"( + (function f10() { + return {a: [1], b: [2]}; + })(); + )", + 0, 0); + + CheckNumberOfAllocations(heap, + R"( + l = { + a: 1, + b: { + c: [5], + } + }; + )", + 0, 0); + + // Eagerly create allocation sites for literals within a loop of iife or + // top-level code + CheckNumberOfAllocations(heap, + R"( + (function f11() { + while(true) { + return {a: [1], b: [2]}; + } + })(); + )", + 1, 2); + + CheckNumberOfAllocations(heap, + R"( + for (i = 0; i < 1; ++i) { + l = { + a: 1, + b: { + c: [5], + } + }; + } + )", + 1, 1); } TEST(CellsInOptimizedCodeAreWeak) { @@ -4330,82 +4408,6 @@ TEST(PolymorphicStaysPolymorphicAfterGC) { CheckIC(loadIC, 0, POLYMORPHIC); } - -TEST(WeakCell) { - ManualGCScope manual_gc_scope; - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - v8::internal::Factory* factory = isolate->factory(); - - HandleScope outer_scope(isolate); - Handle<WeakCell> weak_cell1; - { - HandleScope inner_scope(isolate); - Handle<HeapObject> value = factory->NewFixedArray(1, NOT_TENURED); - weak_cell1 = inner_scope.CloseAndEscape(factory->NewWeakCell(value)); - } - - Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); - Handle<WeakCell> weak_cell2; - { - HandleScope inner_scope(isolate); - weak_cell2 = inner_scope.CloseAndEscape(factory->NewWeakCell(survivor)); - } - CHECK(weak_cell1->value()->IsFixedArray()); - CHECK_EQ(*survivor, weak_cell2->value()); - CcTest::CollectGarbage(NEW_SPACE); - CHECK(weak_cell1->value()->IsFixedArray()); - CHECK_EQ(*survivor, weak_cell2->value()); - CcTest::CollectGarbage(NEW_SPACE); - CHECK(weak_cell1->value()->IsFixedArray()); - CHECK_EQ(*survivor, weak_cell2->value()); - CcTest::CollectAllAvailableGarbage(); - CHECK(weak_cell1->cleared()); - CHECK_EQ(*survivor, weak_cell2->value()); -} - - -TEST(WeakCellsWithIncrementalMarking) { - if (!FLAG_incremental_marking) return; - ManualGCScope manual_gc_scope; - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - v8::internal::Heap* heap = CcTest::heap(); - v8::internal::Factory* factory = isolate->factory(); - - const int N = 16; - HandleScope outer_scope(isolate); - Handle<FixedArray> survivor = factory->NewFixedArray(1, NOT_TENURED); - Handle<WeakCell> weak_cells[N]; - - for (int i = 0; i < N; i++) { - HandleScope inner_scope(isolate); - Handle<HeapObject> value = - i == 0 ? survivor : factory->NewFixedArray(1, NOT_TENURED); - Handle<WeakCell> weak_cell = factory->NewWeakCell(value); - CHECK(weak_cell->value()->IsFixedArray()); - IncrementalMarking* marking = heap->incremental_marking(); - if (marking->IsStopped()) { - heap->StartIncrementalMarking(i::Heap::kNoGCFlags, - i::GarbageCollectionReason::kTesting); - } - marking->Step(128, IncrementalMarking::NO_GC_VIA_STACK_GUARD, - StepOrigin::kV8); - CcTest::CollectGarbage(NEW_SPACE); - CHECK(weak_cell->value()->IsFixedArray()); - weak_cells[i] = inner_scope.CloseAndEscape(weak_cell); - } - // Call collect all twice to make sure that we also cleared - // weak cells that were allocated on black pages. - CcTest::CollectAllGarbage(); - CcTest::CollectAllGarbage(); - CHECK_EQ(*survivor, weak_cells[0]->value()); - for (int i = 1; i < N; i++) { - CHECK(weak_cells[i]->cleared()); - } -} - - #ifdef DEBUG TEST(AddInstructionChangesNewSpacePromotion) { FLAG_allow_natives_syntax = true; @@ -4462,7 +4464,7 @@ TEST(CEntryStubOOM) { CcTest::isolate()->SetFatalErrorHandler(OnFatalErrorExpectOOM); v8::Local<v8::Value> result = CompileRun( - "%SetFlags('--gc-interval=1');" + "%SetAllocationTimeout(1, 1);" "var a = [];" "a.__proto__ = [];" "a.unshift(1)"); @@ -4694,15 +4696,15 @@ TEST(Regress3877) { Factory* factory = isolate->factory(); HandleScope scope(isolate); CompileRun("function cls() { this.x = 10; }"); - Handle<WeakCell> weak_prototype; + Handle<WeakFixedArray> weak_prototype_holder = factory->NewWeakFixedArray(1); { HandleScope inner_scope(isolate); v8::Local<v8::Value> result = CompileRun("cls.prototype"); Handle<JSReceiver> proto = v8::Utils::OpenHandle(*v8::Local<v8::Object>::Cast(result)); - weak_prototype = inner_scope.CloseAndEscape(factory->NewWeakCell(proto)); + weak_prototype_holder->Set(0, HeapObjectReference::Weak(*proto)); } - CHECK(!weak_prototype->cleared()); + CHECK(!weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); CompileRun( "var a = { };" "a.x = new cls();" @@ -4711,13 +4713,13 @@ TEST(Regress3877) { CcTest::CollectAllGarbage(); } // The map of a.x keeps prototype alive - CHECK(!weak_prototype->cleared()); + CHECK(!weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); // Change the map of a.x and make the previous map garbage collectable. CompileRun("a.x.__proto__ = {};"); for (int i = 0; i < 4; i++) { CcTest::CollectAllGarbage(); } - CHECK(weak_prototype->cleared()); + CHECK(weak_prototype_holder->Get(0)->IsClearedWeakHeapObject()); } Handle<WeakFixedArray> AddRetainedMap(Isolate* isolate, Heap* heap) { @@ -4773,20 +4775,6 @@ TEST(WritableVsImmortalRoots) { } } -TEST(FixedArrayOfWeakCells) { - CcTest::InitializeVM(); - v8::HandleScope scope(CcTest::isolate()); - Isolate* isolate = CcTest::i_isolate(); - - Handle<HeapNumber> number = isolate->factory()->NewHeapNumber(1); - Handle<FixedArrayOfWeakCells> array = - FixedArrayOfWeakCells::Add(isolate, Handle<Object>(), number); - array->Remove(number); - array->Compact<FixedArrayOfWeakCells::NullCallback>(isolate); - FixedArrayOfWeakCells::Add(isolate, array, number); -} - - TEST(PreprocessStackTrace) { // Do not automatically trigger early GC. FLAG_gc_interval = -1; @@ -5493,7 +5481,8 @@ TEST(Regress631969) { s3->MakeExternal(&external_string); CcTest::CollectGarbage(OLD_SPACE); // This avoids the GC from trying to free stack allocated resources. - i::Handle<i::ExternalOneByteString>::cast(s3)->set_resource(nullptr); + i::Handle<i::ExternalOneByteString>::cast(s3)->SetResource(isolate, + nullptr); } } @@ -5673,7 +5662,7 @@ TEST(Regress618958) { v8::HandleScope scope(CcTest::isolate()); Heap* heap = CcTest::heap(); bool isolate_is_locked = true; - heap->update_external_memory(100 * MB); + CcTest::isolate()->AdjustAmountOfExternalAllocatedMemory(100 * MB); int mark_sweep_count_before = heap->ms_count(); heap->MemoryPressureNotification(MemoryPressureLevel::kCritical, isolate_is_locked); diff --git a/deps/v8/test/cctest/heap/test-invalidated-slots.cc b/deps/v8/test/cctest/heap/test-invalidated-slots.cc index f18878d511..9162573dd9 100644 --- a/deps/v8/test/cctest/heap/test-invalidated-slots.cc +++ b/deps/v8/test/cctest/heap/test-invalidated-slots.cc @@ -109,6 +109,7 @@ HEAP_TEST(InvalidatedSlotsAllInvalidatedRanges) { } HEAP_TEST(InvalidatedSlotsAfterTrimming) { + ManualGCScope manual_gc_scope; CcTest::InitializeVM(); Heap* heap = CcTest::heap(); std::vector<ByteArray*> byte_arrays; @@ -119,9 +120,7 @@ HEAP_TEST(InvalidatedSlotsAfterTrimming) { byte_arrays[i]->Size()); } // Trim byte arrays and check that the slots outside the byte arrays are - // considered valid. Free space outside invalidated object can be reused - // during evacuation for allocation of the evacuated objects. That can - // add new valid slots to evacuation candidates. + // considered invalid if the old space page was swept. InvalidatedSlotsFilter filter(page); for (size_t i = 0; i < byte_arrays.size(); i++) { ByteArray* byte_array = byte_arrays[i]; @@ -129,7 +128,7 @@ HEAP_TEST(InvalidatedSlotsAfterTrimming) { Address end = byte_array->address() + byte_array->Size(); heap->RightTrimFixedArray(byte_array, byte_array->length()); for (Address addr = start; addr < end; addr += kPointerSize) { - CHECK(filter.IsValid(addr)); + CHECK_EQ(filter.IsValid(addr), page->SweepingDone()); } } } @@ -184,6 +183,185 @@ HEAP_TEST(InvalidatedSlotsResetObjectRegression) { } } +Handle<FixedArray> AllocateArrayOnFreshPage(Isolate* isolate, + PagedSpace* old_space, int length) { + AlwaysAllocateScope always_allocate(isolate); + heap::SimulateFullSpace(old_space); + return isolate->factory()->NewFixedArray(length, TENURED); +} + +Handle<FixedArray> AllocateArrayOnEvacuationCandidate(Isolate* isolate, + PagedSpace* old_space, + int length) { + Handle<FixedArray> object = + AllocateArrayOnFreshPage(isolate, old_space, length); + heap::ForceEvacuationCandidate(Page::FromHeapObject(*object)); + return object; +} + +HEAP_TEST(InvalidatedSlotsRightTrimFixedArray) { + FLAG_manual_evacuation_candidates_selection = true; + FLAG_parallel_compaction = false; + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Heap* heap = CcTest::heap(); + HandleScope scope(isolate); + PagedSpace* old_space = heap->old_space(); + // Allocate a dummy page to be swept be the sweeper during evacuation. + AllocateArrayOnFreshPage(isolate, old_space, 1); + Handle<FixedArray> evacuated = + AllocateArrayOnEvacuationCandidate(isolate, old_space, 1); + Handle<FixedArray> trimmed = AllocateArrayOnFreshPage(isolate, old_space, 10); + heap::SimulateIncrementalMarking(heap); + for (int i = 1; i < trimmed->length(); i++) { + trimmed->set(i, *evacuated); + } + { + HandleScope scope(isolate); + Handle<HeapObject> dead = factory->NewFixedArray(1); + for (int i = 1; i < trimmed->length(); i++) { + trimmed->set(i, *dead); + } + heap->RightTrimFixedArray(*trimmed, trimmed->length() - 1); + } + CcTest::CollectGarbage(i::NEW_SPACE); + CcTest::CollectGarbage(i::OLD_SPACE); +} + +HEAP_TEST(InvalidatedSlotsRightTrimLargeFixedArray) { + FLAG_manual_evacuation_candidates_selection = true; + FLAG_parallel_compaction = false; + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Heap* heap = CcTest::heap(); + HandleScope scope(isolate); + PagedSpace* old_space = heap->old_space(); + // Allocate a dummy page to be swept be the sweeper during evacuation. + AllocateArrayOnFreshPage(isolate, old_space, 1); + Handle<FixedArray> evacuated = + AllocateArrayOnEvacuationCandidate(isolate, old_space, 1); + Handle<FixedArray> trimmed; + { + AlwaysAllocateScope always_allocate(isolate); + trimmed = + factory->NewFixedArray(kMaxRegularHeapObjectSize / kPointerSize + 100); + DCHECK(MemoryChunk::FromHeapObject(*trimmed)->InLargeObjectSpace()); + } + heap::SimulateIncrementalMarking(heap); + for (int i = 1; i < trimmed->length(); i++) { + trimmed->set(i, *evacuated); + } + { + HandleScope scope(isolate); + Handle<HeapObject> dead = factory->NewFixedArray(1); + for (int i = 1; i < trimmed->length(); i++) { + trimmed->set(i, *dead); + } + heap->RightTrimFixedArray(*trimmed, trimmed->length() - 1); + } + CcTest::CollectGarbage(i::NEW_SPACE); + CcTest::CollectGarbage(i::OLD_SPACE); +} + +HEAP_TEST(InvalidatedSlotsLeftTrimFixedArray) { + FLAG_manual_evacuation_candidates_selection = true; + FLAG_parallel_compaction = false; + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Heap* heap = CcTest::heap(); + HandleScope scope(isolate); + PagedSpace* old_space = heap->old_space(); + // Allocate a dummy page to be swept be the sweeper during evacuation. + AllocateArrayOnFreshPage(isolate, old_space, 1); + Handle<FixedArray> evacuated = + AllocateArrayOnEvacuationCandidate(isolate, old_space, 1); + Handle<FixedArray> trimmed = AllocateArrayOnFreshPage(isolate, old_space, 10); + heap::SimulateIncrementalMarking(heap); + for (int i = 0; i + 1 < trimmed->length(); i++) { + trimmed->set(i, *evacuated); + } + { + HandleScope scope(isolate); + Handle<HeapObject> dead = factory->NewFixedArray(1); + for (int i = 1; i < trimmed->length(); i++) { + trimmed->set(i, *dead); + } + heap->LeftTrimFixedArray(*trimmed, trimmed->length() - 1); + } + CcTest::CollectGarbage(i::NEW_SPACE); + CcTest::CollectGarbage(i::OLD_SPACE); +} + +HEAP_TEST(InvalidatedSlotsFastToSlow) { + FLAG_manual_evacuation_candidates_selection = true; + FLAG_parallel_compaction = false; + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Heap* heap = CcTest::heap(); + PagedSpace* old_space = heap->old_space(); + + HandleScope scope(isolate); + + Handle<String> name = factory->InternalizeUtf8String("TestObject"); + Handle<String> prop_name1 = factory->InternalizeUtf8String("prop1"); + Handle<String> prop_name2 = factory->InternalizeUtf8String("prop2"); + Handle<String> prop_name3 = factory->InternalizeUtf8String("prop3"); + // Allocate a dummy page to be swept be the sweeper during evacuation. + AllocateArrayOnFreshPage(isolate, old_space, 1); + Handle<FixedArray> evacuated = + AllocateArrayOnEvacuationCandidate(isolate, old_space, 1); + // Allocate a dummy page to ensure that the JSObject is allocated on + // a fresh page. + AllocateArrayOnFreshPage(isolate, old_space, 1); + Handle<JSObject> obj; + { + AlwaysAllocateScope always_allocate(isolate); + Handle<JSFunction> function = factory->NewFunctionForTest(name); + function->shared()->set_expected_nof_properties(3); + obj = factory->NewJSObject(function, TENURED); + } + // Start incremental marking. + heap::SimulateIncrementalMarking(heap); + // Set properties to point to the evacuation candidate. + JSReceiver::SetProperty(isolate, obj, prop_name1, evacuated, + LanguageMode::kSloppy) + .Check(); + JSReceiver::SetProperty(isolate, obj, prop_name2, evacuated, + LanguageMode::kSloppy) + .Check(); + JSReceiver::SetProperty(isolate, obj, prop_name3, evacuated, + LanguageMode::kSloppy) + .Check(); + + { + HandleScope scope(isolate); + Handle<HeapObject> dead = factory->NewFixedArray(1); + JSReceiver::SetProperty(isolate, obj, prop_name1, dead, + LanguageMode::kSloppy) + .Check(); + JSReceiver::SetProperty(isolate, obj, prop_name2, dead, + LanguageMode::kSloppy) + .Check(); + JSReceiver::SetProperty(isolate, obj, prop_name3, dead, + LanguageMode::kSloppy) + .Check(); + Handle<Map> map(obj->map(), isolate); + Handle<Map> normalized_map = + Map::Normalize(isolate, map, CLEAR_INOBJECT_PROPERTIES, "testing"); + JSObject::MigrateToMap(obj, normalized_map); + } + CcTest::CollectGarbage(i::NEW_SPACE); + CcTest::CollectGarbage(i::OLD_SPACE); +} + } // namespace heap } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/heap/test-weak-references.cc b/deps/v8/test/cctest/heap/test-weak-references.cc index 979a28b1cd..a54b13afd2 100644 --- a/deps/v8/test/cctest/heap/test-weak-references.cc +++ b/deps/v8/test/cctest/heap/test-weak-references.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/heap/factory.h" #include "src/isolate.h" @@ -535,6 +535,55 @@ TEST(WeakArrayListBasic) { CHECK_EQ(Smi::ToInt(array->Get(7)->ToSmi()), 7); } +TEST(WeakArrayListRemove) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + Isolate* isolate = CcTest::i_isolate(); + Factory* factory = isolate->factory(); + Heap* heap = isolate->heap(); + HandleScope outer_scope(isolate); + + Handle<WeakArrayList> array(ReadOnlyRoots(heap).empty_weak_array_list(), + isolate); + + Handle<FixedArray> elem0 = factory->NewFixedArray(1); + Handle<FixedArray> elem1 = factory->NewFixedArray(1); + Handle<FixedArray> elem2 = factory->NewFixedArray(1); + + array = + WeakArrayList::AddToEnd(isolate, array, MaybeObjectHandle::Weak(elem0)); + array = + WeakArrayList::AddToEnd(isolate, array, MaybeObjectHandle::Weak(elem1)); + array = + WeakArrayList::AddToEnd(isolate, array, MaybeObjectHandle::Weak(elem2)); + + CHECK_EQ(array->length(), 3); + CHECK_EQ(array->Get(0), HeapObjectReference::Weak(*elem0)); + CHECK_EQ(array->Get(1), HeapObjectReference::Weak(*elem1)); + CHECK_EQ(array->Get(2), HeapObjectReference::Weak(*elem2)); + + CHECK(array->RemoveOne(MaybeObjectHandle::Weak(elem1))); + + CHECK_EQ(array->length(), 2); + CHECK_EQ(array->Get(0), HeapObjectReference::Weak(*elem0)); + CHECK_EQ(array->Get(1), HeapObjectReference::Weak(*elem2)); + + CHECK(!array->RemoveOne(MaybeObjectHandle::Weak(elem1))); + + CHECK_EQ(array->length(), 2); + CHECK_EQ(array->Get(0), HeapObjectReference::Weak(*elem0)); + CHECK_EQ(array->Get(1), HeapObjectReference::Weak(*elem2)); + + CHECK(array->RemoveOne(MaybeObjectHandle::Weak(elem0))); + + CHECK_EQ(array->length(), 1); + CHECK_EQ(array->Get(0), HeapObjectReference::Weak(*elem2)); + + CHECK(array->RemoveOne(MaybeObjectHandle::Weak(elem2))); + + CHECK_EQ(array->length(), 0); +} + TEST(Regress7768) { i::FLAG_allow_natives_syntax = true; i::FLAG_turbo_inlining = false; diff --git a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc index 0998b3dfd9..a048e82e62 100644 --- a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc +++ b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.cc @@ -10,7 +10,7 @@ #include "include/libplatform/libplatform.h" #include "include/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/logging.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-generator.h" @@ -21,6 +21,7 @@ #include "src/objects/module-inl.h" #include "src/runtime/runtime.h" #include "src/source-position-table.h" +#include "test/cctest/cctest.h" namespace v8 { namespace internal { @@ -116,6 +117,17 @@ BytecodeExpectationsPrinter::GetBytecodeArrayForScript( return i::handle(js_function->shared()->GetBytecodeArray(), i_isolate()); } +i::Handle<i::BytecodeArray> +BytecodeExpectationsPrinter::GetBytecodeArrayOfCallee( + const char* source_code) const { + i::Handle<i::Object> i_object = + v8::Utils::OpenHandle(*CompileRun(source_code)); + i::Handle<i::JSFunction> js_function = + i::Handle<i::JSFunction>::cast(i_object); + CHECK(js_function->shared()->HasBytecodeArray()); + return i::handle(js_function->shared()->GetBytecodeArray(), i_isolate()); +} + void BytecodeExpectationsPrinter::PrintEscapedString( std::ostream& stream, const std::string& string) const { for (char c : string) { @@ -372,11 +384,15 @@ void BytecodeExpectationsPrinter::PrintExpectation( wrap_ ? WrapCodeInFunction(test_function_name_.c_str(), snippet) : snippet; + i::FLAG_enable_one_shot_optimization = oneshot_opt_; + i::FLAG_compilation_cache = false; i::Handle<i::BytecodeArray> bytecode_array; if (module_) { CHECK(top_level_ && !wrap_); v8::Local<v8::Module> module = CompileModule(source_code.c_str()); bytecode_array = GetBytecodeArrayForModule(module); + } else if (print_callee_) { + bytecode_array = GetBytecodeArrayOfCallee(source_code.c_str()); } else { v8::Local<v8::Script> script = CompileScript(source_code.c_str()); if (top_level_) { diff --git a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.h b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.h index be5b143b5d..1d1bc437d0 100644 --- a/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.h +++ b/deps/v8/test/cctest/interpreter/bytecode-expectations-printer.h @@ -32,6 +32,8 @@ class BytecodeExpectationsPrinter final { module_(false), wrap_(true), top_level_(false), + print_callee_(false), + oneshot_opt_(false), test_function_name_(kDefaultTopFunctionName) {} void PrintExpectation(std::ostream& stream, // NOLINT @@ -46,6 +48,12 @@ class BytecodeExpectationsPrinter final { void set_top_level(bool top_level) { top_level_ = top_level; } bool top_level() const { return top_level_; } + void set_print_callee(bool print_callee) { print_callee_ = print_callee; } + bool print_callee() { return print_callee_; } + + void set_oneshot_opt(bool oneshot_opt) { oneshot_opt_ = oneshot_opt; } + bool oneshot_opt() { return oneshot_opt_; } + void set_test_function_name(const std::string& test_function_name) { test_function_name_ = test_function_name; } @@ -94,6 +102,8 @@ class BytecodeExpectationsPrinter final { v8::Local<v8::Module> module) const; i::Handle<v8::internal::BytecodeArray> GetBytecodeArrayForScript( v8::Local<v8::Script> script) const; + i::Handle<i::BytecodeArray> GetBytecodeArrayOfCallee( + const char* source_code) const; i::Isolate* i_isolate() const { return reinterpret_cast<i::Isolate*>(isolate_); @@ -103,6 +113,8 @@ class BytecodeExpectationsPrinter final { bool module_; bool wrap_; bool top_level_; + bool print_callee_; + bool oneshot_opt_; std::string test_function_name_; static const char* const kDefaultTopFunctionName; diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden index 9714926254..ae8d050914 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ArrayLiterals.golden @@ -117,3 +117,164 @@ constant pool: [ handlers: [ ] +--- +snippet: " + var a = [ 1, 2 ]; return [ ...a ]; +" +frame size: 8 +parameter count: 1 +bytecode array length: 86 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), + B(Star), R(0), + /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), + B(Star), R(1), + B(LdaConstant), U8(2), + /* 64 S> */ B(Star), R(2), + B(LdaNamedProperty), R(0), U8(3), U8(7), + B(Star), R(7), + B(CallProperty0), R(7), R(0), U8(9), + B(Mov), R(0), R(6), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), + B(Star), R(5), + B(LdaNamedProperty), R(5), U8(4), U8(11), + B(Star), R(4), + B(CallProperty0), R(4), R(5), U8(13), + B(Star), R(3), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), + B(LdaNamedProperty), R(3), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(21), + B(LdaNamedProperty), R(3), U8(6), U8(17), + B(Star), R(3), + B(StaInArrayLiteral), R(1), R(2), U8(2), + B(Ldar), R(2), + B(Inc), U8(4), + B(Star), R(2), + B(JumpLoop), U8(35), I8(0), + B(Ldar), R(1), + /* 68 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + Smi [0], + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], +] +handlers: [ +] + +--- +snippet: " + var a = [ 1, 2 ]; return [ 0, ...a ]; +" +frame size: 8 +parameter count: 1 +bytecode array length: 86 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), + B(Star), R(0), + /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), + B(Star), R(1), + B(LdaConstant), U8(2), + /* 67 S> */ B(Star), R(2), + B(LdaNamedProperty), R(0), U8(3), U8(7), + B(Star), R(7), + B(CallProperty0), R(7), R(0), U8(9), + B(Mov), R(0), R(6), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), + B(Star), R(5), + B(LdaNamedProperty), R(5), U8(4), U8(11), + B(Star), R(4), + B(CallProperty0), R(4), R(5), U8(13), + B(Star), R(3), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), + B(LdaNamedProperty), R(3), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(21), + B(LdaNamedProperty), R(3), U8(6), U8(17), + B(Star), R(3), + B(StaInArrayLiteral), R(1), R(2), U8(2), + B(Ldar), R(2), + B(Inc), U8(4), + B(Star), R(2), + B(JumpLoop), U8(35), I8(0), + B(Ldar), R(1), + /* 71 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + Smi [1], + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], +] +handlers: [ +] + +--- +snippet: " + var a = [ 1, 2 ]; return [ ...a, 3 ]; +" +frame size: 8 +parameter count: 1 +bytecode array length: 98 +bytecodes: [ + /* 30 E> */ B(StackCheck), + /* 42 S> */ B(CreateArrayLiteral), U8(0), U8(0), U8(37), + B(Star), R(0), + /* 52 S> */ B(CreateArrayLiteral), U8(1), U8(1), U8(37), + B(Star), R(1), + B(LdaConstant), U8(2), + /* 64 S> */ B(Star), R(2), + B(LdaNamedProperty), R(0), U8(3), U8(7), + B(Star), R(7), + B(CallProperty0), R(7), R(0), U8(9), + B(Mov), R(0), R(6), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowSymbolIteratorInvalid), R(0), U8(0), + B(Star), R(5), + B(LdaNamedProperty), R(5), U8(4), U8(11), + B(Star), R(4), + B(CallProperty0), R(4), R(5), U8(13), + B(Star), R(3), + B(JumpIfJSReceiver), U8(7), + B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(3), U8(1), + B(LdaNamedProperty), R(3), U8(5), U8(15), + B(JumpIfToBooleanTrue), U8(21), + B(LdaNamedProperty), R(3), U8(6), U8(17), + B(Star), R(3), + B(StaInArrayLiteral), R(1), R(2), U8(2), + B(Ldar), R(2), + B(Inc), U8(4), + B(Star), R(2), + B(JumpLoop), U8(35), I8(0), + B(LdaSmi), I8(3), + B(StaInArrayLiteral), R(1), R(2), U8(2), + B(Ldar), R(2), + B(Inc), U8(4), + B(Star), R(2), + B(Ldar), R(1), + /* 71 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + Smi [0], + SYMBOL_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["next"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["done"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["value"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden index d7109321c6..f5cbed6a7a 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/AsyncGenerators.golden @@ -362,7 +362,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(18), B(LdaConstant), U8(14), B(Star), R(19), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden index e965d7a689..c5fae1f4f6 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForAwaitOf.golden @@ -123,7 +123,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), @@ -377,7 +377,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), @@ -653,7 +653,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(19), B(LdaConstant), U8(11), B(Star), R(20), @@ -885,7 +885,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(17), B(LdaConstant), U8(9), B(Star), R(18), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden index 5c603964c8..bcb462bc75 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -85,7 +85,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(12), B(LdaConstant), U8(7), B(Star), R(13), @@ -217,7 +217,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(13), B(LdaConstant), U8(7), B(Star), R(14), @@ -361,7 +361,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(12), B(LdaConstant), U8(7), B(Star), R(13), @@ -495,7 +495,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(11), B(LdaConstant), U8(9), B(Star), R(12), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden index 90fcb9065d..d4fe1a091c 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/ForOfLoop.golden @@ -89,7 +89,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(14), B(LdaConstant), U8(6), B(Star), R(15), @@ -256,7 +256,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(14), B(LdaConstant), U8(11), B(Star), R(15), @@ -401,7 +401,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(12), B(LdaConstant), U8(8), B(Star), R(13), @@ -495,7 +495,7 @@ bytecodes: [ B(JumpIfUndefined), U8(6), B(Ldar), R(6), B(JumpIfNotNull), U8(16), - B(LdaSmi), I8(78), + B(LdaSmi), I8(81), B(Star), R(18), B(LdaConstant), U8(4), B(Star), R(19), @@ -550,7 +550,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(17), B(LdaConstant), U8(8), B(Star), R(18), @@ -697,7 +697,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(15), B(LdaConstant), U8(9), B(Star), R(16), @@ -859,7 +859,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(14), B(LdaConstant), U8(12), B(Star), R(15), @@ -1007,7 +1007,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(20), B(LdaConstant), U8(6), B(Star), R(21), @@ -1218,7 +1218,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(19), B(LdaConstant), U8(7), B(Star), R(20), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden index 54deec7198..641a2b2eb0 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -203,7 +203,7 @@ bytecodes: [ B(TestTypeOf), U8(6), B(JumpIfFalse), U8(4), B(Jump), U8(18), - B(Wide), B(LdaSmi), I16(149), + B(Wide), B(LdaSmi), I16(153), B(Star), R(14), B(LdaConstant), U8(13), B(Star), R(15), diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden new file mode 100644 index 0000000000..f2653a6ed1 --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithOneshotOpt.golden @@ -0,0 +1,408 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +top level: yes +print callee: yes +oneshot opt: yes + +--- +snippet: " + + (function() { + l = {}; + l.aa = 2; + l.bb = l.aa; + return arguments.callee; + })(); + +" +frame size: 6 +parameter count: 1 +bytecode array length: 82 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateEmptyObjectLiteral), + /* 31 E> */ B(StaGlobal), U8(0), U8(0), + /* 45 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(2), + B(Star), R(4), + B(LdaConstant), U8(1), + B(Star), R(3), + B(LdaZero), + B(Star), R(5), + B(Mov), R(1), R(2), + /* 50 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 63 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + /* 70 E> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(2), + B(LdaConstant), U8(1), + B(Star), R(4), + B(Mov), R(2), R(3), + /* 72 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + B(Star), R(4), + B(LdaConstant), U8(2), + B(Star), R(3), + B(LdaZero), + B(Star), R(5), + B(Mov), R(1), R(2), + /* 68 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 84 S> */ B(LdaConstant), U8(3), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 101 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 108 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + l = {}; + for (i = 0; i < 5; ++i) { + l.aa = 2; + l.bb = l.aa; + } + return arguments.callee; + })(); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 77 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateEmptyObjectLiteral), + /* 31 E> */ B(StaGlobal), U8(0), U8(0), + /* 50 S> */ B(LdaZero), + /* 52 E> */ B(StaGlobal), U8(1), U8(2), + /* 59 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + B(LdaSmi), I8(5), + /* 59 E> */ B(TestLessThan), R(1), U8(6), + B(JumpIfFalse), U8(43), + /* 45 E> */ B(StackCheck), + /* 81 S> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(1), + B(LdaSmi), I8(2), + /* 86 E> */ B(StaNamedProperty), R(1), U8(2), U8(9), + /* 101 S> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(1), + /* 108 E> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(2), + /* 110 E> */ B(LdaNamedProperty), R(2), U8(2), U8(11), + /* 106 E> */ B(StaNamedProperty), R(1), U8(3), U8(13), + /* 66 S> */ B(LdaGlobal), U8(1), U8(4), + B(Inc), U8(15), + /* 66 E> */ B(StaGlobal), U8(1), U8(2), + B(JumpLoop), U8(50), I8(0), + /* 132 S> */ B(LdaConstant), U8(4), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 149 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 156 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["i"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + l = {}; + c = 4; + while(c > 4) { + l.aa = 2; + l.bb = l.aa; + c--; + } + return arguments.callee; + })(); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 78 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateEmptyObjectLiteral), + /* 31 E> */ B(StaGlobal), U8(0), U8(0), + /* 45 S> */ B(LdaSmi), I8(4), + /* 47 E> */ B(StaGlobal), U8(1), U8(2), + /* 68 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + B(LdaSmi), I8(4), + /* 68 E> */ B(TestGreaterThan), R(1), U8(6), + B(JumpIfFalse), U8(43), + /* 60 E> */ B(StackCheck), + /* 85 S> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(1), + B(LdaSmi), I8(2), + /* 90 E> */ B(StaNamedProperty), R(1), U8(2), U8(9), + /* 105 S> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(1), + /* 112 E> */ B(LdaGlobal), U8(0), U8(7), + B(Star), R(2), + /* 114 E> */ B(LdaNamedProperty), R(2), U8(2), U8(11), + /* 110 E> */ B(StaNamedProperty), R(1), U8(3), U8(13), + /* 128 S> */ B(LdaGlobal), U8(1), U8(4), + B(Dec), U8(15), + /* 129 E> */ B(StaGlobal), U8(1), U8(2), + B(JumpLoop), U8(50), I8(0), + /* 151 S> */ B(LdaConstant), U8(4), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 168 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 175 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["c"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + l = {}; + c = 4; + do { + l.aa = 2; + l.bb = l.aa; + c--; + } while(c > 4) + return arguments.callee; + })(); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 78 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateEmptyObjectLiteral), + /* 31 E> */ B(StaGlobal), U8(0), U8(0), + /* 45 S> */ B(LdaSmi), I8(4), + /* 47 E> */ B(StaGlobal), U8(1), U8(2), + /* 60 E> */ B(StackCheck), + /* 75 S> */ B(LdaGlobal), U8(0), U8(4), + B(Star), R(1), + B(LdaSmi), I8(2), + /* 80 E> */ B(StaNamedProperty), R(1), U8(2), U8(6), + /* 95 S> */ B(LdaGlobal), U8(0), U8(4), + B(Star), R(1), + /* 102 E> */ B(LdaGlobal), U8(0), U8(4), + B(Star), R(2), + /* 104 E> */ B(LdaNamedProperty), R(2), U8(2), U8(8), + /* 100 E> */ B(StaNamedProperty), R(1), U8(3), U8(10), + /* 118 S> */ B(LdaGlobal), U8(1), U8(12), + B(Dec), U8(14), + /* 119 E> */ B(StaGlobal), U8(1), U8(2), + /* 141 S> */ B(LdaGlobal), U8(1), U8(12), + B(Star), R(1), + B(LdaSmi), I8(4), + /* 141 E> */ B(TestGreaterThan), R(1), U8(15), + B(JumpIfFalse), U8(5), + B(JumpLoop), U8(50), I8(0), + /* 154 S> */ B(LdaConstant), U8(4), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 171 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 178 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["c"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + l = { + 'aa': 3.3, + 'bb': 4.4 + }; + if (l.aa < 3) { + l.aa = 3; + } else { + l.aa = l.bb; + } + return arguments.callee; + })(); + +" +frame size: 6 +parameter count: 1 +bytecode array length: 121 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 31 E> */ B(StaGlobal), U8(1), U8(0), + /* 95 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaConstant), U8(2), + B(Star), R(3), + B(Mov), R(1), R(2), + /* 101 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 104 E> */ B(TestLessThan), R(1), U8(4), + B(JumpIfFalse), U8(28), + /* 121 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + B(Star), R(4), + B(LdaConstant), U8(2), + B(Star), R(3), + B(LdaZero), + B(Star), R(5), + B(Mov), R(1), R(2), + /* 126 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + B(Jump), U8(40), + /* 158 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + /* 165 E> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(2), + B(LdaConstant), U8(3), + B(Star), R(4), + B(Mov), R(2), R(3), + /* 167 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + B(Star), R(4), + B(LdaConstant), U8(2), + B(Star), R(3), + B(LdaZero), + B(Star), R(5), + B(Mov), R(1), R(2), + /* 163 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 189 S> */ B(LdaConstant), U8(4), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 206 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 213 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + a = [0, [1, 1,2,], 3]; + return arguments.callee; + })(); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 32 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(LdaConstant), U8(0), + B(Star), R(1), + B(LdaSmi), I8(4), + B(Star), R(2), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + /* 31 E> */ B(StaGlobal), U8(1), U8(0), + /* 60 S> */ B(LdaConstant), U8(2), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 77 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 84 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + a = []; + return arguments.callee; + })(); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 32 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(LdaConstant), U8(0), + B(Star), R(1), + B(LdaSmi), I8(37), + B(Star), R(2), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + /* 31 E> */ B(StaGlobal), U8(1), U8(0), + /* 45 S> */ B(LdaConstant), U8(2), + B(Star), R(3), + B(Mov), R(0), R(2), + /* 62 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + /* 69 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden new file mode 100644 index 0000000000..f116bdc68f --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/IIFEWithoutOneshotOpt.golden @@ -0,0 +1,109 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +top level: yes +print callee: yes + +--- +snippet: " + + (function() { + l = {}; + l.a = 2; + l.b = l.a; + return arguments.callee; + })(); + +" +frame size: 3 +parameter count: 1 +bytecode array length: 42 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateEmptyObjectLiteral), + /* 31 E> */ B(StaGlobal), U8(0), U8(0), + /* 45 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + B(LdaSmi), I8(2), + /* 49 E> */ B(StaNamedProperty), R(1), U8(1), U8(4), + /* 62 S> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(1), + /* 68 E> */ B(LdaGlobal), U8(0), U8(2), + B(Star), R(2), + /* 70 E> */ B(LdaNamedProperty), R(2), U8(1), U8(6), + /* 66 E> */ B(StaNamedProperty), R(1), U8(2), U8(8), + /* 98 S> */ B(LdaNamedProperty), R(0), U8(3), U8(10), + /* 105 S> */ B(Return), +] +constant pool: [ + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + +--- +snippet: " + + (function() { + l = { + 'a': 4.3, + 'b': 3.4 + }; + if (l.a < 3) { + l.a = 3; + } else { + l.a = l.b; + } + return arguments.callee; + })(); + +" +frame size: 3 +parameter count: 1 +bytecode array length: 68 +bytecodes: [ + B(CreateMappedArguments), + B(Star), R(0), + /* 16 E> */ B(StackCheck), + /* 29 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1), + B(Ldar), R(1), + /* 31 E> */ B(StaGlobal), U8(1), U8(1), + /* 93 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + /* 99 E> */ B(LdaNamedProperty), R(1), U8(2), U8(5), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 101 E> */ B(TestLessThan), R(1), U8(7), + B(JumpIfFalse), U8(15), + /* 118 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 122 E> */ B(StaNamedProperty), R(1), U8(2), U8(8), + B(Jump), U8(20), + /* 154 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + /* 160 E> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(2), + /* 162 E> */ B(LdaNamedProperty), R(2), U8(3), U8(10), + /* 158 E> */ B(StaNamedProperty), R(1), U8(2), U8(8), + /* 200 S> */ B(LdaNamedProperty), R(0), U8(4), U8(12), + /* 207 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["callee"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden new file mode 100644 index 0000000000..3bc175b7da --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreOneShot.golden @@ -0,0 +1,423 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +top level: yes +oneshot opt: yes + +--- +snippet: " + + l = { + 'a': 1, + 'b': 2 + }; + + v = l['a'] + l['b']; + l['b'] = 7; + l['a'] = l['b']; + +" +frame size: 7 +parameter count: 1 +bytecode array length: 128 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + /* 60 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + B(LdaConstant), U8(2), + B(Star), R(3), + B(Mov), R(1), R(2), + /* 65 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + B(Star), R(1), + /* 73 E> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(2), + B(LdaConstant), U8(3), + B(Star), R(4), + B(Mov), R(2), R(3), + /* 74 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + /* 71 E> */ B(Add), R(1), U8(2), + /* 62 E> */ B(StaGlobal), U8(4), U8(5), + /* 87 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + B(LdaSmi), I8(7), + B(Star), R(4), + B(LdaConstant), U8(3), + B(Star), R(3), + B(LdaZero), + B(Star), R(5), + B(Mov), R(1), R(2), + /* 94 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(2), U8(4), + /* 105 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + /* 114 E> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(2), + B(LdaConstant), U8(3), + B(Star), R(4), + B(Mov), R(2), R(3), + /* 115 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(3), U8(2), + B(Star), R(2), + B(LdaConstant), U8(2), + B(Star), R(4), + B(LdaZero), + B(Star), R(6), + B(Mov), R(1), R(3), + B(Mov), R(2), R(5), + /* 112 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), + B(Mov), R(5), R(0), + B(Ldar), R(0), + /* 128 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["v"], +] +handlers: [ +] + +--- +snippet: " + + l = { + 'a': 1.1, + 'b': 2.2 + }; + for (i = 0; i < 5; ++i) { + l['a'] = l['a'] + l['b']; + l['b'] = l['a'] + l['b']; + } + +" +frame size: 4 +parameter count: 1 +bytecode array length: 120 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + B(LdaUndefined), + B(Star), R(0), + /* 68 S> */ B(LdaZero), + /* 70 E> */ B(StaGlobal), U8(2), U8(2), + /* 77 S> */ B(LdaGlobal), U8(2), U8(4), + B(Star), R(1), + B(LdaSmi), I8(5), + /* 77 E> */ B(TestLessThan), R(1), U8(6), + B(JumpIfFalse), U8(83), + /* 63 E> */ B(StackCheck), + /* 97 S> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(1), + /* 106 E> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(2), + /* 107 E> */ B(LdaNamedProperty), R(2), U8(3), U8(10), + B(Star), R(2), + /* 115 E> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(3), + /* 116 E> */ B(LdaNamedProperty), R(3), U8(4), U8(12), + /* 113 E> */ B(Add), R(2), U8(9), + /* 104 E> */ B(StaNamedProperty), R(1), U8(3), U8(14), + /* 131 S> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(1), + /* 140 E> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(2), + /* 141 E> */ B(LdaNamedProperty), R(2), U8(3), U8(10), + B(Star), R(2), + /* 149 E> */ B(LdaGlobal), U8(1), U8(7), + B(Star), R(3), + /* 150 E> */ B(LdaNamedProperty), R(3), U8(4), U8(12), + /* 147 E> */ B(Add), R(2), U8(16), + B(Star), R(2), + /* 138 E> */ B(StaNamedProperty), R(1), U8(4), U8(17), + B(Mov), R(2), R(0), + /* 84 S> */ B(LdaGlobal), U8(2), U8(4), + B(Inc), U8(19), + /* 84 E> */ B(StaGlobal), U8(2), U8(2), + B(JumpLoop), U8(90), I8(0), + B(Ldar), R(0), + /* 171 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["i"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], +] +handlers: [ +] + +--- +snippet: " + + l = { + 'a': 1.1, + 'b': 2.2 + }; + while (s > 0) { + l['a'] = l['a'] - l['b']; + l['b'] = l['b'] - l['a']; + } + +" +frame size: 4 +parameter count: 1 +bytecode array length: 109 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + B(LdaUndefined), + B(Star), R(0), + /* 72 S> */ B(LdaGlobal), U8(2), U8(2), + B(Star), R(1), + B(LdaZero), + /* 72 E> */ B(TestGreaterThan), R(1), U8(4), + B(JumpIfFalse), U8(77), + /* 63 E> */ B(StackCheck), + /* 87 S> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(1), + /* 97 E> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(2), + /* 98 E> */ B(LdaNamedProperty), R(2), U8(3), U8(8), + B(Star), R(2), + /* 106 E> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(3), + /* 107 E> */ B(LdaNamedProperty), R(3), U8(4), U8(10), + /* 104 E> */ B(Sub), R(2), U8(7), + /* 95 E> */ B(StaNamedProperty), R(1), U8(3), U8(12), + /* 122 S> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(1), + /* 132 E> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(2), + /* 133 E> */ B(LdaNamedProperty), R(2), U8(4), U8(10), + B(Star), R(2), + /* 141 E> */ B(LdaGlobal), U8(1), U8(5), + B(Star), R(3), + /* 142 E> */ B(LdaNamedProperty), R(3), U8(3), U8(8), + /* 139 E> */ B(Sub), R(2), U8(14), + B(Star), R(2), + /* 130 E> */ B(StaNamedProperty), R(1), U8(4), U8(15), + B(Mov), R(2), R(0), + B(Ldar), R(2), + B(JumpLoop), U8(83), I8(0), + B(Ldar), R(0), + /* 163 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["s"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], +] +handlers: [ +] + +--- +snippet: " + + l = { + 'a': 1.1, + 'b': 2.2 + }; + s = 10; + do { + l['a'] = l['b'] - l['a']; + } while (s < 10); + +" +frame size: 4 +parameter count: 1 +bytecode array length: 81 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + /* 63 S> */ B(LdaSmi), I8(10), + /* 65 E> */ B(StaGlobal), U8(2), U8(2), + B(LdaUndefined), + B(Star), R(0), + /* 77 E> */ B(StackCheck), + /* 90 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + /* 99 E> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(2), + /* 100 E> */ B(LdaNamedProperty), R(2), U8(3), U8(7), + B(Star), R(2), + /* 108 E> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(3), + /* 109 E> */ B(LdaNamedProperty), R(3), U8(4), U8(9), + /* 106 E> */ B(Sub), R(2), U8(6), + B(Star), R(2), + /* 97 E> */ B(StaNamedProperty), R(1), U8(4), U8(11), + B(Mov), R(2), R(0), + /* 133 S> */ B(LdaGlobal), U8(2), U8(13), + B(Star), R(1), + B(LdaSmi), I8(10), + /* 133 E> */ B(TestLessThan), R(1), U8(15), + B(JumpIfFalse), U8(5), + B(JumpLoop), U8(50), I8(0), + B(Ldar), R(0), + /* 146 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["s"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], +] +handlers: [ +] + +--- +snippet: " + + l = { + 'c': 1.1, + 'd': 2.2 + }; + if (l['c'] < 3) { + l['c'] = 3; + } else { + l['d'] = 3; + } + +" +frame size: 7 +parameter count: 1 +bytecode array length: 111 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(2), + B(LdaSmi), I8(41), + B(Star), R(3), + B(CallRuntime), U16(Runtime::kCreateObjectLiteralWithoutAllocationSite), R(2), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + /* 63 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaConstant), U8(2), + B(Star), R(3), + B(Mov), R(1), R(2), + /* 68 E> */ B(InvokeIntrinsic), U8(Runtime::k_GetProperty), R(2), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 74 E> */ B(TestLessThan), R(1), U8(4), + B(JumpIfFalse), U8(36), + /* 89 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + B(Star), R(2), + B(LdaConstant), U8(2), + B(Star), R(4), + B(LdaZero), + B(Star), R(6), + B(Mov), R(1), R(3), + B(Mov), R(2), R(5), + /* 96 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), + B(Mov), R(5), R(0), + B(Ldar), R(2), + B(Jump), U8(34), + /* 124 S> */ B(LdaGlobal), U8(1), U8(2), + B(Star), R(1), + B(LdaSmi), I8(3), + B(Star), R(2), + B(LdaConstant), U8(3), + B(Star), R(4), + B(LdaZero), + B(Star), R(6), + B(Mov), R(1), R(3), + B(Mov), R(2), R(5), + /* 131 E> */ B(CallRuntime), U16(Runtime::kSetProperty), R(3), U8(4), + B(Mov), R(5), R(0), + B(Ldar), R(2), + B(Ldar), R(0), + /* 150 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["c"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["d"], +] +handlers: [ +] + +--- +snippet: " + + a = [1.1, [2.2, 4.5]]; + +" +frame size: 3 +parameter count: 1 +bytecode array length: 20 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(1), + B(LdaSmi), I8(4), + B(Star), R(2), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + B(Star), R(0), + /* 36 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["a"], +] +handlers: [ +] + +--- +snippet: " + + b = []; + +" +frame size: 3 +parameter count: 1 +bytecode array length: 20 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(LdaConstant), U8(0), + B(Star), R(1), + B(LdaSmi), I8(37), + B(Star), R(2), + B(CallRuntime), U16(Runtime::kCreateArrayLiteralWithoutAllocationSite), R(1), U8(2), + /* 9 E> */ B(StaGlobal), U8(1), U8(0), + B(Star), R(0), + /* 21 S> */ B(Return), +] +constant pool: [ + ARRAY_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["b"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreWithoutOneShot.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreWithoutOneShot.golden new file mode 100644 index 0000000000..4b249ea15f --- /dev/null +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/PropertyLoadStoreWithoutOneShot.golden @@ -0,0 +1,119 @@ +# +# Autogenerated by generate-bytecode-expectations. +# + +--- +wrap: no +top level: yes + +--- +snippet: " + + l = { + 'aa': 1.1, + 'bb': 2.2 + }; + + v = l['aa'] + l['bb']; + l['bb'] = 7; + l['aa'] = l['bb']; + +" +frame size: 3 +parameter count: 1 +bytecode array length: 74 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1), + B(Ldar), R(1), + /* 9 E> */ B(StaGlobal), U8(1), U8(1), + /* 66 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + /* 71 E> */ B(LdaNamedProperty), R(1), U8(2), U8(6), + B(Star), R(1), + /* 80 E> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(2), + /* 81 E> */ B(LdaNamedProperty), R(2), U8(3), U8(8), + /* 78 E> */ B(Add), R(1), U8(3), + /* 68 E> */ B(StaGlobal), U8(4), U8(10), + /* 95 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + B(LdaSmi), I8(7), + /* 103 E> */ B(StaNamedProperty), R(1), U8(3), U8(12), + /* 114 S> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(1), + /* 124 E> */ B(LdaGlobal), U8(1), U8(4), + B(Star), R(2), + /* 125 E> */ B(LdaNamedProperty), R(2), U8(3), U8(8), + B(Star), R(2), + /* 122 E> */ B(StaNamedProperty), R(1), U8(2), U8(14), + B(Mov), R(2), R(0), + B(Ldar), R(0), + /* 139 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["aa"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["bb"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["v"], +] +handlers: [ +] + +--- +snippet: " + + l = { + 'cc': 3.1, + 'dd': 4.2 + }; + if (l['cc'] < 3) { + l['cc'] = 3; + } else { + l['dd'] = 3; + } + +" +frame size: 3 +parameter count: 1 +bytecode array length: 70 +bytecodes: [ + /* 0 E> */ B(StackCheck), + /* 7 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(41), R(1), + B(Ldar), R(1), + /* 9 E> */ B(StaGlobal), U8(1), U8(1), + /* 65 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + /* 70 E> */ B(LdaNamedProperty), R(1), U8(2), U8(5), + B(Star), R(1), + B(LdaSmi), I8(3), + /* 77 E> */ B(TestLessThan), R(1), U8(7), + B(JumpIfFalse), U8(22), + /* 92 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + B(LdaSmi), I8(3), + B(Star), R(2), + /* 100 E> */ B(StaNamedProperty), R(1), U8(2), U8(8), + B(Mov), R(2), R(0), + B(Ldar), R(2), + B(Jump), U8(20), + /* 128 S> */ B(LdaGlobal), U8(1), U8(3), + B(Star), R(1), + B(LdaSmi), I8(3), + B(Star), R(2), + /* 136 E> */ B(StaNamedProperty), R(1), U8(3), U8(10), + B(Mov), R(2), R(0), + B(Ldar), R(2), + B(Ldar), R(0), + /* 155 S> */ B(Return), +] +constant pool: [ + OBJECT_BOILERPLATE_DESCRIPTION_TYPE, + ONE_BYTE_INTERNALIZED_STRING_TYPE ["l"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["cc"], + ONE_BYTE_INTERNALIZED_STRING_TYPE ["dd"], +] +handlers: [ +] + diff --git a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden index e87ceaf0de..d870c4362f 100644 --- a/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden +++ b/deps/v8/test/cctest/interpreter/bytecode_expectations/StandardForLoop.golden @@ -229,7 +229,7 @@ bytecodes: [ B(JumpIfUndefined), U8(6), B(Ldar), R(3), B(JumpIfNotNull), U8(16), - B(LdaSmi), I8(78), + B(LdaSmi), I8(81), B(Star), R(4), B(LdaConstant), U8(1), B(Star), R(5), diff --git a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc index 4dad7d48ce..ef0f616528 100644 --- a/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc +++ b/deps/v8/test/cctest/interpreter/generate-bytecode-expectations.cc @@ -42,6 +42,8 @@ class ProgramOptions final { wrap_(true), module_(false), top_level_(false), + print_callee_(false), + oneshot_opt_(false), do_expressions_(false), async_iteration_(false), public_fields_(false), @@ -64,6 +66,8 @@ class ProgramOptions final { bool wrap() const { return wrap_; } bool module() const { return module_; } bool top_level() const { return top_level_; } + bool print_callee() const { return print_callee_; } + bool oneshot_opt() const { return oneshot_opt_; } bool do_expressions() const { return do_expressions_; } bool async_iteration() const { return async_iteration_; } bool public_fields() const { return public_fields_; } @@ -84,6 +88,8 @@ class ProgramOptions final { bool wrap_; bool module_; bool top_level_; + bool print_callee_; + bool oneshot_opt_; bool do_expressions_; bool async_iteration_; bool public_fields_; @@ -174,6 +180,10 @@ ProgramOptions ProgramOptions::FromCommandLine(int argc, char** argv) { options.module_ = true; } else if (strcmp(argv[i], "--top-level") == 0) { options.top_level_ = true; + } else if (strcmp(argv[i], "--print-callee") == 0) { + options.print_callee_ = true; + } else if (strcmp(argv[i], "--disable-oneshot-opt") == 0) { + options.oneshot_opt_ = false; } else if (strcmp(argv[i], "--do-expressions") == 0) { options.do_expressions_ = true; } else if (strcmp(argv[i], "--async-iteration") == 0) { @@ -269,6 +279,8 @@ bool ProgramOptions::Validate() const { void ProgramOptions::UpdateFromHeader(std::istream& stream) { std::string line; + const char* kPrintCallee = "print callee: "; + const char* kOneshotOpt = "oneshot opt: "; // Skip to the beginning of the options header while (std::getline(stream, line)) { @@ -284,6 +296,10 @@ void ProgramOptions::UpdateFromHeader(std::istream& stream) { test_function_name_ = line.c_str() + 20; } else if (line.compare(0, 11, "top level: ") == 0) { top_level_ = ParseBoolean(line.c_str() + 11); + } else if (line.compare(0, strlen(kPrintCallee), kPrintCallee) == 0) { + print_callee_ = ParseBoolean(line.c_str() + strlen(kPrintCallee)); + } else if (line.compare(0, strlen(kOneshotOpt), kOneshotOpt) == 0) { + oneshot_opt_ = ParseBoolean(line.c_str() + strlen(kOneshotOpt)); } else if (line.compare(0, 16, "do expressions: ") == 0) { do_expressions_ = ParseBoolean(line.c_str() + 16); } else if (line.compare(0, 17, "async iteration: ") == 0) { @@ -315,6 +331,8 @@ void ProgramOptions::PrintHeader(std::ostream& stream) const { // NOLINT if (module_) stream << "\nmodule: yes"; if (top_level_) stream << "\ntop level: yes"; + if (print_callee_) stream << "\nprint callee: yes"; + if (oneshot_opt_) stream << "\noneshot opt: yes"; if (do_expressions_) stream << "\ndo expressions: yes"; if (async_iteration_) stream << "\nasync iteration: yes"; if (public_fields_) stream << "\npublic fields: yes"; @@ -364,6 +382,10 @@ bool ReadNextSnippet(std::istream& stream, std::string* string_out) { // NOLINT } if (!found_begin_snippet) continue; if (line == "\"") return true; + if (line.size() == 0) { + string_out->append("\n"); // consume empty line + continue; + } CHECK_GE(line.size(), 2u); // We should have the indent string_out->append(line.begin() + 2, line.end()); *string_out += '\n'; @@ -418,6 +440,8 @@ void GenerateExpectationsFile(std::ostream& stream, // NOLINT printer.set_wrap(options.wrap()); printer.set_module(options.module()); printer.set_top_level(options.top_level()); + printer.set_print_callee(options.print_callee()); + printer.set_oneshot_opt(options.oneshot_opt()); if (!options.test_function_name().empty()) { printer.set_test_function_name(options.test_function_name()); } @@ -478,6 +502,9 @@ void PrintUsage(const char* exec_path) { " --stdin Read from standard input instead of file.\n" " --rebaseline Rebaseline input snippet file.\n" " --no-wrap Do not wrap the snippet in a function.\n" + " --disable-oneshot-opt Disable Oneshot Optimization.\n" + " --print-callee Print bytecode of callee, function should " + "return arguments.callee.\n" " --module Compile as JavaScript module.\n" " --test-function-name=foo " "Specify the name of the test function.\n" diff --git a/deps/v8/test/cctest/interpreter/interpreter-tester.cc b/deps/v8/test/cctest/interpreter/interpreter-tester.cc index d112511d22..acb06f2d8a 100644 --- a/deps/v8/test/cctest/interpreter/interpreter-tester.cc +++ b/deps/v8/test/cctest/interpreter/interpreter-tester.cc @@ -4,6 +4,7 @@ #include "test/cctest/interpreter/interpreter-tester.h" +#include "src/api-inl.h" #include "src/objects-inl.h" namespace v8 { diff --git a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc index 561d163a69..0ec28d3653 100644 --- a/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc +++ b/deps/v8/test/cctest/interpreter/test-bytecode-generator.cc @@ -129,6 +129,27 @@ std::string BuildActual(const BytecodeExpectationsPrinter& printer, return actual_stream.str(); } +// inplace left trim +static inline void ltrim(std::string& str) { + str.erase(str.begin(), + std::find_if(str.begin(), str.end(), + [](unsigned char ch) { return !std::isspace(ch); })); +} + +// inplace right trim +static inline void rtrim(std::string& str) { + str.erase(std::find_if(str.rbegin(), str.rend(), + [](unsigned char ch) { return !std::isspace(ch); }) + .base(), + str.end()); +} + +static inline std::string trim(std::string& str) { + ltrim(str); + rtrim(str); + return str; +} + bool CompareTexts(const std::string& generated, const std::string& expected) { std::istringstream generated_stream(generated); std::istringstream expected_stream(expected); @@ -157,7 +178,7 @@ bool CompareTexts(const std::string& generated, const std::string& expected) { return false; } - if (generated_line != expected_line) { + if (trim(generated_line) != trim(expected_line)) { std::cerr << "Inputs differ at line " << line_number << "\n"; std::cerr << " Generated: '" << generated_line << "'\n"; std::cerr << " Expected: '" << expected_line << "'\n"; @@ -411,6 +432,242 @@ TEST(PropertyLoads) { LoadGolden("PropertyLoads.golden"))); } +TEST(PropertyLoadStoreOneShot) { + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_top_level(true); + printer.set_oneshot_opt(true); + + const char* snippets[] = { + R"( + l = { + 'a': 1, + 'b': 2 + }; + + v = l['a'] + l['b']; + l['b'] = 7; + l['a'] = l['b']; + )", + + R"( + l = { + 'a': 1.1, + 'b': 2.2 + }; + for (i = 0; i < 5; ++i) { + l['a'] = l['a'] + l['b']; + l['b'] = l['a'] + l['b']; + } + )", + + R"( + l = { + 'a': 1.1, + 'b': 2.2 + }; + while (s > 0) { + l['a'] = l['a'] - l['b']; + l['b'] = l['b'] - l['a']; + } + )", + + R"( + l = { + 'a': 1.1, + 'b': 2.2 + }; + s = 10; + do { + l['a'] = l['b'] - l['a']; + } while (s < 10); + )", + + R"( + l = { + 'c': 1.1, + 'd': 2.2 + }; + if (l['c'] < 3) { + l['c'] = 3; + } else { + l['d'] = 3; + } + )", + + R"( + a = [1.1, [2.2, 4.5]]; + )", + + R"( + b = []; + )", + }; + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("PropertyLoadStoreOneShot.golden"))); +} + +TEST(PropertyLoadStoreWithoutOneShot) { + InitializedIgnitionHandleScope scope; + BytecodeExpectationsPrinter printer(CcTest::isolate()); + printer.set_wrap(false); + printer.set_top_level(true); + + const char* snippets[] = { + R"( + l = { + 'aa': 1.1, + 'bb': 2.2 + }; + + v = l['aa'] + l['bb']; + l['bb'] = 7; + l['aa'] = l['bb']; + )", + + R"( + l = { + 'cc': 3.1, + 'dd': 4.2 + }; + if (l['cc'] < 3) { + l['cc'] = 3; + } else { + l['dd'] = 3; + } + )", + }; + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("PropertyLoadStoreWithoutOneShot.golden"))); +} + +TEST(IIFEWithOneshotOpt) { + InitializedIgnitionHandleScope scope; + v8::Isolate* isolate = CcTest::isolate(); + BytecodeExpectationsPrinter printer(isolate); + printer.set_wrap(false); + printer.set_top_level(true); + printer.set_print_callee(true); + printer.set_oneshot_opt(true); + + const char* snippets[] = { + // No feedback vectors for top-level loads/store named property in an IIFE + R"( + (function() { + l = {}; + l.aa = 2; + l.bb = l.aa; + return arguments.callee; + })(); + )", + // Normal load/store within loops of an IIFE + R"( + (function() { + l = {}; + for (i = 0; i < 5; ++i) { + l.aa = 2; + l.bb = l.aa; + } + return arguments.callee; + })(); + )", + + R"( + (function() { + l = {}; + c = 4; + while(c > 4) { + l.aa = 2; + l.bb = l.aa; + c--; + } + return arguments.callee; + })(); + )", + + R"( + (function() { + l = {}; + c = 4; + do { + l.aa = 2; + l.bb = l.aa; + c--; + } while(c > 4) + return arguments.callee; + })(); + )", + // No feedback vectors for loads/stores in conditionals + R"( + (function() { + l = { + 'aa': 3.3, + 'bb': 4.4 + }; + if (l.aa < 3) { + l.aa = 3; + } else { + l.aa = l.bb; + } + return arguments.callee; + })(); + )", + + R"( + (function() { + a = [0, [1, 1,2,], 3]; + return arguments.callee; + })(); + )", + + R"( + (function() { + a = []; + return arguments.callee; + })(); + )", + }; + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("IIFEWithOneshotOpt.golden"))); +} + +TEST(IIFEWithoutOneshotOpt) { + InitializedIgnitionHandleScope scope; + v8::Isolate* isolate = CcTest::isolate(); + BytecodeExpectationsPrinter printer(isolate); + printer.set_wrap(false); + printer.set_top_level(true); + printer.set_print_callee(true); + + const char* snippets[] = { + R"( + (function() { + l = {}; + l.a = 2; + l.b = l.a; + return arguments.callee; + })(); + )", + R"( + (function() { + l = { + 'a': 4.3, + 'b': 3.4 + }; + if (l.a < 3) { + l.a = 3; + } else { + l.a = l.b; + } + return arguments.callee; + })(); + )", + }; + CHECK(CompareTexts(BuildActual(printer, snippets), + LoadGolden("IIFEWithoutOneshotOpt.golden"))); +} + TEST(PropertyStores) { InitializedIgnitionHandleScope scope; BytecodeExpectationsPrinter printer(CcTest::isolate()); @@ -1202,6 +1459,12 @@ TEST(ArrayLiterals) { "return [ [ 1, 2 ], [ 3 ] ];\n", "var a = 1; return [ [ a, 2 ], [ a + 2 ] ];\n", + + "var a = [ 1, 2 ]; return [ ...a ];\n", + + "var a = [ 1, 2 ]; return [ 0, ...a ];\n", + + "var a = [ 1, 2 ]; return [ ...a, 3 ];\n", }; CHECK(CompareTexts(BuildActual(printer, snippets), diff --git a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc index 7eb76ecb21..57d42e2a83 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter-intrinsics.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/api-inl.h" #include "src/interpreter/interpreter-intrinsics.h" #include "src/objects-inl.h" #include "test/cctest/interpreter/interpreter-tester.h" @@ -209,14 +210,14 @@ TEST(IntrinsicAsStubCall) { InvokeIntrinsicHelper has_property_helper(isolate, handles.main_zone(), Runtime::kInlineHasProperty); - CHECK_EQ(*factory->true_value(), - *has_property_helper.Invoke( - has_property_helper.NewObject("'x'"), - has_property_helper.NewObject("({ x: 20 })"))); - CHECK_EQ(*factory->false_value(), - *has_property_helper.Invoke( - has_property_helper.NewObject("'y'"), - has_property_helper.NewObject("({ x: 20 })"))); + CHECK_EQ( + *factory->true_value(), + *has_property_helper.Invoke(has_property_helper.NewObject("({ x: 20 })"), + has_property_helper.NewObject("'x'"))); + CHECK_EQ( + *factory->false_value(), + *has_property_helper.Invoke(has_property_helper.NewObject("({ x: 20 })"), + has_property_helper.NewObject("'y'"))); } } // namespace interpreter diff --git a/deps/v8/test/cctest/interpreter/test-interpreter.cc b/deps/v8/test/cctest/interpreter/test-interpreter.cc index 11163d9688..c1898adf4e 100644 --- a/deps/v8/test/cctest/interpreter/test-interpreter.cc +++ b/deps/v8/test/cctest/interpreter/test-interpreter.cc @@ -6,6 +6,7 @@ #include "src/v8.h" +#include "src/api-inl.h" #include "src/execution.h" #include "src/handles.h" #include "src/interpreter/bytecode-array-builder.h" diff --git a/deps/v8/test/cctest/interpreter/test-source-positions.cc b/deps/v8/test/cctest/interpreter/test-source-positions.cc index 51dd41c720..8f2aae7e0b 100644 --- a/deps/v8/test/cctest/interpreter/test-source-positions.cc +++ b/deps/v8/test/cctest/interpreter/test-source-positions.cc @@ -4,7 +4,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/compiler/pipeline.h" #include "src/handles.h" #include "src/interpreter/bytecode-generator.h" diff --git a/deps/v8/test/cctest/parsing/test-parse-decision.cc b/deps/v8/test/cctest/parsing/test-parse-decision.cc index 926d4c24e0..f44a9e4b82 100644 --- a/deps/v8/test/cctest/parsing/test-parse-decision.cc +++ b/deps/v8/test/cctest/parsing/test-parse-decision.cc @@ -10,7 +10,7 @@ #include <unordered_map> #include "include/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/handles-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" diff --git a/deps/v8/test/cctest/parsing/test-preparser.cc b/deps/v8/test/cctest/parsing/test-preparser.cc index b63a079a78..473debec40 100644 --- a/deps/v8/test/cctest/parsing/test-preparser.cc +++ b/deps/v8/test/cctest/parsing/test-preparser.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/ast/ast.h" #include "src/compiler.h" #include "src/objects-inl.h" diff --git a/deps/v8/test/cctest/parsing/test-scanner-streams.cc b/deps/v8/test/cctest/parsing/test-scanner-streams.cc index 6f9b58daf3..a9dc4482ef 100644 --- a/deps/v8/test/cctest/parsing/test-scanner-streams.cc +++ b/deps/v8/test/cctest/parsing/test-scanner-streams.cc @@ -185,6 +185,110 @@ TEST(Utf8SplitBOM) { } } +TEST(Utf8SplitMultiBOM) { + // Construct chunks with a split BOM followed by another split BOM. + const char* chunks = "\xef\xbb\0\xbf\xef\xbb\0\xbf\0\0"; + ChunkSource chunk_source(chunks); + std::unique_ptr<i::Utf16CharacterStream> stream( + v8::internal::ScannerStream::For( + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + + // Read the data, ensuring we get exactly one of the two BOMs back. + CHECK_EQ(0xFEFF, stream->Advance()); + CHECK_EQ(i::Utf16CharacterStream::kEndOfInput, stream->Advance()); +} + +TEST(Utf8AdvanceUntil) { + // Test utf-8 advancing until a certain char. + + const char line_term = '\n'; + const size_t kLen = arraysize(unicode_utf8); + char data[kLen + 1]; + strncpy(data, unicode_utf8, kLen); + data[kLen - 1] = line_term; + data[kLen] = '\0'; + + { + const char* chunks[] = {data, "\0"}; + ChunkSource chunk_source(chunks); + std::unique_ptr<v8::internal::Utf16CharacterStream> stream( + v8::internal::ScannerStream::For( + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + + int32_t res = stream->AdvanceUntil( + [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); + CHECK_EQ(line_term, res); + } +} + +TEST(AdvanceMatchAdvanceUntil) { + // Test if single advance and advanceUntil behave the same + + char data[] = {'a', 'b', '\n', 'c', '\0'}; + + { + const char* chunks[] = {data, "\0"}; + ChunkSource chunk_source_a(chunks); + + std::unique_ptr<v8::internal::Utf16CharacterStream> stream_advance( + v8::internal::ScannerStream::For( + &chunk_source_a, v8::ScriptCompiler::StreamedSource::UTF8, + nullptr)); + + ChunkSource chunk_source_au(chunks); + std::unique_ptr<v8::internal::Utf16CharacterStream> stream_advance_until( + v8::internal::ScannerStream::For( + &chunk_source_au, v8::ScriptCompiler::StreamedSource::UTF8, + nullptr)); + + int32_t au_c0_ = stream_advance_until->AdvanceUntil( + [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); + + int32_t a_c0_ = '0'; + while (!unibrow::IsLineTerminator(a_c0_)) { + a_c0_ = stream_advance->Advance(); + } + + // Check both advances methods have the same output + CHECK_EQ(a_c0_, au_c0_); + + // Check if both set the cursor to the correct position by advancing both + // streams by one character. + a_c0_ = stream_advance->Advance(); + au_c0_ = stream_advance_until->Advance(); + CHECK_EQ(a_c0_, au_c0_); + } +} + +TEST(Utf8AdvanceUntilOverChunkBoundaries) { + // Test utf-8 advancing until a certain char, crossing chunk boundaries. + + // Split the test string at each byte and pass it to the stream. This way, + // we'll have a split at each possible boundary. + size_t len = strlen(unicode_utf8); + char buffer[arraysize(unicode_utf8) + 4]; + for (size_t i = 1; i < len; i++) { + // Copy source string into buffer, splitting it at i. + // Then add three chunks, 0..i-1, i..strlen-1, empty. + strncpy(buffer, unicode_utf8, i); + strncpy(buffer + i + 1, unicode_utf8 + i, len - i); + buffer[i] = '\0'; + buffer[len + 1] = '\n'; + buffer[len + 2] = '\0'; + buffer[len + 3] = '\0'; + const char* chunks[] = {buffer, buffer + i + 1, buffer + len + 2}; + + ChunkSource chunk_source(chunks); + std::unique_ptr<v8::internal::Utf16CharacterStream> stream( + v8::internal::ScannerStream::For( + &chunk_source, v8::ScriptCompiler::StreamedSource::UTF8, nullptr)); + + int32_t res = stream->AdvanceUntil( + [](int32_t c0_) { return unibrow::IsLineTerminator(c0_); }); + CHECK_EQ(buffer[len + 1], res); + } +} + TEST(Utf8ChunkBoundaries) { // Test utf-8 parsing at chunk boundaries. @@ -323,7 +427,7 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, // This avoids the GC from trying to free a stack allocated resource. if (uc16_string->IsExternalString()) i::Handle<i::ExternalTwoByteString>::cast(uc16_string) - ->set_resource(nullptr); + ->SetResource(isolate, nullptr); } // 1-byte external string @@ -343,7 +447,7 @@ void TestCharacterStreams(const char* one_byte_source, unsigned length, // This avoids the GC from trying to free a stack allocated resource. if (ext_one_byte_string->IsExternalString()) i::Handle<i::ExternalOneByteString>::cast(ext_one_byte_string) - ->set_resource(nullptr); + ->SetResource(isolate, nullptr); } // 1-byte generic i::String @@ -560,3 +664,34 @@ TEST(TestOverlongAndInvalidSequences) { CHECK_EQ(unicode_expected.size(), arraysize(cases)); TestChunkStreamAgainstReference(cases, unicode_expected); } + +TEST(RelocatingCharacterStream) { + ManualGCScope manual_gc_scope; + CcTest::InitializeVM(); + i::Isolate* i_isolate = CcTest::i_isolate(); + v8::HandleScope scope(CcTest::isolate()); + + const char* string = "abcd"; + int length = static_cast<int>(strlen(string)); + std::unique_ptr<i::uc16[]> uc16_buffer(new i::uc16[length]); + for (int i = 0; i < length; i++) { + uc16_buffer[i] = string[i]; + } + i::Vector<const i::uc16> two_byte_vector(uc16_buffer.get(), length); + i::Handle<i::String> two_byte_string = + i_isolate->factory() + ->NewStringFromTwoByte(two_byte_vector, i::NOT_TENURED) + .ToHandleChecked(); + std::unique_ptr<i::Utf16CharacterStream> two_byte_string_stream( + i::ScannerStream::For(i_isolate, two_byte_string, 0, length)); + CHECK_EQ('a', two_byte_string_stream->Advance()); + CHECK_EQ('b', two_byte_string_stream->Advance()); + CHECK_EQ(size_t{2}, two_byte_string_stream->pos()); + i::String* raw = *two_byte_string; + i_isolate->heap()->CollectGarbage(i::NEW_SPACE, + i::GarbageCollectionReason::kUnknown); + // GC moved the string. + CHECK_NE(raw, *two_byte_string); + CHECK_EQ('c', two_byte_string_stream->Advance()); + CHECK_EQ('d', two_byte_string_stream->Advance()); +} diff --git a/deps/v8/test/cctest/parsing/test-scanner.cc b/deps/v8/test/cctest/parsing/test-scanner.cc index ea7a8fbaa2..56fe0ed83a 100644 --- a/deps/v8/test/cctest/parsing/test-scanner.cc +++ b/deps/v8/test/cctest/parsing/test-scanner.cc @@ -21,7 +21,7 @@ const char src_simple[] = "function foo() { var x = 2 * a() + b; }"; struct ScannerTestHelper { ScannerTestHelper() = default; - ScannerTestHelper(ScannerTestHelper&& other) + ScannerTestHelper(ScannerTestHelper&& other) V8_NOEXCEPT : unicode_cache(std::move(other.unicode_cache)), stream(std::move(other.stream)), scanner(std::move(other.scanner)) {} @@ -38,9 +38,9 @@ ScannerTestHelper make_scanner(const char* src) { ScannerTestHelper helper; helper.unicode_cache = std::unique_ptr<UnicodeCache>(new UnicodeCache); helper.stream = ScannerStream::ForTesting(src); - helper.scanner = - std::unique_ptr<Scanner>(new Scanner(helper.unicode_cache.get())); - helper.scanner->Initialize(helper.stream.get(), false); + helper.scanner = std::unique_ptr<Scanner>( + new Scanner(helper.unicode_cache.get(), helper.stream.get(), false)); + helper.scanner->Initialize(); return helper; } diff --git a/deps/v8/test/cctest/test-accessors.cc b/deps/v8/test/cctest/test-accessors.cc index a998a28642..de1901b6d3 100644 --- a/deps/v8/test/cctest/test-accessors.cc +++ b/deps/v8/test/cctest/test-accessors.cc @@ -29,7 +29,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/frames-inl.h" #include "src/string-stream.h" #include "test/cctest/cctest.h" @@ -812,7 +812,7 @@ TEST(PrototypeGetterAccessCheck) { CHECK(try_catch.HasCaught()); } - // Test crankshaft. + // Test TurboFan. CompileRun("%OptimizeFunctionOnNextCall(f);"); security_check_value = true; diff --git a/deps/v8/test/cctest/test-api-accessors.cc b/deps/v8/test/cctest/test-api-accessors.cc index a570301213..5bda0432ea 100644 --- a/deps/v8/test/cctest/test-api-accessors.cc +++ b/deps/v8/test/cctest/test-api-accessors.cc @@ -17,7 +17,7 @@ static void UnreachableCallback( } TEST(CachedAccessor) { - // Crankshaft support for fast accessors is not implemented; crankshafted + // TurboFan support for fast accessors is not implemented; turbofanned // code uses the slow accessor which breaks this test's expectations. v8::internal::FLAG_always_opt = false; LocalContext env; @@ -64,7 +64,7 @@ TEST(CachedAccessor) { "Shhh, I'm private!"); } -TEST(CachedAccessorCrankshaft) { +TEST(CachedAccessorTurboFan) { i::FLAG_allow_natives_syntax = true; // v8::internal::FLAG_always_opt = false; LocalContext env; @@ -116,7 +116,7 @@ TEST(CachedAccessorCrankshaft) { CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 456)) .FromJust()); - // Test Crankshaft. + // Test TurboFan. CompileRun("%OptimizeFunctionOnNextCall(f);"); ExpectInt32("f()", 456); @@ -140,7 +140,7 @@ TEST(CachedAccessorCrankshaft) { CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 789)) .FromJust()); - // Test non-global access in Crankshaft. + // Test non-global access in TurboFan. CompileRun("%OptimizeFunctionOnNextCall(g);"); ExpectInt32("g()", 789); @@ -198,7 +198,7 @@ TEST(CachedAccessorOnGlobalObject) { CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 456)) .FromJust()); - // Test Crankshaft. + // Test TurboFan. CompileRun("%OptimizeFunctionOnNextCall(f);"); ExpectInt32("f()", 456); @@ -222,7 +222,7 @@ TEST(CachedAccessorOnGlobalObject) { CHECK(obj->SetPrivate(env.local(), priv, v8::Integer::New(isolate, 789)) .FromJust()); - // Test non-global access in Crankshaft. + // Test non-global access in TurboFan. CompileRun("%OptimizeFunctionOnNextCall(g);"); ExpectInt32("g()", 789); diff --git a/deps/v8/test/cctest/test-api-interceptors.cc b/deps/v8/test/cctest/test-api-interceptors.cc index 030db759fe..9d9138670e 100644 --- a/deps/v8/test/cctest/test-api-interceptors.cc +++ b/deps/v8/test/cctest/test-api-interceptors.cc @@ -7,7 +7,7 @@ #include "test/cctest/test-api.h" #include "include/v8-util.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/arguments.h" #include "src/base/platform/platform.h" #include "src/compilation-cache.h" @@ -76,16 +76,17 @@ void EmptyInterceptorEnumerator( void SimpleAccessorGetter(Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Local<Object> self = Local<Object>::Cast(info.This()); - info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(), - String::Concat(v8_str("accessor_"), name)) - .ToLocalChecked()); + info.GetReturnValue().Set( + self->Get(info.GetIsolate()->GetCurrentContext(), + String::Concat(info.GetIsolate(), v8_str("accessor_"), name)) + .ToLocalChecked()); } void SimpleAccessorSetter(Local<String> name, Local<Value> value, const v8::PropertyCallbackInfo<void>& info) { Local<Object> self = Local<Object>::Cast(info.This()); self->Set(info.GetIsolate()->GetCurrentContext(), - String::Concat(v8_str("accessor_"), name), value) + String::Concat(info.GetIsolate(), v8_str("accessor_"), name), value) .FromJust(); } @@ -155,13 +156,14 @@ void GenericInterceptorGetter(Local<Name> generic_name, if (generic_name->IsSymbol()) { Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); if (name->IsUndefined()) return; - str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name)); + str = String::Concat(info.GetIsolate(), v8_str("_sym_"), + Local<String>::Cast(name)); } else { Local<String> name = Local<String>::Cast(generic_name); String::Utf8Value utf8(info.GetIsolate(), name); char* name_str = *utf8; if (*name_str == '_') return; - str = String::Concat(v8_str("_str_"), name); + str = String::Concat(info.GetIsolate(), v8_str("_str_"), name); } Local<Object> self = Local<Object>::Cast(info.This()); @@ -175,13 +177,14 @@ void GenericInterceptorSetter(Local<Name> generic_name, Local<Value> value, if (generic_name->IsSymbol()) { Local<Value> name = Local<Symbol>::Cast(generic_name)->Name(); if (name->IsUndefined()) return; - str = String::Concat(v8_str("_sym_"), Local<String>::Cast(name)); + str = String::Concat(info.GetIsolate(), v8_str("_sym_"), + Local<String>::Cast(name)); } else { Local<String> name = Local<String>::Cast(generic_name); String::Utf8Value utf8(info.GetIsolate(), name); char* name_str = *utf8; if (*name_str == '_') return; - str = String::Concat(v8_str("_str_"), name); + str = String::Concat(info.GetIsolate(), v8_str("_str_"), name); } Local<Object> self = Local<Object>::Cast(info.This()); @@ -4304,8 +4307,7 @@ THREADED_TEST(Regress256330) { CHECK_EQ(mask, status & mask); } - -THREADED_TEST(CrankshaftInterceptorSetter) { +THREADED_TEST(OptimizedInterceptorSetter) { i::FLAG_allow_natives_syntax = true; v8::HandleScope scope(CcTest::isolate()); Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); @@ -4334,8 +4336,7 @@ THREADED_TEST(CrankshaftInterceptorSetter) { ExpectInt32("obj.accessor_age", 42); } - -THREADED_TEST(CrankshaftInterceptorGetter) { +THREADED_TEST(OptimizedInterceptorGetter) { i::FLAG_allow_natives_syntax = true; v8::HandleScope scope(CcTest::isolate()); Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); @@ -4361,8 +4362,7 @@ THREADED_TEST(CrankshaftInterceptorGetter) { ExpectInt32("getAge()", 1); } - -THREADED_TEST(CrankshaftInterceptorFieldRead) { +THREADED_TEST(OptimizedInterceptorFieldRead) { i::FLAG_allow_natives_syntax = true; v8::HandleScope scope(CcTest::isolate()); Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); @@ -4385,8 +4385,7 @@ THREADED_TEST(CrankshaftInterceptorFieldRead) { ExpectInt32("getAge();", 100); } - -THREADED_TEST(CrankshaftInterceptorFieldWrite) { +THREADED_TEST(OptimizedInterceptorFieldWrite) { i::FLAG_allow_natives_syntax = true; v8::HandleScope scope(CcTest::isolate()); Local<FunctionTemplate> templ = FunctionTemplate::New(CcTest::isolate()); @@ -5026,7 +5025,7 @@ void ConcatNamedPropertyGetter( Local<Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { info.GetReturnValue().Set( // Return the property name concatenated with itself. - String::Concat(name.As<String>(), name.As<String>())); + String::Concat(info.GetIsolate(), name.As<String>(), name.As<String>())); } void ConcatIndexedPropertyGetter( diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index a018e12853..bf5aba2df6 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -38,7 +38,7 @@ #endif #include "include/v8-util.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/arguments.h" #include "src/base/platform/platform.h" #include "src/code-stubs.h" @@ -52,12 +52,14 @@ #include "src/lookup.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" +#include "src/objects/js-array-buffer-inl.h" +#include "src/objects/js-array-inl.h" #include "src/objects/js-promise-inl.h" -#include "src/parsing/preparse-data.h" #include "src/profiler/cpu-profiler.h" #include "src/unicode-inl.h" #include "src/utils.h" #include "src/vm-state.h" +#include "src/wasm/wasm-js.h" #include "test/cctest/heap/heap-tester.h" #include "test/cctest/heap/heap-utils.h" @@ -374,7 +376,7 @@ THREADED_TEST(HulIgennem) { v8::Local<v8::Primitive> undef = v8::Undefined(isolate); Local<String> undef_str = undef->ToString(env.local()).ToLocalChecked(); char* value = i::NewArray<char>(undef_str->Utf8Length(isolate) + 1); - undef_str->WriteUtf8(value); + undef_str->WriteUtf8(isolate, value); CHECK_EQ(0, strcmp(value, "undefined")); i::DeleteArray(value); } @@ -911,7 +913,8 @@ TEST(ExternalStringWithDisposeHandling) { THREADED_TEST(StringConcat) { { LocalContext env; - v8::HandleScope scope(env->GetIsolate()); + v8::Isolate* isolate = env->GetIsolate(); + v8::HandleScope scope(isolate); const char* one_byte_string_1 = "function a_times_t"; const char* two_byte_string_1 = "wo_plus_b(a, b) {return "; const char* one_byte_extern_1 = "a * 2 + b;} a_times_two_plus_b(4, 8) + "; @@ -928,19 +931,19 @@ THREADED_TEST(StringConcat) { .ToLocalChecked(); i::DeleteArray(two_byte_source); - Local<String> source = String::Concat(left, right); + Local<String> source = String::Concat(isolate, left, right); right = String::NewExternalOneByte( env->GetIsolate(), new TestOneByteResource(i::StrDup(one_byte_extern_1))) .ToLocalChecked(); - source = String::Concat(source, right); + source = String::Concat(isolate, source, right); right = String::NewExternalTwoByte( env->GetIsolate(), new TestResource(AsciiToTwoByteString(two_byte_extern_1))) .ToLocalChecked(); - source = String::Concat(source, right); + source = String::Concat(isolate, source, right); right = v8_str(one_byte_string_2); - source = String::Concat(source, right); + source = String::Concat(isolate, source, right); two_byte_source = AsciiToTwoByteString(two_byte_string_2); right = String::NewFromTwoByte(env->GetIsolate(), two_byte_source, @@ -948,12 +951,12 @@ THREADED_TEST(StringConcat) { .ToLocalChecked(); i::DeleteArray(two_byte_source); - source = String::Concat(source, right); + source = String::Concat(isolate, source, right); right = String::NewExternalTwoByte( env->GetIsolate(), new TestResource(AsciiToTwoByteString(two_byte_extern_2))) .ToLocalChecked(); - source = String::Concat(source, right); + source = String::Concat(isolate, source, right); Local<Script> script = v8_compile(source); Local<Value> value = script->Run(env.local()).ToLocalChecked(); CHECK(value->IsNumber()); @@ -1736,7 +1739,8 @@ THREADED_TEST(StringObject) { Local<v8::String> the_string = as_boxed->ValueOf(); CHECK(!the_string.IsEmpty()); ExpectObject("\"test\"", the_string); - v8::Local<v8::Value> new_boxed_string = v8::StringObject::New(the_string); + v8::Local<v8::Value> new_boxed_string = + v8::StringObject::New(CcTest::isolate(), the_string); CHECK(new_boxed_string->IsStringObject()); as_boxed = new_boxed_string.As<v8::StringObject>(); the_string = as_boxed->ValueOf(); @@ -2469,7 +2473,7 @@ THREADED_TEST(DescriptorInheritance2) { for (int i = 0; i < kDataPropertiesNumber; i++) { v8::Local<v8::Value> val = v8_num(i); v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked(); - v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str); + v8::Local<v8::String> name = String::Concat(isolate, v8_str("p"), val_str); templ->Set(name, val); templ->Set(val_str, val); @@ -2506,7 +2510,7 @@ THREADED_TEST(DescriptorInheritance2) { for (int i = 0; i < kDataPropertiesNumber; i++) { v8::Local<v8::Value> val = v8_num(i); v8::Local<v8::String> val_str = val->ToString(env.local()).ToLocalChecked(); - v8::Local<v8::String> name = String::Concat(v8_str("p"), val_str); + v8::Local<v8::String> name = String::Concat(isolate, v8_str("p"), val_str); CHECK_EQ(i, object->Get(env.local(), name) .ToLocalChecked() @@ -2525,16 +2529,18 @@ THREADED_TEST(DescriptorInheritance2) { void SimpleAccessorGetter(Local<String> name, const v8::PropertyCallbackInfo<v8::Value>& info) { Local<Object> self = Local<Object>::Cast(info.This()); - info.GetReturnValue().Set(self->Get(info.GetIsolate()->GetCurrentContext(), - String::Concat(v8_str("accessor_"), name)) - .ToLocalChecked()); + info.GetReturnValue().Set( + self->Get(info.GetIsolate()->GetCurrentContext(), + String::Concat(info.GetIsolate(), v8_str("accessor_"), name)) + .ToLocalChecked()); } void SimpleAccessorSetter(Local<String> name, Local<Value> value, const v8::PropertyCallbackInfo<void>& info) { Local<Object> self = Local<Object>::Cast(info.This()); CHECK(self->Set(info.GetIsolate()->GetCurrentContext(), - String::Concat(v8_str("accessor_"), name), value) + String::Concat(info.GetIsolate(), v8_str("accessor_"), name), + value) .FromJust()); } @@ -7841,10 +7847,18 @@ static void IndependentWeakHandle(bool global_gc, bool interlinked) { v8::WeakCallbackType::kParameter); object_b.handle.SetWeak(&object_b, &SetFlag, v8::WeakCallbackType::kParameter); +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +#endif + // MarkIndependent is marked deprecated but we still rely on it temporarily. CHECK(!object_b.handle.IsIndependent()); object_a.handle.MarkIndependent(); object_b.handle.MarkIndependent(); CHECK(object_b.handle.IsIndependent()); +#if __clang__ +#pragma clang diagnostic pop +#endif if (global_gc) { CcTest::CollectAllGarbage(); } else { @@ -7996,9 +8010,17 @@ void v8::internal::heap::HeapTester::ResetWeakHandle(bool global_gc) { object_b.handle.SetWeak(&object_b, &ResetUseValueAndSetFlag, v8::WeakCallbackType::kParameter); if (!global_gc) { +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +#endif + // MarkIndependent is marked deprecated but we still rely on it temporarily. object_a.handle.MarkIndependent(); object_b.handle.MarkIndependent(); CHECK(object_b.handle.IsIndependent()); +#if __clang__ +#pragma clang diagnostic pop +#endif } if (global_gc) { CcTest::CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); @@ -8067,7 +8089,16 @@ THREADED_TEST(GCFromWeakCallbacks) { object.flag = false; object.handle.SetWeak(&object, gc_forcing_callback[inner_gc], v8::WeakCallbackType::kParameter); +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" +#endif + // MarkIndependent is marked deprecated but we still rely on it + // temporarily. object.handle.MarkIndependent(); +#if __clang__ +#pragma clang diagnostic pop +#endif invoke_gc[outer_gc](); EmptyMessageQueues(isolate); CHECK(object.flag); @@ -8285,7 +8316,8 @@ int GetUtf8Length(v8::Isolate* isolate, Local<String> str) { THREADED_TEST(StringWrite) { LocalContext context; - v8::HandleScope scope(context->GetIsolate()); + v8::Isolate* isolate = context->GetIsolate(); + v8::HandleScope scope(isolate); v8::Local<String> str = v8_str("abcde"); // abc<Icelandic eth><Unicode snowman>. v8::Local<String> str2 = v8_str("abc\xC3\xB0\xE2\x98\x83"); @@ -8347,65 +8379,63 @@ THREADED_TEST(StringWrite) { int charlen; memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); + len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen); CHECK_EQ(9, len); CHECK_EQ(5, charlen); CHECK_EQ(0, strcmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83")); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 8, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 8, &charlen); CHECK_EQ(8, len); CHECK_EQ(5, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\xE2\x98\x83\x01", 9)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 7, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 7, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 6, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 6, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 5, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 5, &charlen); CHECK_EQ(5, len); CHECK_EQ(4, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\xC3\xB0\x01", 5)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 4, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 4, &charlen); CHECK_EQ(3, len); CHECK_EQ(3, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 3, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 3, &charlen); CHECK_EQ(3, len); CHECK_EQ(3, charlen); CHECK_EQ(0, strncmp(utf8buf, "abc\x01", 4)); memset(utf8buf, 0x1, 1000); - len = str2->WriteUtf8(utf8buf, 2, &charlen); + len = str2->WriteUtf8(isolate, utf8buf, 2, &charlen); CHECK_EQ(2, len); CHECK_EQ(2, charlen); CHECK_EQ(0, strncmp(utf8buf, "ab\x01", 3)); // allow orphan surrogates by default memset(utf8buf, 0x1, 1000); - len = orphans_str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen); + len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen); CHECK_EQ(13, len); CHECK_EQ(8, charlen); CHECK_EQ(0, strcmp(utf8buf, "ab\xED\xA0\x80wx\xED\xB0\x80yz")); // replace orphan surrogates with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = orphans_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = orphans_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(13, len); CHECK_EQ(8, charlen); @@ -8413,9 +8443,7 @@ THREADED_TEST(StringWrite) { // replace single lead surrogate with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = lead_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = lead_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(4, len); CHECK_EQ(1, charlen); @@ -8423,9 +8451,7 @@ THREADED_TEST(StringWrite) { // replace single trail surrogate with Unicode replacement character memset(utf8buf, 0x1, 1000); - len = trail_str->WriteUtf8(utf8buf, - sizeof(utf8buf), - &charlen, + len = trail_str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::REPLACE_INVALID_UTF8); CHECK_EQ(4, len); CHECK_EQ(1, charlen); @@ -8434,19 +8460,17 @@ THREADED_TEST(StringWrite) { // do not replace / write anything if surrogate pair does not fit the buffer // space memset(utf8buf, 0x1, 1000); - len = pair_str->WriteUtf8(utf8buf, - 3, - &charlen, - String::REPLACE_INVALID_UTF8); + len = pair_str->WriteUtf8(isolate, utf8buf, 3, &charlen, + String::REPLACE_INVALID_UTF8); CHECK_EQ(0, len); CHECK_EQ(0, charlen); memset(utf8buf, 0x1, sizeof(utf8buf)); - len = GetUtf8Length(context->GetIsolate(), left_tree); + len = GetUtf8Length(isolate, left_tree); int utf8_expected = (0x80 + (0x800 - 0x80) * 2 + (0xD800 - 0x800) * 3) / kStride; CHECK_EQ(utf8_expected, len); - len = left_tree->WriteUtf8(utf8buf, utf8_expected, &charlen); + len = left_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen); CHECK_EQ(utf8_expected, len); CHECK_EQ(0xD800 / kStride, charlen); CHECK_EQ(0xED, static_cast<unsigned char>(utf8buf[utf8_expected - 3])); @@ -8456,9 +8480,9 @@ THREADED_TEST(StringWrite) { CHECK_EQ(1, utf8buf[utf8_expected]); memset(utf8buf, 0x1, sizeof(utf8buf)); - len = GetUtf8Length(context->GetIsolate(), right_tree); + len = GetUtf8Length(isolate, right_tree); CHECK_EQ(utf8_expected, len); - len = right_tree->WriteUtf8(utf8buf, utf8_expected, &charlen); + len = right_tree->WriteUtf8(isolate, utf8buf, utf8_expected, &charlen); CHECK_EQ(utf8_expected, len); CHECK_EQ(0xD800 / kStride, charlen); CHECK_EQ(0xED, static_cast<unsigned char>(utf8buf[0])); @@ -8468,9 +8492,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf)); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf)); CHECK_EQ(5, len); - len = str->Write(wbuf); + len = str->Write(isolate, wbuf); CHECK_EQ(5, len); CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'}; @@ -8478,9 +8502,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 4); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 4); CHECK_EQ(4, len); - len = str->Write(wbuf, 0, 4); + len = str->Write(isolate, wbuf, 0, 4); CHECK_EQ(4, len); CHECK_EQ(0, strncmp("abcd\x01", buf, 5)); uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101}; @@ -8488,9 +8512,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 5); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 5); CHECK_EQ(5, len); - len = str->Write(wbuf, 0, 5); + len = str->Write(isolate, wbuf, 0, 5); CHECK_EQ(5, len); CHECK_EQ(0, strncmp("abcde\x01", buf, 6)); uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101}; @@ -8498,9 +8522,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 0, 6); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 6); CHECK_EQ(5, len); - len = str->Write(wbuf, 0, 6); + len = str->Write(isolate, wbuf, 0, 6); CHECK_EQ(5, len); CHECK_EQ(0, strcmp("abcde", buf)); uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'}; @@ -8508,9 +8532,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, -1); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, -1); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, -1); + len = str->Write(isolate, wbuf, 4, -1); CHECK_EQ(1, len); CHECK_EQ(0, strcmp("e", buf)); uint16_t answer5[] = {'e', '\0'}; @@ -8518,18 +8542,18 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 6); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, 6); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, 6); + len = str->Write(isolate, wbuf, 4, 6); CHECK_EQ(1, len); CHECK_EQ(0, strcmp("e", buf)); CHECK_EQ(0, StrCmp16(answer5, wbuf)); memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 4, 1); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 4, 1); CHECK_EQ(1, len); - len = str->Write(wbuf, 4, 1); + len = str->Write(isolate, wbuf, 4, 1); CHECK_EQ(1, len); CHECK_EQ(0, strncmp("e\x01", buf, 2)); uint16_t answer6[] = {'e', 0x101}; @@ -8537,9 +8561,9 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); memset(wbuf, 0x1, sizeof(wbuf)); - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), 3, 1); + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 3, 1); CHECK_EQ(1, len); - len = str->Write(wbuf, 3, 1); + len = str->Write(isolate, wbuf, 3, 1); CHECK_EQ(1, len); CHECK_EQ(0, strncmp("d\x01", buf, 2)); uint16_t answer7[] = {'d', 0x101}; @@ -8547,7 +8571,7 @@ THREADED_TEST(StringWrite) { memset(wbuf, 0x1, sizeof(wbuf)); wbuf[5] = 'X'; - len = str->Write(wbuf, 0, 6, String::NO_NULL_TERMINATION); + len = str->Write(isolate, wbuf, 0, 6, String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', wbuf[5]); uint16_t answer8a[] = {'a', 'b', 'c', 'd', 'e'}; @@ -8559,9 +8583,7 @@ THREADED_TEST(StringWrite) { memset(buf, 0x1, sizeof(buf)); buf[5] = 'X'; - len = str->WriteOneByte(reinterpret_cast<uint8_t*>(buf), - 0, - 6, + len = str->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf), 0, 6, String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', buf[5]); @@ -8572,7 +8594,7 @@ THREADED_TEST(StringWrite) { memset(utf8buf, 0x1, sizeof(utf8buf)); utf8buf[8] = 'X'; - len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen, + len = str2->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, String::NO_NULL_TERMINATION); CHECK_EQ(8, len); CHECK_EQ('X', utf8buf[8]); @@ -8584,8 +8606,8 @@ THREADED_TEST(StringWrite) { memset(utf8buf, 0x1, sizeof(utf8buf)); utf8buf[5] = 'X'; - len = str->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen, - String::NO_NULL_TERMINATION); + len = str->WriteUtf8(isolate, utf8buf, sizeof(utf8buf), &charlen, + String::NO_NULL_TERMINATION); CHECK_EQ(5, len); CHECK_EQ('X', utf8buf[5]); // Test that the sixth character is untouched. CHECK_EQ(5, charlen); @@ -8593,15 +8615,17 @@ THREADED_TEST(StringWrite) { CHECK_EQ(0, strcmp(utf8buf, "abcde")); memset(buf, 0x1, sizeof(buf)); - len = str3->WriteOneByte(reinterpret_cast<uint8_t*>(buf)); + len = str3->WriteOneByte(isolate, reinterpret_cast<uint8_t*>(buf)); CHECK_EQ(7, len); CHECK_EQ(0, strcmp("abc", buf)); CHECK_EQ(0, buf[3]); CHECK_EQ(0, strcmp("def", buf + 4)); - CHECK_EQ(0, str->WriteOneByte(nullptr, 0, 0, String::NO_NULL_TERMINATION)); - CHECK_EQ(0, str->WriteUtf8(nullptr, 0, 0, String::NO_NULL_TERMINATION)); - CHECK_EQ(0, str->Write(nullptr, 0, 0, String::NO_NULL_TERMINATION)); + CHECK_EQ(0, str->WriteOneByte(isolate, nullptr, 0, 0, + String::NO_NULL_TERMINATION)); + CHECK_EQ(0, + str->WriteUtf8(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); + CHECK_EQ(0, str->Write(isolate, nullptr, 0, 0, String::NO_NULL_TERMINATION)); } @@ -8627,14 +8651,14 @@ static void Utf16Helper( } void TestUtf8DecodingAgainstReference( - const char* cases[], + v8::Isolate* isolate, const char* cases[], const std::vector<std::vector<uint16_t>>& unicode_expected) { for (size_t test_ix = 0; test_ix < unicode_expected.size(); ++test_ix) { v8::Local<String> str = v8_str(cases[test_ix]); CHECK_EQ(unicode_expected[test_ix].size(), str->Length()); std::unique_ptr<uint16_t[]> buffer(new uint16_t[str->Length()]); - str->Write(buffer.get(), 0, -1, String::NO_NULL_TERMINATION); + str->Write(isolate, buffer.get(), 0, -1, String::NO_NULL_TERMINATION); for (size_t i = 0; i < unicode_expected[test_ix].size(); ++i) { CHECK_EQ(unicode_expected[test_ix][i], buffer[i]); @@ -8684,7 +8708,8 @@ THREADED_TEST(OverlongSequencesAndSurrogates) { {0x58, 0xFFFD, 0xFFFD, 0xFFFD, 0x59}, }; CHECK_EQ(unicode_expected.size(), arraysize(cases)); - TestUtf8DecodingAgainstReference(cases, unicode_expected); + TestUtf8DecodingAgainstReference(context->GetIsolate(), cases, + unicode_expected); } THREADED_TEST(Utf16) { @@ -10592,7 +10617,7 @@ THREADED_TEST(GlobalObjectInstanceProperties) { v8::FunctionTemplate::New(isolate, InstanceFunctionCallback)); - // The script to check how Crankshaft compiles missing global function + // The script to check how TurboFan compiles missing global function // invocations. function g is not defined and should throw on call. const char* script = "function wrapper(call) {" @@ -10639,8 +10664,8 @@ THREADED_TEST(ObjectGetOwnPropertyNames) { v8::Isolate* isolate = context->GetIsolate(); v8::HandleScope handle_scope(isolate); - v8::Local<v8::Object> value = - v8::Local<v8::Object>::Cast(v8::StringObject::New(v8_str("test"))); + v8::Local<v8::Object> value = v8::Local<v8::Object>::Cast( + v8::StringObject::New(CcTest::isolate(), v8_str("test"))); v8::Local<v8::Array> properties; CHECK(value @@ -15366,6 +15391,9 @@ THREADED_TEST(GetPropertyNames) { v8::HandleScope scope(isolate); v8::Local<v8::Value> result = CompileRun( "var result = {0: 0, 1: 1, a: 2, b: 3};" + "result[2**32] = '4294967296';" + "result[2**32-1] = '4294967295';" + "result[2**32-2] = '4294967294';" "result[Symbol('symbol')] = true;" "result.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};" "result;"); @@ -15376,8 +15404,10 @@ THREADED_TEST(GetPropertyNames) { v8::Local<v8::Array> properties = object->GetPropertyNames(context.local()).ToLocalChecked(); - const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"}; - CheckStringArray(isolate, properties, 8, expected_properties1); + const char* expected_properties1[] = {"0", "1", "4294967294", "a", + "b", "4294967296", "4294967295", "2", + "3", "c", "d"}; + CheckStringArray(isolate, properties, 11, expected_properties1); properties = object @@ -15385,7 +15415,7 @@ THREADED_TEST(GetPropertyNames) { v8::KeyCollectionMode::kIncludePrototypes, default_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - CheckStringArray(isolate, properties, 8, expected_properties1); + CheckStringArray(isolate, properties, 11, expected_properties1); properties = object ->GetPropertyNames(context.local(), @@ -15393,10 +15423,11 @@ THREADED_TEST(GetPropertyNames) { include_symbols_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr, - "2", "3", "c", "d"}; - CheckStringArray(isolate, properties, 9, expected_properties1_1); - CheckIsSymbolAt(isolate, properties, 4, "symbol"); + const char* expected_properties1_1[] = { + "0", "1", "4294967294", "a", "b", "4294967296", + "4294967295", nullptr, "2", "3", "c", "d"}; + CheckStringArray(isolate, properties, 12, expected_properties1_1); + CheckIsSymbolAt(isolate, properties, 7, "symbol"); properties = object @@ -15404,8 +15435,9 @@ THREADED_TEST(GetPropertyNames) { v8::KeyCollectionMode::kIncludePrototypes, default_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties2[] = {"a", "b", "c", "d"}; - CheckStringArray(isolate, properties, 4, expected_properties2); + const char* expected_properties2[] = {"a", "b", "4294967296", + "4294967295", "c", "d"}; + CheckStringArray(isolate, properties, 6, expected_properties2); properties = object ->GetPropertyNames(context.local(), @@ -15413,43 +15445,48 @@ THREADED_TEST(GetPropertyNames) { include_symbols_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"}; - CheckStringArray(isolate, properties, 5, expected_properties2_1); - CheckIsSymbolAt(isolate, properties, 2, "symbol"); + const char* expected_properties2_1[] = { + "a", "b", "4294967296", "4294967295", nullptr, "c", "d"}; + CheckStringArray(isolate, properties, 7, expected_properties2_1); + CheckIsSymbolAt(isolate, properties, 4, "symbol"); properties = object ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, default_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties3[] = {"0", "1", "a", "b"}; - CheckStringArray(isolate, properties, 4, expected_properties3); + const char* expected_properties3[] = { + "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", + }; + CheckStringArray(isolate, properties, 7, expected_properties3); properties = object ->GetPropertyNames( context.local(), v8::KeyCollectionMode::kOwnOnly, include_symbols_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr}; - CheckStringArray(isolate, properties, 5, expected_properties3_1); - CheckIsSymbolAt(isolate, properties, 4, "symbol"); + const char* expected_properties3_1[] = { + "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr}; + CheckStringArray(isolate, properties, 8, expected_properties3_1); + CheckIsSymbolAt(isolate, properties, 7, "symbol"); properties = object ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, default_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties4[] = {"a", "b"}; - CheckStringArray(isolate, properties, 2, expected_properties4); + const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"}; + CheckStringArray(isolate, properties, 4, expected_properties4); properties = object ->GetPropertyNames( context.local(), v8::KeyCollectionMode::kOwnOnly, include_symbols_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties4_1[] = {"a", "b", nullptr}; - CheckStringArray(isolate, properties, 3, expected_properties4_1); - CheckIsSymbolAt(isolate, properties, 2, "symbol"); + const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295", + nullptr}; + CheckStringArray(isolate, properties, 5, expected_properties4_1); + CheckIsSymbolAt(isolate, properties, 4, "symbol"); } THREADED_TEST(ProxyGetPropertyNames) { @@ -15458,6 +15495,9 @@ THREADED_TEST(ProxyGetPropertyNames) { v8::HandleScope scope(isolate); v8::Local<v8::Value> result = CompileRun( "var target = {0: 0, 1: 1, a: 2, b: 3};" + "target[2**32] = '4294967296';" + "target[2**32-1] = '4294967295';" + "target[2**32-2] = '4294967294';" "target[Symbol('symbol')] = true;" "target.__proto__ = {__proto__:null, 2: 4, 3: 5, c: 6, d: 7};" "var result = new Proxy(target, {});" @@ -15469,8 +15509,10 @@ THREADED_TEST(ProxyGetPropertyNames) { v8::Local<v8::Array> properties = object->GetPropertyNames(context.local()).ToLocalChecked(); - const char* expected_properties1[] = {"0", "1", "a", "b", "2", "3", "c", "d"}; - CheckStringArray(isolate, properties, 8, expected_properties1); + const char* expected_properties1[] = {"0", "1", "4294967294", "a", + "b", "4294967296", "4294967295", "2", + "3", "c", "d"}; + CheckStringArray(isolate, properties, 11, expected_properties1); properties = object @@ -15478,7 +15520,7 @@ THREADED_TEST(ProxyGetPropertyNames) { v8::KeyCollectionMode::kIncludePrototypes, default_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - CheckStringArray(isolate, properties, 8, expected_properties1); + CheckStringArray(isolate, properties, 11, expected_properties1); properties = object ->GetPropertyNames(context.local(), @@ -15486,10 +15528,11 @@ THREADED_TEST(ProxyGetPropertyNames) { include_symbols_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties1_1[] = {"0", "1", "a", "b", nullptr, - "2", "3", "c", "d"}; - CheckStringArray(isolate, properties, 9, expected_properties1_1); - CheckIsSymbolAt(isolate, properties, 4, "symbol"); + const char* expected_properties1_1[] = { + "0", "1", "4294967294", "a", "b", "4294967296", + "4294967295", nullptr, "2", "3", "c", "d"}; + CheckStringArray(isolate, properties, 12, expected_properties1_1); + CheckIsSymbolAt(isolate, properties, 7, "symbol"); properties = object @@ -15497,8 +15540,9 @@ THREADED_TEST(ProxyGetPropertyNames) { v8::KeyCollectionMode::kIncludePrototypes, default_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties2[] = {"a", "b", "c", "d"}; - CheckStringArray(isolate, properties, 4, expected_properties2); + const char* expected_properties2[] = {"a", "b", "4294967296", + "4294967295", "c", "d"}; + CheckStringArray(isolate, properties, 6, expected_properties2); properties = object ->GetPropertyNames(context.local(), @@ -15506,43 +15550,47 @@ THREADED_TEST(ProxyGetPropertyNames) { include_symbols_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties2_1[] = {"a", "b", nullptr, "c", "d"}; - CheckStringArray(isolate, properties, 5, expected_properties2_1); - CheckIsSymbolAt(isolate, properties, 2, "symbol"); + const char* expected_properties2_1[] = { + "a", "b", "4294967296", "4294967295", nullptr, "c", "d"}; + CheckStringArray(isolate, properties, 7, expected_properties2_1); + CheckIsSymbolAt(isolate, properties, 4, "symbol"); properties = object ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, default_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties3[] = {"0", "1", "a", "b"}; - CheckStringArray(isolate, properties, 4, expected_properties3); + const char* expected_properties3[] = {"0", "1", "4294967294", "a", + "b", "4294967296", "4294967295"}; + CheckStringArray(isolate, properties, 7, expected_properties3); properties = object ->GetPropertyNames( context.local(), v8::KeyCollectionMode::kOwnOnly, include_symbols_filter, v8::IndexFilter::kIncludeIndices) .ToLocalChecked(); - const char* expected_properties3_1[] = {"0", "1", "a", "b", nullptr}; - CheckStringArray(isolate, properties, 5, expected_properties3_1); - CheckIsSymbolAt(isolate, properties, 4, "symbol"); + const char* expected_properties3_1[] = { + "0", "1", "4294967294", "a", "b", "4294967296", "4294967295", nullptr}; + CheckStringArray(isolate, properties, 8, expected_properties3_1); + CheckIsSymbolAt(isolate, properties, 7, "symbol"); properties = object ->GetPropertyNames(context.local(), v8::KeyCollectionMode::kOwnOnly, default_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties4[] = {"a", "b"}; - CheckStringArray(isolate, properties, 2, expected_properties4); + const char* expected_properties4[] = {"a", "b", "4294967296", "4294967295"}; + CheckStringArray(isolate, properties, 4, expected_properties4); properties = object ->GetPropertyNames( context.local(), v8::KeyCollectionMode::kOwnOnly, include_symbols_filter, v8::IndexFilter::kSkipIndices) .ToLocalChecked(); - const char* expected_properties4_1[] = {"a", "b", nullptr}; - CheckStringArray(isolate, properties, 3, expected_properties4_1); - CheckIsSymbolAt(isolate, properties, 2, "symbol"); + const char* expected_properties4_1[] = {"a", "b", "4294967296", "4294967295", + nullptr}; + CheckStringArray(isolate, properties, 5, expected_properties4_1); + CheckIsSymbolAt(isolate, properties, 4, "symbol"); } THREADED_TEST(AccessChecksReenabledCorrectly) { @@ -15739,6 +15787,7 @@ class UC16VectorResource : public v8::String::ExternalStringResource { static void MorphAString(i::String* string, OneByteVectorResource* one_byte_resource, UC16VectorResource* uc16_resource) { + i::Isolate* isolate = CcTest::i_isolate(); CHECK(i::StringShape(string).IsExternal()); i::ReadOnlyRoots roots(CcTest::heap()); if (string->IsOneByteRepresentation()) { @@ -15748,14 +15797,16 @@ static void MorphAString(i::String* string, string->set_map(roots.external_string_map()); i::ExternalTwoByteString* morphed = i::ExternalTwoByteString::cast(string); - morphed->set_resource(uc16_resource); + CcTest::heap()->UpdateExternalString(morphed, string->length(), 0); + morphed->SetResource(isolate, uc16_resource); } else { // Check old map is not internalized or long. CHECK(string->map() == roots.external_string_map()); // Morph external string to be one-byte string. string->set_map(roots.external_one_byte_string_map()); i::ExternalOneByteString* morphed = i::ExternalOneByteString::cast(string); - morphed->set_resource(one_byte_resource); + CcTest::heap()->UpdateExternalString(morphed, string->length(), 0); + morphed->SetResource(isolate, one_byte_resource); } } @@ -15771,6 +15822,7 @@ THREADED_TEST(MorphCompositeStringTest) { LocalContext env; i::Factory* factory = CcTest::i_isolate()->factory(); v8::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = CcTest::i_isolate(); v8::HandleScope scope(isolate); OneByteVectorResource one_byte_resource( i::Vector<const char>(c_string, i::StrLength(c_string))); @@ -15805,7 +15857,7 @@ THREADED_TEST(MorphCompositeStringTest) { v8_compile("cons")->Run(env.local()).ToLocalChecked().As<String>(); CHECK_EQ(128, cons->Utf8Length(isolate)); int nchars = -1; - CHECK_EQ(129, cons->WriteUtf8(utf_buffer, -1, &nchars)); + CHECK_EQ(129, cons->WriteUtf8(isolate, utf_buffer, -1, &nchars)); CHECK_EQ(128, nchars); CHECK_EQ(0, strcmp( utf_buffer, @@ -15844,13 +15896,13 @@ THREADED_TEST(MorphCompositeStringTest) { // This avoids the GC from trying to free a stack allocated resource. if (ilhs->IsExternalOneByteString()) - i::ExternalOneByteString::cast(ilhs)->set_resource(nullptr); + i::ExternalOneByteString::cast(ilhs)->SetResource(i_isolate, nullptr); else - i::ExternalTwoByteString::cast(ilhs)->set_resource(nullptr); + i::ExternalTwoByteString::cast(ilhs)->SetResource(i_isolate, nullptr); if (irhs->IsExternalOneByteString()) - i::ExternalOneByteString::cast(irhs)->set_resource(nullptr); + i::ExternalOneByteString::cast(irhs)->SetResource(i_isolate, nullptr); else - i::ExternalTwoByteString::cast(irhs)->set_resource(nullptr); + i::ExternalTwoByteString::cast(irhs)->SetResource(i_isolate, nullptr); } i::DeleteArray(two_byte_string); } @@ -17342,60 +17394,67 @@ void AnalyzeStackInNativeCode(const v8::FunctionCallbackInfo<v8::Value>& args) { CHECK_EQ(args.Length(), 1); v8::Local<v8::Context> context = args.GetIsolate()->GetCurrentContext(); + v8::Isolate* isolate = args.GetIsolate(); int testGroup = args[0]->Int32Value(context).FromJust(); if (testGroup == kOverviewTest) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 10, v8::StackTrace::kOverview); CHECK_EQ(4, stackTrace->GetFrameCount()); checkStackFrame(origin, "bar", 2, 10, false, false, - stackTrace->GetFrame(0)); - checkStackFrame(origin, "foo", 6, 3, false, true, stackTrace->GetFrame(1)); + stackTrace->GetFrame(args.GetIsolate(), 0)); + checkStackFrame(origin, "foo", 6, 3, false, true, + stackTrace->GetFrame(isolate, 1)); // This is the source string inside the eval which has the call to foo. - checkStackFrame(nullptr, "", 1, 1, true, false, stackTrace->GetFrame(2)); + checkStackFrame(nullptr, "", 1, 1, true, false, + stackTrace->GetFrame(isolate, 2)); // The last frame is an anonymous function which has the initial eval call. - checkStackFrame(origin, "", 8, 7, false, false, stackTrace->GetFrame(3)); + checkStackFrame(origin, "", 8, 7, false, false, + stackTrace->GetFrame(isolate, 3)); } else if (testGroup == kDetailedTest) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 10, v8::StackTrace::kDetailed); CHECK_EQ(4, stackTrace->GetFrameCount()); checkStackFrame(origin, "bat", 4, 22, false, false, - stackTrace->GetFrame(0)); + stackTrace->GetFrame(isolate, 0)); checkStackFrame(origin, "baz", 8, 3, false, true, - stackTrace->GetFrame(1)); + stackTrace->GetFrame(isolate, 1)); bool is_eval = true; // This is the source string inside the eval which has the call to baz. - checkStackFrame(nullptr, "", 1, 1, is_eval, false, stackTrace->GetFrame(2)); + checkStackFrame(nullptr, "", 1, 1, is_eval, false, + stackTrace->GetFrame(isolate, 2)); // The last frame is an anonymous function which has the initial eval call. - checkStackFrame(origin, "", 10, 1, false, false, stackTrace->GetFrame(3)); + checkStackFrame(origin, "", 10, 1, false, false, + stackTrace->GetFrame(isolate, 3)); } else if (testGroup == kFunctionName) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); checkStackFrame(nullptr, "function.name", 3, 1, true, false, - stackTrace->GetFrame(0)); + stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kDisplayName) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); checkStackFrame(nullptr, "function.displayName", 3, 1, true, false, - stackTrace->GetFrame(0)); + stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kFunctionNameAndDisplayName) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); checkStackFrame(nullptr, "function.displayName", 3, 1, true, false, - stackTrace->GetFrame(0)); + stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kDisplayNameIsNotString) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); checkStackFrame(nullptr, "function.name", 3, 1, true, false, - stackTrace->GetFrame(0)); + stackTrace->GetFrame(isolate, 0)); } else if (testGroup == kFunctionNameIsNotString) { v8::Local<v8::StackTrace> stackTrace = v8::StackTrace::CurrentStackTrace( args.GetIsolate(), 5, v8::StackTrace::kOverview); CHECK_EQ(3, stackTrace->GetFrameCount()); - checkStackFrame(nullptr, "", 3, 1, true, false, stackTrace->GetFrame(0)); + checkStackFrame(nullptr, "", 3, 1, true, false, + stackTrace->GetFrame(isolate, 0)); } } @@ -17498,9 +17557,9 @@ static void StackTraceForUncaughtExceptionListener( v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); CHECK_EQ(2, stack_trace->GetFrameCount()); checkStackFrame("origin", "foo", 2, 3, false, false, - stack_trace->GetFrame(0)); + stack_trace->GetFrame(message->GetIsolate(), 0)); checkStackFrame("origin", "bar", 5, 3, false, false, - stack_trace->GetFrame(1)); + stack_trace->GetFrame(message->GetIsolate(), 1)); } @@ -17629,16 +17688,18 @@ TEST(ErrorLevelWarning) { static void StackTraceFunctionNameListener(v8::Local<v8::Message> message, v8::Local<Value>) { v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); + v8::Isolate* isolate = message->GetIsolate(); CHECK_EQ(5, stack_trace->GetFrameCount()); checkStackFrame("origin", "foo:0", 4, 7, false, false, - stack_trace->GetFrame(0)); + stack_trace->GetFrame(isolate, 0)); checkStackFrame("origin", "foo:1", 5, 27, false, false, - stack_trace->GetFrame(1)); + stack_trace->GetFrame(isolate, 1)); checkStackFrame("origin", "foo", 5, 27, false, false, - stack_trace->GetFrame(2)); + stack_trace->GetFrame(isolate, 2)); checkStackFrame("origin", "foo", 5, 27, false, false, - stack_trace->GetFrame(3)); - checkStackFrame("origin", "", 1, 14, false, false, stack_trace->GetFrame(4)); + stack_trace->GetFrame(isolate, 3)); + checkStackFrame("origin", "", 1, 14, false, false, + stack_trace->GetFrame(isolate, 4)); } @@ -17684,7 +17745,8 @@ static void RethrowStackTraceHandler(v8::Local<v8::Message> message, CHECK_EQ(3, frame_count); int line_number[] = {1, 2, 5}; for (int i = 0; i < frame_count; i++) { - CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber()); + CHECK_EQ(line_number[i], + stack_trace->GetFrame(message->GetIsolate(), i)->GetLineNumber()); } } @@ -17728,7 +17790,8 @@ static void RethrowPrimitiveStackTraceHandler(v8::Local<v8::Message> message, CHECK_EQ(2, frame_count); int line_number[] = {3, 7}; for (int i = 0; i < frame_count; i++) { - CHECK_EQ(line_number[i], stack_trace->GetFrame(i)->GetLineNumber()); + CHECK_EQ(line_number[i], + stack_trace->GetFrame(message->GetIsolate(), i)->GetLineNumber()); } } @@ -17763,7 +17826,7 @@ static void RethrowExistingStackTraceHandler(v8::Local<v8::Message> message, v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); CHECK(!stack_trace.IsEmpty()); CHECK_EQ(1, stack_trace->GetFrameCount()); - CHECK_EQ(1, stack_trace->GetFrame(0)->GetLineNumber()); + CHECK_EQ(1, stack_trace->GetFrame(message->GetIsolate(), 0)->GetLineNumber()); } @@ -17790,7 +17853,7 @@ static void RethrowBogusErrorStackTraceHandler(v8::Local<v8::Message> message, v8::Local<v8::StackTrace> stack_trace = message->GetStackTrace(); CHECK(!stack_trace.IsEmpty()); CHECK_EQ(1, stack_trace->GetFrameCount()); - CHECK_EQ(2, stack_trace->GetFrame(0)->GetLineNumber()); + CHECK_EQ(2, stack_trace->GetFrame(message->GetIsolate(), 0)->GetLineNumber()); } @@ -17845,13 +17908,14 @@ void PromiseRejectCallback(v8::PromiseRejectMessage reject_message) { if (!stack_trace.IsEmpty()) { promise_reject_frame_count = stack_trace->GetFrameCount(); if (promise_reject_frame_count > 0) { - CHECK(stack_trace->GetFrame(0) + CHECK(stack_trace->GetFrame(CcTest::isolate(), 0) ->GetScriptName() ->Equals(context, v8_str("pro")) .FromJust()); promise_reject_line_number = - stack_trace->GetFrame(0)->GetLineNumber(); - promise_reject_column_number = stack_trace->GetFrame(0)->GetColumn(); + stack_trace->GetFrame(CcTest::isolate(), 0)->GetLineNumber(); + promise_reject_column_number = + stack_trace->GetFrame(CcTest::isolate(), 0)->GetColumn(); } else { promise_reject_line_number = -1; promise_reject_column_number = -1; @@ -18309,7 +18373,7 @@ void AnalyzeStackOfEvalWithSourceURL( v8::Local<v8::String> url = v8_str("eval_url"); for (int i = 0; i < 3; i++) { v8::Local<v8::String> name = - stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); + stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL(); CHECK(!name.IsEmpty()); CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()); } @@ -18355,7 +18419,8 @@ void AnalyzeScriptIdInStack( args.GetIsolate(), 10, v8::StackTrace::kScriptId); CHECK_EQ(2, stackTrace->GetFrameCount()); for (int i = 0; i < 2; i++) { - scriptIdInStack[i] = stackTrace->GetFrame(i)->GetScriptId(); + scriptIdInStack[i] = + stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptId(); } } @@ -18391,7 +18456,7 @@ void AnalyzeStackOfInlineScriptWithSourceURL( v8::Local<v8::String> url = v8_str("source_url"); for (int i = 0; i < 3; i++) { v8::Local<v8::String> name = - stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); + stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL(); CHECK(!name.IsEmpty()); CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()); } @@ -18806,7 +18871,7 @@ void AnalyzeStackOfDynamicScriptWithSourceURL( v8::Local<v8::String> url = v8_str("source_url"); for (int i = 0; i < 3; i++) { v8::Local<v8::String> name = - stackTrace->GetFrame(i)->GetScriptNameOrSourceURL(); + stackTrace->GetFrame(args.GetIsolate(), i)->GetScriptNameOrSourceURL(); CHECK(!name.IsEmpty()); CHECK(url->Equals(args.GetIsolate()->GetCurrentContext(), name).FromJust()); } @@ -19072,7 +19137,8 @@ TEST(GetHeapSpaceStatistics) { // Force allocation in LO_SPACE so that every space has non-zero size. v8::internal::Isolate* i_isolate = reinterpret_cast<v8::internal::Isolate*>(isolate); - (void)i_isolate->factory()->TryNewFixedArray(512 * 1024); + auto unused = i_isolate->factory()->TryNewFixedArray(512 * 1024); + USE(unused); isolate->GetHeapStatistics(&heap_statistics); @@ -19620,7 +19686,7 @@ THREADED_TEST(ScriptOrigin) { v8::HandleScope scope(isolate); Local<v8::PrimitiveArray> array(v8::PrimitiveArray::New(isolate, 1)); Local<v8::Symbol> symbol(v8::Symbol::New(isolate)); - array->Set(0, symbol); + array->Set(isolate, 0, symbol); v8::ScriptOrigin origin = v8::ScriptOrigin( v8_str("test"), v8::Integer::New(env->GetIsolate(), 1), @@ -19648,7 +19714,7 @@ THREADED_TEST(ScriptOrigin) { CHECK(script_origin_f.Options().IsSharedCrossOrigin()); CHECK(script_origin_f.Options().IsOpaque()); printf("is name = %d\n", script_origin_f.SourceMapUrl()->IsUndefined()); - CHECK(script_origin_f.HostDefinedOptions()->Get(0)->IsSymbol()); + CHECK(script_origin_f.HostDefinedOptions()->Get(isolate, 0)->IsSymbol()); CHECK_EQ(0, strcmp("http://sourceMapUrl", *v8::String::Utf8Value(env->GetIsolate(), @@ -19666,7 +19732,7 @@ THREADED_TEST(ScriptOrigin) { CHECK_EQ(0, strcmp("http://sourceMapUrl", *v8::String::Utf8Value(env->GetIsolate(), script_origin_g.SourceMapUrl()))); - CHECK(script_origin_g.HostDefinedOptions()->Get(0)->IsSymbol()); + CHECK(script_origin_g.HostDefinedOptions()->Get(isolate, 0)->IsSymbol()); } @@ -20470,7 +20536,8 @@ THREADED_TEST(TwoByteStringInOneByteCons) { CHECK_EQ(static_cast<int32_t>('e'), reresult->Int32Value(context.local()).FromJust()); // This avoids the GC from trying to free stack allocated resources. - i::Handle<i::ExternalTwoByteString>::cast(flat_string)->set_resource(nullptr); + i::Handle<i::ExternalTwoByteString>::cast(flat_string) + ->SetResource(i_isolate, nullptr); } @@ -20506,11 +20573,11 @@ TEST(ContainsOnlyOneByte) { Local<String> left = base; Local<String> right = base; for (int i = 0; i < 1000; i++) { - left = String::Concat(base, left); - right = String::Concat(right, base); + left = String::Concat(isolate, base, left); + right = String::Concat(isolate, right, base); } - Local<String> balanced = String::Concat(left, base); - balanced = String::Concat(balanced, right); + Local<String> balanced = String::Concat(isolate, left, base); + balanced = String::Concat(isolate, balanced, right); Local<String> cons_strings[] = {left, balanced, right}; Local<String> two_byte = String::NewExternalTwoByte( @@ -20522,9 +20589,9 @@ TEST(ContainsOnlyOneByte) { string = cons_strings[i]; CHECK(string->IsOneByte() && string->ContainsOnlyOneByte()); // Test left and right concatentation. - string = String::Concat(two_byte, cons_strings[i]); + string = String::Concat(isolate, two_byte, cons_strings[i]); CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); - string = String::Concat(cons_strings[i], two_byte); + string = String::Concat(isolate, cons_strings[i], two_byte); CHECK(!string->IsOneByte() && string->ContainsOnlyOneByte()); } // Set bits in different positions @@ -21921,12 +21988,11 @@ THREADED_TEST(ReadOnlyIndexedProperties) { static int CountLiveMapsInMapCache(i::Context* context) { - i::FixedArray* map_cache = i::FixedArray::cast(context->map_cache()); + i::WeakFixedArray* map_cache = i::WeakFixedArray::cast(context->map_cache()); int length = map_cache->length(); int count = 0; for (int i = 0; i < length; i++) { - i::Object* value = map_cache->get(i); - if (value->IsWeakCell() && !i::WeakCell::cast(value)->cleared()) count++; + if (map_cache->Get(i)->IsWeakHeapObject()) count++; } return count; } @@ -22752,7 +22818,7 @@ void Recompile(Args... args) { stub.GetCode(); } -void RecompileICStubs(i::Isolate* isolate) { +void RecompileICStubs() { // BUG(5784): We had a list of IC stubs here to recompile. These are now // builtins and we can't compile them again (easily). Bug 5784 tracks // our progress in finding another way to do this. @@ -22805,7 +22871,6 @@ void TestStubCache(bool primary) { create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.counter_lookup_callback = LookupCounter; v8::Isolate* isolate = v8::Isolate::New(create_params); - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { v8::Isolate::Scope isolate_scope(isolate); @@ -22814,7 +22879,7 @@ void TestStubCache(bool primary) { // Enforce recompilation of IC stubs that access megamorphic stub cache // to respect enabled native code counters and stub cache test flags. - RecompileICStubs(i_isolate); + RecompileICStubs(); int initial_probes = probes_counter; int initial_misses = misses_counter; @@ -23745,7 +23810,6 @@ TEST(AccessCheckInIC) { create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.counter_lookup_callback = LookupCounter; v8::Isolate* isolate = v8::Isolate::New(create_params); - i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); { v8::Isolate::Scope isolate_scope(isolate); @@ -23754,7 +23818,7 @@ TEST(AccessCheckInIC) { // Enforce recompilation of IC stubs that access megamorphic stub cache // to respect enabled native code counters and stub cache test flags. - RecompileICStubs(i_isolate); + RecompileICStubs(); // Create an ObjectTemplate for global objects and install access // check callbacks that will block access. @@ -25010,8 +25074,12 @@ TEST(ResolvedPromiseReFulfill) { LocalContext context; v8::Isolate* isolate = context->GetIsolate(); v8::HandleScope scope(isolate); - v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo"); - v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar"); + v8::Local<v8::String> value1 = + v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal) + .ToLocalChecked(); + v8::Local<v8::String> value2 = + v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal) + .ToLocalChecked(); v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(context.local()).ToLocalChecked(); @@ -25037,8 +25105,12 @@ TEST(RejectedPromiseReFulfill) { LocalContext context; v8::Isolate* isolate = context->GetIsolate(); v8::HandleScope scope(isolate); - v8::Local<v8::String> value1 = v8::String::NewFromUtf8(isolate, "foo"); - v8::Local<v8::String> value2 = v8::String::NewFromUtf8(isolate, "bar"); + v8::Local<v8::String> value1 = + v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal) + .ToLocalChecked(); + v8::Local<v8::String> value2 = + v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal) + .ToLocalChecked(); v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(context.local()).ToLocalChecked(); @@ -26325,14 +26397,16 @@ TEST(InvalidCodeCacheData) { TEST(StringConcatOverflow) { v8::V8::Initialize(); - v8::HandleScope scope(CcTest::isolate()); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); RandomLengthOneByteResource* r = new RandomLengthOneByteResource(i::String::kMaxLength); v8::Local<v8::String> str = - v8::String::NewExternalOneByte(CcTest::isolate(), r).ToLocalChecked(); + v8::String::NewExternalOneByte(isolate, r).ToLocalChecked(); CHECK(!str.IsEmpty()); - v8::TryCatch try_catch(CcTest::isolate()); - v8::Local<v8::String> result = v8::String::Concat(str, str); + v8::TryCatch try_catch(isolate); + v8::Local<v8::String> result = v8::String::Concat(isolate, str, str); + v8::String::Concat(CcTest::isolate(), str, str); CHECK(result.IsEmpty()); CHECK(!try_catch.HasCaught()); } @@ -26350,7 +26424,7 @@ TEST(TurboAsmDisablesNeuter) { " function load() { return MEM32[0] | 0; }" " return { load: load };" "}" - "var buffer = new ArrayBuffer(1024);" + "var buffer = new ArrayBuffer(4096);" "var module = Module(this, {}, buffer);" "%OptimizeFunctionOnNextCall(module.load);" "module.load();" @@ -26366,7 +26440,7 @@ TEST(TurboAsmDisablesNeuter) { " function store() { MEM32[0] = 0; }" " return { store: store };" "}" - "var buffer = new ArrayBuffer(1024);" + "var buffer = new ArrayBuffer(4096);" "var module = Module(this, {}, buffer);" "%OptimizeFunctionOnNextCall(module.store);" "module.store();" @@ -27981,7 +28055,9 @@ v8::MaybeLocal<v8::Promise> HostImportModuleDynamicallyCallbackResolve( String::Utf8Value referrer_utf8( context->GetIsolate(), Local<String>::Cast(referrer->GetResourceName())); CHECK_EQ(0, strcmp("www.google.com", *referrer_utf8)); - CHECK(referrer->GetHostDefinedOptions()->Get(0)->IsSymbol()); + CHECK(referrer->GetHostDefinedOptions() + ->Get(context->GetIsolate(), 0) + ->IsSymbol()); CHECK(!specifier.IsEmpty()); String::Utf8Value specifier_utf8(context->GetIsolate(), specifier); @@ -28151,41 +28227,41 @@ TEST(PrimitiveArray) { CHECK_EQ(length, array->Length()); for (int i = 0; i < length; i++) { - Local<v8::Primitive> item = array->Get(i); + Local<v8::Primitive> item = array->Get(isolate, i); CHECK(item->IsUndefined()); } Local<v8::Symbol> symbol(v8::Symbol::New(isolate)); - array->Set(0, symbol); - CHECK(array->Get(0)->IsSymbol()); + array->Set(isolate, 0, symbol); + CHECK(array->Get(isolate, 0)->IsSymbol()); Local<v8::String> string = v8::String::NewFromUtf8(isolate, "test", v8::NewStringType::kInternalized) .ToLocalChecked(); - array->Set(1, string); - CHECK(array->Get(0)->IsSymbol()); - CHECK(array->Get(1)->IsString()); + array->Set(isolate, 1, string); + CHECK(array->Get(isolate, 0)->IsSymbol()); + CHECK(array->Get(isolate, 1)->IsString()); Local<v8::Number> num = v8::Number::New(env->GetIsolate(), 3.1415926); - array->Set(2, num); - CHECK(array->Get(0)->IsSymbol()); - CHECK(array->Get(1)->IsString()); - CHECK(array->Get(2)->IsNumber()); + array->Set(isolate, 2, num); + CHECK(array->Get(isolate, 0)->IsSymbol()); + CHECK(array->Get(isolate, 1)->IsString()); + CHECK(array->Get(isolate, 2)->IsNumber()); v8::Local<v8::Boolean> f = v8::False(isolate); - array->Set(3, f); - CHECK(array->Get(0)->IsSymbol()); - CHECK(array->Get(1)->IsString()); - CHECK(array->Get(2)->IsNumber()); - CHECK(array->Get(3)->IsBoolean()); + array->Set(isolate, 3, f); + CHECK(array->Get(isolate, 0)->IsSymbol()); + CHECK(array->Get(isolate, 1)->IsString()); + CHECK(array->Get(isolate, 2)->IsNumber()); + CHECK(array->Get(isolate, 3)->IsBoolean()); v8::Local<v8::Primitive> n = v8::Null(isolate); - array->Set(4, n); - CHECK(array->Get(0)->IsSymbol()); - CHECK(array->Get(1)->IsString()); - CHECK(array->Get(2)->IsNumber()); - CHECK(array->Get(3)->IsBoolean()); - CHECK(array->Get(4)->IsNull()); + array->Set(isolate, 4, n); + CHECK(array->Get(isolate, 0)->IsSymbol()); + CHECK(array->Get(isolate, 1)->IsString()); + CHECK(array->Get(isolate, 2)->IsNumber()); + CHECK(array->Get(isolate, 3)->IsBoolean()); + CHECK(array->Get(isolate, 4)->IsNull()); } TEST(PersistentValueMap) { @@ -28204,22 +28280,123 @@ TEST(PersistentValueMap) { map.Set("key", value); } -TEST(WasmStreamingAbort) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - v8::WasmModuleObjectBuilderStreaming streaming(isolate); - streaming.Abort(v8::Object::New(isolate)); - CHECK_EQ(streaming.GetPromise()->State(), v8::Promise::kRejected); +namespace { + +bool wasm_streaming_callback_got_called = false; +bool wasm_streaming_data_got_collected = false; + +void WasmStreamingTestFinalizer(const v8::WeakCallbackInfo<void>& data) { + CHECK(!wasm_streaming_data_got_collected); + wasm_streaming_data_got_collected = true; + i::JSObject** p = reinterpret_cast<i::JSObject**>(data.GetParameter()); + i::GlobalHandles::Destroy(reinterpret_cast<i::Object**>(p)); +} + +void WasmStreamingCallbackTestCallbackIsCalled( + const v8::FunctionCallbackInfo<v8::Value>& args) { + CHECK(!wasm_streaming_callback_got_called); + wasm_streaming_callback_got_called = true; + + i::Handle<i::Object> global_handle = + reinterpret_cast<i::Isolate*>(args.GetIsolate()) + ->global_handles() + ->Create(*v8::Utils::OpenHandle(*args.Data())); + i::GlobalHandles::MakeWeak(global_handle.location(), global_handle.location(), + WasmStreamingTestFinalizer, + v8::WeakCallbackType::kParameter); +} + +void WasmStreamingCallbackTestOnBytesReceived( + const v8::FunctionCallbackInfo<v8::Value>& args) { + std::shared_ptr<v8::WasmStreaming> streaming = + v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data()); + + // The first bytes of the WebAssembly magic word. + const uint8_t bytes[]{0x00, 0x61, 0x73}; + streaming->OnBytesReceived(bytes, arraysize(bytes)); +} + +void WasmStreamingCallbackTestFinishWithSuccess( + const v8::FunctionCallbackInfo<v8::Value>& args) { + std::shared_ptr<v8::WasmStreaming> streaming = + v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data()); + // The bytes of a minimal WebAssembly module. + const uint8_t bytes[]{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00}; + streaming->OnBytesReceived(bytes, arraysize(bytes)); + streaming->Finish(); +} + +void WasmStreamingCallbackTestFinishWithFailure( + const v8::FunctionCallbackInfo<v8::Value>& args) { + std::shared_ptr<v8::WasmStreaming> streaming = + v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data()); + streaming->Finish(); +} + +void WasmStreamingCallbackTestAbortWithReject( + const v8::FunctionCallbackInfo<v8::Value>& args) { + std::shared_ptr<v8::WasmStreaming> streaming = + v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data()); + streaming->Abort(v8::Object::New(args.GetIsolate())); +} + +void WasmStreamingCallbackTestAbortNoReject( + const v8::FunctionCallbackInfo<v8::Value>& args) { + std::shared_ptr<v8::WasmStreaming> streaming = + v8::WasmStreaming::Unpack(args.GetIsolate(), args.Data()); + streaming->Abort({}); } -TEST(WasmStreamingAbortNoReject) { +void TestWasmStreaming(v8::WasmStreamingCallback callback, + v8::Promise::PromiseState expected_state) { + CcTest::isolate()->SetWasmStreamingCallback(callback); LocalContext env; v8::Isolate* isolate = env->GetIsolate(); v8::HandleScope scope(isolate); - v8::WasmModuleObjectBuilderStreaming streaming(isolate); - streaming.Abort({}); - CHECK_EQ(streaming.GetPromise()->State(), v8::Promise::kPending); + + // Call {WebAssembly.compileStreaming} with {null} as parameter. The parameter + // is only really processed by the embedder, so for this test the value is + // irrelevant. + v8::Local<v8::Promise> promise = v8::Local<v8::Promise>::Cast( + CompileRun("WebAssembly.compileStreaming(null)")); + + EmptyMessageQueues(isolate); + CHECK_EQ(expected_state, promise->State()); +} + +} // namespace + +TEST(WasmStreamingCallback) { + TestWasmStreaming(WasmStreamingCallbackTestCallbackIsCalled, + v8::Promise::kPending); + CHECK(wasm_streaming_callback_got_called); + CcTest::CollectAllAvailableGarbage(); + CHECK(wasm_streaming_data_got_collected); +} + +TEST(WasmStreamingOnBytesReceived) { + TestWasmStreaming(WasmStreamingCallbackTestOnBytesReceived, + v8::Promise::kPending); +} + +TEST(WasmStreamingFinishWithSuccess) { + TestWasmStreaming(WasmStreamingCallbackTestFinishWithSuccess, + v8::Promise::kFulfilled); +} + +TEST(WasmStreamingFinishWithFailure) { + TestWasmStreaming(WasmStreamingCallbackTestFinishWithFailure, + v8::Promise::kRejected); +} + +TEST(WasmStreamingAbortWithReject) { + TestWasmStreaming(WasmStreamingCallbackTestAbortWithReject, + v8::Promise::kRejected); +} + +TEST(WasmStreamingAbortWithoutReject) { + TestWasmStreaming(WasmStreamingCallbackTestAbortNoReject, + v8::Promise::kPending); } enum class AtomicsWaitCallbackAction { @@ -28545,3 +28722,42 @@ TEST(BigIntAPI) { CHECK_EQ(word_count, 2); } } + +namespace { + +bool wasm_threads_enabled_value = false; + +bool MockWasmThreadsEnabledCallback(Local<Context>) { + return wasm_threads_enabled_value; +} + +} // namespace + +TEST(TestSetWasmThreadsEnabledCallback) { + LocalContext env; + v8::Isolate* isolate = env->GetIsolate(); + i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); + v8::HandleScope scope(isolate); + v8::Local<Context> context = Context::New(CcTest::isolate()); + i::Handle<i::Context> i_context = v8::Utils::OpenHandle(*context); + + // {Isolate::AreWasmThreadsEnabled} calls the callback set by the embedder if + // such a callback exists. Otherwise it returns + // {FLAG_experimental_wasm_threads}. First we test that the flag is returned + // correctly if no callback is set. Then we test that the flag is ignored if + // the callback is set. + + i::FLAG_experimental_wasm_threads = false; + CHECK(!i_isolate->AreWasmThreadsEnabled(i_context)); + + i::FLAG_experimental_wasm_threads = true; + CHECK(i_isolate->AreWasmThreadsEnabled(i_context)); + + isolate->SetWasmThreadsEnabledCallback(MockWasmThreadsEnabledCallback); + wasm_threads_enabled_value = false; + CHECK(!i_isolate->AreWasmThreadsEnabled(i_context)); + + wasm_threads_enabled_value = true; + i::FLAG_experimental_wasm_threads = false; + CHECK(i_isolate->AreWasmThreadsEnabled(i_context)); +} diff --git a/deps/v8/test/cctest/test-assembler-arm.cc b/deps/v8/test/cctest/test-assembler-arm.cc index 6ed918a533..7e1bb402fc 100644 --- a/deps/v8/test/cctest/test-assembler-arm.cc +++ b/deps/v8/test/cctest/test-assembler-arm.cc @@ -1082,14 +1082,14 @@ TEST(13) { __ vmov(d21, Double(16.0)); __ mov(r1, Operand(372106121)); __ mov(r2, Operand(1079146608)); - __ vmov(d22, VmovIndexLo, r1); - __ vmov(d22, VmovIndexHi, r2); + __ vmov(NeonS32, d22, 0, r1); + __ vmov(NeonS32, d22, 1, r2); __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, i)))); __ vstm(ia_w, r4, d20, d22); // Move d22 into low and high. - __ vmov(r4, VmovIndexLo, d22); + __ vmov(NeonS32, r4, d22, 0); __ str(r4, MemOperand(r0, offsetof(T, low))); - __ vmov(r4, VmovIndexHi, d22); + __ vmov(NeonS32, r4, d22, 1); __ str(r4, MemOperand(r0, offsetof(T, high))); __ ldm(ia_w, sp, r4.bit() | pc.bit()); diff --git a/deps/v8/test/cctest/test-assembler-arm64.cc b/deps/v8/test/cctest/test-assembler-arm64.cc index c9a13c0b1c..c0f8e171c7 100644 --- a/deps/v8/test/cctest/test-assembler-arm64.cc +++ b/deps/v8/test/cctest/test-assembler-arm64.cc @@ -45,6 +45,7 @@ #include "src/macro-assembler.h" #include "test/cctest/cctest.h" #include "test/cctest/test-utils-arm64.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { @@ -129,13 +130,11 @@ static void InitializeVM() { new Decoder<DispatchingDecoderVisitor>(); \ Simulator simulator(decoder); \ PrintDisassembler* pdis = nullptr; \ - RegisterDump core; - -/* if (Cctest::trace_sim()) { \ - pdis = new PrintDisassembler(stdout); \ - decoder.PrependVisitor(pdis); \ - } \ - */ + RegisterDump core; \ + if (i::FLAG_trace_sim) { \ + pdis = new PrintDisassembler(stdout); \ + decoder->PrependVisitor(pdis); \ + } // Reset the assembler and simulator, so that instructions can be generated, // but don't actually emit any code. This can be used by tests that need to @@ -198,7 +197,6 @@ static void InitializeVM() { #define RUN() \ MakeAssemblerBufferExecutable(buf, allocated); \ - Assembler::FlushICache(buf, masm.SizeOfGeneratedCode()); \ { \ void (*test_function)(void); \ memcpy(&test_function, &buf, sizeof(buf)); \ @@ -1714,7 +1712,7 @@ TEST(adr_far) { INIT_V8(); int max_range = 1 << (Instruction::ImmPCRelRangeBitwidth - 1); - SETUP_SIZE(max_range + 1000 * kInstructionSize); + SETUP_SIZE(max_range + 1000 * kInstrSize); Label done, fail; Label test_near, near_forward, near_backward; @@ -1744,7 +1742,7 @@ TEST(adr_far) { __ Orr(x0, x0, 1 << 3); __ B(&done); - for (unsigned i = 0; i < max_range / kInstructionSize + 1; ++i) { + for (int i = 0; i < max_range / kInstrSize + 1; ++i) { if (i % 100 == 0) { // If we do land in this code, we do not want to execute so many nops // before reaching the end of test (especially if tracing is activated). @@ -1906,7 +1904,7 @@ TEST(branch_to_reg) { RUN(); - CHECK_EQUAL_64(core.xreg(3) + kInstructionSize, x0); + CHECK_EQUAL_64(core.xreg(3) + kInstrSize, x0); CHECK_EQUAL_64(42, x1); CHECK_EQUAL_64(84, x2); @@ -2048,7 +2046,7 @@ TEST(far_branch_backward) { std::max(Instruction::ImmBranchRange(CompareBranchType), Instruction::ImmBranchRange(CondBranchType))); - SETUP_SIZE(max_range + 1000 * kInstructionSize); + SETUP_SIZE(max_range + 1000 * kInstrSize); START(); @@ -2074,7 +2072,7 @@ TEST(far_branch_backward) { // Generate enough code to overflow the immediate range of the three types of // branches below. - for (unsigned i = 0; i < max_range / kInstructionSize + 1; ++i) { + for (int i = 0; i < max_range / kInstrSize + 1; ++i) { if (i % 100 == 0) { // If we do land in this code, we do not want to execute so many nops // before reaching the end of test (especially if tracing is activated). @@ -2095,7 +2093,7 @@ TEST(far_branch_backward) { // For each out-of-range branch instructions, at least two instructions should // have been generated. - CHECK_GE(7 * kInstructionSize, __ SizeOfCodeGeneratedSince(&test_tbz)); + CHECK_GE(7 * kInstrSize, __ SizeOfCodeGeneratedSince(&test_tbz)); __ Bind(&fail); __ Mov(x1, 0); @@ -2122,7 +2120,7 @@ TEST(far_branch_simple_veneer) { std::max(Instruction::ImmBranchRange(CompareBranchType), Instruction::ImmBranchRange(CondBranchType))); - SETUP_SIZE(max_range + 1000 * kInstructionSize); + SETUP_SIZE(max_range + 1000 * kInstrSize); START(); @@ -2144,7 +2142,7 @@ TEST(far_branch_simple_veneer) { // Generate enough code to overflow the immediate range of the three types of // branches below. - for (unsigned i = 0; i < max_range / kInstructionSize + 1; ++i) { + for (int i = 0; i < max_range / kInstrSize + 1; ++i) { if (i % 100 == 0) { // If we do land in this code, we do not want to execute so many nops // before reaching the end of test (especially if tracing is activated). @@ -2198,7 +2196,7 @@ TEST(far_branch_veneer_link_chain) { std::max(Instruction::ImmBranchRange(CompareBranchType), Instruction::ImmBranchRange(CondBranchType))); - SETUP_SIZE(max_range + 1000 * kInstructionSize); + SETUP_SIZE(max_range + 1000 * kInstrSize); START(); @@ -2239,7 +2237,7 @@ TEST(far_branch_veneer_link_chain) { // Generate enough code to overflow the immediate range of the three types of // branches below. - for (unsigned i = 0; i < max_range / kInstructionSize + 1; ++i) { + for (int i = 0; i < max_range / kInstrSize + 1; ++i) { if (i % 100 == 0) { // If we do land in this code, we do not want to execute so many nops // before reaching the end of test (especially if tracing is activated). @@ -2288,7 +2286,7 @@ TEST(far_branch_veneer_broken_link_chain) { int max_range = Instruction::ImmBranchRange(TestBranchType); int inter_range = max_range / 2 + max_range / 10; - SETUP_SIZE(3 * inter_range + 1000 * kInstructionSize); + SETUP_SIZE(3 * inter_range + 1000 * kInstrSize); START(); @@ -2305,7 +2303,7 @@ TEST(far_branch_veneer_broken_link_chain) { __ Mov(x0, 1); __ B(&far_target); - for (unsigned i = 0; i < inter_range / kInstructionSize; ++i) { + for (int i = 0; i < inter_range / kInstrSize; ++i) { if (i % 100 == 0) { // Do not allow generating veneers. They should not be needed. __ b(&fail); @@ -2319,7 +2317,7 @@ TEST(far_branch_veneer_broken_link_chain) { __ Mov(x0, 2); __ Tbz(x10, 7, &far_target); - for (unsigned i = 0; i < inter_range / kInstructionSize; ++i) { + for (int i = 0; i < inter_range / kInstrSize; ++i) { if (i % 100 == 0) { // Do not allow generating veneers. They should not be needed. __ b(&fail); @@ -2334,7 +2332,7 @@ TEST(far_branch_veneer_broken_link_chain) { __ Mov(x0, 3); __ Tbz(x10, 7, &far_target); - for (unsigned i = 0; i < inter_range / kInstructionSize; ++i) { + for (int i = 0; i < inter_range / kInstrSize; ++i) { if (i % 100 == 0) { // Allow generating veneers. __ B(&fail); @@ -6742,65 +6740,72 @@ TEST(ldr_literal) { #ifdef DEBUG // These tests rely on functions available in debug mode. -enum LiteralPoolEmitOption { NoJumpRequired, JumpRequired }; +enum LiteralPoolEmitOutcome { EmitExpected, NoEmitExpected }; -static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option, - bool expect_dump) { - CHECK_GT(range_, 0); - SETUP_SIZE(range_ + 1024); +static void LdrLiteralRangeHelper(size_t range, LiteralPoolEmitOutcome outcome, + size_t prepadding = 0) { + SETUP_SIZE(static_cast<int>(range + 1024)); - Label label_1, label_2; - - size_t range = static_cast<size_t>(range_); size_t code_size = 0; - size_t pool_guard_size; - - if (option == NoJumpRequired) { - // Space for an explicit branch. - pool_guard_size = kInstructionSize; - } else { - pool_guard_size = 0; - } + const size_t pool_entries = 2; + const size_t kEntrySize = 8; START(); // Force a pool dump so the pool starts off empty. __ CheckConstPool(true, true); CHECK_CONSTANT_POOL_SIZE(0); + // Emit prepadding to influence alignment of the pool; we don't count this + // into code size. + for (size_t i = 0; i < prepadding; ++i) __ Nop(); + LoadLiteral(&masm, x0, 0x1234567890ABCDEFUL); LoadLiteral(&masm, x1, 0xABCDEF1234567890UL); - CHECK_CONSTANT_POOL_SIZE(16); - - code_size += 2 * kInstructionSize; + code_size += 2 * kInstrSize; + CHECK_CONSTANT_POOL_SIZE(pool_entries * kEntrySize); // Check that the requested range (allowing space for a branch over the pool) // can be handled by this test. - CHECK_LE(code_size + pool_guard_size, range); + CHECK_LE(code_size, range); + + auto PoolSizeAt = [pool_entries](int pc_offset) { + // To determine padding, consider the size of the prologue of the pool, + // and the jump around the pool, which we always need. + size_t prologue_size = 2 * kInstrSize + kInstrSize; + size_t pc = pc_offset + prologue_size; + const size_t padding = IsAligned(pc, 8) ? 0 : 4; + return prologue_size + pool_entries * kEntrySize + padding; + }; - // Emit NOPs up to 'range', leaving space for the pool guard. - while ((code_size + pool_guard_size + kInstructionSize) < range) { + int pc_offset_before_emission = -1; + // Emit NOPs up to 'range'. + while (code_size < range) { + pc_offset_before_emission = __ pc_offset() + kInstrSize; __ Nop(); - code_size += kInstructionSize; - } - - // Emit the guard sequence before the literal pool. - if (option == NoJumpRequired) { - __ B(&label_1); - code_size += kInstructionSize; + code_size += kInstrSize; } + CHECK_EQ(code_size, range); - // The next instruction will trigger pool emission when expect_dump is true. - CHECK_EQ(code_size, range - kInstructionSize); - CHECK_CONSTANT_POOL_SIZE(16); - - // Possibly generate a literal pool. - __ Nop(); - - __ Bind(&label_1); - if (expect_dump) { + if (outcome == EmitExpected) { CHECK_CONSTANT_POOL_SIZE(0); + // Check that the size of the emitted constant pool is as expected. + size_t pool_size = PoolSizeAt(pc_offset_before_emission); + CHECK_EQ(pc_offset_before_emission + pool_size, __ pc_offset()); + byte* pool_start = buf + pc_offset_before_emission; + Instruction* branch = reinterpret_cast<Instruction*>(pool_start); + CHECK(branch->IsImmBranch()); + CHECK_EQ(pool_size, branch->ImmPCOffset()); + Instruction* marker = + reinterpret_cast<Instruction*>(pool_start + kInstrSize); + CHECK(marker->IsLdrLiteralX()); + const size_t padding = + IsAligned(pc_offset_before_emission + kInstrSize, kEntrySize) ? 0 : 1; + CHECK_EQ(pool_entries * 2 + 1 + padding, marker->ImmLLiteral()); + } else { - CHECK_CONSTANT_POOL_SIZE(16); + CHECK_EQ(outcome, NoEmitExpected); + CHECK_CONSTANT_POOL_SIZE(pool_entries * kEntrySize); + CHECK_EQ(pc_offset_before_emission, __ pc_offset()); } // Force a pool flush to check that a second pool functions correctly. @@ -6810,7 +6815,7 @@ static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option, // These loads should be after the pool (and will require a new one). LoadLiteral(&masm, x4, 0x34567890ABCDEF12UL); LoadLiteral(&masm, x5, 0xABCDEF0123456789UL); - CHECK_CONSTANT_POOL_SIZE(16); + CHECK_CONSTANT_POOL_SIZE(pool_entries * kEntrySize); END(); RUN(); @@ -6824,35 +6829,32 @@ static void LdrLiteralRangeHelper(int range_, LiteralPoolEmitOption option, TEARDOWN(); } -TEST(ldr_literal_range_1) { +TEST(ldr_literal_range_max_dist_emission_1) { INIT_V8(); LdrLiteralRangeHelper(MacroAssembler::GetApproxMaxDistToConstPoolForTesting(), - NoJumpRequired, true); + EmitExpected); } - -TEST(ldr_literal_range_2) { +TEST(ldr_literal_range_max_dist_emission_2) { INIT_V8(); - LdrLiteralRangeHelper( - MacroAssembler::GetApproxMaxDistToConstPoolForTesting() - - kInstructionSize, - NoJumpRequired, false); + LdrLiteralRangeHelper(MacroAssembler::GetApproxMaxDistToConstPoolForTesting(), + EmitExpected, 1); } - -TEST(ldr_literal_range_3) { +TEST(ldr_literal_range_max_dist_no_emission_1) { INIT_V8(); - LdrLiteralRangeHelper(MacroAssembler::GetCheckConstPoolIntervalForTesting(), - JumpRequired, false); + LdrLiteralRangeHelper( + MacroAssembler::GetApproxMaxDistToConstPoolForTesting() - kInstrSize, + NoEmitExpected); } - -TEST(ldr_literal_range_4) { +TEST(ldr_literal_range_max_dist_no_emission_2) { INIT_V8(); LdrLiteralRangeHelper( - MacroAssembler::GetCheckConstPoolIntervalForTesting() - kInstructionSize, - JumpRequired, false); + MacroAssembler::GetApproxMaxDistToConstPoolForTesting() - kInstrSize, + NoEmitExpected, 1); } + #endif TEST(add_sub_imm) { @@ -15251,7 +15253,7 @@ TEST(pool_size) { } __ RecordVeneerPool(masm.pc_offset(), veneer_pool_size); - for (unsigned i = 0; i < veneer_pool_size / kInstructionSize; ++i) { + for (unsigned i = 0; i < veneer_pool_size / kInstrSize; ++i) { __ nop(); } @@ -15289,7 +15291,7 @@ TEST(jump_tables_forward) { const int kNumCases = 512; INIT_V8(); - SETUP_SIZE(kNumCases * 5 * kInstructionSize + 8192); + SETUP_SIZE(kNumCases * 5 * kInstrSize + 8192); START(); int32_t values[kNumCases]; @@ -15353,7 +15355,7 @@ TEST(jump_tables_backward) { const int kNumCases = 512; INIT_V8(); - SETUP_SIZE(kNumCases * 5 * kInstructionSize + 8192); + SETUP_SIZE(kNumCases * 5 * kInstrSize + 8192); START(); int32_t values[kNumCases]; diff --git a/deps/v8/test/cctest/test-assembler-mips.cc b/deps/v8/test/cctest/test-assembler-mips.cc index 4538e8ac78..4b625c2b53 100644 --- a/deps/v8/test/cctest/test-assembler-mips.cc +++ b/deps/v8/test/cctest/test-assembler-mips.cc @@ -3164,16 +3164,13 @@ TEST(jump_tables1) { Label done; { __ BlockTrampolinePoolFor(kNumCases + 7); - PredictableCodeSizeScope predictable( - &assm, (kNumCases + 7) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, (kNumCases + 7) * kInstrSize); - __ bal(&here); + __ nal(); __ nop(); - __ bind(&here); __ sll(at, a0, 2); __ addu(at, at, ra); - __ lw(at, MemOperand(at, 5 * Assembler::kInstrSize)); + __ lw(at, MemOperand(at, 5 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -3243,16 +3240,13 @@ TEST(jump_tables2) { __ bind(&dispatch); { __ BlockTrampolinePoolFor(kNumCases + 7); - PredictableCodeSizeScope predictable( - &assm, (kNumCases + 7) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, (kNumCases + 7) * kInstrSize); - __ bal(&here); + __ nal(); __ nop(); - __ bind(&here); __ sll(at, a0, 2); __ addu(at, at, ra); - __ lw(at, MemOperand(at, 5 * Assembler::kInstrSize)); + __ lw(at, MemOperand(at, 5 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -3319,16 +3313,13 @@ TEST(jump_tables3) { __ bind(&dispatch); { __ BlockTrampolinePoolFor(kNumCases + 7); - PredictableCodeSizeScope predictable( - &assm, (kNumCases + 7) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, (kNumCases + 7) * kInstrSize); - __ bal(&here); + __ nal(); __ nop(); - __ bind(&here); __ sll(at, a0, 2); __ addu(at, at, ra); - __ lw(at, MemOperand(at, 5 * Assembler::kInstrSize)); + __ lw(at, MemOperand(at, 5 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -4811,8 +4802,8 @@ uint32_t run_jic(int16_t offset) { __ beq(v0, t1, &stop_execution); __ nop(); - __ bal(&get_program_counter); // t0 <- program counter - __ nop(); + __ nal(); // t0 <- program counter + __ mov(t0, ra); __ jic(t0, offset); __ addiu(v0, v0, 0x100); @@ -4823,11 +4814,6 @@ uint32_t run_jic(int16_t offset) { __ jr(ra); __ nop(); - __ bind(&get_program_counter); - __ mov(t0, ra); - __ jr(ra); - __ nop(); - __ bind(&stop_execution); __ pop(ra); __ jr(ra); @@ -5158,8 +5144,8 @@ uint32_t run_jialc(int16_t offset) { // Block 3 (Main) __ bind(&main_block); - __ bal(&get_program_counter); // t0 <- program counter - __ nop(); + __ nal(); // t0 <- program counter + __ mov(t0, ra); __ jialc(t0, offset); __ addiu(v0, v0, 0x4); __ pop(ra); @@ -5178,11 +5164,6 @@ uint32_t run_jialc(int16_t offset) { __ jr(ra); __ nop(); - __ bind(&get_program_counter); - __ mov(t0, ra); - __ jr(ra); - __ nop(); - CodeDesc desc; assm.GetCode(isolate, &desc); @@ -5557,7 +5538,7 @@ TEST(Trampoline) { MacroAssembler assm(isolate, nullptr, 0, v8::internal::CodeObjectRequired::kYes); Label done; - size_t nr_calls = kMaxBranchOffset / (2 * Instruction::kInstrSize) + 2; + size_t nr_calls = kMaxBranchOffset / (2 * kInstrSize) + 2; for (size_t i = 0; i < nr_calls; ++i) { __ BranchShort(&done, eq, a0, Operand(a1)); @@ -5715,8 +5696,7 @@ uint32_t run_Subu(uint32_t imm, int32_t num_instr) { Label code_start; __ bind(&code_start); __ Subu(v0, zero_reg, imm); - CHECK_EQ(assm.SizeOfCodeGeneratedSince(&code_start), - num_instr * Assembler::kInstrSize); + CHECK_EQ(assm.SizeOfCodeGeneratedSince(&code_start), num_instr * kInstrSize); __ jr(ra); __ nop(); diff --git a/deps/v8/test/cctest/test-assembler-mips64.cc b/deps/v8/test/cctest/test-assembler-mips64.cc index bd96375c48..785ffa2fa3 100644 --- a/deps/v8/test/cctest/test-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-assembler-mips64.cc @@ -3293,15 +3293,13 @@ TEST(jump_tables1) { Label done; { __ BlockTrampolinePoolFor(kNumCases * 2 + 6); - PredictableCodeSizeScope predictable( - &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, + (kNumCases * 2 + 6) * kInstrSize); - __ bal(&here); + __ nal(); __ dsll(at, a0, 3); // In delay slot. - __ bind(&here); __ daddu(at, at, ra); - __ Ld(at, MemOperand(at, 4 * Assembler::kInstrSize)); + __ Ld(at, MemOperand(at, 4 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -3373,15 +3371,13 @@ TEST(jump_tables2) { __ bind(&dispatch); { __ BlockTrampolinePoolFor(kNumCases * 2 + 6); - PredictableCodeSizeScope predictable( - &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, + (kNumCases * 2 + 6) * kInstrSize); - __ bal(&here); + __ nal(); __ dsll(at, a0, 3); // In delay slot. - __ bind(&here); __ daddu(at, at, ra); - __ Ld(at, MemOperand(at, 4 * Assembler::kInstrSize)); + __ Ld(at, MemOperand(at, 4 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -3453,15 +3449,13 @@ TEST(jump_tables3) { __ bind(&dispatch); { __ BlockTrampolinePoolFor(kNumCases * 2 + 6); - PredictableCodeSizeScope predictable( - &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize); - Label here; + PredictableCodeSizeScope predictable(&assm, + (kNumCases * 2 + 6) * kInstrSize); - __ bal(&here); + __ nal(); __ dsll(at, a0, 3); // In delay slot. - __ bind(&here); __ daddu(at, at, ra); - __ Ld(at, MemOperand(at, 4 * Assembler::kInstrSize)); + __ Ld(at, MemOperand(at, 4 * kInstrSize)); __ jr(at); __ nop(); for (int i = 0; i < kNumCases; ++i) { @@ -5437,8 +5431,8 @@ uint64_t run_jic(int16_t offset) { __ beq(v0, t1, &stop_execution); __ nop(); - __ bal(&get_program_counter); // t0 <- program counter - __ nop(); + __ nal(); // t0 <- program counter + __ mov(t0, ra); __ jic(t0, offset); __ addiu(v0, v0, 0x100); @@ -5449,11 +5443,6 @@ uint64_t run_jic(int16_t offset) { __ jr(ra); __ nop(); - __ bind(&get_program_counter); - __ mov(t0, ra); - __ jr(ra); - __ nop(); - __ bind(&stop_execution); __ pop(ra); __ jr(ra); @@ -5784,8 +5773,8 @@ uint64_t run_jialc(int16_t offset) { // Block 3 (Main) __ bind(&main_block); - __ bal(&get_program_counter); // t0 <- program counter - __ nop(); + __ nal(); // t0 <- program counter + __ mov(t0, ra); __ jialc(t0, offset); __ addiu(v0, v0, 0x4); __ pop(ra); @@ -5804,11 +5793,6 @@ uint64_t run_jialc(int16_t offset) { __ jr(ra); __ nop(); - __ bind(&get_program_counter); - __ mov(t0, ra); - __ jr(ra); - __ nop(); - CodeDesc desc; assm.GetCode(isolate, &desc); @@ -6263,7 +6247,7 @@ TEST(Trampoline) { MacroAssembler assm(isolate, nullptr, 0, v8::internal::CodeObjectRequired::kYes); Label done; - size_t nr_calls = kMaxBranchOffset / (2 * Instruction::kInstrSize) + 2; + size_t nr_calls = kMaxBranchOffset / (2 * kInstrSize) + 2; for (size_t i = 0; i < nr_calls; ++i) { __ BranchShort(&done, eq, a0, Operand(a1)); diff --git a/deps/v8/test/cctest/test-assembler-x64.cc b/deps/v8/test/cctest/test-assembler-x64.cc index eb172ee2aa..7ecef4429c 100644 --- a/deps/v8/test/cctest/test-assembler-x64.cc +++ b/deps/v8/test/cctest/test-assembler-x64.cc @@ -39,6 +39,7 @@ #include "src/ostreams.h" #include "src/simulator.h" #include "test/cctest/cctest.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-code-stub-assembler.cc b/deps/v8/test/cctest/test-code-stub-assembler.cc index ba6af617bb..d7cdb39933 100644 --- a/deps/v8/test/cctest/test-code-stub-assembler.cc +++ b/deps/v8/test/cctest/test-code-stub-assembler.cc @@ -4,7 +4,7 @@ #include <cmath> -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/utils/random-number-generator.h" #include "src/builtins/builtins-promise-gen.h" #include "src/builtins/builtins-string-gen.h" @@ -13,9 +13,12 @@ #include "src/code-stub-assembler.h" #include "src/compiler/node.h" #include "src/debug/debug.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" +#include "src/objects/js-array-buffer-inl.h" +#include "src/objects/js-array-inl.h" #include "src/objects/promise-inl.h" #include "test/cctest/compiler/code-assembler-tester.h" #include "test/cctest/compiler/function-tester.h" @@ -2377,7 +2380,8 @@ TEST(CreatePromiseResolvingFunctions) { std::tie(resolve, reject) = m.CreatePromiseResolvingFunctions( promise, m.BooleanConstant(false), native_context); Node* const kSize = m.IntPtrConstant(2); - Node* const arr = m.AllocateFixedArray(PACKED_ELEMENTS, kSize); + TNode<FixedArray> const arr = + m.Cast(m.AllocateFixedArray(PACKED_ELEMENTS, kSize)); m.StoreFixedArrayElement(arr, 0, resolve); m.StoreFixedArrayElement(arr, 1, reject); m.Return(arr); @@ -3451,6 +3455,54 @@ TEST(IsDoubleElementsKind) { 0); } +TEST(TestCallBuiltinInlineTrampoline) { + Isolate* isolate(CcTest::InitIsolateOnce()); + const int kNumParams = 1; + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); + + const int kContextOffset = 2; + Node* str = m.Parameter(0); + Node* context = m.Parameter(kNumParams + kContextOffset); + + Node* index = m.SmiConstant(2); + + m.Return(m.CallStub(Builtins::CallableFor(isolate, Builtins::kStringRepeat), + context, str, index)); + AssemblerOptions options = AssemblerOptions::Default(isolate); + options.inline_offheap_trampolines = true; + options.use_pc_relative_calls_and_jumps = false; + options.isolate_independent_code = false; + FunctionTester ft(asm_tester.GenerateCode(options), kNumParams); + MaybeHandle<Object> result = ft.Call(MakeString("abcdef")); + CHECK(String::Equals(isolate, MakeString("abcdefabcdef"), + Handle<String>::cast(result.ToHandleChecked()))); +} + +TEST(TestCallBuiltinIndirectLoad) { + Isolate* isolate(CcTest::InitIsolateOnce()); + const int kNumParams = 1; + CodeAssemblerTester asm_tester(isolate, kNumParams); + CodeStubAssembler m(asm_tester.state()); + + const int kContextOffset = 2; + Node* str = m.Parameter(0); + Node* context = m.Parameter(kNumParams + kContextOffset); + + Node* index = m.SmiConstant(2); + + m.Return(m.CallStub(Builtins::CallableFor(isolate, Builtins::kStringRepeat), + context, str, index)); + AssemblerOptions options = AssemblerOptions::Default(isolate); + options.inline_offheap_trampolines = false; + options.use_pc_relative_calls_and_jumps = false; + options.isolate_independent_code = true; + FunctionTester ft(asm_tester.GenerateCode(options), kNumParams); + MaybeHandle<Object> result = ft.Call(MakeString("abcdef")); + CHECK(String::Equals(isolate, MakeString("abcdefabcdef"), + Handle<String>::cast(result.ToHandleChecked()))); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-code-stubs-arm.cc b/deps/v8/test/cctest/test-code-stubs-arm.cc index 8247afeb49..a5746a7f8e 100644 --- a/deps/v8/test/cctest/test-code-stubs-arm.cc +++ b/deps/v8/test/cctest/test-code-stubs-arm.cc @@ -37,6 +37,7 @@ #include "src/v8.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { @@ -116,7 +117,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(isolate, &desc); MakeAssemblerBufferExecutable(buffer, allocated); - Assembler::FlushICache(buffer, allocated); return (reinterpret_cast<ConvertDToIFunc>( reinterpret_cast<intptr_t>(buffer))); } diff --git a/deps/v8/test/cctest/test-code-stubs-arm64.cc b/deps/v8/test/cctest/test-code-stubs-arm64.cc index 43bea1d910..cb20931a5d 100644 --- a/deps/v8/test/cctest/test-code-stubs-arm64.cc +++ b/deps/v8/test/cctest/test-code-stubs-arm64.cc @@ -37,6 +37,7 @@ #include "src/simulator.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { @@ -128,7 +129,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(isolate, &desc); MakeAssemblerBufferExecutable(buffer, allocated); - Assembler::FlushICache(buffer, allocated); return (reinterpret_cast<ConvertDToIFunc>( reinterpret_cast<intptr_t>(buffer))); } diff --git a/deps/v8/test/cctest/test-code-stubs-ia32.cc b/deps/v8/test/cctest/test-code-stubs-ia32.cc index 77a2254245..54f53e57c3 100644 --- a/deps/v8/test/cctest/test-code-stubs-ia32.cc +++ b/deps/v8/test/cctest/test-code-stubs-ia32.cc @@ -38,6 +38,7 @@ #include "src/objects-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-code-stubs-mips.cc b/deps/v8/test/cctest/test-code-stubs-mips.cc index f57459ead0..ed1798160b 100644 --- a/deps/v8/test/cctest/test-code-stubs-mips.cc +++ b/deps/v8/test/cctest/test-code-stubs-mips.cc @@ -39,6 +39,7 @@ #include "src/simulator.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { @@ -129,7 +130,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(isolate, &desc); MakeAssemblerBufferExecutable(buffer, allocated); - Assembler::FlushICache(buffer, allocated); return (reinterpret_cast<ConvertDToIFunc>( reinterpret_cast<intptr_t>(buffer))); } diff --git a/deps/v8/test/cctest/test-code-stubs-mips64.cc b/deps/v8/test/cctest/test-code-stubs-mips64.cc index 6605f82422..3518e722c7 100644 --- a/deps/v8/test/cctest/test-code-stubs-mips64.cc +++ b/deps/v8/test/cctest/test-code-stubs-mips64.cc @@ -39,6 +39,7 @@ #include "src/simulator.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { @@ -126,7 +127,6 @@ ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate, CodeDesc desc; masm.GetCode(isolate, &desc); MakeAssemblerBufferExecutable(buffer, allocated); - Assembler::FlushICache(buffer, allocated); return (reinterpret_cast<ConvertDToIFunc>( reinterpret_cast<intptr_t>(buffer))); } diff --git a/deps/v8/test/cctest/test-code-stubs-x64.cc b/deps/v8/test/cctest/test-code-stubs-x64.cc index 327d45d16c..c55b2e2b1e 100644 --- a/deps/v8/test/cctest/test-code-stubs-x64.cc +++ b/deps/v8/test/cctest/test-code-stubs-x64.cc @@ -37,6 +37,7 @@ #include "src/register-configuration.h" #include "test/cctest/cctest.h" #include "test/cctest/test-code-stubs.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-compiler.cc b/deps/v8/test/cctest/test-compiler.cc index 34868cd4c4..63904e086f 100644 --- a/deps/v8/test/cctest/test-compiler.cc +++ b/deps/v8/test/cctest/test-compiler.cc @@ -30,7 +30,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/compiler.h" #include "src/disasm.h" #include "src/heap/factory.h" @@ -66,8 +66,9 @@ static Handle<JSFunction> Compile(const char* source) { CStrVector(source)).ToHandleChecked(); Handle<SharedFunctionInfo> shared = Compiler::GetSharedFunctionInfoForScript( - source_code, Compiler::ScriptDetails(), v8::ScriptOriginOptions(), - nullptr, nullptr, v8::ScriptCompiler::kNoCompileOptions, + isolate, source_code, Compiler::ScriptDetails(), + v8::ScriptOriginOptions(), nullptr, nullptr, + v8::ScriptCompiler::kNoCompileOptions, ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE) .ToHandleChecked(); return isolate->factory()->NewFunctionFromSharedFunctionInfo( @@ -658,7 +659,7 @@ TEST(CompileFunctionInContextScriptOrigin) { v8::Exception::GetStackTrace(try_catch.Exception()); CHECK(!stack.IsEmpty()); CHECK_GT(stack->GetFrameCount(), 0); - v8::Local<v8::StackFrame> frame = stack->GetFrame(0); + v8::Local<v8::StackFrame> frame = stack->GetFrame(CcTest::isolate(), 0); CHECK_EQ(23, frame->GetLineNumber()); CHECK_EQ(42 + strlen("throw "), static_cast<unsigned>(frame->GetColumn())); } diff --git a/deps/v8/test/cctest/test-cpu-profiler.cc b/deps/v8/test/cctest/test-cpu-profiler.cc index f74bdf1ede..75af3f6d98 100644 --- a/deps/v8/test/cctest/test-cpu-profiler.cc +++ b/deps/v8/test/cctest/test-cpu-profiler.cc @@ -33,7 +33,7 @@ #include "src/v8.h" #include "include/v8-profiler.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/platform/platform.h" #include "src/deoptimizer.h" #include "src/libplatform/default-platform.h" diff --git a/deps/v8/test/cctest/test-debug.cc b/deps/v8/test/cctest/test-debug.cc index 7430fbf06b..f678b8ca6f 100644 --- a/deps/v8/test/cctest/test-debug.cc +++ b/deps/v8/test/cctest/test-debug.cc @@ -29,7 +29,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/compilation-cache.h" #include "src/debug/debug-interface.h" #include "src/debug/debug.h" @@ -191,10 +191,6 @@ class DebugEventCounter : public v8::debug::DebugDelegate { public: void BreakProgramRequested(v8::Local<v8::Context>, const std::vector<v8::debug::BreakpointId>&) { - v8::internal::Debug* debug = CcTest::i_isolate()->debug(); - // When hitting a debug event listener there must be a break set. - CHECK_NE(debug->break_id(), 0); - break_point_hit_count++; // Perform a full deoptimization when the specified number of // breaks have been hit. @@ -217,10 +213,6 @@ class DebugEventBreakPointCollectGarbage : public v8::debug::DebugDelegate { public: void BreakProgramRequested(v8::Local<v8::Context>, const std::vector<v8::debug::BreakpointId>&) { - v8::internal::Debug* debug = CcTest::i_isolate()->debug(); - // When hitting a debug event listener there must be a break set. - CHECK_NE(debug->break_id(), 0); - // Perform a garbage collection when break point is hit and continue. Based // on the number of break points hit either scavenge or mark compact // collector is used. @@ -241,10 +233,6 @@ class DebugEventBreak : public v8::debug::DebugDelegate { public: void BreakProgramRequested(v8::Local<v8::Context>, const std::vector<v8::debug::BreakpointId>&) { - v8::internal::Debug* debug = CcTest::i_isolate()->debug(); - // When hitting a debug event listener there must be a break set. - CHECK_NE(debug->break_id(), 0); - // Count the number of breaks. break_point_hit_count++; @@ -271,9 +259,6 @@ class DebugEventBreakMax : public v8::debug::DebugDelegate { const std::vector<v8::debug::BreakpointId>&) { v8::Isolate* v8_isolate = CcTest::isolate(); v8::internal::Isolate* isolate = CcTest::i_isolate(); - v8::internal::Debug* debug = isolate->debug(); - // When hitting a debug event listener there must be a break set. - CHECK_NE(debug->break_id(), 0); if (break_point_hit_count < max_break_point_hit_count) { // Count the number of breaks. break_point_hit_count++; diff --git a/deps/v8/test/cctest/test-deoptimization.cc b/deps/v8/test/cctest/test-deoptimization.cc index f0d62caff8..0d86f135ea 100644 --- a/deps/v8/test/cctest/test-deoptimization.cc +++ b/deps/v8/test/cctest/test-deoptimization.cc @@ -29,7 +29,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/platform/platform.h" #include "src/compilation-cache.h" #include "src/debug/debug.h" diff --git a/deps/v8/test/cctest/test-dictionary.cc b/deps/v8/test/cctest/test-dictionary.cc index 9f921558dd..1101ec06eb 100644 --- a/deps/v8/test/cctest/test-dictionary.cc +++ b/deps/v8/test/cctest/test-dictionary.cc @@ -28,7 +28,6 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -#include "src/api.h" #include "src/builtins/builtins-constructor.h" #include "src/debug/debug.h" #include "src/execution.h" @@ -195,7 +194,7 @@ class ObjectHashTableTest: public ObjectHashTable { } int lookup(int key) { - Handle<Object> key_obj(Smi::FromInt(key), GetIsolate()); + Handle<Object> key_obj(Smi::FromInt(key), CcTest::i_isolate()); return Smi::ToInt(Lookup(key_obj)); } diff --git a/deps/v8/test/cctest/test-disasm-arm.cc b/deps/v8/test/cctest/test-disasm-arm.cc index d1cebe8138..877ae6665f 100644 --- a/deps/v8/test/cctest/test-disasm-arm.cc +++ b/deps/v8/test/cctest/test-disasm-arm.cc @@ -58,7 +58,7 @@ bool DisassembleAndCompare(byte* begin, UseRegex use_regex, std::vector<std::string> expected_disassembly = {expected_strings...}; size_t n_expected = expected_disassembly.size(); - byte* end = begin + (n_expected * Assembler::kInstrSize); + byte* end = begin + (n_expected * kInstrSize); std::vector<std::string> disassembly; for (byte* pc = begin; pc < end;) { @@ -483,6 +483,9 @@ TEST(Type3) { COMPARE(rbit(r1, r2), "e6ff1f32 rbit r1, r2"); COMPARE(rbit(r10, ip), "e6ffaf3c rbit r10, ip"); + + COMPARE(rev(r1, r2), "e6bf1f32 rev r1, r2"); + COMPARE(rev(r10, ip), "e6bfaf3c rev r10, ip"); } COMPARE(usat(r0, 1, Operand(r1)), @@ -672,14 +675,14 @@ TEST(Vfp) { COMPARE(vmov(s3, Float32(13.0f)), "eef21a0a vmov.f32 s3, #13"); - COMPARE(vmov(d0, VmovIndexLo, r0), + COMPARE(vmov(NeonS32, d0, 0, r0), "ee000b10 vmov.32 d0[0], r0"); - COMPARE(vmov(d0, VmovIndexHi, r0), + COMPARE(vmov(NeonS32, d0, 1, r0), "ee200b10 vmov.32 d0[1], r0"); - COMPARE(vmov(r2, VmovIndexLo, d15), + COMPARE(vmov(NeonS32, r2, d15, 0), "ee1f2b10 vmov.32 r2, d15[0]"); - COMPARE(vmov(r3, VmovIndexHi, d14), + COMPARE(vmov(NeonS32, r3, d14, 1), "ee3e3b10 vmov.32 r3, d14[1]"); COMPARE(vldr(s0, r0, 0), @@ -833,9 +836,9 @@ TEST(Vfp) { COMPARE(vmov(d30, Double(16.0)), "eef3eb00 vmov.f64 d30, #16"); - COMPARE(vmov(d31, VmovIndexLo, r7), + COMPARE(vmov(NeonS32, d31, 0, r7), "ee0f7b90 vmov.32 d31[0], r7"); - COMPARE(vmov(d31, VmovIndexHi, r7), + COMPARE(vmov(NeonS32, d31, 1, r7), "ee2f7b90 vmov.32 d31[1], r7"); COMPARE(vldr(d25, r0, 0), @@ -1513,7 +1516,7 @@ static void TestLoadLiteral(byte* buffer, Assembler* assm, bool* failure, char expected_string[80]; snprintf(expected_string, sizeof(expected_string), expected_string_template, abs(offset), offset, - progcounter + Instruction::kPCReadOffset + offset); + progcounter + Instruction::kPcLoadDelta + offset); if (!DisassembleAndCompare(progcounter, kRawString, expected_string)) { *failure = true; } @@ -1612,6 +1615,9 @@ TEST(LoadStoreExclusive) { COMPARE(strexh(r0, r1, r2), "e1e20f91 strexh r0, r1, [r2]"); COMPARE(ldrex(r0, r1), "e1910f9f ldrex r0, [r1]"); COMPARE(strex(r0, r1, r2), "e1820f91 strex r0, r1, [r2]"); + COMPARE(ldrexd(r0, r1, r2), "e1b20f9f ldrexd r0, [r2]"); + COMPARE(strexd(r0, r2, r3, r4), + "e1a40f92 strexd r0, r2, [r4]"); VERIFY_RUN(); } diff --git a/deps/v8/test/cctest/test-disasm-arm64.cc b/deps/v8/test/cctest/test-disasm-arm64.cc index 275feaa88e..1cc14271a6 100644 --- a/deps/v8/test/cctest/test-disasm-arm64.cc +++ b/deps/v8/test/cctest/test-disasm-arm64.cc @@ -815,7 +815,7 @@ TEST_(adr) { TEST_(branch) { SET_UP_ASM(); - #define INST_OFF(x) ((x) >> kInstructionSizeLog2) +#define INST_OFF(x) ((x) >> kInstrSizeLog2) COMPARE_PREFIX(b(INST_OFF(0x4)), "b #+0x4"); COMPARE_PREFIX(b(INST_OFF(-0x4)), "b #-0x4"); COMPARE_PREFIX(b(INST_OFF(0x7fffffc)), "b #+0x7fffffc"); @@ -840,6 +840,7 @@ TEST_(branch) { COMPARE_PREFIX(tbnz(w10, 31, INST_OFF(0)), "tbnz w10, #31, #+0x0"); COMPARE_PREFIX(tbnz(x11, 31, INST_OFF(0x4)), "tbnz w11, #31, #+0x4"); COMPARE_PREFIX(tbnz(x12, 32, INST_OFF(0x8)), "tbnz x12, #32, #+0x8"); +#undef INST_OFF COMPARE(br(x0), "br x0"); COMPARE(blr(x1), "blr x1"); COMPARE(ret(x2), "ret x2"); @@ -1881,7 +1882,11 @@ TEST_(debug) { byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); uint32_t encoding = 0; AssemblerOptions options; +#ifdef USE_SIMULATOR options.enable_simulator_code = (i == 1); +#else + CHECK(!options.enable_simulator_code); +#endif Assembler* assm = new Assembler(options, buf, INSTR_SIZE); Decoder<DispatchingDecoderVisitor>* decoder = new Decoder<DispatchingDecoderVisitor>(); diff --git a/deps/v8/test/cctest/test-disasm-ia32.cc b/deps/v8/test/cctest/test-disasm-ia32.cc index 84764621c9..a24de5656d 100644 --- a/deps/v8/test/cctest/test-disasm-ia32.cc +++ b/deps/v8/test/cctest/test-disasm-ia32.cc @@ -91,6 +91,8 @@ TEST(DisasmIa320) { __ add(edi, Operand(ebp, ecx, times_4, -3999)); __ add(Operand(ebp, ecx, times_4, 12), Immediate(12)); + __ bswap(eax); + __ nop(); __ add(ebx, Immediate(12)); __ nop(); @@ -391,6 +393,7 @@ TEST(DisasmIa320) { __ shufps(xmm0, xmm0, 0x0); __ cvtsd2ss(xmm0, xmm1); __ cvtsd2ss(xmm0, Operand(ebx, ecx, times_4, 10000)); + __ movq(xmm0, Operand(edx, 4)); // logic operation __ andps(xmm0, xmm1); @@ -871,6 +874,8 @@ TEST(DisasmIa320) { __ cmpxchg_b(Operand(esp, 12), eax); __ cmpxchg_w(Operand(ebx, ecx, times_4, 10000), eax); __ cmpxchg(Operand(ebx, ecx, times_4, 10000), eax); + __ cmpxchg(Operand(ebx, ecx, times_4, 10000), eax); + __ cmpxchg8b(Operand(ebx, ecx, times_8, 10000)); } // lock prefix. diff --git a/deps/v8/test/cctest/test-disasm-x64.cc b/deps/v8/test/cctest/test-disasm-x64.cc index 5811371999..c42606485c 100644 --- a/deps/v8/test/cctest/test-disasm-x64.cc +++ b/deps/v8/test/cctest/test-disasm-x64.cc @@ -89,6 +89,8 @@ TEST(DisasmX64) { __ addq(rdi, Operand(rbp, rcx, times_4, -3999)); __ addq(Operand(rbp, rcx, times_4, 12), Immediate(12)); + __ bswapl(rax); + __ bswapq(rdi); __ bsrl(rax, r15); __ bsrl(r9, Operand(rcx, times_8, 91919)); @@ -384,6 +386,8 @@ TEST(DisasmX64) { __ cvttss2si(rdx, xmm1); __ cvtsd2ss(xmm0, xmm1); __ cvtsd2ss(xmm0, Operand(rbx, rcx, times_4, 10000)); + __ cvttps2dq(xmm0, xmm1); + __ cvttps2dq(xmm0, Operand(rbx, rcx, times_4, 10000)); __ movaps(xmm0, xmm1); __ movdqa(xmm0, Operand(rsp, 12)); __ movdqa(Operand(rsp, 12), xmm0); @@ -524,6 +528,8 @@ TEST(DisasmX64) { { if (CpuFeatures::IsSupported(SSSE3)) { CpuFeatureScope scope(&assm, SSSE3); + __ palignr(xmm5, xmm1, 5); + __ palignr(xmm5, Operand(rdx, 4), 5); SSSE3_INSTRUCTION_LIST(EMIT_SSE34_INSTR) } } @@ -539,6 +545,8 @@ TEST(DisasmX64) { __ pextrd(r12, xmm0, 1); __ pinsrd(xmm9, r9, 0); __ pinsrd(xmm5, Operand(rax, 4), 1); + __ pblendw(xmm5, xmm1, 1); + __ pblendw(xmm9, Operand(rax, 4), 1); __ cmpps(xmm5, xmm1, 1); __ cmpps(xmm5, Operand(rbx, rcx, times_4, 10000), 1); diff --git a/deps/v8/test/cctest/test-elements-kind.cc b/deps/v8/test/cctest/test-elements-kind.cc index 5237a54173..59252f2ef8 100644 --- a/deps/v8/test/cctest/test-elements-kind.cc +++ b/deps/v8/test/cctest/test-elements-kind.cc @@ -15,6 +15,7 @@ #include "src/heap/factory.h" #include "src/ic/stub-cache.h" #include "src/objects-inl.h" +#include "src/objects/js-array-inl.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-feedback-vector.cc b/deps/v8/test/cctest/test-feedback-vector.cc index 44a81dd294..b809854270 100644 --- a/deps/v8/test/cctest/test-feedback-vector.cc +++ b/deps/v8/test/cctest/test-feedback-vector.cc @@ -5,7 +5,7 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/debug/debug.h" #include "src/execution.h" #include "src/global-handles.h" diff --git a/deps/v8/test/cctest/test-field-type-tracking.cc b/deps/v8/test/cctest/test-field-type-tracking.cc index 95b671b43a..4e37103558 100644 --- a/deps/v8/test/cctest/test-field-type-tracking.cc +++ b/deps/v8/test/cctest/test-field-type-tracking.cc @@ -609,7 +609,6 @@ static void TestGeneralizeField(int detach_property_at_index, bool expected_deprecation, bool expected_field_type_dependency) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Handle<FieldType> any_type = FieldType::Any(isolate); CHECK(detach_property_at_index >= -1 && @@ -656,6 +655,7 @@ static void TestGeneralizeField(int detach_property_at_index, // Create new maps by generalizing representation of propX field. CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), property_index); @@ -989,7 +989,6 @@ TEST(GeneralizeFieldWithAccessorProperties) { static void TestReconfigureDataFieldAttribute_GeneralizeField( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate); @@ -1028,6 +1027,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeField( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); @@ -1073,7 +1073,6 @@ static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( const CRFTData& from, const CRFTData& to, const CRFTData& expected, bool expected_field_type_dependency = true) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate); @@ -1112,6 +1111,7 @@ static void TestReconfigureDataFieldAttribute_GeneralizeFieldTrivial( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kSplitProp); @@ -1753,7 +1753,6 @@ TEST(ReconfigureDataFieldAttribute_AccConstantToDataFieldAfterTargetMap) { static void TestReconfigureElementsKind_GeneralizeField( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate, PACKED_SMI_ELEMENTS); @@ -1793,6 +1792,7 @@ static void TestReconfigureElementsKind_GeneralizeField( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); @@ -1848,7 +1848,6 @@ static void TestReconfigureElementsKind_GeneralizeField( static void TestReconfigureElementsKind_GeneralizeFieldTrivial( const CRFTData& from, const CRFTData& to, const CRFTData& expected) { Isolate* isolate = CcTest::i_isolate(); - JSHeapBroker broker(isolate); Expectations expectations(isolate, PACKED_SMI_ELEMENTS); @@ -1888,6 +1887,7 @@ static void TestReconfigureElementsKind_GeneralizeFieldTrivial( Zone zone(isolate->allocator(), ZONE_NAME); CanonicalHandleScope canonical(isolate); + JSHeapBroker broker(isolate, &zone); CompilationDependencies dependencies(isolate, &zone); dependencies.DependOnFieldType(MapRef(&broker, map), kDiffProp); @@ -2636,8 +2636,7 @@ struct SameMapChecker { // Checks that both |map1| and |map2| should stays non-deprecated, this is // the case when property kind is change. struct PropertyKindReconfigurationChecker { - void Check(Isolate* isolate, Expectations& expectations, Handle<Map> map1, - Handle<Map> map2) { + void Check(Expectations& expectations, Handle<Map> map1, Handle<Map> map2) { CHECK(!map1->is_deprecated()); CHECK(!map2->is_deprecated()); CHECK_NE(*map1, *map2); diff --git a/deps/v8/test/cctest/test-func-name-inference.cc b/deps/v8/test/cctest/test-func-name-inference.cc index 160f68813c..61f3ef0eeb 100644 --- a/deps/v8/test/cctest/test-func-name-inference.cc +++ b/deps/v8/test/cctest/test-func-name-inference.cc @@ -29,7 +29,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/debug/debug.h" #include "src/objects-inl.h" #include "src/string-search.h" diff --git a/deps/v8/test/cctest/test-fuzz-arm64.cc b/deps/v8/test/cctest/test-fuzz-arm64.cc index 059eda46fd..4345bb5f44 100644 --- a/deps/v8/test/cctest/test-fuzz-arm64.cc +++ b/deps/v8/test/cctest/test-fuzz-arm64.cc @@ -41,7 +41,7 @@ TEST(FUZZ_decoder) { seed48(seed); Decoder<DispatchingDecoderVisitor> decoder; - Instruction buffer[kInstructionSize]; + Instruction buffer[kInstrSize]; for (int i = 0; i < instruction_count; i++) { uint32_t instr = static_cast<uint32_t>(mrand48()); @@ -61,7 +61,7 @@ TEST(FUZZ_disasm) { Decoder<DispatchingDecoderVisitor> decoder; DisassemblingDecoder disasm; - Instruction buffer[kInstructionSize]; + Instruction buffer[kInstrSize]; decoder.AppendVisitor(&disasm); for (int i = 0; i < instruction_count; i++) { diff --git a/deps/v8/test/cctest/test-global-handles.cc b/deps/v8/test/cctest/test-global-handles.cc index 89b5ed4c83..ea76faa857 100644 --- a/deps/v8/test/cctest/test-global-handles.cc +++ b/deps/v8/test/cctest/test-global-handles.cc @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "src/api.h" +#include "src/api-inl.h" #include "src/global-handles.h" #include "src/heap/factory.h" #include "src/isolate.h" diff --git a/deps/v8/test/cctest/test-global-object.cc b/deps/v8/test/cctest/test-global-object.cc index 24dd270b73..5c154565d9 100644 --- a/deps/v8/test/cctest/test-global-object.cc +++ b/deps/v8/test/cctest/test-global-object.cc @@ -25,7 +25,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "src/api.h" #include "src/objects-inl.h" #include "src/v8.h" #include "test/cctest/cctest.h" diff --git a/deps/v8/test/cctest/test-hashcode.cc b/deps/v8/test/cctest/test-hashcode.cc index a433c77ac7..2059d53885 100644 --- a/deps/v8/test/cctest/test-hashcode.cc +++ b/deps/v8/test/cctest/test-hashcode.cc @@ -6,7 +6,6 @@ #include <sstream> #include <utility> -#include "src/api.h" #include "src/objects-inl.h" #include "src/objects.h" #include "src/v8.h" @@ -26,14 +25,14 @@ int AddToSetAndGetHash(Isolate* isolate, Handle<JSObject> obj, return Smi::ToInt(obj->GetHash()); } -void CheckFastObject(Isolate* isolate, Handle<JSObject> obj, int hash) { +void CheckFastObject(Handle<JSObject> obj, int hash) { CHECK(obj->HasFastProperties()); CHECK(obj->raw_properties_or_hash()->IsPropertyArray()); CHECK_EQ(Smi::FromInt(hash), obj->GetHash()); CHECK_EQ(hash, obj->property_array()->Hash()); } -void CheckDictionaryObject(Isolate* isolate, Handle<JSObject> obj, int hash) { +void CheckDictionaryObject(Handle<JSObject> obj, int hash) { CHECK(!obj->HasFastProperties()); CHECK(obj->raw_properties_or_hash()->IsDictionary()); CHECK_EQ(Smi::FromInt(hash), obj->GetHash()); @@ -83,7 +82,7 @@ TEST(AddHashCodeToFastObjectWithPropertiesArray) { CHECK(obj->HasFastProperties()); int hash = AddToSetAndGetHash(isolate, obj, true); - CheckFastObject(isolate, obj, hash); + CheckFastObject(obj, hash); } TEST(AddHashCodeToSlowObject) { @@ -99,7 +98,7 @@ TEST(AddHashCodeToSlowObject) { CHECK(obj->raw_properties_or_hash()->IsDictionary()); int hash = AddToSetAndGetHash(isolate, obj, false); - CheckDictionaryObject(isolate, obj, hash); + CheckDictionaryObject(obj, hash); } TEST(TransitionFastWithInObjectToFastWithPropertyArray) { @@ -121,7 +120,7 @@ TEST(TransitionFastWithInObjectToFastWithPropertyArray) { int length = obj->property_array()->length(); CompileRun("x.e = 5;"); CHECK(obj->property_array()->length() > length); - CheckFastObject(isolate, obj, hash); + CheckFastObject(obj, hash); } TEST(TransitionFastWithPropertyArray) { @@ -143,7 +142,7 @@ TEST(TransitionFastWithPropertyArray) { int length = obj->property_array()->length(); CompileRun("x.f = 2; x.g = 5; x.h = 2"); CHECK(obj->property_array()->length() > length); - CheckFastObject(isolate, obj, hash); + CheckFastObject(obj, hash); } TEST(TransitionFastWithPropertyArrayToSlow) { @@ -165,7 +164,7 @@ TEST(TransitionFastWithPropertyArrayToSlow) { JSObject::NormalizeProperties(obj, KEEP_INOBJECT_PROPERTIES, 0, "cctest/test-hashcode"); - CheckDictionaryObject(isolate, obj, hash); + CheckDictionaryObject(obj, hash); } TEST(TransitionSlowToSlow) { @@ -187,7 +186,7 @@ TEST(TransitionSlowToSlow) { int length = obj->property_dictionary()->length(); CompileRun("for(var i = 0; i < 10; i++) { x['f'+i] = i };"); CHECK(obj->property_dictionary()->length() > length); - CheckDictionaryObject(isolate, obj, hash); + CheckDictionaryObject(obj, hash); } TEST(TransitionSlowToFastWithoutProperties) { @@ -225,7 +224,7 @@ TEST(TransitionSlowToFastWithPropertyArray) { CHECK_EQ(hash, obj->property_dictionary()->Hash()); JSObject::MigrateSlowToFast(obj, 0, "cctest/test-hashcode"); - CheckFastObject(isolate, obj, hash); + CheckFastObject(obj, hash); } } // namespace internal diff --git a/deps/v8/test/cctest/test-heap-profiler.cc b/deps/v8/test/cctest/test-heap-profiler.cc index 18203c7725..5d8094d635 100644 --- a/deps/v8/test/cctest/test-heap-profiler.cc +++ b/deps/v8/test/cctest/test-heap-profiler.cc @@ -34,7 +34,7 @@ #include "src/v8.h" #include "include/v8-profiler.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/base/hashmap.h" #include "src/collector.h" @@ -49,7 +49,9 @@ using i::AllocationTraceNode; using i::AllocationTraceTree; using i::AllocationTracker; using i::ArrayVector; +using i::SourceLocation; using i::Vector; +using v8::base::Optional; namespace { @@ -151,6 +153,23 @@ static const v8::HeapGraphNode* GetRootChild(const v8::HeapSnapshot* snapshot, return GetChildByName(snapshot->GetRoot(), name); } +static Optional<SourceLocation> GetLocation(const v8::HeapSnapshot* s, + const v8::HeapGraphNode* node) { + const i::HeapSnapshot* snapshot = reinterpret_cast<const i::HeapSnapshot*>(s); + const std::vector<SourceLocation>& locations = snapshot->locations(); + const int index = + const_cast<i::HeapEntry*>(reinterpret_cast<const i::HeapEntry*>(node)) + ->index(); + + for (const auto& loc : locations) { + if (loc.entry_index == index) { + return Optional<SourceLocation>(loc); + } + } + + return Optional<SourceLocation>(); +} + static const v8::HeapGraphNode* GetProperty(v8::Isolate* isolate, const v8::HeapGraphNode* node, v8::HeapGraphEdge::Type type, @@ -258,6 +277,49 @@ TEST(HeapSnapshot) { CHECK(det.has_C2); } +TEST(HeapSnapshotLocations) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); + + CompileRun( + "function X(a) { return function() { return a; } }\n" + "function* getid() { yield 1; }\n" + "class A {}\n" + "var x = X(1);\n" + "var g = getid();\n" + "var o = new A();"); + const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); + CHECK(ValidateSnapshot(snapshot)); + + const v8::HeapGraphNode* global = GetGlobalObject(snapshot); + const v8::HeapGraphNode* x = + GetProperty(env->GetIsolate(), global, v8::HeapGraphEdge::kProperty, "x"); + CHECK(x); + + Optional<SourceLocation> x_loc = GetLocation(snapshot, x); + CHECK(x_loc); + CHECK_EQ(0, x_loc->line); + CHECK_EQ(31, x_loc->col); + + const v8::HeapGraphNode* g = + GetProperty(env->GetIsolate(), global, v8::HeapGraphEdge::kProperty, "g"); + CHECK(x); + + Optional<SourceLocation> g_loc = GetLocation(snapshot, g); + CHECK(g_loc); + CHECK_EQ(1, g_loc->line); + CHECK_EQ(15, g_loc->col); + + const v8::HeapGraphNode* o = + GetProperty(env->GetIsolate(), global, v8::HeapGraphEdge::kProperty, "o"); + CHECK(x); + + Optional<SourceLocation> o_loc = GetLocation(snapshot, o); + CHECK(o_loc); + CHECK_EQ(2, o_loc->line); + CHECK_EQ(0, o_loc->col); +} TEST(HeapSnapshotObjectSizes) { LocalContext env; @@ -1045,6 +1107,7 @@ TEST(HeapSnapshotJSONSerialization) { CHECK(parsed_snapshot->Has(env.local(), v8_str("snapshot")).FromJust()); CHECK(parsed_snapshot->Has(env.local(), v8_str("nodes")).FromJust()); CHECK(parsed_snapshot->Has(env.local(), v8_str("edges")).FromJust()); + CHECK(parsed_snapshot->Has(env.local(), v8_str("locations")).FromJust()); CHECK(parsed_snapshot->Has(env.local(), v8_str("strings")).FromJust()); // Get node and edge "member" offsets. @@ -1869,6 +1932,63 @@ static int StringCmp(const char* ref, i::String* act) { return result; } +TEST(GetConstructor) { + LocalContext env; + v8::HandleScope scope(env->GetIsolate()); + + CompileRun( + "function Constructor1() {};\n" + "var obj1 = new Constructor1();\n" + "var Constructor2 = function() {};\n" + "var obj2 = new Constructor2();\n" + "var obj3 = {};\n" + "obj3.__proto__ = { constructor: function Constructor3() {} };\n" + "var obj4 = {};\n" + "// Slow properties\n" + "for (var i=0; i<2000; ++i) obj4[\"p\" + i] = i;\n" + "obj4.__proto__ = { constructor: function Constructor4() {} };\n" + "var obj5 = {};\n" + "var obj6 = {};\n" + "obj6.constructor = 6;"); + v8::Local<v8::Object> js_global = + env->Global()->GetPrototype().As<v8::Object>(); + v8::Local<v8::Object> obj1 = js_global->Get(env.local(), v8_str("obj1")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj1 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj1)); + CHECK(i::V8HeapExplorer::GetConstructor(*js_obj1)); + v8::Local<v8::Object> obj2 = js_global->Get(env.local(), v8_str("obj2")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj2 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj2)); + CHECK(i::V8HeapExplorer::GetConstructor(*js_obj2)); + v8::Local<v8::Object> obj3 = js_global->Get(env.local(), v8_str("obj3")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj3 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj3)); + CHECK(i::V8HeapExplorer::GetConstructor(*js_obj3)); + v8::Local<v8::Object> obj4 = js_global->Get(env.local(), v8_str("obj4")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj4 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj4)); + CHECK(i::V8HeapExplorer::GetConstructor(*js_obj4)); + v8::Local<v8::Object> obj5 = js_global->Get(env.local(), v8_str("obj5")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj5 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj5)); + CHECK(!i::V8HeapExplorer::GetConstructor(*js_obj5)); + v8::Local<v8::Object> obj6 = js_global->Get(env.local(), v8_str("obj6")) + .ToLocalChecked() + .As<v8::Object>(); + i::Handle<i::JSObject> js_obj6 = + i::Handle<i::JSObject>::cast(v8::Utils::OpenHandle(*obj6)); + CHECK(!i::V8HeapExplorer::GetConstructor(*js_obj6)); +} TEST(GetConstructorName) { LocalContext env; @@ -2134,6 +2254,35 @@ TEST(AccessorInfo) { CHECK(setter); } +TEST(JSGeneratorObject) { + v8::Isolate* isolate = CcTest::isolate(); + LocalContext env; + v8::HandleScope scope(isolate); + v8::HeapProfiler* heap_profiler = isolate->GetHeapProfiler(); + + CompileRun( + "function* foo() { yield 1; }\n" + "g = foo();\n"); + const v8::HeapSnapshot* snapshot = heap_profiler->TakeHeapSnapshot(); + CHECK(ValidateSnapshot(snapshot)); + const v8::HeapGraphNode* global = GetGlobalObject(snapshot); + const v8::HeapGraphNode* g = + GetProperty(isolate, global, v8::HeapGraphEdge::kProperty, "g"); + CHECK(g); + const v8::HeapGraphNode* function = GetProperty( + env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "function"); + CHECK(function); + const v8::HeapGraphNode* context = GetProperty( + env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "context"); + CHECK(context); + const v8::HeapGraphNode* receiver = GetProperty( + env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, "receiver"); + CHECK(receiver); + const v8::HeapGraphNode* parameters_and_registers = + GetProperty(env->GetIsolate(), g, v8::HeapGraphEdge::kInternal, + "parameters_and_registers"); + CHECK(parameters_and_registers); +} bool HasWeakEdge(const v8::HeapGraphNode* node) { for (int i = 0; i < node->GetChildrenCount(); ++i) { @@ -3436,12 +3585,18 @@ TEST(SamplingHeapProfilerRateAgnosticEstimates) { // what we expect in this test. v8::internal::FLAG_always_opt = false; + // Disable compilation cache to force compilation in both cases + v8::internal::FLAG_compilation_cache = false; + // Suppress randomness to avoid flakiness in tests. v8::internal::FLAG_sampling_heap_profiler_suppress_randomness = true; // stress_incremental_marking adds randomness to the test. v8::internal::FLAG_stress_incremental_marking = false; + // warmup compilation + CompileRun(simple_sampling_heap_profiler_script); + int count_1024 = 0; { heap_profiler->StartSamplingHeapProfiler(1024); diff --git a/deps/v8/test/cctest/test-inobject-slack-tracking.cc b/deps/v8/test/cctest/test-inobject-slack-tracking.cc index 9ebe67cab4..0e850b1682 100644 --- a/deps/v8/test/cctest/test-inobject-slack-tracking.cc +++ b/deps/v8/test/cctest/test-inobject-slack-tracking.cc @@ -6,7 +6,7 @@ #include <sstream> #include <utility> -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/objects.h" #include "src/v8.h" @@ -1148,7 +1148,7 @@ TEST(SubclassTypedArrayBuiltin) { CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); -#define TYPED_ARRAY_TEST(Type, type, TYPE, elementType, size) \ +#define TYPED_ARRAY_TEST(Type, type, TYPE, elementType) \ TestSubclassBuiltin("A" #Type, JS_TYPED_ARRAY_TYPE, #Type "Array", "42"); TYPED_ARRAYS(TYPED_ARRAY_TEST) diff --git a/deps/v8/test/cctest/test-isolate-independent-builtins.cc b/deps/v8/test/cctest/test-isolate-independent-builtins.cc index c878484976..4b4babdb37 100644 --- a/deps/v8/test/cctest/test-isolate-independent-builtins.cc +++ b/deps/v8/test/cctest/test-isolate-independent-builtins.cc @@ -11,6 +11,7 @@ #include "src/simulator.h" #include "src/snapshot/macros.h" #include "src/snapshot/snapshot.h" +#include "test/common/assembler-tester.h" // To generate the binary files for the test function, enable this section and // run GenerateTestFunctionData once on each arch. diff --git a/deps/v8/test/cctest/test-liveedit.cc b/deps/v8/test/cctest/test-liveedit.cc index 05044a4aa5..e2fec0a3ae 100644 --- a/deps/v8/test/cctest/test-liveedit.cc +++ b/deps/v8/test/cctest/test-liveedit.cc @@ -29,7 +29,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/debug/liveedit.h" #include "src/objects-inl.h" #include "test/cctest/cctest.h" @@ -248,14 +248,16 @@ TEST(LiveEditPatchFunctions) { PatchFunctions(context, "function foo() { return 1; }", "function foo() { return 42; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 42); // It is expected, we do not reevaluate top level function. PatchFunctions(context, "var a = 1; function foo() { return a; }", "var a = 3; function foo() { return a; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 1); // Throw exception since var b is not defined in original source. @@ -270,14 +272,16 @@ TEST(LiveEditPatchFunctions) { PatchFunctions(context, "var a = 1; function foo() { return a; }", "var b = 4; function foo() { var b = 5; return b; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 5); PatchFunctions(context, "var a = 1; function foo() { return a; }", "var b = 4; function foo() { var a = 6; return a; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 6); @@ -292,7 +296,8 @@ TEST(LiveEditPatchFunctions) { PatchFunctions(context, "var a = 1; function foo() { return a; }", "var b = 1; var a = 2; function foo() { return a; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 1); @@ -307,14 +312,16 @@ TEST(LiveEditPatchFunctions) { PatchFunctions(context, "function foo() { var a = 1; return a; }", "function foo() { var b = 1; return b; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 1); PatchFunctions(context, "var a = 3; function foo() { var a = 1; return a; }", "function foo() { var b = 1; return a; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 3); @@ -330,14 +337,16 @@ TEST(LiveEditPatchFunctions) { PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }", "function fooArgs(a2, b2, c2) { return a2 + b2 + c2; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 6); PatchFunctions(context, "function fooArgs(a1, b1) { return a1 + b1; }", "function fooArgs(a1, b1, c1) { return a1 + b1 + c1; }"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "fooArgs(1,2,3)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 6); @@ -347,7 +356,8 @@ TEST(LiveEditPatchFunctions) { "%OptimizeFunctionOnNextCall(foo); foo(1,2);", "function foo(a, b) { return a * b; };"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(5,7)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 35); i::FLAG_allow_natives_syntax = false; @@ -359,7 +369,8 @@ TEST(LiveEditPatchFunctions) { "function foo(a,b) { function op(a,b) { return a * b } return op(a,b); " "}"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "foo(8,9)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 72); @@ -368,7 +379,8 @@ TEST(LiveEditPatchFunctions) { "class Foo { constructor(a,b) { this.data = a + b; } };", "class Foo { constructor(a,b) { this.data = a * b; } };"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "new Foo(4,5).data") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 20); // Change inner functions. @@ -379,7 +391,8 @@ TEST(LiveEditPatchFunctions) { "function f(evt) { function f2() { return 1; } return f2() + f3(); " "function f3() { return 2; } } function f4() {}"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 3); // Change usage of outer scope. @@ -424,21 +437,24 @@ TEST(LiveEditPatchFunctions) { // TODO(kozyatinskiy): should work when we remove (. PatchFunctions(context, "f = () => 2", "f = a => a"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 2); // Replace function with not a function. PatchFunctions(context, "f = () => 2", "f = a == 2"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f(3)") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 2); // TODO(kozyatinskiy): should work when we put function into (...). PatchFunctions(context, "f = a => 2", "f = (a => 5)()"); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 2); @@ -457,11 +473,13 @@ TEST(LiveEditPatchFunctions) { "f()\n"); // TODO(kozyatinskiy): ditto. CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f2()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 5); CHECK_EQ(CompileRunChecked(env->GetIsolate(), "f()") - ->ToInt32(env->GetIsolate()) + ->ToInt32(context) + .ToLocalChecked() ->Value(), 3); } diff --git a/deps/v8/test/cctest/test-lockers.cc b/deps/v8/test/cctest/test-lockers.cc index ebfbe88de2..dec279e781 100644 --- a/deps/v8/test/cctest/test-lockers.cc +++ b/deps/v8/test/cctest/test-lockers.cc @@ -31,7 +31,6 @@ #include "src/v8.h" -#include "src/api.h" #include "src/base/platform/platform.h" #include "src/compilation-cache.h" #include "src/execution.h" diff --git a/deps/v8/test/cctest/test-log-stack-tracer.cc b/deps/v8/test/cctest/test-log-stack-tracer.cc index 8a09a17684..ea51a168d7 100644 --- a/deps/v8/test/cctest/test-log-stack-tracer.cc +++ b/deps/v8/test/cctest/test-log-stack-tracer.cc @@ -30,7 +30,7 @@ #include <stdlib.h> #include "include/v8-profiler.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/code-stubs.h" #include "src/disassembler.h" #include "src/isolate.h" diff --git a/deps/v8/test/cctest/test-log.cc b/deps/v8/test/cctest/test-log.cc index 1dfa22b4cc..9ac73af3e5 100644 --- a/deps/v8/test/cctest/test-log.cc +++ b/deps/v8/test/cctest/test-log.cc @@ -27,27 +27,16 @@ // // Tests of logging functions from log.h -#ifdef __linux__ -#include <pthread.h> -#include <signal.h> -#include <unistd.h> -#include <cmath> -#endif // __linux__ - #include <unordered_set> #include <vector> -// The C++ style guide recommends using <re2> instead of <regex>. However, the -// former isn't available in V8. -#include <regex> // NOLINT(build/c++11) -#include "src/api.h" +#include "src/api-inl.h" +#include "src/builtins/builtins.h" #include "src/log-utils.h" #include "src/log.h" #include "src/objects-inl.h" #include "src/profiler/cpu-profiler.h" #include "src/snapshot/natives.h" -#include "src/utils.h" #include "src/v8.h" -#include "src/v8threads.h" #include "src/version.h" #include "src/vm-state-inl.h" #include "test/cctest/cctest.h" @@ -68,35 +57,14 @@ namespace { i::FLAG_logfile = i::Log::kLogToTemporaryFile; \ i::FLAG_logfile_per_isolate = false -static const char* StrNStr(const char* s1, const char* s2, size_t n) { - CHECK_EQ(s1[n], '\0'); - return strstr(s1, s2); -} - -// Look for a log line which starts with {prefix} and ends with {suffix}. -static const char* FindLogLine(const char* start, const char* end, - const char* prefix, - const char* suffix = nullptr) { - CHECK_LT(start, end); - CHECK_EQ(end[0], '\0'); - size_t prefixLength = strlen(prefix); - // Loop through the input until we find /{prefix}[^\n]+{suffix}/. - while (start < end) { - const char* prefixResult = strstr(start, prefix); - if (!prefixResult) return NULL; - if (suffix == nullptr) return prefixResult; - const char* suffixResult = - StrNStr(prefixResult, suffix, (end - prefixResult)); - if (!suffixResult) return NULL; - // Check that there are no newlines in between the {prefix} and the {suffix} - // results. - const char* newlineResult = - StrNStr(prefixResult, "\n", (end - prefixResult)); - if (!newlineResult) return prefixResult; - if (newlineResult > suffixResult) return prefixResult; - start = prefixResult + prefixLength; +static std::vector<std::string> Split(const std::string& s, char delimiter) { + std::vector<std::string> result; + std::string line; + std::istringstream stream(s); + while (std::getline(stream, line, delimiter)) { + result.push_back(line); } - return NULL; + return result; } class ScopedLoggerInitializer { @@ -119,7 +87,6 @@ class ScopedLoggerInitializer { if (temp_file_ != nullptr) fclose(temp_file_); i::FLAG_prof = saved_prof_; i::FLAG_log = saved_log_; - log_.Dispose(); } v8::Local<v8::Context>& env() { return env_; } @@ -130,116 +97,81 @@ class ScopedLoggerInitializer { Logger* logger() { return logger_; } - void PrintLog(int requested_nof_lines = 0, const char* start = nullptr) { - if (requested_nof_lines <= 0) { - printf("%s", log_.start()); - return; - } - // Try to print the last {requested_nof_lines} of the log. - if (start == nullptr) start = log_.start(); - const char* current = log_.end(); - int nof_lines = requested_nof_lines; - while (current > start && nof_lines > 0) { - current--; - if (*current == '\n') nof_lines--; - } - printf( - "======================================================\n" - "Last %i log lines:\n" - "======================================================\n" - "...\n%s\n" - "======================================================\n", - requested_nof_lines, current); - } - v8::Local<v8::String> GetLogString() { - return v8::String::NewFromUtf8(isolate_, log_.start(), - v8::NewStringType::kNormal, log_.length()) + int length = static_cast<int>(raw_log_.size()); + return v8::String::NewFromUtf8(isolate_, raw_log_.c_str(), + v8::NewStringType::kNormal, length) .ToLocalChecked(); } void StopLogging() { bool exists = false; - log_ = i::ReadFile(StopLoggingGetTempFile(), &exists, true); + raw_log_ = i::ReadFile(StopLoggingGetTempFile(), &exists, true); + log_ = Split(raw_log_, '\n'); CHECK(exists); } - const char* GetEndPosition() { return log_.start() + log_.length(); } + // Searches |log_| for a line which contains all the strings in |search_terms| + // as substrings, starting from the index |start|, and returns the index of + // the found line. Returns std::string::npos if no line is found. + size_t IndexOfLine(const std::vector<std::string>& search_terms, + size_t start = 0) { + for (size_t i = start; i < log_.size(); ++i) { + const std::string& line = log_.at(i); + bool all_terms_found = true; + for (const std::string& term : search_terms) { + all_terms_found &= line.find(term) != std::string::npos; + } + if (all_terms_found) return i; + } + return std::string::npos; + } - const char* FindLine(const char* prefix, const char* suffix = nullptr, - const char* start = nullptr) { - // Make sure that StopLogging() has been called before. - CHECK(log_.size()); - if (start == nullptr) start = log_.start(); - const char* end = GetEndPosition(); - return FindLogLine(start, end, prefix, suffix); + bool ContainsLine(const std::vector<std::string>& search_terms, + size_t start = 0) { + return IndexOfLine(search_terms, start) != std::string::npos; } - // Find all log lines specified by the {prefix, suffix} pairs and ensure they - // occurr in the specified order. - void FindLogLines(const char* pairs[][2], size_t limit, - const char* start = nullptr) { - const char* prefix = pairs[0][0]; - const char* suffix = pairs[0][1]; - const char* last_position = FindLine(prefix, suffix, start); - if (last_position == nullptr) { - PrintLog(100, start); - V8_Fatal(__FILE__, __LINE__, "Could not find log line: %s ... %s", prefix, - suffix); + // Calls IndexOfLine for each set of substring terms in + // |all_line_search_terms|, in order. Returns true if they're all found. + bool ContainsLinesInOrder( + const std::vector<std::vector<std::string>>& all_line_search_terms, + size_t start = 0) { + CHECK_GT(log_.size(), 0); + for (auto& search_terms : all_line_search_terms) { + start = IndexOfLine(search_terms, start); + if (start == std::string::npos) return false; + ++start; // Skip the found line. } - CHECK(last_position); - for (size_t i = 1; i < limit; i++) { - prefix = pairs[i][0]; - suffix = pairs[i][1]; - const char* position = FindLine(prefix, suffix, start); - if (position == nullptr) { - PrintLog(100, start); - V8_Fatal(__FILE__, __LINE__, "Could not find log line: %s ... %s", - prefix, suffix); - } - // Check that all string positions are in order. - if (position <= last_position) { - PrintLog(100, start); - V8_Fatal(__FILE__, __LINE__, - "Log statements not in expected order (prev=%p, current=%p): " - "%s ... %s", - reinterpret_cast<const void*>(last_position), - reinterpret_cast<const void*>(position), prefix, suffix); - } - last_position = position; + return true; + } + + std::unordered_set<uintptr_t> ExtractAllAddresses(std::string search_term, + size_t address_column) { + CHECK_GT(log_.size(), 0); + std::unordered_set<uintptr_t> result; + size_t start = 0; + while (true) { + start = IndexOfLine({search_term}, start); + if (start == std::string::npos) break; + std::vector<std::string> columns = Split(log_.at(start), ','); + CHECK_LT(address_column, columns.size()); + uintptr_t address = + strtoll(columns.at(address_column).c_str(), nullptr, 16); + CHECK_GT(address, 0); + result.insert(address); + ++start; // Skip the found line. } + return result; } + void LogCodeObjects() { logger_->LogCodeObjects(); } void LogCompiledFunctions() { logger_->LogCompiledFunctions(); } void StringEvent(const char* name, const char* value) { logger_->StringEvent(name, value); } - void ExtractAllAddresses(std::unordered_set<uintptr_t>* map, - const char* prefix, int field_index) { - // Make sure that StopLogging() has been called before. - CHECK(log_.size()); - const char* current = log_.start(); - while (current != nullptr) { - current = FindLine(prefix, nullptr, current); - if (current == nullptr) return; - // Find token number {index}. - const char* previous; - for (int i = 0; i <= field_index; i++) { - previous = current; - current = strchr(current + 1, ','); - if (current == nullptr) break; - // Skip the comma. - current++; - } - if (current == nullptr) break; - uintptr_t address = strtoll(previous, nullptr, 16); - CHECK_LT(0, address); - map->insert(address); - } - } - private: FILE* StopLoggingGetTempFile() { temp_file_ = logger_->TearDown(); @@ -257,7 +189,9 @@ class ScopedLoggerInitializer { v8::HandleScope scope_; v8::Local<v8::Context> env_; Logger* logger_; - i::Vector<const char> log_; + + std::string raw_log_; + std::vector<std::string> log_; DISALLOW_COPY_AND_ASSIGN(ScopedLoggerInitializer); }; @@ -268,15 +202,20 @@ class TestCodeEventHandler : public v8::CodeEventHandler { : v8::CodeEventHandler(isolate), isolate_(isolate) {} size_t CountLines(std::string prefix, std::string suffix = std::string()) { - if (!log_.length()) return 0; - - std::regex expression("(^|\\n)" + prefix + ".*" + suffix + "(?=\\n|$)"); - - size_t match_count(std::distance( - std::sregex_iterator(log_.begin(), log_.end(), expression), - std::sregex_iterator())); + if (event_log_.empty()) return 0; + + size_t match = 0; + for (const std::string& line : event_log_) { + size_t prefix_pos = line.find(prefix); + if (prefix_pos == std::string::npos) continue; + size_t suffix_pos = line.rfind(suffix); + if (suffix_pos == std::string::npos) continue; + if (suffix_pos != line.length() - suffix.length()) continue; + if (prefix_pos >= suffix_pos) continue; + match++; + } - return match_count; + return match; } void Handle(v8::CodeEvent* code_event) override { @@ -284,8 +223,7 @@ class TestCodeEventHandler : public v8::CodeEventHandler { log_line += v8::CodeEvent::GetCodeEventTypeName(code_event->GetCodeType()); log_line += " "; log_line += FormatName(code_event); - log_line += "\n"; - log_ += log_line; + event_log_.push_back(log_line); } private: @@ -294,7 +232,7 @@ class TestCodeEventHandler : public v8::CodeEventHandler { if (name.empty()) { v8::Local<v8::String> functionName = code_event->GetFunctionName(); std::string buffer(functionName->Utf8Length(isolate_) + 1, 0); - functionName->WriteUtf8(&buffer[0], + functionName->WriteUtf8(isolate_, &buffer[0], functionName->Utf8Length(isolate_) + 1); // Sanitize name, removing unwanted \0 resulted from WriteUtf8 name = std::string(buffer.c_str()); @@ -303,195 +241,12 @@ class TestCodeEventHandler : public v8::CodeEventHandler { return name; } - std::string log_; + std::vector<std::string> event_log_; v8::Isolate* isolate_; }; } // namespace -TEST(FindLogLine) { - const char* string = - "prefix1, stuff, suffix1\n" - "prefix2, stuff\n, suffix2\n" - "prefix3suffix3\n" - "prefix4 suffix4"; - const char* end = string + strlen(string); - // Make sure the vector contains the terminating \0 character. - CHECK(FindLogLine(string, end, "prefix1, stuff, suffix1")); - CHECK(FindLogLine(string, end, "prefix1, stuff")); - CHECK(FindLogLine(string, end, "prefix1")); - CHECK(FindLogLine(string, end, "prefix1", "suffix1")); - CHECK(FindLogLine(string, end, "prefix1", "suffix1")); - CHECK(!FindLogLine(string, end, "prefix2", "suffix2")); - CHECK(!FindLogLine(string, end, "prefix1", "suffix2")); - CHECK(!FindLogLine(string, end, "prefix1", "suffix3")); - CHECK(FindLogLine(string, end, "prefix3", "suffix3")); - CHECK(FindLogLine(string, end, "prefix4", "suffix4")); - CHECK(!FindLogLine(string, end, "prefix4", "suffix4XXXXXXXXXXXX")); - CHECK( - !FindLogLine(string, end, "prefix4XXXXXXXXXXXXXXXXXXXXXXxxx", "suffix4")); - CHECK(!FindLogLine(string, end, "suffix", "suffix5XXXXXXXXXXXXXXXXXXXX")); -} - -// BUG(913). Need to implement support for profiling multiple VM threads. -#if 0 - -namespace { - -class LoopingThread : public v8::internal::Thread { - public: - explicit LoopingThread(v8::internal::Isolate* isolate) - : v8::internal::Thread(isolate), - semaphore_(new v8::internal::Semaphore(0)), - run_(true) { - } - - virtual ~LoopingThread() { delete semaphore_; } - - void Run() { - self_ = pthread_self(); - RunLoop(); - } - - void SendSigProf() { pthread_kill(self_, SIGPROF); } - - void Stop() { run_ = false; } - - bool WaitForRunning() { return semaphore_->Wait(1000000); } - - protected: - bool IsRunning() { return run_; } - - virtual void RunLoop() = 0; - - void SetV8ThreadId() { - v8_thread_id_ = v8::V8::GetCurrentThreadId(); - } - - void SignalRunning() { semaphore_->Signal(); } - - private: - v8::internal::Semaphore* semaphore_; - bool run_; - pthread_t self_; - int v8_thread_id_; -}; - - -class LoopingJsThread : public LoopingThread { - public: - explicit LoopingJsThread(v8::internal::Isolate* isolate) - : LoopingThread(isolate) { } - void RunLoop() { - v8::Locker locker; - CHECK_NOT_NULL(CcTest::i_isolate()); - CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0); - SetV8ThreadId(); - while (IsRunning()) { - v8::HandleScope scope; - v8::Persistent<v8::Context> context = v8::Context::New(); - CHECK(!context.IsEmpty()); - { - v8::Context::Scope context_scope(context); - SignalRunning(); - CompileRun( - "var j; for (var i=0; i<10000; ++i) { j = Math.sin(i); }"); - } - context.Dispose(); - i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1)); - } - } -}; - - -class LoopingNonJsThread : public LoopingThread { - public: - explicit LoopingNonJsThread(v8::internal::Isolate* isolate) - : LoopingThread(isolate) { } - void RunLoop() { - v8::Locker locker; - v8::Unlocker unlocker; - // Now thread has V8's id, but will not run VM code. - CHECK_NOT_NULL(CcTest::i_isolate()); - CHECK_GT(CcTest::i_isolate()->thread_manager()->CurrentId(), 0); - double i = 10; - SignalRunning(); - while (IsRunning()) { - i = std::sin(i); - i::OS::Sleep(v8::base::TimeDelta::FromMilliseconds(1)); - } - } -}; - - -class TestSampler : public v8::internal::Sampler { - public: - explicit TestSampler(v8::internal::Isolate* isolate) - : Sampler(isolate, 0, true, true), - semaphore_(new v8::internal::Semaphore(0)), - was_sample_stack_called_(false) { - } - - ~TestSampler() { delete semaphore_; } - - void SampleStack(v8::internal::TickSample*) { - was_sample_stack_called_ = true; - } - - void Tick(v8::internal::TickSample*) { semaphore_->Signal(); } - - bool WaitForTick() { return semaphore_->Wait(1000000); } - - void Reset() { was_sample_stack_called_ = false; } - - bool WasSampleStackCalled() { return was_sample_stack_called_; } - - private: - v8::internal::Semaphore* semaphore_; - bool was_sample_stack_called_; -}; - - -} // namespace - -TEST(ProfMultipleThreads) { - TestSampler* sampler = nullptr; - { - v8::Locker locker; - sampler = new TestSampler(CcTest::i_isolate()); - sampler->Start(); - CHECK(sampler->IsActive()); - } - - LoopingJsThread jsThread(CcTest::i_isolate()); - jsThread.Start(); - LoopingNonJsThread nonJsThread(CcTest::i_isolate()); - nonJsThread.Start(); - - CHECK(!sampler->WasSampleStackCalled()); - jsThread.WaitForRunning(); - jsThread.SendSigProf(); - CHECK(sampler->WaitForTick()); - CHECK(sampler->WasSampleStackCalled()); - sampler->Reset(); - CHECK(!sampler->WasSampleStackCalled()); - nonJsThread.WaitForRunning(); - nonJsThread.SendSigProf(); - CHECK(!sampler->WaitForTick()); - CHECK(!sampler->WasSampleStackCalled()); - sampler->Stop(); - - jsThread.Stop(); - nonJsThread.Stop(); - jsThread.Join(); - nonJsThread.Join(); - - delete sampler; -} - -#endif // __linux__ - - // Test for issue http://crbug.com/23768 in Chromium. // Heap can contain scripts with already disposed external sources. // We need to verify that LogCompiledFunctions doesn't crash on them. @@ -535,17 +290,15 @@ TEST(Issue23768) { CcTest::i_isolate()); // This situation can happen if source was an external string disposed // by its owner. - i_source->set_resource(nullptr); + i_source->SetResource(CcTest::i_isolate(), nullptr); // Must not crash. CcTest::i_isolate()->logger()->LogCompiledFunctions(); } - static void ObjMethod1(const v8::FunctionCallbackInfo<v8::Value>& args) { } - TEST(LogCallbacks) { SETUP_FLAGS(); v8::Isolate::CreateParams create_params; @@ -572,21 +325,20 @@ TEST(LogCallbacks) { CompileRun("Obj.prototype.method1.toString();"); logger.LogCompiledFunctions(); - logger.StopLogging(); Address ObjMethod1_entry = reinterpret_cast<Address>(ObjMethod1); #if USES_FUNCTION_DESCRIPTORS ObjMethod1_entry = *FUNCTION_ENTRYPOINT_ADDRESS(ObjMethod1_entry); #endif - i::EmbeddedVector<char, 100> ref_data; - i::SNPrintF(ref_data, ",0x%" V8PRIxPTR ",1,method1", ObjMethod1_entry); - CHECK(logger.FindLine("code-creation,Callback,-2,", ref_data.start())); + i::EmbeddedVector<char, 100> suffix_buffer; + i::SNPrintF(suffix_buffer, ",0x%" V8PRIxPTR ",1,method1", ObjMethod1_entry); + CHECK(logger.ContainsLine( + {"code-creation,Callback,-2,", std::string(suffix_buffer.start())})); } isolate->Dispose(); } - static void Prop1Getter(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { } @@ -600,7 +352,6 @@ static void Prop2Getter(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) { } - TEST(LogAccessorCallbacks) { SETUP_FLAGS(); v8::Isolate::CreateParams create_params; @@ -627,8 +378,8 @@ TEST(LogAccessorCallbacks) { EmbeddedVector<char, 100> prop1_getter_record; i::SNPrintF(prop1_getter_record, ",0x%" V8PRIxPTR ",1,get prop1", Prop1Getter_entry); - CHECK(logger.FindLine("code-creation,Callback,-2,", - prop1_getter_record.start())); + CHECK(logger.ContainsLine({"code-creation,Callback,-2,", + std::string(prop1_getter_record.start())})); Address Prop1Setter_entry = reinterpret_cast<Address>(Prop1Setter); #if USES_FUNCTION_DESCRIPTORS @@ -637,8 +388,8 @@ TEST(LogAccessorCallbacks) { EmbeddedVector<char, 100> prop1_setter_record; i::SNPrintF(prop1_setter_record, ",0x%" V8PRIxPTR ",1,set prop1", Prop1Setter_entry); - CHECK(logger.FindLine("code-creation,Callback,-2,", - prop1_setter_record.start())); + CHECK(logger.ContainsLine({"code-creation,Callback,-2,", + std::string(prop1_setter_record.start())})); Address Prop2Getter_entry = reinterpret_cast<Address>(Prop2Getter); #if USES_FUNCTION_DESCRIPTORS @@ -647,8 +398,8 @@ TEST(LogAccessorCallbacks) { EmbeddedVector<char, 100> prop2_getter_record; i::SNPrintF(prop2_getter_record, ",0x%" V8PRIxPTR ",1,get prop2", Prop2Getter_entry); - CHECK(logger.FindLine("code-creation,Callback,-2,", - prop2_getter_record.start())); + CHECK(logger.ContainsLine({"code-creation,Callback,-2,", + std::string(prop2_getter_record.start())})); } isolate->Dispose(); } @@ -716,7 +467,7 @@ TEST(EquivalenceOfLoggingAndTraversal) { v8::Local<v8::String> s = result->ToString(logger.env()).ToLocalChecked(); i::ScopedVector<char> data(s->Utf8Length(isolate) + 1); CHECK(data.start()); - s->WriteUtf8(data.start()); + s->WriteUtf8(isolate, data.start()); FATAL("%s\n", data.start()); } } @@ -733,11 +484,12 @@ TEST(LogVersion) { ScopedLoggerInitializer logger(saved_log, saved_prof, isolate); logger.StopLogging(); - i::EmbeddedVector<char, 100> ref_data; - i::SNPrintF(ref_data, "%d,%d,%d,%d,%d", i::Version::GetMajor(), + i::EmbeddedVector<char, 100> line_buffer; + i::SNPrintF(line_buffer, "%d,%d,%d,%d,%d", i::Version::GetMajor(), i::Version::GetMinor(), i::Version::GetBuild(), i::Version::GetPatch(), i::Version::IsCandidate()); - CHECK(logger.FindLine("v8-version,", ref_data.start())); + CHECK( + logger.ContainsLine({"v8-version,", std::string(line_buffer.start())})); } isolate->Dispose(); } @@ -810,7 +562,6 @@ TEST(LogAll) { { ScopedLoggerInitializer logger(saved_log, saved_prof, isolate); - // Function that will const char* source_text = "function testAddFn(a,b) { return a + b };" "let result;" @@ -822,16 +573,16 @@ TEST(LogAll) { logger.StopLogging(); // We should find at least one code-creation even for testAddFn(); - CHECK(logger.FindLine("api,v8::Context::New")); - CHECK(logger.FindLine("timer-event-start", "V8.CompileCode")); - CHECK(logger.FindLine("timer-event-end", "V8.CompileCode")); - CHECK(logger.FindLine("code-creation,Script", ":1:1")); - CHECK(logger.FindLine("api,v8::Script::Run")); - CHECK(logger.FindLine("code-creation,LazyCompile,", "testAddFn")); + CHECK(logger.ContainsLine({"api,v8::Context::New"})); + CHECK(logger.ContainsLine({"timer-event-start", "V8.CompileCode"})); + CHECK(logger.ContainsLine({"timer-event-end", "V8.CompileCode"})); + CHECK(logger.ContainsLine({"code-creation,Script", ":1:1"})); + CHECK(logger.ContainsLine({"api,v8::Script::Run"})); + CHECK(logger.ContainsLine({"code-creation,LazyCompile,", "testAddFn"})); if (i::FLAG_opt && !i::FLAG_always_opt) { - CHECK(logger.FindLine("code-deopt,", "soft")); - CHECK(logger.FindLine("timer-event-start", "V8.DeoptimizeCode")); - CHECK(logger.FindLine("timer-event-end", "V8.DeoptimizeCode")); + CHECK(logger.ContainsLine({"code-deopt,", "soft"})); + CHECK(logger.ContainsLine({"timer-event-start", "V8.DeoptimizeCode"})); + CHECK(logger.ContainsLine({"timer-event-end", "V8.DeoptimizeCode"})); } } isolate->Dispose(); @@ -854,8 +605,8 @@ TEST(LogInterpretedFramesNativeStack) { logger.StopLogging(); - CHECK(logger.FindLine("InterpretedFunction", - "testLogInterpretedFramesNativeStack")); + CHECK(logger.ContainsLine( + {"InterpretedFunction", "testLogInterpretedFramesNativeStack"})); } isolate->Dispose(); } @@ -978,9 +729,9 @@ TEST(TraceMaps) { logger.StopLogging(); // Mostly superficial checks. - CHECK(logger.FindLine("map,InitialMap", ",0x")); - CHECK(logger.FindLine("map,Transition", ",0x")); - CHECK(logger.FindLine("map-details", ",0x")); + CHECK(logger.ContainsLine({"map,InitialMap", ",0x"})); + CHECK(logger.ContainsLine({"map,Transition", ",0x"})); + CHECK(logger.ContainsLine({"map-details", ",0x"})); } i::FLAG_trace_maps = false; isolate->Dispose(); @@ -996,9 +747,8 @@ TEST(LogMaps) { { ScopedLoggerInitializer logger(saved_log, saved_prof, isolate); logger.StopLogging(); - // Extract all the map-detail entry addresses from the log. - std::unordered_set<uintptr_t> map_addresses; - logger.ExtractAllAddresses(&map_addresses, "map-details", 2); + std::unordered_set<uintptr_t> map_addresses = + logger.ExtractAllAddresses("map-details", 2); i::Heap* heap = reinterpret_cast<i::Isolate*>(isolate)->heap(); i::HeapIterator iterator(heap); i::DisallowHeapAllocation no_gc; @@ -1011,15 +761,12 @@ TEST(LogMaps) { if (!obj->IsMap()) continue; uintptr_t address = reinterpret_cast<uintptr_t>(obj); if (map_addresses.find(address) != map_addresses.end()) continue; - logger.PrintLog(200); i::Map::cast(obj)->Print(); V8_Fatal(__FILE__, __LINE__, "Map (%p, #%zu) was not logged during startup with --trace-maps!" - "\n# Expected Log Line: map_details, ... %p" - "\n# Use logger::PrintLog() for more details.", + "\n# Expected Log Line: map_details, ... %p", reinterpret_cast<void*>(obj), i, reinterpret_cast<void*>(obj)); } - logger.PrintLog(200); } i::FLAG_log_function_events = false; isolate->Dispose(); @@ -1045,14 +792,12 @@ TEST(ConsoleTimeEvents) { logger.StopLogging(); - const char* pairs[][2] = {{"timer-event-start,default,", nullptr}, - {"timer-event-end,default,", nullptr}, - {"timer-event,default,", nullptr}, - {"timer-event-start,timerEvent1,", nullptr}, - {"timer-event-end,timerEvent1,", nullptr}, - {"timer-event,timerEvent2,", nullptr}, - {"timer-event,timerEvent3,", nullptr}}; - logger.FindLogLines(pairs, arraysize(pairs)); + std::vector<std::vector<std::string>> lines = { + {"timer-event-start,default,"}, {"timer-event-end,default,"}, + {"timer-event,default,"}, {"timer-event-start,timerEvent1,"}, + {"timer-event-end,timerEvent1,"}, {"timer-event,timerEvent2,"}, + {"timer-event,timerEvent3,"}}; + CHECK(logger.ContainsLinesInOrder(lines)); } isolate->Dispose(); @@ -1096,13 +841,13 @@ TEST(LogFunctionEvents) { logger.StopLogging(); // Ignore all the log entries that happened before warmup - const char* start = - logger.FindLine("function,first-execution", "warmUpEndMarkerFunction"); - CHECK_NOT_NULL(start); - const char* pairs[][2] = { + size_t start = logger.IndexOfLine( + {"function,first-execution", "warmUpEndMarkerFunction"}); + CHECK(start != std::string::npos); + std::vector<std::vector<std::string>> lines = { // Create a new script - {"script,create", nullptr}, - {"script-details", nullptr}, + {"script,create"}, + {"script-details"}, // Step 1: parsing top-level script, preparsing functions {"function,preparse-", ",lazyNotExecutedFunction"}, // Missing name for preparsing lazyInnerFunction @@ -1113,11 +858,11 @@ TEST(LogFunctionEvents) { // Missing name for inner preparsing of Foo.foo // {"function,preparse-", nullptr}, // Missing name for top-level script. - {"function,parse-script,", nullptr}, + {"function,parse-script,"}, // Step 2: compiling top-level script and eager functions // - Compiling script without name. - {"function,compile,", nullptr}, + {"function,compile,"}, {"function,compile,", ",eagerFunction"}, // Step 3: start executing script @@ -1141,8 +886,38 @@ TEST(LogFunctionEvents) { {"function,compile-lazy,", ",Foo.foo"}, {"function,first-execution,", ",Foo.foo"}, }; - logger.FindLogLines(pairs, arraysize(pairs), start); + CHECK(logger.ContainsLinesInOrder(lines, start)); } i::FLAG_log_function_events = false; isolate->Dispose(); } + +TEST(BuiltinsNotLoggedAsLazyCompile) { + SETUP_FLAGS(); + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* isolate = v8::Isolate::New(create_params); + { + ScopedLoggerInitializer logger(saved_log, saved_prof, isolate); + + logger.LogCodeObjects(); + logger.LogCompiledFunctions(); + logger.StopLogging(); + + i::Handle<i::Code> builtin = logger.i_isolate()->builtins()->builtin_handle( + i::Builtins::kBooleanConstructor); + i::EmbeddedVector<char, 100> buffer; + + // Should only be logged as "Builtin" with a name, never as "LazyCompile". + i::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,BooleanConstructor", + builtin->InstructionStart(), builtin->InstructionSize()); + CHECK(logger.ContainsLine( + {"code-creation,Builtin,3,", std::string(buffer.start())})); + + i::SNPrintF(buffer, ",0x%" V8PRIxPTR ",%d,", builtin->InstructionStart(), + builtin->InstructionSize()); + CHECK(!logger.ContainsLine( + {"code-creation,LazyCompile,3,", std::string(buffer.start())})); + } + isolate->Dispose(); +} diff --git a/deps/v8/test/cctest/test-macro-assembler-arm.cc b/deps/v8/test/cctest/test-macro-assembler-arm.cc index d442903ea0..3f115af416 100644 --- a/deps/v8/test/cctest/test-macro-assembler-arm.cc +++ b/deps/v8/test/cctest/test-macro-assembler-arm.cc @@ -33,6 +33,7 @@ #include "src/simulator.h" #include "src/v8.h" #include "test/cctest/cctest.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-macro-assembler-mips.cc b/deps/v8/test/cctest/test-macro-assembler-mips.cc index accee77f34..18404d6629 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips.cc @@ -28,7 +28,7 @@ #include <stdlib.h> #include <iostream> // NOLINT(readability/streams) -#include "src/api.h" +#include "src/api-inl.h" #include "src/base/utils/random-number-generator.h" #include "src/macro-assembler.h" #include "src/mips/macro-assembler-mips.h" @@ -236,7 +236,7 @@ TEST(jump_tables5) { { __ BlockTrampolinePoolFor(kNumCases + 6 + 1); PredictableCodeSizeScope predictable( - masm, kNumCases * kPointerSize + ((6 + 1) * Assembler::kInstrSize)); + masm, kNumCases * kPointerSize + ((6 + 1) * kInstrSize)); __ addiupc(at, 6 + 1); __ Lsa(at, at, a0, 2); @@ -294,7 +294,6 @@ TEST(jump_tables6) { const int kSwitchTableCases = 40; - const int kInstrSize = Assembler::kInstrSize; const int kMaxBranchOffset = Assembler::kMaxBranchOffset; const int kTrampolineSlotsSize = Assembler::kTrampolineSlotsSize; const int kSwitchTablePrologueSize = MacroAssembler::kSwitchTablePrologueSize; diff --git a/deps/v8/test/cctest/test-macro-assembler-mips64.cc b/deps/v8/test/cctest/test-macro-assembler-mips64.cc index f982e869fe..9a6e319363 100644 --- a/deps/v8/test/cctest/test-macro-assembler-mips64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-mips64.cc @@ -309,7 +309,7 @@ TEST(jump_tables5) { { __ BlockTrampolinePoolFor(kNumCases * 2 + 6 + 1); PredictableCodeSizeScope predictable( - masm, kNumCases * kPointerSize + ((6 + 1) * Assembler::kInstrSize)); + masm, kNumCases * kPointerSize + ((6 + 1) * kInstrSize)); __ addiupc(at, 6 + 1); __ Dlsa(at, at, a0, 3); @@ -368,7 +368,6 @@ TEST(jump_tables6) { const int kSwitchTableCases = 40; - const int kInstrSize = Assembler::kInstrSize; const int kMaxBranchOffset = Assembler::kMaxBranchOffset; const int kTrampolineSlotsSize = Assembler::kTrampolineSlotsSize; const int kSwitchTablePrologueSize = MacroAssembler::kSwitchTablePrologueSize; diff --git a/deps/v8/test/cctest/test-macro-assembler-x64.cc b/deps/v8/test/cctest/test-macro-assembler-x64.cc index 54924def87..49d57aed21 100644 --- a/deps/v8/test/cctest/test-macro-assembler-x64.cc +++ b/deps/v8/test/cctest/test-macro-assembler-x64.cc @@ -35,6 +35,7 @@ #include "src/objects-inl.h" #include "src/simulator.h" #include "test/cctest/cctest.h" +#include "test/common/assembler-tester.h" namespace v8 { namespace internal { diff --git a/deps/v8/test/cctest/test-object.cc b/deps/v8/test/cctest/test-object.cc index 4a2dccae6d..3f65691141 100644 --- a/deps/v8/test/cctest/test-object.cc +++ b/deps/v8/test/cctest/test-object.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/handles-inl.h" #include "src/heap/factory.h" #include "src/isolate.h" diff --git a/deps/v8/test/cctest/test-parsing.cc b/deps/v8/test/cctest/test-parsing.cc index b48cc493c7..72e3711405 100644 --- a/deps/v8/test/cctest/test-parsing.cc +++ b/deps/v8/test/cctest/test-parsing.cc @@ -33,7 +33,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" #include "src/compiler.h" @@ -92,16 +92,16 @@ TEST(ScanKeywords) { CHECK(static_cast<int>(sizeof(buffer)) >= length); { auto stream = i::ScannerStream::ForTesting(keyword, length); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(&unicode_cache, stream.get(), false); + scanner.Initialize(); CHECK_EQ(key_token.token, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); } // Removing characters will make keyword matching fail. { auto stream = i::ScannerStream::ForTesting(keyword, length - 1); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(&unicode_cache, stream.get(), false); + scanner.Initialize(); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); } @@ -111,8 +111,8 @@ TEST(ScanKeywords) { i::MemMove(buffer, keyword, length); buffer[length] = chars_to_append[j]; auto stream = i::ScannerStream::ForTesting(buffer, length + 1); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(&unicode_cache, stream.get(), false); + scanner.Initialize(); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); } @@ -121,8 +121,8 @@ TEST(ScanKeywords) { i::MemMove(buffer, keyword, length); buffer[length - 1] = '_'; auto stream = i::ScannerStream::ForTesting(buffer, length); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(&unicode_cache, stream.get(), false); + scanner.Initialize(); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); } @@ -188,8 +188,8 @@ TEST(ScanHTMLEndComments) { for (int i = 0; tests[i]; i++) { const char* source = tests[i]; auto stream = i::ScannerStream::ForTesting(source); - i::Scanner scanner(i_isolate->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(i_isolate->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory(&zone, i_isolate->ast_string_constants(), @@ -207,8 +207,8 @@ TEST(ScanHTMLEndComments) { for (int i = 0; fail_tests[i]; i++) { const char* source = fail_tests[i]; auto stream = i::ScannerStream::ForTesting(source); - i::Scanner scanner(i_isolate->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(i_isolate->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory(&zone, i_isolate->ast_string_constants(), @@ -232,8 +232,8 @@ TEST(ScanHtmlComments) { // Disallow HTML comments. { auto stream = i::ScannerStream::ForTesting(src); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), true); + i::Scanner scanner(&unicode_cache, stream.get(), true); + scanner.Initialize(); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::ILLEGAL, scanner.Next()); } @@ -241,8 +241,8 @@ TEST(ScanHtmlComments) { // Skip HTML comments: { auto stream = i::ScannerStream::ForTesting(src); - i::Scanner scanner(&unicode_cache); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(&unicode_cache, stream.get(), false); + scanner.Initialize(); CHECK_EQ(i::Token::IDENTIFIER, scanner.Next()); CHECK_EQ(i::Token::EOS, scanner.Next()); } @@ -280,8 +280,8 @@ TEST(StandAlonePreParser) { uintptr_t stack_limit = i_isolate->stack_guard()->real_climit(); for (int i = 0; programs[i]; i++) { auto stream = i::ScannerStream::ForTesting(programs[i]); - i::Scanner scanner(i_isolate->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(i_isolate->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory(&zone, @@ -313,8 +313,8 @@ TEST(StandAlonePreParserNoNatives) { uintptr_t stack_limit = isolate->stack_guard()->real_climit(); for (int i = 0; programs[i]; i++) { auto stream = i::ScannerStream::ForTesting(programs[i]); - i::Scanner scanner(isolate->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(isolate->unicode_cache(), stream.get(), false); + scanner.Initialize(); // Preparser defaults to disallowing natives syntax. i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); @@ -348,8 +348,8 @@ TEST(RegressChromium62639) { // failed in debug mode, and sometimes crashed in release mode. auto stream = i::ScannerStream::ForTesting(program); - i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( &zone, CcTest::i_isolate()->ast_string_constants(), @@ -381,8 +381,8 @@ TEST(PreParseOverflow) { uintptr_t stack_limit = isolate->stack_guard()->real_climit(); auto stream = i::ScannerStream::ForTesting(program.get(), kProgramSize); - i::Scanner scanner(isolate->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(isolate->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( @@ -396,13 +396,12 @@ TEST(PreParseOverflow) { CHECK_EQ(i::PreParser::kPreParseStackOverflow, result); } - void TestStreamScanner(i::Utf16CharacterStream* stream, i::Token::Value* expected_tokens, int skip_pos = 0, // Zero means not skipping. int skip_to = 0) { - i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); - scanner.Initialize(stream, false); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), stream, false); + scanner.Initialize(); int i = 0; do { @@ -479,8 +478,8 @@ TEST(StreamScanner) { void TestScanRegExp(const char* re_source, const char* expected) { auto stream = i::ScannerStream::ForTesting(re_source); i::HandleScope scope(CcTest::i_isolate()); - i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); - scanner.Initialize(stream.get(), false); + i::Scanner scanner(CcTest::i_isolate()->unicode_cache(), stream.get(), false); + scanner.Initialize(); i::Token::Value start = scanner.peek(); CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); @@ -1172,9 +1171,9 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, // Preparse the data. i::PendingCompilationErrorHandler pending_error_handler; if (test_preparser) { - i::Scanner scanner(isolate->unicode_cache()); std::unique_ptr<i::Utf16CharacterStream> stream( i::ScannerStream::For(isolate, source)); + i::Scanner scanner(isolate->unicode_cache(), stream.get(), is_module); i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( &zone, CcTest::i_isolate()->ast_string_constants(), @@ -1184,7 +1183,7 @@ void TestParserSyncWithFlags(i::Handle<i::String> source, isolate->counters()->runtime_call_stats(), isolate->logger(), -1, is_module); SetParserFlags(&preparser, flags); - scanner.Initialize(stream.get(), is_module); + scanner.Initialize(); i::PreParser::PreParseResult result = preparser.PreParseProgram(); CHECK_EQ(i::PreParser::kPreParseSuccess, result); } diff --git a/deps/v8/test/cctest/test-profile-generator.cc b/deps/v8/test/cctest/test-profile-generator.cc index b53bf148e6..c4ad1babc5 100644 --- a/deps/v8/test/cctest/test-profile-generator.cc +++ b/deps/v8/test/cctest/test-profile-generator.cc @@ -28,7 +28,7 @@ // Tests of profiles generator and utilities. #include "include/v8-profiler.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/profiler/cpu-profiler.h" #include "src/profiler/profile-generator-inl.h" diff --git a/deps/v8/test/cctest/test-regexp.cc b/deps/v8/test/cctest/test-regexp.cc index bcabebf639..c65714a930 100644 --- a/deps/v8/test/cctest/test-regexp.cc +++ b/deps/v8/test/cctest/test-regexp.cc @@ -32,7 +32,7 @@ #include "include/v8.h" #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/ast/ast.h" #include "src/char-predicates-inl.h" #include "src/objects-inl.h" diff --git a/deps/v8/test/cctest/test-roots.cc b/deps/v8/test/cctest/test-roots.cc index e6220be889..f99b9df399 100644 --- a/deps/v8/test/cctest/test-roots.cc +++ b/deps/v8/test/cctest/test-roots.cc @@ -74,16 +74,23 @@ TEST(TestAllocationSiteMaps) { #undef CHECK_IN_RO_SPACE namespace { -bool IsInitiallyMutable(Heap* heap, Object* object) { +bool IsInitiallyMutable(Factory* factory, Address object_address) { // Entries in this list are in STRONG_MUTABLE_ROOT_LIST, but may initially point // to objects that in RO_SPACE. -#define INITIALLY_READ_ONLY_ROOT_LIST(V) \ - V(materialized_objects) \ - V(retaining_path_targets) \ - V(retained_maps) +#define INITIALLY_READ_ONLY_ROOT_LIST(V) \ + V(builtins_constants_table) \ + V(detached_contexts) \ + V(feedback_vectors_for_profiling_tools) \ + V(materialized_objects) \ + V(microtask_queue) \ + V(noscript_shared_function_infos) \ + V(retained_maps) \ + V(retaining_path_targets) \ + V(serialized_global_proxy_sizes) \ + V(serialized_objects) #define TEST_CAN_BE_READ_ONLY(name) \ - if (heap->name() == object) return false; + if (factory->name().address() == object_address) return false; INITIALLY_READ_ONLY_ROOT_LIST(TEST_CAN_BE_READ_ONLY) #undef TEST_CAN_BE_READ_ONLY #undef INITIALLY_READ_ONLY_ROOT_LIST @@ -91,15 +98,21 @@ bool IsInitiallyMutable(Heap* heap, Object* object) { } } // namespace -#define CHECK_NOT_IN_RO_SPACE(name) \ - Object* name = heap->name(); \ - if (name->IsHeapObject() && IsInitiallyMutable(heap, name)) \ - CHECK_NE(RO_SPACE, GetSpaceFromObject(name)); +// The CHECK_EQ line is there just to ensure that the root is publicly +// accessible from Heap, but ultimately the factory is used as it provides +// handles that have the address in the root table. +#define CHECK_NOT_IN_RO_SPACE(name) \ + Handle<Object> name = factory->name(); \ + CHECK_EQ(*name, heap->name()); \ + if (name->IsHeapObject() && IsInitiallyMutable(factory, name.address())) \ + CHECK_NE(RO_SPACE, \ + GetSpaceFromObject(reinterpret_cast<HeapObject*>(*name))); // The following tests check that all the roots accessible via public Heap // accessors are not in RO_SPACE with the exception of the objects listed in // INITIALLY_READ_ONLY_ROOT_LIST. TEST(TestHeapRootsNotReadOnly) { + Factory* factory = CcTest::i_isolate()->factory(); Heap* heap = CcTest::i_isolate()->heap(); #define TEST_ROOT(type, name, camel_name) CHECK_NOT_IN_RO_SPACE(name) @@ -108,6 +121,7 @@ TEST(TestHeapRootsNotReadOnly) { } TEST(TestAccessorInfosNotReadOnly) { + Factory* factory = CcTest::i_isolate()->factory(); Heap* heap = CcTest::i_isolate()->heap(); #define TEST_ROOT(name, AccessorName) CHECK_NOT_IN_RO_SPACE(name##_accessor) diff --git a/deps/v8/test/cctest/test-serialize.cc b/deps/v8/test/cctest/test-serialize.cc index 8a2fe60b11..d3fd665a66 100644 --- a/deps/v8/test/cctest/test-serialize.cc +++ b/deps/v8/test/cctest/test-serialize.cc @@ -31,7 +31,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/bootstrapper.h" #include "src/compilation-cache.h" @@ -40,6 +40,8 @@ #include "src/heap/spaces.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" +#include "src/objects/js-array-buffer-inl.h" +#include "src/objects/js-array-inl.h" #include "src/runtime/runtime.h" #include "src/snapshot/builtin-deserializer.h" #include "src/snapshot/builtin-serializer.h" @@ -372,7 +374,6 @@ UNINITIALIZED_TEST(StartupSerializerRootMapDependencies) { // - NullValue // - Internalized one byte string // - Map for Internalized one byte string - // - WeakCell // - TheHoleValue // - HeapNumber // HeapNumber objects require kDoubleUnaligned on 32-bit @@ -381,7 +382,6 @@ UNINITIALIZED_TEST(StartupSerializerRootMapDependencies) { v8::internal::Handle<Map> map( ReadOnlyRoots(internal_isolate).one_byte_internalized_string_map(), internal_isolate); - Map::WeakCellForMap(internal_isolate, map); // Need to avoid DCHECKs inside SnapshotCreator. snapshot_creator.SetDefaultContext(v8::Context::New(isolate)); } @@ -1365,9 +1365,9 @@ static Handle<SharedFunctionInfo> CompileScript( Isolate* isolate, Handle<String> source, Handle<String> name, ScriptData* cached_data, v8::ScriptCompiler::CompileOptions options) { return Compiler::GetSharedFunctionInfoForScript( - source, Compiler::ScriptDetails(name), v8::ScriptOriginOptions(), - nullptr, cached_data, options, ScriptCompiler::kNoCacheNoReason, - NOT_NATIVES_CODE) + isolate, source, Compiler::ScriptDetails(name), + v8::ScriptOriginOptions(), nullptr, cached_data, options, + ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE) .ToHandleChecked(); } @@ -1376,9 +1376,9 @@ static Handle<SharedFunctionInfo> CompileScriptAndProduceCache( ScriptData** script_data, v8::ScriptCompiler::CompileOptions options) { Handle<SharedFunctionInfo> sfi = Compiler::GetSharedFunctionInfoForScript( - source, Compiler::ScriptDetails(name), v8::ScriptOriginOptions(), - nullptr, nullptr, options, ScriptCompiler::kNoCacheNoReason, - NOT_NATIVES_CODE) + isolate, source, Compiler::ScriptDetails(name), + v8::ScriptOriginOptions(), nullptr, nullptr, options, + ScriptCompiler::kNoCacheNoReason, NOT_NATIVES_CODE) .ToHandleChecked(); std::unique_ptr<ScriptCompiler::CachedData> cached_data( ScriptCompiler::CreateCodeCache(ToApiHandle<UnboundScript>(sfi))); @@ -1440,6 +1440,13 @@ void TestCodeSerializerOnePlusOneImpl() { TEST(CodeSerializerOnePlusOne) { TestCodeSerializerOnePlusOneImpl(); } +TEST(CodeSerializerOnePlusOneWithDebugger) { + v8::HandleScope scope(CcTest::isolate()); + static v8::debug::DebugDelegate dummy_delegate; + v8::debug::SetDebugDelegate(CcTest::isolate(), &dummy_delegate); + TestCodeSerializerOnePlusOneImpl(); +} + TEST(CodeSerializerOnePlusOne1) { FLAG_serialization_chunk_size = 1; TestCodeSerializerOnePlusOneImpl(); @@ -1903,9 +1910,9 @@ TEST(CodeSerializerExternalString) { // This avoids the GC from trying to free stack allocated resources. i::Handle<i::ExternalOneByteString>::cast(one_byte_string) - ->set_resource(nullptr); + ->SetResource(isolate, nullptr); i::Handle<i::ExternalTwoByteString>::cast(two_byte_string) - ->set_resource(nullptr); + ->SetResource(isolate, nullptr); delete cache; } @@ -1963,7 +1970,8 @@ TEST(CodeSerializerLargeExternalString) { CHECK_EQ(42.0, copy_result->Number()); // This avoids the GC from trying to free stack allocated resources. - i::Handle<i::ExternalOneByteString>::cast(name)->set_resource(nullptr); + i::Handle<i::ExternalOneByteString>::cast(name)->SetResource(isolate, + nullptr); delete cache; string.Dispose(); } @@ -2014,7 +2022,8 @@ TEST(CodeSerializerExternalScriptName) { CHECK_EQ(10.0, copy_result->Number()); // This avoids the GC from trying to free stack allocated resources. - i::Handle<i::ExternalOneByteString>::cast(name)->set_resource(nullptr); + i::Handle<i::ExternalOneByteString>::cast(name)->SetResource(isolate, + nullptr); delete cache; } diff --git a/deps/v8/test/cctest/test-strings.cc b/deps/v8/test/cctest/test-strings.cc index d5ef8af652..8aa621b1c1 100644 --- a/deps/v8/test/cctest/test-strings.cc +++ b/deps/v8/test/cctest/test-strings.cc @@ -34,7 +34,7 @@ #include "src/v8.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/heap/factory.h" #include "src/messages.h" #include "src/objects-inl.h" @@ -951,7 +951,8 @@ TEST(Utf8Conversion) { for (int j = 0; j < 11; j++) buffer[j] = kNoChar; int chars_written; - int written = mixed->WriteUtf8(buffer, i, &chars_written); + int written = + mixed->WriteUtf8(CcTest::isolate(), buffer, i, &chars_written); CHECK_EQ(lengths[i], written); CHECK_EQ(char_lengths[i], chars_written); // Check that the contents are correct @@ -1095,7 +1096,7 @@ TEST(JSONStringifySliceMadeExternal) { int length = underlying->Length(); uc16* two_byte = NewArray<uc16>(length + 1); - underlying->Write(two_byte); + underlying->Write(CcTest::isolate(), two_byte); Resource* resource = new Resource(two_byte, length); CHECK(underlying->MakeExternal(resource)); CHECK(v8::Utils::OpenHandle(*slice)->IsSlicedString()); @@ -1245,7 +1246,8 @@ TEST(SliceFromExternal) { CHECK(SlicedString::cast(*slice)->parent()->IsExternalString()); CHECK(slice->IsFlat()); // This avoids the GC from trying to free stack allocated resources. - i::Handle<i::ExternalOneByteString>::cast(string)->set_resource(nullptr); + i::Handle<i::ExternalOneByteString>::cast(string)->SetResource( + CcTest::i_isolate(), nullptr); } @@ -1526,8 +1528,9 @@ TEST(FormatMessage) { Handle<String> arg1 = isolate->factory()->NewStringFromAsciiChecked("arg1"); Handle<String> arg2 = isolate->factory()->NewStringFromAsciiChecked("arg2"); Handle<String> result = - MessageTemplate::FormatMessage(MessageTemplate::kPropertyNotFunction, - arg0, arg1, arg2).ToHandleChecked(); + MessageTemplate::FormatMessage( + isolate, MessageTemplate::kPropertyNotFunction, arg0, arg1, arg2) + .ToHandleChecked(); Handle<String> expected = isolate->factory()->NewStringFromAsciiChecked( "'arg0' returned for property 'arg1' of object 'arg2' is not a function"); CHECK(String::Equals(isolate, result, expected)); @@ -1661,6 +1664,35 @@ TEST(HashArrayIndexStrings) { isolate->factory()->one_string()->Hash()); } +TEST(StringEquals) { + v8::V8::Initialize(); + v8::Isolate* isolate = CcTest::isolate(); + v8::HandleScope scope(isolate); + + auto foo_str = + v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal) + .ToLocalChecked(); + auto bar_str = + v8::String::NewFromUtf8(isolate, "bar", v8::NewStringType::kNormal) + .ToLocalChecked(); + auto foo_str2 = + v8::String::NewFromUtf8(isolate, "foo", v8::NewStringType::kNormal) + .ToLocalChecked(); + + uint16_t* two_byte_source = AsciiToTwoByteString("foo"); + auto foo_two_byte_str = + v8::String::NewFromTwoByte(isolate, two_byte_source, + v8::NewStringType::kNormal) + .ToLocalChecked(); + i::DeleteArray(two_byte_source); + + CHECK(foo_str->StringEquals(foo_str)); + CHECK(!foo_str->StringEquals(bar_str)); + CHECK(foo_str->StringEquals(foo_str2)); + CHECK(foo_str->StringEquals(foo_two_byte_str)); + CHECK(!bar_str->StringEquals(foo_str2)); +} + } // namespace test_strings } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/test-thread-termination.cc b/deps/v8/test/cctest/test-thread-termination.cc index ddfc262807..902295447b 100644 --- a/deps/v8/test/cctest/test-thread-termination.cc +++ b/deps/v8/test/cctest/test-thread-termination.cc @@ -25,7 +25,7 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "src/api.h" +#include "src/api-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/v8.h" diff --git a/deps/v8/test/cctest/test-trace-event.cc b/deps/v8/test/cctest/test-trace-event.cc index 47545af37f..10b837aaed 100644 --- a/deps/v8/test/cctest/test-trace-event.cc +++ b/deps/v8/test/cctest/test-trace-event.cc @@ -289,6 +289,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); LocalContext env; v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); @@ -307,7 +308,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue()); + CHECK(result->BooleanValue(context).ToChecked()); } { @@ -317,7 +318,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(!result->BooleanValue()); + CHECK(!result->BooleanValue(context).ToChecked()); } { @@ -327,7 +328,7 @@ TEST(BuiltinsIsTraceCategoryEnabled) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue()); + CHECK(result->BooleanValue(context).ToChecked()); } } @@ -337,6 +338,7 @@ TEST(BuiltinsTrace) { v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope handle_scope(isolate); + v8::Local<v8::Context> context = isolate->GetCurrentContext(); LocalContext env; v8::Local<v8::Object> binding = env->GetExtrasBindingObject(); @@ -360,7 +362,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(!result->BooleanValue()); + CHECK(!result->BooleanValue(context).ToChecked()); CHECK_EQ(0, GET_TRACE_OBJECTS_LIST->size()); } @@ -368,7 +370,6 @@ TEST(BuiltinsTrace) { { v8::Local<v8::String> category = v8_str("v8-cat"); v8::Local<v8::String> name = v8_str("name"); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Object> data = v8::Object::New(isolate); data->Set(context, v8_str("foo"), v8_str("bar")).FromJust(); v8::Local<v8::Value> argv[] = { @@ -380,7 +381,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue()); + CHECK(result->BooleanValue(context).ToChecked()); CHECK_EQ(1, GET_TRACE_OBJECTS_LIST->size()); CHECK_EQ(123, GET_TRACE_OBJECT(0)->id); @@ -393,7 +394,6 @@ TEST(BuiltinsTrace) { { v8::Local<v8::String> category = v8_str("v8-cat\u20ac"); v8::Local<v8::String> name = v8_str("name\u20ac"); - v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Object> data = v8::Object::New(isolate); data->Set(context, v8_str("foo"), v8_str("bar")).FromJust(); v8::Local<v8::Value> argv[] = { @@ -405,7 +405,7 @@ TEST(BuiltinsTrace) { .ToLocalChecked() .As<v8::Boolean>(); - CHECK(result->BooleanValue()); + CHECK(result->BooleanValue(context).ToChecked()); CHECK_EQ(2, GET_TRACE_OBJECTS_LIST->size()); CHECK_EQ(123, GET_TRACE_OBJECT(1)->id); diff --git a/deps/v8/test/cctest/test-typedarrays.cc b/deps/v8/test/cctest/test-typedarrays.cc index bab6e0f2f6..b574fdd94a 100644 --- a/deps/v8/test/cctest/test-typedarrays.cc +++ b/deps/v8/test/cctest/test-typedarrays.cc @@ -7,7 +7,6 @@ #include "src/v8.h" #include "test/cctest/cctest.h" -#include "src/api.h" #include "src/heap/heap.h" #include "src/objects-inl.h" #include "src/objects.h" @@ -92,7 +91,7 @@ void TestSpeciesProtector(char* code, v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); std::string typed_array_constructors[] = { -#define TYPED_ARRAY_CTOR(Type, type, TYPE, ctype, size) #Type "Array", +#define TYPED_ARRAY_CTOR(Type, type, TYPE, ctype) #Type "Array", TYPED_ARRAYS(TYPED_ARRAY_CTOR) #undef TYPED_ARRAY_CTOR diff --git a/deps/v8/test/cctest/test-types.cc b/deps/v8/test/cctest/test-types.cc index 831593f17b..c8d5e37fa2 100644 --- a/deps/v8/test/cctest/test-types.cc +++ b/deps/v8/test/cctest/test-types.cc @@ -33,12 +33,14 @@ struct Tests { Isolate* isolate; HandleScope scope; + CanonicalHandleScope canonical; Zone zone; Types T; Tests() : isolate(CcTest::InitIsolateOnce()), scope(isolate), + canonical(isolate), zone(isolate->allocator(), ZONE_NAME), T(&zone, isolate, isolate->random_number_generator()) {} diff --git a/deps/v8/test/cctest/test-unboxed-doubles.cc b/deps/v8/test/cctest/test-unboxed-doubles.cc index 2d63a87fc2..421407180c 100644 --- a/deps/v8/test/cctest/test-unboxed-doubles.cc +++ b/deps/v8/test/cctest/test-unboxed-doubles.cc @@ -8,7 +8,7 @@ #include "src/v8.h" #include "src/accessors.h" -#include "src/api.h" +#include "src/api-inl.h" #include "src/compilation-cache.h" #include "src/execution.h" #include "src/field-type.h" @@ -124,7 +124,7 @@ static Handle<DescriptorArray> CreateDescriptorArray(Isolate* isolate, d = Descriptor::AccessorConstant(name, info, NONE); } else { - d = Descriptor::DataField(name, next_field_offset, NONE, + d = Descriptor::DataField(isolate, name, next_field_offset, NONE, representations[kind]); } descriptors->Append(&d); @@ -658,7 +658,7 @@ static Handle<LayoutDescriptor> TestLayoutDescriptorAppend( d = Descriptor::AccessorConstant(name, info, NONE); } else { - d = Descriptor::DataField(name, next_field_offset, NONE, + d = Descriptor::DataField(isolate, name, next_field_offset, NONE, representations[kind]); } PropertyDetails details = d.GetDetails(); diff --git a/deps/v8/test/cctest/test-utils.cc b/deps/v8/test/cctest/test-utils.cc index c1c15873e9..1f5c7c6a70 100644 --- a/deps/v8/test/cctest/test-utils.cc +++ b/deps/v8/test/cctest/test-utils.cc @@ -31,6 +31,7 @@ #include "src/v8.h" +#include "src/api-inl.h" #include "src/base/platform/platform.h" #include "src/collector.h" #include "src/conversions.h" diff --git a/deps/v8/test/cctest/torque/test-torque.cc b/deps/v8/test/cctest/torque/test-torque.cc index 11a683f85e..439fe043b8 100644 --- a/deps/v8/test/cctest/torque/test-torque.cc +++ b/deps/v8/test/cctest/torque/test-torque.cc @@ -4,7 +4,6 @@ #include <cmath> -#include "src/api.h" #include "src/base/utils/random-number-generator.h" #include "src/builtins/builtins-promise-gen.h" #include "src/builtins/builtins-string-gen.h" @@ -224,6 +223,42 @@ TEST(TestLocalConstBindings) { ft.Call(); } +TEST(TestForLoop) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + TestBuiltinsFromDSLAssembler m(asm_tester.state()); + { + m.TestForLoop(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + +TEST(TestTypeswitch) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + TestBuiltinsFromDSLAssembler m(asm_tester.state()); + { + m.TestTypeswitch(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + +TEST(TestGenericOverload) { + Isolate* isolate(CcTest::InitIsolateOnce()); + CodeAssemblerTester asm_tester(isolate, 0); + TestBuiltinsFromDSLAssembler m(asm_tester.state()); + { + m.TestGenericOverload(); + m.Return(m.UndefinedConstant()); + } + FunctionTester ft(asm_tester.GenerateCode(), 0); + ft.Call(); +} + } // namespace compiler } // namespace internal } // namespace v8 diff --git a/deps/v8/test/cctest/types-fuzz.h b/deps/v8/test/cctest/types-fuzz.h index db264db42c..b6b5bf2dc5 100644 --- a/deps/v8/test/cctest/types-fuzz.h +++ b/deps/v8/test/cctest/types-fuzz.h @@ -40,7 +40,7 @@ namespace compiler { class Types { public: Types(Zone* zone, Isolate* isolate, v8::base::RandomNumberGenerator* rng) - : zone_(zone), js_heap_broker_(isolate), rng_(rng) { + : zone_(zone), js_heap_broker_(isolate, zone), rng_(rng) { #define DECLARE_TYPE(name, value) \ name = Type::name(); \ types.push_back(name); @@ -209,7 +209,7 @@ class Types { } Zone* zone() { return zone_; } - const JSHeapBroker* js_heap_broker() const { return &js_heap_broker_; } + JSHeapBroker* js_heap_broker() { return &js_heap_broker_; } private: Zone* zone_; diff --git a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc index 23a0c3369b..e56060bdd9 100644 --- a/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc +++ b/deps/v8/test/cctest/wasm/test-c-wasm-entry.cc @@ -30,7 +30,7 @@ class CWasmEntryArgTester { public: CWasmEntryArgTester(std::initializer_list<uint8_t> wasm_function_bytes, std::function<ReturnType(Args...)> expected_fn) - : runner_(kExecuteTurbofan), + : runner_(ExecutionTier::kOptimized), isolate_(runner_.main_isolate()), expected_fn_(expected_fn), sig_(runner_.template CreateSig<ReturnType, Args...>()) { @@ -93,7 +93,7 @@ class CWasmEntryArgTester { std::function<ReturnType(Args...)> expected_fn_; FunctionSig* sig_; Handle<JSFunction> c_wasm_entry_fn_; - wasm::WasmCode* wasm_code_; + WasmCode* wasm_code_; }; } // namespace diff --git a/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc b/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc new file mode 100644 index 0000000000..53ee5eedd1 --- /dev/null +++ b/deps/v8/test/cctest/wasm/test-jump-table-assembler.cc @@ -0,0 +1,199 @@ +// Copyright 2018 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/assembler-inl.h" +#include "src/macro-assembler-inl.h" +#include "src/simulator.h" +#include "src/utils.h" +#include "src/wasm/jump-table-assembler.h" +#include "test/cctest/cctest.h" +#include "test/common/assembler-tester.h" + +namespace v8 { +namespace internal { +namespace wasm { + +#if 0 +#define TRACE(...) PrintF(__VA_ARGS__) +#else +#define TRACE(...) +#endif + +#define __ masm. + +// TODO(v8:7424,v8:8018): Extend this test to all architectures. +#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || \ + V8_TARGET_ARCH_ARM64 + +namespace { + +static volatile int global_stop_bit = 0; + +Address GenerateJumpTableThunk(Address jump_target) { + size_t allocated; + byte* buffer; +#if V8_TARGET_ARCH_ARM64 + // TODO(wasm): Currently {kMaxWasmCodeMemory} limits code sufficiently, so + // that the jump table only supports {near_call} distances. + const uintptr_t kThunkAddrMask = (1 << WhichPowerOf2(kMaxWasmCodeMemory)) - 1; + const int kArbitrarilyChosenRetryCount = 10; // Retry to avoid flakes. + for (int retry = 0; retry < kArbitrarilyChosenRetryCount; ++retry) { + Address random_addr = reinterpret_cast<Address>(GetRandomMmapAddr()); + void* address = reinterpret_cast<void*>((jump_target & ~kThunkAddrMask) | + (random_addr & kThunkAddrMask)); + buffer = AllocateAssemblerBuffer( + &allocated, AssemblerBase::kMinimalBufferSize, address); + Address bufferptr = reinterpret_cast<uintptr_t>(buffer); + if ((bufferptr & ~kThunkAddrMask) == (jump_target & ~kThunkAddrMask)) break; + } +#else + buffer = AllocateAssemblerBuffer( + &allocated, AssemblerBase::kMinimalBufferSize, GetRandomMmapAddr()); +#endif + MacroAssembler masm(nullptr, AssemblerOptions{}, buffer, + static_cast<int>(allocated), CodeObjectRequired::kNo); + + Label exit; + Register scratch = kReturnRegister0; + Address stop_bit_address = reinterpret_cast<Address>(&global_stop_bit); +#if V8_TARGET_ARCH_X64 + __ Move(scratch, stop_bit_address, RelocInfo::NONE); + __ testl(MemOperand(scratch, 0), Immediate(1)); + __ j(not_zero, &exit); + __ Jump(jump_target, RelocInfo::NONE); +#elif V8_TARGET_ARCH_IA32 + __ Move(scratch, Immediate(stop_bit_address, RelocInfo::NONE)); + __ test(MemOperand(scratch, 0), Immediate(1)); + __ j(not_zero, &exit); + __ jmp(jump_target, RelocInfo::NONE); +#elif V8_TARGET_ARCH_ARM + __ mov(scratch, Operand(stop_bit_address, RelocInfo::NONE)); + __ ldr(scratch, MemOperand(scratch, 0)); + __ tst(scratch, Operand(1)); + __ b(ne, &exit); + __ Jump(jump_target, RelocInfo::NONE); +#elif V8_TARGET_ARCH_ARM64 + __ Mov(scratch, Operand(stop_bit_address, RelocInfo::NONE)); + __ Ldr(scratch, MemOperand(scratch, 0)); + __ Tbnz(scratch, 0, &exit); + __ Mov(scratch, Immediate(jump_target, RelocInfo::NONE)); + __ Br(scratch); +#else +#error Unsupported architecture +#endif + __ bind(&exit); + __ Ret(); + + CodeDesc desc; + masm.GetCode(nullptr, &desc); + MakeAssemblerBufferExecutable(buffer, allocated); + return reinterpret_cast<Address>(buffer); +} + +class JumpTableRunner : public v8::base::Thread { + public: + JumpTableRunner(Address slot_address, int runner_id) + : Thread(Options("JumpTableRunner")), + slot_address_(slot_address), + runner_id_(runner_id) {} + + void Run() override { + TRACE("Runner #%d is starting ...\n", runner_id_); + GeneratedCode<void>::FromAddress(CcTest::i_isolate(), slot_address_).Call(); + TRACE("Runner #%d is stopping ...\n", runner_id_); + USE(runner_id_); + } + + private: + Address slot_address_; + int runner_id_; +}; + +class JumpTablePatcher : public v8::base::Thread { + public: + JumpTablePatcher(Address slot_start, uint32_t slot_index, Address thunk1, + Address thunk2) + : Thread(Options("JumpTablePatcher")), + slot_start_(slot_start), + slot_index_(slot_index), + thunks_{thunk1, thunk2} {} + + void Run() override { + TRACE("Patcher is starting ...\n"); + constexpr int kNumberOfPatchIterations = 64; + for (int i = 0; i < kNumberOfPatchIterations; ++i) { + TRACE(" patch slot " V8PRIxPTR_FMT " to thunk #%d\n", + slot_start_ + JumpTableAssembler::SlotIndexToOffset(slot_index_), + i % 2); + JumpTableAssembler::PatchJumpTableSlot( + slot_start_, slot_index_, thunks_[i % 2], WasmCode::kFlushICache); + } + TRACE("Patcher is stopping ...\n"); + } + + private: + Address slot_start_; + uint32_t slot_index_; + Address thunks_[2]; +}; + +} // namespace + +// This test is intended to stress concurrent patching of jump-table slots. It +// uses the following setup: +// 1) Picks a particular slot of the jump-table. Slots are iterated over to +// ensure multiple entries (at different offset alignments) are tested. +// 2) Starts multiple runners that spin through the above slot. The runners +// use thunk code that will jump to the same jump-table slot repeatedly +// until the {global_stop_bit} indicates a test-end condition. +// 3) Start a patcher that repeatedly patches the jump-table slot back and +// forth between two thunk. If there is a race then chances are high that +// one of the runners is currently executing the jump-table slot. +TEST(JumpTablePatchingStress) { + constexpr int kJumpTableSlotCount = 128; + constexpr int kNumberOfRunnerThreads = 5; + + size_t allocated; + byte* buffer = AllocateAssemblerBuffer( + &allocated, + JumpTableAssembler::SizeForNumberOfSlots(kJumpTableSlotCount)); + + // Iterate through jump-table slots to hammer at different alignments within + // the jump-table, thereby increasing stress for variable-length ISAs. + Address slot_start = reinterpret_cast<Address>(buffer); + for (int slot = 0; slot < kJumpTableSlotCount; ++slot) { + TRACE("Hammering on jump table slot #%d ...\n", slot); + uint32_t slot_offset = JumpTableAssembler::SlotIndexToOffset(slot); + Address thunk1 = GenerateJumpTableThunk(slot_start + slot_offset); + Address thunk2 = GenerateJumpTableThunk(slot_start + slot_offset); + TRACE(" generated thunk1: " V8PRIxPTR_FMT "\n", thunk1); + TRACE(" generated thunk2: " V8PRIxPTR_FMT "\n", thunk2); + JumpTableAssembler::PatchJumpTableSlot(slot_start, slot, thunk1, + WasmCode::kFlushICache); + + // Start multiple runner threads and a patcher thread that hammer on the + // same jump-table slot concurrently. + std::list<JumpTableRunner> runners; + for (int runner = 0; runner < kNumberOfRunnerThreads; ++runner) { + runners.emplace_back(slot_start + slot_offset, runner); + } + JumpTablePatcher patcher(slot_start, slot, thunk1, thunk2); + global_stop_bit = 0; // Signal runners to keep going. + for (auto& runner : runners) runner.Start(); + patcher.Start(); + patcher.Join(); + global_stop_bit = -1; // Signal runners to stop. + for (auto& runner : runners) runner.Join(); + } +} + +#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_ARM || + // V8_TARGET_ARCH_ARM64 + +#undef __ +#undef TRACE + +} // namespace wasm +} // namespace internal +} // namespace v8 diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc index 157dd519b1..be45f5bc17 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-64.cc @@ -22,7 +22,7 @@ namespace wasm { namespace test_run_wasm_64 { WASM_EXEC_TEST(I64Const) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); const int64_t kExpectedValue = 0x1122334455667788LL; // return(kExpectedValue) BUILD(r, WASM_I64V_9(kExpectedValue)); @@ -32,7 +32,7 @@ WASM_EXEC_TEST(I64Const) { WASM_EXEC_TEST(I64Const_many) { int cntr = 0; FOR_INT32_INPUTS(i) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); const int64_t kExpectedValue = (static_cast<int64_t>(*i) << 32) | cntr; // return(kExpectedValue) BUILD(r, WASM_I64V(kExpectedValue)); @@ -42,7 +42,7 @@ WASM_EXEC_TEST(I64Const_many) { } WASM_EXEC_TEST(Return_I64) { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_RETURN1(WASM_GET_LOCAL(0))); @@ -50,7 +50,7 @@ WASM_EXEC_TEST(Return_I64) { } WASM_EXEC_TEST(I64Add) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i + *j, r.Call(*i, *j)); } @@ -63,7 +63,7 @@ WASM_EXEC_TEST(I64Add) { const int64_t kHasBit33On = 0x100000000; WASM_EXEC_TEST(Regress5800_Add) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_ADD( WASM_I64V(0), WASM_I64V(kHasBit33On)))), WASM_RETURN1(WASM_I32V(0))), @@ -72,7 +72,7 @@ WASM_EXEC_TEST(Regress5800_Add) { } WASM_EXEC_TEST(I64Sub) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i - *j, r.Call(*i, *j)); } @@ -80,7 +80,7 @@ WASM_EXEC_TEST(I64Sub) { } WASM_EXEC_TEST(Regress5800_Sub) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_I64_EQZ(WASM_I64_SUB( WASM_I64V(0), WASM_I64V(kHasBit33On)))), WASM_RETURN1(WASM_I32V(0))), @@ -89,7 +89,7 @@ WASM_EXEC_TEST(Regress5800_Sub) { } WASM_EXEC_TEST(I64AddUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_INT64_INPUTS(i) { @@ -100,7 +100,7 @@ WASM_EXEC_TEST(I64AddUseOnlyLowWord) { } WASM_EXEC_TEST(I64SubUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_INT64_INPUTS(i) { @@ -111,7 +111,7 @@ WASM_EXEC_TEST(I64SubUseOnlyLowWord) { } WASM_EXEC_TEST(I64MulUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_INT64_INPUTS(i) { @@ -122,7 +122,7 @@ WASM_EXEC_TEST(I64MulUseOnlyLowWord) { } WASM_EXEC_TEST(I64ShlUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_INT64_INPUTS(i) { @@ -134,7 +134,7 @@ WASM_EXEC_TEST(I64ShlUseOnlyLowWord) { } WASM_EXEC_TEST(I64ShrUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_UINT64_INPUTS(i) { @@ -146,7 +146,7 @@ WASM_EXEC_TEST(I64ShrUseOnlyLowWord) { } WASM_EXEC_TEST(I64SarUseOnlyLowWord) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64( WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_INT64_INPUTS(i) { @@ -158,7 +158,7 @@ WASM_EXEC_TEST(I64SarUseOnlyLowWord) { } WASM_EXEC_TEST(I64DivS) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { @@ -174,7 +174,7 @@ WASM_EXEC_TEST(I64DivS) { } WASM_EXEC_TEST(I64DivS_Trap) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(0, r.Call(int64_t{0}, int64_t{100})); CHECK_TRAP64(r.Call(int64_t{100}, int64_t{0})); @@ -185,7 +185,7 @@ WASM_EXEC_TEST(I64DivS_Trap) { WASM_EXEC_TEST(I64DivS_Byzero_Const) { for (int8_t denom = -2; denom < 8; denom++) { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); for (int64_t val = -7; val < 8; val++) { if (denom == 0) { @@ -198,7 +198,7 @@ WASM_EXEC_TEST(I64DivS_Byzero_Const) { } WASM_EXEC_TEST(I64DivU) { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { @@ -212,7 +212,7 @@ WASM_EXEC_TEST(I64DivU) { } WASM_EXEC_TEST(I64DivU_Trap) { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(0, r.Call(uint64_t{0}, uint64_t{100})); CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0})); @@ -222,7 +222,7 @@ WASM_EXEC_TEST(I64DivU_Trap) { WASM_EXEC_TEST(I64DivU_Byzero_Const) { for (uint64_t denom = 0xFFFFFFFFFFFFFFFE; denom < 8; denom++) { - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_DIVU(WASM_GET_LOCAL(0), WASM_I64V_1(denom))); for (uint64_t val = 0xFFFFFFFFFFFFFFF0; val < 8; val++) { @@ -236,7 +236,7 @@ WASM_EXEC_TEST(I64DivU_Byzero_Const) { } WASM_EXEC_TEST(I64RemS) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { @@ -250,7 +250,7 @@ WASM_EXEC_TEST(I64RemS) { } WASM_EXEC_TEST(I64RemS_Trap) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(33, r.Call(int64_t{133}, int64_t{100})); CHECK_EQ(0, r.Call(std::numeric_limits<int64_t>::min(), int64_t{-1})); @@ -260,7 +260,7 @@ WASM_EXEC_TEST(I64RemS_Trap) { } WASM_EXEC_TEST(I64RemU) { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { @@ -274,7 +274,7 @@ WASM_EXEC_TEST(I64RemU) { } WASM_EXEC_TEST(I64RemU_Trap) { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(17, r.Call(uint64_t{217}, uint64_t{100})); CHECK_TRAP64(r.Call(uint64_t{100}, uint64_t{0})); @@ -283,7 +283,7 @@ WASM_EXEC_TEST(I64RemU_Trap) { } WASM_EXEC_TEST(I64And) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_AND(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ((*i) & (*j), r.Call(*i, *j)); } @@ -291,7 +291,7 @@ WASM_EXEC_TEST(I64And) { } WASM_EXEC_TEST(I64Ior) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_IOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ((*i) | (*j), r.Call(*i, *j)); } @@ -299,7 +299,7 @@ WASM_EXEC_TEST(I64Ior) { } WASM_EXEC_TEST(I64Xor) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } @@ -308,7 +308,7 @@ WASM_EXEC_TEST(I64Xor) { WASM_EXEC_TEST(I64Shl) { { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { @@ -319,22 +319,22 @@ WASM_EXEC_TEST(I64Shl) { } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(0))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 0, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(32))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 32, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); } } @@ -342,7 +342,7 @@ WASM_EXEC_TEST(I64Shl) { WASM_EXEC_TEST(I64ShrU) { { - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { @@ -353,22 +353,22 @@ WASM_EXEC_TEST(I64ShrU) { } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(32))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 32, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } } { - WasmRunner<uint64_t, int64_t> r(execution_mode); + WasmRunner<uint64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } } @@ -376,7 +376,7 @@ WASM_EXEC_TEST(I64ShrU) { WASM_EXEC_TEST(I64ShrS) { { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { @@ -387,29 +387,29 @@ WASM_EXEC_TEST(I64ShrS) { } } { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } } { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(32))); FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 32, r.Call(*i)); } } { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(20))); FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 20, r.Call(*i)); } } { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } } } WASM_EXEC_TEST(I64Eq) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i == *j ? 1 : 0, r.Call(*i, *j)); } @@ -417,7 +417,7 @@ WASM_EXEC_TEST(I64Eq) { } WASM_EXEC_TEST(I64Ne) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_NE(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i != *j ? 1 : 0, r.Call(*i, *j)); } @@ -425,7 +425,7 @@ WASM_EXEC_TEST(I64Ne) { } WASM_EXEC_TEST(I64LtS) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_LTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } @@ -433,7 +433,7 @@ WASM_EXEC_TEST(I64LtS) { } WASM_EXEC_TEST(I64LeS) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_LES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } @@ -441,7 +441,7 @@ WASM_EXEC_TEST(I64LeS) { } WASM_EXEC_TEST(I64LtU) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_LTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { CHECK_EQ(*i < *j ? 1 : 0, r.Call(*i, *j)); } @@ -449,7 +449,7 @@ WASM_EXEC_TEST(I64LtU) { } WASM_EXEC_TEST(I64LeU) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_LEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { CHECK_EQ(*i <= *j ? 1 : 0, r.Call(*i, *j)); } @@ -457,7 +457,7 @@ WASM_EXEC_TEST(I64LeU) { } WASM_EXEC_TEST(I64GtS) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_GTS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } @@ -465,7 +465,7 @@ WASM_EXEC_TEST(I64GtS) { } WASM_EXEC_TEST(I64GeS) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_GES(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } @@ -473,7 +473,7 @@ WASM_EXEC_TEST(I64GeS) { } WASM_EXEC_TEST(I64GtU) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_GTU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { CHECK_EQ(*i > *j ? 1 : 0, r.Call(*i, *j)); } @@ -481,7 +481,7 @@ WASM_EXEC_TEST(I64GtU) { } WASM_EXEC_TEST(I64GeU) { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_GEU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { FOR_UINT64_INPUTS(j) { CHECK_EQ(*i >= *j ? 1 : 0, r.Call(*i, *j)); } @@ -490,20 +490,20 @@ WASM_EXEC_TEST(I64GeU) { WASM_EXEC_TEST(I32ConvertI64) { FOR_INT64_INPUTS(i) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_I32_CONVERT_I64(WASM_I64V(*i))); CHECK_EQ(static_cast<int32_t>(*i), r.Call()); } } WASM_EXEC_TEST(I64SConvertI32) { - WasmRunner<int64_t, int32_t> r(execution_mode); + WasmRunner<int64_t, int32_t> r(execution_tier); BUILD(r, WASM_I64_SCONVERT_I32(WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } } WASM_EXEC_TEST(I64UConvertI32) { - WasmRunner<int64_t, uint32_t> r(execution_mode); + WasmRunner<int64_t, uint32_t> r(execution_tier); BUILD(r, WASM_I64_UCONVERT_I32(WASM_GET_LOCAL(0))); FOR_UINT32_INPUTS(i) { CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); } } @@ -518,7 +518,7 @@ WASM_EXEC_TEST(I64Popcnt) { {26, 0x1123456782345678}, {38, 0xFFEDCBA09EDCBA09}}; - WasmRunner<int64_t, uint64_t> r(execution_mode); + WasmRunner<int64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_POPCNT(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(values[i].expected, r.Call(values[i].input)); @@ -526,7 +526,7 @@ WASM_EXEC_TEST(I64Popcnt) { } WASM_EXEC_TEST(F32SConvertI64) { - WasmRunner<float, int64_t> r(execution_mode); + WasmRunner<float, int64_t> r(execution_tier); BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); FOR_INT64_INPUTS(i) { CHECK_FLOAT_EQ(static_cast<float>(*i), r.Call(*i)); } } @@ -611,7 +611,7 @@ WASM_EXEC_TEST(F32UConvertI64) { {0x8000008000000001, 0x5F000001}, {0x8000000000000400, 0x5F000000}, {0x8000000000000401, 0x5F000000}}; - WasmRunner<float, uint64_t> r(execution_mode); + WasmRunner<float, uint64_t> r(execution_tier); BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(bit_cast<float>(values[i].expected), r.Call(values[i].input)); @@ -619,7 +619,7 @@ WASM_EXEC_TEST(F32UConvertI64) { } WASM_EXEC_TEST(F64SConvertI64) { - WasmRunner<double, int64_t> r(execution_mode); + WasmRunner<double, int64_t> r(execution_tier); BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); FOR_INT64_INPUTS(i) { CHECK_DOUBLE_EQ(static_cast<double>(*i), r.Call(*i)); } } @@ -703,7 +703,7 @@ WASM_EXEC_TEST(F64UConvertI64) { {0x8000008000000001, 0x43E0000010000000}, {0x8000000000000400, 0x43E0000000000000}, {0x8000000000000401, 0x43E0000000000001}}; - WasmRunner<double, uint64_t> r(execution_mode); + WasmRunner<double, uint64_t> r(execution_tier); BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(bit_cast<double>(values[i].expected), r.Call(values[i].input)); @@ -711,7 +711,7 @@ WASM_EXEC_TEST(F64UConvertI64) { } WASM_EXEC_TEST(I64SConvertF32) { - WasmRunner<int64_t, float> r(execution_mode); + WasmRunner<int64_t, float> r(execution_tier); BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { @@ -726,7 +726,7 @@ WASM_EXEC_TEST(I64SConvertF32) { WASM_EXEC_TEST(I64SConvertSatF32) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int64_t, float> r(execution_mode); + WasmRunner<int64_t, float> r(execution_tier); BUILD(r, WASM_I64_SCONVERT_SAT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { int64_t expected; @@ -746,7 +746,7 @@ WASM_EXEC_TEST(I64SConvertSatF32) { } WASM_EXEC_TEST(I64SConvertF64) { - WasmRunner<int64_t, double> r(execution_mode); + WasmRunner<int64_t, double> r(execution_tier); BUILD(r, WASM_I64_SCONVERT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { @@ -761,7 +761,7 @@ WASM_EXEC_TEST(I64SConvertF64) { WASM_EXEC_TEST(I64SConvertSatF64) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int64_t, double> r(execution_mode); + WasmRunner<int64_t, double> r(execution_tier); BUILD(r, WASM_I64_SCONVERT_SAT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { int64_t expected; @@ -781,7 +781,7 @@ WASM_EXEC_TEST(I64SConvertSatF64) { } WASM_EXEC_TEST(I64UConvertF32) { - WasmRunner<uint64_t, float> r(execution_mode); + WasmRunner<uint64_t, float> r(execution_tier); BUILD(r, WASM_I64_UCONVERT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { @@ -796,7 +796,7 @@ WASM_EXEC_TEST(I64UConvertF32) { WASM_EXEC_TEST(I64UConvertSatF32) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int64_t, float> r(execution_mode); + WasmRunner<int64_t, float> r(execution_tier); BUILD(r, WASM_I64_UCONVERT_SAT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { uint64_t expected; @@ -816,7 +816,7 @@ WASM_EXEC_TEST(I64UConvertSatF32) { } WASM_EXEC_TEST(I64UConvertF64) { - WasmRunner<uint64_t, double> r(execution_mode); + WasmRunner<uint64_t, double> r(execution_tier); BUILD(r, WASM_I64_UCONVERT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { @@ -831,7 +831,7 @@ WASM_EXEC_TEST(I64UConvertF64) { WASM_EXEC_TEST(I64UConvertSatF64) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int64_t, double> r(execution_mode); + WasmRunner<int64_t, double> r(execution_tier); BUILD(r, WASM_I64_UCONVERT_SAT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { int64_t expected; @@ -858,7 +858,7 @@ WASM_EXEC_TEST(CallI64Parameter) { FunctionSig sig(1, 19, param_types); for (int i = 0; i < 19; i++) { if (i == 2 || i == 3) continue; - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // Build the target function. WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(i)); @@ -889,7 +889,7 @@ WASM_EXEC_TEST(CallI64Return) { return_types[1] = kWasmI32; FunctionSig sig(2, 1, return_types); - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); // Build the target function. WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(0), WASM_I32V(7)); @@ -901,32 +901,32 @@ WASM_EXEC_TEST(CallI64Return) { CHECK_EQ(0xBCD12340000000B, r.Call()); } -void TestI64Binop(WasmExecutionMode execution_mode, WasmOpcode opcode, +void TestI64Binop(ExecutionTier execution_tier, WasmOpcode opcode, int64_t expected, int64_t a, int64_t b) { { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); // return K op K BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); // return a op b BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(expected, r.Call(a, b)); } } -void TestI64Cmp(WasmExecutionMode execution_mode, WasmOpcode opcode, +void TestI64Cmp(ExecutionTier execution_tier, WasmOpcode opcode, int64_t expected, int64_t a, int64_t b) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return K op K BUILD(r, WASM_BINOP(opcode, WASM_I64V(a), WASM_I64V(b))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t, int64_t> r(execution_tier); // return a op b BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(expected, r.Call(a, b)); @@ -934,66 +934,66 @@ void TestI64Cmp(WasmExecutionMode execution_mode, WasmOpcode opcode, } WASM_EXEC_TEST(I64Binops) { - TestI64Binop(execution_mode, kExprI64Add, -5586332274295447011, + TestI64Binop(execution_tier, kExprI64Add, -5586332274295447011, 0x501B72EBABC26847, 0x625DE9793D8F79D6); - TestI64Binop(execution_mode, kExprI64Sub, 9001903251710731490, + TestI64Binop(execution_tier, kExprI64Sub, 9001903251710731490, 0xF24FE6474640002E, 0x7562B6F711991B4C); - TestI64Binop(execution_mode, kExprI64Mul, -4569547818546064176, + TestI64Binop(execution_tier, kExprI64Mul, -4569547818546064176, 0x231A263C2CBC6451, 0xEAD44DE6BD3E23D0); - TestI64Binop(execution_mode, kExprI64Mul, -25963122347507043, + TestI64Binop(execution_tier, kExprI64Mul, -25963122347507043, 0x4DA1FA47C9352B73, 0x91FE82317AA035AF); - TestI64Binop(execution_mode, kExprI64Mul, 7640290486138131960, + TestI64Binop(execution_tier, kExprI64Mul, 7640290486138131960, 0x185731ABE8EEA47C, 0x714EC59F1380D4C2); - TestI64Binop(execution_mode, kExprI64DivS, -91517, 0x93B1190A34DE56A0, + TestI64Binop(execution_tier, kExprI64DivS, -91517, 0x93B1190A34DE56A0, 0x00004D8F68863948); - TestI64Binop(execution_mode, kExprI64DivU, 149016, 0xE15B3727E8A2080A, + TestI64Binop(execution_tier, kExprI64DivU, 149016, 0xE15B3727E8A2080A, 0x0000631BFA72DB8B); - TestI64Binop(execution_mode, kExprI64RemS, -664128064149968, + TestI64Binop(execution_tier, kExprI64RemS, -664128064149968, 0x9A78B4E4FE708692, 0x0003E0B6B3BE7609); - TestI64Binop(execution_mode, kExprI64RemU, 1742040017332765, + TestI64Binop(execution_tier, kExprI64RemU, 1742040017332765, 0x0CE84708C6258C81, 0x000A6FDE82016697); - TestI64Binop(execution_mode, kExprI64And, 2531040582801836054, + TestI64Binop(execution_tier, kExprI64And, 2531040582801836054, 0xAF257D1602644A16, 0x33B290A91A10D997); - TestI64Binop(execution_mode, kExprI64Ior, 8556201506536114940, + TestI64Binop(execution_tier, kExprI64Ior, 8556201506536114940, 0x169D9BE7BD3F0A5C, 0x66BCA28D77AF40E8); - TestI64Binop(execution_mode, kExprI64Xor, -4605655183785456377, + TestI64Binop(execution_tier, kExprI64Xor, -4605655183785456377, 0xB6EA20A5D48E85B8, 0x76FF4DA6C80688BF); - TestI64Binop(execution_mode, kExprI64Shl, -7240704056088331264, + TestI64Binop(execution_tier, kExprI64Shl, -7240704056088331264, 0xEF4DC1ED030E8FFE, 9); - TestI64Binop(execution_mode, kExprI64ShrU, 12500673744059159, + TestI64Binop(execution_tier, kExprI64ShrU, 12500673744059159, 0xB1A52FA7DEEC5D14, 10); - TestI64Binop(execution_mode, kExprI64ShrS, 1725103446999874, + TestI64Binop(execution_tier, kExprI64ShrS, 1725103446999874, 0x3107C791461A112B, 11); - TestI64Binop(execution_mode, kExprI64Ror, -8960135652432576946, + TestI64Binop(execution_tier, kExprI64Ror, -8960135652432576946, 0x73418D1717E4E83A, 12); - TestI64Binop(execution_mode, kExprI64Ror, 7617662827409989779, + TestI64Binop(execution_tier, kExprI64Ror, 7617662827409989779, 0xEBFF67CF0C126D36, 13); - TestI64Binop(execution_mode, kExprI64Rol, -2097714064174346012, + TestI64Binop(execution_tier, kExprI64Rol, -2097714064174346012, 0x43938B8DB0B0F230, 14); - TestI64Binop(execution_mode, kExprI64Rol, 8728493013947314237, + TestI64Binop(execution_tier, kExprI64Rol, 8728493013947314237, 0xE07AF243AC4D219D, 15); } WASM_EXEC_TEST(I64Compare) { - TestI64Cmp(execution_mode, kExprI64Eq, 0, 0xB915D8FA494064F0, + TestI64Cmp(execution_tier, kExprI64Eq, 0, 0xB915D8FA494064F0, 0x04D700B2536019A3); - TestI64Cmp(execution_mode, kExprI64Ne, 1, 0xC2FAFAAAB0446CDC, + TestI64Cmp(execution_tier, kExprI64Ne, 1, 0xC2FAFAAAB0446CDC, 0x52A3328F780C97A3); - TestI64Cmp(execution_mode, kExprI64LtS, 0, 0x673636E6306B0578, + TestI64Cmp(execution_tier, kExprI64LtS, 0, 0x673636E6306B0578, 0x028EC9ECA78F7227); - TestI64Cmp(execution_mode, kExprI64LeS, 1, 0xAE5214114B86A0FA, + TestI64Cmp(execution_tier, kExprI64LeS, 1, 0xAE5214114B86A0FA, 0x7C1D21DA3DFD0CCF); - TestI64Cmp(execution_mode, kExprI64LtU, 0, 0x7D52166381EC1CE0, + TestI64Cmp(execution_tier, kExprI64LtU, 0, 0x7D52166381EC1CE0, 0x59F4A6A9E78CD3D8); - TestI64Cmp(execution_mode, kExprI64LeU, 1, 0xE4169A385C7EA0E0, + TestI64Cmp(execution_tier, kExprI64LeU, 1, 0xE4169A385C7EA0E0, 0xFBDBED2C8781E5BC); - TestI64Cmp(execution_mode, kExprI64GtS, 0, 0x9D08FF8FB5F42E81, + TestI64Cmp(execution_tier, kExprI64GtS, 0, 0x9D08FF8FB5F42E81, 0xD4E5C9D7FE09F621); - TestI64Cmp(execution_mode, kExprI64GeS, 1, 0x78DA3B2F73264E0F, + TestI64Cmp(execution_tier, kExprI64GeS, 1, 0x78DA3B2F73264E0F, 0x6FE5E2A67C501CBE); - TestI64Cmp(execution_mode, kExprI64GtU, 0, 0x8F691284E44F7DA9, + TestI64Cmp(execution_tier, kExprI64GtU, 0, 0x8F691284E44F7DA9, 0xD5EA9BC1EE149192); - TestI64Cmp(execution_mode, kExprI64GeU, 0, 0x0886A0C58C7AA224, + TestI64Cmp(execution_tier, kExprI64GeU, 0, 0x0886A0C58C7AA224, 0x5DDBE5A81FD7EE47); } @@ -1035,7 +1035,7 @@ WASM_EXEC_TEST(I64Clz) { {62, 0x0000000000000002}, {63, 0x0000000000000001}, {64, 0x0000000000000000}}; - WasmRunner<int64_t, uint64_t> r(execution_mode); + WasmRunner<int64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_CLZ(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(values[i].expected, r.Call(values[i].input)); @@ -1080,7 +1080,7 @@ WASM_EXEC_TEST(I64Ctz) { {2, 0x000000009AFDBC84}, {1, 0x000000009AFDBC82}, {0, 0x000000009AFDBC81}}; - WasmRunner<int64_t, uint64_t> r(execution_mode); + WasmRunner<int64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_CTZ(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(values[i].expected, r.Call(values[i].input)); @@ -1097,7 +1097,7 @@ WASM_EXEC_TEST(I64Popcnt2) { {26, 0x1123456782345678}, {38, 0xFFEDCBA09EDCBA09}}; - WasmRunner<int64_t, uint64_t> r(execution_mode); + WasmRunner<int64_t, uint64_t> r(execution_tier); BUILD(r, WASM_I64_POPCNT(WASM_GET_LOCAL(0))); for (size_t i = 0; i < arraysize(values); i++) { CHECK_EQ(values[i].expected, r.Call(values[i].input)); @@ -1107,25 +1107,25 @@ WASM_EXEC_TEST(I64Popcnt2) { // Test the WasmRunner with an Int64 return value and different numbers of // Int64 parameters. WASM_EXEC_TEST(I64WasmRunner) { - {FOR_INT64_INPUTS(i){WasmRunner<int64_t> r(execution_mode); + {FOR_INT64_INPUTS(i){WasmRunner<int64_t> r(execution_tier); BUILD(r, WASM_I64V(*i)); CHECK_EQ(*i, r.Call()); } } { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0)); FOR_INT64_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT64_INPUTS(i) { FOR_INT64_INPUTS(j) { CHECK_EQ(*i ^ *j, r.Call(*i, *j)); } } } { - WasmRunner<int64_t, int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64_XOR(WASM_GET_LOCAL(1), WASM_GET_LOCAL(2)))); FOR_INT64_INPUTS(i) { @@ -1137,7 +1137,7 @@ WASM_EXEC_TEST(I64WasmRunner) { } } { - WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_I64_XOR(WASM_GET_LOCAL(1), WASM_I64_XOR(WASM_GET_LOCAL(2), @@ -1154,7 +1154,7 @@ WASM_EXEC_TEST(I64WasmRunner) { } WASM_EXEC_TEST(Call_Int64Sub) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); // Build the target function. TestSignatures sigs; WasmFunctionCompiler& t = r.NewFunction(sigs.l_ll()); @@ -1183,7 +1183,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) { kExprI64LoadMem}; for (size_t m = 0; m < arraysize(loads); m++) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); byte* memory = r.builder().AddMemoryElems<byte>(kWasmPageSize); byte code[] = { @@ -1222,7 +1222,7 @@ WASM_EXEC_TEST(LoadStoreI64_sx) { WASM_EXEC_TEST(I64ReinterpretF64) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); int64_t* memory = r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); @@ -1237,7 +1237,7 @@ WASM_EXEC_TEST(I64ReinterpretF64) { } WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); BUILD(r, WASM_I64_REINTERPRET_F64(WASM_SEQ(kExprF64Const, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF4, 0x7F))); @@ -1246,7 +1246,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI64ReinterpretF64) { } WASM_EXEC_TEST(F64ReinterpretI64) { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); int64_t* memory = r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); @@ -1262,7 +1262,7 @@ WASM_EXEC_TEST(F64ReinterpretI64) { } WASM_EXEC_TEST(LoadMemI64) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); int64_t* memory = r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); r.builder().RandomizeMemory(1111); @@ -1281,7 +1281,7 @@ WASM_EXEC_TEST(LoadMemI64) { WASM_EXEC_TEST(LoadMemI64_alignment) { for (byte alignment = 0; alignment <= 3; alignment++) { - WasmRunner<int64_t> r(execution_mode); + WasmRunner<int64_t> r(execution_tier); int64_t* memory = r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); r.builder().RandomizeMemory(1111); @@ -1302,7 +1302,7 @@ WASM_EXEC_TEST(LoadMemI64_alignment) { WASM_EXEC_TEST(MemI64_Sum) { const int kNumElems = 20; - WasmRunner<uint64_t, int32_t> r(execution_mode); + WasmRunner<uint64_t, int32_t> r(execution_tier); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); const byte kSum = r.AllocateLocal(kWasmI64); @@ -1334,7 +1334,7 @@ WASM_EXEC_TEST(StoreMemI64_alignment) { const int64_t kWritten = 0x12345678ABCD0011ll; for (byte i = 0; i <= 3; i++) { - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); int64_t* memory = r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ZERO, i, @@ -1349,7 +1349,7 @@ WASM_EXEC_TEST(StoreMemI64_alignment) { } WASM_EXEC_TEST(I64Global) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int64_t* global = r.builder().AddGlobal<int64_t>(); // global = global + p0 BUILD(r, WASM_SET_GLOBAL( @@ -1359,14 +1359,14 @@ WASM_EXEC_TEST(I64Global) { r.builder().WriteMemory<int64_t>(global, 0xFFFFFFFFFFFFFFFFLL); for (int i = 9; i < 444444; i += 111111) { - int64_t expected = *global & i; + int64_t expected = ReadLittleEndianValue<int64_t>(global) & i; r.Call(i); - CHECK_EQ(expected, *global); + CHECK_EQ(expected, ReadLittleEndianValue<int64_t>(global)); } } WASM_EXEC_TEST(I64Eqz) { - WasmRunner<int32_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); FOR_INT64_INPUTS(i) { @@ -1376,7 +1376,7 @@ WASM_EXEC_TEST(I64Eqz) { } WASM_EXEC_TEST(I64Ror) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { @@ -1388,7 +1388,7 @@ WASM_EXEC_TEST(I64Ror) { } WASM_EXEC_TEST(I64Rol) { - WasmRunner<int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_UINT64_INPUTS(i) { @@ -1409,7 +1409,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob_i64) { constexpr size_t num_bytes = kWasmPageSize; for (size_t m = 0; m < arraysize(machineTypes); m++) { - WasmRunner<int32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t> r(execution_tier); byte* memory = r.builder().AddMemoryElems<byte>(num_bytes); r.builder().RandomizeMemory(1119 + static_cast<int>(m)); @@ -1436,7 +1436,7 @@ WASM_EXEC_TEST(Store_i64_narrowed) { stored_size_in_bytes = std::max(1, stored_size_in_bytes * 2); constexpr int kBytes = 24; uint8_t expected_memory[kBytes] = {0}; - WasmRunner<int32_t, int32_t, int64_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int64_t> r(execution_tier); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); constexpr uint64_t kPattern = 0x0123456789abcdef; @@ -1459,14 +1459,14 @@ WASM_EXEC_TEST(Store_i64_narrowed) { } WASM_EXEC_TEST(UnalignedInt64Load) { - WasmRunner<uint64_t> r(execution_mode); + WasmRunner<uint64_t> r(execution_tier); r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3)); r.Call(); } WASM_EXEC_TEST(UnalignedInt64Store) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(int64_t)); BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int64(), WASM_ONE, 3, WASM_I64V_1(1)), @@ -1480,12 +1480,12 @@ WASM_EXEC_TEST(UnalignedInt64Store) { for (size_t i = 0; i < sizeof(__buf); i++) vec.push_back(__buf[i]); \ } while (false) -static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) { +static void CompileCallIndirectMany(ExecutionTier tier, ValueType param) { // Make sure we don't run out of registers when compiling indirect calls // with many many parameters. TestSignatures sigs; for (byte num_params = 0; num_params < 40; num_params++) { - WasmRunner<void> r(mode); + WasmRunner<void> r(tier); FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params); r.builder().AddSignature(sig); @@ -1506,10 +1506,10 @@ static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) { } WASM_EXEC_TEST(Compile_Wasm_CallIndirect_Many_i64) { - CompileCallIndirectMany(execution_mode, kWasmI64); + CompileCallIndirectMany(execution_tier, kWasmI64); } -static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { +static void Run_WasmMixedCall_N(ExecutionTier execution_tier, int start) { const int kExpected = 6333; const int kElemSize = 8; TestSignatures sigs; @@ -1525,7 +1525,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { for (int which = 0; which < num_params; which++) { v8::internal::AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); MachineType* memtypes = &mixed[start]; MachineType result = memtypes[which]; @@ -1584,13 +1584,13 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { } } -WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_mode, 0); } -WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_mode, 1); } -WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_mode, 2); } -WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_mode, 3); } +WASM_EXEC_TEST(MixedCall_i64_0) { Run_WasmMixedCall_N(execution_tier, 0); } +WASM_EXEC_TEST(MixedCall_i64_1) { Run_WasmMixedCall_N(execution_tier, 1); } +WASM_EXEC_TEST(MixedCall_i64_2) { Run_WasmMixedCall_N(execution_tier, 2); } +WASM_EXEC_TEST(MixedCall_i64_3) { Run_WasmMixedCall_N(execution_tier, 3); } WASM_EXEC_TEST(Regress5874) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemoryElems<int64_t>(kWasmPageSize / sizeof(int64_t)); BUILD(r, kExprI64Const, 0x00, // -- @@ -1604,7 +1604,7 @@ WASM_EXEC_TEST(Regress5874) { WASM_EXEC_TEST(Regression_6858) { // WasmRunner with 5 params and returns, which is the maximum. - WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t, int64_t, int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); int64_t dividend = 15; int64_t divisor = 0; diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc b/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc index 9e15c46f8d..fc9e395d44 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-asmjs.cc @@ -20,7 +20,7 @@ namespace internal { namespace wasm { WASM_EXEC_TEST(Int32AsmjsDivS) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -32,7 +32,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS) { } WASM_EXEC_TEST(Int32AsmjsRemS) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -44,7 +44,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS) { } WASM_EXEC_TEST(Int32AsmjsDivU) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -56,7 +56,7 @@ WASM_EXEC_TEST(Int32AsmjsDivU) { } WASM_EXEC_TEST(Int32AsmjsRemU) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -68,7 +68,7 @@ WASM_EXEC_TEST(Int32AsmjsRemU) { } WASM_EXEC_TEST(I32AsmjsSConvertF32) { - WasmRunner<int32_t, float> r(execution_mode); + WasmRunner<int32_t, float> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); @@ -79,7 +79,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF32) { } WASM_EXEC_TEST(I32AsmjsSConvertF64) { - WasmRunner<int32_t, double> r(execution_mode); + WasmRunner<int32_t, double> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); @@ -90,7 +90,7 @@ WASM_EXEC_TEST(I32AsmjsSConvertF64) { } WASM_EXEC_TEST(I32AsmjsUConvertF32) { - WasmRunner<uint32_t, float> r(execution_mode); + WasmRunner<uint32_t, float> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); @@ -101,7 +101,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF32) { } WASM_EXEC_TEST(I32AsmjsUConvertF64) { - WasmRunner<uint32_t, double> r(execution_mode); + WasmRunner<uint32_t, double> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); @@ -112,7 +112,7 @@ WASM_EXEC_TEST(I32AsmjsUConvertF64) { } WASM_EXEC_TEST(LoadMemI32_oob_asm) { - WasmRunner<int32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); int32_t* memory = r.builder().AddMemoryElems<int32_t>(8); r.builder().RandomizeMemory(1112); @@ -132,7 +132,7 @@ WASM_EXEC_TEST(LoadMemI32_oob_asm) { } WASM_EXEC_TEST(LoadMemF32_oob_asm) { - WasmRunner<float, uint32_t> r(execution_mode); + WasmRunner<float, uint32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); float* memory = r.builder().AddMemoryElems<float>(8); r.builder().RandomizeMemory(1112); @@ -152,7 +152,7 @@ WASM_EXEC_TEST(LoadMemF32_oob_asm) { } WASM_EXEC_TEST(LoadMemF64_oob_asm) { - WasmRunner<double, uint32_t> r(execution_mode); + WasmRunner<double, uint32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); double* memory = r.builder().AddMemoryElems<double>(8); r.builder().RandomizeMemory(1112); @@ -174,7 +174,7 @@ WASM_EXEC_TEST(LoadMemF64_oob_asm) { } WASM_EXEC_TEST(StoreMemI32_oob_asm) { - WasmRunner<int32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t, uint32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); int32_t* memory = r.builder().AddMemoryElems<int32_t>(8); r.builder().RandomizeMemory(1112); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc b/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc index fca190440f..96877fd571 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics.cc @@ -10,10 +10,10 @@ namespace internal { namespace wasm { namespace test_run_wasm_atomics { -void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, +void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint32BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); r.builder().SetHasSharedMemory(); @@ -33,28 +33,28 @@ void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I32AtomicAdd) { - RunU32BinOp(execution_mode, kExprI32AtomicAdd, Add); + RunU32BinOp(execution_tier, kExprI32AtomicAdd, Add); } WASM_EXEC_TEST(I32AtomicSub) { - RunU32BinOp(execution_mode, kExprI32AtomicSub, Sub); + RunU32BinOp(execution_tier, kExprI32AtomicSub, Sub); } WASM_EXEC_TEST(I32AtomicAnd) { - RunU32BinOp(execution_mode, kExprI32AtomicAnd, And); + RunU32BinOp(execution_tier, kExprI32AtomicAnd, And); } WASM_EXEC_TEST(I32AtomicOr) { - RunU32BinOp(execution_mode, kExprI32AtomicOr, Or); + RunU32BinOp(execution_tier, kExprI32AtomicOr, Or); } WASM_EXEC_TEST(I32AtomicXor) { - RunU32BinOp(execution_mode, kExprI32AtomicXor, Xor); + RunU32BinOp(execution_tier, kExprI32AtomicXor, Xor); } WASM_EXEC_TEST(I32AtomicExchange) { - RunU32BinOp(execution_mode, kExprI32AtomicExchange, Exchange); + RunU32BinOp(execution_tier, kExprI32AtomicExchange, Exchange); } -void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op, +void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, Uint16BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(mode); + WasmRunner<uint32_t, uint32_t> r(tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -74,28 +74,28 @@ void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I32AtomicAdd16U) { - RunU16BinOp(execution_mode, kExprI32AtomicAdd16U, Add); + RunU16BinOp(execution_tier, kExprI32AtomicAdd16U, Add); } WASM_EXEC_TEST(I32AtomicSub16U) { - RunU16BinOp(execution_mode, kExprI32AtomicSub16U, Sub); + RunU16BinOp(execution_tier, kExprI32AtomicSub16U, Sub); } WASM_EXEC_TEST(I32AtomicAnd16U) { - RunU16BinOp(execution_mode, kExprI32AtomicAnd16U, And); + RunU16BinOp(execution_tier, kExprI32AtomicAnd16U, And); } WASM_EXEC_TEST(I32AtomicOr16U) { - RunU16BinOp(execution_mode, kExprI32AtomicOr16U, Or); + RunU16BinOp(execution_tier, kExprI32AtomicOr16U, Or); } WASM_EXEC_TEST(I32AtomicXor16U) { - RunU16BinOp(execution_mode, kExprI32AtomicXor16U, Xor); + RunU16BinOp(execution_tier, kExprI32AtomicXor16U, Xor); } WASM_EXEC_TEST(I32AtomicExchange16U) { - RunU16BinOp(execution_mode, kExprI32AtomicExchange16U, Exchange); + RunU16BinOp(execution_tier, kExprI32AtomicExchange16U, Exchange); } -void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, +void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint8BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); @@ -114,27 +114,27 @@ void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I32AtomicAdd8U) { - RunU8BinOp(execution_mode, kExprI32AtomicAdd8U, Add); + RunU8BinOp(execution_tier, kExprI32AtomicAdd8U, Add); } WASM_EXEC_TEST(I32AtomicSub8U) { - RunU8BinOp(execution_mode, kExprI32AtomicSub8U, Sub); + RunU8BinOp(execution_tier, kExprI32AtomicSub8U, Sub); } WASM_EXEC_TEST(I32AtomicAnd8U) { - RunU8BinOp(execution_mode, kExprI32AtomicAnd8U, And); + RunU8BinOp(execution_tier, kExprI32AtomicAnd8U, And); } WASM_EXEC_TEST(I32AtomicOr8U) { - RunU8BinOp(execution_mode, kExprI32AtomicOr8U, Or); + RunU8BinOp(execution_tier, kExprI32AtomicOr8U, Or); } WASM_EXEC_TEST(I32AtomicXor8U) { - RunU8BinOp(execution_mode, kExprI32AtomicXor8U, Xor); + RunU8BinOp(execution_tier, kExprI32AtomicXor8U, Xor); } WASM_EXEC_TEST(I32AtomicExchange8U) { - RunU8BinOp(execution_mode, kExprI32AtomicExchange8U, Exchange); + RunU8BinOp(execution_tier, kExprI32AtomicExchange8U, Exchange); } WASM_EXEC_TEST(I32AtomicCompareExchange) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -155,7 +155,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange) { WASM_EXEC_TEST(I32AtomicCompareExchange16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -177,7 +177,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange16U) { WASM_EXEC_TEST(I32AtomicCompareExchange8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); BUILD(r, @@ -198,7 +198,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) { WASM_EXEC_TEST(I32AtomicLoad) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t> r(execution_mode); + WasmRunner<uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -214,7 +214,7 @@ WASM_EXEC_TEST(I32AtomicLoad) { WASM_EXEC_TEST(I32AtomicLoad16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t> r(execution_mode); + WasmRunner<uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -230,7 +230,7 @@ WASM_EXEC_TEST(I32AtomicLoad16U) { WASM_EXEC_TEST(I32AtomicLoad8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t> r(execution_mode); + WasmRunner<uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI32AtomicLoad8U, WASM_ZERO, @@ -245,7 +245,7 @@ WASM_EXEC_TEST(I32AtomicLoad8U) { WASM_EXEC_TEST(I32AtomicStoreLoad) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -265,7 +265,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad) { WASM_EXEC_TEST(I32AtomicStoreLoad16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -286,7 +286,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad16U) { WASM_EXEC_TEST(I32AtomicStoreLoad8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); @@ -305,7 +305,7 @@ WASM_EXEC_TEST(I32AtomicStoreLoad8U) { WASM_EXEC_TEST(I32AtomicStoreParameter) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); r.builder().SetHasSharedMemory(); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc b/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc index 48169db191..21b943595a 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-atomics64.cc @@ -10,10 +10,10 @@ namespace internal { namespace wasm { namespace test_run_wasm_atomics_64 { -void RunU64BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, +void RunU64BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint64BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); r.builder().SetHasSharedMemory(); @@ -33,28 +33,28 @@ void RunU64BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I64AtomicAdd) { - RunU64BinOp(execution_mode, kExprI64AtomicAdd, Add); + RunU64BinOp(execution_tier, kExprI64AtomicAdd, Add); } WASM_EXEC_TEST(I64AtomicSub) { - RunU64BinOp(execution_mode, kExprI64AtomicSub, Sub); + RunU64BinOp(execution_tier, kExprI64AtomicSub, Sub); } WASM_EXEC_TEST(I64AtomicAnd) { - RunU64BinOp(execution_mode, kExprI64AtomicAnd, And); + RunU64BinOp(execution_tier, kExprI64AtomicAnd, And); } WASM_EXEC_TEST(I64AtomicOr) { - RunU64BinOp(execution_mode, kExprI64AtomicOr, Or); + RunU64BinOp(execution_tier, kExprI64AtomicOr, Or); } WASM_EXEC_TEST(I64AtomicXor) { - RunU64BinOp(execution_mode, kExprI64AtomicXor, Xor); + RunU64BinOp(execution_tier, kExprI64AtomicXor, Xor); } WASM_EXEC_TEST(I64AtomicExchange) { - RunU64BinOp(execution_mode, kExprI64AtomicExchange, Exchange); + RunU64BinOp(execution_tier, kExprI64AtomicExchange, Exchange); } -void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, +void RunU32BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint32BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); r.builder().SetHasSharedMemory(); @@ -74,28 +74,28 @@ void RunU32BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I64AtomicAdd32U) { - RunU32BinOp(execution_mode, kExprI64AtomicAdd32U, Add); + RunU32BinOp(execution_tier, kExprI64AtomicAdd32U, Add); } WASM_EXEC_TEST(I64AtomicSub32U) { - RunU32BinOp(execution_mode, kExprI64AtomicSub32U, Sub); + RunU32BinOp(execution_tier, kExprI64AtomicSub32U, Sub); } WASM_EXEC_TEST(I64AtomicAnd32U) { - RunU32BinOp(execution_mode, kExprI64AtomicAnd32U, And); + RunU32BinOp(execution_tier, kExprI64AtomicAnd32U, And); } WASM_EXEC_TEST(I64AtomicOr32U) { - RunU32BinOp(execution_mode, kExprI64AtomicOr32U, Or); + RunU32BinOp(execution_tier, kExprI64AtomicOr32U, Or); } WASM_EXEC_TEST(I64AtomicXor32U) { - RunU32BinOp(execution_mode, kExprI64AtomicXor32U, Xor); + RunU32BinOp(execution_tier, kExprI64AtomicXor32U, Xor); } WASM_EXEC_TEST(I64AtomicExchange32U) { - RunU32BinOp(execution_mode, kExprI64AtomicExchange32U, Exchange); + RunU32BinOp(execution_tier, kExprI64AtomicExchange32U, Exchange); } -void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op, +void RunU16BinOp(ExecutionTier tier, WasmOpcode wasm_op, Uint16BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(mode); + WasmRunner<uint64_t, uint64_t> r(tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -115,28 +115,28 @@ void RunU16BinOp(WasmExecutionMode mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I64AtomicAdd16U) { - RunU16BinOp(execution_mode, kExprI64AtomicAdd16U, Add); + RunU16BinOp(execution_tier, kExprI64AtomicAdd16U, Add); } WASM_EXEC_TEST(I64AtomicSub16U) { - RunU16BinOp(execution_mode, kExprI64AtomicSub16U, Sub); + RunU16BinOp(execution_tier, kExprI64AtomicSub16U, Sub); } WASM_EXEC_TEST(I64AtomicAnd16U) { - RunU16BinOp(execution_mode, kExprI64AtomicAnd16U, And); + RunU16BinOp(execution_tier, kExprI64AtomicAnd16U, And); } WASM_EXEC_TEST(I64AtomicOr16U) { - RunU16BinOp(execution_mode, kExprI64AtomicOr16U, Or); + RunU16BinOp(execution_tier, kExprI64AtomicOr16U, Or); } WASM_EXEC_TEST(I64AtomicXor16U) { - RunU16BinOp(execution_mode, kExprI64AtomicXor16U, Xor); + RunU16BinOp(execution_tier, kExprI64AtomicXor16U, Xor); } WASM_EXEC_TEST(I64AtomicExchange16U) { - RunU16BinOp(execution_mode, kExprI64AtomicExchange16U, Exchange); + RunU16BinOp(execution_tier, kExprI64AtomicExchange16U, Exchange); } -void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, +void RunU8BinOp(ExecutionTier execution_tier, WasmOpcode wasm_op, Uint8BinOp expected_op) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); @@ -155,27 +155,27 @@ void RunU8BinOp(WasmExecutionMode execution_mode, WasmOpcode wasm_op, } WASM_EXEC_TEST(I64AtomicAdd8U) { - RunU8BinOp(execution_mode, kExprI64AtomicAdd8U, Add); + RunU8BinOp(execution_tier, kExprI64AtomicAdd8U, Add); } WASM_EXEC_TEST(I64AtomicSub8U) { - RunU8BinOp(execution_mode, kExprI64AtomicSub8U, Sub); + RunU8BinOp(execution_tier, kExprI64AtomicSub8U, Sub); } WASM_EXEC_TEST(I64AtomicAnd8U) { - RunU8BinOp(execution_mode, kExprI64AtomicAnd8U, And); + RunU8BinOp(execution_tier, kExprI64AtomicAnd8U, And); } WASM_EXEC_TEST(I64AtomicOr8U) { - RunU8BinOp(execution_mode, kExprI64AtomicOr8U, Or); + RunU8BinOp(execution_tier, kExprI64AtomicOr8U, Or); } WASM_EXEC_TEST(I64AtomicXor8U) { - RunU8BinOp(execution_mode, kExprI64AtomicXor8U, Xor); + RunU8BinOp(execution_tier, kExprI64AtomicXor8U, Xor); } WASM_EXEC_TEST(I64AtomicExchange8U) { - RunU8BinOp(execution_mode, kExprI64AtomicExchange8U, Exchange); + RunU8BinOp(execution_tier, kExprI64AtomicExchange8U, Exchange); } WASM_EXEC_TEST(I64AtomicCompareExchange) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); @@ -196,7 +196,7 @@ WASM_EXEC_TEST(I64AtomicCompareExchange) { WASM_EXEC_TEST(I64AtomicCompareExchange32U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -218,7 +218,7 @@ WASM_EXEC_TEST(I64AtomicCompareExchange32U) { WASM_EXEC_TEST(I64AtomicCompareExchange16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -240,7 +240,7 @@ WASM_EXEC_TEST(I64AtomicCompareExchange16U) { WASM_EXEC_TEST(I32AtomicCompareExchange8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); BUILD(r, @@ -260,7 +260,7 @@ WASM_EXEC_TEST(I32AtomicCompareExchange8U) { WASM_EXEC_TEST(I64AtomicLoad) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t> r(execution_mode); + WasmRunner<uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); @@ -276,7 +276,7 @@ WASM_EXEC_TEST(I64AtomicLoad) { WASM_EXEC_TEST(I64AtomicLoad32U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t> r(execution_mode); + WasmRunner<uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -292,7 +292,7 @@ WASM_EXEC_TEST(I64AtomicLoad32U) { WASM_EXEC_TEST(I64AtomicLoad16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t> r(execution_mode); + WasmRunner<uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -308,7 +308,7 @@ WASM_EXEC_TEST(I64AtomicLoad16U) { WASM_EXEC_TEST(I64AtomicLoad8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t> r(execution_mode); + WasmRunner<uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); BUILD(r, WASM_ATOMICS_LOAD_OP(kExprI64AtomicLoad8U, WASM_ZERO, @@ -323,7 +323,7 @@ WASM_EXEC_TEST(I64AtomicLoad8U) { WASM_EXEC_TEST(I64AtomicStoreLoad) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint64_t* memory = r.builder().AddMemoryElems<uint64_t>(kWasmPageSize / sizeof(uint64_t)); @@ -343,7 +343,7 @@ WASM_EXEC_TEST(I64AtomicStoreLoad) { WASM_EXEC_TEST(I64AtomicStoreLoad32U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); @@ -364,7 +364,7 @@ WASM_EXEC_TEST(I64AtomicStoreLoad32U) { WASM_EXEC_TEST(I64AtomicStoreLoad16U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint16_t* memory = r.builder().AddMemoryElems<uint16_t>(kWasmPageSize / sizeof(uint16_t)); @@ -385,7 +385,7 @@ WASM_EXEC_TEST(I64AtomicStoreLoad16U) { WASM_EXEC_TEST(I64AtomicStoreLoad8U) { EXPERIMENTAL_FLAG_SCOPE(threads); - WasmRunner<uint64_t, uint64_t> r(execution_mode); + WasmRunner<uint64_t, uint64_t> r(execution_tier); r.builder().SetHasSharedMemory(); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc index 76ca00cb3b..f788cc84b6 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-interpreter.cc @@ -22,7 +22,7 @@ namespace wasm { namespace test_run_wasm_interpreter { TEST(Run_WasmInt8Const_i) { - WasmRunner<int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t> r(ExecutionTier::kInterpreter); const byte kExpectedValue = 109; // return(kExpectedValue) BUILD(r, WASM_I32V_2(kExpectedValue)); @@ -30,14 +30,14 @@ TEST(Run_WasmInt8Const_i) { } TEST(Run_WasmIfElse) { - WasmRunner<int32_t, int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter); BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_I32V_1(9), WASM_I32V_1(10))); CHECK_EQ(10, r.Call(0)); CHECK_EQ(9, r.Call(1)); } TEST(Run_WasmIfReturn) { - WasmRunner<int32_t, int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter); BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_RETURN1(WASM_I32V_2(77))), WASM_I32V_2(65)); CHECK_EQ(65, r.Call(0)); @@ -53,7 +53,7 @@ TEST(Run_WasmNopsN) { code[nops] = kExprI32Const; code[nops + 1] = expected; - WasmRunner<int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + nops + 2); CHECK_EQ(expected, r.Call()); } @@ -76,7 +76,7 @@ TEST(Run_WasmConstsN) { } } - WasmRunner<int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + (count * 3)); CHECK_EQ(expected, r.Call()); } @@ -95,7 +95,7 @@ TEST(Run_WasmBlocksN) { code[2 + nops + 1] = expected; code[2 + nops + 2] = kExprEnd; - WasmRunner<int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + nops + kExtra); CHECK_EQ(expected, r.Call()); } @@ -120,7 +120,7 @@ TEST(Run_WasmBlockBreakN) { code[2 + index + 2] = kExprBr; code[2 + index + 3] = 0; - WasmRunner<int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + kMaxNops + kExtra); CHECK_EQ(expected, r.Call()); } @@ -128,7 +128,7 @@ TEST(Run_WasmBlockBreakN) { } TEST(Run_Wasm_nested_ifs_i) { - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, int32_t, int32_t> r(ExecutionTier::kInterpreter); BUILD( r, @@ -178,7 +178,7 @@ TEST(Breakpoint_I32Add) { Find(code, sizeof(code), kNumBreakpoints, kExprGetLocal, kExprGetLocal, kExprI32Add); - WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + arraysize(code)); @@ -217,7 +217,7 @@ TEST(Step_I32Mul) { static const int kTraceLength = 4; byte code[] = {WASM_I32_MUL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}; - WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + arraysize(code)); @@ -255,7 +255,7 @@ TEST(Breakpoint_I32And_disable) { std::unique_ptr<int[]> offsets = Find(code, sizeof(code), kNumBreakpoints, kExprI32And); - WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t, uint32_t> r(ExecutionTier::kInterpreter); r.Build(code, code + arraysize(code)); @@ -293,14 +293,14 @@ TEST(Breakpoint_I32And_disable) { TEST(GrowMemory) { { - WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); r.builder().SetMaxMemPages(10); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); CHECK_EQ(1, r.Call(1)); } { - WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); r.builder().SetMaxMemPages(10); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); @@ -311,7 +311,7 @@ TEST(GrowMemory) { TEST(GrowMemoryPreservesData) { int32_t index = 16; int32_t value = 2335; - WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_STORE_MEM(MachineType::Int32(), WASM_I32V(index), WASM_I32V(value)), @@ -322,7 +322,7 @@ TEST(GrowMemoryPreservesData) { TEST(GrowMemoryInvalidSize) { // Grow memory by an invalid amount without initial memory. - WasmRunner<int32_t, uint32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, uint32_t> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_GROW_MEMORY(WASM_GET_LOCAL(0))); CHECK_EQ(-1, r.Call(1048575)); @@ -330,7 +330,7 @@ TEST(GrowMemoryInvalidSize) { TEST(TestPossibleNondeterminism) { { - WasmRunner<int32_t, float> r(kExecuteInterpreter); + WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter); BUILD(r, WASM_I32_REINTERPRET_F32(WASM_GET_LOCAL(0))); r.Call(1048575.5f); CHECK(!r.possible_nondeterminism()); @@ -338,7 +338,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<int64_t, double> r(kExecuteInterpreter); + WasmRunner<int64_t, double> r(ExecutionTier::kInterpreter); BUILD(r, WASM_I64_REINTERPRET_F64(WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -346,7 +346,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<float, float> r(kExecuteInterpreter); + WasmRunner<float, float> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F32_COPYSIGN(WASM_F32(42.0f), WASM_GET_LOCAL(0))); r.Call(16.0f); CHECK(!r.possible_nondeterminism()); @@ -354,7 +354,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<double, double> r(kExecuteInterpreter); + WasmRunner<double, double> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F64_COPYSIGN(WASM_F64(42.0), WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -363,7 +363,7 @@ TEST(TestPossibleNondeterminism) { } { int32_t index = 16; - WasmRunner<int32_t, float> r(kExecuteInterpreter); + WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_STORE_MEM(MachineType::Float32(), WASM_I32V(index), WASM_GET_LOCAL(0)), @@ -375,7 +375,7 @@ TEST(TestPossibleNondeterminism) { } { int32_t index = 16; - WasmRunner<int32_t, double> r(kExecuteInterpreter); + WasmRunner<int32_t, double> r(ExecutionTier::kInterpreter); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_STORE_MEM(MachineType::Float64(), WASM_I32V(index), WASM_GET_LOCAL(0)), @@ -386,7 +386,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<float, float> r(kExecuteInterpreter); + WasmRunner<float, float> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(1048575.5f); CHECK(!r.possible_nondeterminism()); @@ -394,7 +394,7 @@ TEST(TestPossibleNondeterminism) { CHECK(r.possible_nondeterminism()); } { - WasmRunner<double, double> r(kExecuteInterpreter); + WasmRunner<double, double> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -402,7 +402,7 @@ TEST(TestPossibleNondeterminism) { CHECK(r.possible_nondeterminism()); } { - WasmRunner<int32_t, float> r(kExecuteInterpreter); + WasmRunner<int32_t, float> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F32_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -410,7 +410,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<int32_t, double> r(kExecuteInterpreter); + WasmRunner<int32_t, double> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F64_EQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -418,7 +418,7 @@ TEST(TestPossibleNondeterminism) { CHECK(!r.possible_nondeterminism()); } { - WasmRunner<float, float> r(kExecuteInterpreter); + WasmRunner<float, float> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(1048575.5f); CHECK(!r.possible_nondeterminism()); @@ -426,7 +426,7 @@ TEST(TestPossibleNondeterminism) { CHECK(r.possible_nondeterminism()); } { - WasmRunner<double, double> r(kExecuteInterpreter); + WasmRunner<double, double> r(ExecutionTier::kInterpreter); BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); r.Call(16.0); CHECK(!r.possible_nondeterminism()); @@ -436,7 +436,7 @@ TEST(TestPossibleNondeterminism) { } TEST(WasmInterpreterActivations) { - WasmRunner<void> r(kExecuteInterpreter); + WasmRunner<void> r(ExecutionTier::kInterpreter); Isolate* isolate = r.main_isolate(); BUILD(r, WASM_NOP); @@ -466,7 +466,7 @@ TEST(WasmInterpreterActivations) { } TEST(InterpreterLoadWithoutMemory) { - WasmRunner<int32_t, int32_t> r(kExecuteInterpreter); + WasmRunner<int32_t, int32_t> r(ExecutionTier::kInterpreter); r.builder().AddMemory(0); BUILD(r, WASM_LOAD_MEM(MachineType::Int32(), WASM_GET_LOCAL(0))); CHECK_TRAP32(r.Call(0)); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-js.cc b/deps/v8/test/cctest/wasm/test-run-wasm-js.cc index 2b62119d25..b9de081c9f 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-js.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-js.cc @@ -7,7 +7,7 @@ #include <stdlib.h> #include <string.h> -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" @@ -96,7 +96,7 @@ void EXPECT_CALL(double expected, Handle<JSFunction> jsfunc, double a, } // namespace WASM_EXEC_TEST(Run_Int32Sub_jswrapped) { - WasmRunner<int, int, int> r(execution_mode); + WasmRunner<int, int, int> r(execution_tier); BUILD(r, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -105,7 +105,7 @@ WASM_EXEC_TEST(Run_Int32Sub_jswrapped) { } WASM_EXEC_TEST(Run_Float32Div_jswrapped) { - WasmRunner<float, float, float> r(execution_mode); + WasmRunner<float, float, float> r(execution_tier); BUILD(r, WASM_F32_DIV(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -114,7 +114,7 @@ WASM_EXEC_TEST(Run_Float32Div_jswrapped) { } WASM_EXEC_TEST(Run_Float64Add_jswrapped) { - WasmRunner<double, double, double> r(execution_mode); + WasmRunner<double, double, double> r(execution_tier); BUILD(r, WASM_F64_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -123,7 +123,7 @@ WASM_EXEC_TEST(Run_Float64Add_jswrapped) { } WASM_EXEC_TEST(Run_I32Popcount_jswrapped) { - WasmRunner<int, int> r(execution_mode); + WasmRunner<int, int> r(execution_tier); BUILD(r, WASM_I32_POPCNT(WASM_GET_LOCAL(0))); Handle<JSFunction> jsfunc = r.builder().WrapCode(r.function()->func_index); @@ -140,7 +140,7 @@ WASM_EXEC_TEST(Run_CallJS_Add_jswrapped) { Handle<JSFunction>::cast(v8::Utils::OpenHandle( *v8::Local<v8::Function>::Cast(CompileRun(source)))); ManuallyImportedJSFunction import = {sigs.i_i(), js_function}; - WasmRunner<int, int> r(execution_mode, &import); + WasmRunner<int, int> r(execution_tier, &import); uint32_t js_index = 0; WasmFunctionCompiler& t = r.NewFunction(sigs.i_i()); @@ -153,7 +153,7 @@ WASM_EXEC_TEST(Run_CallJS_Add_jswrapped) { EXPECT_CALL(-666666801, jsfunc, -666666900, -1); } -void RunJSSelectTest(WasmExecutionMode mode, int which) { +void RunJSSelectTest(ExecutionTier tier, int which) { const int kMaxParams = 8; PredictableInputValues inputs(0x100); ValueType type = kWasmF64; @@ -164,7 +164,7 @@ void RunJSSelectTest(WasmExecutionMode mode, int which) { FunctionSig sig(1, num_params, types); ManuallyImportedJSFunction import = CreateJSSelector(&sig, which); - WasmRunner<void> r(mode, &import); + WasmRunner<void> r(tier, &import); uint32_t js_index = 0; WasmFunctionCompiler& t = r.NewFunction(&sig); @@ -191,45 +191,45 @@ void RunJSSelectTest(WasmExecutionMode mode, int which) { WASM_EXEC_TEST(Run_JSSelect_0) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 0); + RunJSSelectTest(execution_tier, 0); } WASM_EXEC_TEST(Run_JSSelect_1) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 1); + RunJSSelectTest(execution_tier, 1); } WASM_EXEC_TEST(Run_JSSelect_2) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 2); + RunJSSelectTest(execution_tier, 2); } WASM_EXEC_TEST(Run_JSSelect_3) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 3); + RunJSSelectTest(execution_tier, 3); } WASM_EXEC_TEST(Run_JSSelect_4) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 4); + RunJSSelectTest(execution_tier, 4); } WASM_EXEC_TEST(Run_JSSelect_5) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 5); + RunJSSelectTest(execution_tier, 5); } WASM_EXEC_TEST(Run_JSSelect_6) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 6); + RunJSSelectTest(execution_tier, 6); } WASM_EXEC_TEST(Run_JSSelect_7) { CcTest::InitializeVM(); - RunJSSelectTest(execution_mode, 7); + RunJSSelectTest(execution_tier, 7); } -void RunWASMSelectTest(WasmExecutionMode mode, int which) { +void RunWASMSelectTest(ExecutionTier tier, int which) { PredictableInputValues inputs(0x200); Isolate* isolate = CcTest::InitIsolateOnce(); const int kMaxParams = 8; @@ -239,7 +239,7 @@ void RunWASMSelectTest(WasmExecutionMode mode, int which) { type, type, type, type}; FunctionSig sig(1, num_params, types); - WasmRunner<void> r(mode); + WasmRunner<void> r(tier); WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(which)); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index()); @@ -262,46 +262,45 @@ void RunWASMSelectTest(WasmExecutionMode mode, int which) { WASM_EXEC_TEST(Run_WASMSelect_0) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 0); + RunWASMSelectTest(execution_tier, 0); } WASM_EXEC_TEST(Run_WASMSelect_1) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 1); + RunWASMSelectTest(execution_tier, 1); } WASM_EXEC_TEST(Run_WASMSelect_2) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 2); + RunWASMSelectTest(execution_tier, 2); } WASM_EXEC_TEST(Run_WASMSelect_3) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 3); + RunWASMSelectTest(execution_tier, 3); } WASM_EXEC_TEST(Run_WASMSelect_4) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 4); + RunWASMSelectTest(execution_tier, 4); } WASM_EXEC_TEST(Run_WASMSelect_5) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 5); + RunWASMSelectTest(execution_tier, 5); } WASM_EXEC_TEST(Run_WASMSelect_6) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 6); + RunWASMSelectTest(execution_tier, 6); } WASM_EXEC_TEST(Run_WASMSelect_7) { CcTest::InitializeVM(); - RunWASMSelectTest(execution_mode, 7); + RunWASMSelectTest(execution_tier, 7); } -void RunWASMSelectAlignTest(WasmExecutionMode mode, int num_args, - int num_params) { +void RunWASMSelectAlignTest(ExecutionTier tier, int num_args, int num_params) { PredictableInputValues inputs(0x300); Isolate* isolate = CcTest::InitIsolateOnce(); const int kMaxParams = 10; @@ -312,7 +311,7 @@ void RunWASMSelectAlignTest(WasmExecutionMode mode, int num_args, FunctionSig sig(1, num_params, types); for (int which = 0; which < num_params; which++) { - WasmRunner<void> r(mode); + WasmRunner<void> r(tier); WasmFunctionCompiler& t = r.NewFunction(&sig); BUILD(t, WASM_GET_LOCAL(which)); Handle<JSFunction> jsfunc = r.builder().WrapCode(t.function_index()); @@ -336,67 +335,66 @@ void RunWASMSelectAlignTest(WasmExecutionMode mode, int num_args, WASM_EXEC_TEST(Run_WASMSelectAlign_0) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 0, 1); - RunWASMSelectAlignTest(execution_mode, 0, 2); + RunWASMSelectAlignTest(execution_tier, 0, 1); + RunWASMSelectAlignTest(execution_tier, 0, 2); } WASM_EXEC_TEST(Run_WASMSelectAlign_1) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 1, 2); - RunWASMSelectAlignTest(execution_mode, 1, 3); + RunWASMSelectAlignTest(execution_tier, 1, 2); + RunWASMSelectAlignTest(execution_tier, 1, 3); } WASM_EXEC_TEST(Run_WASMSelectAlign_2) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 2, 3); - RunWASMSelectAlignTest(execution_mode, 2, 4); + RunWASMSelectAlignTest(execution_tier, 2, 3); + RunWASMSelectAlignTest(execution_tier, 2, 4); } WASM_EXEC_TEST(Run_WASMSelectAlign_3) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 3, 3); - RunWASMSelectAlignTest(execution_mode, 3, 4); + RunWASMSelectAlignTest(execution_tier, 3, 3); + RunWASMSelectAlignTest(execution_tier, 3, 4); } WASM_EXEC_TEST(Run_WASMSelectAlign_4) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 4, 3); - RunWASMSelectAlignTest(execution_mode, 4, 4); + RunWASMSelectAlignTest(execution_tier, 4, 3); + RunWASMSelectAlignTest(execution_tier, 4, 4); } WASM_EXEC_TEST(Run_WASMSelectAlign_7) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 7, 5); - RunWASMSelectAlignTest(execution_mode, 7, 6); - RunWASMSelectAlignTest(execution_mode, 7, 7); + RunWASMSelectAlignTest(execution_tier, 7, 5); + RunWASMSelectAlignTest(execution_tier, 7, 6); + RunWASMSelectAlignTest(execution_tier, 7, 7); } WASM_EXEC_TEST(Run_WASMSelectAlign_8) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 8, 5); - RunWASMSelectAlignTest(execution_mode, 8, 6); - RunWASMSelectAlignTest(execution_mode, 8, 7); - RunWASMSelectAlignTest(execution_mode, 8, 8); + RunWASMSelectAlignTest(execution_tier, 8, 5); + RunWASMSelectAlignTest(execution_tier, 8, 6); + RunWASMSelectAlignTest(execution_tier, 8, 7); + RunWASMSelectAlignTest(execution_tier, 8, 8); } WASM_EXEC_TEST(Run_WASMSelectAlign_9) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 9, 6); - RunWASMSelectAlignTest(execution_mode, 9, 7); - RunWASMSelectAlignTest(execution_mode, 9, 8); - RunWASMSelectAlignTest(execution_mode, 9, 9); + RunWASMSelectAlignTest(execution_tier, 9, 6); + RunWASMSelectAlignTest(execution_tier, 9, 7); + RunWASMSelectAlignTest(execution_tier, 9, 8); + RunWASMSelectAlignTest(execution_tier, 9, 9); } WASM_EXEC_TEST(Run_WASMSelectAlign_10) { CcTest::InitializeVM(); - RunWASMSelectAlignTest(execution_mode, 10, 7); - RunWASMSelectAlignTest(execution_mode, 10, 8); - RunWASMSelectAlignTest(execution_mode, 10, 9); - RunWASMSelectAlignTest(execution_mode, 10, 10); + RunWASMSelectAlignTest(execution_tier, 10, 7); + RunWASMSelectAlignTest(execution_tier, 10, 8); + RunWASMSelectAlignTest(execution_tier, 10, 9); + RunWASMSelectAlignTest(execution_tier, 10, 10); } -void RunJSSelectAlignTest(WasmExecutionMode mode, int num_args, - int num_params) { +void RunJSSelectAlignTest(ExecutionTier tier, int num_args, int num_params) { PredictableInputValues inputs(0x400); Isolate* isolate = CcTest::InitIsolateOnce(); Factory* factory = isolate->factory(); @@ -427,7 +425,7 @@ void RunJSSelectAlignTest(WasmExecutionMode mode, int num_args, for (int which = 0; which < num_params; which++) { HandleScope scope(isolate); ManuallyImportedJSFunction import = CreateJSSelector(&sig, which); - WasmRunner<void> r(mode, &import); + WasmRunner<void> r(tier, &import); WasmFunctionCompiler& t = r.NewFunction(&sig); t.Build(&code[0], &code[end]); @@ -454,64 +452,64 @@ void RunJSSelectAlignTest(WasmExecutionMode mode, int num_args, WASM_EXEC_TEST(Run_JSSelectAlign_0) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 0, 1); - RunJSSelectAlignTest(execution_mode, 0, 2); + RunJSSelectAlignTest(execution_tier, 0, 1); + RunJSSelectAlignTest(execution_tier, 0, 2); } WASM_EXEC_TEST(Run_JSSelectAlign_1) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 1, 2); - RunJSSelectAlignTest(execution_mode, 1, 3); + RunJSSelectAlignTest(execution_tier, 1, 2); + RunJSSelectAlignTest(execution_tier, 1, 3); } WASM_EXEC_TEST(Run_JSSelectAlign_2) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 2, 3); - RunJSSelectAlignTest(execution_mode, 2, 4); + RunJSSelectAlignTest(execution_tier, 2, 3); + RunJSSelectAlignTest(execution_tier, 2, 4); } WASM_EXEC_TEST(Run_JSSelectAlign_3) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 3, 3); - RunJSSelectAlignTest(execution_mode, 3, 4); + RunJSSelectAlignTest(execution_tier, 3, 3); + RunJSSelectAlignTest(execution_tier, 3, 4); } WASM_EXEC_TEST(Run_JSSelectAlign_4) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 4, 3); - RunJSSelectAlignTest(execution_mode, 4, 4); + RunJSSelectAlignTest(execution_tier, 4, 3); + RunJSSelectAlignTest(execution_tier, 4, 4); } WASM_EXEC_TEST(Run_JSSelectAlign_7) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 7, 3); - RunJSSelectAlignTest(execution_mode, 7, 4); - RunJSSelectAlignTest(execution_mode, 7, 4); - RunJSSelectAlignTest(execution_mode, 7, 4); + RunJSSelectAlignTest(execution_tier, 7, 3); + RunJSSelectAlignTest(execution_tier, 7, 4); + RunJSSelectAlignTest(execution_tier, 7, 4); + RunJSSelectAlignTest(execution_tier, 7, 4); } WASM_EXEC_TEST(Run_JSSelectAlign_8) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 8, 5); - RunJSSelectAlignTest(execution_mode, 8, 6); - RunJSSelectAlignTest(execution_mode, 8, 7); - RunJSSelectAlignTest(execution_mode, 8, 8); + RunJSSelectAlignTest(execution_tier, 8, 5); + RunJSSelectAlignTest(execution_tier, 8, 6); + RunJSSelectAlignTest(execution_tier, 8, 7); + RunJSSelectAlignTest(execution_tier, 8, 8); } WASM_EXEC_TEST(Run_JSSelectAlign_9) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 9, 6); - RunJSSelectAlignTest(execution_mode, 9, 7); - RunJSSelectAlignTest(execution_mode, 9, 8); - RunJSSelectAlignTest(execution_mode, 9, 9); + RunJSSelectAlignTest(execution_tier, 9, 6); + RunJSSelectAlignTest(execution_tier, 9, 7); + RunJSSelectAlignTest(execution_tier, 9, 8); + RunJSSelectAlignTest(execution_tier, 9, 9); } WASM_EXEC_TEST(Run_JSSelectAlign_10) { CcTest::InitializeVM(); - RunJSSelectAlignTest(execution_mode, 10, 7); - RunJSSelectAlignTest(execution_mode, 10, 8); - RunJSSelectAlignTest(execution_mode, 10, 9); - RunJSSelectAlignTest(execution_mode, 10, 10); + RunJSSelectAlignTest(execution_tier, 10, 7); + RunJSSelectAlignTest(execution_tier, 10, 8); + RunJSSelectAlignTest(execution_tier, 10, 9); + RunJSSelectAlignTest(execution_tier, 10, 10); } #undef ADD_CODE diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc index bbceec73a3..d25aeafa33 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-module.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-module.cc @@ -5,7 +5,7 @@ #include <stdlib.h> #include <string.h> -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/snapshot/code-serializer.h" #include "src/version.h" @@ -886,9 +886,11 @@ TEST(AtomicOpDisassembly) { testing::SetupIsolateForWasmModule(isolate); ErrorThrower thrower(isolate, "Test"); + auto enabled_features = WasmFeaturesFromIsolate(isolate); MaybeHandle<WasmModuleObject> module_object = isolate->wasm_engine()->SyncCompile( - isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); + isolate, enabled_features, &thrower, + ModuleWireBytes(buffer.begin(), buffer.end())); module_object.ToHandleChecked()->DisassembleFunction(0); } diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-sign-extension.cc b/deps/v8/test/cctest/wasm/test-run-wasm-sign-extension.cc index 17a79bc27f..71b5285439 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-sign-extension.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-sign-extension.cc @@ -13,7 +13,7 @@ namespace wasm { // TODO(gdeepti): Enable tests to run in the interpreter. WASM_EXEC_TEST(I32SExtendI8) { EXPERIMENTAL_FLAG_SCOPE(se); - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_SIGN_EXT_I8(WASM_GET_LOCAL(0))); CHECK_EQ(0, r.Call(0)); CHECK_EQ(1, r.Call(1)); @@ -24,7 +24,7 @@ WASM_EXEC_TEST(I32SExtendI8) { WASM_EXEC_TEST(I32SExtendI16) { EXPERIMENTAL_FLAG_SCOPE(se); - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_SIGN_EXT_I16(WASM_GET_LOCAL(0))); CHECK_EQ(0, r.Call(0)); CHECK_EQ(1, r.Call(1)); @@ -35,7 +35,7 @@ WASM_EXEC_TEST(I32SExtendI16) { WASM_EXEC_TEST(I64SExtendI8) { EXPERIMENTAL_FLAG_SCOPE(se); - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SIGN_EXT_I8(WASM_GET_LOCAL(0))); CHECK_EQ(0, r.Call(0)); CHECK_EQ(1, r.Call(1)); @@ -46,7 +46,7 @@ WASM_EXEC_TEST(I64SExtendI8) { WASM_EXEC_TEST(I64SExtendI16) { EXPERIMENTAL_FLAG_SCOPE(se); - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SIGN_EXT_I16(WASM_GET_LOCAL(0))); CHECK_EQ(0, r.Call(0)); CHECK_EQ(1, r.Call(1)); @@ -57,7 +57,7 @@ WASM_EXEC_TEST(I64SExtendI16) { WASM_EXEC_TEST(I64SExtendI32) { EXPERIMENTAL_FLAG_SCOPE(se); - WasmRunner<int64_t, int64_t> r(execution_mode); + WasmRunner<int64_t, int64_t> r(execution_tier); BUILD(r, WASM_I64_SIGN_EXT_I32(WASM_GET_LOCAL(0))); CHECK_EQ(0, r.Call(0)); CHECK_EQ(1, r.Call(1)); diff --git a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc index 271ce341fe..f60c65b727 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm-simd.cc @@ -32,23 +32,22 @@ typedef int8_t (*Int8BinOp)(int8_t, int8_t); typedef int (*Int8CompareOp)(int8_t, int8_t); typedef int8_t (*Int8ShiftOp)(int8_t, int); -#define WASM_SIMD_TEST(name) \ - void RunWasm_##name##_Impl(LowerSimd lower_simd, \ - WasmExecutionMode execution_mode); \ - TEST(RunWasm_##name##_turbofan) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(kNoLowerSimd, kExecuteTurbofan); \ - } \ - TEST(RunWasm_##name##_interpreter) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(kNoLowerSimd, kExecuteInterpreter); \ - } \ - TEST(RunWasm_##name##_simd_lowered) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(kLowerSimd, kExecuteTurbofan); \ - } \ - void RunWasm_##name##_Impl(LowerSimd lower_simd, \ - WasmExecutionMode execution_mode) +#define WASM_SIMD_TEST(name) \ + void RunWasm_##name##_Impl(LowerSimd lower_simd, \ + ExecutionTier execution_tier); \ + TEST(RunWasm_##name##_turbofan) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kNoLowerSimd, ExecutionTier::kOptimized); \ + } \ + TEST(RunWasm_##name##_interpreter) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kNoLowerSimd, ExecutionTier::kInterpreter); \ + } \ + TEST(RunWasm_##name##_simd_lowered) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kLowerSimd, ExecutionTier::kOptimized); \ + } \ + void RunWasm_##name##_Impl(LowerSimd lower_simd, ExecutionTier execution_tier) // Generic expected value functions. template <typename T> @@ -400,7 +399,7 @@ bool SkipFPValue(float x) { bool SkipFPExpectedValue(float x) { return std::isnan(x) || SkipFPValue(x); } WASM_SIMD_TEST(F32x4Splat) { - WasmRunner<int32_t, float> r(execution_mode, lower_simd); + WasmRunner<int32_t, float> r(execution_tier, lower_simd); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -414,7 +413,7 @@ WASM_SIMD_TEST(F32x4Splat) { } WASM_SIMD_TEST(F32x4ReplaceLane) { - WasmRunner<int32_t, float, float> r(execution_mode, lower_simd); + WasmRunner<int32_t, float, float> r(execution_tier, lower_simd); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -443,7 +442,7 @@ WASM_SIMD_TEST(F32x4ReplaceLane) { V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Tests both signed and unsigned conversion. WASM_SIMD_TEST(F32x4ConvertI32x4) { - WasmRunner<int32_t, int32_t, float, float> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, float, float> r(execution_tier, lower_simd); byte a = 0; byte expected_signed = 1; byte expected_unsigned = 2; @@ -467,10 +466,10 @@ WASM_SIMD_TEST(F32x4ConvertI32x4) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunF32x4UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunF32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, FloatUnOp expected_op, float error = 0.0f) { - WasmRunner<int32_t, float, float, float> r(execution_mode, lower_simd); + WasmRunner<int32_t, float, float, float> r(execution_tier, lower_simd); byte a = 0; byte low = 1; byte high = 2; @@ -490,27 +489,27 @@ void RunF32x4UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(F32x4Abs) { - RunF32x4UnOpTest(execution_mode, lower_simd, kExprF32x4Abs, std::abs); + RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Abs, std::abs); } WASM_SIMD_TEST(F32x4Neg) { - RunF32x4UnOpTest(execution_mode, lower_simd, kExprF32x4Neg, Negate); + RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4Neg, Negate); } static const float kApproxError = 0.01f; WASM_SIMD_TEST(F32x4RecipApprox) { - RunF32x4UnOpTest(execution_mode, lower_simd, kExprF32x4RecipApprox, Recip, + RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4RecipApprox, Recip, kApproxError); } WASM_SIMD_TEST(F32x4RecipSqrtApprox) { - RunF32x4UnOpTest(execution_mode, lower_simd, kExprF32x4RecipSqrtApprox, + RunF32x4UnOpTest(execution_tier, lower_simd, kExprF32x4RecipSqrtApprox, RecipSqrt, kApproxError); } -void RunF32x4BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunF32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, FloatBinOp expected_op) { - WasmRunner<int32_t, float, float, float> r(execution_mode, lower_simd); + WasmRunner<int32_t, float, float, float> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -534,25 +533,24 @@ void RunF32x4BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(F32x4Add) { - RunF32x4BinOpTest(execution_mode, lower_simd, kExprF32x4Add, Add); + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Add, Add); } WASM_SIMD_TEST(F32x4Sub) { - RunF32x4BinOpTest(execution_mode, lower_simd, kExprF32x4Sub, Sub); + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Sub, Sub); } WASM_SIMD_TEST(F32x4Mul) { - RunF32x4BinOpTest(execution_mode, lower_simd, kExprF32x4Mul, Mul); + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Mul, Mul); } WASM_SIMD_TEST(F32x4_Min) { - RunF32x4BinOpTest(execution_mode, lower_simd, kExprF32x4Min, JSMin); + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Min, JSMin); } WASM_SIMD_TEST(F32x4_Max) { - RunF32x4BinOpTest(execution_mode, lower_simd, kExprF32x4Max, JSMax); + RunF32x4BinOpTest(execution_tier, lower_simd, kExprF32x4Max, JSMax); } -void RunF32x4CompareOpTest(WasmExecutionMode execution_mode, - LowerSimd lower_simd, WasmOpcode simd_op, - FloatCompareOp expected_op) { - WasmRunner<int32_t, float, float, int32_t> r(execution_mode, lower_simd); +void RunF32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode simd_op, FloatCompareOp expected_op) { + WasmRunner<int32_t, float, float, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -576,27 +574,27 @@ void RunF32x4CompareOpTest(WasmExecutionMode execution_mode, } WASM_SIMD_TEST(F32x4Eq) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Eq, Equal); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Eq, Equal); } WASM_SIMD_TEST(F32x4Ne) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Ne, NotEqual); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Ne, NotEqual); } WASM_SIMD_TEST(F32x4Gt) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Gt, Greater); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Gt, Greater); } WASM_SIMD_TEST(F32x4Ge) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Ge, GreaterEqual); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Ge, GreaterEqual); } WASM_SIMD_TEST(F32x4Lt) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Lt, Less); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Lt, Less); } WASM_SIMD_TEST(F32x4Le) { - RunF32x4CompareOpTest(execution_mode, lower_simd, kExprF32x4Le, LessEqual); + RunF32x4CompareOpTest(execution_tier, lower_simd, kExprF32x4Le, LessEqual); } WASM_SIMD_TEST(I32x4Splat) { @@ -610,7 +608,7 @@ WASM_SIMD_TEST(I32x4Splat) { // return 0 // // return 1 - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -621,7 +619,7 @@ WASM_SIMD_TEST(I32x4Splat) { } WASM_SIMD_TEST(I32x4ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -647,7 +645,7 @@ WASM_SIMD_TEST(I32x4ReplaceLane) { } WASM_SIMD_TEST(I16x8Splat) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -658,7 +656,7 @@ WASM_SIMD_TEST(I16x8Splat) { } WASM_SIMD_TEST(I16x8ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -707,7 +705,7 @@ WASM_SIMD_TEST(I16x8ReplaceLane) { } WASM_SIMD_TEST(I8x16Splat) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); byte lane_val = 0; byte simd = r.AllocateLocal(kWasmS128); BUILD(r, @@ -718,7 +716,7 @@ WASM_SIMD_TEST(I8x16Splat) { } WASM_SIMD_TEST(I8x16ReplaceLane) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte old_val = 0; byte new_val = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -839,7 +837,7 @@ int32_t ConvertToInt(double val, bool unsigned_integer) { // Tests both signed and unsigned conversion. WASM_SIMD_TEST(I32x4ConvertF32x4) { - WasmRunner<int32_t, float, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, float, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected_signed = 1; byte expected_unsigned = 2; @@ -864,7 +862,7 @@ WASM_SIMD_TEST(I32x4ConvertF32x4) { // Tests both signed and unsigned conversion from I16x8 (unpacking). WASM_SIMD_TEST(I32x4ConvertI16x8) { - WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(execution_mode, + WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte unpacked_signed = 1; @@ -905,9 +903,9 @@ WASM_SIMD_TEST(I32x4ConvertI16x8) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunI32x4UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI32x4UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int32UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -919,16 +917,16 @@ void RunI32x4UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I32x4Neg) { - RunI32x4UnOpTest(execution_mode, lower_simd, kExprI32x4Neg, Negate); + RunI32x4UnOpTest(execution_tier, lower_simd, kExprI32x4Neg, Negate); } WASM_SIMD_TEST(S128Not) { - RunI32x4UnOpTest(execution_mode, lower_simd, kExprS128Not, Not); + RunI32x4UnOpTest(execution_tier, lower_simd, kExprS128Not, Not); } -void RunI32x4BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI32x4BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int32BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -946,51 +944,50 @@ void RunI32x4BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I32x4Add) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4Add, Add); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4Add, Add); } WASM_SIMD_TEST(I32x4Sub) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4Sub, Sub); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4Sub, Sub); } WASM_SIMD_TEST(I32x4Mul) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4Mul, Mul); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4Mul, Mul); } WASM_SIMD_TEST(I32x4MinS) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4MinS, Minimum); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4MinS, Minimum); } WASM_SIMD_TEST(I32x4MaxS) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4MaxS, Maximum); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4MaxS, Maximum); } WASM_SIMD_TEST(I32x4MinU) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4MinU, + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4MinU, UnsignedMinimum); } WASM_SIMD_TEST(I32x4MaxU) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprI32x4MaxU, + RunI32x4BinOpTest(execution_tier, lower_simd, kExprI32x4MaxU, UnsignedMaximum); } WASM_SIMD_TEST(S128And) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprS128And, And); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprS128And, And); } WASM_SIMD_TEST(S128Or) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprS128Or, Or); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprS128Or, Or); } WASM_SIMD_TEST(S128Xor) { - RunI32x4BinOpTest(execution_mode, lower_simd, kExprS128Xor, Xor); + RunI32x4BinOpTest(execution_tier, lower_simd, kExprS128Xor, Xor); } -void RunI32x4CompareOpTest(WasmExecutionMode execution_mode, - LowerSimd lower_simd, WasmOpcode simd_op, - Int32CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); +void RunI32x4CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode simd_op, Int32CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -1008,54 +1005,54 @@ void RunI32x4CompareOpTest(WasmExecutionMode execution_mode, } WASM_SIMD_TEST(I32x4Eq) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4Eq, Equal); + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4Eq, Equal); } WASM_SIMD_TEST(I32x4Ne) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4Ne, NotEqual); + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4Ne, NotEqual); } WASM_SIMD_TEST(I32x4LtS) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4LtS, Less); + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4LtS, Less); } WASM_SIMD_TEST(I32x4LeS) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4LeS, LessEqual); + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4LeS, LessEqual); } WASM_SIMD_TEST(I32x4GtS) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4GtS, Greater); + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4GtS, Greater); } WASM_SIMD_TEST(I32x4GeS) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4GeS, + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4GeS, GreaterEqual); } WASM_SIMD_TEST(I32x4LtU) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4LtU, + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4LtU, UnsignedLess); } WASM_SIMD_TEST(I32x4LeU) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4LeU, + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4LeU, UnsignedLessEqual); } WASM_SIMD_TEST(I32x4GtU) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4GtU, + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4GtU, UnsignedGreater); } WASM_SIMD_TEST(I32x4GeU) { - RunI32x4CompareOpTest(execution_mode, lower_simd, kExprI32x4GeU, + RunI32x4CompareOpTest(execution_tier, lower_simd, kExprI32x4GeU, UnsignedGreaterEqual); } -void RunI32x4ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI32x4ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int32ShiftOp expected_op) { for (int shift = 1; shift < 32; ++shift) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1069,17 +1066,17 @@ void RunI32x4ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I32x4Shl) { - RunI32x4ShiftOpTest(execution_mode, lower_simd, kExprI32x4Shl, + RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4Shl, LogicalShiftLeft); } WASM_SIMD_TEST(I32x4ShrS) { - RunI32x4ShiftOpTest(execution_mode, lower_simd, kExprI32x4ShrS, + RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4ShrS, ArithmeticShiftRight); } WASM_SIMD_TEST(I32x4ShrU) { - RunI32x4ShiftOpTest(execution_mode, lower_simd, kExprI32x4ShrU, + RunI32x4ShiftOpTest(execution_tier, lower_simd, kExprI32x4ShrU, LogicalShiftRight); } @@ -1087,7 +1084,7 @@ WASM_SIMD_TEST(I32x4ShrU) { V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 // Tests both signed and unsigned conversion from I8x16 (unpacking). WASM_SIMD_TEST(I16x8ConvertI8x16) { - WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(execution_mode, + WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte unpacked_signed = 1; @@ -1130,9 +1127,9 @@ WASM_SIMD_TEST(I16x8ConvertI8x16) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunI16x8UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI16x8UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int16UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1144,7 +1141,7 @@ void RunI16x8UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I16x8Neg) { - RunI16x8UnOpTest(execution_mode, lower_simd, kExprI16x8Neg, Negate); + RunI16x8UnOpTest(execution_tier, lower_simd, kExprI16x8Neg, Negate); } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ @@ -1152,7 +1149,7 @@ WASM_SIMD_TEST(I16x8Neg) { // Tests both signed and unsigned conversion from I32x4 (packing). WASM_SIMD_TEST(I16x8ConvertI32x4) { WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t> r( - execution_mode, lower_simd); + execution_tier, lower_simd); byte a = 0; byte b = 1; // indices for packed signed params @@ -1196,9 +1193,9 @@ WASM_SIMD_TEST(I16x8ConvertI32x4) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunI16x8BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI16x8BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int16BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -1216,59 +1213,58 @@ void RunI16x8BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I16x8Add) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8Add, Add); + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8Add, Add); } WASM_SIMD_TEST(I16x8AddSaturateS) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8AddSaturateS, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8AddSaturateS, AddSaturate); } WASM_SIMD_TEST(I16x8Sub) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8Sub, Sub); + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8Sub, Sub); } WASM_SIMD_TEST(I16x8SubSaturateS) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8SubSaturateS, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8SubSaturateS, SubSaturate); } WASM_SIMD_TEST(I16x8Mul) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8Mul, Mul); + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8Mul, Mul); } WASM_SIMD_TEST(I16x8MinS) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8MinS, Minimum); + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8MinS, Minimum); } WASM_SIMD_TEST(I16x8MaxS) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8MaxS, Maximum); + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8MaxS, Maximum); } WASM_SIMD_TEST(I16x8AddSaturateU) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8AddSaturateU, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8AddSaturateU, UnsignedAddSaturate); } WASM_SIMD_TEST(I16x8SubSaturateU) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8SubSaturateU, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8SubSaturateU, UnsignedSubSaturate); } WASM_SIMD_TEST(I16x8MinU) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8MinU, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8MinU, UnsignedMinimum); } WASM_SIMD_TEST(I16x8MaxU) { - RunI16x8BinOpTest(execution_mode, lower_simd, kExprI16x8MaxU, + RunI16x8BinOpTest(execution_tier, lower_simd, kExprI16x8MaxU, UnsignedMaximum); } -void RunI16x8CompareOpTest(WasmExecutionMode execution_mode, - LowerSimd lower_simd, WasmOpcode simd_op, - Int16CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); +void RunI16x8CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode simd_op, Int16CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -1286,54 +1282,54 @@ void RunI16x8CompareOpTest(WasmExecutionMode execution_mode, } WASM_SIMD_TEST(I16x8Eq) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8Eq, Equal); + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8Eq, Equal); } WASM_SIMD_TEST(I16x8Ne) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8Ne, NotEqual); + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8Ne, NotEqual); } WASM_SIMD_TEST(I16x8LtS) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8LtS, Less); + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8LtS, Less); } WASM_SIMD_TEST(I16x8LeS) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8LeS, LessEqual); + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8LeS, LessEqual); } WASM_SIMD_TEST(I16x8GtS) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8GtS, Greater); + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8GtS, Greater); } WASM_SIMD_TEST(I16x8GeS) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8GeS, + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8GeS, GreaterEqual); } WASM_SIMD_TEST(I16x8GtU) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8GtU, + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8GtU, UnsignedGreater); } WASM_SIMD_TEST(I16x8GeU) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8GeU, + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8GeU, UnsignedGreaterEqual); } WASM_SIMD_TEST(I16x8LtU) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8LtU, + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8LtU, UnsignedLess); } WASM_SIMD_TEST(I16x8LeU) { - RunI16x8CompareOpTest(execution_mode, lower_simd, kExprI16x8LeU, + RunI16x8CompareOpTest(execution_tier, lower_simd, kExprI16x8LeU, UnsignedLessEqual); } -void RunI16x8ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI16x8ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int16ShiftOp expected_op) { for (int shift = 1; shift < 16; ++shift) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1347,23 +1343,23 @@ void RunI16x8ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I16x8Shl) { - RunI16x8ShiftOpTest(execution_mode, lower_simd, kExprI16x8Shl, + RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8Shl, LogicalShiftLeft); } WASM_SIMD_TEST(I16x8ShrS) { - RunI16x8ShiftOpTest(execution_mode, lower_simd, kExprI16x8ShrS, + RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8ShrS, ArithmeticShiftRight); } WASM_SIMD_TEST(I16x8ShrU) { - RunI16x8ShiftOpTest(execution_mode, lower_simd, kExprI16x8ShrU, + RunI16x8ShiftOpTest(execution_tier, lower_simd, kExprI16x8ShrU, LogicalShiftRight); } -void RunI8x16UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI8x16UnOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int8UnOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1375,7 +1371,7 @@ void RunI8x16UnOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I8x16Neg) { - RunI8x16UnOpTest(execution_mode, lower_simd, kExprI8x16Neg, Negate); + RunI8x16UnOpTest(execution_tier, lower_simd, kExprI8x16Neg, Negate); } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ @@ -1383,7 +1379,7 @@ WASM_SIMD_TEST(I8x16Neg) { // Tests both signed and unsigned conversion from I16x8 (packing). WASM_SIMD_TEST(I8x16ConvertI16x8) { WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t, int32_t, int32_t> r( - execution_mode, lower_simd); + execution_tier, lower_simd); byte a = 0; byte b = 1; // indices for packed signed params @@ -1429,9 +1425,9 @@ WASM_SIMD_TEST(I8x16ConvertI16x8) { #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunI8x16BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI8x16BinOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int8BinOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -1449,55 +1445,54 @@ void RunI8x16BinOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, } WASM_SIMD_TEST(I8x16Add) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16Add, Add); + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16Add, Add); } WASM_SIMD_TEST(I8x16AddSaturateS) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16AddSaturateS, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16AddSaturateS, AddSaturate); } WASM_SIMD_TEST(I8x16Sub) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16Sub, Sub); + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16Sub, Sub); } WASM_SIMD_TEST(I8x16SubSaturateS) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16SubSaturateS, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16SubSaturateS, SubSaturate); } WASM_SIMD_TEST(I8x16MinS) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16MinS, Minimum); + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16MinS, Minimum); } WASM_SIMD_TEST(I8x16MaxS) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16MaxS, Maximum); + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16MaxS, Maximum); } WASM_SIMD_TEST(I8x16AddSaturateU) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16AddSaturateU, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16AddSaturateU, UnsignedAddSaturate); } WASM_SIMD_TEST(I8x16SubSaturateU) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16SubSaturateU, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16SubSaturateU, UnsignedSubSaturate); } WASM_SIMD_TEST(I8x16MinU) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16MinU, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16MinU, UnsignedMinimum); } WASM_SIMD_TEST(I8x16MaxU) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16MaxU, + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16MaxU, UnsignedMaximum); } -void RunI8x16CompareOpTest(WasmExecutionMode execution_mode, - LowerSimd lower_simd, WasmOpcode simd_op, - Int8CompareOp expected_op) { - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, lower_simd); +void RunI8x16CompareOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, + WasmOpcode simd_op, Int8CompareOp expected_op) { + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte b = 1; byte expected = 2; @@ -1515,62 +1510,62 @@ void RunI8x16CompareOpTest(WasmExecutionMode execution_mode, } WASM_SIMD_TEST(I8x16Eq) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16Eq, Equal); + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16Eq, Equal); } WASM_SIMD_TEST(I8x16Ne) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16Ne, NotEqual); + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16Ne, NotEqual); } WASM_SIMD_TEST(I8x16GtS) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16GtS, Greater); + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16GtS, Greater); } WASM_SIMD_TEST(I8x16GeS) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16GeS, + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16GeS, GreaterEqual); } WASM_SIMD_TEST(I8x16LtS) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16LtS, Less); + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16LtS, Less); } WASM_SIMD_TEST(I8x16LeS) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16LeS, LessEqual); + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16LeS, LessEqual); } WASM_SIMD_TEST(I8x16GtU) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16GtU, + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16GtU, UnsignedGreater); } WASM_SIMD_TEST(I8x16GeU) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16GeU, + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16GeU, UnsignedGreaterEqual); } WASM_SIMD_TEST(I8x16LtU) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16LtU, + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16LtU, UnsignedLess); } WASM_SIMD_TEST(I8x16LeU) { - RunI8x16CompareOpTest(execution_mode, lower_simd, kExprI8x16LeU, + RunI8x16CompareOpTest(execution_tier, lower_simd, kExprI8x16LeU, UnsignedLessEqual); } #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 WASM_SIMD_TEST(I8x16Mul) { - RunI8x16BinOpTest(execution_mode, lower_simd, kExprI8x16Mul, Mul); + RunI8x16BinOpTest(execution_tier, lower_simd, kExprI8x16Mul, Mul); } #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 -void RunI8x16ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunI8x16ShiftOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, Int8ShiftOp expected_op) { for (int shift = 1; shift < 8; ++shift) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); byte a = 0; byte expected = 1; byte simd = r.AllocateLocal(kWasmS128); @@ -1586,17 +1581,17 @@ void RunI8x16ShiftOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || \ V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 WASM_SIMD_TEST(I8x16Shl) { - RunI8x16ShiftOpTest(execution_mode, lower_simd, kExprI8x16Shl, + RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16Shl, LogicalShiftLeft); } WASM_SIMD_TEST(I8x16ShrS) { - RunI8x16ShiftOpTest(execution_mode, lower_simd, kExprI8x16ShrS, + RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16ShrS, ArithmeticShiftRight); } WASM_SIMD_TEST(I8x16ShrU) { - RunI8x16ShiftOpTest(execution_mode, lower_simd, kExprI8x16ShrU, + RunI8x16ShiftOpTest(execution_tier, lower_simd, kExprI8x16ShrU, LogicalShiftRight); } #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS || @@ -1607,7 +1602,7 @@ WASM_SIMD_TEST(I8x16ShrU) { // vector. #define WASM_SIMD_SELECT_TEST(format) \ WASM_SIMD_TEST(S##format##Select) { \ - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode, lower_simd); \ + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier, lower_simd); \ byte val1 = 0; \ byte val2 = 1; \ byte src1 = r.AllocateLocal(kWasmS128); \ @@ -1647,7 +1642,7 @@ WASM_SIMD_SELECT_TEST(8x16) // rest 0. The mask is not the result of a comparison op. #define WASM_SIMD_NON_CANONICAL_SELECT_TEST(format) \ WASM_SIMD_TEST(S##format##NonCanonicalSelect) { \ - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode, \ + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier, \ lower_simd); \ byte val1 = 0; \ byte val2 = 1; \ @@ -1684,16 +1679,16 @@ WASM_SIMD_NON_CANONICAL_SELECT_TEST(8x16) // Test binary ops with two lane test patterns, all lanes distinct. template <typename T> void RunBinaryLaneOpTest( - WasmExecutionMode execution_mode, LowerSimd lower_simd, WasmOpcode simd_op, + ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, const std::array<T, kSimd128Size / sizeof(T)>& expected) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); // Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7]. T* src0 = r.builder().AddGlobal<T>(kWasmS128); T* src1 = r.builder().AddGlobal<T>(kWasmS128); static const int kElems = kSimd128Size / sizeof(T); for (int i = 0; i < kElems; i++) { - src0[i] = i; - src1[i] = kElems + i; + WriteLittleEndianValue<T>(&src0[i], i); + WriteLittleEndianValue<T>(&src1[i], kElems + i); } if (simd_op == kExprS8x16Shuffle) { BUILD(r, @@ -1710,50 +1705,50 @@ void RunBinaryLaneOpTest( CHECK_EQ(1, r.Call()); for (size_t i = 0; i < expected.size(); i++) { - CHECK_EQ(src0[i], expected[i]); + CHECK_EQ(ReadLittleEndianValue<T>(&src0[i]), expected[i]); } } WASM_SIMD_TEST(I32x4AddHoriz) { // Inputs are [0 1 2 3] and [4 5 6 7]. - RunBinaryLaneOpTest<int32_t>(execution_mode, lower_simd, kExprI32x4AddHoriz, + RunBinaryLaneOpTest<int32_t>(execution_tier, lower_simd, kExprI32x4AddHoriz, {{1, 5, 9, 13}}); } WASM_SIMD_TEST(I16x8AddHoriz) { // Inputs are [0 1 2 3 4 5 6 7] and [8 9 10 11 12 13 14 15]. - RunBinaryLaneOpTest<int16_t>(execution_mode, lower_simd, kExprI16x8AddHoriz, + RunBinaryLaneOpTest<int16_t>(execution_tier, lower_simd, kExprI16x8AddHoriz, {{1, 5, 9, 13, 17, 21, 25, 29}}); } WASM_SIMD_TEST(F32x4AddHoriz) { // Inputs are [0.0f 1.0f 2.0f 3.0f] and [4.0f 5.0f 6.0f 7.0f]. - RunBinaryLaneOpTest<float>(execution_mode, lower_simd, kExprF32x4AddHoriz, + RunBinaryLaneOpTest<float>(execution_tier, lower_simd, kExprF32x4AddHoriz, {{1.0f, 5.0f, 9.0f, 13.0f}}); } // Test shuffle ops. -void RunShuffleOpTest(WasmExecutionMode execution_mode, LowerSimd lower_simd, +void RunShuffleOpTest(ExecutionTier execution_tier, LowerSimd lower_simd, WasmOpcode simd_op, const std::array<int8_t, kSimd128Size>& shuffle) { // Test the original shuffle. - RunBinaryLaneOpTest<int8_t>(execution_mode, lower_simd, simd_op, shuffle); + RunBinaryLaneOpTest<int8_t>(execution_tier, lower_simd, simd_op, shuffle); // Test a non-canonical (inputs reversed) version of the shuffle. std::array<int8_t, kSimd128Size> other_shuffle(shuffle); for (size_t i = 0; i < shuffle.size(); ++i) other_shuffle[i] ^= kSimd128Size; - RunBinaryLaneOpTest<int8_t>(execution_mode, lower_simd, simd_op, + RunBinaryLaneOpTest<int8_t>(execution_tier, lower_simd, simd_op, other_shuffle); // Test the swizzle (one-operand) version of the shuffle. std::array<int8_t, kSimd128Size> swizzle(shuffle); for (size_t i = 0; i < shuffle.size(); ++i) swizzle[i] &= (kSimd128Size - 1); - RunBinaryLaneOpTest<int8_t>(execution_mode, lower_simd, simd_op, swizzle); + RunBinaryLaneOpTest<int8_t>(execution_tier, lower_simd, simd_op, swizzle); // Test the non-canonical swizzle (one-operand) version of the shuffle. std::array<int8_t, kSimd128Size> other_swizzle(shuffle); for (size_t i = 0; i < shuffle.size(); ++i) other_swizzle[i] |= kSimd128Size; - RunBinaryLaneOpTest<int8_t>(execution_mode, lower_simd, simd_op, + RunBinaryLaneOpTest<int8_t>(execution_tier, lower_simd, simd_op, other_swizzle); } @@ -1868,7 +1863,7 @@ ShuffleMap test_shuffles = { WASM_SIMD_TEST(Name) { \ ShuffleMap::const_iterator it = test_shuffles.find(k##Name); \ DCHECK_NE(it, test_shuffles.end()); \ - RunShuffleOpTest(execution_mode, lower_simd, kExprS8x16Shuffle, \ + RunShuffleOpTest(execution_tier, lower_simd, kExprS8x16Shuffle, \ it->second); \ } SHUFFLE_LIST(SHUFFLE_TEST) @@ -1881,7 +1876,7 @@ WASM_SIMD_TEST(S8x16Blend) { for (int bias = 1; bias < kSimd128Size; bias++) { for (int i = 0; i < bias; i++) expected[i] = i; for (int i = bias; i < kSimd128Size; i++) expected[i] = i + kSimd128Size; - RunShuffleOpTest(execution_mode, lower_simd, kExprS8x16Shuffle, expected); + RunShuffleOpTest(execution_tier, lower_simd, kExprS8x16Shuffle, expected); } } @@ -1899,7 +1894,7 @@ WASM_SIMD_TEST(S8x16Concat) { for (int j = 0; j < n; ++j) { expected[i++] = j + kSimd128Size; } - RunShuffleOpTest(execution_mode, lower_simd, kExprS8x16Shuffle, expected); + RunShuffleOpTest(execution_tier, lower_simd, kExprS8x16Shuffle, expected); } } @@ -1926,7 +1921,7 @@ WASM_SIMD_TEST(S8x16ShuffleFuzz) { for (int i = 0; i < kTests; ++i) { auto shuffle = Combine(GetRandomTestShuffle(rng), GetRandomTestShuffle(rng), GetRandomTestShuffle(rng)); - RunShuffleOpTest(execution_mode, lower_simd, kExprS8x16Shuffle, shuffle); + RunShuffleOpTest(execution_tier, lower_simd, kExprS8x16Shuffle, shuffle); } } @@ -1957,35 +1952,34 @@ void BuildShuffle(std::vector<Shuffle>& shuffles, std::vector<byte>* buffer) { } // Runs tests of compiled code, using the interpreter as a reference. -#define WASM_SIMD_COMPILED_TEST(name) \ - void RunWasm_##name##_Impl(LowerSimd lower_simd, \ - WasmExecutionMode execution_mode); \ - TEST(RunWasm_##name##_turbofan) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(kNoLowerSimd, kExecuteTurbofan); \ - } \ - TEST(RunWasm_##name##_simd_lowered) { \ - EXPERIMENTAL_FLAG_SCOPE(simd); \ - RunWasm_##name##_Impl(kLowerSimd, kExecuteTurbofan); \ - } \ - void RunWasm_##name##_Impl(LowerSimd lower_simd, \ - WasmExecutionMode execution_mode) - -void RunWasmCode(WasmExecutionMode execution_mode, LowerSimd lower_simd, +#define WASM_SIMD_COMPILED_TEST(name) \ + void RunWasm_##name##_Impl(LowerSimd lower_simd, \ + ExecutionTier execution_tier); \ + TEST(RunWasm_##name##_turbofan) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kNoLowerSimd, ExecutionTier::kOptimized); \ + } \ + TEST(RunWasm_##name##_simd_lowered) { \ + EXPERIMENTAL_FLAG_SCOPE(simd); \ + RunWasm_##name##_Impl(kLowerSimd, ExecutionTier::kOptimized); \ + } \ + void RunWasm_##name##_Impl(LowerSimd lower_simd, ExecutionTier execution_tier) + +void RunWasmCode(ExecutionTier execution_tier, LowerSimd lower_simd, const std::vector<byte>& code, std::array<int8_t, kSimd128Size>* result) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); // Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7]. int8_t* src0 = r.builder().AddGlobal<int8_t>(kWasmS128); int8_t* src1 = r.builder().AddGlobal<int8_t>(kWasmS128); for (int i = 0; i < kSimd128Size; ++i) { - src0[i] = i; - src1[i] = kSimd128Size + i; + WriteLittleEndianValue<int8_t>(&src0[i], i); + WriteLittleEndianValue<int8_t>(&src1[i], kSimd128Size + i); } r.Build(code.data(), code.data() + code.size()); CHECK_EQ(1, r.Call()); for (size_t i = 0; i < kSimd128Size; i++) { - (*result)[i] = src0[i]; + (*result)[i] = ReadLittleEndianValue<int8_t>(&src0[i]); } } @@ -2009,10 +2003,10 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { // Run the code using the interpreter to get the expected result. std::array<int8_t, kSimd128Size> expected; - RunWasmCode(kExecuteInterpreter, kNoLowerSimd, buffer, &expected); + RunWasmCode(ExecutionTier::kInterpreter, kNoLowerSimd, buffer, &expected); // Run the SIMD or scalar lowered compiled code and compare results. std::array<int8_t, kSimd128Size> result; - RunWasmCode(execution_mode, lower_simd, buffer, &result); + RunWasmCode(execution_tier, lower_simd, buffer, &result); for (size_t i = 0; i < kSimd128Size; ++i) { CHECK_EQ(result[i], expected[i]); } @@ -2024,7 +2018,7 @@ WASM_SIMD_COMPILED_TEST(S8x16MultiShuffleFuzz) { // test inputs. Test inputs with all true, all false, one true, and one false. #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ WASM_SIMD_TEST(ReductionTest##lanes) { \ - WasmRunner<int32_t> r(execution_mode, lower_simd); \ + WasmRunner<int32_t> r(execution_tier, lower_simd); \ byte zero = r.AllocateLocal(kWasmS128); \ byte one_one = r.AllocateLocal(kWasmS128); \ byte reduced = r.AllocateLocal(kWasmI32); \ @@ -2097,7 +2091,7 @@ WASM_SIMD_BOOL_REDUCTION_TEST(16x8, 8) WASM_SIMD_BOOL_REDUCTION_TEST(8x16, 16) WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); BUILD(r, WASM_IF_ELSE_I( WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE( 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))), @@ -2109,7 +2103,7 @@ WASM_SIMD_TEST(SimdI32x4ExtractWithF32x4) { // V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_IA32 WASM_SIMD_TEST(SimdF32x4ExtractWithI32x4) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); BUILD(r, WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE( 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))), @@ -2123,7 +2117,7 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { // representable as a float. const int kOne = 0x3F800000; const int kTwo = 0x40000000; - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); BUILD(r, WASM_IF_ELSE_I( WASM_F32_EQ( @@ -2138,7 +2132,7 @@ WASM_SIMD_TEST(SimdF32x4AddWithI32x4) { } WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); BUILD(r, WASM_IF_ELSE_I( WASM_I32_EQ( @@ -2153,7 +2147,7 @@ WASM_SIMD_TEST(SimdI32x4AddWithF32x4) { } WASM_SIMD_TEST(SimdI32x4Local) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))), @@ -2162,7 +2156,7 @@ WASM_SIMD_TEST(SimdI32x4Local) { } WASM_SIMD_TEST(SimdI32x4SplatFromExtract) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE( @@ -2173,7 +2167,7 @@ WASM_SIMD_TEST(SimdI32x4SplatFromExtract) { } WASM_SIMD_TEST(SimdI32x4For) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, @@ -2207,7 +2201,7 @@ WASM_SIMD_TEST(SimdI32x4For) { } WASM_SIMD_TEST(SimdF32x4For) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmS128); BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))), @@ -2233,30 +2227,21 @@ WASM_SIMD_TEST(SimdF32x4For) { template <typename T, int numLanes = 4> void SetVectorByLanes(T* v, const std::array<T, numLanes>& arr) { for (int lane = 0; lane < numLanes; lane++) { - const T& value = arr[lane]; -#if defined(V8_TARGET_BIG_ENDIAN) - v[numLanes - 1 - lane] = value; -#else - v[lane] = value; -#endif + WriteLittleEndianValue<T>(&v[lane], arr[lane]); } } template <typename T> -const T& GetScalar(T* v, int lane) { +const T GetScalar(T* v, int lane) { constexpr int kElems = kSimd128Size / sizeof(T); -#if defined(V8_TARGET_BIG_ENDIAN) - const int index = kElems - 1 - lane; -#else const int index = lane; -#endif USE(kElems); DCHECK(index >= 0 && index < kElems); - return v[index]; + return ReadLittleEndianValue<T>(&v[index]); } WASM_SIMD_TEST(SimdI32x4GetGlobal) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); // Pad the globals with a few unused slots to get a non-zero offset. r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused @@ -2284,7 +2269,7 @@ WASM_SIMD_TEST(SimdI32x4GetGlobal) { } WASM_SIMD_TEST(SimdI32x4SetGlobal) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); // Pad the globals with a few unused slots to get a non-zero offset. r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused r.builder().AddGlobal<int32_t>(kWasmI32); // purposefully unused @@ -2307,7 +2292,7 @@ WASM_SIMD_TEST(SimdI32x4SetGlobal) { } WASM_SIMD_TEST(SimdF32x4GetGlobal) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); float* global = r.builder().AddGlobal<float>(kWasmS128); SetVectorByLanes<float>(global, {{0.0, 1.5, 2.25, 3.5}}); r.AllocateLocal(kWasmI32); @@ -2330,7 +2315,7 @@ WASM_SIMD_TEST(SimdF32x4GetGlobal) { } WASM_SIMD_TEST(SimdF32x4SetGlobal) { - WasmRunner<int32_t, int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t, int32_t> r(execution_tier, lower_simd); float* global = r.builder().AddGlobal<float>(kWasmS128); BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))), WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0), @@ -2348,7 +2333,7 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) { } WASM_SIMD_TEST(SimdLoadStoreLoad) { - WasmRunner<int32_t> r(execution_mode, lower_simd); + WasmRunner<int32_t> r(execution_tier, lower_simd); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); // Load memory, store it, then reload it and extract the first lane. Use a diff --git a/deps/v8/test/cctest/wasm/test-run-wasm.cc b/deps/v8/test/cctest/wasm/test-run-wasm.cc index bf47ddeadb..0ba12aedd9 100644 --- a/deps/v8/test/cctest/wasm/test-run-wasm.cc +++ b/deps/v8/test/cctest/wasm/test-run-wasm.cc @@ -27,7 +27,7 @@ namespace test_run_wasm { #define RET_I8(x) WASM_I32V_2(x), kExprReturn WASM_EXEC_TEST(Int32Const) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); const int32_t kExpectedValue = 0x11223344; // return(kExpectedValue) BUILD(r, WASM_I32V_5(kExpectedValue)); @@ -36,7 +36,7 @@ WASM_EXEC_TEST(Int32Const) { WASM_EXEC_TEST(Int32Const_many) { FOR_INT32_INPUTS(i) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); const int32_t kExpectedValue = *i; // return(kExpectedValue) BUILD(r, WASM_I32V(kExpectedValue)); @@ -46,58 +46,58 @@ WASM_EXEC_TEST(Int32Const_many) { WASM_EXEC_TEST(GraphTrimming) { // This WebAssembly code requires graph trimming in the TurboFan compiler. - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, kExprGetLocal, 0, kExprGetLocal, 0, kExprGetLocal, 0, kExprI32RemS, kExprI32Eq, kExprGetLocal, 0, kExprI32DivS, kExprUnreachable); r.Call(1); } WASM_EXEC_TEST(Int32Param0) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // return(local[0]) BUILD(r, WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Int32Param0_fallthru) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // local[0] BUILD(r, WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Int32Param1) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); // local[1] BUILD(r, WASM_GET_LOCAL(1)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(-111, *i)); } } WASM_EXEC_TEST(Int32Add) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // 11 + 44 BUILD(r, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(44))); CHECK_EQ(55, r.Call()); } WASM_EXEC_TEST(Int32Add_P) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // p0 + 13 BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); } } WASM_EXEC_TEST(Int32Add_P_fallthru) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // p0 + 13 BUILD(r, WASM_I32_ADD(WASM_I32V_1(13), WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i + 13, r.Call(*i)); } } -static void RunInt32AddTest(WasmExecutionMode execution_mode, const byte* code, +static void RunInt32AddTest(ExecutionTier execution_tier, const byte* code, size_t size) { TestSignatures sigs; - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().AddSignature(sigs.ii_v()); r.builder().AddSignature(sigs.iii_v()); r.Build(code, code + size); @@ -114,7 +114,7 @@ WASM_EXEC_TEST(Int32Add_P2) { EXPERIMENTAL_FLAG_SCOPE(mv); static const byte code[] = { WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))}; - RunInt32AddTest(execution_mode, code, sizeof(code)); + RunInt32AddTest(execution_tier, code, sizeof(code)); } WASM_EXEC_TEST(Int32Add_block1) { @@ -122,7 +122,7 @@ WASM_EXEC_TEST(Int32Add_block1) { static const byte code[] = { WASM_BLOCK_X(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), kExprI32Add}; - RunInt32AddTest(execution_mode, code, sizeof(code)); + RunInt32AddTest(execution_tier, code, sizeof(code)); } WASM_EXEC_TEST(Int32Add_block2) { @@ -130,7 +130,7 @@ WASM_EXEC_TEST(Int32Add_block2) { static const byte code[] = { WASM_BLOCK_X(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), kExprBr, DEPTH_0), kExprI32Add}; - RunInt32AddTest(execution_mode, code, sizeof(code)); + RunInt32AddTest(execution_tier, code, sizeof(code)); } WASM_EXEC_TEST(Int32Add_multi_if) { @@ -140,11 +140,11 @@ WASM_EXEC_TEST(Int32Add_multi_if) { WASM_SEQ(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_SEQ(WASM_GET_LOCAL(1), WASM_GET_LOCAL(0))), kExprI32Add}; - RunInt32AddTest(execution_mode, code, sizeof(code)); + RunInt32AddTest(execution_tier, code, sizeof(code)); } WASM_EXEC_TEST(Float32Add) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // int(11.5f + 44.5f) BUILD(r, WASM_I32_SCONVERT_F32(WASM_F32_ADD(WASM_F32(11.5f), WASM_F32(44.5f)))); @@ -152,7 +152,7 @@ WASM_EXEC_TEST(Float32Add) { } WASM_EXEC_TEST(Float64Add) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return int(13.5d + 43.5d) BUILD(r, WASM_I32_SCONVERT_F64(WASM_F64_ADD(WASM_F64(13.5), WASM_F64(43.5)))); CHECK_EQ(57, r.Call()); @@ -161,18 +161,18 @@ WASM_EXEC_TEST(Float64Add) { // clang-format messes up the FOR_INT32_INPUTS macros. // clang-format off template<typename ctype> -static void TestInt32Binop(WasmExecutionMode execution_mode, WasmOpcode opcode, +static void TestInt32Binop(ExecutionTier execution_tier, WasmOpcode opcode, ctype(*expected)(ctype, ctype)) { FOR_INT32_INPUTS(i) { FOR_INT32_INPUTS(j) { - WasmRunner<ctype> r(execution_mode); + WasmRunner<ctype> r(execution_tier); // Apply {opcode} on two constants. BUILD(r, WASM_BINOP(opcode, WASM_I32V(*i), WASM_I32V(*j))); CHECK_EQ(expected(*i, *j), r.Call()); } } { - WasmRunner<ctype, ctype, ctype> r(execution_mode); + WasmRunner<ctype, ctype, ctype> r(execution_tier); // Apply {opcode} on two parameters. BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_INT32_INPUTS(i) { @@ -186,7 +186,7 @@ static void TestInt32Binop(WasmExecutionMode execution_mode, WasmOpcode opcode, #define WASM_I32_BINOP_TEST(expr, ctype, expected) \ WASM_EXEC_TEST(I32Binop_##expr) { \ - TestInt32Binop<ctype>(execution_mode, kExprI32##expr, \ + TestInt32Binop<ctype>(execution_tier, kExprI32##expr, \ [](ctype a, ctype b) -> ctype { return expected; }); \ } @@ -221,16 +221,16 @@ WASM_I32_BINOP_TEST(GeU, uint32_t, a >= b) #undef WASM_I32_BINOP_TEST -void TestInt32Unop(WasmExecutionMode execution_mode, WasmOpcode opcode, +void TestInt32Unop(ExecutionTier execution_tier, WasmOpcode opcode, int32_t expected, int32_t a) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return op K BUILD(r, WASM_UNOP(opcode, WASM_I32V(a))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // return op a BUILD(r, WASM_UNOP(opcode, WASM_GET_LOCAL(0))); CHECK_EQ(expected, r.Call(a)); @@ -238,96 +238,96 @@ void TestInt32Unop(WasmExecutionMode execution_mode, WasmOpcode opcode, } WASM_EXEC_TEST(Int32Clz) { - TestInt32Unop(execution_mode, kExprI32Clz, 0, 0x80001000); - TestInt32Unop(execution_mode, kExprI32Clz, 1, 0x40000500); - TestInt32Unop(execution_mode, kExprI32Clz, 2, 0x20000300); - TestInt32Unop(execution_mode, kExprI32Clz, 3, 0x10000003); - TestInt32Unop(execution_mode, kExprI32Clz, 4, 0x08050000); - TestInt32Unop(execution_mode, kExprI32Clz, 5, 0x04006000); - TestInt32Unop(execution_mode, kExprI32Clz, 6, 0x02000000); - TestInt32Unop(execution_mode, kExprI32Clz, 7, 0x010000A0); - TestInt32Unop(execution_mode, kExprI32Clz, 8, 0x00800C00); - TestInt32Unop(execution_mode, kExprI32Clz, 9, 0x00400000); - TestInt32Unop(execution_mode, kExprI32Clz, 10, 0x0020000D); - TestInt32Unop(execution_mode, kExprI32Clz, 11, 0x00100F00); - TestInt32Unop(execution_mode, kExprI32Clz, 12, 0x00080000); - TestInt32Unop(execution_mode, kExprI32Clz, 13, 0x00041000); - TestInt32Unop(execution_mode, kExprI32Clz, 14, 0x00020020); - TestInt32Unop(execution_mode, kExprI32Clz, 15, 0x00010300); - TestInt32Unop(execution_mode, kExprI32Clz, 16, 0x00008040); - TestInt32Unop(execution_mode, kExprI32Clz, 17, 0x00004005); - TestInt32Unop(execution_mode, kExprI32Clz, 18, 0x00002050); - TestInt32Unop(execution_mode, kExprI32Clz, 19, 0x00001700); - TestInt32Unop(execution_mode, kExprI32Clz, 20, 0x00000870); - TestInt32Unop(execution_mode, kExprI32Clz, 21, 0x00000405); - TestInt32Unop(execution_mode, kExprI32Clz, 22, 0x00000203); - TestInt32Unop(execution_mode, kExprI32Clz, 23, 0x00000101); - TestInt32Unop(execution_mode, kExprI32Clz, 24, 0x00000089); - TestInt32Unop(execution_mode, kExprI32Clz, 25, 0x00000041); - TestInt32Unop(execution_mode, kExprI32Clz, 26, 0x00000022); - TestInt32Unop(execution_mode, kExprI32Clz, 27, 0x00000013); - TestInt32Unop(execution_mode, kExprI32Clz, 28, 0x00000008); - TestInt32Unop(execution_mode, kExprI32Clz, 29, 0x00000004); - TestInt32Unop(execution_mode, kExprI32Clz, 30, 0x00000002); - TestInt32Unop(execution_mode, kExprI32Clz, 31, 0x00000001); - TestInt32Unop(execution_mode, kExprI32Clz, 32, 0x00000000); + TestInt32Unop(execution_tier, kExprI32Clz, 0, 0x80001000); + TestInt32Unop(execution_tier, kExprI32Clz, 1, 0x40000500); + TestInt32Unop(execution_tier, kExprI32Clz, 2, 0x20000300); + TestInt32Unop(execution_tier, kExprI32Clz, 3, 0x10000003); + TestInt32Unop(execution_tier, kExprI32Clz, 4, 0x08050000); + TestInt32Unop(execution_tier, kExprI32Clz, 5, 0x04006000); + TestInt32Unop(execution_tier, kExprI32Clz, 6, 0x02000000); + TestInt32Unop(execution_tier, kExprI32Clz, 7, 0x010000A0); + TestInt32Unop(execution_tier, kExprI32Clz, 8, 0x00800C00); + TestInt32Unop(execution_tier, kExprI32Clz, 9, 0x00400000); + TestInt32Unop(execution_tier, kExprI32Clz, 10, 0x0020000D); + TestInt32Unop(execution_tier, kExprI32Clz, 11, 0x00100F00); + TestInt32Unop(execution_tier, kExprI32Clz, 12, 0x00080000); + TestInt32Unop(execution_tier, kExprI32Clz, 13, 0x00041000); + TestInt32Unop(execution_tier, kExprI32Clz, 14, 0x00020020); + TestInt32Unop(execution_tier, kExprI32Clz, 15, 0x00010300); + TestInt32Unop(execution_tier, kExprI32Clz, 16, 0x00008040); + TestInt32Unop(execution_tier, kExprI32Clz, 17, 0x00004005); + TestInt32Unop(execution_tier, kExprI32Clz, 18, 0x00002050); + TestInt32Unop(execution_tier, kExprI32Clz, 19, 0x00001700); + TestInt32Unop(execution_tier, kExprI32Clz, 20, 0x00000870); + TestInt32Unop(execution_tier, kExprI32Clz, 21, 0x00000405); + TestInt32Unop(execution_tier, kExprI32Clz, 22, 0x00000203); + TestInt32Unop(execution_tier, kExprI32Clz, 23, 0x00000101); + TestInt32Unop(execution_tier, kExprI32Clz, 24, 0x00000089); + TestInt32Unop(execution_tier, kExprI32Clz, 25, 0x00000041); + TestInt32Unop(execution_tier, kExprI32Clz, 26, 0x00000022); + TestInt32Unop(execution_tier, kExprI32Clz, 27, 0x00000013); + TestInt32Unop(execution_tier, kExprI32Clz, 28, 0x00000008); + TestInt32Unop(execution_tier, kExprI32Clz, 29, 0x00000004); + TestInt32Unop(execution_tier, kExprI32Clz, 30, 0x00000002); + TestInt32Unop(execution_tier, kExprI32Clz, 31, 0x00000001); + TestInt32Unop(execution_tier, kExprI32Clz, 32, 0x00000000); } WASM_EXEC_TEST(Int32Ctz) { - TestInt32Unop(execution_mode, kExprI32Ctz, 32, 0x00000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 31, 0x80000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 30, 0x40000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 29, 0x20000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 28, 0x10000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 27, 0xA8000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 26, 0xF4000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 25, 0x62000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 24, 0x91000000); - TestInt32Unop(execution_mode, kExprI32Ctz, 23, 0xCD800000); - TestInt32Unop(execution_mode, kExprI32Ctz, 22, 0x09400000); - TestInt32Unop(execution_mode, kExprI32Ctz, 21, 0xAF200000); - TestInt32Unop(execution_mode, kExprI32Ctz, 20, 0xAC100000); - TestInt32Unop(execution_mode, kExprI32Ctz, 19, 0xE0B80000); - TestInt32Unop(execution_mode, kExprI32Ctz, 18, 0x9CE40000); - TestInt32Unop(execution_mode, kExprI32Ctz, 17, 0xC7920000); - TestInt32Unop(execution_mode, kExprI32Ctz, 16, 0xB8F10000); - TestInt32Unop(execution_mode, kExprI32Ctz, 15, 0x3B9F8000); - TestInt32Unop(execution_mode, kExprI32Ctz, 14, 0xDB4C4000); - TestInt32Unop(execution_mode, kExprI32Ctz, 13, 0xE9A32000); - TestInt32Unop(execution_mode, kExprI32Ctz, 12, 0xFCA61000); - TestInt32Unop(execution_mode, kExprI32Ctz, 11, 0x6C8A7800); - TestInt32Unop(execution_mode, kExprI32Ctz, 10, 0x8CE5A400); - TestInt32Unop(execution_mode, kExprI32Ctz, 9, 0xCB7D0200); - TestInt32Unop(execution_mode, kExprI32Ctz, 8, 0xCB4DC100); - TestInt32Unop(execution_mode, kExprI32Ctz, 7, 0xDFBEC580); - TestInt32Unop(execution_mode, kExprI32Ctz, 6, 0x27A9DB40); - TestInt32Unop(execution_mode, kExprI32Ctz, 5, 0xDE3BCB20); - TestInt32Unop(execution_mode, kExprI32Ctz, 4, 0xD7E8A610); - TestInt32Unop(execution_mode, kExprI32Ctz, 3, 0x9AFDBC88); - TestInt32Unop(execution_mode, kExprI32Ctz, 2, 0x9AFDBC84); - TestInt32Unop(execution_mode, kExprI32Ctz, 1, 0x9AFDBC82); - TestInt32Unop(execution_mode, kExprI32Ctz, 0, 0x9AFDBC81); + TestInt32Unop(execution_tier, kExprI32Ctz, 32, 0x00000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 31, 0x80000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 30, 0x40000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 29, 0x20000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 28, 0x10000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 27, 0xA8000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 26, 0xF4000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 25, 0x62000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 24, 0x91000000); + TestInt32Unop(execution_tier, kExprI32Ctz, 23, 0xCD800000); + TestInt32Unop(execution_tier, kExprI32Ctz, 22, 0x09400000); + TestInt32Unop(execution_tier, kExprI32Ctz, 21, 0xAF200000); + TestInt32Unop(execution_tier, kExprI32Ctz, 20, 0xAC100000); + TestInt32Unop(execution_tier, kExprI32Ctz, 19, 0xE0B80000); + TestInt32Unop(execution_tier, kExprI32Ctz, 18, 0x9CE40000); + TestInt32Unop(execution_tier, kExprI32Ctz, 17, 0xC7920000); + TestInt32Unop(execution_tier, kExprI32Ctz, 16, 0xB8F10000); + TestInt32Unop(execution_tier, kExprI32Ctz, 15, 0x3B9F8000); + TestInt32Unop(execution_tier, kExprI32Ctz, 14, 0xDB4C4000); + TestInt32Unop(execution_tier, kExprI32Ctz, 13, 0xE9A32000); + TestInt32Unop(execution_tier, kExprI32Ctz, 12, 0xFCA61000); + TestInt32Unop(execution_tier, kExprI32Ctz, 11, 0x6C8A7800); + TestInt32Unop(execution_tier, kExprI32Ctz, 10, 0x8CE5A400); + TestInt32Unop(execution_tier, kExprI32Ctz, 9, 0xCB7D0200); + TestInt32Unop(execution_tier, kExprI32Ctz, 8, 0xCB4DC100); + TestInt32Unop(execution_tier, kExprI32Ctz, 7, 0xDFBEC580); + TestInt32Unop(execution_tier, kExprI32Ctz, 6, 0x27A9DB40); + TestInt32Unop(execution_tier, kExprI32Ctz, 5, 0xDE3BCB20); + TestInt32Unop(execution_tier, kExprI32Ctz, 4, 0xD7E8A610); + TestInt32Unop(execution_tier, kExprI32Ctz, 3, 0x9AFDBC88); + TestInt32Unop(execution_tier, kExprI32Ctz, 2, 0x9AFDBC84); + TestInt32Unop(execution_tier, kExprI32Ctz, 1, 0x9AFDBC82); + TestInt32Unop(execution_tier, kExprI32Ctz, 0, 0x9AFDBC81); } WASM_EXEC_TEST(Int32Popcnt) { - TestInt32Unop(execution_mode, kExprI32Popcnt, 32, 0xFFFFFFFF); - TestInt32Unop(execution_mode, kExprI32Popcnt, 0, 0x00000000); - TestInt32Unop(execution_mode, kExprI32Popcnt, 1, 0x00008000); - TestInt32Unop(execution_mode, kExprI32Popcnt, 13, 0x12345678); - TestInt32Unop(execution_mode, kExprI32Popcnt, 19, 0xFEDCBA09); + TestInt32Unop(execution_tier, kExprI32Popcnt, 32, 0xFFFFFFFF); + TestInt32Unop(execution_tier, kExprI32Popcnt, 0, 0x00000000); + TestInt32Unop(execution_tier, kExprI32Popcnt, 1, 0x00008000); + TestInt32Unop(execution_tier, kExprI32Popcnt, 13, 0x12345678); + TestInt32Unop(execution_tier, kExprI32Popcnt, 19, 0xFEDCBA09); } WASM_EXEC_TEST(I32Eqz) { - TestInt32Unop(execution_mode, kExprI32Eqz, 0, 1); - TestInt32Unop(execution_mode, kExprI32Eqz, 0, -1); - TestInt32Unop(execution_mode, kExprI32Eqz, 0, -827343); - TestInt32Unop(execution_mode, kExprI32Eqz, 0, 8888888); - TestInt32Unop(execution_mode, kExprI32Eqz, 1, 0); + TestInt32Unop(execution_tier, kExprI32Eqz, 0, 1); + TestInt32Unop(execution_tier, kExprI32Eqz, 0, -1); + TestInt32Unop(execution_tier, kExprI32Eqz, 0, -827343); + TestInt32Unop(execution_tier, kExprI32Eqz, 0, 8888888); + TestInt32Unop(execution_tier, kExprI32Eqz, 1, 0); } WASM_EXEC_TEST(Int32DivS_trap) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); CHECK_EQ(0, r.Call(0, 100)); @@ -338,7 +338,7 @@ WASM_EXEC_TEST(Int32DivS_trap) { } WASM_EXEC_TEST(Int32RemS_trap) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); CHECK_EQ(33, r.Call(133, 100)); @@ -349,7 +349,7 @@ WASM_EXEC_TEST(Int32RemS_trap) { } WASM_EXEC_TEST(Int32DivU_trap) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); const int32_t kMin = std::numeric_limits<int32_t>::min(); CHECK_EQ(0, r.Call(0, 100)); @@ -360,7 +360,7 @@ WASM_EXEC_TEST(Int32DivU_trap) { } WASM_EXEC_TEST(Int32RemU_trap) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_REMU(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(17, r.Call(217, 100)); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -372,7 +372,7 @@ WASM_EXEC_TEST(Int32RemU_trap) { WASM_EXEC_TEST(Int32DivS_byzero_const) { for (int8_t denom = -2; denom < 8; ++denom) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); for (int32_t val = -7; val < 8; ++val) { if (denom == 0) { @@ -386,7 +386,7 @@ WASM_EXEC_TEST(Int32DivS_byzero_const) { WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) { for (int8_t denom = -2; denom < 8; ++denom) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_I32_ASMJS_DIVS(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); FOR_INT32_INPUTS(i) { @@ -403,7 +403,7 @@ WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) { WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) { for (int8_t denom = -2; denom < 8; ++denom) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.builder().ChangeOriginToAsmjs(); BUILD(r, WASM_I32_ASMJS_REMS(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); FOR_INT32_INPUTS(i) { @@ -420,7 +420,7 @@ WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) { WASM_EXEC_TEST(Int32DivU_byzero_const) { for (uint32_t denom = 0xFFFFFFFE; denom < 8; ++denom) { - WasmRunner<uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_I32_DIVU(WASM_GET_LOCAL(0), WASM_I32V_1(denom))); for (uint32_t val = 0xFFFFFFF0; val < 8; ++val) { @@ -434,7 +434,7 @@ WASM_EXEC_TEST(Int32DivU_byzero_const) { } WASM_EXEC_TEST(Int32DivS_trap_effect) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_IF_ELSE_I( @@ -455,34 +455,34 @@ WASM_EXEC_TEST(Int32DivS_trap_effect) { CHECK_TRAP(r.Call(0, 0)); } -void TestFloat32Binop(WasmExecutionMode execution_mode, WasmOpcode opcode, +void TestFloat32Binop(ExecutionTier execution_tier, WasmOpcode opcode, int32_t expected, float a, float b) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return K op K BUILD(r, WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, float, float> r(execution_mode); + WasmRunner<int32_t, float, float> r(execution_tier); // return a op b BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(expected, r.Call(a, b)); } } -void TestFloat32BinopWithConvert(WasmExecutionMode execution_mode, +void TestFloat32BinopWithConvert(ExecutionTier execution_tier, WasmOpcode opcode, int32_t expected, float a, float b) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return int(K op K) BUILD(r, WASM_I32_SCONVERT_F32(WASM_BINOP(opcode, WASM_F32(a), WASM_F32(b)))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, float, float> r(execution_mode); + WasmRunner<int32_t, float, float> r(execution_tier); // return int(a op b) BUILD(r, WASM_I32_SCONVERT_F32( WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); @@ -490,66 +490,66 @@ void TestFloat32BinopWithConvert(WasmExecutionMode execution_mode, } } -void TestFloat32UnopWithConvert(WasmExecutionMode execution_mode, - WasmOpcode opcode, int32_t expected, float a) { +void TestFloat32UnopWithConvert(ExecutionTier execution_tier, WasmOpcode opcode, + int32_t expected, float a) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return int(op(K)) BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_F32(a)))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, float> r(execution_mode); + WasmRunner<int32_t, float> r(execution_tier); // return int(op(a)) BUILD(r, WASM_I32_SCONVERT_F32(WASM_UNOP(opcode, WASM_GET_LOCAL(0)))); CHECK_EQ(expected, r.Call(a)); } } -void TestFloat64Binop(WasmExecutionMode execution_mode, WasmOpcode opcode, +void TestFloat64Binop(ExecutionTier execution_tier, WasmOpcode opcode, int32_t expected, double a, double b) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return K op K BUILD(r, WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, double, double> r(execution_mode); + WasmRunner<int32_t, double, double> r(execution_tier); // return a op b BUILD(r, WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); CHECK_EQ(expected, r.Call(a, b)); } } -void TestFloat64BinopWithConvert(WasmExecutionMode execution_mode, +void TestFloat64BinopWithConvert(ExecutionTier execution_tier, WasmOpcode opcode, int32_t expected, double a, double b) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return int(K op K) BUILD(r, WASM_I32_SCONVERT_F64(WASM_BINOP(opcode, WASM_F64(a), WASM_F64(b)))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, double, double> r(execution_mode); + WasmRunner<int32_t, double, double> r(execution_tier); BUILD(r, WASM_I32_SCONVERT_F64( WASM_BINOP(opcode, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); CHECK_EQ(expected, r.Call(a, b)); } } -void TestFloat64UnopWithConvert(WasmExecutionMode execution_mode, - WasmOpcode opcode, int32_t expected, double a) { +void TestFloat64UnopWithConvert(ExecutionTier execution_tier, WasmOpcode opcode, + int32_t expected, double a) { { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // return int(op(K)) BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a)))); CHECK_EQ(expected, r.Call()); } { - WasmRunner<int32_t, double> r(execution_mode); + WasmRunner<int32_t, double> r(execution_tier); // return int(op(a)) BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_GET_LOCAL(0)))); CHECK_EQ(expected, r.Call(a)); @@ -557,50 +557,50 @@ void TestFloat64UnopWithConvert(WasmExecutionMode execution_mode, } WASM_EXEC_TEST(Float32Binops) { - TestFloat32Binop(execution_mode, kExprF32Eq, 1, 8.125f, 8.125f); - TestFloat32Binop(execution_mode, kExprF32Ne, 1, 8.125f, 8.127f); - TestFloat32Binop(execution_mode, kExprF32Lt, 1, -9.5f, -9.0f); - TestFloat32Binop(execution_mode, kExprF32Le, 1, -1111.0f, -1111.0f); - TestFloat32Binop(execution_mode, kExprF32Gt, 1, -9.0f, -9.5f); - TestFloat32Binop(execution_mode, kExprF32Ge, 1, -1111.0f, -1111.0f); + TestFloat32Binop(execution_tier, kExprF32Eq, 1, 8.125f, 8.125f); + TestFloat32Binop(execution_tier, kExprF32Ne, 1, 8.125f, 8.127f); + TestFloat32Binop(execution_tier, kExprF32Lt, 1, -9.5f, -9.0f); + TestFloat32Binop(execution_tier, kExprF32Le, 1, -1111.0f, -1111.0f); + TestFloat32Binop(execution_tier, kExprF32Gt, 1, -9.0f, -9.5f); + TestFloat32Binop(execution_tier, kExprF32Ge, 1, -1111.0f, -1111.0f); - TestFloat32BinopWithConvert(execution_mode, kExprF32Add, 10, 3.5f, 6.5f); - TestFloat32BinopWithConvert(execution_mode, kExprF32Sub, 2, 44.5f, 42.5f); - TestFloat32BinopWithConvert(execution_mode, kExprF32Mul, -66, -132.1f, 0.5f); - TestFloat32BinopWithConvert(execution_mode, kExprF32Div, 11, 22.1f, 2.0f); + TestFloat32BinopWithConvert(execution_tier, kExprF32Add, 10, 3.5f, 6.5f); + TestFloat32BinopWithConvert(execution_tier, kExprF32Sub, 2, 44.5f, 42.5f); + TestFloat32BinopWithConvert(execution_tier, kExprF32Mul, -66, -132.1f, 0.5f); + TestFloat32BinopWithConvert(execution_tier, kExprF32Div, 11, 22.1f, 2.0f); } WASM_EXEC_TEST(Float32Unops) { - TestFloat32UnopWithConvert(execution_mode, kExprF32Abs, 8, 8.125f); - TestFloat32UnopWithConvert(execution_mode, kExprF32Abs, 9, -9.125f); - TestFloat32UnopWithConvert(execution_mode, kExprF32Neg, -213, 213.125f); - TestFloat32UnopWithConvert(execution_mode, kExprF32Sqrt, 12, 144.4f); + TestFloat32UnopWithConvert(execution_tier, kExprF32Abs, 8, 8.125f); + TestFloat32UnopWithConvert(execution_tier, kExprF32Abs, 9, -9.125f); + TestFloat32UnopWithConvert(execution_tier, kExprF32Neg, -213, 213.125f); + TestFloat32UnopWithConvert(execution_tier, kExprF32Sqrt, 12, 144.4f); } WASM_EXEC_TEST(Float64Binops) { - TestFloat64Binop(execution_mode, kExprF64Eq, 1, 16.25, 16.25); - TestFloat64Binop(execution_mode, kExprF64Ne, 1, 16.25, 16.15); - TestFloat64Binop(execution_mode, kExprF64Lt, 1, -32.4, 11.7); - TestFloat64Binop(execution_mode, kExprF64Le, 1, -88.9, -88.9); - TestFloat64Binop(execution_mode, kExprF64Gt, 1, 11.7, -32.4); - TestFloat64Binop(execution_mode, kExprF64Ge, 1, -88.9, -88.9); - - TestFloat64BinopWithConvert(execution_mode, kExprF64Add, 100, 43.5, 56.5); - TestFloat64BinopWithConvert(execution_mode, kExprF64Sub, 200, 12200.1, + TestFloat64Binop(execution_tier, kExprF64Eq, 1, 16.25, 16.25); + TestFloat64Binop(execution_tier, kExprF64Ne, 1, 16.25, 16.15); + TestFloat64Binop(execution_tier, kExprF64Lt, 1, -32.4, 11.7); + TestFloat64Binop(execution_tier, kExprF64Le, 1, -88.9, -88.9); + TestFloat64Binop(execution_tier, kExprF64Gt, 1, 11.7, -32.4); + TestFloat64Binop(execution_tier, kExprF64Ge, 1, -88.9, -88.9); + + TestFloat64BinopWithConvert(execution_tier, kExprF64Add, 100, 43.5, 56.5); + TestFloat64BinopWithConvert(execution_tier, kExprF64Sub, 200, 12200.1, 12000.1); - TestFloat64BinopWithConvert(execution_mode, kExprF64Mul, -33, 134, -0.25); - TestFloat64BinopWithConvert(execution_mode, kExprF64Div, -1111, -2222.3, 2); + TestFloat64BinopWithConvert(execution_tier, kExprF64Mul, -33, 134, -0.25); + TestFloat64BinopWithConvert(execution_tier, kExprF64Div, -1111, -2222.3, 2); } WASM_EXEC_TEST(Float64Unops) { - TestFloat64UnopWithConvert(execution_mode, kExprF64Abs, 108, 108.125); - TestFloat64UnopWithConvert(execution_mode, kExprF64Abs, 209, -209.125); - TestFloat64UnopWithConvert(execution_mode, kExprF64Neg, -209, 209.125); - TestFloat64UnopWithConvert(execution_mode, kExprF64Sqrt, 13, 169.4); + TestFloat64UnopWithConvert(execution_tier, kExprF64Abs, 108, 108.125); + TestFloat64UnopWithConvert(execution_tier, kExprF64Abs, 209, -209.125); + TestFloat64UnopWithConvert(execution_tier, kExprF64Neg, -209, 209.125); + TestFloat64UnopWithConvert(execution_tier, kExprF64Sqrt, 13, 169.4); } WASM_EXEC_TEST(Float32Neg) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_F32_NEG(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { @@ -610,7 +610,7 @@ WASM_EXEC_TEST(Float32Neg) { } WASM_EXEC_TEST(Float64Neg) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_F64_NEG(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { @@ -620,7 +620,7 @@ WASM_EXEC_TEST(Float64Neg) { } WASM_EXEC_TEST(IfElse_P) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // if (p0) return 11; else return 22; BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // -- WASM_I32V_1(11), // -- @@ -632,34 +632,34 @@ WASM_EXEC_TEST(IfElse_P) { } WASM_EXEC_TEST(If_empty1) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprEnd, WASM_GET_LOCAL(1)); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 9, *i)); } } WASM_EXEC_TEST(IfElse_empty1) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, kExprEnd, WASM_GET_LOCAL(1)); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 8, *i)); } } WASM_EXEC_TEST(IfElse_empty2) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, WASM_NOP, kExprElse, kExprEnd, WASM_GET_LOCAL(1)); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 7, *i)); } } WASM_EXEC_TEST(IfElse_empty3) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_GET_LOCAL(0), kExprIf, kLocalVoid, kExprElse, WASM_NOP, kExprEnd, WASM_GET_LOCAL(1)); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i - 6, *i)); } } WASM_EXEC_TEST(If_chain1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // if (p0) 13; if (p0) 14; 15 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), WASM_IF(WASM_GET_LOCAL(0), WASM_NOP), WASM_I32V_1(15)); @@ -667,7 +667,7 @@ WASM_EXEC_TEST(If_chain1) { } WASM_EXEC_TEST(If_chain_set) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); // if (p0) p1 = 73; if (p0) p1 = 74; p1 BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(1, WASM_I32V_2(73))), WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(1, WASM_I32V_2(74))), @@ -679,7 +679,7 @@ WASM_EXEC_TEST(If_chain_set) { } WASM_EXEC_TEST(IfElse_Unreachable1) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // 0 ? unreachable : 27 BUILD(r, WASM_IF_ELSE_I(WASM_ZERO, // -- WASM_UNREACHABLE, // -- @@ -688,7 +688,7 @@ WASM_EXEC_TEST(IfElse_Unreachable1) { } WASM_EXEC_TEST(IfElse_Unreachable2) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // 1 ? 28 : unreachable BUILD(r, WASM_IF_ELSE_I(WASM_I32V_1(1), // -- WASM_I32V_1(28), // -- @@ -697,21 +697,21 @@ WASM_EXEC_TEST(IfElse_Unreachable2) { } WASM_EXEC_TEST(Return12) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, RET_I8(12)); CHECK_EQ(12, r.Call()); } WASM_EXEC_TEST(Return17) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK(RET_I8(17)), WASM_ZERO); CHECK_EQ(17, r.Call()); } WASM_EXEC_TEST(Return_I32) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, RET(WASM_GET_LOCAL(0))); @@ -719,7 +719,7 @@ WASM_EXEC_TEST(Return_I32) { } WASM_EXEC_TEST(Return_F32) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, RET(WASM_GET_LOCAL(0))); @@ -735,7 +735,7 @@ WASM_EXEC_TEST(Return_F32) { } WASM_EXEC_TEST(Return_F64) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, RET(WASM_GET_LOCAL(0))); @@ -751,7 +751,7 @@ WASM_EXEC_TEST(Return_F64) { } WASM_EXEC_TEST(Select_float_parameters) { - WasmRunner<float, float, float, int32_t> r(execution_mode); + WasmRunner<float, float, float, int32_t> r(execution_tier); // return select(11, 22, a); BUILD(r, WASM_SELECT(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1), WASM_GET_LOCAL(2))); @@ -759,7 +759,7 @@ WASM_EXEC_TEST(Select_float_parameters) { } WASM_EXEC_TEST(Select) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // return select(11, 22, a); BUILD(r, WASM_SELECT(WASM_I32V_1(11), WASM_I32V_1(22), WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { @@ -769,7 +769,7 @@ WASM_EXEC_TEST(Select) { } WASM_EXEC_TEST(Select_strict1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // select(a=0, a=1, a=2); return a BUILD(r, WASM_SELECT(WASM_TEE_LOCAL(0, WASM_ZERO), WASM_TEE_LOCAL(0, WASM_I32V_1(1)), @@ -779,7 +779,7 @@ WASM_EXEC_TEST(Select_strict1) { } WASM_EXEC_TEST(Select_strict2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32); // select(b=5, c=6, a) @@ -792,7 +792,7 @@ WASM_EXEC_TEST(Select_strict2) { } WASM_EXEC_TEST(Select_strict3) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.AllocateLocal(kWasmI32); r.AllocateLocal(kWasmI32); // select(b=5, c=6, a=b) @@ -806,7 +806,7 @@ WASM_EXEC_TEST(Select_strict3) { } WASM_EXEC_TEST(BrIf_strict) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_TEE_LOCAL(0, WASM_I32V_2(99))))); @@ -814,7 +814,7 @@ WASM_EXEC_TEST(BrIf_strict) { } WASM_EXEC_TEST(Br_height) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( WASM_BLOCK(WASM_BRV_IFD(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0)), WASM_RETURN1(WASM_I32V_1(9))), @@ -827,7 +827,7 @@ WASM_EXEC_TEST(Br_height) { } WASM_EXEC_TEST(Regression_660262) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, kExprI32Const, 0x00, kExprI32Const, 0x00, kExprI32LoadMem, 0x00, 0x0F, kExprBrTable, 0x00, 0x80, 0x00); // entries=0 @@ -835,14 +835,14 @@ WASM_EXEC_TEST(Regression_660262) { } WASM_EXEC_TEST(BrTable0a) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0)))), WASM_I32V_2(91)); FOR_INT32_INPUTS(i) { CHECK_EQ(91, r.Call(*i)); } } WASM_EXEC_TEST(BrTable0b) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(0)))), WASM_I32V_2(92)); @@ -850,7 +850,7 @@ WASM_EXEC_TEST(BrTable0b) { } WASM_EXEC_TEST(BrTable0c) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD( r, B1(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(0), BR_TARGET(1))), @@ -863,13 +863,13 @@ WASM_EXEC_TEST(BrTable0c) { } WASM_EXEC_TEST(BrTable1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 0, BR_TARGET(0))), RET_I8(93)); FOR_INT32_INPUTS(i) { CHECK_EQ(93, r.Call(*i)); } } WASM_EXEC_TEST(BrTable_loop) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B2(B1(WASM_LOOP(WASM_BR_TABLE(WASM_INC_LOCAL_BYV(0, 1), 2, BR_TARGET(2), BR_TARGET(1), BR_TARGET(0)))), @@ -883,7 +883,7 @@ WASM_EXEC_TEST(BrTable_loop) { } WASM_EXEC_TEST(BrTable_br) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 1, BR_TARGET(1), BR_TARGET(0))), RET_I8(91)), @@ -895,7 +895,7 @@ WASM_EXEC_TEST(BrTable_br) { } WASM_EXEC_TEST(BrTable_br2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B2(B2(B2(B1(WASM_BR_TABLE(WASM_GET_LOCAL(0), 3, BR_TARGET(1), BR_TARGET(2), BR_TARGET(3), BR_TARGET(0))), @@ -926,7 +926,7 @@ WASM_EXEC_TEST(BrTable4) { RET_I8(73)), WASM_I32V_2(75)}; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.Build(code, code + arraysize(code)); for (int x = -3; x < 50; ++x) { @@ -956,7 +956,7 @@ WASM_EXEC_TEST(BrTable4x4) { RET_I8(53)), WASM_I32V_2(55)}; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.Build(code, code + arraysize(code)); for (int x = -6; x < 47; ++x) { @@ -981,7 +981,7 @@ WASM_EXEC_TEST(BrTable4_fallthru) { WASM_INC_LOCAL_BY(1, 8)), WASM_GET_LOCAL(1)}; - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); r.Build(code, code + arraysize(code)); CHECK_EQ(15, r.Call(0, 0)); @@ -1005,14 +1005,14 @@ WASM_EXEC_TEST(BrTable_loop_target) { BR_TARGET(0), BR_TARGET(1), BR_TARGET(1))), WASM_ONE)}; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.Build(code, code + arraysize(code)); CHECK_EQ(1, r.Call(0)); } WASM_EXEC_TEST(F32ReinterpretI32) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); @@ -1027,7 +1027,7 @@ WASM_EXEC_TEST(F32ReinterpretI32) { } WASM_EXEC_TEST(I32ReinterpretF32) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); @@ -1046,7 +1046,7 @@ WASM_EXEC_TEST(I32ReinterpretF32) { #ifndef USE_SIMULATOR WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_I32_REINTERPRET_F32( WASM_SEQ(kExprF32Const, 0x00, 0x00, 0xA0, 0x7F))); @@ -1058,7 +1058,7 @@ WASM_EXEC_TEST(SignallingNanSurvivesI32ReinterpretF32) { #endif WASM_EXEC_TEST(LoadMaxUint32Offset) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_OFFSET(MachineType::Int32(), // type @@ -1069,7 +1069,7 @@ WASM_EXEC_TEST(LoadMaxUint32Offset) { } WASM_EXEC_TEST(LoadStoreLoad) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); @@ -1085,28 +1085,28 @@ WASM_EXEC_TEST(LoadStoreLoad) { } WASM_EXEC_TEST(UnalignedFloat32Load) { - WasmRunner<float> r(execution_mode); + WasmRunner<float> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE, 2)); r.Call(); } WASM_EXEC_TEST(UnalignedFloat64Load) { - WasmRunner<double> r(execution_mode); + WasmRunner<double> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE, 3)); r.Call(); } WASM_EXEC_TEST(UnalignedInt32Load) { - WasmRunner<uint32_t> r(execution_mode); + WasmRunner<uint32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_LOAD_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2)); r.Call(); } WASM_EXEC_TEST(UnalignedInt32Store) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ONE, 2, WASM_I32V_1(1)), @@ -1115,7 +1115,7 @@ WASM_EXEC_TEST(UnalignedInt32Store) { } WASM_EXEC_TEST(UnalignedFloat32Store) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float32(), WASM_ONE, 2, WASM_F32(1.0)), @@ -1124,7 +1124,7 @@ WASM_EXEC_TEST(UnalignedFloat32Store) { } WASM_EXEC_TEST(UnalignedFloat64Store) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_SEQ(WASM_STORE_MEM_ALIGNMENT(MachineType::Float64(), WASM_ONE, 3, WASM_F64(1.0)), @@ -1134,7 +1134,7 @@ WASM_EXEC_TEST(UnalignedFloat64Store) { WASM_EXEC_TEST(VoidReturn1) { const int32_t kExpected = -414444; - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // Build the test function. WasmFunctionCompiler& test_func = r.NewFunction<void>(); @@ -1151,7 +1151,7 @@ WASM_EXEC_TEST(VoidReturn1) { WASM_EXEC_TEST(VoidReturn2) { const int32_t kExpected = -414444; - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // Build the test function. WasmFunctionCompiler& test_func = r.NewFunction<void>(); @@ -1167,67 +1167,67 @@ WASM_EXEC_TEST(VoidReturn2) { } WASM_EXEC_TEST(BrEmpty) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BRV(0, WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(BrIfEmpty) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BRV_IF(0, WASM_GET_LOCAL(0), WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_empty) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, kExprBlock, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_empty_br1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(WASM_BR(0)), WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_empty_brif1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_ZERO)), WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_empty_brif2) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_BLOCK(WASM_BR_IF(0, WASM_GET_LOCAL(1))), WASM_GET_LOCAL(0)); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } } WASM_EXEC_TEST(Block_i) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_f) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_BLOCK_F(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_d) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_BLOCK_D(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Block_br2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)))); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, static_cast<uint32_t>(r.Call(*i))); } } WASM_EXEC_TEST(Block_If_P) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // block { if (p0) break 51; 52; } BUILD(r, WASM_BLOCK_I( // -- WASM_IF(WASM_GET_LOCAL(0), // -- @@ -1240,49 +1240,49 @@ WASM_EXEC_TEST(Block_If_P) { } WASM_EXEC_TEST(Loop_empty) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, kExprLoop, kLocalVoid, kExprEnd, WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_i) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_LOOP_I(WASM_GET_LOCAL(0))); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_f) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_LOOP_F(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_d) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_LOOP_D(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_FLOAT_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_empty_br1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(WASM_LOOP(WASM_BR(1))), WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_empty_brif1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(WASM_LOOP(WASM_BR_IF(1, WASM_ZERO))), WASM_GET_LOCAL(0)); FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } } WASM_EXEC_TEST(Loop_empty_brif2) { - WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_LOOP_I(WASM_BRV_IF(1, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)))); FOR_UINT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i, *i + 1)); } } WASM_EXEC_TEST(Loop_empty_brif3) { - WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_mode); + WasmRunner<uint32_t, uint32_t, uint32_t, uint32_t> r(execution_tier); BUILD(r, WASM_LOOP(WASM_BRV_IFD(1, WASM_GET_LOCAL(2), WASM_GET_LOCAL(0))), WASM_GET_LOCAL(1)); FOR_UINT32_INPUTS(i) { @@ -1294,7 +1294,7 @@ WASM_EXEC_TEST(Loop_empty_brif3) { } WASM_EXEC_TEST(Block_BrIf_P) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I32V_1(51), WASM_GET_LOCAL(0)), WASM_I32V_1(52))); FOR_INT32_INPUTS(i) { @@ -1304,7 +1304,7 @@ WASM_EXEC_TEST(Block_BrIf_P) { } WASM_EXEC_TEST(Block_IfElse_P_assign) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // { if (p0) p0 = 71; else p0 = 72; return p0; } BUILD(r, // -- WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- @@ -1318,7 +1318,7 @@ WASM_EXEC_TEST(Block_IfElse_P_assign) { } WASM_EXEC_TEST(Block_IfElse_P_return) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // if (p0) return 81; else return 82; BUILD(r, // -- WASM_IF_ELSE(WASM_GET_LOCAL(0), // -- @@ -1332,7 +1332,7 @@ WASM_EXEC_TEST(Block_IfElse_P_return) { } WASM_EXEC_TEST(Block_If_P_assign) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // { if (p0) p0 = 61; p0; } BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32V_1(61))), WASM_GET_LOCAL(0)); @@ -1343,14 +1343,14 @@ WASM_EXEC_TEST(Block_If_P_assign) { } WASM_EXEC_TEST(DanglingAssign) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // { return 0; p0 = 0; } BUILD(r, WASM_BLOCK_I(RET_I8(99), WASM_TEE_LOCAL(0, WASM_ZERO))); CHECK_EQ(99, r.Call(1)); } WASM_EXEC_TEST(ExprIf_P) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // p0 ? 11 : 22; BUILD(r, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), // -- WASM_I32V_1(11), // -- @@ -1362,7 +1362,7 @@ WASM_EXEC_TEST(ExprIf_P) { } WASM_EXEC_TEST(CountDown) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_LOOP(WASM_IFB(WASM_GET_LOCAL(0), WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V_1(1))), @@ -1374,7 +1374,7 @@ WASM_EXEC_TEST(CountDown) { } WASM_EXEC_TEST(CountDown_fallthru) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD( r, WASM_LOOP( @@ -1388,7 +1388,7 @@ WASM_EXEC_TEST(CountDown_fallthru) { } WASM_EXEC_TEST(WhileCountDown) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_WHILE(WASM_GET_LOCAL(0), WASM_SET_LOCAL( 0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_I32V_1(1)))), @@ -1399,7 +1399,7 @@ WASM_EXEC_TEST(WhileCountDown) { } WASM_EXEC_TEST(Loop_if_break1) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(2, WASM_GET_LOCAL(1))), WASM_SET_LOCAL(0, WASM_I32V_2(99))), WASM_GET_LOCAL(0)); @@ -1410,7 +1410,7 @@ WASM_EXEC_TEST(Loop_if_break1) { } WASM_EXEC_TEST(Loop_if_break2) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_LOOP(WASM_BRV_IF(1, WASM_GET_LOCAL(1), WASM_GET_LOCAL(0)), WASM_DROP, WASM_SET_LOCAL(0, WASM_I32V_2(99))), WASM_GET_LOCAL(0)); @@ -1421,7 +1421,7 @@ WASM_EXEC_TEST(Loop_if_break2) { } WASM_EXEC_TEST(Loop_if_break_fallthru) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2)), WASM_SET_LOCAL(0, WASM_I32V_2(93)))), WASM_GET_LOCAL(0)); @@ -1432,7 +1432,7 @@ WASM_EXEC_TEST(Loop_if_break_fallthru) { } WASM_EXEC_TEST(Loop_if_break_fallthru2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, B1(B1(WASM_LOOP(WASM_IF(WASM_GET_LOCAL(0), WASM_BR(2)), WASM_SET_LOCAL(0, WASM_I32V_2(93))))), WASM_GET_LOCAL(0)); @@ -1443,7 +1443,7 @@ WASM_EXEC_TEST(Loop_if_break_fallthru2) { } WASM_EXEC_TEST(IfBreak1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_BR(0), WASM_UNREACHABLE)), WASM_I32V_2(91)); CHECK_EQ(91, r.Call(0)); @@ -1452,7 +1452,7 @@ WASM_EXEC_TEST(IfBreak1) { } WASM_EXEC_TEST(IfBreak2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_BR(0), RET_I8(77))), WASM_I32V_2(81)); CHECK_EQ(81, r.Call(0)); @@ -1461,7 +1461,7 @@ WASM_EXEC_TEST(IfBreak2) { } WASM_EXEC_TEST(LoadMemI32) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().RandomizeMemory(1111); @@ -1480,7 +1480,7 @@ WASM_EXEC_TEST(LoadMemI32) { WASM_EXEC_TEST(LoadMemI32_alignment) { for (byte alignment = 0; alignment <= 2; ++alignment) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().RandomizeMemory(1111); @@ -1500,7 +1500,7 @@ WASM_EXEC_TEST(LoadMemI32_alignment) { } WASM_EXEC_TEST(LoadMemI32_oob) { - WasmRunner<int32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().RandomizeMemory(1111); @@ -1529,7 +1529,7 @@ WASM_EXEC_TEST(LoadMem_offset_oob) { constexpr size_t num_bytes = kWasmPageSize; for (size_t m = 0; m < arraysize(machineTypes); ++m) { - WasmRunner<int32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t> r(execution_tier); r.builder().AddMemoryElems<byte>(num_bytes); r.builder().RandomizeMemory(1116 + static_cast<int>(m)); @@ -1549,7 +1549,7 @@ WASM_EXEC_TEST(LoadMem_offset_oob) { } WASM_EXEC_TEST(LoadMemI32_offset) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().RandomizeMemory(1111); @@ -1581,7 +1581,7 @@ WASM_EXEC_TEST(LoadMemI32_const_oob_misaligned) { for (byte offset = 0; offset < kRunwayLength + 5; ++offset) { for (uint32_t index = kWasmPageSize - kRunwayLength; index < kWasmPageSize + 5; ++index) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemoryElems<byte>(kWasmPageSize); r.builder().RandomizeMemory(); @@ -1604,7 +1604,7 @@ WASM_EXEC_TEST(LoadMemI32_const_oob) { for (byte offset = 0; offset < kRunwayLength + 5; offset += 4) { for (uint32_t index = kWasmPageSize - kRunwayLength; index < kWasmPageSize + 5; index += 4) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemoryElems<byte>(kWasmPageSize); r.builder().RandomizeMemory(); @@ -1624,7 +1624,7 @@ WASM_EXEC_TEST(StoreMemI32_alignment) { const int32_t kWritten = 0x12345678; for (byte i = 0; i <= 2; ++i) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); BUILD(r, WASM_STORE_MEM_ALIGNMENT(MachineType::Int32(), WASM_ZERO, i, @@ -1639,7 +1639,7 @@ WASM_EXEC_TEST(StoreMemI32_alignment) { } WASM_EXEC_TEST(StoreMemI32_offset) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); const int32_t kWritten = 0xAABBCCDD; @@ -1672,7 +1672,7 @@ WASM_EXEC_TEST(StoreMem_offset_oob) { constexpr size_t num_bytes = kWasmPageSize; for (size_t m = 0; m < arraysize(machineTypes); ++m) { - WasmRunner<int32_t, uint32_t> r(execution_mode); + WasmRunner<int32_t, uint32_t> r(execution_tier); byte* memory = r.builder().AddMemoryElems<byte>(num_bytes); r.builder().RandomizeMemory(1119 + static_cast<int>(m)); @@ -1700,7 +1700,7 @@ WASM_EXEC_TEST(Store_i32_narrowed) { stored_size_in_bytes = std::max(1, stored_size_in_bytes * 2); constexpr int kBytes = 24; uint8_t expected_memory[kBytes] = {0}; - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); uint8_t* memory = r.builder().AddMemoryElems<uint8_t>(kWasmPageSize); constexpr uint32_t kPattern = 0x12345678; @@ -1724,7 +1724,7 @@ WASM_EXEC_TEST(Store_i32_narrowed) { WASM_EXEC_TEST(LoadMemI32_P) { const int kNumElems = 8; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* memory = r.builder().AddMemoryElems<int32_t>(kWasmPageSize / sizeof(int32_t)); r.builder().RandomizeMemory(2222); @@ -1738,7 +1738,7 @@ WASM_EXEC_TEST(LoadMemI32_P) { WASM_EXEC_TEST(MemI32_Sum) { const int kNumElems = 20; - WasmRunner<uint32_t, int32_t> r(execution_mode); + WasmRunner<uint32_t, int32_t> r(execution_tier); uint32_t* memory = r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(int32_t)); const byte kSum = r.AllocateLocal(kWasmI32); @@ -1768,7 +1768,7 @@ WASM_EXEC_TEST(MemI32_Sum) { WASM_EXEC_TEST(CheckMachIntsZero) { const int kNumElems = 55; - WasmRunner<uint32_t, int32_t> r(execution_mode); + WasmRunner<uint32_t, int32_t> r(execution_tier); r.builder().AddMemoryElems<uint32_t>(kWasmPageSize / sizeof(uint32_t)); BUILD(r, // -- @@ -1796,7 +1796,7 @@ WASM_EXEC_TEST(CheckMachIntsZero) { WASM_EXEC_TEST(MemF32_Sum) { const int kSize = 5; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.builder().AddMemoryElems<float>(kWasmPageSize / sizeof(float)); float* buffer = r.builder().raw_mem_start<float>(); r.builder().WriteMemory(&buffer[0], -99.25f); @@ -1824,10 +1824,9 @@ WASM_EXEC_TEST(MemF32_Sum) { } template <typename T> -T GenerateAndRunFold(WasmExecutionMode execution_mode, WasmOpcode binop, - T* buffer, uint32_t size, ValueType astType, - MachineType memType) { - WasmRunner<int32_t, int32_t> r(execution_mode); +T GenerateAndRunFold(ExecutionTier execution_tier, WasmOpcode binop, T* buffer, + uint32_t size, ValueType astType, MachineType memType) { + WasmRunner<int32_t, int32_t> r(execution_tier); T* memory = r.builder().AddMemoryElems<T>(static_cast<uint32_t>( RoundUp(size * sizeof(T), kWasmPageSize) / sizeof(sizeof(T)))); for (uint32_t i = 0; i < size; ++i) { @@ -1855,19 +1854,19 @@ WASM_EXEC_TEST(MemF64_Mul) { const size_t kSize = 6; double buffer[kSize] = {1, 2, 2, 2, 2, 2}; double result = - GenerateAndRunFold<double>(execution_mode, kExprF64Mul, buffer, kSize, + GenerateAndRunFold<double>(execution_tier, kExprF64Mul, buffer, kSize, kWasmF64, MachineType::Float64()); CHECK_EQ(32, result); } WASM_EXEC_TEST(Build_Wasm_Infinite_Loop) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // Only build the graph and compile, don't run. BUILD(r, WASM_INFINITE_LOOP, WASM_ZERO); } WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); // Only build the graph and compile, don't run. @@ -1876,49 +1875,49 @@ WASM_EXEC_TEST(Build_Wasm_Infinite_Loop_effect) { } WASM_EXEC_TEST(Unreachable0a) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_I32V_1(9)), RET(WASM_GET_LOCAL(0)))); CHECK_EQ(9, r.Call(0)); CHECK_EQ(9, r.Call(1)); } WASM_EXEC_TEST(Unreachable0b) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_I32V_1(7)), WASM_UNREACHABLE)); CHECK_EQ(7, r.Call(0)); CHECK_EQ(7, r.Call(1)); } WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_UNREACHABLE); } WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE); } WASM_COMPILED_EXEC_TEST(Build_Wasm_Unreachable3) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_UNREACHABLE, WASM_UNREACHABLE, WASM_UNREACHABLE); } WASM_COMPILED_EXEC_TEST(Build_Wasm_UnreachableIf1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_UNREACHABLE, WASM_IF(WASM_GET_LOCAL(0), WASM_SEQ(WASM_GET_LOCAL(0), WASM_DROP)), WASM_ZERO); } WASM_COMPILED_EXEC_TEST(Build_Wasm_UnreachableIf2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_UNREACHABLE, WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_GET_LOCAL(0), WASM_UNREACHABLE)); } WASM_EXEC_TEST(Unreachable_Load) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); BUILD(r, WASM_BLOCK_I(WASM_BRV(0, WASM_GET_LOCAL(0)), WASM_LOAD_MEM(MachineType::Int8(), WASM_GET_LOCAL(0)))); @@ -1927,21 +1926,21 @@ WASM_EXEC_TEST(Unreachable_Load) { } WASM_EXEC_TEST(BrV_Fallthrough) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BLOCK(WASM_BRV(1, WASM_I32V_1(42))), WASM_I32V_1(22))); CHECK_EQ(42, r.Call()); } WASM_EXEC_TEST(Infinite_Loop_not_taken1) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_IF(WASM_GET_LOCAL(0), WASM_INFINITE_LOOP), WASM_I32V_1(45)); // Run the code, but don't go into the infinite loop. CHECK_EQ(45, r.Call(0)); } WASM_EXEC_TEST(Infinite_Loop_not_taken2) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( WASM_IF_ELSE(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I32V_1(45)), WASM_INFINITE_LOOP), @@ -1951,7 +1950,7 @@ WASM_EXEC_TEST(Infinite_Loop_not_taken2) { } WASM_EXEC_TEST(Infinite_Loop_not_taken2_brif) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV_IF(0, WASM_I32V_1(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP)); // Run the code, but don't go into the infinite loop. @@ -2005,7 +2004,7 @@ TEST(Build_Wasm_SimpleExprs) { } WASM_EXEC_TEST(Int32LoadInt8_signext) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); const int kNumElems = kWasmPageSize; int8_t* memory = r.builder().AddMemoryElems<int8_t>(kNumElems); r.builder().RandomizeMemory(); @@ -2018,7 +2017,7 @@ WASM_EXEC_TEST(Int32LoadInt8_signext) { } WASM_EXEC_TEST(Int32LoadInt8_zeroext) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); const int kNumElems = kWasmPageSize; byte* memory = r.builder().AddMemory(kNumElems); r.builder().RandomizeMemory(77); @@ -2031,7 +2030,7 @@ WASM_EXEC_TEST(Int32LoadInt8_zeroext) { } WASM_EXEC_TEST(Int32LoadInt16_signext) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); const int kNumBytes = kWasmPageSize; byte* memory = r.builder().AddMemory(kNumBytes); r.builder().RandomizeMemory(888); @@ -2045,7 +2044,7 @@ WASM_EXEC_TEST(Int32LoadInt16_signext) { } WASM_EXEC_TEST(Int32LoadInt16_zeroext) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); const int kNumBytes = kWasmPageSize; byte* memory = r.builder().AddMemory(kNumBytes); r.builder().RandomizeMemory(9999); @@ -2059,18 +2058,18 @@ WASM_EXEC_TEST(Int32LoadInt16_zeroext) { } WASM_EXEC_TEST(Int32Global) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* global = r.builder().AddGlobal<int32_t>(); // global = global + p0 BUILD(r, WASM_SET_GLOBAL(0, WASM_I32_ADD(WASM_GET_GLOBAL(0), WASM_GET_LOCAL(0))), WASM_ZERO); - *global = 116; + WriteLittleEndianValue<int32_t>(global, 116); for (int i = 9; i < 444444; i += 111111) { - int32_t expected = *global + i; + int32_t expected = ReadLittleEndianValue<int32_t>(global) + i; r.Call(i); - CHECK_EQ(expected, *global); + CHECK_EQ(expected, ReadLittleEndianValue<int32_t>(global)); } } @@ -2078,7 +2077,7 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) { const int kNumGlobals = 3; for (int g = 0; g < kNumGlobals; ++g) { // global = global + p0 - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* globals[] = {r.builder().AddGlobal<int32_t>(), r.builder().AddGlobal<int32_t>(), r.builder().AddGlobal<int32_t>()}; @@ -2088,23 +2087,24 @@ WASM_EXEC_TEST(Int32Globals_DontAlias) { WASM_GET_GLOBAL(g)); // Check that reading/writing global number {g} doesn't alter the others. - *globals[g] = 116 * g; + WriteLittleEndianValue<int32_t>(globals[g], 116 * g); int32_t before[kNumGlobals]; for (int i = 9; i < 444444; i += 111113) { - int32_t sum = *globals[g] + i; - for (int j = 0; j < kNumGlobals; ++j) before[j] = *globals[j]; + int32_t sum = ReadLittleEndianValue<int32_t>(globals[g]) + i; + for (int j = 0; j < kNumGlobals; ++j) + before[j] = ReadLittleEndianValue<int32_t>(globals[j]); int32_t result = r.Call(i); CHECK_EQ(sum, result); for (int j = 0; j < kNumGlobals; ++j) { int32_t expected = j == g ? sum : before[j]; - CHECK_EQ(expected, *globals[j]); + CHECK_EQ(expected, ReadLittleEndianValue<int32_t>(globals[j])); } } } } WASM_EXEC_TEST(Float32Global) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); float* global = r.builder().AddGlobal<float>(); // global = global + p0 BUILD(r, WASM_SET_GLOBAL( @@ -2112,16 +2112,16 @@ WASM_EXEC_TEST(Float32Global) { WASM_F32_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_ZERO); - *global = 1.25; + WriteLittleEndianValue<float>(global, 1.25); for (int i = 9; i < 4444; i += 1111) { - volatile float expected = *global + i; + volatile float expected = ReadLittleEndianValue<float>(global) + i; r.Call(i); - CHECK_EQ(expected, *global); + CHECK_EQ(expected, ReadLittleEndianValue<float>(global)); } } WASM_EXEC_TEST(Float64Global) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); double* global = r.builder().AddGlobal<double>(); // global = global + p0 BUILD(r, WASM_SET_GLOBAL( @@ -2129,16 +2129,16 @@ WASM_EXEC_TEST(Float64Global) { WASM_F64_SCONVERT_I32(WASM_GET_LOCAL(0)))), WASM_ZERO); - *global = 1.25; + WriteLittleEndianValue<double>(global, 1.25); for (int i = 9; i < 4444; i += 1111) { - volatile double expected = *global + i; + volatile double expected = ReadLittleEndianValue<double>(global) + i; r.Call(i); - CHECK_EQ(expected, *global); + CHECK_EQ(expected, ReadLittleEndianValue<double>(global)); } } WASM_EXEC_TEST(MixedGlobals) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); int32_t* unused = r.builder().AddGlobal<int32_t>(); byte* memory = r.builder().AddMemory(kWasmPageSize); @@ -2164,17 +2164,20 @@ WASM_EXEC_TEST(MixedGlobals) { memory[7] = 0x99; r.Call(1); - CHECK(static_cast<int32_t>(0xEE55CCAA) == *var_int32); - CHECK(static_cast<uint32_t>(0xEE55CCAA) == *var_uint32); - CHECK(bit_cast<float>(0xEE55CCAA) == *var_float); - CHECK(bit_cast<double>(0x99112233EE55CCAAULL) == *var_double); + CHECK(static_cast<int32_t>(0xEE55CCAA) == + ReadLittleEndianValue<int32_t>(var_int32)); + CHECK(static_cast<uint32_t>(0xEE55CCAA) == + ReadLittleEndianValue<uint32_t>(var_uint32)); + CHECK(bit_cast<float>(0xEE55CCAA) == ReadLittleEndianValue<float>(var_float)); + CHECK(bit_cast<double>(0x99112233EE55CCAAULL) == + ReadLittleEndianValue<double>(var_double)); USE(unused); } WASM_EXEC_TEST(CallEmpty) { const int32_t kExpected = -414444; - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); // Build the target function. WasmFunctionCompiler& target_func = r.NewFunction<int>(); @@ -2188,7 +2191,7 @@ WASM_EXEC_TEST(CallEmpty) { } WASM_EXEC_TEST(CallF32StackParameter) { - WasmRunner<float> r(execution_mode); + WasmRunner<float> r(execution_tier); // Build the target function. ValueType param_types[20]; @@ -2211,7 +2214,7 @@ WASM_EXEC_TEST(CallF32StackParameter) { } WASM_EXEC_TEST(CallF64StackParameter) { - WasmRunner<double> r(execution_mode); + WasmRunner<double> r(execution_tier); // Build the target function. ValueType param_types[20]; @@ -2234,7 +2237,7 @@ WASM_EXEC_TEST(CallF64StackParameter) { } WASM_EXEC_TEST(CallVoid) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); const byte kMemOffset = 8; const int32_t kElemNum = kMemOffset / sizeof(int32_t); @@ -2259,7 +2262,7 @@ WASM_EXEC_TEST(CallVoid) { } WASM_EXEC_TEST(Call_Int32Add) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); // Build the target function. WasmFunctionCompiler& t = r.NewFunction<int32_t, int32_t, int32_t>(); @@ -2279,7 +2282,7 @@ WASM_EXEC_TEST(Call_Int32Add) { } WASM_EXEC_TEST(Call_Float32Sub) { - WasmRunner<float, float, float> r(execution_mode); + WasmRunner<float, float, float> r(execution_tier); // Build the target function. WasmFunctionCompiler& target_func = r.NewFunction<float, float, float>(); @@ -2295,7 +2298,7 @@ WASM_EXEC_TEST(Call_Float32Sub) { } WASM_EXEC_TEST(Call_Float64Sub) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); double* memory = r.builder().AddMemoryElems<double>(kWasmPageSize / sizeof(double)); @@ -2329,7 +2332,7 @@ WASM_EXEC_TEST(Call_Float64Sub) { for (size_t i = 0; i < sizeof(__buf); ++i) vec.push_back(__buf[i]); \ } while (false) -static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { +static void Run_WasmMixedCall_N(ExecutionTier execution_tier, int start) { const int kExpected = 6333; const int kElemSize = 8; TestSignatures sigs; @@ -2345,7 +2348,7 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { for (int which = 0; which < num_params; ++which) { v8::internal::AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); r.builder().AddMemory(kWasmPageSize); MachineType* memtypes = &mixed[start]; MachineType result = memtypes[which]; @@ -2404,13 +2407,13 @@ static void Run_WasmMixedCall_N(WasmExecutionMode execution_mode, int start) { } } -WASM_EXEC_TEST(MixedCall_0) { Run_WasmMixedCall_N(execution_mode, 0); } -WASM_EXEC_TEST(MixedCall_1) { Run_WasmMixedCall_N(execution_mode, 1); } -WASM_EXEC_TEST(MixedCall_2) { Run_WasmMixedCall_N(execution_mode, 2); } -WASM_EXEC_TEST(MixedCall_3) { Run_WasmMixedCall_N(execution_mode, 3); } +WASM_EXEC_TEST(MixedCall_0) { Run_WasmMixedCall_N(execution_tier, 0); } +WASM_EXEC_TEST(MixedCall_1) { Run_WasmMixedCall_N(execution_tier, 1); } +WASM_EXEC_TEST(MixedCall_2) { Run_WasmMixedCall_N(execution_tier, 2); } +WASM_EXEC_TEST(MixedCall_3) { Run_WasmMixedCall_N(execution_tier, 3); } WASM_EXEC_TEST(AddCall) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); WasmFunctionCompiler& t1 = r.NewFunction<int32_t, int32_t, int32_t>(); BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); @@ -2429,7 +2432,7 @@ WASM_EXEC_TEST(AddCall) { WASM_EXEC_TEST(MultiReturnSub) { EXPERIMENTAL_FLAG_SCOPE(mv); - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); ValueType storage[] = {kWasmI32, kWasmI32, kWasmI32, kWasmI32}; FunctionSig sig_ii_ii(2, 2, storage); @@ -2449,7 +2452,7 @@ WASM_EXEC_TEST(MultiReturnSub) { } template <typename T> -void RunMultiReturnSelect(WasmExecutionMode execution_mode, const T* inputs) { +void RunMultiReturnSelect(ExecutionTier execution_tier, const T* inputs) { EXPERIMENTAL_FLAG_SCOPE(mv); ValueType type = ValueTypes::ValueTypeFor(MachineTypeForC<T>()); ValueType storage[] = {type, type, type, type, type, type}; @@ -2460,7 +2463,7 @@ void RunMultiReturnSelect(WasmExecutionMode execution_mode, const T* inputs) { for (size_t i = 0; i < kNumParams; i++) { for (size_t j = 0; j < kNumParams; j++) { for (int k = 0; k < 2; k++) { - WasmRunner<T, T, T, T, T> r(execution_mode); + WasmRunner<T, T, T, T, T> r(execution_tier); WasmFunctionCompiler& r1 = r.NewFunction(&sig); BUILD(r1, WASM_GET_LOCAL(i), WASM_GET_LOCAL(j)); @@ -2486,12 +2489,12 @@ void RunMultiReturnSelect(WasmExecutionMode execution_mode, const T* inputs) { WASM_EXEC_TEST(MultiReturnSelect_i32) { static const int32_t inputs[] = {3333333, 4444444, -55555555, -7777777}; - RunMultiReturnSelect<int32_t>(execution_mode, inputs); + RunMultiReturnSelect<int32_t>(execution_tier, inputs); } WASM_EXEC_TEST(MultiReturnSelect_f32) { static const float inputs[] = {33.33333f, 444.4444f, -55555.555f, -77777.77f}; - RunMultiReturnSelect<float>(execution_mode, inputs); + RunMultiReturnSelect<float>(execution_tier, inputs); } WASM_EXEC_TEST(MultiReturnSelect_i64) { @@ -2499,17 +2502,17 @@ WASM_EXEC_TEST(MultiReturnSelect_i64) { // TODO(titzer): implement int64-lowering for multiple return values static const int64_t inputs[] = {33333338888, 44444446666, -555555553333, -77777771111}; - RunMultiReturnSelect<int64_t>(execution_mode, inputs); + RunMultiReturnSelect<int64_t>(execution_tier, inputs); #endif } WASM_EXEC_TEST(MultiReturnSelect_f64) { static const double inputs[] = {3.333333, 44444.44, -55.555555, -7777.777}; - RunMultiReturnSelect<double>(execution_mode, inputs); + RunMultiReturnSelect<double>(execution_tier, inputs); } WASM_EXEC_TEST(ExprBlock2a) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I32V_1(1))), WASM_I32V_1(1))); CHECK_EQ(1, r.Call(0)); @@ -2517,7 +2520,7 @@ WASM_EXEC_TEST(ExprBlock2a) { } WASM_EXEC_TEST(ExprBlock2b) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_GET_LOCAL(0), WASM_BRV(1, WASM_I32V_1(1))), WASM_I32V_1(2))); CHECK_EQ(2, r.Call(0)); @@ -2525,7 +2528,7 @@ WASM_EXEC_TEST(ExprBlock2b) { } WASM_EXEC_TEST(ExprBlock2c) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I32V_1(1), WASM_GET_LOCAL(0)), WASM_I32V_1(1))); CHECK_EQ(1, r.Call(0)); @@ -2533,7 +2536,7 @@ WASM_EXEC_TEST(ExprBlock2c) { } WASM_EXEC_TEST(ExprBlock2d) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_BRV_IFD(0, WASM_I32V_1(1), WASM_GET_LOCAL(0)), WASM_I32V_1(2))); CHECK_EQ(2, r.Call(0)); @@ -2541,7 +2544,7 @@ WASM_EXEC_TEST(ExprBlock2d) { } WASM_EXEC_TEST(ExprBlock_ManualSwitch) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I32V_1(1)), WASM_BRV(1, WASM_I32V_1(11))), WASM_IF(WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I32V_1(2)), @@ -2563,7 +2566,7 @@ WASM_EXEC_TEST(ExprBlock_ManualSwitch) { } WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( WASM_BRV_IFD(0, WASM_I32V_1(11), WASM_I32_EQ(WASM_GET_LOCAL(0), WASM_I32V_1(1))), @@ -2586,7 +2589,7 @@ WASM_EXEC_TEST(ExprBlock_ManualSwitch_brif) { } WASM_EXEC_TEST(If_nested) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD( r, @@ -2602,7 +2605,7 @@ WASM_EXEC_TEST(If_nested) { } WASM_EXEC_TEST(ExprBlock_if) { - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_IF_ELSE_I(WASM_GET_LOCAL(0), WASM_BRV(0, WASM_I32V_1(11)), @@ -2613,7 +2616,7 @@ WASM_EXEC_TEST(ExprBlock_if) { } WASM_EXEC_TEST(ExprBlock_nested_ifs) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I(WASM_IF_ELSE_I( WASM_GET_LOCAL(0), @@ -2630,7 +2633,7 @@ WASM_EXEC_TEST(ExprBlock_nested_ifs) { WASM_EXEC_TEST(SimpleCallIndirect) { TestSignatures sigs; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); WasmFunctionCompiler& t1 = r.NewFunction(sigs.i_ii()); BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); @@ -2664,7 +2667,7 @@ WASM_EXEC_TEST(SimpleCallIndirect) { WASM_EXEC_TEST(MultipleCallIndirect) { TestSignatures sigs; - WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t, int32_t> r(execution_tier); WasmFunctionCompiler& t1 = r.NewFunction(sigs.i_ii()); BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); @@ -2707,7 +2710,7 @@ WASM_EXEC_TEST(MultipleCallIndirect) { WASM_EXEC_TEST(CallIndirect_EmptyTable) { TestSignatures sigs; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); // One function. WasmFunctionCompiler& t1 = r.NewFunction(sigs.i_ii()); @@ -2730,7 +2733,7 @@ WASM_EXEC_TEST(CallIndirect_EmptyTable) { WASM_EXEC_TEST(CallIndirect_canonical) { TestSignatures sigs; - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); WasmFunctionCompiler& t1 = r.NewFunction(sigs.i_ii()); BUILD(t1, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); @@ -2772,63 +2775,63 @@ WASM_EXEC_TEST(CallIndirect_canonical) { } WASM_EXEC_TEST(F32Floor) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_F32_FLOOR(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(floorf(*i), r.Call(*i)); } } WASM_EXEC_TEST(F32Ceil) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_F32_CEIL(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(ceilf(*i), r.Call(*i)); } } WASM_EXEC_TEST(F32Trunc) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_F32_TRUNC(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(truncf(*i), r.Call(*i)); } } WASM_EXEC_TEST(F32NearestInt) { - WasmRunner<float, float> r(execution_mode); + WasmRunner<float, float> r(execution_tier); BUILD(r, WASM_F32_NEARESTINT(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { CHECK_FLOAT_EQ(nearbyintf(*i), r.Call(*i)); } } WASM_EXEC_TEST(F64Floor) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_F64_FLOOR(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(floor(*i), r.Call(*i)); } } WASM_EXEC_TEST(F64Ceil) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_F64_CEIL(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(ceil(*i), r.Call(*i)); } } WASM_EXEC_TEST(F64Trunc) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_F64_TRUNC(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(trunc(*i), r.Call(*i)); } } WASM_EXEC_TEST(F64NearestInt) { - WasmRunner<double, double> r(execution_mode); + WasmRunner<double, double> r(execution_tier); BUILD(r, WASM_F64_NEARESTINT(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { CHECK_DOUBLE_EQ(nearbyint(*i), r.Call(*i)); } } WASM_EXEC_TEST(F32Min) { - WasmRunner<float, float, float> r(execution_mode); + WasmRunner<float, float, float> r(execution_tier); BUILD(r, WASM_F32_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT32_INPUTS(i) { @@ -2837,7 +2840,7 @@ WASM_EXEC_TEST(F32Min) { } WASM_EXEC_TEST(F64Min) { - WasmRunner<double, double, double> r(execution_mode); + WasmRunner<double, double, double> r(execution_tier); BUILD(r, WASM_F64_MIN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT64_INPUTS(i) { @@ -2846,7 +2849,7 @@ WASM_EXEC_TEST(F64Min) { } WASM_EXEC_TEST(F32Max) { - WasmRunner<float, float, float> r(execution_mode); + WasmRunner<float, float, float> r(execution_tier); BUILD(r, WASM_F32_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT32_INPUTS(i) { @@ -2855,7 +2858,7 @@ WASM_EXEC_TEST(F32Max) { } WASM_EXEC_TEST(F64Max) { - WasmRunner<double, double, double> r(execution_mode); + WasmRunner<double, double, double> r(execution_tier); BUILD(r, WASM_F64_MAX(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT64_INPUTS(i) { @@ -2867,7 +2870,7 @@ WASM_EXEC_TEST(F64Max) { } WASM_EXEC_TEST(I32SConvertF32) { - WasmRunner<int32_t, float> r(execution_mode); + WasmRunner<int32_t, float> r(execution_tier); BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { @@ -2881,7 +2884,7 @@ WASM_EXEC_TEST(I32SConvertF32) { WASM_EXEC_TEST(I32SConvertSatF32) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int32_t, float> r(execution_mode); + WasmRunner<int32_t, float> r(execution_tier); BUILD(r, WASM_I32_SCONVERT_SAT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { @@ -2897,7 +2900,7 @@ WASM_EXEC_TEST(I32SConvertSatF32) { } WASM_EXEC_TEST(I32SConvertF64) { - WasmRunner<int32_t, double> r(execution_mode); + WasmRunner<int32_t, double> r(execution_tier); BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { @@ -2911,7 +2914,7 @@ WASM_EXEC_TEST(I32SConvertF64) { WASM_EXEC_TEST(I32SConvertSatF64) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<int32_t, double> r(execution_mode); + WasmRunner<int32_t, double> r(execution_tier); BUILD(r, WASM_I32_SCONVERT_SAT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { int32_t expected = @@ -2926,7 +2929,7 @@ WASM_EXEC_TEST(I32SConvertSatF64) { } WASM_EXEC_TEST(I32UConvertF32) { - WasmRunner<uint32_t, float> r(execution_mode); + WasmRunner<uint32_t, float> r(execution_tier); BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { if (is_inbounds<uint32_t>(*i)) { @@ -2939,7 +2942,7 @@ WASM_EXEC_TEST(I32UConvertF32) { WASM_EXEC_TEST(I32UConvertSatF32) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<uint32_t, float> r(execution_mode); + WasmRunner<uint32_t, float> r(execution_tier); BUILD(r, WASM_I32_UCONVERT_SAT_F32(WASM_GET_LOCAL(0))); FOR_FLOAT32_INPUTS(i) { int32_t expected = @@ -2954,7 +2957,7 @@ WASM_EXEC_TEST(I32UConvertSatF32) { } WASM_EXEC_TEST(I32UConvertF64) { - WasmRunner<uint32_t, double> r(execution_mode); + WasmRunner<uint32_t, double> r(execution_tier); BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { if (is_inbounds<uint32_t>(*i)) { @@ -2967,7 +2970,7 @@ WASM_EXEC_TEST(I32UConvertF64) { WASM_EXEC_TEST(I32UConvertSatF64) { EXPERIMENTAL_FLAG_SCOPE(sat_f2i_conversions); - WasmRunner<uint32_t, double> r(execution_mode); + WasmRunner<uint32_t, double> r(execution_tier); BUILD(r, WASM_I32_UCONVERT_SAT_F64(WASM_GET_LOCAL(0))); FOR_FLOAT64_INPUTS(i) { int32_t expected = @@ -2982,7 +2985,7 @@ WASM_EXEC_TEST(I32UConvertSatF64) { } WASM_EXEC_TEST(F64CopySign) { - WasmRunner<double, double, double> r(execution_mode); + WasmRunner<double, double, double> r(execution_tier); BUILD(r, WASM_F64_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT64_INPUTS(i) { @@ -2991,7 +2994,7 @@ WASM_EXEC_TEST(F64CopySign) { } WASM_EXEC_TEST(F32CopySign) { - WasmRunner<float, float, float> r(execution_mode); + WasmRunner<float, float, float> r(execution_tier); BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); FOR_FLOAT32_INPUTS(i) { @@ -2999,12 +3002,12 @@ WASM_EXEC_TEST(F32CopySign) { } } -static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) { +static void CompileCallIndirectMany(ExecutionTier tier, ValueType param) { // Make sure we don't run out of registers when compiling indirect calls // with many many parameters. TestSignatures sigs; for (byte num_params = 0; num_params < 40; ++num_params) { - WasmRunner<void> r(mode); + WasmRunner<void> r(tier); FunctionSig* sig = sigs.many(r.zone(), kWasmStmt, param, num_params); r.builder().AddSignature(sig); @@ -3025,19 +3028,19 @@ static void CompileCallIndirectMany(WasmExecutionMode mode, ValueType param) { } WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_i32) { - CompileCallIndirectMany(execution_mode, kWasmI32); + CompileCallIndirectMany(execution_tier, kWasmI32); } WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_f32) { - CompileCallIndirectMany(execution_mode, kWasmF32); + CompileCallIndirectMany(execution_tier, kWasmF32); } WASM_COMPILED_EXEC_TEST(Compile_Wasm_CallIndirect_Many_f64) { - CompileCallIndirectMany(execution_mode, kWasmF64); + CompileCallIndirectMany(execution_tier, kWasmF64); } WASM_EXEC_TEST(Int32RemS_dead) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, WASM_ZERO); const int32_t kMin = std::numeric_limits<int32_t>::min(); @@ -3050,7 +3053,7 @@ WASM_EXEC_TEST(Int32RemS_dead) { } WASM_EXEC_TEST(BrToLoopWithValue) { - WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t, int32_t> r(execution_tier); // Subtracts <1> times 3 from <0> and returns the result. BUILD(r, // loop i32 @@ -3070,7 +3073,7 @@ WASM_EXEC_TEST(BrToLoopWithValue) { WASM_EXEC_TEST(BrToLoopWithoutValue) { // This was broken in the interpreter, see http://crbug.com/715454 - WasmRunner<int32_t, int32_t> r(execution_mode); + WasmRunner<int32_t, int32_t> r(execution_tier); BUILD( r, kExprLoop, kLocalI32, // loop i32 WASM_SET_LOCAL(0, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_ONE)), // dec <0> @@ -3081,31 +3084,31 @@ WASM_EXEC_TEST(BrToLoopWithoutValue) { } WASM_EXEC_TEST(LoopsWithValues) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_LOOP_I(WASM_LOOP_I(WASM_ONE), WASM_ONE, kExprI32Add)); CHECK_EQ(2, r.Call()); } WASM_EXEC_TEST(InvalidStackAfterUnreachable) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, kExprUnreachable, kExprI32Add); CHECK_TRAP32(r.Call()); } WASM_EXEC_TEST(InvalidStackAfterBr) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BRV(0, WASM_I32V_1(27)), kExprI32Add); CHECK_EQ(27, r.Call()); } WASM_EXEC_TEST(InvalidStackAfterReturn) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_RETURN1(WASM_I32V_1(17)), kExprI32Add); CHECK_EQ(17, r.Call()); } WASM_EXEC_TEST(BranchOverUnreachableCode) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, // Start a block which breaks in the middle (hence unreachable code // afterwards) and continue execution after this block. @@ -3116,7 +3119,7 @@ WASM_EXEC_TEST(BranchOverUnreachableCode) { } WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop0) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( // Start a loop which breaks in the middle (hence unreachable code @@ -3130,7 +3133,7 @@ WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop0) { } WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop1) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( // Start a loop which breaks in the middle (hence unreachable code @@ -3143,7 +3146,7 @@ WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop1) { } WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop2) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_BLOCK_I( // Start a loop which breaks in the middle (hence unreachable code @@ -3157,13 +3160,13 @@ WASM_EXEC_TEST(BranchOverUnreachableCodeInLoop2) { } WASM_EXEC_TEST(BlockInsideUnreachable) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD(r, WASM_RETURN1(WASM_I32V_1(17)), WASM_BLOCK(WASM_BR(0))); CHECK_EQ(17, r.Call()); } WASM_EXEC_TEST(IfInsideUnreachable) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); BUILD( r, WASM_RETURN1(WASM_I32V_1(17)), WASM_IF_ELSE_I(WASM_ONE, WASM_BRV(0, WASM_ONE), WASM_RETURN1(WASM_ONE))); @@ -3177,9 +3180,8 @@ WASM_EXEC_TEST(IfInsideUnreachable) { // not overwritten. template <typename ctype> void BinOpOnDifferentRegisters( - WasmExecutionMode execution_mode, ValueType type, - Vector<const ctype> inputs, WasmOpcode opcode, - std::function<ctype(ctype, ctype, bool*)> expect_fn) { + ExecutionTier execution_tier, ValueType type, Vector<const ctype> inputs, + WasmOpcode opcode, std::function<ctype(ctype, ctype, bool*)> expect_fn) { static constexpr int kMaxNumLocals = 8; for (int num_locals = 1; num_locals < kMaxNumLocals; ++num_locals) { // {init_locals_code} is shared by all code generated in the loop below. @@ -3202,7 +3204,7 @@ void BinOpOnDifferentRegisters( } for (int lhs = 0; lhs < num_locals; ++lhs) { for (int rhs = 0; rhs < num_locals; ++rhs) { - WasmRunner<int32_t> r(execution_mode); + WasmRunner<int32_t> r(execution_tier); ctype* memory = r.builder().AddMemoryElems<ctype>(kWasmPageSize / sizeof(ctype)); for (int i = 0; i < num_locals; ++i) { @@ -3226,8 +3228,7 @@ void BinOpOnDifferentRegisters( ctype value = i == lhs ? lhs_value : i == rhs ? rhs_value : static_cast<ctype>(i + 47); - WriteLittleEndianValue<ctype>( - reinterpret_cast<Address>(&memory[i]), value); + WriteLittleEndianValue<ctype>(&memory[i], value); } bool trap = false; int64_t expect = expect_fn(lhs_value, rhs_value, &trap); @@ -3236,14 +3237,12 @@ void BinOpOnDifferentRegisters( continue; } CHECK_EQ(0, r.Call()); - CHECK_EQ(expect, ReadLittleEndianValue<ctype>( - reinterpret_cast<Address>(&memory[0]))); + CHECK_EQ(expect, ReadLittleEndianValue<ctype>(&memory[0])); for (int i = 0; i < num_locals; ++i) { ctype value = i == lhs ? lhs_value : i == rhs ? rhs_value : static_cast<ctype>(i + 47); - CHECK_EQ(value, ReadLittleEndianValue<ctype>( - reinterpret_cast<Address>(&memory[i + 1]))); + CHECK_EQ(value, ReadLittleEndianValue<ctype>(&memory[i + 1])); } } } @@ -3260,37 +3259,37 @@ static constexpr int64_t kSome64BitInputs[] = { WASM_EXEC_TEST(I32AddOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Add, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Add, [](int32_t lhs, int32_t rhs, bool* trap) { return lhs + rhs; }); } WASM_EXEC_TEST(I32SubOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Sub, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Sub, [](int32_t lhs, int32_t rhs, bool* trap) { return lhs - rhs; }); } WASM_EXEC_TEST(I32MulOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Mul, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Mul, [](int32_t lhs, int32_t rhs, bool* trap) { return lhs * rhs; }); } WASM_EXEC_TEST(I32ShlOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Shl, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32Shl, [](int32_t lhs, int32_t rhs, bool* trap) { return lhs << (rhs & 31); }); } WASM_EXEC_TEST(I32ShrSOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32ShrS, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32ShrS, [](int32_t lhs, int32_t rhs, bool* trap) { return lhs >> (rhs & 31); }); } WASM_EXEC_TEST(I32ShrUOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32ShrU, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32ShrU, [](int32_t lhs, int32_t rhs, bool* trap) { return static_cast<uint32_t>(lhs) >> (rhs & 31); }); @@ -3298,7 +3297,7 @@ WASM_EXEC_TEST(I32ShrUOnDifferentRegisters) { WASM_EXEC_TEST(I32DivSOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32DivS, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32DivS, [](int32_t lhs, int32_t rhs, bool* trap) { *trap = rhs == 0; return *trap ? 0 : lhs / rhs; @@ -3307,7 +3306,7 @@ WASM_EXEC_TEST(I32DivSOnDifferentRegisters) { WASM_EXEC_TEST(I32DivUOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32DivU, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32DivU, [](uint32_t lhs, uint32_t rhs, bool* trap) { *trap = rhs == 0; return *trap ? 0 : lhs / rhs; @@ -3316,7 +3315,7 @@ WASM_EXEC_TEST(I32DivUOnDifferentRegisters) { WASM_EXEC_TEST(I32RemSOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32RemS, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32RemS, [](int32_t lhs, int32_t rhs, bool* trap) { *trap = rhs == 0; return *trap || rhs == -1 ? 0 : lhs % rhs; @@ -3325,7 +3324,7 @@ WASM_EXEC_TEST(I32RemSOnDifferentRegisters) { WASM_EXEC_TEST(I32RemUOnDifferentRegisters) { BinOpOnDifferentRegisters<int32_t>( - execution_mode, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32RemU, + execution_tier, kWasmI32, ArrayVector(kSome32BitInputs), kExprI32RemU, [](uint32_t lhs, uint32_t rhs, bool* trap) { *trap = rhs == 0; return *trap ? 0 : lhs % rhs; @@ -3334,37 +3333,37 @@ WASM_EXEC_TEST(I32RemUOnDifferentRegisters) { WASM_EXEC_TEST(I64AddOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Add, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Add, [](int64_t lhs, int64_t rhs, bool* trap) { return lhs + rhs; }); } WASM_EXEC_TEST(I64SubOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Sub, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Sub, [](int64_t lhs, int64_t rhs, bool* trap) { return lhs - rhs; }); } WASM_EXEC_TEST(I64MulOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Mul, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Mul, [](int64_t lhs, int64_t rhs, bool* trap) { return lhs * rhs; }); } WASM_EXEC_TEST(I64ShlOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Shl, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64Shl, [](int64_t lhs, int64_t rhs, bool* trap) { return lhs << (rhs & 63); }); } WASM_EXEC_TEST(I64ShrSOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64ShrS, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64ShrS, [](int64_t lhs, int64_t rhs, bool* trap) { return lhs >> (rhs & 63); }); } WASM_EXEC_TEST(I64ShrUOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64ShrU, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64ShrU, [](int64_t lhs, int64_t rhs, bool* trap) { return static_cast<uint64_t>(lhs) >> (rhs & 63); }); @@ -3372,7 +3371,7 @@ WASM_EXEC_TEST(I64ShrUOnDifferentRegisters) { WASM_EXEC_TEST(I64DivSOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64DivS, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64DivS, [](int64_t lhs, int64_t rhs, bool* trap) { *trap = rhs == 0 || (rhs == -1 && lhs == std::numeric_limits<int64_t>::min()); @@ -3382,7 +3381,7 @@ WASM_EXEC_TEST(I64DivSOnDifferentRegisters) { WASM_EXEC_TEST(I64DivUOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64DivU, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64DivU, [](uint64_t lhs, uint64_t rhs, bool* trap) { *trap = rhs == 0; return *trap ? 0 : lhs / rhs; @@ -3391,7 +3390,7 @@ WASM_EXEC_TEST(I64DivUOnDifferentRegisters) { WASM_EXEC_TEST(I64RemSOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64RemS, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64RemS, [](int64_t lhs, int64_t rhs, bool* trap) { *trap = rhs == 0; return *trap || rhs == -1 ? 0 : lhs % rhs; @@ -3400,7 +3399,7 @@ WASM_EXEC_TEST(I64RemSOnDifferentRegisters) { WASM_EXEC_TEST(I64RemUOnDifferentRegisters) { BinOpOnDifferentRegisters<int64_t>( - execution_mode, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64RemU, + execution_tier, kWasmI64, ArrayVector(kSome64BitInputs), kExprI64RemU, [](uint64_t lhs, uint64_t rhs, bool* trap) { *trap = rhs == 0; return *trap ? 0 : lhs % rhs; @@ -3408,7 +3407,7 @@ WASM_EXEC_TEST(I64RemUOnDifferentRegisters) { } TEST(Liftoff_tier_up) { - WasmRunner<int32_t, int32_t, int32_t> r(WasmExecutionMode::kExecuteLiftoff); + WasmRunner<int32_t, int32_t, int32_t> r(ExecutionTier::kBaseline); WasmFunctionCompiler& add = r.NewFunction<int32_t, int32_t, int32_t>("add"); BUILD(add, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); diff --git a/deps/v8/test/cctest/wasm/test-streaming-compilation.cc b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc index e9ee63d93c..39d7e1a5be 100644 --- a/deps/v8/test/cctest/wasm/test-streaming-compilation.cc +++ b/deps/v8/test/cctest/wasm/test-streaming-compilation.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/v8.h" #include "src/vector.h" @@ -88,7 +88,7 @@ enum class CompilationState { kFailed, }; -class TestResolver : public i::wasm::CompilationResultResolver { +class TestResolver : public CompilationResultResolver { public: explicit TestResolver(CompilationState* state) : state_(state) {} @@ -109,12 +109,13 @@ class StreamTester { StreamTester() : zone_(&allocator_, "StreamTester") { v8::Isolate* isolate = CcTest::isolate(); i::Isolate* i_isolate = CcTest::i_isolate(); + i::HandleScope internal_scope(i_isolate); v8::Local<v8::Context> context = isolate->GetCurrentContext(); stream_ = i_isolate->wasm_engine()->StartStreamingCompilation( - i_isolate, v8::Utils::OpenHandle(*context), - base::make_unique<TestResolver>(&state_)); + i_isolate, kAllWasmFeatures, v8::Utils::OpenHandle(*context), + std::make_shared<TestResolver>(&state_)); } std::shared_ptr<StreamingDecoder> stream() { return stream_; } @@ -151,8 +152,6 @@ class StreamTester { TEST(name) { \ MockPlatform platform; \ CcTest::InitializeVM(); \ - v8::HandleScope handle_scope(CcTest::isolate()); \ - i::HandleScope internal_scope(CcTest::i_isolate()); \ RunStream_##name(); \ } \ void RunStream_##name() @@ -212,8 +211,9 @@ STREAM_TEST(TestAllBytesArriveAOTCompilerFinishesFirst) { size_t GetFunctionOffset(i::Isolate* isolate, const uint8_t* buffer, size_t size, size_t index) { - ModuleResult result = SyncDecodeWasmModule(isolate, buffer, buffer + size, - false, ModuleOrigin::kWasmOrigin); + ModuleResult result = DecodeWasmModule( + kAllWasmFeatures, buffer, buffer + size, false, ModuleOrigin::kWasmOrigin, + isolate->counters(), isolate->allocator()); CHECK(result.ok()); const WasmFunction* func = &result.val->functions[1]; return func->code.offset(); diff --git a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc index ef0a0e545e..ec93639e17 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-breakpoints.cc @@ -242,7 +242,7 @@ std::vector<WasmValue> wasmVec(Args... args) { } // namespace WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) { - WasmRunner<int> runner(execution_mode); + WasmRunner<int> runner(execution_tier); BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_ZERO, WASM_ONE)); @@ -269,7 +269,7 @@ WASM_COMPILED_EXEC_TEST(WasmCollectPossibleBreakpoints) { } WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) { - WasmRunner<int> runner(execution_mode); + WasmRunner<int> runner(execution_tier); Isolate* isolate = runner.main_isolate(); BUILD(runner, WASM_NOP, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))); @@ -290,7 +290,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleBreak) { } WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) { - WasmRunner<int> runner(execution_mode); + WasmRunner<int> runner(execution_tier); BUILD(runner, WASM_I32_ADD(WASM_I32V_1(11), WASM_I32V_1(3))); Isolate* isolate = runner.main_isolate(); @@ -317,7 +317,7 @@ WASM_COMPILED_EXEC_TEST(WasmSimpleStepping) { } WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) { - WasmRunner<int, int> runner(execution_mode); + WasmRunner<int, int> runner(execution_tier); WasmFunctionCompiler& f2 = runner.NewFunction<void>(); f2.AllocateLocal(kWasmI32); @@ -357,7 +357,7 @@ WASM_COMPILED_EXEC_TEST(WasmStepInAndOut) { } WASM_COMPILED_EXEC_TEST(WasmGetLocalsAndStack) { - WasmRunner<void, int> runner(execution_mode); + WasmRunner<void, int> runner(execution_tier); runner.AllocateLocal(kWasmI64); runner.AllocateLocal(kWasmF32); runner.AllocateLocal(kWasmF64); diff --git a/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc b/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc index 16c525945f..d927de34ca 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-interpreter-entry.cc @@ -91,7 +91,7 @@ static ArgPassingHelper<T> GetHelper( // Pass int32_t, return int32_t. TEST(TestArgumentPassing_int32) { - WasmRunner<int32_t, int32_t> runner(kExecuteTurbofan); + WasmRunner<int32_t, int32_t> runner(ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<int32_t, int32_t>(); auto helper = GetHelper( @@ -107,7 +107,7 @@ TEST(TestArgumentPassing_int32) { // Pass int64_t, return double. TEST(TestArgumentPassing_double_int64) { - WasmRunner<double, int32_t, int32_t> runner(kExecuteTurbofan); + WasmRunner<double, int32_t, int32_t> runner(ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<double, int64_t>(); auto helper = GetHelper( @@ -140,7 +140,7 @@ TEST(TestArgumentPassing_double_int64) { // Pass double, return int64_t. TEST(TestArgumentPassing_int64_double) { // Outer function still returns double. - WasmRunner<double, double> runner(kExecuteTurbofan); + WasmRunner<double, double> runner(ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<int64_t, double>(); auto helper = GetHelper( @@ -159,7 +159,7 @@ TEST(TestArgumentPassing_int64_double) { // Pass float, return double. TEST(TestArgumentPassing_float_double) { - WasmRunner<double, float> runner(kExecuteTurbofan); + WasmRunner<double, float> runner(ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<double, float>(); auto helper = GetHelper( @@ -177,7 +177,7 @@ TEST(TestArgumentPassing_float_double) { // Pass two doubles, return double. TEST(TestArgumentPassing_double_double) { - WasmRunner<double, double, double> runner(kExecuteTurbofan); + WasmRunner<double, double, double> runner(ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<double, double, double>(); auto helper = GetHelper(runner, f2, @@ -197,7 +197,7 @@ TEST(TestArgumentPassing_double_double) { TEST(TestArgumentPassing_AllTypes) { // The second and third argument will be combined to an i64. WasmRunner<double, int32_t, int32_t, int32_t, float, double> runner( - kExecuteTurbofan); + ExecutionTier::kOptimized); WasmFunctionCompiler& f2 = runner.NewFunction<double, int32_t, int64_t, float, double>(); diff --git a/deps/v8/test/cctest/wasm/test-wasm-serialization.cc b/deps/v8/test/cctest/wasm/test-wasm-serialization.cc index 9475332ad0..a2c53ab210 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-serialization.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-serialization.cc @@ -5,7 +5,7 @@ #include <stdlib.h> #include <string.h> -#include "src/api.h" +#include "src/api-inl.h" #include "src/objects-inl.h" #include "src/snapshot/code-serializer.h" #include "src/version.h" @@ -147,9 +147,10 @@ class WasmSerializationTest { HandleScope scope(serialization_isolate); testing::SetupIsolateForWasmModule(serialization_isolate); + auto enabled_features = WasmFeaturesFromIsolate(serialization_isolate); MaybeHandle<WasmModuleObject> maybe_module_object = serialization_isolate->wasm_engine()->SyncCompile( - serialization_isolate, &thrower, + serialization_isolate, enabled_features, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); Handle<WasmModuleObject> module_object = maybe_module_object.ToHandleChecked(); @@ -269,46 +270,75 @@ TEST(BlockWasmCodeGenAtDeserialization) { Cleanup(); } -TEST(TransferrableWasmModules) { +namespace { + +void TestTransferrableWasmModules(bool should_share) { + i::wasm::WasmEngine::InitializeOncePerProcess(); v8::internal::AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); ZoneBuffer buffer(&zone); WasmSerializationTest::BuildWireBytes(&zone, &buffer); - Isolate* from_isolate = CcTest::InitIsolateOnce(); - ErrorThrower thrower(from_isolate, ""); + v8::Isolate::CreateParams create_params; + create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); + v8::Isolate* from_isolate = v8::Isolate::New(create_params); std::vector<v8::WasmCompiledModule::TransferrableModule> store; + std::shared_ptr<NativeModule> original_native_module; { - HandleScope scope(from_isolate); - testing::SetupIsolateForWasmModule(from_isolate); - - MaybeHandle<WasmModuleObject> module_object = - from_isolate->wasm_engine()->SyncCompile( - from_isolate, &thrower, + v8::HandleScope scope(from_isolate); + LocalContext env(from_isolate); + + Isolate* from_i_isolate = reinterpret_cast<Isolate*>(from_isolate); + testing::SetupIsolateForWasmModule(from_i_isolate); + ErrorThrower thrower(from_i_isolate, "TestTransferrableWasmModules"); + auto enabled_features = WasmFeaturesFromIsolate(from_i_isolate); + MaybeHandle<WasmModuleObject> maybe_module_object = + from_i_isolate->wasm_engine()->SyncCompile( + from_i_isolate, enabled_features, &thrower, ModuleWireBytes(buffer.begin(), buffer.end())); + Handle<WasmModuleObject> module_object = + maybe_module_object.ToHandleChecked(); v8::Local<v8::WasmCompiledModule> v8_module = - v8::Local<v8::WasmCompiledModule>::Cast(v8::Utils::ToLocal( - Handle<JSObject>::cast(module_object.ToHandleChecked()))); + v8::Local<v8::WasmCompiledModule>::Cast( + v8::Utils::ToLocal(Handle<JSObject>::cast(module_object))); store.push_back(v8_module->GetTransferrableModule()); + original_native_module = module_object->managed_native_module()->get(); } { - v8::Isolate::CreateParams create_params; - create_params.array_buffer_allocator = - from_isolate->array_buffer_allocator(); v8::Isolate* to_isolate = v8::Isolate::New(create_params); { - v8::HandleScope new_scope(to_isolate); - v8::Local<v8::Context> deserialization_context = - v8::Context::New(to_isolate); - deserialization_context->Enter(); - v8::MaybeLocal<v8::WasmCompiledModule> mod = + v8::HandleScope scope(to_isolate); + LocalContext env(to_isolate); + + v8::MaybeLocal<v8::WasmCompiledModule> transferred_module = v8::WasmCompiledModule::FromTransferrableModule(to_isolate, store[0]); - CHECK(!mod.IsEmpty()); + CHECK(!transferred_module.IsEmpty()); + Handle<WasmModuleObject> module_object = Handle<WasmModuleObject>::cast( + v8::Utils::OpenHandle(*transferred_module.ToLocalChecked())); + std::shared_ptr<NativeModule> transferred_native_module = + module_object->managed_native_module()->get(); + bool is_sharing = (original_native_module == transferred_native_module); + CHECK_EQ(should_share, is_sharing); } to_isolate->Dispose(); } + original_native_module.reset(); + from_isolate->Dispose(); +} + +} // namespace + +UNINITIALIZED_TEST(TransferrableWasmModulesCloned) { + FlagScope<bool> flag_scope_code(&FLAG_wasm_shared_code, false); + TestTransferrableWasmModules(false); +} + +UNINITIALIZED_TEST(TransferrableWasmModulesShared) { + FlagScope<bool> flag_scope_engine(&FLAG_wasm_shared_engine, true); + FlagScope<bool> flag_scope_code(&FLAG_wasm_shared_code, true); + TestTransferrableWasmModules(true); } #undef EMIT_CODE_WITH_END diff --git a/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc b/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc index 8d9131ad75..5e70edf830 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-shared-engine.cc @@ -5,6 +5,7 @@ #include <memory> #include "src/objects-inl.h" +#include "src/wasm/function-compiler.h" #include "src/wasm/wasm-engine.h" #include "src/wasm/wasm-module-builder.h" #include "src/wasm/wasm-module.h" @@ -25,8 +26,7 @@ namespace test_wasm_shared_engine { class SharedEngine { public: explicit SharedEngine(size_t max_committed = kMaxWasmCodeMemory) - : wasm_engine_(base::make_unique<WasmEngine>( - base::make_unique<WasmCodeManager>(max_committed))) {} + : wasm_engine_(base::make_unique<WasmEngine>()) {} ~SharedEngine() { // Ensure no remaining uses exist. CHECK(wasm_engine_.unique()); @@ -83,20 +83,9 @@ class SharedEngineIsolate { return instance.ToHandleChecked(); } - // TODO(mstarzinger): Switch over to a public API for sharing modules via the - // {v8::WasmCompiledModule::TransferrableModule} class once it is ready. Handle<WasmInstanceObject> ImportInstance(SharedModule shared_module) { - Vector<const byte> wire_bytes = shared_module->wire_bytes(); - Handle<Script> script = CreateWasmScript(isolate(), wire_bytes); Handle<WasmModuleObject> module_object = - WasmModuleObject::New(isolate(), shared_module, script); - - // TODO(6792): Wrappers below might be cloned using {Factory::CopyCode}. - // This requires unlocking the code space here. This should eventually be - // moved into the allocator. - CodeSpaceMemoryModificationScope modification_scope(isolate()->heap()); - CompileJsToWasmWrappers(isolate(), module_object); - + isolate()->wasm_engine()->ImportNativeModule(isolate(), shared_module); ErrorThrower thrower(isolate(), "ImportInstance"); MaybeHandle<WasmInstanceObject> instance = isolate()->wasm_engine()->SyncInstantiate(isolate(), &thrower, @@ -117,6 +106,26 @@ class SharedEngineIsolate { std::unique_ptr<Zone> zone_; }; +// Helper class representing a Thread running its own instance of an Isolate +// with a shared WebAssembly engine available at construction time. +class SharedEngineThread : public v8::base::Thread { + public: + SharedEngineThread(SharedEngine* engine, + std::function<void(SharedEngineIsolate&)> callback) + : Thread(Options("SharedEngineThread")), + engine_(engine), + callback_(callback) {} + + virtual void Run() { + SharedEngineIsolate isolate(engine_); + callback_(isolate); + } + + private: + SharedEngine* engine_; + std::function<void(SharedEngineIsolate&)> callback_; +}; + namespace { ZoneBuffer* BuildReturnConstantModule(Zone* zone, int constant) { @@ -132,6 +141,62 @@ ZoneBuffer* BuildReturnConstantModule(Zone* zone, int constant) { return buffer; } +class MockInstantiationResolver : public InstantiationResultResolver { + public: + explicit MockInstantiationResolver(Handle<Object>* out_instance) + : out_instance_(out_instance) {} + virtual void OnInstantiationSucceeded(Handle<WasmInstanceObject> result) { + *out_instance_->location() = *result; + } + virtual void OnInstantiationFailed(Handle<Object> error_reason) { + UNREACHABLE(); + } + + private: + Handle<Object>* out_instance_; +}; + +class MockCompilationResolver : public CompilationResultResolver { + public: + MockCompilationResolver(SharedEngineIsolate& isolate, + Handle<Object>* out_instance) + : isolate_(isolate), out_instance_(out_instance) {} + virtual void OnCompilationSucceeded(Handle<WasmModuleObject> result) { + isolate_.isolate()->wasm_engine()->AsyncInstantiate( + isolate_.isolate(), + base::make_unique<MockInstantiationResolver>(out_instance_), result, + {}); + } + virtual void OnCompilationFailed(Handle<Object> error_reason) { + UNREACHABLE(); + } + + private: + SharedEngineIsolate& isolate_; + Handle<Object>* out_instance_; +}; + +void PumpMessageLoop(SharedEngineIsolate& isolate) { + v8::platform::PumpMessageLoop(i::V8::GetCurrentPlatform(), + isolate.v8_isolate(), + platform::MessageLoopBehavior::kWaitForWork); + isolate.isolate()->RunMicrotasks(); +} + +Handle<WasmInstanceObject> CompileAndInstantiateAsync( + SharedEngineIsolate& isolate, ZoneBuffer* buffer) { + Handle<Object> maybe_instance = handle(Smi::kZero, isolate.isolate()); + auto enabled_features = WasmFeaturesFromIsolate(isolate.isolate()); + isolate.isolate()->wasm_engine()->AsyncCompile( + isolate.isolate(), enabled_features, + base::make_unique<MockCompilationResolver>(isolate, &maybe_instance), + ModuleWireBytes(buffer->begin(), buffer->end()), true); + while (!maybe_instance->IsWasmInstanceObject()) PumpMessageLoop(isolate); + Handle<WasmInstanceObject> instance = + Handle<WasmInstanceObject>::cast(maybe_instance); + return instance; +} + } // namespace TEST(SharedEngineUseCount) { @@ -192,6 +257,111 @@ TEST(SharedEngineRunImported) { CHECK_EQ(1, module.use_count()); } +TEST(SharedEngineRunThreadedBuildingSync) { + SharedEngine engine; + SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); + Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); + CHECK_EQ(23, isolate.Run(instance)); + }); + SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); + Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); + CHECK_EQ(42, isolate.Run(instance)); + }); + thread1.Start(); + thread2.Start(); + thread1.Join(); + thread2.Join(); +} + +TEST(SharedEngineRunThreadedBuildingAsync) { + SharedEngine engine; + SharedEngineThread thread1(&engine, [](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); + Handle<WasmInstanceObject> instance = + CompileAndInstantiateAsync(isolate, buffer); + CHECK_EQ(23, isolate.Run(instance)); + }); + SharedEngineThread thread2(&engine, [](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 42); + Handle<WasmInstanceObject> instance = + CompileAndInstantiateAsync(isolate, buffer); + CHECK_EQ(42, isolate.Run(instance)); + }); + thread1.Start(); + thread2.Start(); + thread1.Join(); + thread2.Join(); +} + +TEST(SharedEngineRunThreadedExecution) { + SharedEngine engine; + SharedModule module; + { + SharedEngineIsolate isolate(&engine); + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); + Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); + module = isolate.ExportInstance(instance); + } + SharedEngineThread thread1(&engine, [module](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); + CHECK_EQ(23, isolate.Run(instance)); + }); + SharedEngineThread thread2(&engine, [module](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); + CHECK_EQ(23, isolate.Run(instance)); + }); + thread1.Start(); + thread2.Start(); + thread1.Join(); + thread2.Join(); +} + +TEST(SharedEngineRunThreadedTierUp) { + SharedEngine engine; + SharedModule module; + { + SharedEngineIsolate isolate(&engine); + HandleScope scope(isolate.isolate()); + ZoneBuffer* buffer = BuildReturnConstantModule(isolate.zone(), 23); + Handle<WasmInstanceObject> instance = isolate.CompileAndInstantiate(buffer); + module = isolate.ExportInstance(instance); + } + constexpr int kNumberOfThreads = 5; + std::list<SharedEngineThread> threads; + for (int i = 0; i < kNumberOfThreads; ++i) { + threads.emplace_back(&engine, [module](SharedEngineIsolate& isolate) { + constexpr int kNumberOfIterations = 100; + HandleScope scope(isolate.isolate()); + Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); + for (int j = 0; j < kNumberOfIterations; ++j) { + CHECK_EQ(23, isolate.Run(instance)); + } + }); + } + threads.emplace_back(&engine, [module](SharedEngineIsolate& isolate) { + HandleScope scope(isolate.isolate()); + Handle<WasmInstanceObject> instance = isolate.ImportInstance(module); + ErrorThrower thrower(isolate.isolate(), "Forced Tier Up"); + WasmFeatures detected = kNoWasmFeatures; + WasmCompilationUnit::CompileWasmFunction( + isolate.isolate(), module.get(), &detected, &thrower, + GetModuleEnv(module->compilation_state()), + &module->module()->functions[0], ExecutionTier::kOptimized); + CHECK_EQ(23, isolate.Run(instance)); + }); + for (auto& thread : threads) thread.Start(); + for (auto& thread : threads) thread.Join(); +} + } // namespace test_wasm_shared_engine } // namespace wasm } // namespace internal diff --git a/deps/v8/test/cctest/wasm/test-wasm-stack.cc b/deps/v8/test/cctest/wasm/test-wasm-stack.cc index 227b90187a..2bed7e64db 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-stack.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-stack.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "test/cctest/cctest.h" #include "test/cctest/compiler/value-helper.h" @@ -35,7 +35,7 @@ namespace { void PrintStackTrace(v8::Isolate* isolate, v8::Local<v8::StackTrace> stack) { printf("Stack Trace (length %d):\n", stack->GetFrameCount()); for (int i = 0, e = stack->GetFrameCount(); i != e; ++i) { - v8::Local<v8::StackFrame> frame = stack->GetFrame(i); + v8::Local<v8::StackFrame> frame = stack->GetFrame(isolate, i); v8::Local<v8::String> script = frame->GetScriptName(); v8::Local<v8::String> func = frame->GetFunctionName(); printf( @@ -68,7 +68,7 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, CHECK_EQ(N, stack->GetFrameCount()); for (int frameNr = 0; frameNr < N; ++frameNr) { - v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr); + v8::Local<v8::StackFrame> frame = stack->GetFrame(v8_isolate, frameNr); v8::String::Utf8Value funName(v8_isolate, frame->GetFunctionName()); CHECK_CSTREQ(excInfos[frameNr].func_name, *funName); // Line and column are 1-based in v8::StackFrame, just as in ExceptionInfo. @@ -111,7 +111,7 @@ WASM_EXEC_TEST(CollectDetailedWasmStack_ExplicitThrowFromJs) { *v8::Local<v8::Function>::Cast(CompileRun(source)))); ManuallyImportedJSFunction import = {sigs.v_v(), js_function}; uint32_t js_throwing_index = 0; - WasmRunner<void> r(execution_mode, &import); + WasmRunner<void> r(execution_tier, &import); // Add a nop such that we don't always get position 1. BUILD(r, WASM_NOP, WASM_CALL_FUNCTION0(js_throwing_index)); @@ -157,7 +157,7 @@ WASM_EXEC_TEST(CollectDetailedWasmStack_WasmError) { int unreachable_pos = 1 << (8 * pos_shift); TestSignatures sigs; // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<int> r(execution_mode, 0, "main", kRuntimeExceptionSupport); + WasmRunner<int> r(execution_tier, 0, "main", kRuntimeExceptionSupport); std::vector<byte> code(unreachable_pos + 1, kExprNop); code[unreachable_pos] = kExprUnreachable; diff --git a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc index 08ad5d31f8..ad9b6d3b56 100644 --- a/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc +++ b/deps/v8/test/cctest/wasm/test-wasm-trap-position.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/api.h" +#include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/trap-handler/trap-handler.h" #include "test/cctest/cctest.h" @@ -54,7 +54,7 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, CHECK_EQ(N, stack->GetFrameCount()); for (int frameNr = 0; frameNr < N; ++frameNr) { - v8::Local<v8::StackFrame> frame = stack->GetFrame(frameNr); + v8::Local<v8::StackFrame> frame = stack->GetFrame(v8_isolate, frameNr); v8::String::Utf8Value funName(v8_isolate, frame->GetFunctionName()); CHECK_CSTREQ(excInfos[frameNr].func_name, *funName); CHECK_EQ(excInfos[frameNr].line_nr, frame->GetLineNumber()); @@ -69,7 +69,7 @@ void CheckExceptionInfos(v8::internal::Isolate* i_isolate, Handle<Object> exc, // Trigger a trap for executing unreachable. WASM_EXEC_TEST(Unreachable) { // Create a WasmRunner with stack checks and traps enabled. - WasmRunner<void> r(execution_mode, 0, "main", kRuntimeExceptionSupport); + WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport); TestSignatures sigs; BUILD(r, WASM_UNREACHABLE); @@ -103,7 +103,7 @@ WASM_EXEC_TEST(Unreachable) { // Trigger a trap for loading from out-of-bounds. WASM_EXEC_TEST(IllegalLoad) { - WasmRunner<void> r(execution_mode, 0, "main", kRuntimeExceptionSupport); + WasmRunner<void> r(execution_tier, 0, "main", kRuntimeExceptionSupport); TestSignatures sigs; r.builder().AddMemory(0L); diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.cc b/deps/v8/test/cctest/wasm/wasm-run-utils.cc index d7a87849a2..5f623a46cc 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.cc +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.cc @@ -14,13 +14,13 @@ namespace internal { namespace wasm { TestingModuleBuilder::TestingModuleBuilder( - Zone* zone, ManuallyImportedJSFunction* maybe_import, - WasmExecutionMode mode, RuntimeExceptionSupport exception_support, - LowerSimd lower_simd) + Zone* zone, ManuallyImportedJSFunction* maybe_import, ExecutionTier tier, + RuntimeExceptionSupport exception_support, LowerSimd lower_simd) : test_module_(std::make_shared<WasmModule>()), test_module_ptr_(test_module_.get()), isolate_(CcTest::InitIsolateOnce()), - execution_mode_(mode), + enabled_features_(WasmFeaturesFromIsolate(isolate_)), + execution_tier_(tier), runtime_exception_support_(exception_support), lower_simd_(lower_simd) { WasmJs::Install(isolate_, true); @@ -47,14 +47,13 @@ TestingModuleBuilder::TestingModuleBuilder( trap_handler::IsTrapHandlerEnabled() ? kUseTrapHandler : kNoTrapHandler); auto wasm_to_js_wrapper = native_module_->AddCodeCopy( - code.ToHandleChecked(), wasm::WasmCode::kWasmToJsWrapper, - maybe_import_index); + code.ToHandleChecked(), WasmCode::kWasmToJsWrapper, maybe_import_index); ImportedFunctionEntry(instance_object_, maybe_import_index) .set_wasm_to_js(*maybe_import->js_function, wasm_to_js_wrapper); } - if (mode == kExecuteInterpreter) { + if (tier == ExecutionTier::kInterpreter) { interpreter_ = WasmDebugInfo::SetupForTesting(instance_object_); } } @@ -69,7 +68,7 @@ byte* TestingModuleBuilder::AddMemory(uint32_t size) { test_module_->has_memory = true; uint32_t alloc_size = RoundUp(size, kWasmPageSize); Handle<JSArrayBuffer> new_buffer; - CHECK(wasm::NewArrayBuffer(isolate_, alloc_size).ToHandle(&new_buffer)); + CHECK(NewArrayBuffer(isolate_, alloc_size).ToHandle(&new_buffer)); CHECK(!new_buffer.is_null()); mem_start_ = reinterpret_cast<byte*>(new_buffer->backing_store()); mem_size_ = size; @@ -195,7 +194,7 @@ ModuleEnv TestingModuleBuilder::CreateModuleEnv() { return { test_module_ptr_, trap_handler::IsTrapHandlerEnabled() ? kUseTrapHandler : kNoTrapHandler, - runtime_exception_support_}; + runtime_exception_support_, lower_simd()}; } const WasmGlobal* TestingModuleBuilder::AddGlobal(ValueType type) { @@ -214,8 +213,9 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { isolate_->factory()->NewScript(isolate_->factory()->empty_string()); script->set_type(Script::TYPE_WASM); ModuleEnv env = CreateModuleEnv(); - Handle<WasmModuleObject> module_object = WasmModuleObject::New( - isolate_, test_module_, env, {}, script, Handle<ByteArray>::null()); + Handle<WasmModuleObject> module_object = + WasmModuleObject::New(isolate_, enabled_features_, test_module_, env, {}, + script, Handle<ByteArray>::null()); // This method is called when we initialize TestEnvironment. We don't // have a memory yet, so we won't create it here. We'll update the // interpreter when we get a memory. We do have globals, though. @@ -230,14 +230,18 @@ Handle<WasmInstanceObject> TestingModuleBuilder::InitInstanceObject() { void TestBuildingGraphWithBuilder(compiler::WasmGraphBuilder* builder, Zone* zone, FunctionSig* sig, const byte* start, const byte* end) { + WasmFeatures unused_detected_features; + FunctionBody body(sig, 0, start, end); DecodeResult result = - BuildTFGraph(zone->allocator(), builder, sig, start, end); + BuildTFGraph(zone->allocator(), kAllWasmFeatures, nullptr, builder, + &unused_detected_features, body, nullptr); if (result.failed()) { #ifdef DEBUG if (!FLAG_trace_wasm_decoder) { // Retry the compilation with the tracing flag on, to help in debugging. FLAG_trace_wasm_decoder = true; - result = BuildTFGraph(zone->allocator(), builder, sig, start, end); + result = BuildTFGraph(zone->allocator(), kAllWasmFeatures, nullptr, + builder, &unused_detected_features, body, nullptr); } #endif @@ -398,6 +402,13 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { interpreter_->SetFunctionCodeForTesting(function_, start, end); } + // TODO(wasm): tests that go through JS depend on having a compiled version + // of each function, even if the execution tier is the interpreter. Fix. + auto tier = builder_->execution_tier(); + if (tier == ExecutionTier::kInterpreter) { + tier = ExecutionTier::kOptimized; + } + Vector<const uint8_t> wire_bytes = builder_->instance_object() ->module_object() ->native_module() @@ -416,18 +427,15 @@ void WasmFunctionCompiler::Build(const byte* start, const byte* end) { FunctionBody func_body{function_->sig, function_->code.offset(), func_wire_bytes.start(), func_wire_bytes.end()}; - WasmCompilationUnit::CompilationMode comp_mode = - builder_->execution_mode() == WasmExecutionMode::kExecuteLiftoff - ? WasmCompilationUnit::CompilationMode::kLiftoff - : WasmCompilationUnit::CompilationMode::kTurbofan; NativeModule* native_module = builder_->instance_object()->module_object()->native_module(); - WasmCompilationUnit unit(isolate(), &module_env, native_module, func_body, - func_name, function_->func_index, comp_mode, - isolate()->counters(), builder_->lower_simd()); - unit.ExecuteCompilation(); - wasm::WasmCode* wasm_code = unit.FinishCompilation(&thrower); - if (wasm::WasmCode::ShouldBeLogged(isolate())) { + WasmCompilationUnit unit(isolate()->wasm_engine(), &module_env, native_module, + func_body, func_name, function_->func_index, + isolate()->counters(), tier); + WasmFeatures unused_detected_features; + unit.ExecuteCompilation(&unused_detected_features); + WasmCode* wasm_code = unit.FinishCompilation(&thrower); + if (WasmCode::ShouldBeLogged(isolate())) { wasm_code->LogCode(isolate()); } CHECK(!thrower.error()); diff --git a/deps/v8/test/cctest/wasm/wasm-run-utils.h b/deps/v8/test/cctest/wasm/wasm-run-utils.h index ca1c922dd4..899dc06268 100644 --- a/deps/v8/test/cctest/wasm/wasm-run-utils.h +++ b/deps/v8/test/cctest/wasm/wasm-run-utils.h @@ -33,6 +33,7 @@ #include "src/wasm/wasm-objects-inl.h" #include "src/wasm/wasm-objects.h" #include "src/wasm/wasm-opcodes.h" +#include "src/wasm/wasm-tier.h" #include "src/zone/accounting-allocator.h" #include "src/zone/zone.h" @@ -48,14 +49,6 @@ namespace wasm { constexpr uint32_t kMaxFunctions = 10; constexpr uint32_t kMaxGlobalsSize = 128; -enum WasmExecutionMode { - kExecuteInterpreter, - kExecuteTurbofan, - kExecuteLiftoff -}; - -enum LowerSimd : bool { kLowerSimd = true, kNoLowerSimd = false }; - using compiler::CallDescriptor; using compiler::MachineTypeForC; using compiler::Node; @@ -90,7 +83,7 @@ struct ManuallyImportedJSFunction { // the interpreter. class TestingModuleBuilder { public: - TestingModuleBuilder(Zone*, ManuallyImportedJSFunction*, WasmExecutionMode, + TestingModuleBuilder(Zone*, ManuallyImportedJSFunction*, ExecutionTier, RuntimeExceptionSupport, LowerSimd); void ChangeOriginToAsmjs() { test_module_->origin = kAsmJsOrigin; } @@ -203,7 +196,7 @@ class TestingModuleBuilder { Handle<WasmInstanceObject> instance_object() const { return instance_object_; } - wasm::WasmCode* GetFunctionCode(uint32_t index) const { + WasmCode* GetFunctionCode(uint32_t index) const { return native_module_->code(index); } Address globals_start() const { @@ -217,7 +210,7 @@ class TestingModuleBuilder { ModuleEnv CreateModuleEnv(); - WasmExecutionMode execution_mode() const { return execution_mode_; } + ExecutionTier execution_tier() const { return execution_tier_; } RuntimeExceptionSupport runtime_exception_support() const { return runtime_exception_support_; @@ -227,12 +220,13 @@ class TestingModuleBuilder { std::shared_ptr<WasmModule> test_module_; WasmModule* test_module_ptr_; Isolate* isolate_; + WasmFeatures enabled_features_; uint32_t global_offset = 0; byte* mem_start_ = nullptr; uint32_t mem_size_ = 0; V8_ALIGNED(16) byte globals_data_[kMaxGlobalsSize]; WasmInterpreter* interpreter_ = nullptr; - WasmExecutionMode execution_mode_; + ExecutionTier execution_tier_; Handle<WasmInstanceObject> instance_object_; NativeModule* native_module_ = nullptr; bool linked_ = false; @@ -265,7 +259,7 @@ class WasmFunctionWrapper : private compiler::GraphAndBuilders { Init(call_descriptor, MachineTypeForC<ReturnType>(), param_vec); } - void SetInnerCode(wasm::WasmCode* code) { + void SetInnerCode(WasmCode* code) { intptr_t address = static_cast<intptr_t>(code->instruction_start()); compiler::NodeProperties::ChangeOp( inner_code_node_, @@ -347,11 +341,11 @@ class WasmFunctionCompiler : public compiler::GraphAndBuilders { class WasmRunnerBase : public HandleAndZoneScope { public: WasmRunnerBase(ManuallyImportedJSFunction* maybe_import, - WasmExecutionMode execution_mode, int num_params, + ExecutionTier execution_tier, int num_params, RuntimeExceptionSupport runtime_exception_support, LowerSimd lower_simd) : zone_(&allocator_, ZONE_NAME), - builder_(&zone_, maybe_import, execution_mode, + builder_(&zone_, maybe_import, execution_tier, runtime_exception_support, lower_simd), wrapper_(&zone_, num_params) {} @@ -428,13 +422,13 @@ class WasmRunnerBase : public HandleAndZoneScope { template <typename ReturnType, typename... ParamTypes> class WasmRunner : public WasmRunnerBase { public: - WasmRunner(WasmExecutionMode execution_mode, + WasmRunner(ExecutionTier execution_tier, ManuallyImportedJSFunction* maybe_import = nullptr, const char* main_fn_name = "main", RuntimeExceptionSupport runtime_exception_support = kNoRuntimeExceptionSupport, LowerSimd lower_simd = kNoLowerSimd) - : WasmRunnerBase(maybe_import, execution_mode, sizeof...(ParamTypes), + : WasmRunnerBase(maybe_import, execution_tier, sizeof...(ParamTypes), runtime_exception_support, lower_simd) { NewFunction<ReturnType, ParamTypes...>(main_fn_name); if (!interpret()) { @@ -442,8 +436,8 @@ class WasmRunner : public WasmRunnerBase { } } - WasmRunner(WasmExecutionMode execution_mode, LowerSimd lower_simd) - : WasmRunner(execution_mode, nullptr, "main", kNoRuntimeExceptionSupport, + WasmRunner(ExecutionTier execution_tier, LowerSimd lower_simd) + : WasmRunner(execution_tier, nullptr, "main", kNoRuntimeExceptionSupport, lower_simd) {} ReturnType Call(ParamTypes... p) { @@ -501,18 +495,20 @@ class WasmRunner : public WasmRunnerBase { }; // A macro to define tests that run in different engine configurations. -#define WASM_EXEC_TEST(name) \ - void RunWasm_##name(WasmExecutionMode execution_mode); \ - TEST(RunWasmTurbofan_##name) { RunWasm_##name(kExecuteTurbofan); } \ - TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \ - TEST(RunWasmInterpreter_##name) { RunWasm_##name(kExecuteInterpreter); } \ - void RunWasm_##name(WasmExecutionMode execution_mode) - -#define WASM_COMPILED_EXEC_TEST(name) \ - void RunWasm_##name(WasmExecutionMode execution_mode); \ - TEST(RunWasmTurbofan_##name) { RunWasm_##name(kExecuteTurbofan); } \ - TEST(RunWasmLiftoff_##name) { RunWasm_##name(kExecuteLiftoff); } \ - void RunWasm_##name(WasmExecutionMode execution_mode) +#define WASM_EXEC_TEST(name) \ + void RunWasm_##name(ExecutionTier execution_tier); \ + TEST(RunWasmTurbofan_##name) { RunWasm_##name(ExecutionTier::kOptimized); } \ + TEST(RunWasmLiftoff_##name) { RunWasm_##name(ExecutionTier::kBaseline); } \ + TEST(RunWasmInterpreter_##name) { \ + RunWasm_##name(ExecutionTier::kInterpreter); \ + } \ + void RunWasm_##name(ExecutionTier execution_tier) + +#define WASM_COMPILED_EXEC_TEST(name) \ + void RunWasm_##name(ExecutionTier execution_tier); \ + TEST(RunWasmTurbofan_##name) { RunWasm_##name(ExecutionTier::kOptimized); } \ + TEST(RunWasmLiftoff_##name) { RunWasm_##name(ExecutionTier::kBaseline); } \ + void RunWasm_##name(ExecutionTier execution_tier) } // namespace wasm } // namespace internal |